From a97debb0c46f1c8b88ec2983a90ce83198faf849 Mon Sep 17 00:00:00 2001 From: Adrien Bustany Date: Sun, 15 Dec 2019 22:03:45 +0100 Subject: [PATCH] mobile: Add workaround for Flutter issue #24703 --- mobile/test_driver/clone_test.dart | 4 +++- mobile/test_driver/create_populate_share_test.dart | 10 +++++++++- mobile/test_driver/test_utils.dart | 8 ++++++-- 3 files changed, 18 insertions(+), 4 deletions(-) diff --git a/mobile/test_driver/clone_test.dart b/mobile/test_driver/clone_test.dart index 44e8c78..32a6ddc 100644 --- a/mobile/test_driver/clone_test.dart +++ b/mobile/test_driver/clone_test.dart @@ -11,6 +11,7 @@ void main() { FlutterDriver driver; TransactionCheck txcheck; String accountId; + void Function() unpauseIsolateCleanup; setUpAll(() async { final accounts = await listServerAccounts(); @@ -23,7 +24,7 @@ void main() { // Connects to the app driver = await FlutterDriver.connect(); - unpauseIsolates(driver); + unpauseIsolateCleanup = await unpauseIsolates(driver); txcheck = TransactionCheck(driver); }); @@ -63,6 +64,7 @@ void main() { }); tearDownAll(() async { + unpauseIsolateCleanup(); await stopFlouzeServer(); await disableReversePortForwarding(); diff --git a/mobile/test_driver/create_populate_share_test.dart b/mobile/test_driver/create_populate_share_test.dart index 54a522a..f455bb0 100644 --- a/mobile/test_driver/create_populate_share_test.dart +++ b/mobile/test_driver/create_populate_share_test.dart @@ -10,6 +10,7 @@ void main() { group('Create, populate and share an account', () { FlutterDriver driver; TransactionCheck txcheck; + void Function() unpauseIsolateCleanup; setUpAll(() async { await startFlouzeServer(deleteDataFirst: true); @@ -17,11 +18,12 @@ void main() { // Connects to the app driver = await FlutterDriver.connect(); - unpauseIsolates(driver); + unpauseIsolateCleanup = await unpauseIsolates(driver); txcheck = TransactionCheck(driver); }); tearDownAll(() async { + unpauseIsolateCleanup(); await stopFlouzeServer(); await disableReversePortForwarding(); @@ -193,24 +195,30 @@ void main() { // Return to the account list page, where we started await pressBackButton(); }); + /* }); group('Create and delete an account', () { FlutterDriver driver; + void Function() unpauseIsolateCleanup; setUpAll(() async { await enableReversePortForwarding(); // Connects to the app driver = await FlutterDriver.connect(); + unpauseIsolateCleanup = await unpauseIsolates(driver); }); tearDownAll(() async { + unpauseIsolateCleanup(); + if (driver != null) { // Closes the connection driver.close(); } }); + */ test('create an account', () async { await driver.waitForAbsent(find.byValueKey('account-list-loading')); diff --git a/mobile/test_driver/test_utils.dart b/mobile/test_driver/test_utils.dart index aa424db..48d17dd 100644 --- a/mobile/test_driver/test_utils.dart +++ b/mobile/test_driver/test_utils.dart @@ -186,7 +186,7 @@ Future> listServerTransactions(String accountName) { } // Workaround for https://github.com/flutter/flutter/issues/24703 -Future unpauseIsolates(FlutterDriver driver) async { +Future unpauseIsolates(FlutterDriver driver) async { (await driver.serviceClient.getVM()).isolates.forEach((isolateRef) async { final isolate = await isolateRef.load(); if (isolate.isPaused) { @@ -194,7 +194,7 @@ Future unpauseIsolates(FlutterDriver driver) async { } }); - driver.serviceClient.onIsolateRunnable + final sub = driver.serviceClient.onIsolateRunnable .asBroadcastStream() .listen((isolateRef) async { final isolate = await isolateRef.load(); @@ -202,4 +202,8 @@ Future unpauseIsolates(FlutterDriver driver) async { isolate.resume(); } }); + + return () { + sub.cancel(); + }; }