Skip to content

Conversation

copybara-service[bot]
Copy link

Only drain main looper when it is paused.

ControlledLooper.drainMainThreadUntilIdle was created
so Robolectric can manually execute tasks when main looper is paused.

Now with the introduction of INSTRUMENTATION_TEST looper mode with a
free running looper, it doesn't make sense to always idle the main looper,
and could lead to deviation of behavior between a test run with Robolectric
INSTRUMENTATION_TEST mode and real android.

This commit changes drainMainThreadUntilIdle so its a no-op if main looper
is not paused.

ControlledLooper.drainMainThreadUntilIdle was created
so Robolectric can manually execute tasks when main looper is paused.

Now with the introduction of INSTRUMENTATION_TEST looper mode with a
free running looper, it doesn't make sense to always idle the main looper,
and could lead to deviation of behavior between a test run with Robolectric
INSTRUMENTATION_TEST mode and real android.

This commit changes drainMainThreadUntilIdle so its a no-op if main looper
is not paused.

PiperOrigin-RevId: 703634485
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant