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 [
self.appDelegate application:[UIApplication sharedApplication]
67 openURL:[NSURL URLWithString:@"http://myApp/custom/route?query=test"]
69 XCTAssertTrue(result);
71 invokeMethod:
@"pushRouteInformation"
72 arguments:@{
@"location" :
@"http://myApp/custom/route?query=test"}]);
75 - (void)testLaunchUrlWithDeepLinkingNotSet {
76 OCMStub([
self.
mockMainBundle objectForInfoDictionaryKey:
@"FlutterDeepLinkingEnabled"])
80 [
self.appDelegate application:[UIApplication sharedApplication]
81 openURL:[NSURL URLWithString:@"http://myApp/custom/route?query=test"]
83 XCTAssertFalse(result);
87 - (void)testLaunchUrlWithDeepLinkingDisabled {
88 OCMStub([
self.
mockMainBundle objectForInfoDictionaryKey:
@"FlutterDeepLinkingEnabled"])
92 [
self.appDelegate application:[UIApplication sharedApplication]
93 openURL:[NSURL URLWithString:@"http://myApp/custom/route?query=test"]
95 XCTAssertFalse(result);
99 - (void)testLaunchUrlWithQueryParameterAndFragment {
100 OCMStub([
self.
mockMainBundle objectForInfoDictionaryKey:
@"FlutterDeepLinkingEnabled"])
103 BOOL result = [
self.appDelegate
104 application:[UIApplication sharedApplication]
105 openURL:[NSURL URLWithString:@"http://myApp/custom/route?query=test#fragment"]
107 XCTAssertTrue(result);
109 invokeMethod:
@"pushRouteInformation"
110 arguments:@{
@"location" :
@"http://myApp/custom/route?query=test#fragment"}]);
113 - (void)testLaunchUrlWithFragmentNoQueryParameter {
114 OCMStub([
self.
mockMainBundle objectForInfoDictionaryKey:
@"FlutterDeepLinkingEnabled"])
118 [
self.appDelegate application:[UIApplication sharedApplication]
119 openURL:[NSURL URLWithString:@"http://myApp/custom/route#fragment"]
121 XCTAssertTrue(result);
123 invokeMethod:
@"pushRouteInformation"
124 arguments:@{
@"location" :
@"http://myApp/custom/route#fragment"}]);
127 - (void)testReleasesWindowOnDealloc {
128 __weak UIWindow* weakWindow;
130 id mockWindow = OCMClassMock([UIWindow
class]);
133 weakWindow = mockWindow;
134 XCTAssertNotNil(weakWindow);
135 [mockWindow stopMocking];
140 XCTAssertNil(weakWindow);
143 #pragma mark - Deep linking
145 - (void)testUniversalLinkPushRouteInformation {
146 OCMStub([
self.
mockMainBundle objectForInfoDictionaryKey:
@"FlutterDeepLinkingEnabled"])
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){
156 XCTAssertTrue(result);
158 invokeMethod:
@"pushRouteInformation"
159 arguments:@{
@"location" :
@"http://myApp/custom/route?query=test"}]);