diff --git a/super_editor/lib/src/super_textfield/desktop/desktop_textfield.dart b/super_editor/lib/src/super_textfield/desktop/desktop_textfield.dart index 096c4eff0f..0a3eb45620 100644 --- a/super_editor/lib/src/super_textfield/desktop/desktop_textfield.dart +++ b/super_editor/lib/src/super_textfield/desktop/desktop_textfield.dart @@ -1308,7 +1308,11 @@ class _SuperTextFieldImeInteractorState extends State[ // handlers, passing the key combo to the OS on Mac. Place all custom Mac key // combos above this handler. DefaultSuperTextFieldKeyboardHandlers.sendKeyEventToMacOs, - DefaultSuperTextFieldKeyboardHandlers.insertNewlineWhenEnterIsPressed, DefaultSuperTextFieldKeyboardHandlers.moveCaretToStartOrEnd, DefaultSuperTextFieldKeyboardHandlers.moveUpDownLeftAndRightWithArrowKeys, DefaultSuperTextFieldKeyboardHandlers.moveToLineStartWithHome, diff --git a/super_editor/pubspec.yaml b/super_editor/pubspec.yaml index 3d9346fb09..3aa63771ed 100644 --- a/super_editor/pubspec.yaml +++ b/super_editor/pubspec.yaml @@ -36,7 +36,7 @@ dependencies: # Dependencies for testing tools that we ship with super_editor flutter_test: sdk: flutter - flutter_test_robots: 0.0.21 + flutter_test_robots: 0.0.22 dependency_overrides: # # Override to local mono-repo path so devs can test this repo diff --git a/super_editor/test/super_textfield/super_textfield_ime_test.dart b/super_editor/test/super_textfield/super_textfield_ime_test.dart index 114bf246ce..940a40fec6 100644 --- a/super_editor/test/super_textfield/super_textfield_ime_test.dart +++ b/super_editor/test/super_textfield/super_textfield_ime_test.dart @@ -231,7 +231,7 @@ void main() { }); group('inserts line', () { - testWidgetsOnWindowsAndLinux('when ENTER is pressed in middle of text', (tester) async { + testWidgetsOnDesktop('when ENTER is pressed in middle of text', (tester) async { await _pumpSuperTextField( tester, AttributedTextEditingController( @@ -240,31 +240,13 @@ void main() { ); await tester.placeCaretInSuperTextField(8); - await tester.pressEnter(); + await tester.pressEnterAdaptive(getter: imeClientGetter); expect(SuperTextFieldInspector.findText().text, "this is \nsome text"); expect(SuperTextFieldInspector.findSelection(), const TextSelection.collapsed(offset: 9)); }); - testWidgetsOnMac('when ENTER is pressed in middle of text (on MAC)', (tester) async { - await _pumpSuperTextField( - tester, - AttributedTextEditingController( - text: AttributedText('this is some text'), - ), - ); - await tester.placeCaretInSuperTextField(8); - - // Simulate the user pressing ENTER. - // On macOS, pressing ENTER generates a new line input action. - await tester.testTextInput.receiveAction(TextInputAction.newline); - await tester.pump(); - - expect(SuperTextFieldInspector.findText().text, "this is \nsome text"); - expect(SuperTextFieldInspector.findSelection(), const TextSelection.collapsed(offset: 9)); - }); - - testWidgetsOnWindowsAndLinux('when ENTER is pressed at beginning of text', (tester) async { + testWidgetsOnDesktop('when ENTER is pressed at beginning of text', (tester) async { await _pumpSuperTextField( tester, AttributedTextEditingController( @@ -273,46 +255,13 @@ void main() { ); await tester.placeCaretInSuperTextField(0); - await tester.pressEnter(); + await tester.pressEnterAdaptive(getter: imeClientGetter); expect(SuperTextFieldInspector.findText().text, "\nthis is some text"); expect(SuperTextFieldInspector.findSelection(), const TextSelection.collapsed(offset: 1)); }); - testWidgetsOnMac('when ENTER is pressed at beginning of text (on MAC)', (tester) async { - await _pumpSuperTextField( - tester, - AttributedTextEditingController( - text: AttributedText('this is some text'), - ), - ); - await tester.placeCaretInSuperTextField(0); - - // Simulate the user pressing ENTER. - // On macOS, pressing ENTER generates a new line input action. - await tester.testTextInput.receiveAction(TextInputAction.newline); - await tester.pump(); - - expect(SuperTextFieldInspector.findText().text, "\nthis is some text"); - expect(SuperTextFieldInspector.findSelection(), const TextSelection.collapsed(offset: 1)); - }); - - testWidgetsOnWindowsAndLinux('when ENTER is pressed at end of text', (tester) async { - await _pumpSuperTextField( - tester, - AttributedTextEditingController( - text: AttributedText('this is some text'), - ), - ); - await tester.placeCaretInSuperTextField(17); - - await tester.pressEnter(); - - expect(SuperTextFieldInspector.findText().text, "this is some text\n"); - expect(SuperTextFieldInspector.findSelection(), const TextSelection.collapsed(offset: 18)); - }); - - testWidgetsOnMac('when ENTER is pressed at end of text (on MAC)', (tester) async { + testWidgetsOnDesktop('when ENTER is pressed at end of text', (tester) async { await _pumpSuperTextField( tester, AttributedTextEditingController( @@ -321,16 +270,13 @@ void main() { ); await tester.placeCaretInSuperTextField(17); - // Simulate the user pressing ENTER. - // On macOS, pressing ENTER generates a new line input action. - await tester.testTextInput.receiveAction(TextInputAction.newline); - await tester.pump(); + await tester.pressEnterAdaptive(getter: imeClientGetter); expect(SuperTextFieldInspector.findText().text, "this is some text\n"); expect(SuperTextFieldInspector.findSelection(), const TextSelection.collapsed(offset: 18)); }); - // TODO: Make this a Windows + Linux test when Flutter supports numpad enter on windows + // TODO: Merge this with the testWidgetsOnMac below when Flutter supports numpad enter on windows testWidgetsOnLinux('when NUMPAD ENTER is pressed in middle of text', (tester) async { await _pumpSuperTextField( tester, @@ -340,7 +286,7 @@ void main() { ); await tester.placeCaretInSuperTextField(8); - await tester.pressNumpadEnter(); + await tester.pressNumpadEnterAdaptive(getter: imeClientGetter); expect(SuperTextFieldInspector.findText().text, "this is \nsome text"); expect(SuperTextFieldInspector.findSelection(), const TextSelection.collapsed(offset: 9)); @@ -355,16 +301,13 @@ void main() { ); await tester.placeCaretInSuperTextField(8); - // Simulate the user pressing ENTER. - // On macOS, pressing ENTER generates a new line input action. - await tester.testTextInput.receiveAction(TextInputAction.newline); - await tester.pump(); + await tester.pressNumpadEnterAdaptive(getter: imeClientGetter); expect(SuperTextFieldInspector.findText().text, "this is \nsome text"); expect(SuperTextFieldInspector.findSelection(), const TextSelection.collapsed(offset: 9)); }); - // TODO: Make this a Windows + Linux test when Flutter supports numpad enter on windows + // TODO: Merge this with the testWidgetsOnMac below when Flutter supports numpad enter on windows testWidgetsOnLinux('when NUMPAD ENTER is pressed at beginning of text', (tester) async { await _pumpSuperTextField( tester, @@ -374,7 +317,7 @@ void main() { ); await tester.placeCaretInSuperTextField(0); - await tester.pressNumpadEnter(); + await tester.pressNumpadEnterAdaptive(getter: imeClientGetter); expect(SuperTextFieldInspector.findText().text, "\nthis is some text"); expect(SuperTextFieldInspector.findSelection(), const TextSelection.collapsed(offset: 1)); @@ -389,16 +332,13 @@ void main() { ); await tester.placeCaretInSuperTextField(0); - // Simulate the user pressing ENTER. - // On macOS, pressing ENTER generates a new line input action. - await tester.testTextInput.receiveAction(TextInputAction.newline); - await tester.pump(); + await tester.pressNumpadEnterAdaptive(getter: imeClientGetter); expect(SuperTextFieldInspector.findText().text, "\nthis is some text"); expect(SuperTextFieldInspector.findSelection(), const TextSelection.collapsed(offset: 1)); }); - // TODO: Make this a Windows + Linux test when Flutter supports numpad enter on windows + // TODO: Merge this with the testWidgetsOnMac below when Flutter supports numpad enter on windows testWidgetsOnLinux('when NUMPAD ENTER is pressed at end of text', (tester) async { await _pumpSuperTextField( tester, @@ -408,7 +348,7 @@ void main() { ); await tester.placeCaretInSuperTextField(17); - await tester.pressNumpadEnter(); + await tester.pressNumpadEnterAdaptive(getter: imeClientGetter); expect(SuperTextFieldInspector.findText().text, "this is some text\n"); expect(SuperTextFieldInspector.findSelection(), const TextSelection.collapsed(offset: 18)); @@ -423,10 +363,7 @@ void main() { ); await tester.placeCaretInSuperTextField(17); - // Simulate the user pressing ENTER. - // On macOS, pressing ENTER generates a new line input action. - await tester.testTextInput.receiveAction(TextInputAction.newline); - await tester.pump(); + await tester.pressNumpadEnterAdaptive(getter: imeClientGetter); expect(SuperTextFieldInspector.findText().text, "this is some text\n"); expect(SuperTextFieldInspector.findSelection(), const TextSelection.collapsed(offset: 18));