Skip to content

Commit

Permalink
[flutter_driver] Remove runUnsynchronized in `VMServiceFlutterDrive…
Browse files Browse the repository at this point in the history
  • Loading branch information
nploi authored Aug 3, 2021
1 parent 52bf9db commit 31fd0f7
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 12 deletions.
12 changes: 0 additions & 12 deletions packages/flutter_driver/lib/src/driver/vmservice_driver.dart
Original file line number Diff line number Diff line change
Expand Up @@ -485,18 +485,6 @@ class VMServiceFlutterDriver extends FlutterDriver {
}
}

@override
Future<T> runUnsynchronized<T>(Future<T> Function() action, { Duration? timeout }) async {
await sendCommand(SetFrameSync(false, timeout: timeout));
T result;
try {
result = await action();
} finally {
await sendCommand(SetFrameSync(true, timeout: timeout));
}
return result;
}

@override
Future<void> forceGC() async {
try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -666,6 +666,23 @@ void main() {
test('VMServiceFlutterDriver does not support webDriver', () async {
expect(() => driver.webDriver, throwsUnsupportedError);
});

group('runUnsynchronized', () {
test('wrap waitFor with runUnsynchronized', () async {
fakeClient.responses['waitFor'] = makeFakeResponse(<String, dynamic>{});
fakeClient.responses['set_frame_sync'] = makeFakeResponse(<String, dynamic>{});

await driver.runUnsynchronized(() async {
await driver.waitFor(find.byTooltip('foo'), timeout: _kTestTimeout);
});

expect(fakeClient.commandLog, <String>[
'ext.flutter.driver {command: set_frame_sync, enabled: false}',
'ext.flutter.driver {command: waitFor, timeout: $_kSerializedTestTimeout, finderType: ByTooltipMessage, text: foo}',
'ext.flutter.driver {command: set_frame_sync, enabled: true}'
]);
});
});
});

group('VMServiceFlutterDriver with custom timeout', () {
Expand Down Expand Up @@ -965,6 +982,23 @@ void main() {
expect(() => driver.serviceClient.getVM(), throwsUnsupportedError);
});
});

group('runUnsynchronized', () {
test('wrap waitFor with runUnsynchronized', () async {
fakeConnection.responses['waitFor'] = jsonEncode(makeFakeResponse(<String, dynamic>{'text': 'hello'}));
fakeConnection.responses['set_frame_sync'] = jsonEncode(makeFakeResponse(<String, dynamic>{}));

await driver.runUnsynchronized(() async {
await driver.waitFor(find.byTooltip('foo'), timeout: _kTestTimeout);
});

expect(fakeConnection.commandLog, <String>[
r'''window.$flutterDriver('{"command":"set_frame_sync","enabled":"false"}') null''',
r'''window.$flutterDriver('{"command":"waitFor","timeout":"1234","finderType":"ByTooltipMessage","text":"foo"}') 0:00:01.234000''',
r'''window.$flutterDriver('{"command":"set_frame_sync","enabled":"true"}') null''',
]);
});
});
});

group('WebFlutterDriver with non-chrome browser', () {
Expand Down

0 comments on commit 31fd0f7

Please sign in to comment.