android / android/android-test
Test crashes if intent is mocked in onDestroy on S
- Dominant language
- Java
- Stars
- 1.2k
- Forks
- 342
- Avg merge
- 11h 29m
- Merged PRs (30d)
- 2
Description
### Description
On a S device, when using `Intents.intending(...).respondWith(something)`, and the intent is sent from an Activity onDestroy, the test will crash with:
```
java.lang.IllegalArgumentException: Activity client record must not be null to execute transaction item
at android.app.servertransaction.ActivityTransactionItem.getActivityClientRecord(ActivityTransactionItem.java:90)
at android.app.servertransaction.ActivityTransactionItem.getActivityClientRecord(ActivityTransactionItem.java:58)
[...]
```
This seems to happen because there is no activity to post the mock ActivityResult to.
### Steps to Reproduce
See sample change: https://android-review.googlesource.com/c/platform/packages/modules/CaptivePortalLogin/+/1835092
Run with "atest TestPocTest" with a S (beta) device connected
### Expected Results
The test passes
### Actual Results
The test crashes with "Activity client record must not be null to execute transaction item"
### AndroidX Test and Android OS Versions
androidx from the AOSP repo (3.3.0-beta02 ?), Android S beta 3 (also seen on later builds). This does not happen when running on a R device.
### Link to a public git repo demonstrating the problem:
https://android-review.googlesource.com/c/platform/packages/modules/CaptivePortalLogin/+/1835092
Contributor guide
Research direction
Reproduce the failure with atest TestPocTest on an Android S device, using Intents.intending(...).respondWith(something) when the intent is sent from Activity.onDestroy; compare with Android R. Trace the ActivityResult handling around the reported ActivityTransactionItem.getActivityClientRecord stack frames, and consider the issue done when the test passes on S without the crash.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- android, java
- Domain
- mobile-dev, testing
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100