15
15
16
16
@interface FlutterAppDelegateTest : XCTestCase
17
17
@property (strong ) FlutterAppDelegate* appDelegate;
18
-
18
+ @property ( strong ) FlutterViewController* viewController;
19
19
@property (strong ) id mockMainBundle;
20
20
@property (strong ) id mockNavigationChannel;
21
21
@@ -37,6 +37,8 @@ - (void)setUp {
37
37
self.appDelegate = appDelegate;
38
38
39
39
FlutterViewController* viewController = OCMClassMock ([FlutterViewController class ]);
40
+ self.viewController = viewController;
41
+
40
42
FlutterMethodChannel* navigationChannel = OCMClassMock ([FlutterMethodChannel class ]);
41
43
self.mockNavigationChannel = navigationChannel;
42
44
@@ -172,4 +174,28 @@ - (void)testUniversalLinkPushRouteInformation {
172
174
OCMVerifyAll (self.mockNavigationChannel );
173
175
}
174
176
177
+ - (void )testUseNonDeprecatedOpenURLAPI {
178
+ OCMStub ([self .mockMainBundle objectForInfoDictionaryKey: @" FlutterDeepLinkingEnabled" ])
179
+ .andReturn (@YES );
180
+ NSUserActivity * userActivity = [[NSUserActivity alloc ] initWithActivityType: @" com.example.test" ];
181
+ userActivity.webpageURL = [NSURL URLWithString: @" http://myApp/custom/route?query=nonexist" ];
182
+ OCMStub ([self .viewController sendDeepLinkToFramework: [OCMArg any ] completionHandler: [OCMArg any ]])
183
+ .andDo (^(NSInvocation * invocation) {
184
+ void (^handler)(BOOL success);
185
+ [invocation getArgument: &handler atIndex: 3 ];
186
+ handler (NO );
187
+ });
188
+ id mockApplication = OCMClassMock ([UIApplication class ]);
189
+ OCMStub ([mockApplication sharedApplication ]).andReturn (mockApplication);
190
+ BOOL result = [self .appDelegate
191
+ application: [UIApplication sharedApplication ]
192
+ continueUserActivity: userActivity
193
+ restorationHandler: ^(NSArray <id <UIUserActivityRestoring>>* __nullable restorableObjects){
194
+ }];
195
+ XCTAssertTrue (result);
196
+ OCMVerify ([mockApplication openURL: [OCMArg any ]
197
+ options: [OCMArg any ]
198
+ completionHandler: [OCMArg any ]]);
199
+ }
200
+
175
201
@end
0 commit comments