Revert "Revert "Driver vm service (#68654)" (#69074)" (#69077)

This reverts commit 19ce7a86af.
This commit is contained in:
Dan Field
2020-10-26 19:22:25 -07:00
committed by GitHub
parent 19ce7a86af
commit 05ab0eba19
34 changed files with 756 additions and 1162 deletions

View File

@@ -2,13 +2,11 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import 'dart:async';
import 'dart:io';
import 'package:flutter_driver/flutter_driver.dart';
import 'package:path/path.dart' as path;
import 'package:test/test.dart' hide TypeMatcher, isInstanceOf;
import 'package:vm_service_client/vm_service_client.dart';
// Connect and disconnect from the empty app.
void main() {
@@ -23,19 +21,15 @@ void main() {
group('License file check', () {
FlutterDriver driver;
IsolatesWorkaround workaround;
setUpAll(() async {
driver = await FlutterDriver.connect();
workaround = IsolatesWorkaround(driver);
await workaround.resumeIsolates();
await driver.waitUntilFirstFrameRasterized();
});
tearDownAll(() async {
if (driver != null) {
await driver.close();
await workaround.tearDown();
}
});
@@ -57,40 +51,3 @@ void main() {
});
});
}
/// Workaround for isolates being paused by driver tests.
/// https://github.com/flutter/flutter/issues/24703
class IsolatesWorkaround {
IsolatesWorkaround(this._driver);
final FlutterDriver _driver;
StreamSubscription<VMIsolateRef> _streamSubscription;
Future<void> resumeIsolates() async {
final VM vm = await _driver.serviceClient.getVM();
// Resume any paused isolate
for (final VMIsolateRef isolateRef in vm.isolates) {
final VMIsolate isolate = await isolateRef.load();
if (isolate.isPaused) {
isolate.resume();
}
}
if (_streamSubscription != null) {
return;
}
_streamSubscription = _driver.serviceClient.onIsolateRunnable
.asBroadcastStream()
.listen((VMIsolateRef isolateRef) async {
final VMIsolate isolate = await isolateRef.load();
if (isolate.isPaused) {
isolate.resume();
}
});
}
Future<void> tearDown() async {
if (_streamSubscription != null) {
await _streamSubscription.cancel();
}
}
}