Skip to content

Commit d8721c7

Browse files
ADjenkovdtopuzov
authored andcommitted
tests(ui-test-app): add LayoutChanged event test
1 parent c3a7c81 commit d8721c7

3 files changed

Lines changed: 38 additions & 0 deletions

File tree

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
import { StackLayout } from "tns-core-modules/ui/layouts/stack-layout";
2+
import { Button } from "tns-core-modules/ui/button";
3+
import { TextView } from "tns-core-modules/ui/text-view";
4+
import { View } from "tns-core-modules/ui/core/view";
5+
import { EventData } from "tns-core-modules/data/observable";
6+
let buttonsCount = 1;
7+
8+
export function onLayoutChanged(args) {
9+
let msg = "StackLayout layout changed - width:" + args.object.getActualSize().width;
10+
(<TextView>args.object.page.getViewById("output")).text += msg + "\n";
11+
}
12+
13+
export function addChild(args) {
14+
let button = new Button();
15+
button.text = "Button" + buttonsCount;
16+
button.margin = 10;
17+
button.backgroundColor = "lightgreen";
18+
19+
(<StackLayout>args.object.page.getViewById("target")).addChild(button);
20+
buttonsCount++;
21+
}
22+
23+
export function clear(args) {
24+
(<StackLayout>args.object.page.getViewById("target")).removeChildren();
25+
args.object.page.getViewById("output").text = "";
26+
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<Page>
2+
<GridLayout rows="*, *, *" >
3+
<StackLayout horizontalAlignment="left" orientation="horizontal" backgroundColor="yellow" id="target" margin="20" layoutChanged="onLayoutChanged"/>
4+
5+
<StackLayout row="1">
6+
<Button text="clear" tap="clear"/>
7+
<Button text="add child" tap="addChild"/>
8+
</StackLayout>
9+
<TextView row="2" id="output" automationText="output" style="font-size: 10, font-family: monospace;"/>
10+
</GridLayout>
11+
</Page>

apps/app/ui-tests-app/events/main-page.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ export function loadExamples() {
1919
examples.set("i61", "events/i61");
2020
examples.set("i73", "events/i73");
2121
examples.set("i86", "events/i86");
22+
examples.set("layout changed", "events/layout-changed-event");
2223

2324
return examples;
2425
}

0 commit comments

Comments
 (0)