Skip to content

Commit 0261561

Browse files
brettchabotcopybara-androidxtest
authored andcommitted
Internal google build file change.
Enable EspressoWithPausedTest to run in INSTRUMENTATION_TEST looper mode again inside google. It was previously disabled due to espresso bug. PiperOrigin-RevId: 703634483
1 parent f5ff2c3 commit 0261561

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed

espresso/CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ The following artifacts were released:
1616

1717
**Bug Fixes**
1818

19+
* Fix deadlock in espresso in Robolectric INSTRUMENTATION_TEST + paused looper.
20+
1921
**New Features**
2022

2123
**Breaking Changes**

espresso/core/java/androidx/test/espresso/base/ThreadPoolExecutorExtractor.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@
1919
import android.os.Handler;
2020
import android.os.Looper;
2121
import androidx.annotation.Nullable;
22+
import androidx.test.internal.platform.ServiceLoaderWrapper;
23+
import androidx.test.internal.platform.os.ControlledLooper;
2224
import java.lang.reflect.Field;
2325
import java.util.concurrent.Callable;
2426
import java.util.concurrent.CountDownLatch;
@@ -42,6 +44,10 @@ final class ThreadPoolExecutorExtractor {
4244
private static final String MODERN_ASYNC_TASK_FIELD_NAME = "THREAD_POOL_EXECUTOR";
4345
private final Handler mainHandler;
4446

47+
private final ControlledLooper controlledLooper =
48+
ServiceLoaderWrapper.loadSingleService(
49+
ControlledLooper.class, () -> ControlledLooper.NO_OP_CONTROLLED_LOOPER);
50+
4551
@Inject
4652
ThreadPoolExecutorExtractor(Looper looper) {
4753
mainHandler = new Handler(looper);
@@ -85,6 +91,7 @@ public void run() {
8591
}
8692
});
8793
try {
94+
controlledLooper.drainMainThreadUntilIdle();
8895
latch.await();
8996
} catch (InterruptedException ie) {
9097
if (!futureToRun.isDone()) {

0 commit comments

Comments
 (0)