Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Only drain main looper when it is paused. #2320

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

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