Unverified Commit 31fd0f75 authored by Nguyen Phuc Loi's avatar Nguyen Phuc Loi Committed by GitHub

[flutter_driver] Remove `runUnsynchronized` in `VMServiceFlutterDriver` (#87467)

parent 52bf9dbb
......@@ -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 {
......
......@@ -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', () {
......@@ -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', () {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment