@@ -17,10 +17,48 @@ @interface FlutterPlatformPluginTest : XCTestCase
17
17
18
18
@interface FlutterPlatformPlugin ()
19
19
- (BOOL )isLiveTextInputAvailable ;
20
+ - (void )showLookUpViewController : (NSString *)term ;
21
+ @end
22
+
23
+ @interface UIViewController ()
24
+ - (void )presentViewController : (UIViewController*)viewControllerToPresent
25
+ animated : (BOOL )flag
26
+ completion : (void (^)(void ))completion ;
20
27
@end
21
28
22
29
@implementation FlutterPlatformPluginTest
23
30
31
+ - (void )testLookUpCallInitiated {
32
+ FlutterEngine* engine = [[[FlutterEngine alloc ] initWithName: @" test" project: nil ] autorelease ];
33
+ [engine runWithEntrypoint: nil ];
34
+ std::unique_ptr<fml::WeakPtrFactory<FlutterEngine>> _weakFactory =
35
+ std::make_unique<fml::WeakPtrFactory<FlutterEngine>>(engine);
36
+
37
+ XCTestExpectation* presentExpectation =
38
+ [self expectationWithDescription: @" Look Up view controller presented" ];
39
+
40
+ FlutterViewController* engineViewController = [[FlutterViewController alloc ] initWithEngine: engine
41
+ nibName: nil
42
+ bundle: nil ];
43
+ FlutterViewController* mockEngineViewController = OCMPartialMock (engineViewController);
44
+
45
+ FlutterPlatformPlugin* plugin =
46
+ [[[FlutterPlatformPlugin alloc ] initWithEngine: _weakFactory->GetWeakPtr ()] autorelease ];
47
+ FlutterPlatformPlugin* mockPlugin = OCMPartialMock (plugin);
48
+
49
+ FlutterMethodCall* methodCall = [FlutterMethodCall methodCallWithMethodName: @" LookUp.invoke"
50
+ arguments: @" Test" ];
51
+ FlutterResult result = ^(id result) {
52
+ OCMVerify ([mockEngineViewController
53
+ presentViewController: [OCMArg isKindOfClass: [UIReferenceLibraryViewController class ]]
54
+ animated: YES
55
+ completion: nil ]);
56
+ [presentExpectation fulfill ];
57
+ };
58
+ [mockPlugin handleMethodCall: methodCall result: result];
59
+ [self waitForExpectationsWithTimeout: 2 handler: nil ];
60
+ }
61
+
24
62
- (void )testClipboardHasCorrectStrings {
25
63
[UIPasteboard generalPasteboard ].string = nil ;
26
64
FlutterEngine* engine = [[[FlutterEngine alloc ] initWithName: @" test" project: nil ] autorelease ];
0 commit comments