Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Avoid using CompletableFuture #27398

Merged
merged 1 commit into from
Jul 14, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions testing/scenario_app/android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ dependencies {
implementation 'com.google.android.material:material:1.0.0'
implementation 'androidx.lifecycle:lifecycle-common-java8:2.2.0-alpha01'
implementation "com.squareup.leakcanary:leakcanary-android:$leakcanary_version"
implementation 'com.google.guava:guava:28.1-android'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test:runner:1.2.0'
androidTestImplementation 'androidx.test:rules:1.2.0'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@
import androidx.test.InstrumentationRegistry;
import androidx.test.internal.runner.junit4.statement.UiThreadStatement;
import androidx.test.runner.AndroidJUnit4;
import com.google.common.util.concurrent.SettableFuture;
import io.flutter.embedding.engine.FlutterEngine;
import io.flutter.embedding.engine.dart.DartExecutor;
import java.util.Arrays;
import java.util.Locale;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;
Expand All @@ -34,7 +34,7 @@ public void smokeTestEngineLaunch() throws Throwable {
// as @UiThreadTest because having the message handler and the CompletableFuture both being
// on the same thread will create deadlocks.
UiThreadStatement.runOnUiThread(() -> engine.set(new FlutterEngine(applicationContext)));
CompletableFuture<Boolean> statusReceived = new CompletableFuture<>();
SettableFuture<Boolean> statusReceived = new SettableFuture<>();

// Resolve locale to `en_US`.
// This is required, so `window.locale` in populated in dart.
Expand All @@ -49,8 +49,7 @@ public void smokeTestEngineLaunch() throws Throwable {
.get()
.getDartExecutor()
.setMessageHandler(
"waiting_for_status",
(byteBuffer, binaryReply) -> statusReceived.complete(Boolean.TRUE));
"waiting_for_status", (byteBuffer, binaryReply) -> statusReceived.set(Boolean.TRUE));

// Launching the entrypoint will run the Dart code that sends the "waiting_for_status" platform
// message.
Expand Down