Skip to content
This repository was archived by the owner on Jun 14, 2023. It is now read-only.

Commit

Permalink
mobile: Add workaround for Flutter issue #24703
Browse files Browse the repository at this point in the history
  • Loading branch information
abustany committed Dec 15, 2019
1 parent ee2331d commit a97debb
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 4 deletions.
4 changes: 3 additions & 1 deletion mobile/test_driver/clone_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ void main() {
FlutterDriver driver;
TransactionCheck txcheck;
String accountId;
void Function() unpauseIsolateCleanup;

setUpAll(() async {
final accounts = await listServerAccounts();
Expand All @@ -23,7 +24,7 @@ void main() {

// Connects to the app
driver = await FlutterDriver.connect();
unpauseIsolates(driver);
unpauseIsolateCleanup = await unpauseIsolates(driver);
txcheck = TransactionCheck(driver);
});

Expand Down Expand Up @@ -63,6 +64,7 @@ void main() {
});

tearDownAll(() async {
unpauseIsolateCleanup();
await stopFlouzeServer();
await disableReversePortForwarding();

Expand Down
10 changes: 9 additions & 1 deletion mobile/test_driver/create_populate_share_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,20 @@ void main() {
group('Create, populate and share an account', () {
FlutterDriver driver;
TransactionCheck txcheck;
void Function() unpauseIsolateCleanup;

setUpAll(() async {
await startFlouzeServer(deleteDataFirst: true);
await enableReversePortForwarding();

// Connects to the app
driver = await FlutterDriver.connect();
unpauseIsolates(driver);
unpauseIsolateCleanup = await unpauseIsolates(driver);
txcheck = TransactionCheck(driver);
});

tearDownAll(() async {
unpauseIsolateCleanup();
await stopFlouzeServer();
await disableReversePortForwarding();

Expand Down Expand Up @@ -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'));
Expand Down
8 changes: 6 additions & 2 deletions mobile/test_driver/test_utils.dart
Original file line number Diff line number Diff line change
Expand Up @@ -186,20 +186,24 @@ Future<List<Flouze.Transaction>> listServerTransactions(String accountName) {
}

// Workaround for https://github.com/flutter/flutter/issues/24703
Future<void> unpauseIsolates(FlutterDriver driver) async {
Future<void Function()> unpauseIsolates(FlutterDriver driver) async {
(await driver.serviceClient.getVM()).isolates.forEach((isolateRef) async {
final isolate = await isolateRef.load();
if (isolate.isPaused) {
isolate.resume();
}
});

driver.serviceClient.onIsolateRunnable
final sub = driver.serviceClient.onIsolateRunnable
.asBroadcastStream()
.listen((isolateRef) async {
final isolate = await isolateRef.load();
if (isolate.isPaused) {
isolate.resume();
}
});

return () {
sub.cancel();
};
}

0 comments on commit a97debb

Please sign in to comment.