mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-08-17 21:01:34 +08:00
Another test fix
This commit is contained in:
@ -25,6 +25,7 @@ import textBase = require("ui/text-base");
|
||||
import enums = require("ui/enums");
|
||||
import labelTestsNative = require("./label-tests-native");
|
||||
import fs = require("file-system");
|
||||
import background = require("ui/styling/background");
|
||||
|
||||
export class LabelTest extends testModule.UITest<LabelModule.Label> {
|
||||
|
||||
@ -32,13 +33,13 @@ export class LabelTest extends testModule.UITest<LabelModule.Label> {
|
||||
var label = new LabelModule.Label();
|
||||
label.text = "Label";
|
||||
return label;
|
||||
}
|
||||
}
|
||||
|
||||
public test_Label_Members() {
|
||||
var label = new LabelModule.Label();
|
||||
TKUnit.assert(types.isDefined(label.text), "Label.text is not defined");
|
||||
TKUnit.assert(types.isDefined(label.textWrap), "Label.textWrap is not defined");
|
||||
}
|
||||
}
|
||||
|
||||
public snippet_Set_Text_TNS() {
|
||||
// <snippet module="ui/label" title="Label">
|
||||
@ -49,7 +50,7 @@ export class LabelTest extends testModule.UITest<LabelModule.Label> {
|
||||
label.text = expectedValue;
|
||||
// ```
|
||||
// </snippet>
|
||||
}
|
||||
}
|
||||
|
||||
public snippet_Set_TextWrap_TNS() {
|
||||
// <snippet module="ui/label" title="Label">
|
||||
@ -85,7 +86,7 @@ export class LabelTest extends testModule.UITest<LabelModule.Label> {
|
||||
}
|
||||
|
||||
TKUnit.assertEqual(actualNative, expectedValue, "Native text not equal");
|
||||
}
|
||||
}
|
||||
|
||||
public test_measuredWidth_is_not_clipped() {
|
||||
var label = this.testView;
|
||||
@ -109,7 +110,7 @@ export class LabelTest extends testModule.UITest<LabelModule.Label> {
|
||||
|
||||
var actual = label._getValue(LabelModule.Label.textWrapProperty);
|
||||
TKUnit.assertEqual(actual, true);
|
||||
}
|
||||
}
|
||||
|
||||
public test_Set_TextWrap_Native() {
|
||||
var testLabel = this.testView;
|
||||
@ -178,7 +179,7 @@ export class LabelTest extends testModule.UITest<LabelModule.Label> {
|
||||
}
|
||||
|
||||
TKUnit.assertEqual(actualLinesNumber, expectedLinesNumber, "LinesNumber");
|
||||
}
|
||||
}
|
||||
|
||||
public test_SetStyleProperties_via_css_class_Native() {
|
||||
var label = this.testView;
|
||||
@ -223,7 +224,8 @@ export class LabelTest extends testModule.UITest<LabelModule.Label> {
|
||||
normalColor = actualColors.getDefaultColor()
|
||||
TKUnit.assert(normalColor, "Expected: " + expColor + ", Actual: " + normalColor);
|
||||
|
||||
actualBackgroundColor = (<any>testLabel.android.getBackground()).backgroundColor;
|
||||
var bkg = (<background.ad.BorderDrawable>testLabel.android.getBackground());
|
||||
actualBackgroundColor = bkg.background.color.android;
|
||||
expBackgroundColor = android.graphics.Color.parseColor(backgroundColor);
|
||||
TKUnit.assertEqual(actualBackgroundColor, expBackgroundColor);
|
||||
}
|
||||
@ -307,7 +309,7 @@ export class LabelTest extends testModule.UITest<LabelModule.Label> {
|
||||
|
||||
var actualFontSize = label.style.fontSize;
|
||||
TKUnit.assertEqual(fontSize, actualFontSize);
|
||||
}
|
||||
}
|
||||
|
||||
public test_BindingToText() {
|
||||
// <snippet module="ui/label" title="Label">
|
||||
@ -327,7 +329,7 @@ export class LabelTest extends testModule.UITest<LabelModule.Label> {
|
||||
// </snippet>
|
||||
|
||||
TKUnit.assertEqual(label.text, expValue);
|
||||
}
|
||||
}
|
||||
|
||||
public test_BindingToText_Native() {
|
||||
var label = this.testView;
|
||||
@ -351,7 +353,7 @@ export class LabelTest extends testModule.UITest<LabelModule.Label> {
|
||||
}
|
||||
|
||||
TKUnit.assertEqual(actualNative, expValue);
|
||||
}
|
||||
}
|
||||
|
||||
public test_BindingToText_WithBindingContext() {
|
||||
var label = this.testView;
|
||||
@ -375,7 +377,7 @@ export class LabelTest extends testModule.UITest<LabelModule.Label> {
|
||||
this.testPage.bindingContext = secondSourceObject;
|
||||
|
||||
TKUnit.assertEqual(label.text, secondExpValue);
|
||||
}
|
||||
}
|
||||
|
||||
public test_BindingToText_BindingContext_SetingLocalValue() {
|
||||
var label = this.testView;
|
||||
@ -400,7 +402,7 @@ export class LabelTest extends testModule.UITest<LabelModule.Label> {
|
||||
firstSourceObject.set("sourceProperty", "some value");
|
||||
// after setting a value one way binding should be gone.
|
||||
TKUnit.assertEqual(label.text, secondExpValue);
|
||||
}
|
||||
}
|
||||
|
||||
private expectedTextAlignment = enums.TextAlignment.right;
|
||||
public testLocalTextAlignmentFromCss() {
|
||||
@ -408,7 +410,7 @@ export class LabelTest extends testModule.UITest<LabelModule.Label> {
|
||||
this.testPage.css = "label { text-align: " + this.expectedTextAlignment + "; }";
|
||||
this.waitUntilTestElementIsLoaded();
|
||||
TKUnit.assertEqual(label.style.textAlignment, this.expectedTextAlignment);
|
||||
}
|
||||
}
|
||||
|
||||
public testLocalTextAlignmentFromCssWhenAddingCss() {
|
||||
var view = this.testView;
|
||||
@ -421,7 +423,7 @@ export class LabelTest extends testModule.UITest<LabelModule.Label> {
|
||||
|
||||
page.addCss("label { text-align: " + enums.TextAlignment.left + "; }");
|
||||
TKUnit.assertEqual(view.style.textAlignment, view.style.textAlignment);
|
||||
}
|
||||
}
|
||||
|
||||
public testLocalTextAlignmentFromCssWhenAddingCssAllSelectorsAreApplied() {
|
||||
var view = this.testView;
|
||||
@ -435,7 +437,7 @@ export class LabelTest extends testModule.UITest<LabelModule.Label> {
|
||||
var actualResult = view.style.textAlignment;
|
||||
// actual result is taken from #testLabel tag, because it has a greater priority (id vs type).
|
||||
TKUnit.assertEqual(actualResult, this.expectedTextAlignment);
|
||||
}
|
||||
}
|
||||
|
||||
public testLocalTextAlignmentFromCssWhenAddingCssFileAllSelectorsAreApplied() {
|
||||
var view = this.testView;
|
||||
@ -450,7 +452,7 @@ export class LabelTest extends testModule.UITest<LabelModule.Label> {
|
||||
// actual result is taken from #testLabel tag, because it has a greater priority (id vs type).
|
||||
TKUnit.assertEqual(actualResult, this.expectedTextAlignment);
|
||||
TKUnit.assertEqual(view.style.backgroundColor.hex, "#FF0000");
|
||||
}
|
||||
}
|
||||
|
||||
public testNativeTextAlignmentFromCss() {
|
||||
var view = this.testView;
|
||||
@ -460,7 +462,7 @@ export class LabelTest extends testModule.UITest<LabelModule.Label> {
|
||||
page.css = "label { text-align: " + this.expectedTextAlignment + "; }";
|
||||
var actualResult = labelTestsNative.getNativeTextAlignment(view);
|
||||
TKUnit.assert(actualResult, this.expectedTextAlignment);
|
||||
}
|
||||
}
|
||||
|
||||
public testNativeTextAlignmentFromLocal() {
|
||||
var view = this.testView;
|
||||
@ -470,7 +472,7 @@ export class LabelTest extends testModule.UITest<LabelModule.Label> {
|
||||
|
||||
var actualResult = labelTestsNative.getNativeTextAlignment(view);
|
||||
TKUnit.assertEqual(actualResult, this.expectedTextAlignment);
|
||||
}
|
||||
}
|
||||
|
||||
public testErrorMessageWhenWrongCssIsAddedWithFile() {
|
||||
var view = this.testView;
|
||||
|
Reference in New Issue
Block a user