5 #import <OCMock/OCMock.h>
6 #import <XCTest/XCTest.h>
41 self.mockNavigationChannel = navigationChannel;
44 OCMStub([
engine navigationChannel]).andReturn(navigationChannel);
57 [
self.mockMainBundle stopMocking];
61 - (void)testLaunchUrl {
62 OCMStub([
self.
mockMainBundle objectForInfoDictionaryKey:
@"FlutterDeepLinkingEnabled"])
66 invokeMethod:
@"pushRouteInformation"
67 arguments:@{
@"location" :
@"http://myApp/custom/route?query=test"}])
71 [
self.appDelegate application:[UIApplication sharedApplication]
72 openURL:[NSURL URLWithString:@"http://myApp/custom/route?query=test"]
75 XCTAssertTrue(result);
79 - (void)testLaunchUrlWithDeepLinkingNotSet {
80 OCMStub([
self.
mockMainBundle objectForInfoDictionaryKey:
@"FlutterDeepLinkingEnabled"])
84 [
self.appDelegate application:[UIApplication sharedApplication]
85 openURL:[NSURL URLWithString:@"http://myApp/custom/route?query=test"]
87 XCTAssertFalse(result);
91 - (void)testLaunchUrlWithDeepLinkingDisabled {
92 OCMStub([
self.
mockMainBundle objectForInfoDictionaryKey:
@"FlutterDeepLinkingEnabled"])
96 [
self.appDelegate application:[UIApplication sharedApplication]
97 openURL:[NSURL URLWithString:@"http://myApp/custom/route?query=test"]
99 XCTAssertFalse(result);
103 - (void)testLaunchUrlWithQueryParameterAndFragment {
104 OCMStub([
self.
mockMainBundle objectForInfoDictionaryKey:
@"FlutterDeepLinkingEnabled"])
107 invokeMethod:
@"pushRouteInformation"
108 arguments:@{
@"location" :
@"http://myApp/custom/route?query=test#fragment"}])
110 BOOL result = [
self.appDelegate
111 application:[UIApplication sharedApplication]
112 openURL:[NSURL URLWithString:@"http://myApp/custom/route?query=test#fragment"]
114 XCTAssertTrue(result);
118 - (void)testLaunchUrlWithFragmentNoQueryParameter {
119 OCMStub([
self.
mockMainBundle objectForInfoDictionaryKey:
@"FlutterDeepLinkingEnabled"])
122 invokeMethod:
@"pushRouteInformation"
123 arguments:@{
@"location" :
@"http://myApp/custom/route#fragment"}])
126 [
self.appDelegate application:[UIApplication sharedApplication]
127 openURL:[NSURL URLWithString:@"http://myApp/custom/route#fragment"]
129 XCTAssertTrue(result);
133 - (void)testReleasesWindowOnDealloc {
134 __weak UIWindow* weakWindow;
136 id mockWindow = OCMClassMock([UIWindow
class]);
139 weakWindow = mockWindow;
140 XCTAssertNotNil(weakWindow);
141 [mockWindow stopMocking];
146 XCTAssertNil(weakWindow);
149 #pragma mark - Deep linking
151 - (void)testUniversalLinkPushRouteInformation {
152 OCMStub([
self.
mockMainBundle objectForInfoDictionaryKey:
@"FlutterDeepLinkingEnabled"])
155 invokeMethod:
@"pushRouteInformation"
156 arguments:@{
@"location" :
@"http://myApp/custom/route?query=test"}])
158 NSUserActivity* userActivity = [[NSUserActivity alloc] initWithActivityType:@"com.example.test"];
159 userActivity.webpageURL = [NSURL URLWithString:@"http://myApp/custom/route?query=test"];
160 BOOL result = [
self.appDelegate
161 application:[UIApplication sharedApplication]
162 continueUserActivity:userActivity
163 restorationHandler:^(NSArray<id<UIUserActivityRestoring>>* __nullable restorableObjects){
165 XCTAssertTrue(result);