diff --git a/dev/integration_tests/README.md b/dev/integration_tests/README.md index 07accc95bb..4be32c8212 100644 --- a/dev/integration_tests/README.md +++ b/dev/integration_tests/README.md @@ -1,13 +1,20 @@ -Automated Flutter integration test suites. Each suite consists of either a -complete Flutter app and a `flutter_driver` specification that drives tests -from the UI, or a native app that is meant to integrate with Flutter for -testing. +# Automated Flutter integration test suites + +Each suite consists of either a complete Flutter app and a `flutter_driver` +specification that drives tests from the UI, or a native app that is meant to +integrate with Flutter for testing. Intended for use with devicelab tests. -If you want to run a driver test locally, to debug a problem with a test, -you can use this command from the appropriate subdirectory: +If you want to run a driver test locally, to debug a problem with a test, you +can use this command from the appropriate subdirectory: ```shell -% flutter drive +flutter drive -t --driver +``` + +For example: + +```sh +flutter drive -t lib/keyboard_resize.dart --driver test_driver/keyboard_resize_test.dart ``` diff --git a/dev/integration_tests/ui/test_driver/keyboard_resize_test.dart b/dev/integration_tests/ui/test_driver/keyboard_resize_test.dart index 81f5bcdb75..3b35997d42 100644 --- a/dev/integration_tests/ui/test_driver/keyboard_resize_test.dart +++ b/dev/integration_tests/ui/test_driver/keyboard_resize_test.dart @@ -33,22 +33,35 @@ void main() { final SerializableFinder defaultTextField = find.byValueKey(keys.kDefaultTextField); await driver.waitFor(defaultTextField); await driver.tap(defaultTextField); - await Future.delayed(const Duration(seconds: 1)); - // Measure the height with keyboard displayed. - final String heightWithKeyboardShown = await driver.getText(heightText); - expect(double.parse(heightWithKeyboardShown) < double.parse(startHeight), isTrue); + bool heightTextDidShrink = false; + for (int i = 0; i < 3; ++i) { + await Future.delayed(const Duration(seconds: 1)); + // Measure the height with keyboard displayed. + final String heightWithKeyboardShown = await driver.getText(heightText); + if (double.parse(heightWithKeyboardShown) < double.parse(startHeight)) { + heightTextDidShrink = true; + break; + } + } + expect(heightTextDidShrink, isTrue); // Unfocus the text field to dismiss the keyboard. final SerializableFinder unfocusButton = find.byValueKey(keys.kUnfocusButton); await driver.waitFor(unfocusButton); await driver.tap(unfocusButton); - await Future.delayed(const Duration(seconds: 1)); - // Measure the final height. - final String endHeight = await driver.getText(heightText); - - expect(endHeight, startHeight); + bool heightTextDidExpand = false; + for (int i = 0; i < 3; ++i) { + await Future.delayed(const Duration(seconds: 1)); + // Measure the final height. + final String endHeight = await driver.getText(heightText); + if (endHeight == startHeight) { + heightTextDidExpand = true; + break; + } + } + expect(heightTextDidExpand, isTrue); }); }); }