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 invokeMethod:
@"pushRouteInformation"
85 arguments:@{
@"location" :
@"http://myApp/custom/route?query=test"}])
89 [
self.appDelegate application:[UIApplication sharedApplication]
90 openURL:[NSURL URLWithString:@"http://myApp/custom/route?query=test"]
93 XCTAssertTrue(result);
97 - (void)testLaunchUrlWithDeepLinkingDisabled {
98 OCMStub([
self.
mockMainBundle objectForInfoDictionaryKey:
@"FlutterDeepLinkingEnabled"])
102 [
self.appDelegate application:[UIApplication sharedApplication]
103 openURL:[NSURL URLWithString:@"http://myApp/custom/route?query=test"]
105 XCTAssertFalse(result);
109 - (void)testLaunchUrlWithQueryParameterAndFragment {
110 OCMStub([
self.
mockMainBundle objectForInfoDictionaryKey:
@"FlutterDeepLinkingEnabled"])
113 invokeMethod:
@"pushRouteInformation"
114 arguments:@{
@"location" :
@"http://myApp/custom/route?query=test#fragment"}])
116 BOOL result = [
self.appDelegate
117 application:[UIApplication sharedApplication]
118 openURL:[NSURL URLWithString:@"http://myApp/custom/route?query=test#fragment"]
120 XCTAssertTrue(result);
124 - (void)testLaunchUrlWithFragmentNoQueryParameter {
125 OCMStub([
self.
mockMainBundle objectForInfoDictionaryKey:
@"FlutterDeepLinkingEnabled"])
128 invokeMethod:
@"pushRouteInformation"
129 arguments:@{
@"location" :
@"http://myApp/custom/route#fragment"}])
132 [
self.appDelegate application:[UIApplication sharedApplication]
133 openURL:[NSURL URLWithString:@"http://myApp/custom/route#fragment"]
135 XCTAssertTrue(result);
139 - (void)testReleasesWindowOnDealloc {
140 __weak UIWindow* weakWindow;
142 id mockWindow = OCMClassMock([UIWindow
class]);
145 weakWindow = mockWindow;
146 XCTAssertNotNil(weakWindow);
147 [mockWindow stopMocking];
152 XCTAssertNil(weakWindow);
155 #pragma mark - Deep linking
157 - (void)testUniversalLinkPushRouteInformation {
158 OCMStub([
self.
mockMainBundle objectForInfoDictionaryKey:
@"FlutterDeepLinkingEnabled"])
161 invokeMethod:
@"pushRouteInformation"
162 arguments:@{
@"location" :
@"http://myApp/custom/route?query=test"}])
164 NSUserActivity* userActivity = [[NSUserActivity alloc] initWithActivityType:@"com.example.test"];
165 userActivity.webpageURL = [NSURL URLWithString:@"http://myApp/custom/route?query=test"];
166 BOOL result = [
self.appDelegate
167 application:[UIApplication sharedApplication]
168 continueUserActivity:userActivity
169 restorationHandler:^(NSArray<id<UIUserActivityRestoring>>* __nullable restorableObjects){
171 XCTAssertTrue(result);