5 #import <XCTest/XCTest.h>
17 - (void)testWindowSceneIfViewLoadedReturnsWindowSceneIfViewLoaded {
18 if (@available(iOS 13.0, *)) {
19 UIViewController*
viewController = [[UIViewController alloc] initWithNibName:nil bundle:nil];
21 NSSet<UIScene*>* scenes = UIApplication.sharedApplication.connectedScenes;
22 XCTAssertEqual(scenes.count, 1UL,
@"There must only be 1 scene for test");
23 UIScene* scene = scenes.anyObject;
24 XCTAssert([scene isKindOfClass:[UIWindowScene
class]],
@"Must be a window scene for test");
25 UIWindowScene* windowScene = (UIWindowScene*)scene;
26 XCTAssert(windowScene.windows.count > 0,
@"There must be at least 1 window for test");
27 UIWindow* window = windowScene.windows[0];
28 [window addSubview:viewController.view];
30 [viewController loadView];
31 XCTAssertEqual(
viewController.flutterWindowSceneIfViewLoaded, windowScene,
32 @"Must return the correct window scene when view loaded");
36 - (void)testWindowSceneIfViewLoadedReturnsNilIfViewNotLoaded {
37 if (@available(iOS 13.0, *)) {
38 UIViewController*
viewController = [[UIViewController alloc] initWithNibName:nil bundle:nil];
40 @"Must return nil window scene when view not loaded");
44 - (void)testScreenIfViewLoadedReturnsMainScreenBeforeIOS13 {
45 if (@available(iOS 13.0, *)) {
49 UIViewController*
viewController = [[UIViewController alloc] initWithNibName:nil bundle:nil];
50 XCTAssertEqual(
viewController.flutterScreenIfViewLoaded, UIScreen.mainScreen,
51 @"Must return UIScreen.mainScreen before iOS 13");
54 - (void)testScreenIfViewLoadedReturnsScreenIfViewLoadedAfterIOS13 {
55 if (@available(iOS 13.0, *)) {
56 UIViewController*
viewController = [[UIViewController alloc] initWithNibName:nil bundle:nil];
58 NSSet<UIScene*>* scenes = UIApplication.sharedApplication.connectedScenes;
59 XCTAssertEqual(scenes.count, 1UL,
@"There must only be 1 scene for test");
60 UIScene* scene = scenes.anyObject;
61 XCTAssert([scene isKindOfClass:[UIWindowScene
class]],
@"Must be a window scene for test");
62 UIWindowScene* windowScene = (UIWindowScene*)scene;
63 XCTAssert(windowScene.windows.count > 0,
@"There must be at least 1 window for test");
64 UIWindow* window = windowScene.windows[0];
65 [window addSubview:viewController.view];
67 [viewController loadView];
68 XCTAssertEqual(
viewController.flutterScreenIfViewLoaded, windowScene.screen,
69 @"Must return the correct screen when view loaded");
73 - (void)testScreenIfViewLoadedReturnsNilIfViewNotLoadedAfterIOS13 {
74 if (@available(iOS 13.0, *)) {
75 UIViewController*
viewController = [[UIViewController alloc] initWithNibName:nil bundle:nil];
77 @"Must return nil screen when view not loaded");