Skip to content
This repository was archived by the owner on Feb 22, 2023. It is now read-only.

[quick_actions]Migrate the plugin class to Swift, and remove custom modulemap #6369

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions packages/quick_actions/quick_actions_ios/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
## 1.0.1

* Removes custom modulemap file with "Test" submodule and private headers for Swift migration.
* Migrates `FLTQuickActionsPlugin` class to Swift.

## 1.0.0

* Updates version to 1.0 to reflect current status.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

@import Flutter;
@import quick_actions_ios;
@import quick_actions_ios.Test;
@import XCTest;
#import <OCMock/OCMock.h>

Expand All @@ -26,9 +25,9 @@ - (void)testHandleMethodCall_setShortcutItems {

FLTShortcutStateManager *mockShortcutStateManager = OCMClassMock([FLTShortcutStateManager class]);

FLTQuickActionsPlugin *plugin =
[[FLTQuickActionsPlugin alloc] initWithChannel:OCMClassMock([FlutterMethodChannel class])
shortcutStateManager:mockShortcutStateManager];
QuickActionsPlugin *plugin =
[[QuickActionsPlugin alloc] initWithChannel:OCMClassMock([FlutterMethodChannel class])
shortcutStateManager:mockShortcutStateManager];
XCTestExpectation *resultExpectation =
[self expectationWithDescription:@"result block must be called."];
[plugin handleMethodCall:call
Expand All @@ -45,9 +44,9 @@ - (void)testHandleMethodCall_clearShortcutItems {
FlutterMethodCall *call = [FlutterMethodCall methodCallWithMethodName:@"clearShortcutItems"
arguments:nil];
FLTShortcutStateManager *mockShortcutStateManager = OCMClassMock([FLTShortcutStateManager class]);
FLTQuickActionsPlugin *plugin =
[[FLTQuickActionsPlugin alloc] initWithChannel:OCMClassMock([FlutterMethodChannel class])
shortcutStateManager:mockShortcutStateManager];
QuickActionsPlugin *plugin =
[[QuickActionsPlugin alloc] initWithChannel:OCMClassMock([FlutterMethodChannel class])
shortcutStateManager:mockShortcutStateManager];
XCTestExpectation *resultExpectation =
[self expectationWithDescription:@"result block must be called."];
[plugin handleMethodCall:call
Expand All @@ -63,9 +62,9 @@ - (void)testHandleMethodCall_getLaunchAction {
FlutterMethodCall *call = [FlutterMethodCall methodCallWithMethodName:@"getLaunchAction"
arguments:nil];

FLTQuickActionsPlugin *plugin =
[[FLTQuickActionsPlugin alloc] initWithChannel:OCMClassMock([FlutterMethodChannel class])
shortcutStateManager:OCMClassMock([FLTShortcutStateManager class])];
QuickActionsPlugin *plugin =
[[QuickActionsPlugin alloc] initWithChannel:OCMClassMock([FlutterMethodChannel class])
shortcutStateManager:OCMClassMock([FLTShortcutStateManager class])];
XCTestExpectation *resultExpectation =
[self expectationWithDescription:@"result block must be called."];
[plugin handleMethodCall:call
Expand All @@ -79,9 +78,9 @@ - (void)testHandleMethodCall_getLaunchAction {
- (void)testHandleMethodCall_nonExistMethods {
FlutterMethodCall *call = [FlutterMethodCall methodCallWithMethodName:@"nonExist" arguments:nil];

FLTQuickActionsPlugin *plugin =
[[FLTQuickActionsPlugin alloc] initWithChannel:OCMClassMock([FlutterMethodChannel class])
shortcutStateManager:OCMClassMock([FLTShortcutStateManager class])];
QuickActionsPlugin *plugin =
[[QuickActionsPlugin alloc] initWithChannel:OCMClassMock([FlutterMethodChannel class])
shortcutStateManager:OCMClassMock([FLTShortcutStateManager class])];
XCTestExpectation *resultExpectation =
[self expectationWithDescription:@"result must be called."];
[plugin
Expand All @@ -97,9 +96,9 @@ - (void)testHandleMethodCall_nonExistMethods {

- (void)testApplicationPerformActionForShortcutItem {
id mockChannel = OCMClassMock([FlutterMethodChannel class]);
FLTQuickActionsPlugin *plugin =
[[FLTQuickActionsPlugin alloc] initWithChannel:mockChannel
shortcutStateManager:OCMClassMock([FLTShortcutStateManager class])];
QuickActionsPlugin *plugin =
[[QuickActionsPlugin alloc] initWithChannel:mockChannel
shortcutStateManager:OCMClassMock([FLTShortcutStateManager class])];

UIApplicationShortcutItem *item = [[UIApplicationShortcutItem alloc]
initWithType:@"SearchTheThing"
Expand All @@ -118,9 +117,9 @@ - (void)testApplicationPerformActionForShortcutItem {

- (void)testApplicationDidFinishLaunchingWithOptions_launchWithShortcut {
id mockShortcutStateManager = OCMClassMock([FLTShortcutStateManager class]);
FLTQuickActionsPlugin *plugin =
[[FLTQuickActionsPlugin alloc] initWithChannel:OCMClassMock([FlutterMethodChannel class])
shortcutStateManager:mockShortcutStateManager];
QuickActionsPlugin *plugin =
[[QuickActionsPlugin alloc] initWithChannel:OCMClassMock([FlutterMethodChannel class])
shortcutStateManager:mockShortcutStateManager];

UIApplicationShortcutItem *item = [[UIApplicationShortcutItem alloc]
initWithType:@"SearchTheThing"
Expand All @@ -138,9 +137,9 @@ - (void)testApplicationDidFinishLaunchingWithOptions_launchWithShortcut {
}

- (void)testApplicationDidFinishLaunchingWithOptions_launchWithoutShortcut {
FLTQuickActionsPlugin *plugin =
[[FLTQuickActionsPlugin alloc] initWithChannel:OCMClassMock([FlutterMethodChannel class])
shortcutStateManager:OCMClassMock([FLTShortcutStateManager class])];
QuickActionsPlugin *plugin =
[[QuickActionsPlugin alloc] initWithChannel:OCMClassMock([FlutterMethodChannel class])
shortcutStateManager:OCMClassMock([FLTShortcutStateManager class])];
BOOL launchResult = [plugin application:[UIApplication sharedApplication]
didFinishLaunchingWithOptions:@{}];
XCTAssertTrue(launchResult,
Expand All @@ -150,21 +149,24 @@ - (void)testApplicationDidFinishLaunchingWithOptions_launchWithoutShortcut {
- (void)testApplicationDidBecomeActive_launchWithoutShortcut {
id mockChannel = OCMClassMock([FlutterMethodChannel class]);
id mockShortcutStateManager = OCMClassMock([FLTShortcutStateManager class]);
FLTQuickActionsPlugin *plugin =
[[FLTQuickActionsPlugin alloc] initWithChannel:mockChannel
shortcutStateManager:mockShortcutStateManager];
QuickActionsPlugin *plugin =
[[QuickActionsPlugin alloc] initWithChannel:mockChannel
shortcutStateManager:mockShortcutStateManager];

[plugin application:[UIApplication sharedApplication] didFinishLaunchingWithOptions:@{}];
BOOL launchResult = [plugin application:[UIApplication sharedApplication]
didFinishLaunchingWithOptions:@{}];
XCTAssertTrue(launchResult,
@"didFinishLaunchingWithOptions must return true if not launched from shortcut.");
[plugin applicationDidBecomeActive:[UIApplication sharedApplication]];
OCMVerify(never(), [mockChannel invokeMethod:OCMOCK_ANY arguments:OCMOCK_ANY]);
}

- (void)testApplicationDidBecomeActive_launchWithShortcut {
id mockChannel = OCMClassMock([FlutterMethodChannel class]);
id mockShortcutStateManager = OCMClassMock([FLTShortcutStateManager class]);
FLTQuickActionsPlugin *plugin =
[[FLTQuickActionsPlugin alloc] initWithChannel:mockChannel
shortcutStateManager:mockShortcutStateManager];
QuickActionsPlugin *plugin =
[[QuickActionsPlugin alloc] initWithChannel:mockChannel
shortcutStateManager:mockShortcutStateManager];

UIApplicationShortcutItem *item = [[UIApplicationShortcutItem alloc]
initWithType:@"SearchTheThing"
Expand All @@ -173,19 +175,20 @@ - (void)testApplicationDidBecomeActive_launchWithShortcut {
icon:[UIApplicationShortcutIcon
iconWithTemplateImageName:@"search_the_thing.png"]
userInfo:nil];
[plugin application:[UIApplication sharedApplication]
didFinishLaunchingWithOptions:@{UIApplicationLaunchOptionsShortcutItemKey : item}];

BOOL launchResult = [plugin application:[UIApplication sharedApplication]
didFinishLaunchingWithOptions:@{UIApplicationLaunchOptionsShortcutItemKey : item}];
XCTAssertFalse(launchResult,
@"didFinishLaunchingWithOptions must return false if launched from shortcut.");
[plugin applicationDidBecomeActive:[UIApplication sharedApplication]];
OCMVerify([mockChannel invokeMethod:@"launch" arguments:item.type]);
}

- (void)testApplicationDidBecomeActive_launchWithShortcut_becomeActiveTwice {
id mockChannel = OCMClassMock([FlutterMethodChannel class]);
id mockShortcutStateManager = OCMClassMock([FLTShortcutStateManager class]);
FLTQuickActionsPlugin *plugin =
[[FLTQuickActionsPlugin alloc] initWithChannel:mockChannel
shortcutStateManager:mockShortcutStateManager];
QuickActionsPlugin *plugin =
[[QuickActionsPlugin alloc] initWithChannel:mockChannel
shortcutStateManager:mockShortcutStateManager];

UIApplicationShortcutItem *item = [[UIApplicationShortcutItem alloc]
initWithType:@"SearchTheThing"
Expand All @@ -194,9 +197,10 @@ - (void)testApplicationDidBecomeActive_launchWithShortcut_becomeActiveTwice {
icon:[UIApplicationShortcutIcon
iconWithTemplateImageName:@"search_the_thing.png"]
userInfo:nil];
[plugin application:[UIApplication sharedApplication]
didFinishLaunchingWithOptions:@{UIApplicationLaunchOptionsShortcutItemKey : item}];

BOOL launchResult = [plugin application:[UIApplication sharedApplication]
didFinishLaunchingWithOptions:@{UIApplicationLaunchOptionsShortcutItemKey : item}];
XCTAssertFalse(launchResult,
@"didFinishLaunchingWithOptions must return false if launched from shortcut.");
[plugin applicationDidBecomeActive:[UIApplication sharedApplication]];
[plugin applicationDidBecomeActive:[UIApplication sharedApplication]];
// shortcut should only be handled once per launch.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
// found in the LICENSE file.

@import quick_actions_ios;
@import quick_actions_ios.Test;
@import XCTest;
#import <OCMock/OCMock.h>

Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

Loading