diff --git a/apps/app/App_Resources/Android/drawable-nodpi/icon.png b/apps/app/App_Resources/Android/drawable-nodpi/icon.png
index 76f61ec1f..1034356e2 100644
Binary files a/apps/app/App_Resources/Android/drawable-nodpi/icon.png and b/apps/app/App_Resources/Android/drawable-nodpi/icon.png differ
diff --git a/apps/app/App_Resources/Android/drawable-nodpi/testlogo.jpg b/apps/app/App_Resources/Android/drawable-nodpi/testlogo.jpg
new file mode 100644
index 000000000..102a9b134
Binary files /dev/null and b/apps/app/App_Resources/Android/drawable-nodpi/testlogo.jpg differ
diff --git a/apps/app/ui-tests-app/search-bar/issue-4147.xml b/apps/app/ui-tests-app/search-bar/issue-4147.xml
index 79df36dfa..bb3a743d9 100644
--- a/apps/app/ui-tests-app/search-bar/issue-4147.xml
+++ b/apps/app/ui-tests-app/search-bar/issue-4147.xml
@@ -5,10 +5,10 @@
-
-
-
-
-
-
-
\ No newline at end of file
+
+
+
+
+
+
+
diff --git a/apps/package.json b/apps/package.json
index 1b2ffe56f..0ed4081ad 100644
--- a/apps/package.json
+++ b/apps/package.json
@@ -6,7 +6,7 @@
"nativescript": {
"id": "org.nativescript.apps",
"tns-android": {
- "version": "3.0.0"
+ "version": "3.0.1"
},
"tns-ios": {
"version": "3.1.0-2017-5-16-2"
diff --git a/tests/.vscode/launch.json b/tests/.vscode/launch.json
index c0c6c021b..a51cfc788 100644
--- a/tests/.vscode/launch.json
+++ b/tests/.vscode/launch.json
@@ -31,7 +31,7 @@
"appRoot": "${workspaceRoot}",
"sourceMaps": true,
"watch": true,
- "stopOnEntry": false,
+ "stopOnEntry": true,
"tnsArgs": [
"--sync-all-files"
]
diff --git a/tests/app/TKUnit.ts b/tests/app/TKUnit.ts
index 1da82183f..bbe2457a8 100644
--- a/tests/app/TKUnit.ts
+++ b/tests/app/TKUnit.ts
@@ -210,7 +210,7 @@ export function assertNotEqual(actual: any, expected: any, message?: string) {
}
if (equals) {
- throw new Error(message + " Actual: " + actual + " Expected: " + expected);
+ throw new Error(message + " Actual: " + actual + " Not_Expected: " + expected);
}
}
@@ -233,59 +233,59 @@ export function assertEqual(actual: T, e
/**
* Assert two json like objects are deep equal.
*/
-export function assertDeepEqual(actual, expected, path: any[] = []): void {
+export function assertDeepEqual(actual, expected, message: string = '', path: any[] = []): void {
let typeofActual: string = typeof actual;
let typeofExpected: string = typeof expected;
if (typeofActual !== typeofExpected) {
- throw new Error("At /" + path.join("/") + " types of actual " + typeofActual + " and expected " + typeofExpected + " differ.");
+ throw new Error(message + ' ' + "At /" + path.join("/") + " types of actual " + typeofActual + " and expected " + typeofExpected + " differ.");
} else if (typeofActual === "object" || typeofActual === "array") {
if (expected instanceof Map) {
if (actual instanceof Map) {
expected.forEach((value, key) => {
if (actual.has(key)) {
- assertDeepEqual(actual.get(key), value, path.concat([key]));
+ assertDeepEqual(actual.get(key), value, message, path.concat([key]));
} else {
- throw new Error("At /" + path.join("/") + " expected Map has key '" + key + "' but actual does not.");
+ throw new Error(message + ' ' + "At /" + path.join("/") + " expected Map has key '" + key + "' but actual does not.");
}
});
actual.forEach((value, key) => {
if (!expected.has(key)) {
- throw new Error("At /" + path.join("/") + " actual Map has key '" + key + "' but expected does not.");
+ throw new Error(message + ' ' + "At /" + path.join("/") + " actual Map has key '" + key + "' but expected does not.");
}
});
} else {
- throw new Error("At /" + path.join("/") + " expected is Map but actual is not.");
+ throw new Error(message + ' ' + "At /" + path.join("/") + " expected is Map but actual is not.");
}
}
if (expected instanceof Set) {
if (actual instanceof Set) {
expected.forEach(i => {
if (!actual.has(i)) {
- throw new Error("At /" + path.join("/") + " expected Set has item '" + i + "' but actual does not.");
+ throw new Error(message + ' ' + "At /" + path.join("/") + " expected Set has item '" + i + "' but actual does not.");
}
});
actual.forEach(i => {
if (!expected.has(i)) {
- throw new Error("At /" + path.join("/") + " actual Set has item '" + i + "' but expected does not.");
+ throw new Error(message + ' ' + "At /" + path.join("/") + " actual Set has item '" + i + "' but expected does not.");
}
})
} else {
- throw new Error("At /" + path.join("/") + " expected is Set but actual is not.");
+ throw new Error(message + ' ' + "At /" + path.join("/") + " expected is Set but actual is not.");
}
}
for (let key in actual) {
if (!(key in expected)) {
- throw new Error("At /" + path.join("/") + " found unexpected key " + key + ".");
+ throw new Error(message + ' ' + "At /" + path.join("/") + " found unexpected key " + key + ".");
}
- assertDeepEqual(actual[key], expected[key], path.concat([key]));
+ assertDeepEqual(actual[key], expected[key], message, path.concat([key]));
}
for (let key in expected) {
if (!(key in actual)) {
- throw new Error("At /" + path.join("/") + " expected a key " + key + ".");
+ throw new Error(message + ' ' + "At /" + path.join("/") + " expected a key " + key + ".");
}
}
} else if (actual !== expected) {
- throw new Error("At /" + path.join("/") + " actual: '" + actual + "' and expected: '" + expected + "' differ.");
+ throw new Error(message + ' ' + "At /" + path.join("/") + " actual: '" + actual + "' and expected: '" + expected + "' differ.");
}
}
diff --git a/tests/app/app/mainPage.ts b/tests/app/app/mainPage.ts
index 81dff086d..a8a52f4f0 100644
--- a/tests/app/app/mainPage.ts
+++ b/tests/app/app/mainPage.ts
@@ -24,7 +24,7 @@ page.id = "mainPage";
page.on(Page.navigatedToEvent, onNavigatedTo);
function runTests() {
- setTimeout(() => tests.runAll(), 10);
+ setTimeout(() => tests.runAll(''), 10);
}
function onNavigatedTo(args) {
diff --git a/tests/app/testRunner.ts b/tests/app/testRunner.ts
index ad88bced0..93b934209 100644
--- a/tests/app/testRunner.ts
+++ b/tests/app/testRunner.ts
@@ -217,9 +217,6 @@ allTests["HTML-VIEW"] = htmlViewTests;
import * as repeaterTests from "./ui/repeater/repeater-tests";
allTests["REPEATER"] = repeaterTests;
-import * as searchBarTests from "./ui/search-bar/search-bar-tests";
-allTests["SEARCH-BAR"] = searchBarTests;
-
import * as segmentedBarTests from "./ui/segmented-bar/segmented-bar-tests";
allTests["SEGMENTED-BAR"] = segmentedBarTests;
@@ -238,6 +235,9 @@ if (!(platform.device.os === platform.platformNames.android && parseInt(platform
allTests["TANSITIONS"] = transitionTests;
}
+import * as searchBarTests from "./ui/search-bar/search-bar-tests";
+allTests["SEARCH-BAR"] = searchBarTests;
+
import * as navigationTests from "./navigation/navigation-tests";
allTests["NAVIGATION"] = navigationTests;
diff --git a/tests/app/ui/action-bar/action-bar-tests-common.ts b/tests/app/ui/action-bar/action-bar-tests-common.ts
index a06ea2e6a..9925d256b 100644
--- a/tests/app/ui/action-bar/action-bar-tests-common.ts
+++ b/tests/app/ui/action-bar/action-bar-tests-common.ts
@@ -333,3 +333,7 @@ export function createPageAndNavigate() {
return page;
}
+
+export function test_recycling() {
+ helper.nativeView_recycling_test(() => new actionBarModule.ActionBar());
+}
\ No newline at end of file
diff --git a/tests/app/ui/activity-indicator/activity-indicator-tests.ts b/tests/app/ui/activity-indicator/activity-indicator-tests.ts
index 313bc3a00..f94566fa3 100644
--- a/tests/app/ui/activity-indicator/activity-indicator-tests.ts
+++ b/tests/app/ui/activity-indicator/activity-indicator-tests.ts
@@ -9,6 +9,10 @@ import * as color from "tns-core-modules/color";
import * as activityIndicatorModule from "tns-core-modules/ui/activity-indicator";
// << activity-indicator-require
+export function test_recycling() {
+ helper.nativeView_recycling_test(() => new activityIndicatorModule.ActivityIndicator());
+}
+
export function test_default_TNS_values() {
// >> activity-indicator-create
var indicator = new activityIndicatorModule.ActivityIndicator();
diff --git a/tests/app/ui/border/border-tests.ts b/tests/app/ui/border/border-tests.ts
index 3d03ad2c4..c50b618ab 100644
--- a/tests/app/ui/border/border-tests.ts
+++ b/tests/app/ui/border/border-tests.ts
@@ -1,7 +1,8 @@
// >> border-require
import { Border } from "tns-core-modules/ui/border";
// << border-require
+import * as helper from "../helper";
-if (Border) {
- // NOOP
+export function test_recycling() {
+ helper.nativeView_recycling_test(() => new Border());
}
\ No newline at end of file
diff --git a/tests/app/ui/button/button-tests.ts b/tests/app/ui/button/button-tests.ts
index 1224b4091..7487bcedb 100644
--- a/tests/app/ui/button/button-tests.ts
+++ b/tests/app/ui/button/button-tests.ts
@@ -16,6 +16,10 @@ import * as bindable from "tns-core-modules/ui/core/bindable";
import * as observable from "tns-core-modules/data/observable";
// << button-require-others
+export function test_recycling() {
+ helper.nativeView_recycling_test(() => new buttonModule.Button());
+}
+
export var testSetText = function () {
helper.buildUIAndRunTest(_createButtonFunc(), _testSetText);
}
diff --git a/tests/app/ui/date-picker/date-picker-tests.ts b/tests/app/ui/date-picker/date-picker-tests.ts
index 812496ddd..73c0a98a5 100644
--- a/tests/app/ui/date-picker/date-picker-tests.ts
+++ b/tests/app/ui/date-picker/date-picker-tests.ts
@@ -8,6 +8,12 @@ import * as platform from "tns-core-modules/platform";
import * as datePickerModule from "tns-core-modules/ui/date-picker";
// << date-picker-require
+import * as helper from "../helper";
+
+export function test_recycling() {
+ helper.nativeView_recycling_test(() => new datePickerModule.DatePicker());
+}
+
function assertDate(datePicker: datePickerModule.DatePicker, expectedYear: number, expectedMonth: number, expectedDay: number) {
TKUnit.assertEqual(datePicker.year, expectedYear, "datePicker.year");
TKUnit.assertEqual(datePicker.month, expectedMonth, "datePicker.month");
diff --git a/tests/app/ui/helper.ts b/tests/app/ui/helper.ts
index 3f743c874..59428838c 100644
--- a/tests/app/ui/helper.ts
+++ b/tests/app/ui/helper.ts
@@ -1,18 +1,18 @@
-import * as view from "tns-core-modules/ui/core/view";
-import * as frame from "tns-core-modules/ui/frame";
-import * as page from "tns-core-modules/ui/page";
-import * as stackLayoutModule from "tns-core-modules/ui/layouts/stack-layout";
-import * as button from "tns-core-modules/ui/button";
+import * as frame from "tns-core-modules/ui/frame";
+import { ViewBase, View, unsetValue, isIOS } from "tns-core-modules/ui/core/view";
+import { Page } from "tns-core-modules/ui/page";
+import { StackLayout } from "tns-core-modules/ui/layouts/stack-layout";
+import { Button } from "tns-core-modules/ui/button";
import * as TKUnit from "../TKUnit";
import * as utils from "tns-core-modules/utils/utils";
-import * as platform from "tns-core-modules/platform";
-import * as colorModule from "tns-core-modules/color";
-import * as formattedStringModule from "tns-core-modules/text/formatted-string";
-import * as spanModule from "tns-core-modules/text/span";
import { ActionBar } from "tns-core-modules/ui/action-bar";
-import { unsetValue } from "tns-core-modules/ui/core/view";
import { Color } from "tns-core-modules/color";
+import { LayoutBase } from "tns-core-modules/ui/layouts/layout-base";
+import { FlexboxLayout } from "tns-core-modules/ui/layouts/flexbox-layout";
+import { FormattedString, Span } from "tns-core-modules/text/formatted-string";
+import { _getProperties, _getStyleProperties } from "tns-core-modules/ui/core/properties";
+
var DELTA = 0.1;
export var ASYNC = 0.2;
@@ -46,7 +46,7 @@ function clearPage(): void {
newPage.id = unsetValue;
}
-export function do_PageTest(test: (views: [page.Page, view.View, view.View, view.View, ActionBar]) => void, content: view.View, secondView: view.View, thirdView: view.View) {
+export function do_PageTest(test: (views: [Page, View, View, View, ActionBar]) => void, content: View, secondView: View, thirdView: View) {
clearPage();
let newPage = getCurrentPage();
newPage.content = content;
@@ -54,20 +54,20 @@ export function do_PageTest(test: (views: [page.Page, view.View, view.View, view
newPage.content = null;
}
-export function do_PageTest_WithButton(test: (views: [page.Page, button.Button, ActionBar]) => void) {
+export function do_PageTest_WithButton(test: (views: [Page, Button, ActionBar]) => void) {
clearPage();
let newPage = getCurrentPage();
- let btn = new button.Button();
+ let btn = new Button();
newPage.content = btn;
test([newPage, btn, newPage.actionBar]);
newPage.content = null;
}
-export function do_PageTest_WithStackLayout_AndButton(test: (views: [page.Page, stackLayoutModule.StackLayout, button.Button, ActionBar]) => void) {
+export function do_PageTest_WithStackLayout_AndButton(test: (views: [Page, StackLayout, Button, ActionBar]) => void) {
clearPage();
let newPage = getCurrentPage();
- let stackLayout = new stackLayoutModule.StackLayout();
- let btn = new button.Button();
+ let stackLayout = new StackLayout();
+ let btn = new Button();
stackLayout.addChild(btn);
newPage.content = stackLayout;
test([newPage, stackLayout, btn, newPage.actionBar]);
@@ -75,7 +75,7 @@ export function do_PageTest_WithStackLayout_AndButton(test: (views: [page.Page,
}
//export function buildUIAndRunTest(controlToTest, testFunction, pageCss?, testDelay?) {
-export function buildUIAndRunTest(controlToTest: T, testFunction: (views: [T, page.Page]) => void, pageCss?) {
+export function buildUIAndRunTest(controlToTest: T, testFunction: (views: [T, Page]) => void, pageCss?) {
clearPage();
let newPage = getCurrentPage();
@@ -87,7 +87,7 @@ export function buildUIAndRunTest(controlToTest: T, testFun
newPage.css = null;
}
-export function buildUIWithWeakRefAndInteract(createFunc: () => T, interactWithViewFunc?: (view: T) => void, done?) {
+export function buildUIWithWeakRefAndInteract(createFunc: () => T, interactWithViewFunc?: (view: T) => void, done?) {
clearPage();
const page = getCurrentPage();
const weakRef = new WeakRef(createFunc());
@@ -120,44 +120,45 @@ export function navigateToModuleAndRunTest(moduleName, context, testFunction) {
testFunction(page);
}
-export function navigate(pageFactory: () => page.Page, navigationContext?: any): page.Page {
+export function navigate(pageFactory: () => Page, navigationContext?: any): Page {
let entry: frame.NavigationEntry = { create: pageFactory, animated: false, context: navigationContext, clearHistory: true };
return navigateWithEntry(entry);
}
-export function navigateWithHistory(pageFactory: () => page.Page, navigationContext?: any): page.Page {
+export function navigateWithHistory(pageFactory: () => Page, navigationContext?: any): Page {
let entry: frame.NavigationEntry = { create: pageFactory, animated: false, context: navigationContext, clearHistory: false };
return navigateWithEntry(entry);
}
-export function navigateToModule(moduleName: string, context?: any): page.Page {
+export function navigateToModule(moduleName: string, context?: any): Page {
let entry: frame.NavigationEntry = { moduleName: moduleName, context: context, animated: false, clearHistory: true };
return navigateWithEntry(entry);
}
-export function getCurrentPage(): page.Page {
+export function getCurrentPage(): Page {
return frame.topmost().currentPage;
}
-export function getClearCurrentPage(): page.Page {
+export function getClearCurrentPage(): Page {
let page = frame.topmost().currentPage;
page.style.backgroundColor = unsetValue;
page.style.color = unsetValue;
page.bindingContext = unsetValue;
page.className = unsetValue;
page.id = unsetValue;
+ page.css = '';
return page;
}
-export function waitUntilNavigatedFrom(oldPage: page.Page) {
+export function waitUntilNavigatedFrom(oldPage: Page) {
TKUnit.waitUntilReady(() => getCurrentPage() && getCurrentPage() !== oldPage);
}
-export function waitUntilLayoutReady(view: view.View): void {
+export function waitUntilLayoutReady(view: View): void {
TKUnit.waitUntilReady(() => view.isLayoutValid);
}
-export function navigateWithEntry(entry: frame.NavigationEntry): page.Page {
+export function navigateWithEntry(entry: frame.NavigationEntry): Page {
let page = frame.resolvePageFromEntry(entry);
entry.moduleName = null;
entry.create = function () {
@@ -183,18 +184,18 @@ export function assertAreClose(actual: number, expected: number, message: string
TKUnit.assertAreClose(actual, expected, delta, message);
}
-export function assertViewColor(testView: view.View, hexColor: string) {
+export function assertViewColor(testView: View, hexColor: string) {
TKUnit.assert(testView.style.color, "Color property not applied correctly. Style value is not defined.");
TKUnit.assertEqual(testView.style.color.hex, hexColor, "color property");
}
-export function assertViewBackgroundColor(testView: view.ViewBase, hexColor: string) {
+export function assertViewBackgroundColor(testView: ViewBase, hexColor: string) {
TKUnit.assert(testView.style.backgroundColor, "Background color property not applied correctly. Style value is not defined.");
TKUnit.assertEqual(testView.style.backgroundColor.hex, hexColor, "backgroundColor property");
}
export function forceGC() {
- if (platform.device.os === platform.platformNames.ios) {
+ if (isIOS) {
/* tslint:disable:no-unused-expression */
// Could cause GC on the next call.
new ArrayBuffer(4 * 1024 * 1024);
@@ -204,29 +205,515 @@ export function forceGC() {
TKUnit.wait(0.001);
}
-export function _generateFormattedString(): formattedStringModule.FormattedString {
- let formattedString = new formattedStringModule.FormattedString();
- let span: spanModule.Span;
+export function _generateFormattedString(): FormattedString {
+ let formattedString = new FormattedString();
+ let span: Span;
- span = new spanModule.Span();
+ span = new Span();
span.fontFamily = "serif";
span.fontSize = 10;
span.fontWeight = "bold";
- span.color = new colorModule.Color("red");
- span.backgroundColor = new colorModule.Color("blue");
+ span.color = new Color("red");
+ span.backgroundColor = new Color("blue");
span.textDecoration = "line-through";
span.text = "Formatted";
formattedString.spans.push(span);
- span = new spanModule.Span();
+ span = new Span();
span.fontFamily = "sans-serif";
span.fontSize = 20;
span.fontStyle = "italic";
- span.color = new colorModule.Color("green");
- span.backgroundColor = new colorModule.Color("yellow");
+ span.color = new Color("green");
+ span.backgroundColor = new Color("yellow");
span.textDecoration = "underline";
span.text = "Text";
formattedString.spans.push(span);
return formattedString;
}
+
+const props = _getProperties();
+const styleProps = _getStyleProperties();
+let setters: Map;
+let cssSetters: Map;
+let defaultNativeGetters: Map any>;
+
+export function nativeView_recycling_test(createNew: () => View, createLayout?: () => LayoutBase, nativeGetters?: Map any>, customSetters?: Map) {
+ if (isIOS) {
+ // recycling not implemented yet.
+ return;
+ }
+ setupSetters();
+ const page = getClearCurrentPage();
+ let layout: LayoutBase = new FlexboxLayout();
+ if (createLayout) {
+ // This is done on purpose. We need the constructor of Flexbox
+ // to run otherwise some module fileds stays uninitialized.
+ layout = createLayout();
+ }
+
+ page.content = layout;
+
+ const first = createNew();
+ const test = createNew();
+
+ // Make sure we are not reusing a native views.
+ first.recycleNativeView = false;
+ test.recycleNativeView = false;
+
+ page.content = layout;
+
+ layout.addChild(test);
+
+ setValue(test.style, cssSetters);
+ setValue(test, setters, customSetters);
+ // Needed so we can reset formattedText
+ test["secure"] = false;
+
+ const nativeView = test.nativeView;
+ // Mark so we reuse the native views.
+ test.recycleNativeView = true;
+ layout.removeChild(test);
+ const newer = createNew();
+ newer.recycleNativeView = true;
+ layout.addChild(newer);
+ layout.addChild(first);
+
+ TKUnit.assertEqual(newer.nativeView, nativeView, "nativeView not reused.");
+ checkDefaults(newer, first, props, nativeGetters || defaultNativeGetters);
+ checkDefaults(newer, first, styleProps, nativeGetters || defaultNativeGetters);
+ layout.removeChild(newer);
+ layout.removeChild(first);
+}
+
+function checkDefaults(newer: View, first: View, props: Array, nativeGetters: Map any>): void {
+ props.forEach(prop => {
+ const name = (prop).name;
+ if (nativeGetters.has(name)) {
+ const getter = nativeGetters.get(name);
+ TKUnit.assertDeepEqual(getter(newer), getter(first), name);
+ } else if (newer[prop.getDefault]) {
+ TKUnit.assertDeepEqual(newer[prop.getDefault](), first[prop.getDefault](), name);
+ } else if (newer[prop.setNative]) {
+ console.log(`Type: ${newer.typeName} has no getter for ${name} property.`)
+ }
+ });
+}
+
+function setValue(object: Object, setters: Map, customSetters?: Map): void {
+ setters.forEach((value1, key) => {
+ let value = customSetters && customSetters.has(key) ? customSetters.get(key) : value1;
+ const currentValue = object[key];
+ if (currentValue === value) {
+ if (value === 'horizontal' && key === 'orientation') {
+ // wrap-layout.orientation default value is 'horizontal'
+ value = 'vertical';
+ } else if (value === 2) {
+ value = 3;
+ }
+ }
+
+ object[key] = value;
+ const newValue = object[key];
+ TKUnit.assertNotEqual(newValue, currentValue, `${object} setting ${key} should change current value.`);
+ });
+}
+
+function setupSetters(): void {
+ if (setters) {
+ return;
+ }
+
+ setters = new Map();
+ // view-base
+ setters.set('id', "someId");
+ setters.set('className', "someClassName");
+ setters.set('bindingContext', "someBindingContext");
+
+ // view
+ setters.set('automationText', "automationText");
+ setters.set('originX', 0.2);
+ setters.set('originY', 0.2);
+ setters.set('isEnabled', false);
+ setters.set('isUserInteractionEnabled', false);
+
+ // action-bar
+ setters.set('title', 'title');
+ setters.set('text', 'text');
+ setters.set('icon', '~/logo.png');
+ setters.set('visibility', 'collapse');
+
+ // activity-indicator
+ setters.set('busy', true);
+
+ // date-picker
+ setters.set('year', '2010');
+ setters.set('month', '2');
+ setters.set('day', '2');
+ setters.set('maxDate', '2100');
+ setters.set('minDate', '2000');
+ setters.set('date', new Date(2011, 3, 3));
+
+ // editable-text
+ setters.set('keyboardType', 'datetime');
+ setters.set('returnKeyType', 'done');
+ setters.set('editable', false);
+ setters.set('updateTextTrigger', 'focusLost');
+ setters.set('autocapitalizationType', 'words');
+ setters.set('autocorrect', true);
+ setters.set('hint', 'hint');
+ setters.set('maxLength', '10');
+
+ // html-view
+ setters.set('html', '');
+
+ // image-view
+ setters.set('imageSource', '');
+ setters.set('src', '');
+ setters.set('loadMode', 'async');
+ setters.set('isLoading', true);
+ setters.set('stretch', 'none');
+
+ // layout-base
+ setters.set('clipToBounds', false);
+
+ // absolute-layout
+ setters.set('left', '20');
+ setters.set('top', '20');
+
+ // dock-layout
+ setters.set('dock', 'top');
+ setters.set('stretchLastChild', false);
+
+ // grid-layout props
+ setters.set('row', '1');
+ setters.set('rowSpan', '2');
+ setters.set('col', '1');
+ setters.set('colSpan', '2');
+
+ // stack-layout
+ setters.set('orientation', 'horizontal');
+
+ // wrap-layout
+ // custom orientation value
+ // setters.set('orientation', 'vertical');
+ setters.set('itemWidth', '50');
+ setters.set('itemHeight', '50');
+
+ // list-picker
+ setters.set('items', ['1', '2', '3']);
+ setters.set('selectedIndex', '1');
+
+ // list-view
+ setters.set('items', ['1', '2', '3']);
+ setters.set('itemTemplate', '');
+ setters.set('itemTemplates', '');
+ setters.set('rowHeight', '50');
+
+ // page
+ setters.set('actionBarHidden', 'true');
+ setters.set('backgroundSpanUnderStatusBar', 'true');
+ setters.set('enableSwipeBackNavigation', 'false');
+
+ // progress
+ setters.set('value', '1');
+ setters.set('maxValue', '99');
+
+ // repeater
+ setters.set('items', ['1', '2', '3']);
+ setters.set('itemTemplate', '');
+ setters.set('itemsLayout', new StackLayout());
+ setters.set('rowHeight', '50');
+
+ // scroll-view
+ // custom orientation value
+ //setters.set('orientation', 'horizontal');
+
+ // search-bar
+ setters.set('textFieldHintColor', 'red');
+ setters.set('textFieldBackgroundColor', 'red');
+
+ // segmented-bar
+ // custom items property
+
+ // slider
+ setters.set('minValue', '5');
+
+ // switch
+ setters.set('checked', 'true');
+
+ // tab-view
+ // custom items property
+ setters.set('androidOffscreenTabLimit', '2');
+
+ // text-base
+ const formattedText = new FormattedString();
+ const span = new Span();
+ span.text = 'span';
+ formattedText.spans.push(span);
+ setters.set('formattedText', formattedText);
+
+ // text-base
+ setters.set('secure', 'true');
+
+ // time-picker
+ setters.set('minHour', 1);
+ setters.set('hour', 2);
+ setters.set('maxHour', 11);
+ setters.set('minMinute', 1);
+ setters.set('minute', 2);
+ setters.set('maxMinute', 11);
+ setters.set('minuteInterval', 2);
+ setters.set('time', new Date(2011, 2, 2, 3, 3, 3));
+
+ cssSetters = new Map();
+
+ // style
+ cssSetters.set('rotate', '90');
+ cssSetters.set('scaleX', 2);
+ cssSetters.set('scaleY', 2);
+ cssSetters.set('translateX', 20);
+ cssSetters.set('translateY', 20);
+
+ cssSetters.set('clipPath', 'inset(100px 50px)');
+ cssSetters.set('color', 'red');
+ cssSetters.set('tintColor', 'green');
+ cssSetters.set('placeholderColor', 'green');
+
+ cssSetters.set('backgroundColor', 'red');
+ cssSetters.set('backgroundImage', '~/logo.png');
+ cssSetters.set('backgroundRepeat', 'repeat');
+ cssSetters.set('backgroundSize', '60px 120px');
+ cssSetters.set('backgroundPosition', 'center');
+ cssSetters.set('borderColor', 'blue');
+ cssSetters.set('borderTopColor', 'green');
+ cssSetters.set('borderRightColor', 'green');
+ cssSetters.set('borderBottomColor', 'green');
+ cssSetters.set('borderLeftColor', 'green');
+ cssSetters.set('borderWidth', '10px');
+ cssSetters.set('borderTopWidth', '5px');
+ cssSetters.set('borderRightWidth', '5px');
+ cssSetters.set('borderBottomWidth', '5px');
+ cssSetters.set('borderLeftWidth', '5px');
+ cssSetters.set('borderRadius', '10px');
+ cssSetters.set('borderTopLeftRadius', '5px');
+ cssSetters.set('borderTopRightRadius', '5px');
+ cssSetters.set('borderBottomRightRadius', '5px');
+ cssSetters.set('borderBottomLeftRadius', '5px');
+
+ cssSetters.set('fontSize', '20');
+ cssSetters.set('fontFamily', 'monospace');
+ cssSetters.set('fontStyle', 'italic');
+ cssSetters.set('fontWeight', '100');
+ cssSetters.set('font', 'italic 2 "Open Sans", sans-serif');
+
+ // zIndex on android is not what you think...
+ // cssSetters.set('zIndex', '2');
+ cssSetters.set('opacity', '0.5');
+ // already set through view properties.
+ // cssSetters.set('visibility', 'collapse');
+
+ cssSetters.set('letterSpacing', '2');
+ cssSetters.set('textAlignment', 'center');
+ cssSetters.set('textDecoration', 'underline');
+ cssSetters.set('textTransform', 'capitalize');
+ cssSetters.set('whiteSpace', 'normal');
+
+ cssSetters.set('minWidth', 50);
+ cssSetters.set('minHeight', 50);
+ cssSetters.set('width', 100);
+ cssSetters.set('height', 100);
+ cssSetters.set('margin', '25');
+ cssSetters.set('marginLeft', '30px');
+ cssSetters.set('marginTop', '30px');
+ cssSetters.set('marginRight', '30px');
+ cssSetters.set('marginBottom', '30px');
+ cssSetters.set('padding', '25');
+ cssSetters.set('paddingLeft', '30px');
+ cssSetters.set('paddingTop', '30px');
+ cssSetters.set('paddingRight', '30px');
+ cssSetters.set('paddingBottom', '30px');
+ cssSetters.set('horizontalAlignment', 'center');
+ cssSetters.set('verticalAlignment', 'center');
+
+ cssSetters.set('transform', 'translate(5, 10), scale(1.2, 1.2), rotate(45)');
+
+ // TabView-specific props
+ cssSetters.set('tabTextColor', 'red');
+ cssSetters.set('tabBackgroundColor', 'red');
+ cssSetters.set('selectedTabTextColor', 'red');
+ cssSetters.set('androidSelectedTabHighlightColor', 'red');
+
+ // ListView-specific props
+ cssSetters.set('separatorColor', 'red');
+
+ // SegmentedBar-specific props
+ cssSetters.set('selectedBackgroundColor', 'red');
+
+ // Page-specific props
+ cssSetters.set('statusBarStyle', 'light');
+ cssSetters.set('androidStatusBarBackground', 'red');
+
+ // Flexbox-layout props
+ cssSetters.set('flexDirection', 'column');
+ cssSetters.set('flexWrap', 'wrap');
+ cssSetters.set('justifyContent', 'center');
+ cssSetters.set('alignItems', 'center');
+ cssSetters.set('alignContent', 'center');
+ cssSetters.set('order', '2');
+ cssSetters.set('flexGrow', '1');
+ cssSetters.set('flexShrink', '0');
+ cssSetters.set('flexWrapBefore', 'true');
+ cssSetters.set('alignSelf', 'center');
+ cssSetters.set('flexFlow', 'row-reverse wrap');
+ cssSetters.set('flex', '2 0.2');
+
+ const nativeGetters = defaultNativeGetters = new Map any>();
+
+ nativeGetters.set("marginLeft", (v: { nativeView: android.view.View }) => {
+ const lp = v.nativeView.getLayoutParams();
+ return (lp instanceof android.view.ViewGroup.MarginLayoutParams) ? lp.leftMargin : 0;
+ });
+
+ nativeGetters.set("marginTop", (v: { nativeView: android.view.View }) => {
+ const lp = v.nativeView.getLayoutParams();
+ return (lp instanceof android.view.ViewGroup.MarginLayoutParams) ? lp.topMargin : 0;
+ });
+
+ nativeGetters.set("marginRight", (v: { nativeView: android.view.View }) => {
+ const lp = v.nativeView.getLayoutParams();
+ return (lp instanceof android.view.ViewGroup.MarginLayoutParams) ? lp.rightMargin : 0;
+ });
+
+ nativeGetters.set("marginBottom", (v: { nativeView: android.view.View }) => {
+ const lp = v.nativeView.getLayoutParams();
+ return (lp instanceof android.view.ViewGroup.MarginLayoutParams) ? lp.bottomMargin : 0;
+ });
+
+ nativeGetters.set("col", (v: { nativeView: android.view.View }) => {
+ const lp = v.nativeView.getLayoutParams();
+ return (lp instanceof org.nativescript.widgets.CommonLayoutParams) ? lp.column : 0;
+ });
+
+ nativeGetters.set("colSpan", (v: { nativeView: android.view.View }) => {
+ const lp = v.nativeView.getLayoutParams();
+ return (lp instanceof org.nativescript.widgets.CommonLayoutParams) ? lp.columnSpan : 1;
+ });
+
+ nativeGetters.set("row", (v: { nativeView: android.view.View }) => {
+ const lp = v.nativeView.getLayoutParams();
+ return (lp instanceof org.nativescript.widgets.CommonLayoutParams) ? lp.column : 0;
+ });
+
+ nativeGetters.set("rowSpan", (v: { nativeView: android.view.View }) => {
+ const lp = v.nativeView.getLayoutParams();
+ return (lp instanceof org.nativescript.widgets.CommonLayoutParams) ? lp.columnSpan : 1;
+ });
+
+ nativeGetters.set("width", (v: { nativeView: android.view.View }) => {
+ const native = v.nativeView;
+ if (native.getParent() instanceof org.nativescript.widgets.FlexboxLayout) {
+ return -2;
+ }
+ return native.getLayoutParams().width;
+ });
+ nativeGetters.set("height", (v: { nativeView: android.view.View }) => {
+ const native = v.nativeView;
+ if (native.getParent() instanceof org.nativescript.widgets.FlexboxLayout) {
+ return -2;
+ }
+ return native.getLayoutParams().height;
+ });
+
+ nativeGetters.set("paddingLeft", (v: { nativeView: android.view.View }) => v.nativeView.getPaddingLeft());
+ nativeGetters.set("paddingTop", (v: { nativeView: android.view.View }) => v.nativeView.getPaddingTop());
+ nativeGetters.set("paddingRight", (v: { nativeView: android.view.View }) => v.nativeView.getPaddingRight());
+ nativeGetters.set("paddingBottom", (v: { nativeView: android.view.View }) => v.nativeView.getPaddingBottom());
+
+ nativeGetters.set("minWidth", (v: { nativeView: android.view.View }) => v.nativeView.getMinimumWidth());
+ nativeGetters.set("minHeight", (v: { nativeView: android.view.View }) => v.nativeView.getMinimumHeight());
+
+ nativeGetters.set("scaleX", (v: { nativeView: android.view.View }) => v.nativeView.getScaleX());
+ nativeGetters.set("scaleY", (v: { nativeView: android.view.View }) => v.nativeView.getScaleY());
+ nativeGetters.set("translateX", (v: { nativeView: android.view.View }) => v.nativeView.getTranslationX());
+ nativeGetters.set("translateY", (v: { nativeView: android.view.View }) => v.nativeView.getTranslationY());
+ nativeGetters.set("isEnabled", (v: { nativeView: android.view.View }) => v.nativeView.isEnabled());
+ nativeGetters.set("rotate", (v: { nativeView: android.view.View }) => v.nativeView.getRotation());
+
+ nativeGetters.set("order", (v: { nativeView: android.view.View }) => {
+ const lp = v.nativeView.getLayoutParams();
+ return (lp instanceof org.nativescript.widgets.FlexboxLayout.LayoutParams) ? lp.order : 1;
+ });
+
+ nativeGetters.set("flexGrow", (v: { nativeView: android.view.View }) => {
+ const lp = v.nativeView.getLayoutParams();
+ return (lp instanceof org.nativescript.widgets.FlexboxLayout.LayoutParams) ? lp.flexGrow : 0;
+ });
+
+ nativeGetters.set("flexShrink", (v: { nativeView: android.view.View }) => {
+ const lp = v.nativeView.getLayoutParams();
+ return (lp instanceof org.nativescript.widgets.FlexboxLayout.LayoutParams) ? lp.flexShrink : 1;
+ });
+
+ nativeGetters.set("flexWrapBefore", (v: { nativeView: android.view.View }) => {
+ const lp = v.nativeView.getLayoutParams();
+ return (lp instanceof org.nativescript.widgets.FlexboxLayout.LayoutParams) ? lp.wrapBefore : false;
+ });
+
+ nativeGetters.set("alignSelf", (v: { nativeView: android.view.View }) => {
+ const lp = v.nativeView.getLayoutParams();
+ return (lp instanceof org.nativescript.widgets.FlexboxLayout.LayoutParams) ? lp.alignSelf : "auto";
+ });
+
+ nativeGetters.set("formattedText", (v: { nativeView: android.view.View }) => {
+ const nativeView = v.nativeView;
+ return (nativeView instanceof android.widget.TextView) ? nativeView.getText().toString() : undefined;
+ });
+
+ nativeGetters.set("isUserInteractionEnabled", (v) => true);
+
+ nativeGetters.set("orientation", (v: { nativeView: android.view.View }) => {
+ const nativeView = v.nativeView;
+ if (nativeView instanceof org.nativescript.widgets.StackLayout) {
+ return nativeView.getOrientation();
+ } else if (nativeView instanceof org.nativescript.widgets.WrapLayout) {
+ return nativeView.getOrientation();
+ }
+ });
+
+ nativeGetters.set("textTransform", (v: { nativeView: android.view.View }) => {
+ const nativeView = v.nativeView;
+ if (nativeView instanceof android.widget.TextView) {
+ return nativeView.getTransformationMethod();
+ }
+ });
+
+ nativeGetters.set("editable", (v: { nativeView: android.view.View }) => {
+ const nativeView = v.nativeView;
+ if (nativeView instanceof android.widget.TextView) {
+ return nativeView.getKeyListener();
+ }
+ });
+
+ nativeGetters.set("maxLength", (v: { nativeView: android.view.View }) => {
+ const nativeView = v.nativeView;
+ if (nativeView instanceof android.widget.TextView) {
+ return nativeView.getFilters();
+ }
+ });
+
+ nativeGetters.set("whiteSpace", (v: { nativeView: android.view.View }) => {
+ const nativeView = v.nativeView;
+ if (nativeView instanceof android.widget.TextView) {
+ return { lineCount: nativeView.getLineCount(), ellipsize: nativeView.getEllipsize() };
+ }
+ });
+
+ nativeGetters.set("text", (v: { nativeView: android.view.View }) => {
+ const nativeView = v.nativeView;
+ if (nativeView instanceof android.widget.TextView) {
+ const text = nativeView.getText();
+ return text ? text.toString() : text;
+ }
+ });
+}
\ No newline at end of file
diff --git a/tests/app/ui/html-view/html-view-tests.ts b/tests/app/ui/html-view/html-view-tests.ts
index 50abcc5ad..8d19ae417 100644
--- a/tests/app/ui/html-view/html-view-tests.ts
+++ b/tests/app/ui/html-view/html-view-tests.ts
@@ -6,6 +6,10 @@ import * as types from "tns-core-modules/utils/types";
import * as htmlViewModule from "tns-core-modules/ui/html-view";
// << htmlview-require
+export function test_recycling() {
+ helper.nativeView_recycling_test(() => new htmlViewModule.HtmlView());
+}
+
var _createHtmlViewFunc = function (): htmlViewModule.HtmlView {
// >> htmlview-create
var htmlView = new htmlViewModule.HtmlView();
diff --git a/tests/app/ui/image/image-tests.ts b/tests/app/ui/image/image-tests.ts
index a566ca6bd..16633856a 100644
--- a/tests/app/ui/image/image-tests.ts
+++ b/tests/app/ui/image/image-tests.ts
@@ -21,6 +21,10 @@ import * as backgroundModule from "tns-core-modules/ui/styling/background";
import { android as androidApp } from "tns-core-modules/application";
const imagePath = "~/logo.png";
+export function test_recycling() {
+ helper.nativeView_recycling_test(() => new Image());
+}
+
if (isAndroid) {
(backgroundModule).initImageCache(androidApp.startActivity, (backgroundModule).CacheMode.memory); // use memory cache only.
}
diff --git a/tests/app/ui/label/label-tests.ts b/tests/app/ui/label/label-tests.ts
index e296a8a86..fad7aa778 100644
--- a/tests/app/ui/label/label-tests.ts
+++ b/tests/app/ui/label/label-tests.ts
@@ -29,6 +29,10 @@ export class LabelTest extends testModule.UITest {
return label;
}
+ public test_recycling() {
+ helper.nativeView_recycling_test(() => new LabelModule.Label());
+ }
+
public test_Label_Members() {
const label = new LabelModule.Label();
TKUnit.assert(types.isDefined(label.text), "Label.text is not defined");
diff --git a/tests/app/ui/layouts/absolute-layout-tests.ts b/tests/app/ui/layouts/absolute-layout-tests.ts
index f49ab25eb..be4bc45a8 100644
--- a/tests/app/ui/layouts/absolute-layout-tests.ts
+++ b/tests/app/ui/layouts/absolute-layout-tests.ts
@@ -4,6 +4,7 @@ import * as labelModule from "tns-core-modules/ui/label";
import * as colorModule from "tns-core-modules/color";
import * as layoutHelper from "./layout-helper";
import * as commonTests from "./common-layout-tests";
+import * as helper from "../helper";
// >> absolute-layout-require
import * as absoluteLayoutModule from "tns-core-modules/ui/layouts/absolute-layout";
@@ -15,6 +16,14 @@ export class AbsoluteLayoutTest extends testModule.UITest new absoluteLayoutModule.AbsoluteLayout());
+ }
+
+ public test_item_recycling() {
+ helper.nativeView_recycling_test(() => new labelModule.Label(), () => new absoluteLayoutModule.AbsoluteLayout());
+ }
+
public snippet() {
// >> absolute-layout-populating
diff --git a/tests/app/ui/layouts/dock-layout-tests.ts b/tests/app/ui/layouts/dock-layout-tests.ts
index 07b0782ce..93a97d4cc 100644
--- a/tests/app/ui/layouts/dock-layout-tests.ts
+++ b/tests/app/ui/layouts/dock-layout-tests.ts
@@ -4,6 +4,7 @@ import * as TKUnit from "../../TKUnit";
import * as helper from "./layout-helper";
import * as testModule from "../../ui-test";
import * as commonTests from "./common-layout-tests";
+import * as testHelper from "../helper";
// >> dock-layout-require
import * as dockModule from "tns-core-modules/ui/layouts/dock-layout";
@@ -22,6 +23,14 @@ export class DockLayoutTest extends testModule.UITest {
return rootLayout;
}
+ public test_recycling() {
+ testHelper.nativeView_recycling_test(() => new DockLayout());
+ }
+
+ public test_item_recycling() {
+ testHelper.nativeView_recycling_test(() => new button.Button(), () => new DockLayout());
+ }
+
public test_stretchLastChild_DefaultValue() {
TKUnit.assertEqual(this.testView.stretchLastChild, true, "Default stretchLastChild.");
}
diff --git a/tests/app/ui/layouts/flexbox-layout-tests.ts b/tests/app/ui/layouts/flexbox-layout-tests.ts
index 21d6e7e82..b0d7e6cd0 100644
--- a/tests/app/ui/layouts/flexbox-layout-tests.ts
+++ b/tests/app/ui/layouts/flexbox-layout-tests.ts
@@ -2,6 +2,8 @@
import { FlexboxLayout } from "tns-core-modules/ui/layouts/flexbox-layout";
// << flexbox-layout-require
+import { Button } from "tns-core-modules/ui/button";
+
export namespace FlexDirection {
export const ROW: "row" = "row";
export const ROW_REVERSE: "row-reverse" = "row-reverse";
@@ -49,12 +51,12 @@ export namespace AlignSelf {
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 { View, unsetValue, Length, PercentLength } from "tns-core-modules/ui/core/view";
+import { Label } from "tns-core-modules/ui/label";
import * as TKUnit from "../../TKUnit";
import * as helper from "../helper";
-import {layout} from "tns-core-modules/utils/utils";
-import {parse} from "tns-core-modules/ui/builder";
+import { layout } from "tns-core-modules/utils/utils";
+import { parse } from "tns-core-modules/ui/builder";
// TODO: Test the flexbox-layout-page.xml can be loaded and displayed
@@ -85,7 +87,7 @@ function commonAncestor(view1: View, view2: View): View {
set.add(view2);
view2 = view2.parent;
}
- } while(view1 || view2);
+ } while (view1 || view2);
return null;
}
@@ -106,7 +108,7 @@ function bounds(view: View): Bounds {
*/
function boundsToAncestor(child: View, ancestor: View = null) {
let currentBounds = bounds(child);
- while(child && child !== ancestor) {
+ while (child && child !== ancestor) {
child = child.parent;
let childBounds = bounds(child);
currentBounds.left += childBounds.left;
@@ -239,7 +241,8 @@ function test(ui: () => U, setup: (ui: U) => void, tes
let getViews = (template: string) => {
let root = parse(template);
- return { root,
+ return {
+ root,
flexbox: root.getViewById("flexbox") as FlexboxLayout,
text1: root.getViewById("text1") as Label,
text2: root.getViewById("text2") as Label,
@@ -262,10 +265,18 @@ let activity_flex_wrap = () => getViews(
`
);
+export function test_recycling() {
+ helper.nativeView_recycling_test(() => new FlexboxLayout());
+}
+
+export function test_item_recycling() {
+ helper.nativeView_recycling_test(() => new Button(), () => new FlexboxLayout());
+}
+
export const testFlexWrap_wrap = test(
activity_flex_wrap,
- ({flexbox}) => flexbox.flexWrap = FlexWrap.WRAP,
- ({root, flexbox, text1, text2, text3}) => {
+ ({ flexbox }) => flexbox.flexWrap = FlexWrap.WRAP,
+ ({ root, flexbox, text1, text2, text3 }) => {
isLeftAlignedWith(text1, flexbox);
isTopAlignedWith(text1, flexbox);
isRightOf(text2, text1);
@@ -279,8 +290,8 @@ export const testFlexWrap_wrap = test(
export const testFlexWrap_nowrap = test(
activity_flex_wrap,
- ({flexbox}) => flexbox.flexWrap = FlexWrap.NOWRAP,
- ({root, flexbox, text1, text2, text3}) => {
+ ({ flexbox }) => flexbox.flexWrap = FlexWrap.NOWRAP,
+ ({ root, flexbox, text1, text2, text3 }) => {
isLeftAlignedWith(text1, flexbox);
isTopAlignedWith(text1, flexbox);
isRightOf(text2, text1);
@@ -293,8 +304,8 @@ export const testFlexWrap_nowrap = test(
export const testFlexWrap_wrap_reverse = test(
activity_flex_wrap,
- ({flexbox}) => flexbox.flexWrap = FlexWrap.WRAP_REVERSE,
- ({root, flexbox, text1, text2, text3}) => {
+ ({ flexbox }) => flexbox.flexWrap = FlexWrap.WRAP_REVERSE,
+ ({ root, flexbox, text1, text2, text3 }) => {
isLeftAlignedWith(text1, flexbox);
isRightOf(text2, text1);
isAbove(text3, text1);
@@ -306,8 +317,8 @@ export const testFlexWrap_wrap_reverse = test(
export const testFlexWrap_wrap_flexDirection_column = test(
activity_flex_wrap,
- ({flexbox}) => flexbox.flexDirection = FlexDirection.COLUMN,
- ({root, flexbox, text1, text2, text3}) => {
+ ({ flexbox }) => flexbox.flexDirection = FlexDirection.COLUMN,
+ ({ root, flexbox, text1, text2, text3 }) => {
isLeftAlignedWith(text1, flexbox);
isTopAlignedWith(text1, flexbox);
isBelow(text2, text1);
@@ -321,10 +332,10 @@ export const testFlexWrap_wrap_flexDirection_column = test(
export const testFlexWrap_nowrap_flexDirection_column = test(
activity_flex_wrap,
- ({flexbox}) => {
+ ({ flexbox }) => {
flexbox.flexDirection = FlexDirection.COLUMN;
flexbox.flexWrap = FlexWrap.NOWRAP;
- }, ({root, flexbox, text1, text2, text3}) => {
+ }, ({ root, flexbox, text1, text2, text3 }) => {
isLeftAlignedWith(text1, flexbox);
isTopAlignedWith(text1, flexbox);
isBelow(text2, text1);
@@ -337,10 +348,10 @@ export const testFlexWrap_nowrap_flexDirection_column = test(
export const testFlexWrap_wrap_reverse_flexDirection_column = test(
activity_flex_wrap,
- ({flexbox}) => {
+ ({ flexbox }) => {
flexbox.flexDirection = FlexDirection.COLUMN;
flexbox.flexWrap = FlexWrap.WRAP_REVERSE;
- }, ({root, flexbox, text1, text2, text3}) => {
+ }, ({ root, flexbox, text1, text2, text3 }) => {
isTopAlignedWith(text1, flexbox);
isRightAlignedWith(text1, flexbox);
isBelow(text2, text1);
@@ -369,7 +380,7 @@ let activity_flex_item_match_parent = () => getViews(
export const testFlexItem_match_parent = test(
activity_flex_item_match_parent,
noop,
- ({root, flexbox, text1, text2, text3}) => {
+ ({ root, flexbox, text1, text2, text3 }) => {
widthEqual(text1, flexbox);
widthEqual(text2, flexbox);
widthEqual(text3, flexbox);
@@ -395,7 +406,7 @@ let activity_flex_item_match_parent_direction_column = () => getViews(
export const testFlexItem_match_parent_flexDirection_column = test(
activity_flex_item_match_parent_direction_column,
noop,
- ({root, flexbox, text1, text2, text3}) => {
+ ({ root, flexbox, text1, text2, text3 }) => {
heightEqual(text1, flexbox);
heightEqual(text2, flexbox);
heightEqual(text3, flexbox);
@@ -419,7 +430,7 @@ let activity_flexbox_wrap_content = () => getViews(
export const testFlexboxLayout_wrapContent = test(
activity_flexbox_wrap_content,
noop,
- ({root, flexbox, text1, text2, text3}) => {
+ ({ root, flexbox, text1, text2, text3 }) => {
isLeftAlignedWith(text1, flexbox);
isTopAlignedWith(text1, flexbox);
isBottomAlignedWith(text1, flexbox);
@@ -453,7 +464,7 @@ let activity_flexbox_wrapped_with_scrollview = () => getViews(
export const testFlexboxLayout_wrapped_with_ScrollView = test(
activity_flexbox_wrapped_with_scrollview,
noop,
- ({root, flexbox, text1, text2, text3}) => {
+ ({ root, flexbox, text1, text2, text3 }) => {
isLeftAlignedWith(text1, flexbox);
isTopAlignedWith(text1, flexbox);
@@ -481,7 +492,7 @@ let activity_flexbox_wrapped_with_horizontalscrollview = () => getViews(
export const testFlexboxLayout_wrapped_with_HorizontalScrollView = test(
activity_flexbox_wrapped_with_horizontalscrollview,
noop,
- ({root, flexbox, text1, text2, text3}) => {
+ ({ root, flexbox, text1, text2, text3 }) => {
isLeftAlignedWith(text1, flexbox);
isTopAlignedWith(text1, flexbox);
@@ -510,7 +521,7 @@ let activity_justify_content_test = () => getViews(
export const testJustifyContent_flexStart = test(
activity_justify_content_test,
noop,
- ({root, flexbox, text1, text2, text3}) => {
+ ({ root, flexbox, text1, text2, text3 }) => {
isTopAlignedWith(text1, flexbox);
isLeftAlignedWith(text1, flexbox);
isRightOf(text2, text1);
@@ -531,7 +542,7 @@ let activity_justify_content_with_parent_padding = () => getViews(
export const testJustifyContent_flexStart_withParentPadding = test(
activity_justify_content_with_parent_padding,
noop,
- ({root, flexbox, text1, text2, text3}) => {
+ ({ root, flexbox, text1, text2, text3 }) => {
isRightOf(text2, text1);
isRightOf(text3, text2);
equal(left(text1), Length.toDevicePixels(flexbox.style.paddingLeft, 0), `Expected ${text1}.left to equal ${flexbox}.paddingLeft`);
@@ -541,8 +552,8 @@ export const testJustifyContent_flexStart_withParentPadding = test(
export const testJustifyContent_flexEnd = test(
activity_justify_content_test,
- ({flexbox}) => flexbox.justifyContent = JustifyContent.FLEX_END,
- ({root, flexbox, text1, text2, text3}) => {
+ ({ flexbox }) => flexbox.justifyContent = JustifyContent.FLEX_END,
+ ({ root, flexbox, text1, text2, text3 }) => {
isTopAlignedWith(text3, flexbox);
isRightAlignedWith(text3, flexbox);
isLeftOf(text2, text3);
@@ -552,8 +563,8 @@ export const testJustifyContent_flexEnd = test(
export const testJustifyContent_flexEnd_withParentPadding = test(
activity_justify_content_with_parent_padding,
- ({flexbox}) => flexbox.justifyContent = JustifyContent.FLEX_END,
- ({root, flexbox, text1, text2, text3}) => {
+ ({ flexbox }) => flexbox.justifyContent = JustifyContent.FLEX_END,
+ ({ root, flexbox, text1, text2, text3 }) => {
isLeftOf(text2, text3);
isLeftOf(text1, text2);
closeEnough(width(flexbox) - right(text3), Length.toDevicePixels(flexbox.style.paddingRight, 0));
@@ -563,8 +574,8 @@ export const testJustifyContent_flexEnd_withParentPadding = test(
export const testJustifyContent_center = test(
activity_justify_content_test,
- ({flexbox}) => flexbox.justifyContent = JustifyContent.CENTER,
- ({root, flexbox, text1, text2, text3}) => {
+ ({ flexbox }) => flexbox.justifyContent = JustifyContent.CENTER,
+ ({ root, flexbox, text1, text2, text3 }) => {
isTopAlignedWith(text1, flexbox);
isRightOf(text2, text1);
isTopAlignedWith(text2, flexbox);
@@ -580,8 +591,8 @@ export const testJustifyContent_center = test(
export const testJustifyContent_center_withParentPadding = test(
activity_justify_content_with_parent_padding,
- ({flexbox}) => flexbox.justifyContent = JustifyContent.CENTER,
- ({root, flexbox, text1, text2, text3}) => {
+ ({ flexbox }) => flexbox.justifyContent = JustifyContent.CENTER,
+ ({ root, flexbox, text1, text2, text3 }) => {
isRightOf(text2, text1);
isRightOf(text3, text2);
let space = width(flexbox) - width(text1) - width(text2) - width(text3) - Length.toDevicePixels(flexbox.style.paddingLeft, 0) - Length.toDevicePixels(flexbox.style.paddingRight, 0);
@@ -593,8 +604,8 @@ export const testJustifyContent_center_withParentPadding = test(
export const testJustifyContent_spaceBetween = test(
activity_justify_content_test,
- ({flexbox}) => flexbox.justifyContent = JustifyContent.SPACE_BETWEEN,
- ({root, flexbox, text1, text2, text3}) => {
+ ({ flexbox }) => flexbox.justifyContent = JustifyContent.SPACE_BETWEEN,
+ ({ root, flexbox, text1, text2, text3 }) => {
isTopAlignedWith(text1, flexbox);
isLeftAlignedWith(text1, flexbox);
isTopAlignedWith(text2, flexbox);
@@ -609,11 +620,11 @@ export const testJustifyContent_spaceBetween = test(
export const testJustifyContent_spaceBetween_withPadding = test(
activity_justify_content_test,
- ({flexbox}) => {
+ ({ flexbox }) => {
flexbox.justifyContent = JustifyContent.SPACE_BETWEEN;
flexbox.style.padding = padding;
},
- ({root, flexbox, text1, text2, text3}) => {
+ ({ root, flexbox, text1, text2, text3 }) => {
let space = width(flexbox) - width(text1) - width(text2) - width(text3) - dipToDp(padding) * 2;
space = space / 2;
closeEnough(left(text1), dipToDp(padding));
@@ -625,8 +636,8 @@ export const testJustifyContent_spaceBetween_withPadding = test(
export const testJustifyContent_spaceAround = test(
activity_justify_content_test,
- ({flexbox}) => flexbox.justifyContent = JustifyContent.SPACE_AROUND,
- ({root, flexbox, text1, text2, text3}) => {
+ ({ flexbox }) => flexbox.justifyContent = JustifyContent.SPACE_AROUND,
+ ({ root, flexbox, text1, text2, text3 }) => {
isTopAlignedWith(text1, flexbox);
isTopAlignedWith(text2, flexbox);
isTopAlignedWith(text3, flexbox);
@@ -646,11 +657,11 @@ const padding: any = 40;
export const testJustifyContent_spaceAround_withPadding = test(
activity_justify_content_test,
- ({flexbox}) => {
+ ({ flexbox }) => {
flexbox.justifyContent = JustifyContent.SPACE_AROUND;
flexbox.style.padding = padding;
},
- ({root, flexbox, text1, text2, text3}) => {
+ ({ root, flexbox, text1, text2, text3 }) => {
let space = width(flexbox) - width(text1) - width(text2) - width(text3) - dipToDp(padding) * 2;
space = space / 6; // Divide by the number of children * 2
check(space - 1 <= left(text1) - dipToDp(padding) && left(text1) - dipToDp(padding) <= space + 1);
@@ -664,8 +675,8 @@ export const testJustifyContent_spaceAround_withPadding = test(
export const testJustifyContent_flexStart_flexDirection_column = test(
activity_justify_content_test,
- ({flexbox}) => flexbox.flexDirection = FlexDirection.COLUMN,
- ({root, flexbox, text1, text2, text3}) => {
+ ({ flexbox }) => flexbox.flexDirection = FlexDirection.COLUMN,
+ ({ root, flexbox, text1, text2, text3 }) => {
isTopAlignedWith(text1, flexbox);
isLeftAlignedWith(text1, flexbox);
isBelow(text2, text1);
@@ -677,11 +688,11 @@ export const testJustifyContent_flexStart_flexDirection_column = test(
export const testJustifyContent_flexEnd_flexDirection_column = test(
activity_justify_content_test,
- ({flexbox}) => {
+ ({ flexbox }) => {
flexbox.justifyContent = JustifyContent.FLEX_END;
flexbox.flexDirection = FlexDirection.COLUMN;
},
- ({root, flexbox, text1, text2, text3}) => {
+ ({ root, flexbox, text1, text2, text3 }) => {
isBottomAlignedWith(text3, flexbox);
isRightAlignedWith(text3, flexbox);
isAbove(text2, text3);
@@ -691,11 +702,11 @@ export const testJustifyContent_flexEnd_flexDirection_column = test(
export const testJustifyContent_center_flexDirection_column = test(
activity_justify_content_test,
- ({flexbox}) => {
+ ({ flexbox }) => {
flexbox.justifyContent = JustifyContent.CENTER;
flexbox.flexDirection = FlexDirection.COLUMN;
},
- ({root, flexbox, text1, text2, text3}) => {
+ ({ root, flexbox, text1, text2, text3 }) => {
isLeftAlignedWith(text1, flexbox);
isBelow(text2, text1);
isLeftAlignedWith(text2, flexbox);
@@ -711,11 +722,11 @@ export const testJustifyContent_center_flexDirection_column = test(
export const testJustifyContent_spaceBetween_flexDirection_column = test(
activity_justify_content_test,
- ({flexbox}) => {
+ ({ flexbox }) => {
flexbox.justifyContent = JustifyContent.SPACE_BETWEEN;
flexbox.flexDirection = FlexDirection.COLUMN;
},
- ({root, flexbox, text1, text2, text3}) => {
+ ({ root, flexbox, text1, text2, text3 }) => {
isTopAlignedWith(text1, flexbox);
isLeftAlignedWith(text1, flexbox);
isLeftAlignedWith(text2, flexbox);
@@ -731,12 +742,12 @@ export const testJustifyContent_spaceBetween_flexDirection_column = test(
export const testJustifyContent_spaceBetween_flexDirection_column_withPadding = test(
activity_justify_content_test,
- ({flexbox}) => {
+ ({ flexbox }) => {
flexbox.justifyContent = JustifyContent.SPACE_BETWEEN;
flexbox.flexDirection = FlexDirection.COLUMN;
flexbox.style.padding = padding;
},
- ({root, flexbox, text1, text2, text3}) => {
+ ({ root, flexbox, text1, text2, text3 }) => {
let space = height(flexbox) - height(text1) - height(text2) - height(text3) - dipToDp(padding) * 2;
space = space / 2;
closeEnough(top(text1), dipToDp(padding));
@@ -748,11 +759,11 @@ export const testJustifyContent_spaceBetween_flexDirection_column_withPadding =
export const testJustifyContent_spaceAround_flexDirection_column = test(
activity_justify_content_test,
- ({flexbox}) => {
+ ({ flexbox }) => {
flexbox.justifyContent = JustifyContent.SPACE_AROUND
flexbox.flexDirection = FlexDirection.COLUMN;
},
- ({root, flexbox, text1, text2, text3}) => {
+ ({ root, flexbox, text1, text2, text3 }) => {
isLeftAlignedWith(text1, flexbox);
isLeftAlignedWith(text2, flexbox);
isLeftAlignedWith(text3, flexbox);
@@ -770,12 +781,12 @@ export const testJustifyContent_spaceAround_flexDirection_column = test(
export const testJustifyContent_spaceAround_flexDirection_column_withPadding = test(
activity_justify_content_test,
- ({flexbox}) => {
+ ({ flexbox }) => {
flexbox.justifyContent = JustifyContent.SPACE_AROUND;
flexbox.flexDirection = FlexDirection.COLUMN;
flexbox.style.padding = padding;
},
- ({root, flexbox, text1, text2, text3}) => {
+ ({ root, flexbox, text1, text2, text3 }) => {
let space = height(flexbox) - height(text1) - height(text2) - height(text3) - dipToDp(padding) * 2;
space = space / 6; // Divide by the number of children * 2
check(space - 1 <= top(text1) - dipToDp(padding) && top(text1) - dipToDp(padding) <= space + 1);
@@ -788,7 +799,7 @@ export const testJustifyContent_spaceAround_flexDirection_column_withPadding = t
);
let activity_flex_grow_test = () => getViews(
- `
+ `
@@ -798,7 +809,7 @@ let activity_flex_grow_test = () => getViews(
export const testFlexGrow_withExactParentLength = test(
activity_flex_grow_test,
noop,
- ({root, flexbox, text1, text2, text3}) => {
+ ({ root, flexbox, text1, text2, text3 }) => {
isTopAlignedWith(text1, flexbox);
isLeftAlignedWith(text1, flexbox);
isTopAlignedWith(text2, flexbox);
@@ -813,8 +824,8 @@ export const testFlexGrow_withExactParentLength = test(
export const testFlexGrow_withExactParentLength_flexDirection_column = test(
activity_flex_grow_test,
- ({flexbox}) => flexbox.flexDirection = FlexDirection.COLUMN,
- ({root, flexbox, text1, text2, text3}) => {
+ ({ flexbox }) => flexbox.flexDirection = FlexDirection.COLUMN,
+ ({ root, flexbox, text1, text2, text3 }) => {
isTopAlignedWith(text1, flexbox);
isLeftAlignedWith(text1, flexbox);
isLeftAlignedWith(text2, flexbox);
@@ -830,8 +841,8 @@ export const testFlexGrow_withExactParentLength_flexDirection_column = test(
export const testFlexGrow_including_view_gone = test(
activity_flex_grow_test,
- ({flexbox, text2}) => text2.visibility = "collapse",
- ({root, flexbox, text1, text2, text3}) => {
+ ({ flexbox, text2 }) => text2.visibility = "collapse",
+ ({ root, flexbox, text1, text2, text3 }) => {
isTopAlignedWith(text1, flexbox);
isLeftAlignedWith(text1, flexbox);
@@ -854,12 +865,12 @@ let activity_align_content_test = () => getViews(
export const testAlignContent_stretch = test(
activity_align_content_test,
noop,
- ({root, flexbox, text1, text2, text3}) => {
+ ({ root, flexbox, text1, text2, text3 }) => {
isTopAlignedWith(text1, flexbox);
isLeftAlignedWith(text1, flexbox);
isTopAlignedWith(text2, flexbox);
- isRightOf(text2,text1);
-
+ isRightOf(text2, text1);
+
isLeftAlignedWith(text3, flexbox);
isBelow(text3, text1);
isBelow(text3, text2);
@@ -870,8 +881,8 @@ export const testAlignContent_stretch = test(
export const testAlignContent_flexStart = test(
activity_align_content_test,
- ({flexbox}) => flexbox.alignContent = AlignContent.FLEX_START,
- ({root, flexbox, text1, text2, text3}) => {
+ ({ flexbox }) => flexbox.alignContent = AlignContent.FLEX_START,
+ ({ root, flexbox, text1, text2, text3 }) => {
isTopAlignedWith(text1, flexbox);
isLeftAlignedWith(text1, flexbox);
isTopAlignedWith(text2, flexbox);
@@ -887,8 +898,8 @@ export const testAlignContent_flexStart = test(
export const testAlignContent_flexEnd = test(
activity_align_content_test,
- ({flexbox}) => flexbox.alignContent = AlignContent.FLEX_END,
- ({root, flexbox, text1, text2, text3}) => {
+ ({ flexbox }) => flexbox.alignContent = AlignContent.FLEX_END,
+ ({ root, flexbox, text1, text2, text3 }) => {
isLeftAlignedWith(text3, flexbox);
isBottomAlignedWith(text3, flexbox);
isAbove(text1, text3);
@@ -901,11 +912,11 @@ export const testAlignContent_flexEnd = test(
export const testAlignContent_flexEnd_parentPadding = test(
activity_align_content_test,
- ({flexbox}) => {
+ ({ flexbox }) => {
flexbox.alignContent = AlignContent.FLEX_END;
flexbox.style.padding = "32";
},
- ({root, flexbox, text1, text2, text3}) => {
+ ({ root, flexbox, text1, text2, text3 }) => {
isAbove(text1, text3);
isAbove(text1, text3);
isAbove(text2, text3);
@@ -916,12 +927,12 @@ export const testAlignContent_flexEnd_parentPadding = test(
export const testAlignContent_flexEnd_parentPadding_column = test(
activity_align_content_test,
- ({flexbox}) => {
+ ({ flexbox }) => {
flexbox.alignContent = AlignContent.FLEX_END;
flexbox.flexDirection = FlexDirection.COLUMN;
flexbox.style.padding = "32";
},
- ({root, flexbox, text1, text2, text3}) => {
+ ({ root, flexbox, text1, text2, text3 }) => {
isLeftOf(text1, text3);
isLeftOf(text2, text3);
@@ -932,8 +943,8 @@ export const testAlignContent_flexEnd_parentPadding_column = test(
export const testAlignContent_center = test(
activity_align_content_test,
- ({flexbox}) => flexbox.alignContent = AlignContent.CENTER,
- ({root, flexbox, text1, text2, text3}) => {
+ ({ flexbox }) => flexbox.alignContent = AlignContent.CENTER,
+ ({ root, flexbox, text1, text2, text3 }) => {
isLeftAlignedWith(text1, flexbox);
isRightOf(text2, text1);
isBelow(text3, text1);
@@ -950,8 +961,8 @@ export const testAlignContent_center = test(
export const testAlignContent_spaceBetween = test(
activity_align_content_test,
- ({flexbox}) => flexbox.alignContent = AlignContent.SPACE_BETWEEN,
- ({root, flexbox, text1, text2, text3}) => {
+ ({ flexbox }) => flexbox.alignContent = AlignContent.SPACE_BETWEEN,
+ ({ root, flexbox, text1, text2, text3 }) => {
isLeftAlignedWith(text1, flexbox);
isTopAlignedWith(text1, flexbox);
isRightOf(text2, text1);
@@ -964,8 +975,8 @@ export const testAlignContent_spaceBetween = test(
export const testAlignContent_spaceBetween_withPadding = test(
activity_align_content_test,
- ({flexbox}) => flexbox.alignContent = AlignContent.SPACE_BETWEEN,
- ({root, flexbox, text1, text2, text3}) => {
+ ({ flexbox }) => flexbox.alignContent = AlignContent.SPACE_BETWEEN,
+ ({ root, flexbox, text1, text2, text3 }) => {
isLeftAlignedWith(text1, flexbox);
isTopAlignedWith(text1, flexbox);
isRightOf(text2, text1);
@@ -977,8 +988,8 @@ export const testAlignContent_spaceBetween_withPadding = test(
export const testAlignContent_spaceAround = test(
activity_align_content_test,
- ({flexbox}) => flexbox.alignContent = AlignContent.SPACE_AROUND,
- ({root, flexbox, text1, text2, text3}) => {
+ ({ flexbox }) => flexbox.alignContent = AlignContent.SPACE_AROUND,
+ ({ root, flexbox, text1, text2, text3 }) => {
isLeftAlignedWith(text1, flexbox);
isRightOf(text2, text1);
isLeftAlignedWith(text3, flexbox);
@@ -996,11 +1007,11 @@ export const testAlignContent_spaceAround = test(
export const testAlignContent_stretch_parentWrapContent = test(
activity_align_content_test,
- ({flexbox}) => {
+ ({ flexbox }) => {
flexbox.height = unsetValue; // TODO: Check that "NaN" is auto-ish
flexbox.verticalAlignment = "top";
},
- ({root, flexbox, text1, text2, text3}) => {
+ ({ root, flexbox, text1, text2, text3 }) => {
isTopAlignedWith(text1, flexbox);
isLeftAlignedWith(text1, flexbox);
isTopAlignedWith(text2, flexbox);
@@ -1017,8 +1028,8 @@ export const testAlignContent_stretch_parentWrapContent = test(
export const testAlignContent_stretch_flexDirection_column = test(
activity_align_content_test,
- ({flexbox}) => flexbox.flexDirection = FlexDirection.COLUMN,
- ({root, flexbox, text1, text2, text3}) => {
+ ({ flexbox }) => flexbox.flexDirection = FlexDirection.COLUMN,
+ ({ root, flexbox, text1, text2, text3 }) => {
isTopAlignedWith(text1, flexbox);
isLeftAlignedWith(text1, flexbox);
isLeftAlignedWith(text2, flexbox);
@@ -1035,11 +1046,11 @@ export const testAlignContent_stretch_flexDirection_column = test(
export const testAlignContent_flexStart_flexDirection_column = test(
activity_align_content_test,
- ({flexbox}) => {
+ ({ flexbox }) => {
flexbox.alignContent = AlignContent.FLEX_START;
flexbox.flexDirection = FlexDirection.COLUMN;
},
- ({root, flexbox, text1, text2, text3}) => {
+ ({ root, flexbox, text1, text2, text3 }) => {
isTopAlignedWith(text1, flexbox);
isLeftAlignedWith(text1, flexbox);
isLeftAlignedWith(text2, flexbox);
@@ -1055,11 +1066,11 @@ export const testAlignContent_flexStart_flexDirection_column = test(
export const testAlignContent_flexEnd_flexDirection_column = test(
activity_align_content_test,
- ({flexbox}) => {
+ ({ flexbox }) => {
flexbox.alignContent = AlignContent.FLEX_END;
flexbox.flexDirection = FlexDirection.COLUMN;
},
- ({root, flexbox, text1, text2, text3}) => {
+ ({ root, flexbox, text1, text2, text3 }) => {
isRightAlignedWith(text3, flexbox);
isTopAlignedWith(text3, flexbox);
isLeftOf(text1, text3);
@@ -1072,11 +1083,11 @@ export const testAlignContent_flexEnd_flexDirection_column = test(
export const testAlignContent_center_flexDirection_column = test(
activity_align_content_test,
- ({flexbox}) => {
+ ({ flexbox }) => {
flexbox.alignContent = AlignContent.CENTER;
flexbox.flexDirection = FlexDirection.COLUMN;
},
- ({root, flexbox, text1, text2, text3}) => {
+ ({ root, flexbox, text1, text2, text3 }) => {
isTopAlignedWith(text1, flexbox);
isBelow(text2, text1);
isRightOf(text3, text1);
@@ -1093,11 +1104,11 @@ export const testAlignContent_center_flexDirection_column = test(
export const testAlignContent_spaceBetween_flexDirection_column = test(
activity_align_content_test,
- ({flexbox}) => {
+ ({ flexbox }) => {
flexbox.alignContent = AlignContent.SPACE_BETWEEN;
flexbox.flexDirection = FlexDirection.COLUMN;
},
- ({root, flexbox, text1, text2, text3}) => {
+ ({ root, flexbox, text1, text2, text3 }) => {
isLeftAlignedWith(text1, flexbox);
isTopAlignedWith(text1, flexbox);
isBelow(text2, text1);
@@ -1109,11 +1120,11 @@ export const testAlignContent_spaceBetween_flexDirection_column = test(
export const testAlignContent_spaceAround_flexDirection_column = test(
activity_align_content_test,
- ({flexbox}) => {
+ ({ flexbox }) => {
flexbox.alignContent = AlignContent.SPACE_AROUND;
flexbox.flexDirection = FlexDirection.COLUMN;
},
- ({root, flexbox, text1, text2, text3}) => {
+ ({ root, flexbox, text1, text2, text3 }) => {
isTopAlignedWith(text1, flexbox);
isBelow(text2, text1);
isTopAlignedWith(text3, flexbox);
@@ -1130,12 +1141,12 @@ export const testAlignContent_spaceAround_flexDirection_column = test(
export const testAlignContent_stretch_parentWrapContent_flexDirection_column = test(
activity_align_content_test,
- ({flexbox}) => {
+ ({ flexbox }) => {
flexbox.width = unsetValue; // TODO: Check default is Number.NaN
flexbox.horizontalAlignment = "left";
flexbox.flexDirection = FlexDirection.COLUMN;
},
- ({root, flexbox, text1, text2, text3}) => {
+ ({ root, flexbox, text1, text2, text3 }) => {
isTopAlignedWith(text1, flexbox);
isLeftAlignedWith(text1, flexbox);
isLeftAlignedWith(text2, flexbox);
@@ -1160,7 +1171,7 @@ let activity_stretch_test = () => getViews(
export const testAlignItems_stretch = test(
activity_stretch_test,
noop,
- ({root, flexbox, text1, text2, text3}) => {
+ ({ root, flexbox, text1, text2, text3 }) => {
isTopAlignedWith(text1, flexbox);
isLeftAlignedWith(text1, flexbox);
isTopAlignedWith(text2, flexbox);
@@ -1187,7 +1198,7 @@ let activity_align_self_stretch_test = () => getViews(
export const testAlignSelf_stretch = test(
activity_align_self_stretch_test,
noop,
- ({root, flexbox, text1, text2, text3}) => {
+ ({ root, flexbox, text1, text2, text3 }) => {
isTopAlignedWith(text1, flexbox);
isLeftAlignedWith(text1, flexbox);
isTopAlignedWith(text2, flexbox);
@@ -1208,8 +1219,8 @@ export const testAlignSelf_stretch = test(
export const testAlignSelf_stretch_flexDirection_column = test(
activity_align_self_stretch_test,
- ({flexbox}) => flexbox.flexDirection = FlexDirection.COLUMN,
- ({root, flexbox, text1, text2, text3}) => {
+ ({ flexbox }) => flexbox.flexDirection = FlexDirection.COLUMN,
+ ({ root, flexbox, text1, text2, text3 }) => {
isTopAlignedWith(text1, flexbox);
isLeftAlignedWith(text1, flexbox);
isLeftAlignedWith(text2, flexbox);
@@ -1236,8 +1247,8 @@ let activity_align_items_test = () => getViews(
export const testAlignItems_flexStart = test(
activity_align_items_test,
- ({flexbox}) => flexbox.alignItems = AlignItems.FLEX_START,
- ({root, flexbox, text1, text2, text3}) => {
+ ({ flexbox }) => flexbox.alignItems = AlignItems.FLEX_START,
+ ({ root, flexbox, text1, text2, text3 }) => {
isTopAlignedWith(text1, flexbox);
isLeftAlignedWith(text1, flexbox);
isTopAlignedWith(text2, flexbox);
@@ -1257,8 +1268,8 @@ export const testAlignItems_flexStart = test(
export const testAlignItems_flexEnd = test(
activity_align_items_test,
- ({flexbox}) => flexbox.alignItems = AlignItems.FLEX_END,
- ({root, flexbox, text1, text2, text3}) => {
+ ({ flexbox }) => flexbox.alignItems = AlignItems.FLEX_END,
+ ({ root, flexbox, text1, text2, text3 }) => {
isLeftAlignedWith(text1, flexbox);
isRightOf(text2, text1);
isLeftAlignedWith(text3, flexbox);
@@ -1286,8 +1297,8 @@ let activity_align_items_parent_padding_test = () => getViews(
export const testAlignItems_flexEnd_parentPadding = test(
activity_align_items_parent_padding_test,
- ({flexbox}) => flexbox.alignItems = AlignItems.FLEX_END,
- ({root, flexbox, text1, text2, text3}) => {
+ ({ flexbox }) => flexbox.alignItems = AlignItems.FLEX_END,
+ ({ root, flexbox, text1, text2, text3 }) => {
isRightOf(text2, text1);
closeEnough(bottom(text1), height(flexbox) - Length.toDevicePixels(flexbox.style.paddingBottom, 0));
closeEnough(bottom(text2), height(flexbox) - Length.toDevicePixels(flexbox.style.paddingBottom, 0));
@@ -1296,11 +1307,11 @@ export const testAlignItems_flexEnd_parentPadding = test(
export const testAlignItems_flexEnd_parentPadding_column = test(
activity_align_items_parent_padding_test,
- ({flexbox}) => {
+ ({ flexbox }) => {
flexbox.alignItems = AlignItems.FLEX_END;
flexbox.flexDirection = FlexDirection.COLUMN;
},
- ({root, flexbox, text1, text2, text3}) => {
+ ({ root, flexbox, text1, text2, text3 }) => {
isBelow(text2, text1);
closeEnough(right(text1), width(flexbox) - Length.toDevicePixels(flexbox.style.paddingRight, 0));
closeEnough(right(text2), width(flexbox) - Length.toDevicePixels(flexbox.style.paddingRight, 0));
@@ -1309,8 +1320,8 @@ export const testAlignItems_flexEnd_parentPadding_column = test(
export const testAlignItems_center = test(
activity_align_items_test,
- ({flexbox}) => flexbox.alignItems = AlignItems.CENTER,
- ({root, flexbox, text1, text2, text3}) => {
+ ({ flexbox }) => flexbox.alignItems = AlignItems.CENTER,
+ ({ root, flexbox, text1, text2, text3 }) => {
isLeftAlignedWith(text1, flexbox);
isRightOf(text2, text1);
isLeftAlignedWith(text3, flexbox);
@@ -1331,11 +1342,11 @@ export const testAlignItems_center = test(
export const testAlignItems_flexEnd_wrapReverse = test(
activity_align_items_test,
- ({flexbox}) => {
+ ({ flexbox }) => {
flexbox.flexWrap = FlexWrap.WRAP_REVERSE;
flexbox.alignItems = AlignItems.FLEX_END;
},
- ({root, flexbox, text1, text2, text3}) => {
+ ({ root, flexbox, text1, text2, text3 }) => {
isLeftAlignedWith(text1, flexbox);
isRightOf(text2, text1);
isLeftAlignedWith(text3, flexbox);
@@ -1356,11 +1367,11 @@ export const testAlignItems_flexEnd_wrapReverse = test(
export const testAlignItems_center_wrapReverse = test(
activity_align_items_test,
- ({flexbox}) => {
+ ({ flexbox }) => {
flexbox.flexWrap = FlexWrap.WRAP_REVERSE;
flexbox.alignItems = AlignItems.CENTER;
},
- ({root, flexbox, text1, text2, text3}) => {
+ ({ root, flexbox, text1, text2, text3 }) => {
isLeftAlignedWith(text1, flexbox);
isRightOf(text2, text1);
isLeftAlignedWith(text3, flexbox);
@@ -1382,8 +1393,8 @@ export const testAlignItems_center_wrapReverse = test(
export const testAlignItems_flexStart_flexDirection_column = test(
activity_align_items_test,
- ({flexbox}) => flexbox.flexDirection = FlexDirection.COLUMN,
- ({root, flexbox, text1, text2, text3}) => {
+ ({ flexbox }) => flexbox.flexDirection = FlexDirection.COLUMN,
+ ({ root, flexbox, text1, text2, text3 }) => {
isTopAlignedWith(text1, flexbox);
isLeftAlignedWith(text1, flexbox);
isLeftAlignedWith(text2, flexbox);
@@ -1402,11 +1413,11 @@ export const testAlignItems_flexStart_flexDirection_column = test(
export const testAlignItems_flexEnd_flexDirection_column = test(
activity_align_items_test,
- ({flexbox}) => {
+ ({ flexbox }) => {
flexbox.alignItems = AlignItems.FLEX_END;
flexbox.flexDirection = FlexDirection.COLUMN;
},
- ({root, flexbox, text1, text2, text3}) => {
+ ({ root, flexbox, text1, text2, text3 }) => {
isTopAlignedWith(text1, flexbox);
isBelow(text2, text1);
isTopAlignedWith(text3, flexbox);
@@ -1427,11 +1438,11 @@ export const testAlignItems_flexEnd_flexDirection_column = test(
export const testAlignItems_center_flexDirection_column = test(
activity_align_items_test,
- ({flexbox}) => {
+ ({ flexbox }) => {
flexbox.alignItems = AlignItems.CENTER;
flexbox.flexDirection = FlexDirection.COLUMN;
},
- ({root, flexbox, text1, text2, text3}) => {
+ ({ root, flexbox, text1, text2, text3 }) => {
isTopAlignedWith(text1, flexbox);
isBelow(text2, text1);
isTopAlignedWith(text3, flexbox);
@@ -1452,12 +1463,12 @@ export const testAlignItems_center_flexDirection_column = test(
export const testAlignItems_flexEnd_wrapReverse_flexDirection_column = test(
activity_align_items_test,
- ({flexbox}) => {
+ ({ flexbox }) => {
flexbox.flexWrap = FlexWrap.WRAP_REVERSE;
flexbox.alignItems = AlignItems.FLEX_END;
flexbox.flexDirection = FlexDirection.COLUMN;
},
- ({root, flexbox, text1, text2, text3}) => {
+ ({ root, flexbox, text1, text2, text3 }) => {
isTopAlignedWith(text1, flexbox);
isBelow(text2, text1);
isLeftAlignedWith(text3, flexbox);
@@ -1478,12 +1489,12 @@ export const testAlignItems_flexEnd_wrapReverse_flexDirection_column = test(
export const testAlignItems_center_wrapReverse_flexDirection_column = test(
activity_align_items_test,
- ({flexbox}) => {
+ ({ flexbox }) => {
flexbox.flexWrap = FlexWrap.WRAP_REVERSE;
flexbox.alignItems = AlignItems.CENTER;
flexbox.flexDirection = FlexDirection.COLUMN;
},
- ({root, flexbox, text1, text2, text3}) => {
+ ({ root, flexbox, text1, text2, text3 }) => {
isTopAlignedWith(text1, flexbox);
isBelow(text2, text1);
isTopAlignedWith(text3, flexbox);
@@ -1513,7 +1524,7 @@ let activity_align_items_baseline_test = () => getViews(
export const testAlignItems_baseline = test(
activity_align_items_baseline_test,
noop,
- ({root, flexbox, text1, text2, text3}) => {
+ ({ root, flexbox, text1, text2, text3 }) => {
let topPluBaseline1 = top(text1) + baseline(text1);
let topPluBaseline2 = top(text2) + baseline(text2);
let topPluBaseline3 = top(text3) + baseline(text3);
@@ -1525,8 +1536,8 @@ export const testAlignItems_baseline = test(
export const testAlignItems_baseline_wrapReverse = test(
activity_align_items_baseline_test,
- ({flexbox}) => flexbox.flexWrap = FlexWrap.WRAP_REVERSE,
- ({root, flexbox, text1, text2, text3}) => {
+ ({ flexbox }) => flexbox.flexWrap = FlexWrap.WRAP_REVERSE,
+ ({ root, flexbox, text1, text2, text3 }) => {
let bottomPluBaseline1 = bottom(text1) + baseline(text1);
let bottomPluBaseline2 = bottom(text2) + baseline(text2);
let bottomPluBaseline3 = bottom(text3) + baseline(text3);
@@ -1546,8 +1557,8 @@ let activity_flex_wrap_test = () => getViews(
export const testFlexDirection_row_reverse = test(
activity_flex_wrap_test,
- ({flexbox}) => flexbox.flexDirection = FlexDirection.ROW_REVERSE,
- ({root, flexbox, text1, text2, text3}) => {
+ ({ flexbox }) => flexbox.flexDirection = FlexDirection.ROW_REVERSE,
+ ({ root, flexbox, text1, text2, text3 }) => {
isTopAlignedWith(text1, flexbox);
isRightAlignedWith(text1, flexbox);
isTopAlignedWith(text2, flexbox);
@@ -1560,8 +1571,8 @@ export const testFlexDirection_row_reverse = test(
export const testFlexDirection_column_reverse = test(
activity_flex_wrap_test,
- ({flexbox}) => flexbox.flexDirection = FlexDirection.COLUMN_REVERSE,
- ({root, flexbox, text1, text2, text3}) => {
+ ({ flexbox }) => flexbox.flexDirection = FlexDirection.COLUMN_REVERSE,
+ ({ root, flexbox, text1, text2, text3 }) => {
isBottomAlignedWith(text1, flexbox);
isLeftAlignedWith(text1, flexbox);
isLeftAlignedWith(text2, flexbox);
@@ -1583,7 +1594,7 @@ let activity_flex_basis_percent_test = () => getViews(
export const testFlexBasisPercent_wrap = test(
activity_flex_basis_percent_test,
noop,
- ({root, flexbox, text1, text2, text3}) => {
+ ({ root, flexbox, text1, text2, text3 }) => {
isTopAlignedWith(text1, flexbox);
isLeftAlignedWith(text1, flexbox);
isLeftAlignedWith(text2, flexbox);
@@ -1598,8 +1609,8 @@ export const testFlexBasisPercent_wrap = test(
export const testFlexBasisPercent_nowrap = test(
activity_flex_basis_percent_test,
- ({flexbox}) => flexbox.flexWrap = FlexWrap.NOWRAP,
- ({root, flexbox, text1, text2, text3}) => {
+ ({ flexbox }) => flexbox.flexWrap = FlexWrap.NOWRAP,
+ ({ root, flexbox, text1, text2, text3 }) => {
isTopAlignedWith(text1, flexbox);
isLeftAlignedWith(text1, flexbox);
isTopAlignedWith(text2, flexbox);
@@ -1614,8 +1625,8 @@ export const testFlexBasisPercent_nowrap = test(
export const testFlexBasisPercent_wrap_flexDirection_column = test(
activity_flex_basis_percent_test,
- ({flexbox}) => flexbox.flexDirection = FlexDirection.COLUMN,
- ({root, flexbox, text1, text2, text3}) => {
+ ({ flexbox }) => flexbox.flexDirection = FlexDirection.COLUMN,
+ ({ root, flexbox, text1, text2, text3 }) => {
isTopAlignedWith(text1, flexbox);
isLeftAlignedWith(text1, flexbox);
isTopAlignedWith(text2, flexbox);
@@ -1629,11 +1640,11 @@ export const testFlexBasisPercent_wrap_flexDirection_column = test(
export const testFlexBasisPercent_nowrap_flexDirection_column = test(
activity_flex_basis_percent_test,
- ({flexbox}) => {
+ ({ flexbox }) => {
flexbox.flexWrap = FlexWrap.NOWRAP;
flexbox.flexDirection = FlexDirection.COLUMN;
},
- ({root, flexbox, text1, text2, text3}) => {
+ ({ root, flexbox, text1, text2, text3 }) => {
isTopAlignedWith(text1, flexbox);
isLeftAlignedWith(text1, flexbox);
isLeftAlignedWith(text2, flexbox);
@@ -1648,16 +1659,16 @@ export const testFlexBasisPercent_nowrap_flexDirection_column = test(
);
let activity_minwidth_test = () => getViews(
- `
+ `
`
- );
+);
export const testMinWidth_initial_width_less_than_minWidth = test(
activity_minwidth_test,
noop,
- ({root, flexbox, text1, text2, text3}) => {
+ ({ root, flexbox, text1, text2, text3 }) => {
let minWidth = 100;
closeEnough(width(text1), dipToDp(100));
closeEnough(width(text2), width(flexbox) - dipToDp(100));
@@ -1676,7 +1687,7 @@ let activity_minwidth_lower_bound_test = () => getViews(
export const testMinWidth_works_as_lower_bound_shrink_to = test(
activity_minwidth_lower_bound_test,
noop,
- ({root, flexbox, text1, text2, text3, text4}) => {
+ ({ root, flexbox, text1, text2, text3, text4 }) => {
closeEnough(width(text1), dipToDp(150));
closeEnough(width(flexbox), width(text1) + width(text2) + width(text3) + width(text4));
}
@@ -1692,7 +1703,7 @@ let activity_minheight_test = () => getViews(
export const testMinHeight_initial_height_less_than_minHeight = test(
activity_minheight_test,
noop,
- ({root, flexbox, text1, text2}) => {
+ ({ root, flexbox, text1, text2 }) => {
closeEnough(height(text1), dipToDp(100));
closeEnough(height(text2), height(flexbox) - dipToDp(100));
}
@@ -1710,7 +1721,7 @@ let activity_minheight_lower_bound_test = () => getViews(
export const testMinHeight_works_as_lower_bound_shrink_to = test(
activity_minheight_lower_bound_test,
noop,
- ({root, flexbox, text1, text2, text3, text4}) => {
+ ({ root, flexbox, text1, text2, text3, text4 }) => {
closeEnough(height(text1), dipToDp(150));
closeEnough(height(flexbox), height(text1) + height(text2) + height(text3) + height(text4));
}
@@ -1735,7 +1746,7 @@ let activity_views_visibility_gone = () => getViews(
export const testView_visibility_gone = test(
activity_views_visibility_gone,
noop,
- ({root, flexbox, text1, text2, text3, text4, text5}) => {
+ ({ root, flexbox, text1, text2, text3, text4, text5 }) => {
isTopAlignedWith(text3, flexbox);
isLeftAlignedWith(text3, flexbox);
isTopAlignedWith(text4, flexbox);
@@ -1759,7 +1770,7 @@ let activity_visibility_gone_first_item_in_flex_line_row = () => getViews(
export const testView_visibility_gone_first_item_in_flex_line_horizontal = test(
activity_visibility_gone_first_item_in_flex_line_row,
noop,
- ({root, flexbox, text1, text2, text3}) => {
+ ({ root, flexbox, text1, text2, text3 }) => {
check(height(flexbox) > 0);
equal(height(flexbox), height(text1) + height(text3));
}
@@ -1776,7 +1787,7 @@ let activity_visibility_gone_first_item_in_flex_line_column = () => getViews(
export const testView_visibility_gone_first_item_in_flex_line_vertical = test(
activity_visibility_gone_first_item_in_flex_line_column,
noop,
- ({flexbox, text1, text3}) => {
+ ({ flexbox, text1, text3 }) => {
check(width(flexbox) > 0);
equal(width(flexbox), width(text1) + width(text3));
}
@@ -1793,7 +1804,7 @@ let activity_wrap_before_test = () => getViews(
export const testWrapBefore = test(
activity_wrap_before_test,
noop,
- ({flexbox, text1, text2, text3}) => {
+ ({ flexbox, text1, text2, text3 }) => {
isTopAlignedWith(text1, flexbox);
isLeftAlignedWith(text1, flexbox);
isLeftAlignedWith(text2, flexbox);
@@ -1805,8 +1816,8 @@ export const testWrapBefore = test(
export const testWrapBefore2 = test(
activity_wrap_before_test,
- ({text2}) => FlexboxLayout.setFlexWrapBefore(text2, false),
- ({flexbox, text1, text2, text3}) => {
+ ({ text2 }) => FlexboxLayout.setFlexWrapBefore(text2, false),
+ ({ flexbox, text1, text2, text3 }) => {
isTopAlignedWith(text1, flexbox);
isLeftAlignedWith(text1, flexbox);
isTopAlignedWith(text2, flexbox);
@@ -1820,8 +1831,8 @@ export const testWrapBefore2 = test(
export const testWrapBefore_nowrap = test(
activity_wrap_before_test,
- ({flexbox}) => flexbox.flexWrap = FlexWrap.NOWRAP,
- ({flexbox, text1, text2, text3}) => {
+ ({ flexbox }) => flexbox.flexWrap = FlexWrap.NOWRAP,
+ ({ flexbox, text1, text2, text3 }) => {
isTopAlignedWith(text1, flexbox);
isLeftAlignedWith(text1, flexbox);
isBottomAlignedWith(text1, flexbox);
@@ -1845,7 +1856,7 @@ let activity_wrap_parent_padding_horizontal_test = () => getViews(
export const testWrap_parentPadding_horizontal = test(
activity_wrap_parent_padding_horizontal_test,
noop,
- ({flexbox, text1, text2, text3}) => {
+ ({ flexbox, text1, text2, text3 }) => {
isBelow(text2, text1);
isRightOf(text3, text2);
closeEnough(height(flexbox), Length.toDevicePixels(flexbox.style.paddingTop, 0) + Length.toDevicePixels(flexbox.style.paddingBottom, 0) + height(text1) + height(text2));
@@ -1863,7 +1874,7 @@ let activity_wrap_parent_padding_vertical_test = () => getViews(
export const testWrap_parentPadding_vertical = test(
activity_wrap_parent_padding_vertical_test,
noop,
- ({flexbox, text1, text2, text3}) => {
+ ({ flexbox, text1, text2, text3 }) => {
isRightOf(text2, text1);
isBelow(text3, text2);
closeEnough(width(flexbox), Length.toDevicePixels(flexbox.style.paddingLeft, 0) + Length.toDevicePixels(flexbox.style.paddingRight, 0) + width(text1) + width(text2));
@@ -1881,7 +1892,7 @@ let activity_wrap_child_margin_horizontal_test = () => getViews(
export const testWrap_childMargin_horizontal = test(
activity_wrap_child_margin_horizontal_test,
noop,
- ({flexbox, text1, text2, text3}) => {
+ ({ flexbox, text1, text2, text3 }) => {
isBelow(text2, text1);
isRightOf(text3, text2);
closeEnough(height(flexbox), height(text1) + height(text2) + PercentLength.toDevicePixels(text2.style.marginTop, 0, Number.NaN) + PercentLength.toDevicePixels(text2.style.marginBottom, 0, Number.NaN));
@@ -1899,7 +1910,7 @@ let activity_first_item_large_horizontal_test = () => getViews(
export const testFirstItemLarge_horizontal = test(
activity_first_item_large_horizontal_test,
noop,
- ({flexbox, text1, text2, text3}) => {
+ ({ flexbox, text1, text2, text3 }) => {
isTopAlignedWith(text1, flexbox);
isLeftAlignedWith(text1, flexbox);
isLeftAlignedWith(text2, flexbox);
@@ -1921,7 +1932,7 @@ let activity_first_item_large_vertical_test = () => getViews(
export const testFirstItemLarge_vertical = test(
activity_first_item_large_vertical_test,
noop,
- ({flexbox, text1, text2, text3}) => {
+ ({ flexbox, text1, text2, text3 }) => {
isTopAlignedWith(text1, flexbox);
isLeftAlignedWith(text1, flexbox);
isTopAlignedWith(text2, flexbox);
@@ -1943,7 +1954,7 @@ let activity_wrap_child_margin_vertical_test = () => getViews(
export const testWrap_childMargin_vertical = test(
activity_wrap_child_margin_vertical_test,
noop,
- ({flexbox, text1, text2, text3}) => {
+ ({ flexbox, text1, text2, text3 }) => {
isRightOf(text2, text1);
isBelow(text3, text2);
// dips anyone?
@@ -1960,7 +1971,7 @@ let activity_flexbox_with_proxy_view_container = () => getViews(
export const testFlexboxLayout_does_not_crash_with_proxy_view_container = test(
activity_flexbox_with_proxy_view_container,
noop,
- ({root, flexbox}) => {
+ ({ root, flexbox }) => {
TKUnit.assert(flexbox.id === "flexbox", "FlexboxLayout actually there");
}
);
diff --git a/tests/app/ui/layouts/grid-layout-tests.ts b/tests/app/ui/layouts/grid-layout-tests.ts
index ba4034755..fd2ee333e 100644
--- a/tests/app/ui/layouts/grid-layout-tests.ts
+++ b/tests/app/ui/layouts/grid-layout-tests.ts
@@ -9,6 +9,7 @@ import * as testModule from "../../ui-test";
import * as layoutHelper from "./layout-helper";
import * as platform from "tns-core-modules/platform";
import * as commonTests from "./common-layout-tests";
+import * as helper from "../helper";
var DELTA = 1;
@@ -33,6 +34,14 @@ export class GridLayoutTest extends testModule.UITest
return new RemovalTrackingGridLayout();
}
+ public test_recycling() {
+ helper.nativeView_recycling_test(() => new GridLayout());
+ }
+
+ public test_item_recycling() {
+ helper.nativeView_recycling_test(() => new Button(), () => new GridLayout());
+ }
+
private row(view: view.View): number {
return GridLayout.getRow(view);
}
diff --git a/tests/app/ui/layouts/stack-layout-tests.ts b/tests/app/ui/layouts/stack-layout-tests.ts
index 97f27c11f..190d6f548 100644
--- a/tests/app/ui/layouts/stack-layout-tests.ts
+++ b/tests/app/ui/layouts/stack-layout-tests.ts
@@ -1,7 +1,7 @@
-import {StackLayout} from "tns-core-modules/ui/layouts/stack-layout";
-import {Button} from "tns-core-modules/ui/button";
+import { StackLayout } from "tns-core-modules/ui/layouts/stack-layout";
+import { Button } from "tns-core-modules/ui/button";
import * as TKUnit from "../../TKUnit";
-import * as helper from "./layout-helper";
+import * as helper from "../helper";
import * as enums from "tns-core-modules/ui/enums";
import * as utils from "tns-core-modules/utils/utils";
import * as testModule from "../../ui-test";
@@ -10,21 +10,25 @@ import * as commonTests from "./common-layout-tests";
export class StackLayoutTest extends testModule.UITest {
- private rootLayout: helper.MyStackLayout;
- private btn1: helper.MyButton;
- private btn2: helper.MyButton;
+ private rootLayout: layoutHelper.MyStackLayout;
+ private btn1: layoutHelper.MyButton;
+ private btn2: layoutHelper.MyButton;
public create(): StackLayout {
- this.rootLayout = new helper.MyStackLayout();
- this.btn1 = new helper.MyButton();
+ this.rootLayout = new layoutHelper.MyStackLayout();
+ this.btn1 = new layoutHelper.MyButton();
this.btn1.text = "btn1";
this.rootLayout.addChild(this.btn1);
- this.btn2 = new helper.MyButton();
+ this.btn2 = new layoutHelper.MyButton();
this.btn2.text = "btn2";
this.rootLayout.addChild(this.btn2);
return this.rootLayout;
}
+ public test_StackLayout_recycling() {
+ helper.nativeView_recycling_test(() => new StackLayout());
+ }
+
public test_orientation_DefaultValue() {
TKUnit.assertEqual(this.rootLayout.orientation, enums.Orientation.vertical, "Default orientation should be Vertical.");
}
@@ -105,11 +109,11 @@ export class StackLayoutTest extends testModule.UITest {
this.waitUntilTestElementLayoutIsValid();
- helper.assertMeasure(this.btn1, 260, 50);
- helper.assertMeasure(this.btn2, 260, 50);
+ layoutHelper.assertMeasure(this.btn1, 260, 50);
+ layoutHelper.assertMeasure(this.btn2, 260, 50);
- helper.assertLayout(this.btn1, 10, 20, 260, 50, "btn1");
- helper.assertLayout(this.btn2, 10, 70, 260, 50, "btn2");
+ layoutHelper.assertLayout(this.btn1, 10, 20, 260, 50, "btn1");
+ layoutHelper.assertLayout(this.btn2, 10, 70, 260, 50, "btn2");
}
public test_Padding_Horizontal() {
@@ -127,11 +131,11 @@ export class StackLayoutTest extends testModule.UITest {
this.waitUntilTestElementLayoutIsValid();
- helper.assertMeasure(this.btn1, 50, 240);
- helper.assertMeasure(this.btn2, 50, 240);
+ layoutHelper.assertMeasure(this.btn1, 50, 240);
+ layoutHelper.assertMeasure(this.btn2, 50, 240);
- helper.assertLayout(this.btn1, 10, 20, 50, 240, "btn1");
- helper.assertLayout(this.btn2, 60, 20, 50, 240, "btn2");
+ layoutHelper.assertLayout(this.btn1, 10, 20, 50, 240, "btn1");
+ layoutHelper.assertLayout(this.btn2, 60, 20, 50, 240, "btn2");
}
private assertChildTexts(expected, layout, message) {
@@ -164,7 +168,7 @@ export class StackLayoutTest extends testModule.UITest {
// >> stack-layout-require
// var StackLayout = require("ui/layouts/stack-layout").StackLayout;
// << stack-layout-require
-
+
// >> stack-layout-new
// >> (hide)
// var Button = require("ui/button").Button;
diff --git a/tests/app/ui/layouts/wrap-layout-tests.ts b/tests/app/ui/layouts/wrap-layout-tests.ts
index b9d92e140..0e0c7fb0e 100644
--- a/tests/app/ui/layouts/wrap-layout-tests.ts
+++ b/tests/app/ui/layouts/wrap-layout-tests.ts
@@ -1,8 +1,9 @@
import * as TKUnit from "../../TKUnit";
-import {Label} from "tns-core-modules/ui/label";
+import { Label } from "tns-core-modules/ui/label";
import * as layoutHelper from "./layout-helper";
import * as testModule from "../../ui-test";
import * as commonTests from "./common-layout-tests";
+import * as helper from "../helper";
// >> wrap-layout-require
import * as wrapLayoutModule from "tns-core-modules/ui/layouts/wrap-layout";
@@ -30,6 +31,10 @@ export class WrapLayoutTest extends testModule.UITest new wrapLayoutModule.WrapLayout());
+ }
+
public testItemWidhtItemHeight() {
let wrap = this.testView;
wrap.removeChildren();
diff --git a/tests/app/ui/list-picker/list-picker-tests.ts b/tests/app/ui/list-picker/list-picker-tests.ts
index 51ce8a08b..256e67c15 100644
--- a/tests/app/ui/list-picker/list-picker-tests.ts
+++ b/tests/app/ui/list-picker/list-picker-tests.ts
@@ -24,6 +24,10 @@ function _createItems(count: number): Array {
return items;
}
+export function test_recycling() {
+ helper.nativeView_recycling_test(() => new listPickerModule.ListPicker());
+}
+
export var testWhenlistPickerIsCreatedItemsAreUndefined = function () {
helper.buildUIAndRunTest(_createListPicker(), function (views: Array) {
var listPicker = views[0];
diff --git a/tests/app/ui/list-view/list-view-tests.ts b/tests/app/ui/list-view/list-view-tests.ts
index c7ced8b61..23fd0e23f 100644
--- a/tests/app/ui/list-view/list-view-tests.ts
+++ b/tests/app/ui/list-view/list-view-tests.ts
@@ -52,6 +52,10 @@ export class ListViewTest extends testModule.UITest {
return new listViewModule.ListView();
}
+ public test_recycling() {
+ helper.nativeView_recycling_test(() => new listViewModule.ListView());
+ }
+
public test_default_TNS_values() {
// >> article-create-listview
var listView = new listViewModule.ListView();
@@ -870,7 +874,7 @@ export class ListViewTest extends testModule.UITest {
// Back
const count = listView.items.length - 1;
- listView.items.forEach((item, i, arr) => {
+ listView.items.forEach((item, i, arr) => {
listView.scrollToIndex(count - i);
TKUnit.wait(0.01);
});
diff --git a/tests/app/ui/page/page-tests-common.ts b/tests/app/ui/page/page-tests-common.ts
index 14987c2af..73cbeec45 100644
--- a/tests/app/ui/page/page-tests-common.ts
+++ b/tests/app/ui/page/page-tests-common.ts
@@ -22,7 +22,7 @@ import { Label } from "tns-core-modules/ui/label";
import { EventData } from "tns-core-modules/data/observable";
import { PercentLength } from "tns-core-modules/ui/core/view";
import * as platform from "tns-core-modules/platform";
-import {unsetValue} from "tns-core-modules/ui/core/view";
+import { unsetValue } from "tns-core-modules/ui/core/view";
import { Color } from "tns-core-modules/color";
export function addLabelToPage(page: Page, text?: string) {
@@ -31,6 +31,10 @@ export function addLabelToPage(page: Page, text?: string) {
page.content = label;
}
+export function test_recycling() {
+ helper.nativeView_recycling_test(() => new Page());
+}
+
export function test_AfterPageLoaded_is_called_NativeInstance_is_created() {
let page: Page;
let label: Label;
@@ -122,11 +126,11 @@ export function test_NavigateToNewPage() {
// << article-navigating-backward
TKUnit.waitUntilReady(() => { return topFrame.currentPage !== null && topFrame.currentPage === currentPage });
- TKUnit.assert(testPage.parent === undefined, "Page.parent should become undefined after navigating back");
- TKUnit.assert(testPage._context === null, "Page._context should become undefined after navigating back");
- TKUnit.assert(testPage.isLoaded === false, "Page.isLoaded should become false after navigating back");
- TKUnit.assert(testPage.frame === undefined, "Page.frame should become undefined after navigating back");
- TKUnit.assert(testPage._isAddedToNativeVisualTree === false, "Page._isAddedToNativeVisualTree should become false after navigating back");
+ TKUnit.assertNull(testPage.parent, "Page.parent should become undefined after navigating back");
+ TKUnit.assertNull(testPage._context, "Page._context should become undefined after navigating back");
+ TKUnit.assertFalse(testPage.isLoaded, "Page.isLoaded should become false after navigating back");
+ TKUnit.assertNull(testPage.frame, "Page.frame should become undefined after navigating back");
+ TKUnit.assertFalse(testPage._isAddedToNativeVisualTree, "Page._isAddedToNativeVisualTree should become false after navigating back");
}
export function test_PageNavigation_EventSequence_WithTransition() {
diff --git a/tests/app/ui/progress/progress-tests.ts b/tests/app/ui/progress/progress-tests.ts
index a6933f270..c068b9c2e 100644
--- a/tests/app/ui/progress/progress-tests.ts
+++ b/tests/app/ui/progress/progress-tests.ts
@@ -18,6 +18,10 @@ export function test_default_TNS_values() {
TKUnit.assertEqual(progress.maxValue, 100, "Default progress.maxValue");
}
+export function test_recycling() {
+ helper.nativeView_recycling_test(() => new progressModule.Progress());
+}
+
export function test_default_native_values() {
var progress = new progressModule.Progress();
diff --git a/tests/app/ui/repeater/repeater-tests.ts b/tests/app/ui/repeater/repeater-tests.ts
index 8f6098908..9c3aad640 100644
--- a/tests/app/ui/repeater/repeater-tests.ts
+++ b/tests/app/ui/repeater/repeater-tests.ts
@@ -18,13 +18,18 @@ import * as observableArray from "tns-core-modules/data/observable-array";
import * as labelModule from "tns-core-modules/ui/label";
// << article-require-modules-repeater
-var ASYNC = 0.2;
var FEW_ITEMS = [0, 1, 2];
var MANY_ITEMS = [];
for (var i = 0; i < 100; i++) {
MANY_ITEMS[i] = i;
}
+export function test_recycling() {
+ const setters = new Map();
+ setters.set('itemsLayout', new stackLayoutModule.StackLayout());
+ helper.nativeView_recycling_test(() => new repeaterModule.Repeater(), null, null, setters);
+}
+
export function test_set_items_to_array_loads_all_items() {
var repeater = new repeaterModule.Repeater();
@@ -72,7 +77,8 @@ export function test_refresh_after_adding_items_to_array_loads_new_items() {
// Manually trigger the update so that the new color is shown.
repeater.refresh();
// << artcle-array-push-element
- TKUnit.wait(ASYNC);
+ // TKUnit.wait(ASYNC);
+ TKUnit.waitUntilReady(() => repeater.isLayoutValid);
TKUnit.assertEqual(getChildrenCount(repeater), colors.length, "views count.");
};
diff --git a/tests/app/ui/search-bar/search-bar-tests.ts b/tests/app/ui/search-bar/search-bar-tests.ts
index ebc2cbb35..e7c417c77 100644
--- a/tests/app/ui/search-bar/search-bar-tests.ts
+++ b/tests/app/ui/search-bar/search-bar-tests.ts
@@ -24,6 +24,10 @@ var _createSearchBarFunc = function (): searchBarModule.SearchBar {
return searchBar;
};
+export function test_recycling() {
+ helper.nativeView_recycling_test(() => new searchBarModule.SearchBar());
+}
+
export var testSearchBarHintColorAndroid = function () {
helper.buildUIAndRunTest(_createSearchBarFunc(), function (views: Array) {
var searchBar = views[0];
diff --git a/tests/app/ui/segmented-bar/segmented-bar-tests.ts b/tests/app/ui/segmented-bar/segmented-bar-tests.ts
index e4e9f191f..4396145d7 100644
--- a/tests/app/ui/segmented-bar/segmented-bar-tests.ts
+++ b/tests/app/ui/segmented-bar/segmented-bar-tests.ts
@@ -5,6 +5,7 @@ import { View } from "tns-core-modules/ui/core/view";
import { BindingOptions } from "tns-core-modules/ui/core/bindable";
import { Observable } from "tns-core-modules/data/observable";
import { Color } from "tns-core-modules/color";
+import * as helper from "../helper";
// >> article-require-segmentedbar-module
import * as segmentedBarModule from "tns-core-modules/ui/segmented-bar";
@@ -18,6 +19,12 @@ function _createSegmentedBar(): segmentedBarModule.SegmentedBar {
return segmentedBar;
}
+export function test_recycling() {
+ const setters = new Map>();
+ setters.set('items', _createItems(3));
+ helper.nativeView_recycling_test(() => new segmentedBarModule.SegmentedBar(), null, null, setters);
+}
+
function _createItems(count: number): Array {
var items = new Array();
for (var i = 0; i < count; i++) {
diff --git a/tests/app/ui/slider/slider-tests.ts b/tests/app/ui/slider/slider-tests.ts
index 19d3006a2..a8e537c2f 100644
--- a/tests/app/ui/slider/slider-tests.ts
+++ b/tests/app/ui/slider/slider-tests.ts
@@ -48,6 +48,10 @@ function detachValueChangedEvents(slider: Slider) {
slider.off(MAX_VALUE_EVENT);
}
+export function test_recycling() {
+ helper.nativeView_recycling_test(() => new Slider());
+}
+
export function test_set_TNS_value_updates_native_value() {
// >> article-creating-slider
const slider = new Slider();
diff --git a/tests/app/ui/switch/switch-tests.ts b/tests/app/ui/switch/switch-tests.ts
index 1bff068f4..0d4ead850 100644
--- a/tests/app/ui/switch/switch-tests.ts
+++ b/tests/app/ui/switch/switch-tests.ts
@@ -21,6 +21,10 @@ function pageLoaded(args) {
exports.pageLoaded = pageLoaded;
// << article-binding-switch-property
+export function test_recycling() {
+ helper.nativeView_recycling_test(() => new switchModule.Switch());
+}
+
export function test_default_TNS_values() {
// >> article-create-switch
var mySwitch = new switchModule.Switch();
diff --git a/tests/app/ui/tab-view/tab-view-tests.ts b/tests/app/ui/tab-view/tab-view-tests.ts
index 30c0d5166..d2ff3bf22 100644
--- a/tests/app/ui/tab-view/tab-view-tests.ts
+++ b/tests/app/ui/tab-view/tab-view-tests.ts
@@ -21,6 +21,12 @@ export class TabViewTest extends testModule.UITest {
return tabView;
}
+ public test_recycling() {
+ const setters = new Map>();
+ setters.set('items', this._createItems(3));
+ helper.nativeView_recycling_test(() => new tabViewModule.TabView(), null, null, setters);
+ }
+
_createItems(count: number): Array {
var items = new Array();
for (var i = 0; i < count; i++) {
@@ -292,9 +298,9 @@ export class TabViewTest extends testModule.UITest {
// return `${font.typeface} ${font.size}`;
// }
// }
-
+
let assertFontsAreEqual = (actual: any, expected: any, message?: string) => {
- if (this.testView.ios){
+ if (this.testView.ios) {
TKUnit.assertEqual(actual, expected, message);
}
else {
@@ -315,17 +321,17 @@ export class TabViewTest extends testModule.UITest {
this.testView.style.font = "20 Pacifico";
nativeFont = tabViewTestsNative.getNativeFont(this.testView);
//console.log(`>>>>>>>>>>>>> nativeFont: ${fontToString(nativeFont)}`);
-
+
//console.log(`>>>>>>>>>>>>> CREATE 3 ITEMS`);
this.testView.items = this._createItems(2);
assertFontsAreEqual(tabViewTestsNative.getNativeFont(this.testView), nativeFont, "Font must be 20 Pacifico after rebinding items.");
//console.log(`>>>>>>>>>>>>> nativeFont: ${fontToString(nativeFont)}`);
-
+
//console.log(`>>>>>>>>>>>>> MONOSPACE;`);
this.testView.style.font = "bold 12 monospace";
nativeFont = tabViewTestsNative.getNativeFont(this.testView);
//console.log(`>>>>>>>>>>>>> nativeFont: ${fontToString(nativeFont)}`);
-
+
//console.log(`>>>>>>>>>>>>> CREATE 3 ITEMS`);
this.testView.items = this._createItems(3);
assertFontsAreEqual(tabViewTestsNative.getNativeFont(this.testView), nativeFont, "Font must be bold 12 monospace after rebinding items.");
diff --git a/tests/app/ui/text-field/text-field-tests.ts b/tests/app/ui/text-field/text-field-tests.ts
index 32483d14c..adfc52309 100644
--- a/tests/app/ui/text-field/text-field-tests.ts
+++ b/tests/app/ui/text-field/text-field-tests.ts
@@ -21,14 +21,18 @@ import * as observable from "tns-core-modules/data/observable";
// ### Binding two TextFields text property to observable view-model property.
// >> binding-text-property-textfield
function pageLoaded(args) {
- var page = args.object;
- var obj = new observable.Observable();
- obj.set("someProperty", "Please change this text!");
- page.bindingContext = obj;
+ var page = args.object;
+ var obj = new observable.Observable();
+ obj.set("someProperty", "Please change this text!");
+ page.bindingContext = obj;
}
exports.pageLoaded = pageLoaded;
// << binding-text-property-textfield
+export function test_recycling() {
+ helper.nativeView_recycling_test(_createTextFieldFunc);
+}
+
var _createTextFieldFunc = function (): textFieldModule.TextField {
// >> creating-textfield
var textField = new textFieldModule.TextField();
@@ -40,7 +44,7 @@ var _createTextFieldFunc = function (): textFieldModule.TextField {
export var testSetText = function () {
helper.buildUIAndRunTest(_createTextFieldFunc(), function (views: Array) {
var textField = views[0];
-
+
// >> setting-text-property
textField.text = "Hello, world!";
// << setting-text-property
@@ -48,13 +52,13 @@ export var testSetText = function () {
var expectedValue = "Hello, world!";
var actualValue = textFieldTestsNative.getNativeText(textField);
TKUnit.assertEqual(actualValue, expectedValue, "TextField native text");
- });
+ });
}
export var testSetTextNull = function () {
helper.buildUIAndRunTest(_createTextFieldFunc(), function (views: Array) {
var textField = views[0];
-
+
textField.text = null;
var expectedValue = "";
@@ -98,7 +102,7 @@ function createFormattedString(value: any): formattedStringModule.FormattedStrin
export var testSetTextWithSpan = function () {
helper.buildUIAndRunTest(_createTextFieldFunc(), function (views: Array) {
var textField = views[0];
-
+
textField.formattedText = createFormattedString("Hello, world!");
var expectedValue = "Hello, world!";
@@ -155,6 +159,7 @@ export var testSetHintToNumber = function () {
var actualValue = textFieldTestsNative.getNativeHint(textField);
TKUnit.assert(actualValue == expectedValue, "Actual: " + actualValue + "; Expected: " + expectedValue);
+
});
}
/* tslint:enable */
@@ -551,8 +556,8 @@ export function test_IntegrationTest_Transform_Decoration_Spacing_WithoutFormatt
view.text = "NormalText";
view.setInlineStyle("text-transform: uppercase; text-decoration: underline; letter-spacing: 1;");
-
- TKUnit.assertEqual(view.style.textTransform, "uppercase", "TextTransform");
+
+ TKUnit.assertEqual(view.style.textTransform, "uppercase", "TextTransform");
TKUnit.assertEqual(view.style.textDecoration, "underline", "TextDecoration");
TKUnit.assertEqual(view.style.letterSpacing, 1, "LetterSpacing");
});
@@ -564,7 +569,7 @@ export function test_IntegrationTest_Transform_Decoration_Spacing_WithFormattedT
helper.buildUIAndRunTest(view, function (views: Array) {
view.formattedText = formattedString;
view.setInlineStyle("text-transform: uppercase; text-decoration: underline; letter-spacing: 1;");
-
+
TKUnit.assertEqual(view.style.textTransform, "uppercase", "TextTransform");
TKUnit.assertEqual(view.style.textDecoration, "underline", "TextDecoration");
TKUnit.assertEqual(view.style.letterSpacing, 1, "LetterSpacing");
diff --git a/tests/app/ui/text-view/text-view-tests.ts b/tests/app/ui/text-view/text-view-tests.ts
index ac1a3f5eb..ce42ed181 100644
--- a/tests/app/ui/text-view/text-view-tests.ts
+++ b/tests/app/ui/text-view/text-view-tests.ts
@@ -35,6 +35,10 @@ export function pageLoaded(args) {
exports.pageLoaded = pageLoaded;
// << observable-declare
+export function test_recycling() {
+ helper.nativeView_recycling_test(_createTextViewFunc);
+}
+
var _createTextViewFunc = function (): textViewModule.TextView {
// >> text-view-create
var textView = new textViewModule.TextView();
diff --git a/tests/app/ui/time-picker/time-picker-tests.ts b/tests/app/ui/time-picker/time-picker-tests.ts
index b39a5d265..e6a5b09d4 100644
--- a/tests/app/ui/time-picker/time-picker-tests.ts
+++ b/tests/app/ui/time-picker/time-picker-tests.ts
@@ -3,6 +3,7 @@ import * as testModule from "../../ui-test";
import * as timePickerTestsNative from "./time-picker-tests-native";
import * as color from "tns-core-modules/color";
import * as platform from "tns-core-modules/platform";
+import * as helper from "../helper";
// >> require-time-picker
import * as timePickerModule from "tns-core-modules/ui/time-picker";
@@ -22,7 +23,11 @@ export class TimePickerTest extends testModule.UITest> declare-time-picker
var timePicker = new timePickerModule.TimePicker();
@@ -30,12 +35,12 @@ export class TimePickerTest extends testModule.UITest) {
helper.waitUntilLayoutReady(btn);
diff --git a/tests/package.json b/tests/package.json
index 7057c271c..8a7019c35 100644
--- a/tests/package.json
+++ b/tests/package.json
@@ -9,7 +9,7 @@
"version": "3.0.0"
},
"tns-android": {
- "version": "3.0.0"
+ "version": "3.0.1"
}
},
"dependencies": {
diff --git a/tns-core-modules/ui/action-bar/action-bar-common.ts b/tns-core-modules/ui/action-bar/action-bar-common.ts
index b89220006..9a8a4fff9 100644
--- a/tns-core-modules/ui/action-bar/action-bar-common.ts
+++ b/tns-core-modules/ui/action-bar/action-bar-common.ts
@@ -5,6 +5,8 @@
NavigationButton, IOSActionItemSettings, AndroidActionItemSettings, AndroidActionBarSettings
} from ".";
+import { profile } from "../../profiling";
+
export * from "../core/view";
import { View, ViewBase, Property, unsetValue, horizontalAlignmentProperty, verticalAlignmentProperty } from "../core/view";
@@ -262,8 +264,6 @@ export class ActionItemBase extends ViewBase implements ActionItemDefinition {
if (this._actionView) {
this._addView(this._actionView);
- this._actionView.style[horizontalAlignmentProperty.cssName] = "center";
- this._actionView.style[verticalAlignmentProperty.cssName] = "middle";
}
if (this._actionBar) {
@@ -281,6 +281,15 @@ export class ActionItemBase extends ViewBase implements ActionItemDefinition {
}
}
+ @profile
+ public onLoaded() {
+ if (this._actionView) {
+ this._actionView.style[horizontalAlignmentProperty.cssName] = "center";
+ this._actionView.style[verticalAlignmentProperty.cssName] = "middle";
+ }
+ super.onLoaded();
+ }
+
public _raiseTap() {
this._emit(ActionItemBase.tapEvent);
}
diff --git a/tns-core-modules/ui/action-bar/action-bar.android.ts b/tns-core-modules/ui/action-bar/action-bar.android.ts
index bb1a55ea4..43a6a0b87 100644
--- a/tns-core-modules/ui/action-bar/action-bar.android.ts
+++ b/tns-core-modules/ui/action-bar/action-bar.android.ts
@@ -9,6 +9,7 @@ export * from "./action-bar-common";
const R_ID_HOME = 0x0102002c;
const ACTION_ITEM_ID_OFFSET = 10000;
+let AppCompatTextView;
let actionItemIdGenerator = ACTION_ITEM_ID_OFFSET;
function generateItemId(): number {
actionItemIdGenerator++;
@@ -27,6 +28,8 @@ function initializeMenuItemClickListener(): void {
return;
}
+ AppCompatTextView = (android).support.v7.widget.AppCompatTextView;
+
@Interfaces([android.support.v7.widget.Toolbar.OnMenuItemClickListener])
class MenuItemClickListenerImpl extends java.lang.Object implements android.support.v7.widget.Toolbar.OnMenuItemClickListener {
constructor(public owner: ActionBar) {
@@ -354,20 +357,45 @@ export class ActionBar extends ActionBarBase {
}
[colorProperty.getDefault](): number {
+ const nativeView = this.nativeView;
if (!defaultTitleTextColor) {
- let textView = new android.widget.TextView(this._context);
- defaultTitleTextColor = textView.getTextColors().getDefaultColor();
+ let tv: android.widget.TextView = getAppCompatTextView(nativeView);
+ if (!tv) {
+ const title = nativeView.getTitle();
+ // setTitle will create AppCompatTextView internally;
+ nativeView.setTitle("");
+ tv = getAppCompatTextView(nativeView);
+ if (title) {
+ // restore title.
+ nativeView.setTitle(title);
+ }
+ }
+
+ // Fallback to hardcoded falue if we don't find TextView instance...
+ // using new TextView().getTextColors().getDefaultColor() returns different value: -1979711488
+ defaultTitleTextColor = tv ? tv.getTextColors().getDefaultColor() : -570425344;
}
return defaultTitleTextColor;
}
[colorProperty.setNative](value: number | Color) {
- let color = value instanceof Color ? value.android : value;
+ const color = value instanceof Color ? value.android : value;
this.nativeView.setTitleTextColor(color);
}
}
-// ActionBar.prototype.recycleNativeView = true;
+function getAppCompatTextView(toolbar: android.support.v7.widget.Toolbar): typeof AppCompatTextView {
+ for (let i = 0, count = toolbar.getChildCount(); i < count; i++) {
+ const child = toolbar.getChildAt(i);
+ if (child instanceof AppCompatTextView) {
+ return child;
+ }
+ }
+
+ return null;
+}
+
+ActionBar.prototype.recycleNativeView = true;
let defaultTitleTextColor: number;
diff --git a/tns-core-modules/ui/activity-indicator/activity-indicator-common.ts b/tns-core-modules/ui/activity-indicator/activity-indicator-common.ts
index 5b9410bfa..e974983eb 100644
--- a/tns-core-modules/ui/activity-indicator/activity-indicator-common.ts
+++ b/tns-core-modules/ui/activity-indicator/activity-indicator-common.ts
@@ -7,7 +7,7 @@ export class ActivityIndicatorBase extends View implements ActivityIndicatorDefi
public busy: boolean;
}
-// ActivityIndicatorBase.prototype.recycleNativeView = true;
+ActivityIndicatorBase.prototype.recycleNativeView = true;
export const busyProperty = new Property({ name: "busy", defaultValue: false, valueConverter: booleanConverter });
busyProperty.register(ActivityIndicatorBase);
diff --git a/tns-core-modules/ui/border/border.ts b/tns-core-modules/ui/border/border.ts
index 5a45088a6..7fd9feac5 100644
--- a/tns-core-modules/ui/border/border.ts
+++ b/tns-core-modules/ui/border/border.ts
@@ -41,4 +41,4 @@ export class Border extends ContentView implements BorderDefinition {
}
}
-// Border.prototype.recycleNativeView = true;
\ No newline at end of file
+Border.prototype.recycleNativeView = true;
\ No newline at end of file
diff --git a/tns-core-modules/ui/button/button-common.ts b/tns-core-modules/ui/button/button-common.ts
index 58d51264a..e717200fa 100644
--- a/tns-core-modules/ui/button/button-common.ts
+++ b/tns-core-modules/ui/button/button-common.ts
@@ -18,4 +18,4 @@ export abstract class ButtonBase extends TextBase implements ButtonDefinition {
}
}
-// ButtonBase.prototype.recycleNativeView = true;
\ No newline at end of file
+ButtonBase.prototype.recycleNativeView = true;
\ No newline at end of file
diff --git a/tns-core-modules/ui/button/button.android.ts b/tns-core-modules/ui/button/button.android.ts
index 9210e92cd..c18acce1b 100644
--- a/tns-core-modules/ui/button/button.android.ts
+++ b/tns-core-modules/ui/button/button.android.ts
@@ -14,6 +14,7 @@ interface ClickListener {
let ClickListener: ClickListener;
let APILEVEL: number;
+let AndroidButton: typeof android.widget.Button;
function initializeClickListener(): void {
if (ClickListener) {
@@ -34,17 +35,19 @@ function initializeClickListener(): void {
ClickListener = ClickListenerImpl;
APILEVEL = android.os.Build.VERSION.SDK_INT;
+ AndroidButton = android.widget.Button;
}
export class Button extends ButtonBase {
nativeView: android.widget.Button;
+ private _stateListAnimator: any;
private _highlightedHandler: (args: TouchGestureEventData) => void;
@profile
public createNativeView() {
initializeClickListener();
- const button = new android.widget.Button(this._context);
+ const button = new AndroidButton(this._context);
const clickListener = new ClickListener(this);
button.setOnClickListener(clickListener);
(button).clickListener = clickListener;
@@ -52,7 +55,8 @@ export class Button extends ButtonBase {
}
public initNativeView(): void {
- (this.nativeView).clickListener.owner = this;
+ const nativeView = this.nativeView;
+ (nativeView).clickListener.owner = this;
super.initNativeView();
}
@@ -61,6 +65,15 @@ export class Button extends ButtonBase {
super.disposeNativeView();
}
+ public resetNativeView(): void {
+ super.resetNativeView();
+
+ if (this._stateListAnimator && APILEVEL >= 21) {
+ (this.nativeView).setStateListAnimator(this._stateListAnimator);
+ this._stateListAnimator = undefined;
+ }
+ }
+
@PseudoClassHandler("normal", "highlighted", "pressed", "active")
_updateHandler(subscribe: boolean) {
if (subscribe) {
@@ -108,15 +121,17 @@ export class Button extends ButtonBase {
org.nativescript.widgets.ViewHelper.setPaddingLeft(this.nativeView, Length.toDevicePixels(value, 0) + Length.toDevicePixels(this.style.borderLeftWidth, 0));
}
- [zIndexProperty.getDefault](): number {
- return org.nativescript.widgets.ViewHelper.getZIndex(this.nativeView);
- }
[zIndexProperty.setNative](value: number) {
- org.nativescript.widgets.ViewHelper.setZIndex(this.nativeView, value);
// API >= 21
if (APILEVEL >= 21) {
- (this.nativeView).setStateListAnimator(null);
+ const nativeView = this.nativeView;
+ if (!this._stateListAnimator) {
+ this._stateListAnimator = (nativeView).getStateListAnimator();
+ }
+ (nativeView).setStateListAnimator(null);
}
+
+ org.nativescript.widgets.ViewHelper.setZIndex(this.nativeView, value);
}
[textAlignmentProperty.setNative](value: TextAlignment) {
diff --git a/tns-core-modules/ui/content-view/content-view.ts b/tns-core-modules/ui/content-view/content-view.ts
index 629bbc0db..fe9a74480 100644
--- a/tns-core-modules/ui/content-view/content-view.ts
+++ b/tns-core-modules/ui/content-view/content-view.ts
@@ -92,4 +92,4 @@ export class ContentView extends CustomLayoutView implements ContentViewDefiniti
}
}
-// ContentView.prototype.recycleNativeView = true;
\ No newline at end of file
+ContentView.prototype.recycleNativeView = true;
\ No newline at end of file
diff --git a/tns-core-modules/ui/core/properties/properties.d.ts b/tns-core-modules/ui/core/properties/properties.d.ts
index aa093fd10..8e8dabed3 100644
--- a/tns-core-modules/ui/core/properties/properties.d.ts
+++ b/tns-core-modules/ui/core/properties/properties.d.ts
@@ -124,4 +124,16 @@ export function makeValidator(...values: T[]): (value: any) => value is T;
export function makeParser(isValid: (value: any) => boolean): (value: any) => T;
export function getSetProperties(view: ViewBase): [string, any][];
-export function getComputedCssValues(view: ViewBase): [string, any][];
\ No newline at end of file
+export function getComputedCssValues(view: ViewBase): [string, any][];
+
+//@private
+/**
+ * @private get all properties defined on ViewBase
+ */
+export function _getProperties(): Property[];
+
+/**
+ * @private get all properties defined on Style
+ */
+export function _getStyleProperties(): CssProperty[];
+//@endprivate
diff --git a/tns-core-modules/ui/core/properties/properties.ts b/tns-core-modules/ui/core/properties/properties.ts
index 59c303e60..17e9bf3c4 100644
--- a/tns-core-modules/ui/core/properties/properties.ts
+++ b/tns-core-modules/ui/core/properties/properties.ts
@@ -42,6 +42,20 @@ const enum ValueSource {
Keyframe = 4
}
+export function _getProperties(): Property[] {
+ return getPropertiesFromMap(symbolPropertyMap) as Property[];
+}
+
+export function _getStyleProperties(): CssProperty[] {
+ return getPropertiesFromMap(cssSymbolPropertyMap) as CssProperty[];
+}
+
+function getPropertiesFromMap(map): Property[] | CssProperty[] {
+ const props = [];
+ Object.getOwnPropertySymbols(map).forEach(symbol => props.push(map[symbol]));
+ return props;
+}
+
export class Property implements TypedPropertyDescriptor, definitions.Property {
private registered: boolean;
@@ -1112,11 +1126,9 @@ export function applyAllNativeSetters(view: ViewBase): void {
}
if (view[property.setNative]) {
- if (view[property.getDefault]) {
- const defaultValueKey = property.defaultValueKey;
- if (!(defaultValueKey in style)) {
- style[defaultValueKey] = view[property.getDefault] ? view[property.getDefault]() : property.defaultValue;
- }
+ const defaultValueKey = property.defaultValueKey;
+ if (!(defaultValueKey in style)) {
+ style[defaultValueKey] = view[property.getDefault] ? view[property.getDefault]() : property.defaultValue;
}
const value = style[symbol];
diff --git a/tns-core-modules/ui/core/view-base/view-base.ts b/tns-core-modules/ui/core/view-base/view-base.ts
index 6c0a47194..e25446a7b 100644
--- a/tns-core-modules/ui/core/view-base/view-base.ts
+++ b/tns-core-modules/ui/core/view-base/view-base.ts
@@ -94,7 +94,7 @@ export function eachDescendant(view: ViewBaseDefinition, callback: (child: ViewB
let viewIdCounter = 1;
-const contextMap = new Map