Added pressed, active and disabled states for button.

This commit is contained in:
Nedyalko Nikolov
2016-10-21 14:26:37 +03:00
parent 8d178754a2
commit a63f46ee83
4 changed files with 94 additions and 7 deletions

View File

@@ -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];

View File

@@ -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);
});
}