[flutter_driver] Fix browser check (#54741)
This commit is contained in:
parent
b6262e7c1c
commit
21588019bd
@ -167,7 +167,7 @@ abstract class FlutterDriver {
|
||||
///
|
||||
/// * [VMServiceFlutterDriver], which uses vmservice to implement.
|
||||
/// * [WebFlutterDriver], which uses webdriver to implement.
|
||||
Future<Map<String, dynamic>> sendCommand(Command command) => throw UnimplementedError();
|
||||
Future<Map<String, dynamic>> sendCommand(Command command) async => throw UnimplementedError();
|
||||
|
||||
/// Checks the status of the Flutter Driver extension.
|
||||
Future<Health> 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<List<int>> screenshot() {
|
||||
Future<List<int>> 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<List<Map<String, dynamic>>> getVmFlags() {
|
||||
Future<List<Map<String, dynamic>>> getVmFlags() async {
|
||||
throw UnimplementedError();
|
||||
}
|
||||
/// Starts recording performance traces.
|
||||
@ -598,7 +598,7 @@ abstract class FlutterDriver {
|
||||
Future<void> startTracing({
|
||||
List<TimelineStream> streams = const <TimelineStream>[TimelineStream.all],
|
||||
Duration timeout = kUnusuallyLongTimeout,
|
||||
}) {
|
||||
}) async {
|
||||
throw UnimplementedError();
|
||||
}
|
||||
|
||||
@ -611,7 +611,7 @@ abstract class FlutterDriver {
|
||||
/// For [WebFlutterDriver], this is only supported for Chrome.
|
||||
Future<Timeline> stopTracingAndDownloadTimeline({
|
||||
Duration timeout = kUnusuallyLongTimeout,
|
||||
}) {
|
||||
}) async {
|
||||
throw UnimplementedError();
|
||||
}
|
||||
/// Runs [action] and outputs a performance trace for it.
|
||||
@ -637,7 +637,7 @@ abstract class FlutterDriver {
|
||||
Future<dynamic> action(), {
|
||||
List<TimelineStream> streams = const <TimelineStream>[TimelineStream.all],
|
||||
bool retainPriorEvents = false,
|
||||
}) {
|
||||
}) async {
|
||||
throw UnimplementedError();
|
||||
}
|
||||
|
||||
@ -650,7 +650,7 @@ abstract class FlutterDriver {
|
||||
/// For [WebFlutterDriver], this is only supported for Chrome.
|
||||
Future<void> 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<void> forceGC() {
|
||||
Future<void> forceGC() async {
|
||||
throw UnimplementedError();
|
||||
}
|
||||
|
||||
/// Closes the underlying connection to the VM service.
|
||||
///
|
||||
/// Returns a [Future] that fires once the connection has been closed.
|
||||
Future<void> close() {
|
||||
Future<void> close() async {
|
||||
throw UnimplementedError();
|
||||
}
|
||||
}
|
||||
|
@ -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.
|
||||
|
@ -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<dynamic>.value(); }),
|
||||
throwsA(isA<UnimplementedError>()));
|
||||
throwsA(isA<UnsupportedError>()));
|
||||
expect(driver.startTracing(),
|
||||
throwsA(isA<UnimplementedError>()));
|
||||
throwsA(isA<UnsupportedError>()));
|
||||
expect(driver.stopTracingAndDownloadTimeline(),
|
||||
throwsA(isA<UnimplementedError>()));
|
||||
throwsA(isA<UnsupportedError>()));
|
||||
expect(driver.clearTimeline(),
|
||||
throwsA(isA<UnimplementedError>()));
|
||||
throwsA(isA<UnsupportedError>()));
|
||||
});
|
||||
});
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user