Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
UIViewController_FlutterScreenAndSceneIfLoadedTest.mm
Go to the documentation of this file.
1// Copyright 2013 The Flutter Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5#import <XCTest/XCTest.h>
6
7#import "flutter/shell/platform/darwin/common/framework/Headers/FlutterMacros.h"
8#import "flutter/shell/platform/darwin/ios/framework/Source/UIViewController+FlutterScreenAndSceneIfLoaded.h"
9
11
13@end
14
16
18 if (@available(iOS 13.0, *)) {
19 UIViewController* viewController = [[UIViewController alloc] initWithNibName:nil bundle:nil];
20
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];
29
30 [viewController loadView];
31 XCTAssertEqual(viewController.flutterWindowSceneIfViewLoaded, windowScene,
32 @"Must return the correct window scene when view loaded");
33 }
34}
35
37 if (@available(iOS 13.0, *)) {
38 UIViewController* viewController = [[UIViewController alloc] initWithNibName:nil bundle:nil];
39 XCTAssertNil(viewController.flutterWindowSceneIfViewLoaded,
40 @"Must return nil window scene when view not loaded");
41 }
42}
43
45 if (@available(iOS 13.0, *)) {
46 return;
47 }
48
49 UIViewController* viewController = [[UIViewController alloc] initWithNibName:nil bundle:nil];
50 XCTAssertEqual(viewController.flutterScreenIfViewLoaded, UIScreen.mainScreen,
51 @"Must return UIScreen.mainScreen before iOS 13");
52}
53
55 if (@available(iOS 13.0, *)) {
56 UIViewController* viewController = [[UIViewController alloc] initWithNibName:nil bundle:nil];
57
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];
66
67 [viewController loadView];
68 XCTAssertEqual(viewController.flutterScreenIfViewLoaded, windowScene.screen,
69 @"Must return the correct screen when view loaded");
70 }
71}
72
74 if (@available(iOS 13.0, *)) {
75 UIViewController* viewController = [[UIViewController alloc] initWithNibName:nil bundle:nil];
76 XCTAssertNil(viewController.flutterScreenIfViewLoaded,
77 @"Must return nil screen when view not loaded");
78 }
79}
80
81@end
GLFWwindow * window
Definition main.cc:45
FlutterViewController * viewController