@@ -78,6 +78,22 @@ function getNativeHeight(view: View): number {
7878 return layout . toDevicePixels ( bounds . size . height ) ;
7979}
8080
81+ export function test_correct_layout_top_bottom_edges_does_not_span_not_scrollable_not_flat ( ) {
82+ test_correct_layout_top_bottom_edges_does_not_span_options ( false , false ) ;
83+ }
84+
85+ export function test_correct_layout_top_bottom_edges_does_not_span_scrollable_not_flat ( ) {
86+ test_correct_layout_top_bottom_edges_does_not_span_options ( true , false ) ;
87+ }
88+
89+ export function test_correct_layout_top_bottom_edges_does_not_span_not_scrollable_flat ( ) {
90+ test_correct_layout_top_bottom_edges_does_not_span_options ( false , true ) ;
91+ }
92+
93+ export function test_correct_layout_top_bottom_edges_does_not_span_scrollable_flat ( ) {
94+ test_correct_layout_top_bottom_edges_does_not_span_options ( true , true ) ;
95+ }
96+
8197export function test_correct_layout_scrollable_content_false ( ) {
8298 const page = new Page ( ) ;
8399 topmost ( ) . viewController . navigationBar . translucent = true ;
@@ -251,6 +267,8 @@ export function test_correct_layout_scrollable_content_true_top_edge_does_not_sp
251267 const tabItem = new TabViewItem ( ) ;
252268 tabItem . title = "Item" ;
253269 const lbl = new Label ( ) ;
270+ lbl . viewController = iosView . UILayoutViewController . initWithOwner ( new WeakRef ( lbl ) ) ;
271+ lbl . viewController . edgesForExtendedLayout = UIRectEdge . Bottom | UIRectEdge . Left | UIRectEdge . Right ;
254272 ( < any > lbl ) . scrollableContent = true ;
255273 tabItem . view = lbl ;
256274 tabView . items = [ tabItem ] ;
@@ -284,6 +302,8 @@ export function test_correct_layout_scrollable_content_true_bottom_edge_does_not
284302 const tabItem = new TabViewItem ( ) ;
285303 tabItem . title = "Item" ;
286304 const lbl = new Label ( ) ;
305+ lbl . viewController = iosView . UILayoutViewController . initWithOwner ( new WeakRef ( lbl ) ) ;
306+ lbl . viewController . edgesForExtendedLayout = UIRectEdge . Top | UIRectEdge . Left | UIRectEdge . Right ;
287307 ( < any > lbl ) . scrollableContent = true ;
288308 tabItem . view = lbl ;
289309 tabView . items = [ tabItem ] ;
@@ -292,11 +312,7 @@ export function test_correct_layout_scrollable_content_true_bottom_edge_does_not
292312 helper . navigate ( ( ) => page ) ;
293313 TKUnit . assertTrue ( page . isLoaded , "page NOT loaded!" ) ;
294314 TKUnit . assertNotNull ( lbl . viewController ) ;
295- ( < UIViewController > lbl . viewController ) . edgesForExtendedLayout = UIRectEdge . Top | UIRectEdge . Left | UIRectEdge . Right ;
296- lbl . requestLayout ( ) ;
297- ( < UIView > lbl . nativeViewProtected ) . setNeedsLayout ( ) ;
298- ( < UIView > lbl . nativeViewProtected ) . layoutIfNeeded ( ) ;
299- TKUnit . waitUntilReady ( ( ) => lbl . isLayoutValid ) ;
315+
300316 const tabBarHeight = uiUtils . ios . getActualHeight ( tabView . viewController . tabBar ) ;
301317 const screenHeight = layout . toDevicePixels ( UIScreen . mainScreen . bounds . size . height ) ;
302318
@@ -307,58 +323,35 @@ export function test_correct_layout_scrollable_content_true_bottom_edge_does_not
307323 TKUnit . assertEqual ( contentHeight , screenHeight - tabBarHeight , "lbl.height !== screenHeight - tabBarHeight" ) ;
308324}
309325
310- export function test_correct_layout_top_bottom_edges_does_not_span ( ) {
326+ function test_correct_layout_top_bottom_edges_does_not_span_options ( scrollable : boolean , flat : boolean ) {
311327 const page = new Page ( ) ;
312- page . actionBar . flat = false ;
313- ( < any > page ) . scrollableContent = false ;
314328 page . actionBar . title = "ActionBar" ;
315- ( < UIViewController > page . viewController ) . edgesForExtendedLayout = UIRectEdge . Left | UIRectEdge . Right ;
316329
317330 const tabView = new TabView ( ) ;
318- ( < UIViewController > tabView . viewController ) . edgesForExtendedLayout = UIRectEdge . Left | UIRectEdge . Right ;
319331 const tabItem = new TabViewItem ( ) ;
320332 tabItem . title = "Item" ;
321333 const lbl = new Label ( ) ;
334+ lbl . viewController = iosView . UILayoutViewController . initWithOwner ( new WeakRef ( lbl ) ) ;
335+ lbl . viewController . edgesForExtendedLayout = UIRectEdge . Left | UIRectEdge . Right ;
322336 tabItem . view = lbl ;
323337 tabView . items = [ tabItem ] ;
324338
325339 page . content = tabView ;
340+
341+ page . actionBar . flat = flat ;
342+ ( < any > page ) . scrollableContent = scrollable ;
343+ ( < any > lbl ) . scrollableContent = scrollable ;
344+
326345 helper . navigate ( ( ) => page ) ;
327346 TKUnit . assertTrue ( page . isLoaded , "page NOT loaded!" ) ;
328347
329- ( < UIViewController > lbl . viewController ) . edgesForExtendedLayout = UIRectEdge . Left | UIRectEdge . Right ;
330- lbl . requestLayout ( ) ;
331- ( < UIView > lbl . nativeViewProtected ) . setNeedsLayout ( ) ;
332- ( < UIView > lbl . nativeViewProtected ) . layoutIfNeeded ( ) ;
333- TKUnit . waitUntilReady ( ( ) => lbl . isLayoutValid ) ;
334-
335348 const statusBarHeight = uiUtils . ios . getStatusBarHeight ( page . viewController ) ;
336349 const tabBarHeight = uiUtils . ios . getActualHeight ( tabView . viewController . tabBar ) ;
337350 const screenHeight = layout . toDevicePixels ( UIScreen . mainScreen . bounds . size . height ) ;
338351 const navBarHeight = uiUtils . ios . getActualHeight ( page . frame . ios . controller . navigationBar ) ;
339352
340- const assert = ( scrollable : boolean , flat : boolean ) => {
341- page . actionBar . flat = flat ;
342- ( < any > page ) . scrollableContent = scrollable ;
343- ( < any > lbl ) . scrollableContent = scrollable ;
344-
345- lbl . requestLayout ( ) ;
346- TKUnit . waitUntilReady ( ( ) => lbl . isLayoutValid ) ;
347-
348- const pageHeight = getHeight ( page ) ;
349- TKUnit . assertEqual ( pageHeight , screenHeight - statusBarHeight - navBarHeight , "page.height !== screenHeight - statusBarHeight - navBarHeight" ) ;
350- const contentHeight = getHeight ( lbl ) ;
351- TKUnit . assertEqual ( contentHeight , screenHeight - statusBarHeight - navBarHeight - tabBarHeight , "lbl.height !== screenHeight - statusBarHeight - navBarHeight - tabBarHeight" ) ;
352- } ;
353-
354- // scrollable: false, flat: false;
355- assert ( false , false ) ;
356- // scrollable: true, flat: false;
357- assert ( true , false ) ;
358- // scrollable: true, flat: true;
359- assert ( true , true ) ;
360- // scrollable: false, flat: true;
361- assert ( false , true ) ;
353+ const contentHeight = getHeight ( lbl ) ;
354+ TKUnit . assertEqual ( contentHeight , screenHeight - statusBarHeight - navBarHeight - tabBarHeight , "lbl.height !== screenHeight - statusBarHeight - navBarHeight - tabBarHeight" ) ;
362355}
363356
364357export function test_showing_native_viewcontroller_doesnt_throw_exception ( ) {
0 commit comments