Skip to content

Commit f350f71

Browse files
author
Hristo Hristov
authored
textTransform, whiteSpace & textAlignment defaultValue is now “initia” (#3948)
removed enum namespaces add valueConverter to clipToBounds
1 parent 2c74f93 commit f350f71

31 files changed

+358
-634
lines changed
Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
import { EventData, TextBase, TextDecoration } from "tns-core-modules/ui/text-base";
22

33
const possibleValues = [
4-
TextDecoration.NONE,
5-
TextDecoration.UNDERLINE,
6-
TextDecoration.LINE_THROUGH,
7-
TextDecoration.UNDERLINE_LINE_THROUGH
4+
"none",
5+
"underline",
6+
"line-through",
7+
"underline line-through"
88
];
99

1010
export function butonTap(args: EventData) {
@@ -13,19 +13,19 @@ export function butonTap(args: EventData) {
1313
let btn = <TextBase>page.getViewById("Button");
1414
let textField = <TextBase>page.getViewById("TextField");
1515
let textView = <TextBase>page.getViewById("TextView");
16-
16+
1717
let currentIndex = possibleValues.indexOf(lbl.textDecoration);
1818
let newIndex = (currentIndex + 1) % possibleValues.length;
1919
let newValue = <TextDecoration>possibleValues[newIndex];
20-
20+
2121
lbl.textDecoration = newValue;
2222
btn.textDecoration = newValue;
2323
textField.textDecoration = newValue;
2424
textView.textDecoration = newValue;
2525

26-
if(lbl.text === "Change text") {
26+
if (lbl.text === "Change text") {
2727
lbl.text = btn.text = textField.text = textView.text = "Text changed";
2828
} else {
2929
lbl.text = btn.text = textField.text = textView.text = "Change text";
3030
}
31-
}
31+
}

tests/app/ui/layouts/dock-layout-tests.ts

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ export class DockLayoutTest extends testModule.UITest<DockLayout> {
3636
var testBtn = new button.Button();
3737

3838
TKUnit.assertThrows(() => {
39-
dockModule.DockLayout.setDock(testBtn, "invalid");
39+
dockModule.DockLayout.setDock(testBtn, <"left">"invalid");
4040
});
4141
}
4242

@@ -54,7 +54,7 @@ export class DockLayoutTest extends testModule.UITest<DockLayout> {
5454
public test_dock_right() {
5555
var testBtn = new helper.MyButton();
5656
testBtn.width = { value: 20, unit: "px" };
57-
dockModule.DockLayout.setDock(testBtn, enums.Dock.right);
57+
dockModule.DockLayout.setDock(testBtn, "right");
5858
this.testView.stretchLastChild = false;
5959
this.testView.addChild(testBtn);
6060

@@ -66,7 +66,7 @@ export class DockLayoutTest extends testModule.UITest<DockLayout> {
6666
public test_dock_top() {
6767
var testBtn = new helper.MyButton();
6868
testBtn.height = { value: 20, unit: "px" };
69-
dockModule.DockLayout.setDock(testBtn, enums.Dock.top);
69+
dockModule.DockLayout.setDock(testBtn, "top");
7070
this.testView.stretchLastChild = false;
7171
this.testView.addChild(testBtn);
7272

@@ -78,7 +78,7 @@ export class DockLayoutTest extends testModule.UITest<DockLayout> {
7878
public test_dock_button() {
7979
var testBtn = new helper.MyButton();
8080
testBtn.height = { value: 20, unit: "px" };
81-
dockModule.DockLayout.setDock(testBtn, enums.Dock.bottom);
81+
dockModule.DockLayout.setDock(testBtn, "bottom");
8282
this.testView.stretchLastChild = false;
8383
this.testView.addChild(testBtn);
8484

@@ -103,21 +103,21 @@ export class DockLayoutTest extends testModule.UITest<DockLayout> {
103103

104104
var testBtnTop = new helper.MyButton();
105105
testBtnTop.height = { value: 20, unit: "px" };
106-
dockModule.DockLayout.setDock(testBtnTop, enums.Dock.top);
106+
dockModule.DockLayout.setDock(testBtnTop, "top");
107107
this.testView.addChild(testBtnTop);
108108

109109
var testBtnRight = new helper.MyButton();
110110
testBtnRight.width = { value: 20, unit: "px" }
111-
dockModule.DockLayout.setDock(testBtnRight, enums.Dock.right);
111+
dockModule.DockLayout.setDock(testBtnRight, "right");
112112
this.testView.addChild(testBtnRight);
113113

114114
var testBtnBottom = new helper.MyButton();
115115
testBtnBottom.height = { value: 20, unit: "px" }
116-
dockModule.DockLayout.setDock(testBtnBottom, enums.Dock.bottom);
116+
dockModule.DockLayout.setDock(testBtnBottom, "bottom");
117117
this.testView.addChild(testBtnBottom);
118118

119119
var testBtnFill = new helper.MyButton();
120-
dockModule.DockLayout.setDock(testBtnFill, enums.Dock.bottom);
120+
dockModule.DockLayout.setDock(testBtnFill, "bottom");
121121
this.testView.addChild(testBtnFill);
122122

123123
this.waitUntilTestElementLayoutIsValid();
@@ -159,7 +159,7 @@ export class DockLayoutTest extends testModule.UITest<DockLayout> {
159159

160160
// >> dock-layout-setdocl
161161
var btnDockedToRight = new button.Button();
162-
dockModule.DockLayout.setDock(btnDockedToRight, enums.Dock.right);
162+
dockModule.DockLayout.setDock(btnDockedToRight, "right");
163163
dockLayout.addChild(btnDockedToRight);
164164
// << dock-layout-setdocl
165165
}

tests/app/ui/layouts/flexbox-layout-tests.ts

Lines changed: 48 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,54 @@
11
// >> flexbox-layout-require
2-
import {
3-
FlexboxLayout,
4-
FlexDirection,
5-
FlexWrap,
6-
JustifyContent,
7-
AlignItems,
8-
AlignContent,
9-
AlignSelf
10-
} from "tns-core-modules/ui/layouts/flexbox-layout";
2+
import { FlexboxLayout } from "tns-core-modules/ui/layouts/flexbox-layout";
113
// << flexbox-layout-require
124

5+
export namespace FlexDirection {
6+
export const ROW: "row" = "row";
7+
export const ROW_REVERSE: "row-reverse" = "row-reverse";
8+
export const COLUMN: "column" = "column";
9+
export const COLUMN_REVERSE: "column-reverse" = "column-reverse";
10+
}
11+
12+
export namespace FlexWrap {
13+
export const NOWRAP: "nowrap" = "nowrap";
14+
export const WRAP: "wrap" = "wrap";
15+
export const WRAP_REVERSE: "wrap-reverse" = "wrap-reverse";
16+
}
17+
18+
export namespace JustifyContent {
19+
export const FLEX_START: "flex-start" = "flex-start";
20+
export const FLEX_END: "flex-end" = "flex-end";
21+
export const CENTER: "center" = "center";
22+
export const SPACE_BETWEEN: "space-between" = "space-between";
23+
export const SPACE_AROUND: "space-around" = "space-around";
24+
}
25+
26+
export namespace AlignItems {
27+
export const FLEX_START: "flex-start" = "flex-start";
28+
export const FLEX_END: "flex-end" = "flex-end";
29+
export const CENTER: "center" = "center";
30+
export const BASELINE: "baseline" = "baseline";
31+
export const STRETCH: "stretch" = "stretch";
32+
}
33+
34+
export namespace AlignContent {
35+
export const FLEX_START: "flex-start" = "flex-start";
36+
export const FLEX_END: "flex-end" = "flex-end";
37+
export const CENTER: "center" = "center";
38+
export const SPACE_BETWEEN: "space-between" = "space-between";
39+
export const SPACE_AROUND: "space-around" = "space-around";
40+
export const STRETCH: "stretch" = "stretch";
41+
}
42+
43+
export namespace AlignSelf {
44+
export const AUTO: "auto" = "auto";
45+
export const FLEX_START: "flex-start" = "flex-start";
46+
export const FLEX_END: "flex-end" = "flex-end";
47+
export const CENTER: "center" = "center";
48+
export const BASELINE: "baseline" = "baseline";
49+
export const STRETCH: "stretch" = "stretch";
50+
}
51+
1352
import {View, unsetValue, Length, PercentLength} from "tns-core-modules/ui/core/view";
1453
import {Label} from "tns-core-modules/ui/label";
1554
import * as TKUnit from "../../TKUnit";

tests/app/ui/scroll-view/scroll-view-tests.ts

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11
import * as TKUnit from "../../TKUnit";
22
import * as app from "tns-core-modules/application";
33
import * as button from "tns-core-modules/ui/button";
4-
import * as enums from "tns-core-modules/ui/enums";
54
import * as testModule from "../../ui-test";
65
import * as layoutHelper from "../layouts/layout-helper";
7-
import {Page} from "tns-core-modules/ui/page";
6+
import { Page } from "tns-core-modules/ui/page";
87
import * as frame from "tns-core-modules/ui/frame";
98

109
// >> article-require-scrollview-module
@@ -15,7 +14,7 @@ class ScrollLayoutTest extends testModule.UITest<scrollViewModule.ScrollView> {
1514

1615
public create(): scrollViewModule.ScrollView {
1716
let scrollView = new scrollViewModule.ScrollView();
18-
scrollView.orientation = enums.Orientation.vertical;
17+
scrollView.orientation = "vertical";
1918

2019
scrollView.width = { value: 200, unit: "px" };
2120
scrollView.height = { value: 300, unit: "px" };
@@ -38,13 +37,13 @@ class ScrollLayoutTest extends testModule.UITest<scrollViewModule.ScrollView> {
3837

3938
public test_default_TNS_values() {
4039
let scroll = new scrollViewModule.ScrollView();
41-
TKUnit.assertEqual(scroll.orientation, enums.Orientation.vertical, "Default this.testView.orientation");
40+
TKUnit.assertEqual(scroll.orientation, "vertical", "Default this.testView.orientation");
4241
TKUnit.assertEqual(scroll.verticalOffset, 0, "Default this.testView.verticalOffset");
4342
TKUnit.assertEqual(scroll.horizontalOffset, 0, "Default this.testView.horizontalOffset");
4443
}
4544

4645
public test_vertical_oriantation_creates_correct_native_view() {
47-
this.testView.orientation = enums.Orientation.vertical;
46+
this.testView.orientation = "vertical";
4847

4948
if (app.android) {
5049
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> {
5554
}
5655

5756
public test_horizontal_oriantation_creates_correct_native_view() {
58-
this.testView.orientation = enums.Orientation.horizontal;
57+
this.testView.orientation = "horizontal";
5958

6059
if (app.android) {
6160
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> {
8382
}
8483

8584
public test_scrollableWidth_horizontal_orientation_when_content_is_small() {
86-
this.testView.orientation = enums.Orientation.horizontal;
85+
this.testView.orientation = "horizontal";
8786
this.testView.content.width = { value: 100, unit: "px" };
8887
this.testView.content.height = { value: 100, unit: "px" };
8988
this.waitUntilTestElementLayoutIsValid();
@@ -93,7 +92,7 @@ class ScrollLayoutTest extends testModule.UITest<scrollViewModule.ScrollView> {
9392
}
9493

9594
public test_scrollableWidth_horizontal_orientation_when_content_is_big() {
96-
this.testView.orientation = enums.Orientation.horizontal;
95+
this.testView.orientation = "horizontal";
9796
this.testView.content.height = { value: 100, unit: "px" };
9897
this.waitUntilTestElementLayoutIsValid();
9998

@@ -125,7 +124,7 @@ class ScrollLayoutTest extends testModule.UITest<scrollViewModule.ScrollView> {
125124
}
126125

127126
public test_scrollToHorizontalOffset_no_animation() {
128-
this.testView.orientation = enums.Orientation.horizontal;
127+
this.testView.orientation = "horizontal";
129128
this.waitUntilTestElementLayoutIsValid();
130129

131130
TKUnit.assertEqual(this.testView.horizontalOffset, 0, "this.testView.horizontalOffset");
@@ -134,7 +133,7 @@ class ScrollLayoutTest extends testModule.UITest<scrollViewModule.ScrollView> {
134133
}
135134

136135
public test_scrollToHorizontalOffset_with_animation() {
137-
this.testView.orientation = enums.Orientation.horizontal;
136+
this.testView.orientation = "horizontal";
138137
this.waitUntilTestElementLayoutIsValid();
139138

140139
TKUnit.assertEqual(this.testView.horizontalOffset, 0, "this.testView.horizontalOffset");
@@ -173,7 +172,7 @@ class ScrollLayoutTest extends testModule.UITest<scrollViewModule.ScrollView> {
173172
}
174173

175174
public test_scrollView_persistsState_horizontal() {
176-
this.testView.orientation = enums.Orientation.horizontal;
175+
this.testView.orientation = "horizontal";
177176
this.waitUntilTestElementLayoutIsValid();
178177

179178
this.testView.scrollToHorizontalOffset(layoutHelper.dp(100), false);
@@ -211,7 +210,7 @@ class ScrollLayoutTest extends testModule.UITest<scrollViewModule.ScrollView> {
211210
}
212211

213212
public test_scrollView_horizontal_raised_scroll_event() {
214-
this.testView.orientation = enums.Orientation.horizontal;
213+
this.testView.orientation = "horizontal";
215214

216215
var scrollX: number;
217216
this.testView.on(scrollViewModule.ScrollView.scrollEvent, (args: scrollViewModule.ScrollEventData) => {
@@ -240,7 +239,7 @@ class ScrollLayoutTest extends testModule.UITest<scrollViewModule.ScrollView> {
240239
}
241240

242241
public test_scrollView_horizontal_raised_scroll_event_after_loaded() {
243-
this.testView.orientation = enums.Orientation.horizontal;
242+
this.testView.orientation = "horizontal";
244243
this.waitUntilTestElementLayoutIsValid();
245244

246245
var scrollX: number;

tests/app/ui/styling/style-properties-tests.ts

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -610,58 +610,58 @@ function test_native_font(style: "normal" | "italic", weight: "100" | "200" | "3
610610
//TODO: If needed add tests for other platforms
611611
}
612612

613-
export const test_setting_button_whiteSpace_normal_sets_native = function () {
614-
const testView = new Button();
613+
export function test_setting_label_whiteSpace_nowrap_sets_native() {
614+
const testView = new Label();
615615
testView.style.whiteSpace = "nowrap";
616616

617617
helper.buildUIAndRunTest(testView, function (views: Array<View>) {
618618
if (isAndroid) {
619-
TKUnit.assertEqual((<android.widget.Button>testView.android).getEllipsize(), android.text.TextUtils.TruncateAt.END);
619+
TKUnit.assertEqual((<android.widget.TextView>testView.android).getEllipsize(), android.text.TextUtils.TruncateAt.END);
620620
} else if (isIOS) {
621-
TKUnit.assertEqual((<UIButton>testView.ios).titleLabel.lineBreakMode, NSLineBreakMode.ByTruncatingMiddle);
622-
TKUnit.assertEqual((<UIButton>testView.ios).titleLabel.numberOfLines, 1);
621+
TKUnit.assertEqual((<UILabel>testView.ios).lineBreakMode, NSLineBreakMode.ByTruncatingTail);
622+
TKUnit.assertEqual((<UILabel>testView.ios).numberOfLines, 1);
623623
}
624624
});
625625
};
626626

627-
export const test_setting_label_whiteSpace_normal_sets_native = function () {
627+
export function test_setting_label_whiteSpace_normal_sets_native() {
628628
const testView = new Label();
629-
testView.style.whiteSpace = "nowrap";
629+
testView.style.whiteSpace = "normal";
630630

631631
helper.buildUIAndRunTest(testView, function (views: Array<View>) {
632632
if (isAndroid) {
633-
TKUnit.assertEqual((<android.widget.TextView>testView.android).getEllipsize(), android.text.TextUtils.TruncateAt.END);
633+
TKUnit.assertNull((<android.widget.TextView>testView.android).getEllipsize(), null);
634634
} else if (isIOS) {
635-
TKUnit.assertEqual((<UILabel>testView.ios).lineBreakMode, NSLineBreakMode.ByTruncatingTail);
636-
TKUnit.assertEqual((<UILabel>testView.ios).numberOfLines, 1);
635+
TKUnit.assertEqual((<UILabel>testView.ios).lineBreakMode, NSLineBreakMode.ByWordWrapping);
636+
TKUnit.assertEqual((<UILabel>testView.ios).numberOfLines, 0);
637637
}
638638
});
639639
};
640640

641-
export const test_setting_button_whiteSpace_nowrap_sets_native = function () {
641+
export function test_setting_button_whiteSpace_nowrap_sets_native() {
642642
const testView = new Button();
643-
testView.style.whiteSpace = "normal";
643+
testView.style.whiteSpace = "nowrap";
644644

645645
helper.buildUIAndRunTest(testView, function (views: Array<View>) {
646646
if (isAndroid) {
647-
TKUnit.assertNull((<android.widget.Button>testView.android).getEllipsize(), null);
647+
TKUnit.assertEqual((<android.widget.Button>testView.android).getEllipsize(), android.text.TextUtils.TruncateAt.END);
648648
} else if (isIOS) {
649-
TKUnit.assertEqual((<UIButton>testView.ios).titleLabel.lineBreakMode, NSLineBreakMode.ByWordWrapping);
650-
TKUnit.assertEqual((<UIButton>testView.ios).titleLabel.numberOfLines, 0);
649+
TKUnit.assertEqual((<UIButton>testView.ios).titleLabel.lineBreakMode, NSLineBreakMode.ByTruncatingMiddle);
650+
TKUnit.assertEqual((<UIButton>testView.ios).titleLabel.numberOfLines, 1);
651651
}
652652
});
653653
};
654654

655-
export const test_setting_label_whiteSpace_nowrap_sets_native = function () {
656-
const testView = new Label();
655+
export function test_setting_button_whiteSpace_normal_sets_native() {
656+
const testView = new Button();
657657
testView.style.whiteSpace = "normal";
658658

659659
helper.buildUIAndRunTest(testView, function (views: Array<View>) {
660660
if (isAndroid) {
661-
TKUnit.assertNull((<android.widget.TextView>testView.android).getEllipsize(), null);
661+
TKUnit.assertNull((<android.widget.Button>testView.android).getEllipsize(), null);
662662
} else if (isIOS) {
663-
TKUnit.assertEqual((<UILabel>testView.ios).lineBreakMode, NSLineBreakMode.ByWordWrapping);
664-
TKUnit.assertEqual((<UILabel>testView.ios).numberOfLines, 0);
663+
TKUnit.assertEqual((<UIButton>testView.ios).titleLabel.lineBreakMode, NSLineBreakMode.ByWordWrapping);
664+
TKUnit.assertEqual((<UIButton>testView.ios).titleLabel.numberOfLines, 0);
665665
}
666666
});
667667
};

0 commit comments

Comments
 (0)