@@ -387,6 +387,148 @@ - (bool)testClearClientDuringComposing {
387
387
return true ;
388
388
}
389
389
390
+ - (bool )testAutocompleteEnabledByDefault {
391
+ // Set up FlutterTextInputPlugin.
392
+ id engineMock = flutter::testing::CreateMockFlutterEngine (@" " );
393
+ id binaryMessengerMock = OCMProtocolMock (@protocol (FlutterBinaryMessenger));
394
+ OCMStub ( // NOLINT(google-objc-avoid-throwing-exception)
395
+ [engineMock binaryMessenger ])
396
+ .andReturn (binaryMessengerMock);
397
+ FlutterViewController* viewController = [[FlutterViewController alloc ] initWithEngine: engineMock
398
+ nibName: @" "
399
+ bundle: nil ];
400
+ FlutterTextInputPlugin* plugin =
401
+ [[FlutterTextInputPlugin alloc ] initWithViewController: viewController];
402
+
403
+ // Set input client 1.
404
+ [plugin handleMethodCall: [FlutterMethodCall
405
+ methodCallWithMethodName: @" TextInput.setClient"
406
+ arguments: @[
407
+ @(1 ), @{
408
+ @" inputAction" : @" action" ,
409
+ @" inputType" : @{@" name" : @" inputName" },
410
+ }
411
+ ]]
412
+ result: ^(id ){
413
+ }];
414
+
415
+ // Verify autocomplete is enabled.
416
+ EXPECT_TRUE ([plugin isAutomaticTextCompletionEnabled ]);
417
+ return true ;
418
+ }
419
+
420
+ - (bool )testAutocompleteDisabledWhenObscureTextIsSet {
421
+ // Set up FlutterTextInputPlugin.
422
+ id engineMock = flutter::testing::CreateMockFlutterEngine (@" " );
423
+ id binaryMessengerMock = OCMProtocolMock (@protocol (FlutterBinaryMessenger));
424
+ OCMStub ( // NOLINT(google-objc-avoid-throwing-exception)
425
+ [engineMock binaryMessenger ])
426
+ .andReturn (binaryMessengerMock);
427
+ FlutterViewController* viewController = [[FlutterViewController alloc ] initWithEngine: engineMock
428
+ nibName: @" "
429
+ bundle: nil ];
430
+ FlutterTextInputPlugin* plugin =
431
+ [[FlutterTextInputPlugin alloc ] initWithViewController: viewController];
432
+
433
+ // Set input client 1.
434
+ [plugin handleMethodCall: [FlutterMethodCall
435
+ methodCallWithMethodName: @" TextInput.setClient"
436
+ arguments: @[
437
+ @(1 ), @{
438
+ @" inputAction" : @" action" ,
439
+ @" inputType" : @{@" name" : @" inputName" },
440
+ @" obscureText" : @YES ,
441
+ }
442
+ ]]
443
+ result: ^(id ){
444
+ }];
445
+
446
+ // Verify autocomplete is disabled.
447
+ EXPECT_FALSE ([plugin isAutomaticTextCompletionEnabled ]);
448
+ return true ;
449
+ }
450
+
451
+ - (bool )testAutocompleteDisabledWhenAutofillEmpty {
452
+ // Set up FlutterTextInputPlugin.
453
+ id engineMock = flutter::testing::CreateMockFlutterEngine (@" " );
454
+ id binaryMessengerMock = OCMProtocolMock (@protocol (FlutterBinaryMessenger));
455
+ OCMStub ( // NOLINT(google-objc-avoid-throwing-exception)
456
+ [engineMock binaryMessenger ])
457
+ .andReturn (binaryMessengerMock);
458
+ FlutterViewController* viewController = [[FlutterViewController alloc ] initWithEngine: engineMock
459
+ nibName: @" "
460
+ bundle: nil ];
461
+ FlutterTextInputPlugin* plugin =
462
+ [[FlutterTextInputPlugin alloc ] initWithViewController: viewController];
463
+
464
+ // Set input client 1.
465
+ [plugin handleMethodCall: [FlutterMethodCall
466
+ methodCallWithMethodName: @" TextInput.setClient"
467
+ arguments: @[
468
+ @(1 ), @{
469
+ @" inputAction" : @" action" ,
470
+ @" inputType" : @{@" name" : @" inputName" },
471
+ @" autofill" : @{@" hints" : @[ @" " ]},
472
+ }
473
+ ]]
474
+ result: ^(id ){
475
+ }];
476
+
477
+ // Verify autocomplete is disabled.
478
+ EXPECT_FALSE ([plugin isAutomaticTextCompletionEnabled ]);
479
+ return true ;
480
+ }
481
+
482
+ - (bool )testAutocompleteDisabledWhenAutofillGroupIncludesPassword {
483
+ // Set up FlutterTextInputPlugin.
484
+ id engineMock = flutter::testing::CreateMockFlutterEngine (@" " );
485
+ id binaryMessengerMock = OCMProtocolMock (@protocol (FlutterBinaryMessenger));
486
+ OCMStub ( // NOLINT(google-objc-avoid-throwing-exception)
487
+ [engineMock binaryMessenger ])
488
+ .andReturn (binaryMessengerMock);
489
+ FlutterViewController* viewController = [[FlutterViewController alloc ] initWithEngine: engineMock
490
+ nibName: @" "
491
+ bundle: nil ];
492
+ FlutterTextInputPlugin* plugin =
493
+ [[FlutterTextInputPlugin alloc ] initWithViewController: viewController];
494
+
495
+ // Set input client 1.
496
+ [plugin handleMethodCall: [FlutterMethodCall
497
+ methodCallWithMethodName: @" TextInput.setClient"
498
+ arguments: @[
499
+ @(1 ), @{
500
+ @" inputAction" : @" action" ,
501
+ @" inputType" : @{@" name" : @" inputName" },
502
+ @" fields" : @[
503
+ @{
504
+ @" inputAction" : @" action" ,
505
+ @" inputType" : @{@" name" : @" inputName" },
506
+ @" autofill" : @{
507
+ @" uniqueIdentifier" : @" field1" ,
508
+ @" hints" : @[ @" password" ],
509
+ @" editingValue" : @{@" text" : @" " },
510
+ }
511
+ },
512
+ @{
513
+ @" inputAction" : @" action" ,
514
+ @" inputType" : @{@" name" : @" inputName" },
515
+ @" autofill" : @{
516
+ @" uniqueIdentifier" : @" field2" ,
517
+ @" hints" : @[ @" name" ],
518
+ @" editingValue" : @{@" text" : @" " },
519
+ }
520
+ }
521
+ ]
522
+ }
523
+ ]]
524
+ result: ^(id ){
525
+ }];
526
+
527
+ // Verify autocomplete is disabled.
528
+ EXPECT_FALSE ([plugin isAutomaticTextCompletionEnabled ]);
529
+ return true ;
530
+ }
531
+
390
532
- (bool )testFirstRectForCharacterRange {
391
533
id engineMock = flutter::testing::CreateMockFlutterEngine (@" " );
392
534
id binaryMessengerMock = OCMProtocolMock (@protocol (FlutterBinaryMessenger));
@@ -1354,6 +1496,23 @@ - (bool)testSelectorsAreForwardedToFramework {
1354
1496
ASSERT_TRUE ([[FlutterInputPluginTestObjc alloc ] testClearClientDuringComposing ]);
1355
1497
}
1356
1498
1499
+ TEST (FlutterTextInputPluginTest, TestAutocompleteEnabledByDefault) {
1500
+ ASSERT_TRUE ([[FlutterInputPluginTestObjc alloc ] testAutocompleteEnabledByDefault ]);
1501
+ }
1502
+
1503
+ TEST (FlutterTextInputPluginTest, TestAutocompleteDisabledWhenObscureTextIsSet) {
1504
+ ASSERT_TRUE ([[FlutterInputPluginTestObjc alloc ] testAutocompleteDisabledWhenObscureTextIsSet ]);
1505
+ }
1506
+
1507
+ TEST (FlutterTextInputPluginTest, TestAutocompleteDisabledWhenAutofillEmpty) {
1508
+ ASSERT_TRUE ([[FlutterInputPluginTestObjc alloc ] testAutocompleteDisabledWhenAutofillEmpty ]);
1509
+ }
1510
+
1511
+ TEST (FlutterTextInputPluginTest, TestAutocompleteDisabledWhenAutofillGroupIncludesPassword) {
1512
+ ASSERT_TRUE ([[FlutterInputPluginTestObjc alloc ]
1513
+ testAutocompleteDisabledWhenAutofillGroupIncludesPassword ]);
1514
+ }
1515
+
1357
1516
TEST (FlutterTextInputPluginTest, TestFirstRectForCharacterRange) {
1358
1517
ASSERT_TRUE ([[FlutterInputPluginTestObjc alloc ] testFirstRectForCharacterRange ]);
1359
1518
}
0 commit comments