Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
Instance Methods | Properties | List of all members
FlutterAppDelegateTest Class Reference
Inheritance diagram for FlutterAppDelegateTest:

Instance Methods

(void) - setUp [implementation]
 
(void) - tearDown [implementation]
 
(void) - testLaunchUrl [implementation]
 
(void) - testLaunchUrlWithDeepLinkingNotSet [implementation]
 
(void) - testLaunchUrlWithDeepLinkingDisabled [implementation]
 
(void) - testLaunchUrlWithQueryParameterAndFragment [implementation]
 
(void) - testLaunchUrlWithFragmentNoQueryParameter [implementation]
 
(void) - testReleasesWindowOnDealloc [implementation]
 
(void) - testUniversalLinkPushRouteInformation [implementation]
 

Properties

FlutterAppDelegateappDelegate
 
id mockMainBundle
 
id mockNavigationChannel
 
id mockEngineFirstFrameCallback
 

Detailed Description

Definition at line 16 of file FlutterAppDelegateTest.mm.

Method Documentation

◆ setUp

- (void) setUp
implementation

Definition at line 24 of file FlutterAppDelegateTest.mm.

29 {
30 [super setUp];
31
32 id mockMainBundle = OCMClassMock([NSBundle class]);
33 OCMStub([mockMainBundle mainBundle]).andReturn(mockMainBundle);
34 self.mockMainBundle = mockMainBundle;
35
37 self.appDelegate = appDelegate;
38
40 FlutterMethodChannel* navigationChannel = OCMClassMock([FlutterMethodChannel class]);
41 self.mockNavigationChannel = navigationChannel;
42
43 FlutterEngine* engine = OCMClassMock([FlutterEngine class]);
44 OCMStub([engine navigationChannel]).andReturn(navigationChannel);
45 OCMStub([viewController engine]).andReturn(engine);
46
47 id mockEngineFirstFrameCallback = [OCMArg invokeBlockWithArgs:@NO, nil];
48 self.mockEngineFirstFrameCallback = mockEngineFirstFrameCallback;
49 OCMStub([engine waitForFirstFrame:3.0 callback:mockEngineFirstFrameCallback]);
51 return viewController;
52 };
53}
FlutterEngine engine
Definition main.cc:68
FlKeyEvent uint64_t FlKeyResponderAsyncCallback callback
FlutterAppDelegate * appDelegate
FlutterViewController *(^ rootFlutterViewControllerGetter)(void)
FlutterViewController * viewController

◆ tearDown

- (void) tearDown
implementation

Definition at line 24 of file FlutterAppDelegateTest.mm.

55 {
56 // Explicitly stop mocking the NSBundle class property.
57 [self.mockMainBundle stopMocking];
58 [super tearDown];
59}

◆ testLaunchUrl

- (void) testLaunchUrl
implementation

Definition at line 24 of file FlutterAppDelegateTest.mm.

61 {
62 OCMStub([self.mockMainBundle objectForInfoDictionaryKey:@"FlutterDeepLinkingEnabled"])
63 .andReturn(@YES);
64
65 BOOL result =
66 [self.appDelegate application:[UIApplication sharedApplication]
67 openURL:[NSURL URLWithString:@"http://myApp/custom/route?query=test"]
68 options:@{}];
69 XCTAssertTrue(result);
70 OCMVerify([self.mockNavigationChannel
71 invokeMethod:@"pushRouteInformation"
72 arguments:@{@"location" : @"http://myApp/custom/route?query=test"}]);
73}
GAsyncResult * result
int BOOL

◆ testLaunchUrlWithDeepLinkingDisabled

- (void) testLaunchUrlWithDeepLinkingDisabled
implementation

Definition at line 24 of file FlutterAppDelegateTest.mm.

87 {
88 OCMStub([self.mockMainBundle objectForInfoDictionaryKey:@"FlutterDeepLinkingEnabled"])
89 .andReturn(@NO);
90
91 BOOL result =
92 [self.appDelegate application:[UIApplication sharedApplication]
93 openURL:[NSURL URLWithString:@"http://myApp/custom/route?query=test"]
94 options:@{}];
95 XCTAssertFalse(result);
96 OCMReject([self.mockNavigationChannel invokeMethod:OCMOCK_ANY arguments:OCMOCK_ANY]);
97}

◆ testLaunchUrlWithDeepLinkingNotSet

- (void) testLaunchUrlWithDeepLinkingNotSet
implementation

Definition at line 24 of file FlutterAppDelegateTest.mm.

75 {
76 OCMStub([self.mockMainBundle objectForInfoDictionaryKey:@"FlutterDeepLinkingEnabled"])
77 .andReturn(nil);
78
79 BOOL result =
80 [self.appDelegate application:[UIApplication sharedApplication]
81 openURL:[NSURL URLWithString:@"http://myApp/custom/route?query=test"]
82 options:@{}];
83 XCTAssertFalse(result);
84 OCMReject([self.mockNavigationChannel invokeMethod:OCMOCK_ANY arguments:OCMOCK_ANY]);
85}

◆ testLaunchUrlWithFragmentNoQueryParameter

- (void) testLaunchUrlWithFragmentNoQueryParameter
implementation

Definition at line 24 of file FlutterAppDelegateTest.mm.

113 {
114 OCMStub([self.mockMainBundle objectForInfoDictionaryKey:@"FlutterDeepLinkingEnabled"])
115 .andReturn(@YES);
116
117 BOOL result =
118 [self.appDelegate application:[UIApplication sharedApplication]
119 openURL:[NSURL URLWithString:@"http://myApp/custom/route#fragment"]
120 options:@{}];
121 XCTAssertTrue(result);
122 OCMVerify([self.mockNavigationChannel
123 invokeMethod:@"pushRouteInformation"
124 arguments:@{@"location" : @"http://myApp/custom/route#fragment"}]);
125}

◆ testLaunchUrlWithQueryParameterAndFragment

- (void) testLaunchUrlWithQueryParameterAndFragment
implementation

Definition at line 24 of file FlutterAppDelegateTest.mm.

99 {
100 OCMStub([self.mockMainBundle objectForInfoDictionaryKey:@"FlutterDeepLinkingEnabled"])
101 .andReturn(@YES);
102
103 BOOL result = [self.appDelegate
104 application:[UIApplication sharedApplication]
105 openURL:[NSURL URLWithString:@"http://myApp/custom/route?query=test#fragment"]
106 options:@{}];
107 XCTAssertTrue(result);
108 OCMVerify([self.mockNavigationChannel
109 invokeMethod:@"pushRouteInformation"
110 arguments:@{@"location" : @"http://myApp/custom/route?query=test#fragment"}]);
111}

◆ testReleasesWindowOnDealloc

- (void) testReleasesWindowOnDealloc
implementation

Definition at line 24 of file FlutterAppDelegateTest.mm.

127 {
128 __weak UIWindow* weakWindow;
129 @autoreleasepool {
130 id mockWindow = OCMClassMock([UIWindow class]);
132 appDelegate.window = mockWindow;
133 weakWindow = mockWindow;
134 XCTAssertNotNil(weakWindow);
135 [mockWindow stopMocking];
136 mockWindow = nil;
137 appDelegate = nil;
138 }
139 // App delegate has released the window.
140 XCTAssertNil(weakWindow);
141}
FlutterAppLifeCycleProvider UIWindow * window

◆ testUniversalLinkPushRouteInformation

- (void) testUniversalLinkPushRouteInformation
implementation

Definition at line 24 of file FlutterAppDelegateTest.mm.

145 {
146 OCMStub([self.mockMainBundle objectForInfoDictionaryKey:@"FlutterDeepLinkingEnabled"])
147 .andReturn(@YES);
148
149 NSUserActivity* userActivity = [[NSUserActivity alloc] initWithActivityType:@"com.example.test"];
150 userActivity.webpageURL = [NSURL URLWithString:@"http://myApp/custom/route?query=test"];
151 BOOL result = [self.appDelegate
152 application:[UIApplication sharedApplication]
153 continueUserActivity:userActivity
154 restorationHandler:^(NSArray<id<UIUserActivityRestoring>>* __nullable restorableObjects){
155 }];
156 XCTAssertTrue(result);
157 OCMVerify([self.mockNavigationChannel
158 invokeMethod:@"pushRouteInformation"
159 arguments:@{@"location" : @"http://myApp/custom/route?query=test"}]);
160}

Property Documentation

◆ appDelegate

- (FlutterAppDelegate*) appDelegate
readwriteatomicstrong

Definition at line 17 of file FlutterAppDelegateTest.mm.

◆ mockEngineFirstFrameCallback

- (id) mockEngineFirstFrameCallback
readwriteatomicstrong

Definition at line 24 of file FlutterAppDelegateTest.mm.

◆ mockMainBundle

- (id) mockMainBundle
readwriteatomicstrong

Definition at line 19 of file FlutterAppDelegateTest.mm.

◆ mockNavigationChannel

- (id) mockNavigationChannel
readwriteatomicstrong

Definition at line 20 of file FlutterAppDelegateTest.mm.


The documentation for this class was generated from the following file: