diff --git a/packages/flutter_driver/lib/src/driver/driver.dart b/packages/flutter_driver/lib/src/driver/driver.dart index 1898335654..d9dfa7cb41 100644 --- a/packages/flutter_driver/lib/src/driver/driver.dart +++ b/packages/flutter_driver/lib/src/driver/driver.dart @@ -167,7 +167,7 @@ abstract class FlutterDriver { /// /// * [VMServiceFlutterDriver], which uses vmservice to implement. /// * [WebFlutterDriver], which uses webdriver to implement. - Future> sendCommand(Command command) => throw UnimplementedError(); + Future> sendCommand(Command command) async => throw UnimplementedError(); /// Checks the status of the Flutter Driver extension. Future checkHealth({ Duration timeout }) async { @@ -560,7 +560,7 @@ abstract class FlutterDriver { /// In practice, sometimes the device gets really busy for a while and /// even two seconds isn't enough, which means that this is still racy /// and a source of flakes. - Future> screenshot() { + Future> screenshot() async { throw UnimplementedError(); } @@ -585,7 +585,7 @@ abstract class FlutterDriver { /// [getFlagList]: https://github.com/dart-lang/sdk/blob/master/runtime/vm/service/service.md#getflaglist /// /// Throws [UnimplementedError] on [WebFlutterDriver] instances. - Future>> getVmFlags() { + Future>> getVmFlags() async { throw UnimplementedError(); } /// Starts recording performance traces. @@ -598,7 +598,7 @@ abstract class FlutterDriver { Future startTracing({ List streams = const [TimelineStream.all], Duration timeout = kUnusuallyLongTimeout, - }) { + }) async { throw UnimplementedError(); } @@ -611,7 +611,7 @@ abstract class FlutterDriver { /// For [WebFlutterDriver], this is only supported for Chrome. Future stopTracingAndDownloadTimeline({ Duration timeout = kUnusuallyLongTimeout, - }) { + }) async { throw UnimplementedError(); } /// Runs [action] and outputs a performance trace for it. @@ -637,7 +637,7 @@ abstract class FlutterDriver { Future action(), { List streams = const [TimelineStream.all], bool retainPriorEvents = false, - }) { + }) async { throw UnimplementedError(); } @@ -650,7 +650,7 @@ abstract class FlutterDriver { /// For [WebFlutterDriver], this is only supported for Chrome. Future clearTimeline({ Duration timeout = kUnusuallyLongTimeout, - }) { + }) async { throw UnimplementedError(); } /// [action] will be executed with the frame sync mechanism disabled. @@ -683,14 +683,14 @@ abstract class FlutterDriver { /// Force a garbage collection run in the VM. /// /// Throws [UnimplementedError] on [WebFlutterDriver] instances. - Future forceGC() { + Future forceGC() async { throw UnimplementedError(); } /// Closes the underlying connection to the VM service. /// /// Returns a [Future] that fires once the connection has been closed. - Future close() { + Future close() async { throw UnimplementedError(); } } diff --git a/packages/flutter_driver/lib/src/driver/web_driver.dart b/packages/flutter_driver/lib/src/driver/web_driver.dart index 9b21690ec2..4f604f0837 100644 --- a/packages/flutter_driver/lib/src/driver/web_driver.dart +++ b/packages/flutter_driver/lib/src/driver/web_driver.dart @@ -154,7 +154,7 @@ class WebFlutterDriver extends FlutterDriver { /// Checks whether browser supports Timeline related operations void _checkBrowserSupportsTimeline() { - if (_connection.supportsTimelineAction) { + if (!_connection.supportsTimelineAction) { throw UnsupportedError('Timeline action is not supported by current testing browser'); } } @@ -164,22 +164,12 @@ class WebFlutterDriver extends FlutterDriver { class FlutterWebConnection { /// Creates a FlutterWebConnection with WebDriver /// and whether the WebDriver supports timeline action - FlutterWebConnection(this._driver, this._supportsTimelineAction); + FlutterWebConnection(this._driver, this.supportsTimelineAction); final async_io.WebDriver _driver; - - bool _supportsTimelineAction; /// Whether the connected WebDriver supports timeline action for Flutter Web Driver - // ignore: unnecessary_getters_setters - bool get supportsTimelineAction => _supportsTimelineAction; - - /// Setter for _supportsTimelineAction - @visibleForTesting - // ignore: unnecessary_getters_setters - set supportsTimelineAction(bool value) { - _supportsTimelineAction = value; - } + bool supportsTimelineAction; /// Starts WebDriver with the given [settings] and /// establishes the connection to Flutter Web application. diff --git a/packages/flutter_driver/test/flutter_driver_test.dart b/packages/flutter_driver/test/flutter_driver_test.dart index 9ab5ea885c..18add5d4b5 100644 --- a/packages/flutter_driver/test/flutter_driver_test.dart +++ b/packages/flutter_driver/test/flutter_driver_test.dart @@ -693,7 +693,7 @@ void main() { setUp(() { mockConnection = MockFlutterWebConnection(); - mockConnection.supportsTimelineAction = true; + when(mockConnection.supportsTimelineAction).thenReturn(true); driver = WebFlutterDriver.connectedTo(mockConnection); }); @@ -1033,19 +1033,19 @@ void main() { setUp(() { mockConnection = MockFlutterWebConnection(); - mockConnection.supportsTimelineAction = false; + when(mockConnection.supportsTimelineAction).thenReturn(false); driver = WebFlutterDriver.connectedTo(mockConnection); }); test('tracing', () async { expect(driver.traceAction(() async { return Future.value(); }), - throwsA(isA())); + throwsA(isA())); expect(driver.startTracing(), - throwsA(isA())); + throwsA(isA())); expect(driver.stopTracingAndDownloadTimeline(), - throwsA(isA())); + throwsA(isA())); expect(driver.clearTimeline(), - throwsA(isA())); + throwsA(isA())); }); }); }