mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-11-05 13:26:48 +08:00
Added pressed, active and disabled states for button.
This commit is contained in:
@@ -258,6 +258,48 @@ export var testNativeTextAlignmentFromCss = function () {
|
||||
});
|
||||
}
|
||||
|
||||
export var test_StateHighlighted_also_fires_pressedState = function () {
|
||||
helper.buildUIAndRunTest(_createButtonFunc(), function (views: Array<viewModule.View>) {
|
||||
var view = <buttonModule.Button>views[0];
|
||||
var page = <pagesModule.Page>views[1];
|
||||
var expectedColor = "#ffff0000";
|
||||
page.css = "button:pressed { background-color: " + expectedColor + "; }";
|
||||
|
||||
view._goToVisualState('highlighted');
|
||||
|
||||
var actualResult = buttonTestsNative.getNativeBackgroundColor(view);
|
||||
TKUnit.assert(actualResult.hex === expectedColor, "Actual: " + actualResult.hex + "; Expected: " + expectedColor);
|
||||
});
|
||||
}
|
||||
|
||||
export var test_StateHighlighted_also_fires_activeState = function () {
|
||||
helper.buildUIAndRunTest(_createButtonFunc(), function (views: Array<viewModule.View>) {
|
||||
var view = <buttonModule.Button>views[0];
|
||||
var page = <pagesModule.Page>views[1];
|
||||
var expectedColor = "#ffff0000";
|
||||
page.css = "button:active { background-color: " + expectedColor + "; }";
|
||||
|
||||
view._goToVisualState('highlighted');
|
||||
|
||||
var actualResult = buttonTestsNative.getNativeBackgroundColor(view);
|
||||
TKUnit.assert(actualResult.hex === expectedColor, "Actual: " + actualResult.hex + "; Expected: " + expectedColor);
|
||||
});
|
||||
}
|
||||
|
||||
export var test_applying_disabled_visual_State_when_button_is_disable = function () {
|
||||
helper.buildUIAndRunTest(_createButtonFunc(), function (views: Array<viewModule.View>) {
|
||||
var view = <buttonModule.Button>views[0];
|
||||
var page = <pagesModule.Page>views[1];
|
||||
var expectedColor = "#ffff0000";
|
||||
page.css = "button:disabled { background-color: " + expectedColor + "; }";
|
||||
|
||||
view.isEnabled = false;
|
||||
|
||||
var actualResult = buttonTestsNative.getNativeBackgroundColor(view);
|
||||
TKUnit.assert(actualResult.hex === expectedColor, "Actual: " + actualResult.hex + "; Expected: " + expectedColor);
|
||||
});
|
||||
}
|
||||
|
||||
export var testNativeTextAlignmentFromLocal = function () {
|
||||
helper.buildUIAndRunTest(_createButtonFunc(), function (views: Array<viewModule.View>) {
|
||||
var view = <buttonModule.Button>views[0];
|
||||
|
||||
Reference in New Issue
Block a user