Skip to content

Commit 4d520e8

Browse files
PanayotCankovSvetoslavTsenov
authored andcommitted
Added perf category in the tests suite and the synthetic properties perf app from HHristov
1 parent dce7d04 commit 4d520e8

File tree

6 files changed

+413
-0
lines changed

6 files changed

+413
-0
lines changed

apps/app/ui-tests-app/mainPage.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@ export function pageLoaded(args: EventData) {
3838
examples.set("issues", "issues/main-page");
3939
examples.set("page", "page/main-page");
4040

41+
examples.set("perf", "perf/main-page");
42+
4143
//examples.set("listview_binding", "pages/listview_binding");
4244
//examples.set("textfield", "text-field/text-field");
4345

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
import { EventData } from "tns-core-modules/data/observable";
2+
import { MainPageViewModel } from "../mainPage";
3+
import { WrapLayout } from "tns-core-modules/ui/layouts/wrap-layout";
4+
import { Page } from "tns-core-modules/ui/page";
5+
6+
export function pageLoaded(args: EventData) {
7+
let page = <Page>args.object;
8+
let view = require("ui/core/view");
9+
10+
let wrapLayout = view.getViewById(page, "wrapLayoutWithExamples");
11+
12+
let examples: Map<string, string> = new Map<string, string>();
13+
examples.set("properties", "perf/properties/main-page");
14+
15+
let viewModel = new SubMainPageViewModel(wrapLayout, examples);
16+
page.bindingContext = viewModel;
17+
}
18+
19+
export class SubMainPageViewModel extends MainPageViewModel {
20+
constructor(container: WrapLayout, examples: Map<string, string>) {
21+
super(container, examples);
22+
}
23+
}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<?xml version="1.0" encoding="UTF-8" ?>
2+
<Page loaded="pageLoaded">
3+
<ScrollView orientation="vertical" row="1">
4+
<WrapLayout id="wrapLayoutWithExamples"/>
5+
</ScrollView>
6+
</Page>
Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
import { StackLayout } from "tns-core-modules/ui/layouts/stack-layout";
2+
import { Label } from "tns-core-modules/ui/label";
3+
import { TextView } from "tns-core-modules/ui/text-view";
4+
import { Button } from "tns-core-modules/ui/button";
5+
import { Page } from "tns-core-modules/ui/page";
6+
import { Color } from "tns-core-modules/color";
7+
import { isIOS } from "tns-core-modules/platform";
8+
9+
import * as knownColors from "tns-core-modules/color/known-colors";
10+
11+
import * as tests from "./tests";
12+
13+
let red = new Color(knownColors.Red);
14+
let green = new Color(knownColors.Green);
15+
let blue = new Color(knownColors.Blue);
16+
let purple = new Color(knownColors.Purple);
17+
18+
const c = [10, 100, 1000, 10000, 100000];
19+
20+
function getStack(stack: StackLayout): StackLayout {
21+
let p = new StackLayout();
22+
stack.removeChildren();
23+
stack.addChild(p);
24+
return p;
25+
}
26+
27+
let runner;
28+
29+
export function onNavigatingFrom() {
30+
clearInterval(runner);
31+
}
32+
33+
export function onTap3(args) {
34+
let btn = <Button>args.object;
35+
const p = btn.page.getViewById<StackLayout>("placeholder");
36+
btn.text = "Start tests...";
37+
38+
let result = btn.page.getViewById<TextView>("result");
39+
40+
result.text = "";
41+
42+
function track(line: string) {
43+
console.log(line);
44+
result.text += line + "\n";
45+
}
46+
47+
let text = "Count";
48+
c.forEach(e => {
49+
text += `\t${e}`;
50+
});
51+
track(text);
52+
53+
let tasks = [
54+
() => track(tests.setBackgroundColor(c)),
55+
() => track(tests.setBackgroundColor(c, getStack(p))),
56+
() => track(tests.setBindingContext(c)),
57+
() => track(tests.setBindingContext(c, getStack(p))),
58+
() => track(tests.setBindingContextWithParents(c, getStack(p))),
59+
() => track(tests.setBindingContextWithParentsBound(c, getStack(p))),
60+
() => track(tests.setBorderWidths(c)),
61+
() => track(tests.setBorderWidths(c, getStack(p))),
62+
() => track(tests.setFontSize(c)),
63+
() => track(tests.setFontSize(c, getStack(p))),
64+
() => track(tests.setFontSizeWithParents(c, getStack(p))),
65+
() => track(tests.setFontWeight(c)),
66+
() => track(tests.setFontWeight(c, getStack(p))),
67+
() => track(tests.setFontWeightWithParents(c, getStack(p))),
68+
() => track(tests.setColor(c)),
69+
() => track(tests.setColor(c, getStack(p))),
70+
() => track(tests.setColorWithParents(c, getStack(p))),
71+
() => track(tests.setText(c)),
72+
() => track(tests.setText(c, getStack(p))),
73+
() => track(tests.addRemove(c, getStack(p))),
74+
() => track("Complete!")
75+
];
76+
let i = 0;
77+
runner = setInterval(nextTask, 1);
78+
function nextTask() {
79+
if (i < tasks.length) {
80+
tasks[i]();
81+
i++;
82+
} else {
83+
clearInterval(runner);
84+
}
85+
}
86+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
<Page xmlns="http://schemas.nativescript.org/tns.xsd" navigatingFrom="onNavigatingFrom">
2+
<GridLayout rows="auto, *">
3+
<StackLayout id="placeholder" rowSpan="2" opacity="0.2" />
4+
<Button text="Start test..." tap="onTap3"/>
5+
<TextView id="result" row="1" />
6+
</GridLayout>
7+
</Page>

0 commit comments

Comments
 (0)