mirror of
https://github.com/GitJournal/GitJournal.git
synced 2025-06-26 16:46:51 +08:00
Remove isolates_workaround
No longer required
This commit is contained in:
@ -1,67 +0,0 @@
|
||||
import 'dart:async';
|
||||
|
||||
import 'package:flutter_driver/flutter_driver.dart';
|
||||
|
||||
/// Workaround for bug: https://github.com/flutter/flutter/issues/24703
|
||||
///
|
||||
/// USAGE
|
||||
///
|
||||
/// ```
|
||||
/// FlutterDriver driver;
|
||||
/// IsolatesWorkaround workaround;
|
||||
///
|
||||
/// setUpAll(() async {
|
||||
/// driver = await FlutterDriver.connect();
|
||||
/// workaround = IsolatesWorkaround(driver);
|
||||
/// await workaround.resumeIsolates();
|
||||
/// });
|
||||
///
|
||||
/// tearDownAll(() async {
|
||||
/// if (driver != null) {
|
||||
/// await driver.close();
|
||||
/// await workaround.tearDown();
|
||||
/// }
|
||||
/// });
|
||||
/// ```
|
||||
class IsolatesWorkaround {
|
||||
IsolatesWorkaround(this._driver, {this.log = false});
|
||||
final FlutterDriver _driver;
|
||||
final bool log;
|
||||
StreamSubscription _streamSubscription;
|
||||
|
||||
/// workaround for isolates
|
||||
/// https://github.com/flutter/flutter/issues/24703
|
||||
Future<void> resumeIsolates() async {
|
||||
final vm = await _driver.serviceClient.getVM();
|
||||
// // unpause any paused isolated
|
||||
for (final isolateRef in vm.isolates) {
|
||||
final isolate = await isolateRef.load();
|
||||
if (isolate.isPaused) {
|
||||
isolate.resume();
|
||||
if (log) {
|
||||
print("Resuming isolate: ${isolate.numberAsString}:${isolate.name}");
|
||||
}
|
||||
}
|
||||
}
|
||||
if (_streamSubscription != null) {
|
||||
return;
|
||||
}
|
||||
_streamSubscription = _driver.serviceClient.onIsolateRunnable
|
||||
.asBroadcastStream()
|
||||
.listen((isolateRef) async {
|
||||
final isolate = await isolateRef.load();
|
||||
if (isolate.isPaused) {
|
||||
isolate.resume();
|
||||
if (log) {
|
||||
print("Resuming isolate: ${isolate.numberAsString}:${isolate.name}");
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
Future<void> tearDown() async {
|
||||
if (_streamSubscription != null) {
|
||||
await _streamSubscription.cancel();
|
||||
}
|
||||
}
|
||||
}
|
@ -3,12 +3,9 @@ import 'package:screenshots/screenshots.dart';
|
||||
import 'package:test/test.dart';
|
||||
import 'package:time/time.dart';
|
||||
|
||||
import 'isolates_workaround.dart';
|
||||
|
||||
void main() {
|
||||
group('Test', () {
|
||||
FlutterDriver driver;
|
||||
IsolatesWorkaround workaround;
|
||||
|
||||
int screenshotNum = 0;
|
||||
final config = Config();
|
||||
@ -16,20 +13,10 @@ void main() {
|
||||
// Connect to the Flutter driver before running any tests
|
||||
setUpAll(() async {
|
||||
driver = await FlutterDriver.connect();
|
||||
workaround = IsolatesWorkaround(driver);
|
||||
await workaround.resumeIsolates();
|
||||
|
||||
await Future.delayed(15.seconds);
|
||||
});
|
||||
|
||||
// Close the connection to the driver after the tests have completed
|
||||
tearDownAll(() async {
|
||||
if (driver != null) {
|
||||
await driver.close();
|
||||
await workaround.tearDown();
|
||||
}
|
||||
});
|
||||
|
||||
Future _takeScreenshot() async {
|
||||
screenshotNum += 1;
|
||||
await screenshot(driver, config, screenshotNum.toString());
|
||||
|
Reference in New Issue
Block a user