diff --git a/.flutter-plugins-dependencies b/.flutter-plugins-dependencies index cc3c63c..9aa870a 100644 --- a/.flutter-plugins-dependencies +++ b/.flutter-plugins-dependencies @@ -1 +1 @@ -{"info":"This is a generated file; do not edit or check into version control.","plugins":{"ios":[{"name":"integration_test","path":"C:\\\\Google\\\\flutter\\\\packages\\\\integration_test\\\\","dependencies":[]}],"android":[{"name":"integration_test","path":"C:\\\\Google\\\\flutter\\\\packages\\\\integration_test\\\\","dependencies":[]}],"macos":[],"linux":[],"windows":[],"web":[]},"dependencyGraph":[{"name":"integration_test","dependencies":[]}],"date_created":"2021-05-25 17:10:21.135264","version":"2.2.0"} \ No newline at end of file +{"info":"This is a generated file; do not edit or check into version control.","plugins":{"ios":[{"name":"integration_test","path":"C:\\\\Google\\\\flutter\\\\packages\\\\integration_test\\\\","dependencies":[]}],"android":[{"name":"integration_test","path":"C:\\\\Google\\\\flutter\\\\packages\\\\integration_test\\\\","dependencies":[]}],"macos":[],"linux":[],"windows":[],"web":[]},"dependencyGraph":[{"name":"integration_test","dependencies":[]}],"date_created":"2021-05-25 17:13:13.998769","version":"2.2.0"} \ No newline at end of file diff --git a/CHANGELOG.md b/CHANGELOG.md index cd0c487..5152453 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,8 +8,8 @@ In order to progress this library and add support for the new integration_test package various things have had to be changed to enable this will still supporting Flutter Driver. The big of which is removing Flutter Driver instance from the `FlutterWorld` instance in favour of an adapter approach whereby driving of the app (whether that is via `flutter_driver` or `WidgetTester`) becomes agnostic see `https://github.com/jonsamwell/flutter_gherkin/blob/f1fb2d4a632362629f5d1a196a0c055f858ad1d7/lib/src/flutter/adapters/app_driver_adapter.dart`. -- `FlutterDriverUtils` has been removed, use `world.appDriver` instead. You can still access the raw driver if needed via `world.appDriver.rawDriver` -- If you are using a custom world object and still want to use Flutter Driver it will need to extend `FlutterDriverWorld` instead of `FlutterWorld` this will give you type safety on the `world.appDriver.rawDriver` property +- `FlutterDriverUtils` has been removed, use `world.appDriver` instead. You can still access the raw driver if needed via `world.appDriver.nativeDriver` +- If you are using a custom world object and still want to use Flutter Driver it will need to extend `FlutterDriverWorld` instead of `FlutterWorld` this will give you type safety on the `world.appDriver.nativeDriver` property The change to use the `integration_test` package is a fundamentally different approach. Where using the `flutter_driver` implementation your app is launch in a different process and then controlled by remote RPC calls from flutter driver in a different process. Using the new `integration_test` package your tests surround your app and become the app themselves. This removes the need for RPC communication from an external process into the app as well as giving you access to the internal state of your app. This is an altogether better approach, one that is quicker, more maintainable, scalable to device testing labs. However, it brings with it, its own set of challenges when trying to make this library work with it. Traditionally this library has evaluated the Gherkin feature files at run time, then used that evaluation to invoke actions against the app under test. However, as the tests need to surround the app in the `integration_test` view of the world the Gherkin tests need to be generated at development time so they can be complied in to a test app. Much like `json_serializable` creates classes that are able to work with json data. diff --git a/lib/src/flutter/adapters/app_driver_adapter.dart b/lib/src/flutter/adapters/app_driver_adapter.dart index 9f79f5e..9cb508e 100644 --- a/lib/src/flutter/adapters/app_driver_adapter.dart +++ b/lib/src/flutter/adapters/app_driver_adapter.dart @@ -13,14 +13,14 @@ enum ExpectedWidgetResultType { list, } -abstract class AppDriverAdapter { - TRawAdapter _driver; +abstract class AppDriverAdapter { + TNativeAdapter _driver; AppDriverAdapter(this._driver); - TRawAdapter get rawDriver => _driver; + TNativeAdapter get nativeDriver => _driver; - void setRawDriver(TRawAdapter driver) { + void setNativeDriver(TNativeAdapter driver) { _driver = driver; } diff --git a/lib/src/flutter/adapters/flutter_driver_app_driver_adapter.dart b/lib/src/flutter/adapters/flutter_driver_app_driver_adapter.dart index 74b070a..00844c1 100644 --- a/lib/src/flutter/adapters/flutter_driver_app_driver_adapter.dart +++ b/lib/src/flutter/adapters/flutter_driver_app_driver_adapter.dart @@ -14,7 +14,7 @@ class FlutterDriverAppDriverAdapter Duration? timeout = const Duration(seconds: 30), }) async { try { - await rawDriver.waitUntilNoTransientCallbacks(timeout: timeout); + await nativeDriver.waitUntilNoTransientCallbacks(timeout: timeout); } catch (_) { return 1; } @@ -34,7 +34,7 @@ class FlutterDriverAppDriverAdapter @override void dispose() { - rawDriver.close().catchError( + nativeDriver.close().catchError( (e, st) { // Avoid an unhandled error return null; @@ -44,7 +44,7 @@ class FlutterDriverAppDriverAdapter @override Future> screenshot() { - return rawDriver.screenshot(); + return nativeDriver.screenshot(); } @override @@ -53,7 +53,7 @@ class FlutterDriverAppDriverAdapter Duration? timeout = const Duration(seconds: 1), }) async { try { - await rawDriver.waitFor( + await nativeDriver.waitFor( finder, timeout: timeout, ); @@ -69,7 +69,7 @@ class FlutterDriverAppDriverAdapter Duration? timeout = const Duration(seconds: 1), }) async { try { - await rawDriver.waitForAbsent( + await nativeDriver.waitForAbsent( finder, timeout: timeout, ); @@ -86,7 +86,7 @@ class FlutterDriverAppDriverAdapter }) async { await waitForAppToSettle(timeout: timeout); - return await rawDriver.getText( + return await nativeDriver.getText( finder, timeout: timeout, ); @@ -102,7 +102,7 @@ class FlutterDriverAppDriverAdapter finder, timeout: timeout, ); - await rawDriver.enterText( + await nativeDriver.enterText( text, timeout: timeout, ); @@ -113,7 +113,7 @@ class FlutterDriverAppDriverAdapter SerializableFinder finder, { Duration? timeout = const Duration(seconds: 30), }) async { - await rawDriver.tap(finder, timeout: timeout); + await nativeDriver.tap(finder, timeout: timeout); await waitForAppToSettle(timeout: timeout); } @@ -141,7 +141,7 @@ class FlutterDriverAppDriverAdapter Duration? duration = const Duration(milliseconds: 200), Duration? timeout = const Duration(seconds: 30), }) async { - await rawDriver.scroll( + await nativeDriver.scroll( finder, dx ?? 0, dy ?? 0, @@ -206,7 +206,7 @@ class FlutterDriverAppDriverAdapter double? dy, Duration? timeout = const Duration(seconds: 30), }) async { - await rawDriver.scrollUntilVisible( + await nativeDriver.scrollUntilVisible( scrollable!, item, timeout: timeout, @@ -220,7 +220,7 @@ class FlutterDriverAppDriverAdapter SerializableFinder finder, { Duration? timeout = const Duration(seconds: 30), }) async { - await rawDriver.scrollIntoView( + await nativeDriver.scrollIntoView( finder, timeout: timeout, ); diff --git a/lib/src/flutter/adapters/widget_tester_app_driver_adapter.dart b/lib/src/flutter/adapters/widget_tester_app_driver_adapter.dart index ee1afc1..7d7d362 100644 --- a/lib/src/flutter/adapters/widget_tester_app_driver_adapter.dart +++ b/lib/src/flutter/adapters/widget_tester_app_driver_adapter.dart @@ -18,7 +18,7 @@ class WidgetTesterAppDriverAdapter Duration? timeout = const Duration(seconds: 30), }) async { try { - return await rawDriver.pumpAndSettle( + return await nativeDriver.pumpAndSettle( duration!, ); } catch (_) { @@ -32,7 +32,7 @@ class WidgetTesterAppDriverAdapter ExpectedWidgetResultType expectResultType = ExpectedWidgetResultType.first, ]) { try { - final element = rawDriver.widget(finder); + final element = nativeDriver.widget(finder); return Future.value(element); } on StateError { @@ -44,7 +44,7 @@ class WidgetTesterAppDriverAdapter @override Future> screenshot() { - var renderObject = rawDriver.binding.renderViewElement?.renderObject; + var renderObject = nativeDriver.binding.renderViewElement?.renderObject; while (renderObject != null && !renderObject.isRepaintBoundary) { renderObject = renderObject.parent as RenderObject; @@ -105,7 +105,7 @@ class WidgetTesterAppDriverAdapter finder, timeout: timeout, ); - await rawDriver.enterText( + await nativeDriver.enterText( finder, text, ); @@ -119,7 +119,7 @@ class WidgetTesterAppDriverAdapter Finder finder, { Duration? timeout = const Duration(seconds: 30), }) async { - await rawDriver.tap(finder); + await nativeDriver.tap(finder); await waitForAppToSettle( timeout: timeout, ); @@ -154,11 +154,11 @@ class WidgetTesterAppDriverAdapter find.byType(Scrollable).first, matchRoot: true, ); - final state = rawDriver.state(scrollableFinder) as ScrollableState; + final state = nativeDriver.state(scrollableFinder) as ScrollableState; final position = state.position; position.jumpTo(dy ?? dx ?? 0); - await rawDriver.pump(); + await nativeDriver.pump(); } @override @@ -214,7 +214,7 @@ class WidgetTesterAppDriverAdapter double? dy, Duration? timeout = const Duration(seconds: 30), }) async { - await rawDriver.scrollUntilVisible( + await nativeDriver.scrollUntilVisible( item, dy ?? dx ?? 0, scrollable: scrollable, @@ -226,13 +226,13 @@ class WidgetTesterAppDriverAdapter Finder finder, { Duration? timeout = const Duration(seconds: 30), }) async { - await rawDriver.ensureVisible(finder); + await nativeDriver.ensureVisible(finder); await waitForAppToSettle(); } @override Future pageBack() async { - await rawDriver.pageBack(); + await nativeDriver.pageBack(); await waitForAppToSettle(); } } diff --git a/lib/src/flutter/world/flutter_world.dart b/lib/src/flutter/world/flutter_world.dart index e92d2fc..c10ea65 100644 --- a/lib/src/flutter/world/flutter_world.dart +++ b/lib/src/flutter/world/flutter_world.dart @@ -34,7 +34,7 @@ class FlutterTypedAdapterWorld extends FlutterWorld { /// It is suggested you use `appDriver` for all interactions with the app under tests /// however if you need a specific api not available on `appDriver` this property /// exposes the actual class that can interact with the app under test - TDriver get rawAppDriver => _adapter!.rawDriver as TDriver; + TDriver get rawAppDriver => _adapter!.nativeDriver as TDriver; /// The adapter that is used to agnostically drive the app under test @override