From 44ca44ce2e6e213b5e67afeecbdbca7ba2e2d383 Mon Sep 17 00:00:00 2001 From: Tim Shedor Date: Thu, 26 Mar 2020 09:46:11 -0700 Subject: [PATCH] reverse arguments and expect on the presence step --- CHANGELOG.md | 4 ++++ lib/src/flutter/steps/given_i_open_the_drawer_step.dart | 2 +- .../flutter/steps/then_expect_widget_to_be_present_step.dart | 5 +++-- lib/src/flutter/utils/driver_utils.dart | 4 ++-- 4 files changed, 10 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7939fc9..e8c0467 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +## Unreleased +* **BREAKING CHANGE** reverse order of `driver` and `finder` in `FlutterDriverUtils#isPresent`. This makes this method's arguments more consistent with all other instance methods in the class by including `driver` first. +* `expect` the presence of `ThenExpectWidgetToBePresent`. If the widget was not present, the method would simply timeout and not report an error for the step. + ## [1.1.7+7] - 25/03/2019 * Added the ability to test against an already running app; enabling you to debug a running application while it has tests executed against it. Setting the configuration property `runningAppProtocolEndpointUri` to the service protocol endpoint (found in stdout when an app has `--verbose` logging turrned on) will ensure that the existing app is connected to rather than starting a new instance of the app. NOTE: ensure the app you are trying to connect to calls `enableFlutterDriverExtension()` when it starts up otherwise the Flutter Driver will not be able to connect to it. diff --git a/lib/src/flutter/steps/given_i_open_the_drawer_step.dart b/lib/src/flutter/steps/given_i_open_the_drawer_step.dart index 19216c0..1228769 100644 --- a/lib/src/flutter/steps/given_i_open_the_drawer_step.dart +++ b/lib/src/flutter/steps/given_i_open_the_drawer_step.dart @@ -16,7 +16,7 @@ class GivenOpenDrawer extends Given1WithWorld { Future executeStep(String action) async { final drawerFinder = find.byType("Drawer"); final isOpen = - await FlutterDriverUtils.isPresent(drawerFinder, world.driver); + await FlutterDriverUtils.isPresent(world.driver, drawerFinder); // https://github.com/flutter/flutter/issues/9002#issuecomment-293660833 if (isOpen && action == "close") { // Swipe to the left across the whole app to close the drawer diff --git a/lib/src/flutter/steps/then_expect_widget_to_be_present_step.dart b/lib/src/flutter/steps/then_expect_widget_to_be_present_step.dart index dd999a9..301902f 100644 --- a/lib/src/flutter/steps/then_expect_widget_to_be_present_step.dart +++ b/lib/src/flutter/steps/then_expect_widget_to_be_present_step.dart @@ -20,10 +20,11 @@ class ThenExpectWidgetToBePresent @override Future executeStep(String key, int seconds) async { - await FlutterDriverUtils.isPresent( - find.byValueKey(key), + final isPresent = await FlutterDriverUtils.isPresent( world.driver, + find.byValueKey(key), timeout: Duration(seconds: seconds), ); + expect(isPresent, true); } } diff --git a/lib/src/flutter/utils/driver_utils.dart b/lib/src/flutter/utils/driver_utils.dart index af32846..1d6d2d0 100644 --- a/lib/src/flutter/utils/driver_utils.dart +++ b/lib/src/flutter/utils/driver_utils.dart @@ -4,8 +4,8 @@ import 'package:flutter_driver/flutter_driver.dart'; class FlutterDriverUtils { static Future isPresent( - SerializableFinder finder, - FlutterDriver driver, { + FlutterDriver driver, + SerializableFinder finder, { Duration timeout = const Duration(seconds: 1), }) async { try {