mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-11-05 13:26:48 +08:00
textTransform, whiteSpace & textAlignment defaultValue is now “initia” (#3948)
removed enum namespaces add valueConverter to clipToBounds
This commit is contained in:
@@ -36,7 +36,7 @@ export class DockLayoutTest extends testModule.UITest<DockLayout> {
|
||||
var testBtn = new button.Button();
|
||||
|
||||
TKUnit.assertThrows(() => {
|
||||
dockModule.DockLayout.setDock(testBtn, "invalid");
|
||||
dockModule.DockLayout.setDock(testBtn, <"left">"invalid");
|
||||
});
|
||||
}
|
||||
|
||||
@@ -54,7 +54,7 @@ export class DockLayoutTest extends testModule.UITest<DockLayout> {
|
||||
public test_dock_right() {
|
||||
var testBtn = new helper.MyButton();
|
||||
testBtn.width = { value: 20, unit: "px" };
|
||||
dockModule.DockLayout.setDock(testBtn, enums.Dock.right);
|
||||
dockModule.DockLayout.setDock(testBtn, "right");
|
||||
this.testView.stretchLastChild = false;
|
||||
this.testView.addChild(testBtn);
|
||||
|
||||
@@ -66,7 +66,7 @@ export class DockLayoutTest extends testModule.UITest<DockLayout> {
|
||||
public test_dock_top() {
|
||||
var testBtn = new helper.MyButton();
|
||||
testBtn.height = { value: 20, unit: "px" };
|
||||
dockModule.DockLayout.setDock(testBtn, enums.Dock.top);
|
||||
dockModule.DockLayout.setDock(testBtn, "top");
|
||||
this.testView.stretchLastChild = false;
|
||||
this.testView.addChild(testBtn);
|
||||
|
||||
@@ -78,7 +78,7 @@ export class DockLayoutTest extends testModule.UITest<DockLayout> {
|
||||
public test_dock_button() {
|
||||
var testBtn = new helper.MyButton();
|
||||
testBtn.height = { value: 20, unit: "px" };
|
||||
dockModule.DockLayout.setDock(testBtn, enums.Dock.bottom);
|
||||
dockModule.DockLayout.setDock(testBtn, "bottom");
|
||||
this.testView.stretchLastChild = false;
|
||||
this.testView.addChild(testBtn);
|
||||
|
||||
@@ -103,21 +103,21 @@ export class DockLayoutTest extends testModule.UITest<DockLayout> {
|
||||
|
||||
var testBtnTop = new helper.MyButton();
|
||||
testBtnTop.height = { value: 20, unit: "px" };
|
||||
dockModule.DockLayout.setDock(testBtnTop, enums.Dock.top);
|
||||
dockModule.DockLayout.setDock(testBtnTop, "top");
|
||||
this.testView.addChild(testBtnTop);
|
||||
|
||||
var testBtnRight = new helper.MyButton();
|
||||
testBtnRight.width = { value: 20, unit: "px" }
|
||||
dockModule.DockLayout.setDock(testBtnRight, enums.Dock.right);
|
||||
dockModule.DockLayout.setDock(testBtnRight, "right");
|
||||
this.testView.addChild(testBtnRight);
|
||||
|
||||
var testBtnBottom = new helper.MyButton();
|
||||
testBtnBottom.height = { value: 20, unit: "px" }
|
||||
dockModule.DockLayout.setDock(testBtnBottom, enums.Dock.bottom);
|
||||
dockModule.DockLayout.setDock(testBtnBottom, "bottom");
|
||||
this.testView.addChild(testBtnBottom);
|
||||
|
||||
var testBtnFill = new helper.MyButton();
|
||||
dockModule.DockLayout.setDock(testBtnFill, enums.Dock.bottom);
|
||||
dockModule.DockLayout.setDock(testBtnFill, "bottom");
|
||||
this.testView.addChild(testBtnFill);
|
||||
|
||||
this.waitUntilTestElementLayoutIsValid();
|
||||
@@ -159,7 +159,7 @@ export class DockLayoutTest extends testModule.UITest<DockLayout> {
|
||||
|
||||
// >> dock-layout-setdocl
|
||||
var btnDockedToRight = new button.Button();
|
||||
dockModule.DockLayout.setDock(btnDockedToRight, enums.Dock.right);
|
||||
dockModule.DockLayout.setDock(btnDockedToRight, "right");
|
||||
dockLayout.addChild(btnDockedToRight);
|
||||
// << dock-layout-setdocl
|
||||
}
|
||||
|
||||
@@ -1,15 +1,54 @@
|
||||
// >> flexbox-layout-require
|
||||
import {
|
||||
FlexboxLayout,
|
||||
FlexDirection,
|
||||
FlexWrap,
|
||||
JustifyContent,
|
||||
AlignItems,
|
||||
AlignContent,
|
||||
AlignSelf
|
||||
} from "tns-core-modules/ui/layouts/flexbox-layout";
|
||||
import { FlexboxLayout } from "tns-core-modules/ui/layouts/flexbox-layout";
|
||||
// << flexbox-layout-require
|
||||
|
||||
export namespace FlexDirection {
|
||||
export const ROW: "row" = "row";
|
||||
export const ROW_REVERSE: "row-reverse" = "row-reverse";
|
||||
export const COLUMN: "column" = "column";
|
||||
export const COLUMN_REVERSE: "column-reverse" = "column-reverse";
|
||||
}
|
||||
|
||||
export namespace FlexWrap {
|
||||
export const NOWRAP: "nowrap" = "nowrap";
|
||||
export const WRAP: "wrap" = "wrap";
|
||||
export const WRAP_REVERSE: "wrap-reverse" = "wrap-reverse";
|
||||
}
|
||||
|
||||
export namespace JustifyContent {
|
||||
export const FLEX_START: "flex-start" = "flex-start";
|
||||
export const FLEX_END: "flex-end" = "flex-end";
|
||||
export const CENTER: "center" = "center";
|
||||
export const SPACE_BETWEEN: "space-between" = "space-between";
|
||||
export const SPACE_AROUND: "space-around" = "space-around";
|
||||
}
|
||||
|
||||
export namespace AlignItems {
|
||||
export const FLEX_START: "flex-start" = "flex-start";
|
||||
export const FLEX_END: "flex-end" = "flex-end";
|
||||
export const CENTER: "center" = "center";
|
||||
export const BASELINE: "baseline" = "baseline";
|
||||
export const STRETCH: "stretch" = "stretch";
|
||||
}
|
||||
|
||||
export namespace AlignContent {
|
||||
export const FLEX_START: "flex-start" = "flex-start";
|
||||
export const FLEX_END: "flex-end" = "flex-end";
|
||||
export const CENTER: "center" = "center";
|
||||
export const SPACE_BETWEEN: "space-between" = "space-between";
|
||||
export const SPACE_AROUND: "space-around" = "space-around";
|
||||
export const STRETCH: "stretch" = "stretch";
|
||||
}
|
||||
|
||||
export namespace AlignSelf {
|
||||
export const AUTO: "auto" = "auto";
|
||||
export const FLEX_START: "flex-start" = "flex-start";
|
||||
export const FLEX_END: "flex-end" = "flex-end";
|
||||
export const CENTER: "center" = "center";
|
||||
export const BASELINE: "baseline" = "baseline";
|
||||
export const STRETCH: "stretch" = "stretch";
|
||||
}
|
||||
|
||||
import {View, unsetValue, Length, PercentLength} from "tns-core-modules/ui/core/view";
|
||||
import {Label} from "tns-core-modules/ui/label";
|
||||
import * as TKUnit from "../../TKUnit";
|
||||
|
||||
@@ -1,10 +1,9 @@
|
||||
import * as TKUnit from "../../TKUnit";
|
||||
import * as app from "tns-core-modules/application";
|
||||
import * as button from "tns-core-modules/ui/button";
|
||||
import * as enums from "tns-core-modules/ui/enums";
|
||||
import * as testModule from "../../ui-test";
|
||||
import * as layoutHelper from "../layouts/layout-helper";
|
||||
import {Page} from "tns-core-modules/ui/page";
|
||||
import { Page } from "tns-core-modules/ui/page";
|
||||
import * as frame from "tns-core-modules/ui/frame";
|
||||
|
||||
// >> article-require-scrollview-module
|
||||
@@ -15,7 +14,7 @@ class ScrollLayoutTest extends testModule.UITest<scrollViewModule.ScrollView> {
|
||||
|
||||
public create(): scrollViewModule.ScrollView {
|
||||
let scrollView = new scrollViewModule.ScrollView();
|
||||
scrollView.orientation = enums.Orientation.vertical;
|
||||
scrollView.orientation = "vertical";
|
||||
|
||||
scrollView.width = { value: 200, unit: "px" };
|
||||
scrollView.height = { value: 300, unit: "px" };
|
||||
@@ -38,13 +37,13 @@ class ScrollLayoutTest extends testModule.UITest<scrollViewModule.ScrollView> {
|
||||
|
||||
public test_default_TNS_values() {
|
||||
let scroll = new scrollViewModule.ScrollView();
|
||||
TKUnit.assertEqual(scroll.orientation, enums.Orientation.vertical, "Default this.testView.orientation");
|
||||
TKUnit.assertEqual(scroll.orientation, "vertical", "Default this.testView.orientation");
|
||||
TKUnit.assertEqual(scroll.verticalOffset, 0, "Default this.testView.verticalOffset");
|
||||
TKUnit.assertEqual(scroll.horizontalOffset, 0, "Default this.testView.horizontalOffset");
|
||||
}
|
||||
|
||||
public test_vertical_oriantation_creates_correct_native_view() {
|
||||
this.testView.orientation = enums.Orientation.vertical;
|
||||
this.testView.orientation = "vertical";
|
||||
|
||||
if (app.android) {
|
||||
TKUnit.assert(this.testView.android instanceof org.nativescript.widgets.VerticalScrollView, "android property should be instanceof org.nativescript.widgets.VerticalScrollView");
|
||||
@@ -55,7 +54,7 @@ class ScrollLayoutTest extends testModule.UITest<scrollViewModule.ScrollView> {
|
||||
}
|
||||
|
||||
public test_horizontal_oriantation_creates_correct_native_view() {
|
||||
this.testView.orientation = enums.Orientation.horizontal;
|
||||
this.testView.orientation = "horizontal";
|
||||
|
||||
if (app.android) {
|
||||
TKUnit.assert(this.testView.android instanceof org.nativescript.widgets.HorizontalScrollView, "android property should be instanceof org.nativescript.widgets.HorizontalScrollView");
|
||||
@@ -83,7 +82,7 @@ class ScrollLayoutTest extends testModule.UITest<scrollViewModule.ScrollView> {
|
||||
}
|
||||
|
||||
public test_scrollableWidth_horizontal_orientation_when_content_is_small() {
|
||||
this.testView.orientation = enums.Orientation.horizontal;
|
||||
this.testView.orientation = "horizontal";
|
||||
this.testView.content.width = { value: 100, unit: "px" };
|
||||
this.testView.content.height = { value: 100, unit: "px" };
|
||||
this.waitUntilTestElementLayoutIsValid();
|
||||
@@ -93,7 +92,7 @@ class ScrollLayoutTest extends testModule.UITest<scrollViewModule.ScrollView> {
|
||||
}
|
||||
|
||||
public test_scrollableWidth_horizontal_orientation_when_content_is_big() {
|
||||
this.testView.orientation = enums.Orientation.horizontal;
|
||||
this.testView.orientation = "horizontal";
|
||||
this.testView.content.height = { value: 100, unit: "px" };
|
||||
this.waitUntilTestElementLayoutIsValid();
|
||||
|
||||
@@ -125,7 +124,7 @@ class ScrollLayoutTest extends testModule.UITest<scrollViewModule.ScrollView> {
|
||||
}
|
||||
|
||||
public test_scrollToHorizontalOffset_no_animation() {
|
||||
this.testView.orientation = enums.Orientation.horizontal;
|
||||
this.testView.orientation = "horizontal";
|
||||
this.waitUntilTestElementLayoutIsValid();
|
||||
|
||||
TKUnit.assertEqual(this.testView.horizontalOffset, 0, "this.testView.horizontalOffset");
|
||||
@@ -134,7 +133,7 @@ class ScrollLayoutTest extends testModule.UITest<scrollViewModule.ScrollView> {
|
||||
}
|
||||
|
||||
public test_scrollToHorizontalOffset_with_animation() {
|
||||
this.testView.orientation = enums.Orientation.horizontal;
|
||||
this.testView.orientation = "horizontal";
|
||||
this.waitUntilTestElementLayoutIsValid();
|
||||
|
||||
TKUnit.assertEqual(this.testView.horizontalOffset, 0, "this.testView.horizontalOffset");
|
||||
@@ -173,7 +172,7 @@ class ScrollLayoutTest extends testModule.UITest<scrollViewModule.ScrollView> {
|
||||
}
|
||||
|
||||
public test_scrollView_persistsState_horizontal() {
|
||||
this.testView.orientation = enums.Orientation.horizontal;
|
||||
this.testView.orientation = "horizontal";
|
||||
this.waitUntilTestElementLayoutIsValid();
|
||||
|
||||
this.testView.scrollToHorizontalOffset(layoutHelper.dp(100), false);
|
||||
@@ -211,7 +210,7 @@ class ScrollLayoutTest extends testModule.UITest<scrollViewModule.ScrollView> {
|
||||
}
|
||||
|
||||
public test_scrollView_horizontal_raised_scroll_event() {
|
||||
this.testView.orientation = enums.Orientation.horizontal;
|
||||
this.testView.orientation = "horizontal";
|
||||
|
||||
var scrollX: number;
|
||||
this.testView.on(scrollViewModule.ScrollView.scrollEvent, (args: scrollViewModule.ScrollEventData) => {
|
||||
@@ -240,7 +239,7 @@ class ScrollLayoutTest extends testModule.UITest<scrollViewModule.ScrollView> {
|
||||
}
|
||||
|
||||
public test_scrollView_horizontal_raised_scroll_event_after_loaded() {
|
||||
this.testView.orientation = enums.Orientation.horizontal;
|
||||
this.testView.orientation = "horizontal";
|
||||
this.waitUntilTestElementLayoutIsValid();
|
||||
|
||||
var scrollX: number;
|
||||
|
||||
@@ -610,21 +610,7 @@ function test_native_font(style: "normal" | "italic", weight: "100" | "200" | "3
|
||||
//TODO: If needed add tests for other platforms
|
||||
}
|
||||
|
||||
export const test_setting_button_whiteSpace_normal_sets_native = function () {
|
||||
const testView = new Button();
|
||||
testView.style.whiteSpace = "nowrap";
|
||||
|
||||
helper.buildUIAndRunTest(testView, function (views: Array<View>) {
|
||||
if (isAndroid) {
|
||||
TKUnit.assertEqual((<android.widget.Button>testView.android).getEllipsize(), android.text.TextUtils.TruncateAt.END);
|
||||
} else if (isIOS) {
|
||||
TKUnit.assertEqual((<UIButton>testView.ios).titleLabel.lineBreakMode, NSLineBreakMode.ByTruncatingMiddle);
|
||||
TKUnit.assertEqual((<UIButton>testView.ios).titleLabel.numberOfLines, 1);
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
export const test_setting_label_whiteSpace_normal_sets_native = function () {
|
||||
export function test_setting_label_whiteSpace_nowrap_sets_native() {
|
||||
const testView = new Label();
|
||||
testView.style.whiteSpace = "nowrap";
|
||||
|
||||
@@ -638,21 +624,7 @@ export const test_setting_label_whiteSpace_normal_sets_native = function () {
|
||||
});
|
||||
};
|
||||
|
||||
export const test_setting_button_whiteSpace_nowrap_sets_native = function () {
|
||||
const testView = new Button();
|
||||
testView.style.whiteSpace = "normal";
|
||||
|
||||
helper.buildUIAndRunTest(testView, function (views: Array<View>) {
|
||||
if (isAndroid) {
|
||||
TKUnit.assertNull((<android.widget.Button>testView.android).getEllipsize(), null);
|
||||
} else if (isIOS) {
|
||||
TKUnit.assertEqual((<UIButton>testView.ios).titleLabel.lineBreakMode, NSLineBreakMode.ByWordWrapping);
|
||||
TKUnit.assertEqual((<UIButton>testView.ios).titleLabel.numberOfLines, 0);
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
export const test_setting_label_whiteSpace_nowrap_sets_native = function () {
|
||||
export function test_setting_label_whiteSpace_normal_sets_native() {
|
||||
const testView = new Label();
|
||||
testView.style.whiteSpace = "normal";
|
||||
|
||||
@@ -666,6 +638,34 @@ export const test_setting_label_whiteSpace_nowrap_sets_native = function () {
|
||||
});
|
||||
};
|
||||
|
||||
export function test_setting_button_whiteSpace_nowrap_sets_native() {
|
||||
const testView = new Button();
|
||||
testView.style.whiteSpace = "nowrap";
|
||||
|
||||
helper.buildUIAndRunTest(testView, function (views: Array<View>) {
|
||||
if (isAndroid) {
|
||||
TKUnit.assertEqual((<android.widget.Button>testView.android).getEllipsize(), android.text.TextUtils.TruncateAt.END);
|
||||
} else if (isIOS) {
|
||||
TKUnit.assertEqual((<UIButton>testView.ios).titleLabel.lineBreakMode, NSLineBreakMode.ByTruncatingMiddle);
|
||||
TKUnit.assertEqual((<UIButton>testView.ios).titleLabel.numberOfLines, 1);
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
export function test_setting_button_whiteSpace_normal_sets_native() {
|
||||
const testView = new Button();
|
||||
testView.style.whiteSpace = "normal";
|
||||
|
||||
helper.buildUIAndRunTest(testView, function (views: Array<View>) {
|
||||
if (isAndroid) {
|
||||
TKUnit.assertNull((<android.widget.Button>testView.android).getEllipsize(), null);
|
||||
} else if (isIOS) {
|
||||
TKUnit.assertEqual((<UIButton>testView.ios).titleLabel.lineBreakMode, NSLineBreakMode.ByWordWrapping);
|
||||
TKUnit.assertEqual((<UIButton>testView.ios).titleLabel.numberOfLines, 0);
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
const initial = "text Text";
|
||||
const capitalized = "Text Text";
|
||||
const upper = "TEXT TEXT";
|
||||
|
||||
@@ -4,7 +4,6 @@ import * as viewModule from "tns-core-modules/ui/core/view";
|
||||
import * as pagesModule from "tns-core-modules/ui/page";
|
||||
import * as textFieldTestsNative from "./text-field-tests-native";
|
||||
import * as colorModule from "tns-core-modules/color";
|
||||
import * as enums from "tns-core-modules/ui/enums";
|
||||
import * as platform from "tns-core-modules/platform";
|
||||
import * as formattedStringModule from "tns-core-modules/text/formatted-string";
|
||||
import * as spanModule from "tns-core-modules/text/span";
|
||||
@@ -542,15 +541,15 @@ export function test_IntegrationTest_Transform_Decoration_Spacing_WithoutFormatt
|
||||
let view = new textFieldModule.TextField();
|
||||
helper.buildUIAndRunTest(view, function (views: Array<viewModule.View>) {
|
||||
TKUnit.assertEqual(view.text, "", "Text");
|
||||
TKUnit.assertNull(view.style.textTransform, "TextTransform default value");
|
||||
TKUnit.assertEqual(view.style.textDecoration, enums.TextDecoration.none, "TextDecoration default value");
|
||||
TKUnit.assertEqual(view.style.textTransform, "initial", "TextTransform default value");
|
||||
TKUnit.assertEqual(view.style.textDecoration, "none", "TextDecoration default value");
|
||||
TKUnit.assertTrue(view.style.letterSpacing === 0, "LetterSpacing default value");
|
||||
|
||||
view.text = "NormalText";
|
||||
view.setInlineStyle("text-transform: uppercase; text-decoration: underline; letter-spacing: 1;");
|
||||
|
||||
TKUnit.assertEqual(view.style.textTransform, enums.TextTransform.uppercase, "TextTransform");
|
||||
TKUnit.assertEqual(view.style.textDecoration, enums.TextDecoration.underline, "TextDecoration");
|
||||
TKUnit.assertEqual(view.style.textTransform, "uppercase", "TextTransform");
|
||||
TKUnit.assertEqual(view.style.textDecoration, "underline", "TextDecoration");
|
||||
TKUnit.assertEqual(view.style.letterSpacing, 1, "LetterSpacing");
|
||||
});
|
||||
}
|
||||
@@ -562,8 +561,8 @@ export function test_IntegrationTest_Transform_Decoration_Spacing_WithFormattedT
|
||||
view.formattedText = formattedString;
|
||||
view.setInlineStyle("text-transform: uppercase; text-decoration: underline; letter-spacing: 1;");
|
||||
|
||||
TKUnit.assertEqual(view.style.textTransform, enums.TextTransform.uppercase, "TextTransform");
|
||||
TKUnit.assertEqual(view.style.textDecoration, enums.TextDecoration.underline, "TextDecoration");
|
||||
TKUnit.assertEqual(view.style.textTransform, "uppercase", "TextTransform");
|
||||
TKUnit.assertEqual(view.style.textDecoration, "underline", "TextDecoration");
|
||||
TKUnit.assertEqual(view.style.letterSpacing, 1, "LetterSpacing");
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user