@@ -60,6 +60,7 @@ - (bool)testClearClientDuringComposing;
60
60
@interface FlutterTextInputPluginTestDelegate : NSObject <FlutterTextInputPluginDelegate> {
61
61
id <FlutterBinaryMessenger> _binaryMessenger;
62
62
FlutterViewController* _viewController;
63
+ FlutterViewController* _implicitViewController;
63
64
}
64
65
65
66
@end
@@ -80,10 +81,22 @@ - (instancetype)initWithBinaryMessenger:(id<FlutterBinaryMessenger>)messenger
80
81
return self;
81
82
}
82
83
84
+ - (instancetype )initWithBinaryMessenger : (id <FlutterBinaryMessenger>)messenger
85
+ implicitViewController : (FlutterViewController*)viewController {
86
+ self = [super init ];
87
+ if (self) {
88
+ _binaryMessenger = messenger;
89
+ _implicitViewController = viewController;
90
+ }
91
+ return self;
92
+ }
93
+
83
94
- (nullable FlutterViewController*)viewControllerForIdentifier :
84
95
(FlutterViewIdentifier)viewIdentifier {
85
96
if (viewIdentifier == kViewId ) {
86
97
return _viewController;
98
+ } else if (viewIdentifier == flutter::kFlutterImplicitViewId ) {
99
+ return _implicitViewController;
87
100
} else {
88
101
return nil ;
89
102
}
@@ -2394,4 +2407,32 @@ - (bool)testSelectorsNotForwardedToFrameworkIfNoClient {
2394
2407
ASSERT_TRUE (plugin.clipsToBounds );
2395
2408
}
2396
2409
2410
+ TEST (FlutterTextInputPluginTest, WorksWithoutViewId) {
2411
+ id engineMock = flutter::testing::CreateMockFlutterEngine (@" " );
2412
+ id binaryMessengerMock = OCMProtocolMock (@protocol (FlutterBinaryMessenger));
2413
+ OCMStub ( // NOLINT(google-objc-avoid-throwing-exception)
2414
+ [engineMock binaryMessenger ])
2415
+ .andReturn (binaryMessengerMock);
2416
+
2417
+ FlutterViewController* viewController = [[FlutterViewController alloc ] initWithEngine: engineMock
2418
+ nibName: @" "
2419
+ bundle: nil ];
2420
+
2421
+ FlutterTextInputPluginTestDelegate* delegate =
2422
+ [[FlutterTextInputPluginTestDelegate alloc ] initWithBinaryMessenger: binaryMessengerMock
2423
+ implicitViewController: viewController];
2424
+
2425
+ FlutterTextInputPlugin* plugin = [[FlutterTextInputPlugin alloc ] initWithDelegate: delegate];
2426
+
2427
+ NSDictionary * setClientConfig = @{
2428
+ // omit viewId
2429
+ };
2430
+ [plugin handleMethodCall: [FlutterMethodCall methodCallWithMethodName: @" TextInput.setClient"
2431
+ arguments: @[ @(1 ), setClientConfig ]]
2432
+ result: ^(id ){
2433
+ }];
2434
+
2435
+ ASSERT_TRUE (plugin.currentViewController == viewController);
2436
+ }
2437
+
2397
2438
} // namespace flutter::testing
0 commit comments