@@ -19,6 +19,7 @@ @interface FlutterPlatformPlugin ()
19
19
- (BOOL )isLiveTextInputAvailable ;
20
20
- (void )searchWeb : (NSString *)searchTerm ;
21
21
- (void )showLookUpViewController : (NSString *)term ;
22
+ - (void )showShareViewController : (NSString *)content ;
22
23
@end
23
24
24
25
@interface UIViewController ()
@@ -122,6 +123,36 @@ - (void)testLookUpCallInitiated {
122
123
[self waitForExpectationsWithTimeout: 2 handler: nil ];
123
124
}
124
125
126
+ - (void )testShareScreenInvoked {
127
+ FlutterEngine* engine = [[[FlutterEngine alloc ] initWithName: @" test" project: nil ] autorelease ];
128
+ [engine runWithEntrypoint: nil ];
129
+ std::unique_ptr<fml::WeakPtrFactory<FlutterEngine>> _weakFactory =
130
+ std::make_unique<fml::WeakPtrFactory<FlutterEngine>>(engine);
131
+
132
+ XCTestExpectation* presentExpectation =
133
+ [self expectationWithDescription: @" Share view controller presented" ];
134
+
135
+ FlutterViewController* engineViewController =
136
+ [[[FlutterViewController alloc ] initWithEngine: engine nibName: nil bundle: nil ] autorelease ];
137
+ FlutterViewController* mockEngineViewController = OCMPartialMock (engineViewController);
138
+
139
+ FlutterPlatformPlugin* plugin =
140
+ [[[FlutterPlatformPlugin alloc ] initWithEngine: _weakFactory->GetWeakPtr ()] autorelease ];
141
+ FlutterPlatformPlugin* mockPlugin = OCMPartialMock (plugin);
142
+
143
+ FlutterMethodCall* methodCall = [FlutterMethodCall methodCallWithMethodName: @" Share.invoke"
144
+ arguments: @" Test" ];
145
+ FlutterResult result = ^(id result) {
146
+ OCMVerify ([mockEngineViewController
147
+ presentViewController: [OCMArg isKindOfClass: [UIActivityViewController class ]]
148
+ animated: YES
149
+ completion: nil ]);
150
+ [presentExpectation fulfill ];
151
+ };
152
+ [mockPlugin handleMethodCall: methodCall result: result];
153
+ [self waitForExpectationsWithTimeout: 1 handler: nil ];
154
+ }
155
+
125
156
- (void )testClipboardHasCorrectStrings {
126
157
[UIPasteboard generalPasteboard ].string = nil ;
127
158
FlutterEngine* engine = [[[FlutterEngine alloc ] initWithName: @" test" project: nil ] autorelease ];
0 commit comments