Files
Dat Vu 113def869b TF-4925 Submit the rename folder dialog on Enter (#5222)
* TF-4925 Submit EditTextDialogBuilder on Enter through _onPositiveAction

* TF-4925 Add RenamePersonalFolderWithEnterScenario and share CoreRobot.pressEnterOnFocusedField
2026-12-03 10:55:03 +07:00

45 lines
1.5 KiB
Dart

import 'package:flutter/services.dart';
import 'package:flutter/widgets.dart';
import 'package:patrol/patrol.dart';
import '../utils/mock_text_input.dart';
import '../utils/test_timeouts.dart';
import '../utils/wait_for_condition.dart';
abstract class CoreRobot {
final PatrolIntegrationTester $;
CoreRobot(this.$);
dynamic ignoreException() => $.tester.takeException();
MobileAutomator get native => $.platformAutomator.mobile;
// patrol_finders 3.2.0 enterText leaves its mock text input registered, which swallows every hide
Future<void> hideKeyboard() async {
$.tester.testTextInput.unregister();
FocusManager.instance.primaryFocus?.unfocus();
await SystemChannels.textInput.invokeMethod<void>('TextInput.hide');
final view = $.tester.view;
await waitForCondition(
() async {
await $.pump();
return view.viewInsets.bottom == 0;
},
timeout: TestTimeouts.short,
reason: 'Keyboard was not hidden',
);
// The mock input must own the connection again before the next enterText.
if (registerMockTextInput) $.tester.testTextInput.register();
}
// Profile web builds keep the mock text input registered, which swallows the browser's Enter.
Future<void> pressEnterOnFocusedField() async {
if ($.tester.testTextInput.isRegistered) {
await $.tester.testTextInput.receiveAction(TextInputAction.done);
} else {
await $.platformAutomator.web.pressKeyCombo(keys: ['Enter']);
}
}
}