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];
|
||||
|
||||
@@ -23,6 +23,7 @@ import {Label} from "ui/label";
|
||||
import {LayoutBase} from "ui/layouts/layout-base";
|
||||
import * as helper from "../helper";
|
||||
import viewModule = require("ui/core/view");
|
||||
import {Page} from "ui/page";
|
||||
|
||||
export class LabelTest extends testModule.UITest<LabelModule.Label> {
|
||||
|
||||
@@ -666,3 +667,18 @@ export function test_IntegrationTest_Transform_Decoration_Spacing_WithFormattedT
|
||||
TKUnit.assertEqual(view.style.letterSpacing, 1, "LetterSpacing");
|
||||
});
|
||||
}
|
||||
|
||||
export var test_applying_disabled_visual_State_when_label_is_disable = function () {
|
||||
let view = new Label();
|
||||
helper.buildUIAndRunTest(view, function (views: Array<viewModule.View>) {
|
||||
var view = <Label>views[0];
|
||||
var page = <Page>views[1];
|
||||
var expectedColor = "#ffff0000";
|
||||
page.css = "label:disabled { background-color: " + expectedColor + "; }";
|
||||
|
||||
view.isEnabled = false;
|
||||
|
||||
var actualResult = labelTestsNative.getNativeBackgroundColor(view);
|
||||
TKUnit.assert(actualResult.hex === expectedColor, "Actual: " + actualResult.hex + "; Expected: " + expectedColor);
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user