android / android/android-test

LocalActivityInvoker#getActivityResult() should wait for Activity with timeout

Open
#1,515 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Java
Stars
1.2k
Forks
342
Avg merge
11h 29m
Merged PRs (30d)
2

Description

### Description

LocalActivityInvoker#getActivityResult() throws exception immediately if Activity is not finished when this method is invoked, while InstrumentationActivityInvoker#getActivityResult() waits for Activity to be finished with a timeout duration of ActivityLifecycleTimeout.

This behavior was by design as Robolectric test is usually run in a single thread. However, there is a use case where a test has two threads and one thread is computing an expensive operation while the test main thread is waiting.

To reduce the behavior difference between Local and Device test, LocalActivityInvoker#getActivityResult() should wait for Activity with timeout.

Contributor guide

Open the contributing guide

Research direction

Start with LocalActivityInvoker#getActivityResult() and compare its behavior with InstrumentationActivityInvoker#getActivityResult(), using ActivityLifecycleTimeout as the timeout reference. The change is complete when the local invoker waits for the Activity result up to the timeout instead of failing immediately, while preserving the documented behavior for tests.

Written by the indexing model from the issue text.

Assessment

Tech stack
android, java
Domain
mobile-dev, testing
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.