mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-08-15 19:26:42 +08:00
Merge pull request #1533 from NativeScript/label-null
Fixed null and undefined as Label text
This commit is contained in:
@ -89,6 +89,40 @@ export class LabelTest extends testModule.UITest<LabelModule.Label> {
|
|||||||
TKUnit.assertEqual(actualNative, expectedValue, "Native text not equal");
|
TKUnit.assertEqual(actualNative, expectedValue, "Native text not equal");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public test_Set_Text_Native_Null() {
|
||||||
|
var testLabel = this.testView;
|
||||||
|
var expectedValue = "";
|
||||||
|
|
||||||
|
testLabel.text = null;
|
||||||
|
var actualNative;
|
||||||
|
if (testLabel.ios) {
|
||||||
|
actualNative = testLabel.ios.text;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
this.waitUntilTestElementIsLoaded();
|
||||||
|
actualNative = testLabel.android.getText();
|
||||||
|
}
|
||||||
|
|
||||||
|
TKUnit.assertEqual(actualNative, expectedValue, "Native text not equal");
|
||||||
|
}
|
||||||
|
|
||||||
|
public test_Set_Text_Native_Undefined() {
|
||||||
|
var testLabel = this.testView;
|
||||||
|
var expectedValue = "";
|
||||||
|
|
||||||
|
testLabel.text = undefined;
|
||||||
|
var actualNative;
|
||||||
|
if (testLabel.ios) {
|
||||||
|
actualNative = testLabel.ios.text;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
this.waitUntilTestElementIsLoaded();
|
||||||
|
actualNative = testLabel.android.getText();
|
||||||
|
}
|
||||||
|
|
||||||
|
TKUnit.assertEqual(actualNative, expectedValue, "Native text not equal");
|
||||||
|
}
|
||||||
|
|
||||||
public test_Set_BackgroundColor_TNS() {
|
public test_Set_BackgroundColor_TNS() {
|
||||||
var label = this.testView;
|
var label = this.testView;
|
||||||
var expectedValue = new colorModule.Color("Red");
|
var expectedValue = new colorModule.Color("Red");
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
import definition = require("ui/text-base");
|
import definition = require("ui/text-base");
|
||||||
import view = require("ui/core/view");
|
import view = require("ui/core/view");
|
||||||
|
import types = require("utils/types");
|
||||||
import observable = require("data/observable");
|
import observable = require("data/observable");
|
||||||
import dependencyObservable = require("ui/core/dependency-observable");
|
import dependencyObservable = require("ui/core/dependency-observable");
|
||||||
import proxy = require("ui/core/proxy");
|
import proxy = require("ui/core/proxy");
|
||||||
@ -100,11 +101,12 @@ export class TextBase extends view.View implements definition.TextBase, formatte
|
|||||||
}
|
}
|
||||||
|
|
||||||
public _onTextPropertyChanged(data: dependencyObservable.PropertyChangeData) {
|
public _onTextPropertyChanged(data: dependencyObservable.PropertyChangeData) {
|
||||||
|
var newValue = types.isNullOrUndefined(data.newValue) ? "" : data.newValue + "";
|
||||||
if (this.android) {
|
if (this.android) {
|
||||||
this.android.setText(data.newValue + "");
|
this.android.setText(newValue);
|
||||||
}
|
}
|
||||||
else if (this.ios) {
|
else if (this.ios) {
|
||||||
this.ios.text = data.newValue + "";
|
this.ios.text = newValue;
|
||||||
this.style._updateTextDecoration();
|
this.style._updateTextDecoration();
|
||||||
this.style._updateTextTransform();
|
this.style._updateTextTransform();
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user