diff --git a/packages/patrol/android/build.gradle b/packages/patrol/android/build.gradle index d7feddf65..d34afe114 100644 --- a/packages/patrol/android/build.gradle +++ b/packages/patrol/android/build.gradle @@ -70,7 +70,6 @@ android { implementation "org.http4k:http4k-client-apache" implementation "org.http4k:http4k-server-ktorcio" implementation "org.jetbrains.kotlinx:kotlinx-serialization-json:1.6.0" - implementation "org.jetbrains.kotlinx:kotlinx-coroutines-guava:1.5.2" testImplementation "org.jetbrains.kotlin:kotlin-test" } diff --git a/packages/patrol/android/src/main/kotlin/pl/leancode/patrol/AutomatorServer.kt b/packages/patrol/android/src/main/kotlin/pl/leancode/patrol/AutomatorServer.kt index 158c1c5a0..6ea616c19 100644 --- a/packages/patrol/android/src/main/kotlin/pl/leancode/patrol/AutomatorServer.kt +++ b/packages/patrol/android/src/main/kotlin/pl/leancode/patrol/AutomatorServer.kt @@ -208,6 +208,6 @@ class AutomatorServer(private val automation: Automator) : NativeAutomatorServer } override fun markPatrolAppServiceReady() { - PatrolServer.appReady.set(true) + PatrolServer.appReady.open() } } diff --git a/packages/patrol/android/src/main/kotlin/pl/leancode/patrol/PatrolJUnitRunner.java b/packages/patrol/android/src/main/kotlin/pl/leancode/patrol/PatrolJUnitRunner.java index 1109f60bf..03c969a7e 100644 --- a/packages/patrol/android/src/main/kotlin/pl/leancode/patrol/PatrolJUnitRunner.java +++ b/packages/patrol/android/src/main/kotlin/pl/leancode/patrol/PatrolJUnitRunner.java @@ -96,13 +96,8 @@ public PatrolAppServiceClient createAppServiceClient() { public void waitForPatrolAppService() { final String TAG = "PatrolJUnitRunner.setUp(): "; - try { - Logger.INSTANCE.i(TAG + "Waiting for PatrolAppService to report its readiness..."); - PatrolServer.Companion.getAppReadyFuture().get(); - } catch (InterruptedException | ExecutionException e) { - Logger.INSTANCE.e(TAG + "Exception was thrown when waiting for appReady: ", e); - throw new RuntimeException(e); - } + Logger.INSTANCE.i(TAG + "Waiting for PatrolAppService to report its readiness..."); + PatrolServer.Companion.getAppReady().block(); Logger.INSTANCE.i(TAG + "PatrolAppService is ready to report Dart tests"); } diff --git a/packages/patrol/android/src/main/kotlin/pl/leancode/patrol/PatrolServer.kt b/packages/patrol/android/src/main/kotlin/pl/leancode/patrol/PatrolServer.kt index 3e8d395a8..fc82c0870 100644 --- a/packages/patrol/android/src/main/kotlin/pl/leancode/patrol/PatrolServer.kt +++ b/packages/patrol/android/src/main/kotlin/pl/leancode/patrol/PatrolServer.kt @@ -1,13 +1,12 @@ package pl.leancode.patrol +import android.os.ConditionVariable import androidx.test.platform.app.InstrumentationRegistry -import com.google.common.util.concurrent.SettableFuture import org.http4k.core.ContentType import org.http4k.filter.ServerFilters import org.http4k.server.Http4kServer import org.http4k.server.KtorCIO import org.http4k.server.asServer -import java.util.concurrent.Future class PatrolServer { private val envPortKey = "PATROL_PORT" @@ -44,9 +43,7 @@ class PatrolServer { } companion object { - val appReady: SettableFuture = SettableFuture.create() - val appReadyFuture: Future - get() = appReady + val appReady: ConditionVariable = ConditionVariable() } }