@@ -1033,6 +1033,55 @@ void testMain() {
10331033 expect (formsOnTheDom, hasLength (1 ));
10341034 });
10351035
1036+ test (
1037+ 'singleTextField Autofill setEditableSizeAndTransform preserves'
1038+ 'editing state' , () {
1039+ // Create a configuration with focused element has autofil hint.
1040+ final Map <String , dynamic > flutterSingleAutofillElementConfig =
1041+ createFlutterConfig ('text' , autofillHint: 'username' );
1042+ final MethodCall setClient = MethodCall ('TextInput.setClient' ,
1043+ < dynamic > [123 , flutterSingleAutofillElementConfig]);
1044+ sendFrameworkMessage (codec.encodeMethodCall (setClient));
1045+
1046+ const MethodCall setEditingState1 =
1047+ MethodCall ('TextInput.setEditingState' , < String , dynamic > {
1048+ 'text' : 'abcd' ,
1049+ 'selectionBase' : 2 ,
1050+ 'selectionExtent' : 3 ,
1051+ });
1052+ sendFrameworkMessage (codec.encodeMethodCall (setEditingState1));
1053+
1054+ const MethodCall show = MethodCall ('TextInput.show' );
1055+ sendFrameworkMessage (codec.encodeMethodCall (show));
1056+
1057+ // The second [setEditingState] should override the first one.
1058+ checkInputEditingState (
1059+ textEditing.editingElement.domElement, 'abcd' , 2 , 3 );
1060+
1061+ // The transform is changed. For example after a validation error, red
1062+ // line appeared under the input field.
1063+ final MethodCall setSizeAndTransform =
1064+ configureSetSizeAndTransformMethodCall (150 , 50 ,
1065+ Matrix4 .translationValues (10.0 , 20.0 , 30.0 ).storage.toList ());
1066+ sendFrameworkMessage (codec.encodeMethodCall (setSizeAndTransform));
1067+
1068+ // Check the element still has focus. User can keep editing.
1069+ expect (document.activeElement, textEditing.editingElement.domElement);
1070+
1071+ // Check the cursor location is the same.
1072+ checkInputEditingState (
1073+ textEditing.editingElement.domElement, 'abcd' , 2 , 3 );
1074+
1075+ const MethodCall clearClient = MethodCall ('TextInput.clearClient' );
1076+ sendFrameworkMessage (codec.encodeMethodCall (clearClient));
1077+
1078+ // Confirm that [HybridTextEditing] didn't send any messages.
1079+ expect (spy.messages, isEmpty);
1080+ // Form stays on the DOM until autofill context is finalized.
1081+ expect (document.getElementsByTagName ('form' ), isNotEmpty);
1082+ expect (formsOnTheDom, hasLength (1 ));
1083+ });
1084+
10361085 test (
10371086 'multiTextField Autofill: setClient, setEditingState, show, '
10381087 'setEditingState, clearClient' , () {
@@ -1693,7 +1742,8 @@ void testMain() {
16931742 // Autofill value is applied to the element.
16941743 expect (firstElement.name,
16951744 BrowserAutofillHints .instance.flutterToEngine ('password' ));
1696- expect (firstElement.id, BrowserAutofillHints .instance.flutterToEngine ('password' ));
1745+ expect (firstElement.id,
1746+ BrowserAutofillHints .instance.flutterToEngine ('password' ));
16971747 expect (firstElement.type, 'password' );
16981748 if (browserEngine == BrowserEngine .firefox) {
16991749 expect (firstElement.name,
@@ -1722,7 +1772,6 @@ void testMain() {
17221772 EngineAutofillForm .fromFrameworkMessage (
17231773 createAutofillInfo ('username' , 'field1' ), fields);
17241774
1725-
17261775 expect (autofillForm.formIdentifier, 'aabbcc*jjkkll*zzyyxx' );
17271776 });
17281777
0 commit comments