@@ -6,6 +6,8 @@ import * as platform from "tns-core-modules/platform";
6
6
import { ios as iosUtils } from "tns-core-modules/utils/utils" ;
7
7
import * as helper from "../helper" ;
8
8
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" ;
9
11
import {
10
12
dipToDp , left , top , right , bottom , height , width ,
11
13
equal , closeEnough , lessOrCloseEnough , greaterOrCloseEnough , check ,
@@ -37,6 +39,30 @@ export class SafeAreaTests extends testModule.UITest<any> {
37
39
// no operation
38
40
} ;
39
41
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
+
40
66
// Common
41
67
private getViews ( template : string ) {
42
68
let root = parse ( template ) ;
0 commit comments