diff --git a/packages/flutter_driver/lib/src/driver/vmservice_driver.dart b/packages/flutter_driver/lib/src/driver/vmservice_driver.dart index e75dca3ee2..54dc392004 100644 --- a/packages/flutter_driver/lib/src/driver/vmservice_driver.dart +++ b/packages/flutter_driver/lib/src/driver/vmservice_driver.dart @@ -485,18 +485,6 @@ class VMServiceFlutterDriver extends FlutterDriver { } } - @override - Future runUnsynchronized(Future 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 forceGC() async { try { diff --git a/packages/flutter_driver/test/src/real_tests/flutter_driver_test.dart b/packages/flutter_driver/test/src/real_tests/flutter_driver_test.dart index 7dd1e3a8b1..d031085024 100644 --- a/packages/flutter_driver/test/src/real_tests/flutter_driver_test.dart +++ b/packages/flutter_driver/test/src/real_tests/flutter_driver_test.dart @@ -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({}); + fakeClient.responses['set_frame_sync'] = makeFakeResponse({}); + + await driver.runUnsynchronized(() async { + await driver.waitFor(find.byTooltip('foo'), timeout: _kTestTimeout); + }); + + expect(fakeClient.commandLog, [ + '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({'text': 'hello'})); + fakeConnection.responses['set_frame_sync'] = jsonEncode(makeFakeResponse({})); + + await driver.runUnsynchronized(() async { + await driver.waitFor(find.byTooltip('foo'), timeout: _kTestTimeout); + }); + + expect(fakeConnection.commandLog, [ + 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', () {