@@ -2305,26 +2305,22 @@ - (void)testInitialActiveViewCantAccessTextInputDelegate {
2305
2305
XCTAssertNil (textInputPlugin.activeView .textInputDelegate );
2306
2306
}
2307
2307
2308
- - (void )testInputHiderIsInitiallyOffScreen {
2309
- FlutterTextInputPlugin* myInputPlugin =
2310
- [[FlutterTextInputPlugin alloc ] initWithDelegate: OCMClassMock ([FlutterEngine class ])];
2311
-
2312
- FlutterMethodCall* setClientCall =
2313
- [FlutterMethodCall methodCallWithMethodName: @" TextInput.setClient"
2314
- arguments: @[ @(123 ), self .mutableTemplateCopy ]];
2315
- [myInputPlugin handleMethodCall: setClientCall
2316
- result: ^(id _Nullable result){
2317
- }];
2318
-
2319
- CGRect offScreenRect = {{0 , -2000 }, {0 , 0 }};
2320
-
2321
- XCTAssert (CGRectEqualToRect (myInputPlugin.inputHider .frame , offScreenRect),
2322
- @" The initial input hider should be offScreen." );
2323
- }
2324
-
2325
2308
- (void )testInputHiderIsOffScreenWhenScribbleIsDisabled {
2326
2309
FlutterTextInputPlugin* myInputPlugin =
2327
2310
[[FlutterTextInputPlugin alloc ] initWithDelegate: OCMClassMock ([FlutterEngine class ])];
2311
+ myInputPlugin.viewController = viewController;
2312
+
2313
+ NSSet <UIScene*>* scenes = UIApplication.sharedApplication .connectedScenes ;
2314
+ XCTAssertEqual (scenes.count , 1UL , @" There must only be 1 scene for test" );
2315
+ UIScene* scene = scenes.anyObject ;
2316
+ XCTAssert ([scene isKindOfClass: [UIWindowScene class ]], @" Must be a window scene for test" );
2317
+ UIWindowScene* windowScene = (UIWindowScene*)scene;
2318
+ XCTAssert (windowScene.windows .count > 0 , @" There must be at least 1 window for test" );
2319
+ UIWindow* window = windowScene.windows [0 ];
2320
+ [window addSubview: viewController.view];
2321
+ [viewController loadView ];
2322
+ UIScreen* screen = viewController.flutterScreenIfViewLoaded ;
2323
+ XCTAssertNotNil (screen, @" Screen must be present at this point" );
2328
2324
2329
2325
FlutterMethodCall* setClientCall =
2330
2326
[FlutterMethodCall methodCallWithMethodName: @" TextInput.setClient"
@@ -2333,8 +2329,6 @@ - (void)testInputHiderIsOffScreenWhenScribbleIsDisabled {
2333
2329
result: ^(id _Nullable result){
2334
2330
}];
2335
2331
2336
- CGRect offScreenRect = {{0 , -2000 }, {0 , 0 }};
2337
-
2338
2332
FlutterTextInputView* mockInputView = OCMPartialMock (myInputPlugin.activeView );
2339
2333
OCMStub ([mockInputView isScribbleAvailable ]).andReturn (NO );
2340
2334
@@ -2348,6 +2342,7 @@ - (void)testInputHiderIsOffScreenWhenScribbleIsDisabled {
2348
2342
result: ^(id _Nullable result){
2349
2343
}];
2350
2344
2345
+ CGRect offScreenRect = CGRectMake (0 , -screen.bounds .size .height , 0 , 0 );
2351
2346
XCTAssert (CGRectEqualToRect (myInputPlugin.inputHider .frame , offScreenRect),
2352
2347
@" The input hider should stay offScreen if scribble is disabled." );
2353
2348
}
0 commit comments