44
55@import Flutter;
66@import quick_actions_ios;
7- @import quick_actions_ios.Test;
87@import XCTest;
98#import < OCMock/OCMock.h>
109
@@ -26,9 +25,9 @@ - (void)testHandleMethodCall_setShortcutItems {
2625
2726 FLTShortcutStateManager *mockShortcutStateManager = OCMClassMock ([FLTShortcutStateManager class ]);
2827
29- FLTQuickActionsPlugin *plugin =
30- [[FLTQuickActionsPlugin alloc ] initWithChannel: OCMClassMock ([FlutterMethodChannel class ])
31- shortcutStateManager: mockShortcutStateManager];
28+ QuickActionsPlugin *plugin =
29+ [[QuickActionsPlugin alloc ] initWithChannel: OCMClassMock ([FlutterMethodChannel class ])
30+ shortcutStateManager: mockShortcutStateManager];
3231 XCTestExpectation *resultExpectation =
3332 [self expectationWithDescription: @" result block must be called." ];
3433 [plugin handleMethodCall: call
@@ -45,9 +44,9 @@ - (void)testHandleMethodCall_clearShortcutItems {
4544 FlutterMethodCall *call = [FlutterMethodCall methodCallWithMethodName: @" clearShortcutItems"
4645 arguments: nil ];
4746 FLTShortcutStateManager *mockShortcutStateManager = OCMClassMock ([FLTShortcutStateManager class ]);
48- FLTQuickActionsPlugin *plugin =
49- [[FLTQuickActionsPlugin alloc ] initWithChannel: OCMClassMock ([FlutterMethodChannel class ])
50- shortcutStateManager: mockShortcutStateManager];
47+ QuickActionsPlugin *plugin =
48+ [[QuickActionsPlugin alloc ] initWithChannel: OCMClassMock ([FlutterMethodChannel class ])
49+ shortcutStateManager: mockShortcutStateManager];
5150 XCTestExpectation *resultExpectation =
5251 [self expectationWithDescription: @" result block must be called." ];
5352 [plugin handleMethodCall: call
@@ -63,9 +62,9 @@ - (void)testHandleMethodCall_getLaunchAction {
6362 FlutterMethodCall *call = [FlutterMethodCall methodCallWithMethodName: @" getLaunchAction"
6463 arguments: nil ];
6564
66- FLTQuickActionsPlugin *plugin =
67- [[FLTQuickActionsPlugin alloc ] initWithChannel: OCMClassMock ([FlutterMethodChannel class ])
68- shortcutStateManager: OCMClassMock ([FLTShortcutStateManager class ])];
65+ QuickActionsPlugin *plugin =
66+ [[QuickActionsPlugin alloc ] initWithChannel: OCMClassMock ([FlutterMethodChannel class ])
67+ shortcutStateManager: OCMClassMock ([FLTShortcutStateManager class ])];
6968 XCTestExpectation *resultExpectation =
7069 [self expectationWithDescription: @" result block must be called." ];
7170 [plugin handleMethodCall: call
@@ -79,9 +78,9 @@ - (void)testHandleMethodCall_getLaunchAction {
7978- (void )testHandleMethodCall_nonExistMethods {
8079 FlutterMethodCall *call = [FlutterMethodCall methodCallWithMethodName: @" nonExist" arguments: nil ];
8180
82- FLTQuickActionsPlugin *plugin =
83- [[FLTQuickActionsPlugin alloc ] initWithChannel: OCMClassMock ([FlutterMethodChannel class ])
84- shortcutStateManager: OCMClassMock ([FLTShortcutStateManager class ])];
81+ QuickActionsPlugin *plugin =
82+ [[QuickActionsPlugin alloc ] initWithChannel: OCMClassMock ([FlutterMethodChannel class ])
83+ shortcutStateManager: OCMClassMock ([FLTShortcutStateManager class ])];
8584 XCTestExpectation *resultExpectation =
8685 [self expectationWithDescription: @" result must be called." ];
8786 [plugin
@@ -97,9 +96,9 @@ - (void)testHandleMethodCall_nonExistMethods {
9796
9897- (void )testApplicationPerformActionForShortcutItem {
9998 id mockChannel = OCMClassMock ([FlutterMethodChannel class ]);
100- FLTQuickActionsPlugin *plugin =
101- [[FLTQuickActionsPlugin alloc ] initWithChannel: mockChannel
102- shortcutStateManager: OCMClassMock ([FLTShortcutStateManager class ])];
99+ QuickActionsPlugin *plugin =
100+ [[QuickActionsPlugin alloc ] initWithChannel: mockChannel
101+ shortcutStateManager: OCMClassMock ([FLTShortcutStateManager class ])];
103102
104103 UIApplicationShortcutItem *item = [[UIApplicationShortcutItem alloc ]
105104 initWithType: @" SearchTheThing"
@@ -118,9 +117,9 @@ - (void)testApplicationPerformActionForShortcutItem {
118117
119118- (void )testApplicationDidFinishLaunchingWithOptions_launchWithShortcut {
120119 id mockShortcutStateManager = OCMClassMock ([FLTShortcutStateManager class ]);
121- FLTQuickActionsPlugin *plugin =
122- [[FLTQuickActionsPlugin alloc ] initWithChannel: OCMClassMock ([FlutterMethodChannel class ])
123- shortcutStateManager: mockShortcutStateManager];
120+ QuickActionsPlugin *plugin =
121+ [[QuickActionsPlugin alloc ] initWithChannel: OCMClassMock ([FlutterMethodChannel class ])
122+ shortcutStateManager: mockShortcutStateManager];
124123
125124 UIApplicationShortcutItem *item = [[UIApplicationShortcutItem alloc ]
126125 initWithType: @" SearchTheThing"
@@ -138,9 +137,9 @@ - (void)testApplicationDidFinishLaunchingWithOptions_launchWithShortcut {
138137}
139138
140139- (void )testApplicationDidFinishLaunchingWithOptions_launchWithoutShortcut {
141- FLTQuickActionsPlugin *plugin =
142- [[FLTQuickActionsPlugin alloc ] initWithChannel: OCMClassMock ([FlutterMethodChannel class ])
143- shortcutStateManager: OCMClassMock ([FLTShortcutStateManager class ])];
140+ QuickActionsPlugin *plugin =
141+ [[QuickActionsPlugin alloc ] initWithChannel: OCMClassMock ([FlutterMethodChannel class ])
142+ shortcutStateManager: OCMClassMock ([FLTShortcutStateManager class ])];
144143 BOOL launchResult = [plugin application: [UIApplication sharedApplication ]
145144 didFinishLaunchingWithOptions: @{}];
146145 XCTAssertTrue (launchResult,
@@ -150,21 +149,24 @@ - (void)testApplicationDidFinishLaunchingWithOptions_launchWithoutShortcut {
150149- (void )testApplicationDidBecomeActive_launchWithoutShortcut {
151150 id mockChannel = OCMClassMock ([FlutterMethodChannel class ]);
152151 id mockShortcutStateManager = OCMClassMock ([FLTShortcutStateManager class ]);
153- FLTQuickActionsPlugin *plugin =
154- [[FLTQuickActionsPlugin alloc ] initWithChannel: mockChannel
155- shortcutStateManager: mockShortcutStateManager];
152+ QuickActionsPlugin *plugin =
153+ [[QuickActionsPlugin alloc ] initWithChannel: mockChannel
154+ shortcutStateManager: mockShortcutStateManager];
156155
157- [plugin application: [UIApplication sharedApplication ] didFinishLaunchingWithOptions: @{}];
156+ BOOL launchResult = [plugin application: [UIApplication sharedApplication ]
157+ didFinishLaunchingWithOptions: @{}];
158+ XCTAssertTrue (launchResult,
159+ @" didFinishLaunchingWithOptions must return true if not launched from shortcut." );
158160 [plugin applicationDidBecomeActive: [UIApplication sharedApplication ]];
159161 OCMVerify (never (), [mockChannel invokeMethod: OCMOCK_ANY arguments: OCMOCK_ANY]);
160162}
161163
162164- (void )testApplicationDidBecomeActive_launchWithShortcut {
163165 id mockChannel = OCMClassMock ([FlutterMethodChannel class ]);
164166 id mockShortcutStateManager = OCMClassMock ([FLTShortcutStateManager class ]);
165- FLTQuickActionsPlugin *plugin =
166- [[FLTQuickActionsPlugin alloc ] initWithChannel: mockChannel
167- shortcutStateManager: mockShortcutStateManager];
167+ QuickActionsPlugin *plugin =
168+ [[QuickActionsPlugin alloc ] initWithChannel: mockChannel
169+ shortcutStateManager: mockShortcutStateManager];
168170
169171 UIApplicationShortcutItem *item = [[UIApplicationShortcutItem alloc ]
170172 initWithType: @" SearchTheThing"
@@ -173,19 +175,20 @@ - (void)testApplicationDidBecomeActive_launchWithShortcut {
173175 icon: [UIApplicationShortcutIcon
174176 iconWithTemplateImageName: @" search_the_thing.png" ]
175177 userInfo: nil ];
176- [plugin application: [UIApplication sharedApplication ]
177- didFinishLaunchingWithOptions: @{UIApplicationLaunchOptionsShortcutItemKey : item}];
178-
178+ BOOL launchResult = [plugin application: [UIApplication sharedApplication ]
179+ didFinishLaunchingWithOptions: @{UIApplicationLaunchOptionsShortcutItemKey : item}];
180+ XCTAssertFalse (launchResult,
181+ @" didFinishLaunchingWithOptions must return false if launched from shortcut." );
179182 [plugin applicationDidBecomeActive: [UIApplication sharedApplication ]];
180183 OCMVerify ([mockChannel invokeMethod: @" launch" arguments: item.type]);
181184}
182185
183186- (void )testApplicationDidBecomeActive_launchWithShortcut_becomeActiveTwice {
184187 id mockChannel = OCMClassMock ([FlutterMethodChannel class ]);
185188 id mockShortcutStateManager = OCMClassMock ([FLTShortcutStateManager class ]);
186- FLTQuickActionsPlugin *plugin =
187- [[FLTQuickActionsPlugin alloc ] initWithChannel: mockChannel
188- shortcutStateManager: mockShortcutStateManager];
189+ QuickActionsPlugin *plugin =
190+ [[QuickActionsPlugin alloc ] initWithChannel: mockChannel
191+ shortcutStateManager: mockShortcutStateManager];
189192
190193 UIApplicationShortcutItem *item = [[UIApplicationShortcutItem alloc ]
191194 initWithType: @" SearchTheThing"
@@ -194,9 +197,10 @@ - (void)testApplicationDidBecomeActive_launchWithShortcut_becomeActiveTwice {
194197 icon: [UIApplicationShortcutIcon
195198 iconWithTemplateImageName: @" search_the_thing.png" ]
196199 userInfo: nil ];
197- [plugin application: [UIApplication sharedApplication ]
198- didFinishLaunchingWithOptions: @{UIApplicationLaunchOptionsShortcutItemKey : item}];
199-
200+ BOOL launchResult = [plugin application: [UIApplication sharedApplication ]
201+ didFinishLaunchingWithOptions: @{UIApplicationLaunchOptionsShortcutItemKey : item}];
202+ XCTAssertFalse (launchResult,
203+ @" didFinishLaunchingWithOptions must return false if launched from shortcut." );
200204 [plugin applicationDidBecomeActive: [UIApplication sharedApplication ]];
201205 [plugin applicationDidBecomeActive: [UIApplication sharedApplication ]];
202206 // shortcut should only be handled once per launch.
0 commit comments