mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-11-05 13:26:48 +08:00
Tests added
This commit is contained in:
@@ -89,6 +89,7 @@
|
|||||||
<DependentUpon>modal-page.xml</DependentUpon>
|
<DependentUpon>modal-page.xml</DependentUpon>
|
||||||
</TypeScriptCompile>
|
</TypeScriptCompile>
|
||||||
<TypeScriptCompile Include="apps\tests\ui\placeholder\placeholder-tests.ts" />
|
<TypeScriptCompile Include="apps\tests\ui\placeholder\placeholder-tests.ts" />
|
||||||
|
<TypeScriptCompile Include="apps\tests\ui\proxy-view-container\proxy-view-container-tests.ts" />
|
||||||
<TypeScriptCompile Include="apps\tests\ui\tab-view\tab-view-navigation-tests.ts" />
|
<TypeScriptCompile Include="apps\tests\ui\tab-view\tab-view-navigation-tests.ts" />
|
||||||
<TypeScriptCompile Include="apps\tests\xml-declaration\custom-code-file.ts" />
|
<TypeScriptCompile Include="apps\tests\xml-declaration\custom-code-file.ts" />
|
||||||
<TypeScriptCompile Include="apps\transforms\app.ts" />
|
<TypeScriptCompile Include="apps\transforms\app.ts" />
|
||||||
@@ -726,8 +727,8 @@
|
|||||||
<TypeScriptCompile Include="ui\builder\binding-builder.d.ts" />
|
<TypeScriptCompile Include="ui\builder\binding-builder.d.ts" />
|
||||||
<TypeScriptCompile Include="ui\builder\special-properties.d.ts" />
|
<TypeScriptCompile Include="ui\builder\special-properties.d.ts" />
|
||||||
<TypeScriptCompile Include="ui\builder\special-properties.ts" />
|
<TypeScriptCompile Include="ui\builder\special-properties.ts" />
|
||||||
<TypeScriptCompile Include="ui\view-container\view-container.ts" />
|
<TypeScriptCompile Include="ui\proxy-view-container\proxy-view-container.d.ts" />
|
||||||
<TypeScriptCompile Include="ui\view-container\view-container.d.ts" />
|
<TypeScriptCompile Include="ui\proxy-view-container\proxy-view-container.ts" />
|
||||||
<TypeScriptCompile Include="ui\styling\background.android.d.ts" />
|
<TypeScriptCompile Include="ui\styling\background.android.d.ts" />
|
||||||
<TypeScriptCompile Include="ui\styling\style-scope.d.ts" />
|
<TypeScriptCompile Include="ui\styling\style-scope.d.ts" />
|
||||||
<TypeScriptCompile Include="ui\styling\style.d.ts" />
|
<TypeScriptCompile Include="ui\styling\style.d.ts" />
|
||||||
@@ -2089,9 +2090,7 @@
|
|||||||
</Content>
|
</Content>
|
||||||
<Content Include="ui\package.json" />
|
<Content Include="ui\package.json" />
|
||||||
<Content Include="tsconfig.json" />
|
<Content Include="tsconfig.json" />
|
||||||
<Content Include="ui\view-container\package.json">
|
<Content Include="ui\proxy-view-container\package.json" />
|
||||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
|
||||||
</Content>
|
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<None Include="build\tslint.json" />
|
<None Include="build\tslint.json" />
|
||||||
@@ -2154,7 +2153,7 @@
|
|||||||
<SaveServerSettingsInUserFile>False</SaveServerSettingsInUserFile>
|
<SaveServerSettingsInUserFile>False</SaveServerSettingsInUserFile>
|
||||||
</WebProjectProperties>
|
</WebProjectProperties>
|
||||||
</FlavorProperties>
|
</FlavorProperties>
|
||||||
<UserProperties ui_2layouts_2wrap-layout_2package_1json__JSONSchema="http://json.schemastore.org/package" ui_2layouts_2grid-layout_2package_1json__JSONSchema="" ui_2layouts_2dock-layout_2package_1json__JSONSchema="" ui_2layouts_2absolute-layout_2package_1json__JSONSchema="http://json.schemastore.org/package" ui_2web-view_2package_1json__JSONSchema="http://json.schemastore.org/package" ui_2content-view_2package_1json__JSONSchema="http://json.schemastore.org/package" apps_2gallery-app_2package_1json__JSONSchema="http://json.schemastore.org/package" apps_2absolute-layout-demo_2package_1json__JSONSchema="http://json.schemastore.org/package" apps_2editable-text-demo_2package_1json__JSONSchema="http://json.schemastore.org/package" ui_2scroll-view_2package_1json__JSONSchema="http://json.schemastore.org/package" />
|
<UserProperties ui_2scroll-view_2package_1json__JSONSchema="http://json.schemastore.org/package" apps_2editable-text-demo_2package_1json__JSONSchema="http://json.schemastore.org/package" apps_2absolute-layout-demo_2package_1json__JSONSchema="http://json.schemastore.org/package" apps_2gallery-app_2package_1json__JSONSchema="http://json.schemastore.org/package" ui_2content-view_2package_1json__JSONSchema="http://json.schemastore.org/package" ui_2web-view_2package_1json__JSONSchema="http://json.schemastore.org/package" ui_2layouts_2absolute-layout_2package_1json__JSONSchema="http://json.schemastore.org/package" ui_2layouts_2dock-layout_2package_1json__JSONSchema="" ui_2layouts_2grid-layout_2package_1json__JSONSchema="" ui_2layouts_2wrap-layout_2package_1json__JSONSchema="http://json.schemastore.org/package" />
|
||||||
</VisualStudio>
|
</VisualStudio>
|
||||||
</ProjectExtensions>
|
</ProjectExtensions>
|
||||||
</Project>
|
</Project>
|
||||||
@@ -25,6 +25,7 @@ export function isRunningOnEmulator(): boolean {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export var allTests = {};
|
export var allTests = {};
|
||||||
|
allTests["PROXY-VIEW-CONTAINER"] = require("./ui/proxy-view-container/proxy-view-container-tests")
|
||||||
allTests["SCROLL-VIEW"] = require("./ui/scroll-view/scroll-view-tests");
|
allTests["SCROLL-VIEW"] = require("./ui/scroll-view/scroll-view-tests");
|
||||||
allTests["ACTION-BAR"] = require("./ui/action-bar/action-bar-tests");
|
allTests["ACTION-BAR"] = require("./ui/action-bar/action-bar-tests");
|
||||||
allTests["XML-DECLARATION"] = require("./xml-declaration/xml-declaration-tests");
|
allTests["XML-DECLARATION"] = require("./xml-declaration/xml-declaration-tests");
|
||||||
|
|||||||
160
apps/tests/ui/proxy-view-container/proxy-view-container-tests.ts
Normal file
160
apps/tests/ui/proxy-view-container/proxy-view-container-tests.ts
Normal file
@@ -0,0 +1,160 @@
|
|||||||
|
import TKUnit = require("../../TKUnit");
|
||||||
|
import helper = require("../helper");
|
||||||
|
import viewModule = require("ui/core/view");
|
||||||
|
import observable = require("data/observable");
|
||||||
|
import color = require("color");
|
||||||
|
import platform = require("platform");
|
||||||
|
|
||||||
|
import {ProxyViewContainer} from "ui/proxy-view-container";
|
||||||
|
import {View, Button, StackLayout} from "ui";
|
||||||
|
|
||||||
|
export function test_add_children_to_attached_proxy() {
|
||||||
|
var outer = new StackLayout();
|
||||||
|
var proxy = new ProxyViewContainer();
|
||||||
|
|
||||||
|
function testAction(views: Array<viewModule.View>) {
|
||||||
|
outer.addChild(createBtn("1"));
|
||||||
|
outer.addChild(proxy);
|
||||||
|
proxy.addChild(createBtn("2"));
|
||||||
|
proxy.addChild(createBtn("3"));
|
||||||
|
proxy.addChild(createBtn("4"));
|
||||||
|
|
||||||
|
outer.addChild(createBtn("5"));
|
||||||
|
|
||||||
|
assertNativeChildren(outer, ["1", "2", "3", "4", "5"]);
|
||||||
|
};
|
||||||
|
|
||||||
|
helper.buildUIAndRunTest(outer, testAction);
|
||||||
|
}
|
||||||
|
|
||||||
|
export function test_add_children_to_detached_proxy() {
|
||||||
|
var outer = new StackLayout();
|
||||||
|
var proxy = new ProxyViewContainer();
|
||||||
|
|
||||||
|
function testAction(views: Array<viewModule.View>) {
|
||||||
|
outer.addChild(createBtn("1"));
|
||||||
|
|
||||||
|
proxy.addChild(createBtn("2"));
|
||||||
|
proxy.addChild(createBtn("3"));
|
||||||
|
proxy.addChild(createBtn("4"));
|
||||||
|
outer.addChild(proxy);
|
||||||
|
|
||||||
|
outer.addChild(createBtn("5"));
|
||||||
|
|
||||||
|
assertNativeChildren(outer, ["1", "2", "3", "4", "5"]);
|
||||||
|
};
|
||||||
|
|
||||||
|
helper.buildUIAndRunTest(outer, testAction);
|
||||||
|
}
|
||||||
|
|
||||||
|
export function test_remove_proxy() {
|
||||||
|
var outer = new StackLayout();
|
||||||
|
var proxy = new ProxyViewContainer();
|
||||||
|
|
||||||
|
outer.addChild(createBtn("1"));
|
||||||
|
|
||||||
|
outer.addChild(proxy);
|
||||||
|
proxy.addChild(createBtn("2"));
|
||||||
|
proxy.addChild(createBtn("3"));
|
||||||
|
proxy.addChild(createBtn("4"));
|
||||||
|
|
||||||
|
outer.addChild(createBtn("5"));
|
||||||
|
|
||||||
|
function testAction(views: Array<viewModule.View>) {
|
||||||
|
assertNativeChildren(outer, ["1", "2", "3", "4", "5"]);
|
||||||
|
outer.removeChild(proxy);
|
||||||
|
assertNativeChildren(outer, ["1", "5"]);
|
||||||
|
};
|
||||||
|
|
||||||
|
helper.buildUIAndRunTest(outer, testAction);
|
||||||
|
}
|
||||||
|
|
||||||
|
export function test_remove_child_of_attached_proxy() {
|
||||||
|
var outer = new StackLayout();
|
||||||
|
var proxy = new ProxyViewContainer();
|
||||||
|
|
||||||
|
outer.addChild(createBtn("1"));
|
||||||
|
|
||||||
|
outer.addChild(proxy);
|
||||||
|
proxy.addChild(createBtn("2"));
|
||||||
|
var testBtn = createBtn("3")
|
||||||
|
proxy.addChild(testBtn);
|
||||||
|
proxy.addChild(createBtn("4"));
|
||||||
|
|
||||||
|
outer.addChild(createBtn("5"));
|
||||||
|
|
||||||
|
function testAction(views: Array<viewModule.View>) {
|
||||||
|
assertNativeChildren(outer, ["1", "2", "3", "4", "5"]);
|
||||||
|
proxy.removeChild(testBtn);
|
||||||
|
assertNativeChildren(outer, ["1", "2", "4", "5"]);
|
||||||
|
};
|
||||||
|
|
||||||
|
helper.buildUIAndRunTest(outer, testAction);
|
||||||
|
}
|
||||||
|
|
||||||
|
export function test_insert_inside_porxy() {
|
||||||
|
var outer = new StackLayout();
|
||||||
|
var proxy = new ProxyViewContainer();
|
||||||
|
|
||||||
|
outer.addChild(createBtn("1"));
|
||||||
|
|
||||||
|
outer.addChild(proxy);
|
||||||
|
proxy.addChild(createBtn("2"));
|
||||||
|
proxy.addChild(createBtn("4"));
|
||||||
|
|
||||||
|
outer.addChild(createBtn("5"));
|
||||||
|
|
||||||
|
function testAction(views: Array<viewModule.View>) {
|
||||||
|
assertNativeChildren(outer, ["1", "2", "4", "5"]);
|
||||||
|
proxy.insertChild(createBtn("3"), 1);
|
||||||
|
assertNativeChildren(outer, ["1", "2", "3", "4", "5"]);
|
||||||
|
};
|
||||||
|
|
||||||
|
helper.buildUIAndRunTest(outer, testAction);
|
||||||
|
}
|
||||||
|
|
||||||
|
export function test_insert_after_porxy() {
|
||||||
|
var outer = new StackLayout();
|
||||||
|
var proxy = new ProxyViewContainer();
|
||||||
|
|
||||||
|
outer.addChild(createBtn("1"));
|
||||||
|
|
||||||
|
outer.addChild(proxy);
|
||||||
|
proxy.addChild(createBtn("2"));
|
||||||
|
proxy.addChild(createBtn("3"));
|
||||||
|
proxy.addChild(createBtn("4"));
|
||||||
|
|
||||||
|
function testAction(views: Array<viewModule.View>) {
|
||||||
|
assertNativeChildren(outer, ["1", "2", "3", "4"]);
|
||||||
|
outer.insertChild(createBtn("5"), 2);
|
||||||
|
assertNativeChildren(outer, ["1", "2", "3", "4", "5"]);
|
||||||
|
};
|
||||||
|
|
||||||
|
helper.buildUIAndRunTest(outer, testAction);
|
||||||
|
}
|
||||||
|
|
||||||
|
function createBtn(text: string): Button {
|
||||||
|
var b = new Button();
|
||||||
|
b.text = text;
|
||||||
|
return b;
|
||||||
|
}
|
||||||
|
|
||||||
|
function assertNativeChildren(stack: StackLayout, arr: Array<string>) {
|
||||||
|
if (stack.android) {
|
||||||
|
let android: org.nativescript.widgets.StackLayout = stack.android;
|
||||||
|
TKUnit.assertEqual(android.getChildCount(), arr.length, "Native children");
|
||||||
|
for (let i = 0; i < arr.length; i++) {
|
||||||
|
let nativeBtn = <android.widget.Button>android.getChildAt(i);
|
||||||
|
TKUnit.assertEqual(nativeBtn.getText(), arr[i]);
|
||||||
|
}
|
||||||
|
} else if (stack.ios) {
|
||||||
|
let ios: UIView = stack.ios;
|
||||||
|
TKUnit.assertEqual(ios.subviews.count, arr.length, "Native children");
|
||||||
|
for (let i = 0; i < arr.length; i++) {
|
||||||
|
let nativeBtn = <UIButton>ios.subviews[i];
|
||||||
|
TKUnit.assertEqual(nativeBtn.titleLabel.text, arr[i]);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
TKUnit.assert(false, "No native view to assert");
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -265,6 +265,7 @@
|
|||||||
"apps/tests/ui/page/test-page-module.ts",
|
"apps/tests/ui/page/test-page-module.ts",
|
||||||
"apps/tests/ui/placeholder/placeholder-tests.ts",
|
"apps/tests/ui/placeholder/placeholder-tests.ts",
|
||||||
"apps/tests/ui/progress/progress-tests.ts",
|
"apps/tests/ui/progress/progress-tests.ts",
|
||||||
|
"apps/tests/ui/proxy-view-container/proxy-view-container-tests.ts",
|
||||||
"apps/tests/ui/repeater/repeater-tests.ts",
|
"apps/tests/ui/repeater/repeater-tests.ts",
|
||||||
"apps/tests/ui/repeater/repeaterItems-bindingToGestures.ts",
|
"apps/tests/ui/repeater/repeaterItems-bindingToGestures.ts",
|
||||||
"apps/tests/ui/scroll-view/scroll-view-tests.ts",
|
"apps/tests/ui/scroll-view/scroll-view-tests.ts",
|
||||||
@@ -594,6 +595,8 @@
|
|||||||
"ui/progress/progress.android.ts",
|
"ui/progress/progress.android.ts",
|
||||||
"ui/progress/progress.d.ts",
|
"ui/progress/progress.d.ts",
|
||||||
"ui/progress/progress.ios.ts",
|
"ui/progress/progress.ios.ts",
|
||||||
|
"ui/proxy-view-container/proxy-view-container.d.ts",
|
||||||
|
"ui/proxy-view-container/proxy-view-container.ts",
|
||||||
"ui/repeater/repeater.d.ts",
|
"ui/repeater/repeater.d.ts",
|
||||||
"ui/repeater/repeater.ts",
|
"ui/repeater/repeater.ts",
|
||||||
"ui/scroll-view/scroll-view-common.ts",
|
"ui/scroll-view/scroll-view-common.ts",
|
||||||
@@ -664,8 +667,6 @@
|
|||||||
"ui/ui.ts",
|
"ui/ui.ts",
|
||||||
"ui/utils.d.ts",
|
"ui/utils.d.ts",
|
||||||
"ui/utils.ios.ts",
|
"ui/utils.ios.ts",
|
||||||
"ui/view-container/proxy-view-container.d.ts",
|
|
||||||
"ui/view-container/proxy-view-container.ts",
|
|
||||||
"ui/web-view/web-view-common.ts",
|
"ui/web-view/web-view-common.ts",
|
||||||
"ui/web-view/web-view.android.ts",
|
"ui/web-view/web-view.android.ts",
|
||||||
"ui/web-view/web-view.d.ts",
|
"ui/web-view/web-view.d.ts",
|
||||||
|
|||||||
Reference in New Issue
Block a user