@@ -19,6 +19,7 @@ @interface FlutterPlatformPlugin ()
1919- (BOOL )isLiveTextInputAvailable ;
2020- (void )searchWeb : (NSString *)searchTerm ;
2121- (void )showLookUpViewController : (NSString *)term ;
22+ - (void )showShareViewController : (NSString *)content ;
2223@end
2324
2425@interface UIViewController ()
@@ -83,6 +84,37 @@ - (void)testLookUpCallInitiated {
8384 [self waitForExpectationsWithTimeout: 2 handler: nil ];
8485}
8586
87+ - (void )testShareScreenInvoked {
88+ FlutterEngine* engine = [[[FlutterEngine alloc ] initWithName: @" test" project: nil ] autorelease ];
89+ [engine runWithEntrypoint: nil ];
90+ std::unique_ptr<fml::WeakPtrFactory<FlutterEngine>> _weakFactory =
91+ std::make_unique<fml::WeakPtrFactory<FlutterEngine>>(engine);
92+
93+ XCTestExpectation* presentExpectation =
94+ [self expectationWithDescription: @" Share view controller presented" ];
95+
96+ FlutterViewController* engineViewController =
97+ [[[FlutterViewController alloc ] initWithEngine: engine nibName: nil bundle: nil ] autorelease ];
98+ FlutterViewController* mockEngineViewController = OCMPartialMock (engineViewController);
99+
100+ FlutterPlatformPlugin* plugin =
101+ [[[FlutterPlatformPlugin alloc ] initWithEngine: _weakFactory->GetWeakPtr ()] autorelease ];
102+ FlutterPlatformPlugin* mockPlugin = OCMPartialMock (plugin);
103+
104+ FlutterMethodCall* methodCall = [FlutterMethodCall methodCallWithMethodName: @" Share.invoke"
105+ arguments: @" Test" ];
106+ FlutterResult result = ^(id result) {
107+ OCMVerify ([mockPlugin showShareViewController: @" Test" ]);
108+ OCMVerify ([mockEngineViewController
109+ presentViewController: [OCMArg isKindOfClass: [UIActivityViewController class ]]
110+ animated: YES
111+ completion: nil ]);
112+ [presentExpectation fulfill ];
113+ };
114+ [mockPlugin handleMethodCall: methodCall result: result];
115+ [self waitForExpectationsWithTimeout: 1 handler: nil ];
116+ }
117+
86118- (void )testClipboardHasCorrectStrings {
87119 [UIPasteboard generalPasteboard ].string = nil ;
88120 FlutterEngine* engine = [[[FlutterEngine alloc ] initWithName: @" test" project: nil ] autorelease ];
0 commit comments