Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 1485445

Browse files
tgpetrovmanoldonev
authored andcommitted
test(safe-area): add layoutChanged test (NativeScript#6462)
1 parent 41ba93d commit 1485445

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

tests/app/ui/layouts/safe-area-tests.ts

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ import * as platform from "tns-core-modules/platform";
66
import { ios as iosUtils } from "tns-core-modules/utils/utils";
77
import * as helper from "../helper";
88
import { parse } from "tns-core-modules/ui/builder";
9+
import { Page } from "tns-core-modules/ui/page";
10+
import { Label } from "tns-core-modules/ui/label";
911
import {
1012
dipToDp, left, top, right, bottom, height, width,
1113
equal, closeEnough, lessOrCloseEnough, greaterOrCloseEnough, check,
@@ -37,6 +39,30 @@ export class SafeAreaTests extends testModule.UITest<any> {
3739
// no operation
3840
};
3941

42+
public test_layout_changed_event_count() {
43+
const page = <Page>parse(`
44+
<Page>
45+
<GridLayout id="grid" backgroundColor="Crimson">
46+
<Label id="label" text="label1" backgroundColor="Gold"></Label>
47+
</GridLayout>
48+
</Page>
49+
`);
50+
let gridLayoutChangedCounter = 0;
51+
let labelLayoutChangedCounter = 0;
52+
const grid = page.getViewById("grid");
53+
grid.on(view.View.layoutChangedEvent, () => {
54+
gridLayoutChangedCounter++;
55+
});
56+
const label = <Label>page.getViewById("label");
57+
label.on(view.View.layoutChangedEvent, () => {
58+
labelLayoutChangedCounter++;
59+
});
60+
helper.navigate(() => page);
61+
label.height = 100;
62+
TKUnit.waitUntilReady(() => labelLayoutChangedCounter === 2);
63+
TKUnit.assert(gridLayoutChangedCounter === 1, `${grid} layoutChanged event count - actual:${gridLayoutChangedCounter}; expected: 1`)
64+
}
65+
4066
// Common
4167
private getViews(template: string) {
4268
let root = parse(template);

0 commit comments

Comments
 (0)