chore(rename): renamed rawDriver -> nativeDriver

This commit is contained in:
Jon Samwell 2021-05-25 17:13:33 +10:00
parent cfb9febe66
commit 6d54ef7799
6 changed files with 29 additions and 29 deletions

View File

@ -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"}
{"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"}

View File

@ -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.

View File

@ -13,14 +13,14 @@ enum ExpectedWidgetResultType {
list,
}
abstract class AppDriverAdapter<TRawAdapter, TFinderType, TWidgetBaseType> {
TRawAdapter _driver;
abstract class AppDriverAdapter<TNativeAdapter, TFinderType, TWidgetBaseType> {
TNativeAdapter _driver;
AppDriverAdapter(this._driver);
TRawAdapter get rawDriver => _driver;
TNativeAdapter get nativeDriver => _driver;
void setRawDriver(TRawAdapter driver) {
void setNativeDriver(TNativeAdapter driver) {
_driver = driver;
}

View File

@ -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<List<int>> 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,
);

View File

@ -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<T>(finder);
final element = nativeDriver.widget<T>(finder);
return Future.value(element);
} on StateError {
@ -44,7 +44,7 @@ class WidgetTesterAppDriverAdapter
@override
Future<List<int>> 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<void> pageBack() async {
await rawDriver.pageBack();
await nativeDriver.pageBack();
await waitForAppToSettle();
}
}

View File

@ -34,7 +34,7 @@ class FlutterTypedAdapterWorld<TDriver, TFinder, TWidget> 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