tests added

This commit is contained in:
Vladimir Enchev
2015-10-22 10:42:20 +03:00
parent 433bc020ad
commit 5b543deec4
2 changed files with 32 additions and 5 deletions

View File

@ -3,6 +3,8 @@ import helper = require("../helper");
import viewModule = require("ui/core/view");
import bindable = require("ui/core/bindable");
import observable = require("data/observable");
import color = require("color");
import platform = require("platform");
// <snippet module="ui/switch" title="switch">
// # Switch
// Using a switch requires the Switch module.
@ -51,6 +53,31 @@ export function test_default_native_values() {
helper.buildUIAndRunTest(mySwitch, testAction);
}
// Uncomment this when find way to check android Drawable color set by setColorFilter() method.
if (platform.device.os === platform.platformNames.ios) {
exports.test_set_color = function () {
var mySwitch = new switchModule.Switch();
mySwitch.color = new color.Color("red");
function testAction(views: Array<viewModule.View>) {
TKUnit.assert(mySwitch.color.ios.isEqual(mySwitch.ios.thumbTintColor), "mySwitch.color");
};
helper.buildUIAndRunTest(mySwitch, testAction);
}
exports.test_set_backgroundColor = function () {
var mySwitch = new switchModule.Switch();
mySwitch.backgroundColor = new color.Color("red");
function testAction(views: Array<viewModule.View>) {
TKUnit.assert(CGColorEqualToColor(mySwitch.backgroundColor.ios.CGColor, mySwitch.ios.onTintColor.CGColor), "mySwitch.color");
};
helper.buildUIAndRunTest(mySwitch, testAction);
}
}
export function test_set_TNS_checked_updates_native_checked() {
var mySwitch = new switchModule.Switch();
function testAction(views: Array<viewModule.View>) {

View File

@ -442,12 +442,12 @@ export class ProgressStyler implements definition.stylers.Styler {
export class SwitchStyler implements definition.stylers.Styler {
private static setColorProperty(view: view.View, newValue: any) {
var sw = <UISwitch>view.ios;
sw.thumbTintColor = UIColor.alloc().initWithCGColor((<UIColor>newValue).CGColor);
sw.thumbTintColor = newValue;
}
private static resetColorProperty(view: view.View, nativeValue: any) {
var sw = <UISwitch>view.ios;
sw.thumbTintColor = UIColor.alloc().initWithCGColor((<UIColor>nativeValue).CGColor);
sw.thumbTintColor = nativeValue;
}
private static getNativeColorValue(view: view.View): any {
@ -457,17 +457,17 @@ export class SwitchStyler implements definition.stylers.Styler {
private static setBackgroundColorProperty(view: view.View, newValue: any) {
var sw = <UISwitch>view.ios;
sw.tintColor = UIColor.alloc().initWithCGColor((<UIColor>newValue).CGColor);
sw.onTintColor = view.backgroundColor.ios;
}
private static resetBackgroundColorProperty(view: view.View, nativeValue: any) {
var sw = <UISwitch>view.ios;
sw.tintColor = UIColor.alloc().initWithCGColor((<UIColor>nativeValue).CGColor);
sw.onTintColor = nativeValue;
}
private static getBackgroundColorProperty(view: view.View): any {
var sw = <UISwitch>view.ios;
return sw.tintColor;
return sw.onTintColor;
}
public static registerHandlers() {