Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions tests/app/ui/layouts/safe-area-tests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ import * as platform from "tns-core-modules/platform";
import { ios as iosUtils } from "tns-core-modules/utils/utils";
import * as helper from "../helper";
import { parse } from "tns-core-modules/ui/builder";
import { Page } from "tns-core-modules/ui/page";
import { Label } from "tns-core-modules/ui/label";
import {
dipToDp, left, top, right, bottom, height, width,
equal, closeEnough, lessOrCloseEnough, greaterOrCloseEnough, check,
Expand Down Expand Up @@ -37,6 +39,30 @@ export class SafeAreaTests extends testModule.UITest<any> {
// no operation
};

public test_layout_changed_event_count() {
const page = <Page>parse(`
<Page>
<GridLayout id="grid" backgroundColor="Crimson">
<Label id="label" text="label1" backgroundColor="Gold"></Label>
</GridLayout>
</Page>
`);
let gridLayoutChangedCounter = 0;
let labelLayoutChangedCounter = 0;
const grid = page.getViewById("grid");
grid.on(view.View.layoutChangedEvent, () => {
gridLayoutChangedCounter++;
});
const label = <Label>page.getViewById("label");
label.on(view.View.layoutChangedEvent, () => {
labelLayoutChangedCounter++;
});
helper.navigate(() => page);
label.height = 100;
TKUnit.waitUntilReady(() => labelLayoutChangedCounter === 2);
TKUnit.assert(gridLayoutChangedCounter === 1, `${grid} layoutChanged event count - actual:${gridLayoutChangedCounter}; expected: 1`)
}

// Common
private getViews(template: string) {
let root = parse(template);
Expand Down