mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-11-05 13:26:48 +08:00
tests(ui-test-app): add LayoutChanged event test
This commit is contained in:
committed by
Dimitar Topuzov
parent
c3a7c815e5
commit
d8721c7bd8
26
apps/app/ui-tests-app/events/layout-changed-event.ts
Normal file
26
apps/app/ui-tests-app/events/layout-changed-event.ts
Normal file
@@ -0,0 +1,26 @@
|
||||
import { StackLayout } from "tns-core-modules/ui/layouts/stack-layout";
|
||||
import { Button } from "tns-core-modules/ui/button";
|
||||
import { TextView } from "tns-core-modules/ui/text-view";
|
||||
import { View } from "tns-core-modules/ui/core/view";
|
||||
import { EventData } from "tns-core-modules/data/observable";
|
||||
let buttonsCount = 1;
|
||||
|
||||
export function onLayoutChanged(args) {
|
||||
let msg = "StackLayout layout changed - width:" + args.object.getActualSize().width;
|
||||
(<TextView>args.object.page.getViewById("output")).text += msg + "\n";
|
||||
}
|
||||
|
||||
export function addChild(args) {
|
||||
let button = new Button();
|
||||
button.text = "Button" + buttonsCount;
|
||||
button.margin = 10;
|
||||
button.backgroundColor = "lightgreen";
|
||||
|
||||
(<StackLayout>args.object.page.getViewById("target")).addChild(button);
|
||||
buttonsCount++;
|
||||
}
|
||||
|
||||
export function clear(args) {
|
||||
(<StackLayout>args.object.page.getViewById("target")).removeChildren();
|
||||
args.object.page.getViewById("output").text = "";
|
||||
}
|
||||
11
apps/app/ui-tests-app/events/layout-changed-event.xml
Normal file
11
apps/app/ui-tests-app/events/layout-changed-event.xml
Normal file
@@ -0,0 +1,11 @@
|
||||
<Page>
|
||||
<GridLayout rows="*, *, *" >
|
||||
<StackLayout horizontalAlignment="left" orientation="horizontal" backgroundColor="yellow" id="target" margin="20" layoutChanged="onLayoutChanged"/>
|
||||
|
||||
<StackLayout row="1">
|
||||
<Button text="clear" tap="clear"/>
|
||||
<Button text="add child" tap="addChild"/>
|
||||
</StackLayout>
|
||||
<TextView row="2" id="output" automationText="output" style="font-size: 10, font-family: monospace;"/>
|
||||
</GridLayout>
|
||||
</Page>
|
||||
@@ -19,6 +19,7 @@ export function loadExamples() {
|
||||
examples.set("i61", "events/i61");
|
||||
examples.set("i73", "events/i73");
|
||||
examples.set("i86", "events/i86");
|
||||
examples.set("layout changed", "events/layout-changed-event");
|
||||
|
||||
return examples;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user