Skip to content

Commit c5588af

Browse files
author
nturgut
authored
[web] run safari desktop tests on luci (flutter#21228)
* run safari desktop tests on luci * fix safari issue. focus on dom element when new transform is received. add transform to test cases * Update text_editing.dart minor change to retrigger tests (recipe change is merged)
1 parent 90b82ec commit c5588af

File tree

3 files changed

+38
-16
lines changed

3 files changed

+38
-16
lines changed

lib/web_ui/dev/test_runner.dart

-5
Original file line numberDiff line numberDiff line change
@@ -133,11 +133,6 @@ class TestCommand extends Command<bool> with ArgUtils {
133133
/// Collect information on the bot.
134134
final MacOSInfo macOsInfo = new MacOSInfo();
135135
await macOsInfo.printInformation();
136-
137-
/// Tests may fail on the CI, therefore exit test_runner.
138-
if (isLuci) {
139-
return true;
140-
}
141136
}
142137

143138
switch (testTypesRequested) {

lib/web_ui/lib/src/engine/text_editing/text_editing.dart

+9-6
Original file line numberDiff line numberDiff line change
@@ -667,12 +667,6 @@ class SafariDesktopTextEditingStrategy extends DefaultTextEditingStrategy {
667667
_geometry?.applyToDomElement(domElement);
668668
if (hasAutofillGroup) {
669669
placeForm();
670-
// Set the last editing state if it exists, this is critical for a
671-
// users ongoing work to continue uninterrupted when there is an update to
672-
// the transform.
673-
if (_lastEditingState != null) {
674-
_lastEditingState!.applyToDomElement(domElement);
675-
}
676670
// On Safari Desktop, when a form is focused, it opens an autofill menu
677671
// immediately.
678672
// Flutter framework sends `setEditableSizeAndTransform` for informing
@@ -682,6 +676,15 @@ class SafariDesktopTextEditingStrategy extends DefaultTextEditingStrategy {
682676
// form only after placing it to the correct position and only once after
683677
// that. Calling focus multiple times causes flickering.
684678
focusedFormElement!.focus();
679+
680+
// Set the last editing state if it exists, this is critical for a
681+
// users ongoing work to continue uninterrupted when there is an update to
682+
// the transform.
683+
// If domElement is not focused cursor location will not be correct.
684+
domElement.focus();
685+
if (_lastEditingState != null) {
686+
_lastEditingState!.applyToDomElement(domElement);
687+
}
685688
}
686689
}
687690

lib/web_ui/test/text_editing_test.dart

+29-5
Original file line numberDiff line numberDiff line change
@@ -1016,7 +1016,7 @@ void testMain() {
10161016

10171017
test(
10181018
'singleTextField Autofill: setClient, setEditingState, show, '
1019-
'setEditingState, clearClient', () {
1019+
'setSizeAndTransform, setEditingState, clearClient', () {
10201020
// Create a configuration with focused element has autofil hint.
10211021
final Map<String, dynamic> flutterSingleAutofillElementConfig =
10221022
createFlutterConfig('text', autofillHint: 'username');
@@ -1035,6 +1035,11 @@ void testMain() {
10351035
const MethodCall show = MethodCall('TextInput.show');
10361036
sendFrameworkMessage(codec.encodeMethodCall(show));
10371037

1038+
final MethodCall setSizeAndTransform =
1039+
configureSetSizeAndTransformMethodCall(150, 50,
1040+
Matrix4.translationValues(10.0, 20.0, 30.0).storage.toList());
1041+
sendFrameworkMessage(codec.encodeMethodCall(setSizeAndTransform));
1042+
10381043
// The second [setEditingState] should override the first one.
10391044
checkInputEditingState(
10401045
textEditing.editingElement.domElement, 'abcd', 2, 3);
@@ -1074,9 +1079,18 @@ void testMain() {
10741079
const MethodCall show = MethodCall('TextInput.show');
10751080
sendFrameworkMessage(codec.encodeMethodCall(show));
10761081

1077-
// The second [setEditingState] should override the first one.
1078-
checkInputEditingState(
1079-
textEditing.editingElement.domElement, 'abcd', 2, 3);
1082+
final InputElement inputElement =
1083+
textEditing.editingElement.domElement as InputElement;
1084+
expect(inputElement.value, 'abcd');
1085+
if (!(browserEngine == BrowserEngine.webkit &&
1086+
operatingSystem == OperatingSystem.macOs)) {
1087+
// In Safari Desktop Autofill menu appears as soon as an element is
1088+
// focused, therefore the input element is only focused after the
1089+
// location is received.
1090+
expect(document.activeElement, inputElement);
1091+
expect(inputElement.selectionStart, 2);
1092+
expect(inputElement.selectionEnd, 3);
1093+
}
10801094

10811095
// The transform is changed. For example after a validation error, red
10821096
// line appeared under the input field.
@@ -1104,7 +1118,7 @@ void testMain() {
11041118

11051119
test(
11061120
'multiTextField Autofill: setClient, setEditingState, show, '
1107-
'setEditingState, clearClient', () {
1121+
'setSizeAndTransform setEditingState, clearClient', () {
11081122
// Create a configuration with an AutofillGroup of four text fields.
11091123
final Map<String, dynamic> flutterMultiAutofillElementConfig =
11101124
createFlutterConfig('text',
@@ -1130,6 +1144,11 @@ void testMain() {
11301144
const MethodCall show = MethodCall('TextInput.show');
11311145
sendFrameworkMessage(codec.encodeMethodCall(show));
11321146

1147+
final MethodCall setSizeAndTransform =
1148+
configureSetSizeAndTransformMethodCall(150, 50,
1149+
Matrix4.translationValues(10.0, 20.0, 30.0).storage.toList());
1150+
sendFrameworkMessage(codec.encodeMethodCall(setSizeAndTransform));
1151+
11331152
// The second [setEditingState] should override the first one.
11341153
checkInputEditingState(
11351154
textEditing.editingElement.domElement, 'abcd', 2, 3);
@@ -1502,6 +1521,11 @@ void testMain() {
15021521
const MethodCall show = MethodCall('TextInput.show');
15031522
sendFrameworkMessage(codec.encodeMethodCall(show));
15041523

1524+
final MethodCall setSizeAndTransform =
1525+
configureSetSizeAndTransformMethodCall(150, 50,
1526+
Matrix4.translationValues(10.0, 20.0, 30.0).storage.toList());
1527+
sendFrameworkMessage(codec.encodeMethodCall(setSizeAndTransform));
1528+
15051529
// The second [setEditingState] should override the first one.
15061530
checkInputEditingState(
15071531
textEditing.editingElement.domElement, 'abcd', 2, 3);

0 commit comments

Comments
 (0)