Fix text & fromattedText failing tests

This commit is contained in:
Rossen Hristov
2017-01-12 14:12:41 +02:00
parent eede9c2888
commit cc337094e9
6 changed files with 15 additions and 20 deletions

View File

@ -330,7 +330,7 @@ export class TabViewTest extends testModule.UITest<tabViewModule.TabView> {
assertFontsAreEqual(tabViewTestsNative.getNativeFont(this.testView), nativeFont, "Font must be bold 12 monospace after rebinding items.");
//console.log(`>>>>>>>>>>>>> nativeFont: ${fontToString(nativeFont)}`);
console.log(`>>>>>>>>>>>>> RESET`);
//console.log(`>>>>>>>>>>>>> RESET`);
this.testView.style.font = unsetValue;
assertFontsAreEqual(tabViewTestsNative.getNativeFont(this.testView), originalFont, "Font must be the original one after resetting the style.");
}

View File

@ -700,8 +700,8 @@ export function test_parseSpansDirectlyOnLabel() {
function testAction(views: Array<viewModule.View>) {
var page = <Page>views[0];
var testLabel = <Label>page.getViewById("testLabel");
TKUnit.assertEqual(testLabel.formattedText + "", "We areAwesome", "Formatted string should be set");
TKUnit.assertEqual(testLabel.text + "", "We areAwesome", "Formatted string should be set");
TKUnit.assertEqual(testLabel.formattedText + "", "We areAwesome", "formattedText");
TKUnit.assertEqual(testLabel.text + "", "We areAwesome", "text");
}
helper.navigate(function () { return p; });
@ -713,8 +713,8 @@ export function test_parseSpansDirectlyOnButton() {
function testAction(views: Array<viewModule.View>) {
var page = <Page>views[0];
var testButton = <Button>page.getViewById("testButton");
TKUnit.assertEqual(testButton.formattedText + "", "We areAwesome", "Formatted string should be set");
TKUnit.assertEqual(testButton.text + "", "We areAwesome", "Formatted string should be set");
TKUnit.assertEqual(testButton.formattedText + "", "We areAwesome", "formattedText");
TKUnit.assertEqual(testButton.text + "", "We areAwesome", "text");
}
helper.navigate(function () { return p; });
@ -726,8 +726,8 @@ export function test_parseFormattedStringWithoutFormattedText() {
function testAction(views: Array<viewModule.View>) {
var page = <Page>views[0];
var testButton = <Button>page.getViewById("testButton");
TKUnit.assertEqual(testButton.formattedText + "", "author num_comments", "Formatted string should be set");
TKUnit.assertEqual(testButton.text + "", "author num_comments", "Formatted string should be set");
TKUnit.assertEqual(testButton.formattedText + "", "author num_comments", "formattedText");
TKUnit.assertEqual(testButton.text + "", "author num_comments", "text");
}
helper.navigate(function () { return p; });
@ -739,8 +739,8 @@ export function test_parseFormattedStringFullSyntax() {
function testAction(views: Array<viewModule.View>) {
var page = <Page>views[0];
var testButton = <Button>page.getViewById("testButton");
TKUnit.assertEqual(testButton.formattedText + "", "author num_comments", "Formatted string should be set");
TKUnit.assertEqual(testButton.text + "", "author num_comments", "Formatted string should be set");
TKUnit.assertEqual(testButton.formattedText + "", "author num_comments", "formattedText");
TKUnit.assertEqual(testButton.text + "", "author num_comments", "text");
}
helper.navigate(function () { return p; });
@ -752,8 +752,8 @@ export function test_parseSpansDirectlyToFormattedString() {
function testAction(views: Array<viewModule.View>) {
var page = <Page>views[0];
var testButton = <Button>page.getViewById("testButton");
TKUnit.assertEqual(testButton.formattedText + "", "author num_comments", "Formatted string should be set");
TKUnit.assertEqual(testButton.text + "", "author num_comments", "Formatted string should be set");
TKUnit.assertEqual(testButton.formattedText + "", "author num_comments", "formattedText");
TKUnit.assertEqual(testButton.text + "", "author num_comments", "text");
}
helper.navigate(function () { return p; });

View File

@ -28,6 +28,7 @@ export class TextBase extends TextBaseCommon {
let spannableStringBuilder = createSpannableStringBuilder(value);
const text = (spannableStringBuilder === null || spannableStringBuilder === undefined) ? '' : <any>spannableStringBuilder;
this._nativeView.setText(text);
textProperty.nativeValueChange(this, (value === null || value === undefined) ? '' : value.toString());
if (spannableStringBuilder && this._nativeView instanceof android.widget.Button &&
!(this._nativeView.getTransformationMethod() instanceof TextTransformation)){

View File

@ -49,9 +49,11 @@ export class TextBase extends TextBaseCommon {
let nativeView = this.nativeView;
if (nativeView instanceof UIButton) {
nativeView.setAttributedTitleForState(mas, UIControlState.Normal);
} else {
}
else {
nativeView.attributedText = mas;
}
textProperty.nativeValueChange(this, (value === null || value === undefined) ? '' : value.toString());
}
//Color

View File

@ -40,10 +40,6 @@ class UITextFieldDelegateImpl extends NSObject implements UITextFieldDelegate {
}
owner.dismissSoftInput();
// if (owner.formattedText) {
// formattedTextProperty.nativeValueChange(owner, textField.attributedText);
// }
}
}

View File

@ -39,10 +39,6 @@ class UITextViewDelegateImpl extends NSObject implements UITextViewDelegate {
owner.dismissSoftInput();
owner._refreshHintState(owner.hint, textView.text);
// if (owner.formattedText) {
// formattedTextProperty.nativeValueChange(owner, textView.attributedText);
// }
}
}