android / android/android-test

Orchestrator fails to run tests on Android Automotive / Polestar

Offen
#555 2 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen
Vorherrschende Sprache
Java
Sterne
1.2k
Forks
342
Ø Merge
11 Std. 29 Min.
Gemergte PRs (30 T.)
2

Beschreibung

### Description
The Androidx Test Orchestrator fails to run on an **Automotive Emulator** because it fails to grant the requested runtime permissions (permission.WRITE_EXTERNAL_STORAGE, permission.READ_EXTERNAL_STORAGE).

### Steps to Reproduce
* Install the Polestar Automotive Emulator: https://developer.polestar.com/
* Create a new project with the wizard: File -> New -> New Project
* Add the test orchestrator dependencies to the project's build.gradle:
```
androidTestImplementation 'androidx.test:runner:1.2.0'
androidTestUtil 'androidx.test:orchestrator:1.2.0'
```
* Start the Automotive emulator
* Run `./gradlew connectedAndroidTest`

### Expected Results
The tests should run

### Actual Results
The test orchestrator crashes and no tests are executed.
Logcat:
```
2020-03-03 21:43:53.623 18314-18330/? E/AndroidTestOrchestrator: Fatal exception when setting up.
java.lang.IllegalStateException: Permission requested but not granted!
at androidx.test.orchestrator.AndroidTestOrchestrator.grantRuntimePermissions(AndroidTestOrchestrator.java:231)
at androidx.test.orchestrator.AndroidTestOrchestrator.onStart(AndroidTestOrchestrator.java:201)
at android.app.Instrumentation$InstrumentationThread.run(Instrumentation.java:2145)
2020-03-03 21:43:53.630 18314-18330/? E/AndroidRuntime: FATAL EXCEPTION: Instr: androidx.test.orchestrator.AndroidTestOrchestrator
Process: androidx.test.orchestrator, PID: 18314
java.lang.NullPointerException: Attempt to invoke virtual method 'android.content.Context android.app.Instrumentation.getContext()' on a null object reference
at androidx.test.orchestrator.listeners.OrchestrationXmlTestRunListener.createOutputResultStream(OrchestrationXmlTestRunListener.java:253)
at androidx.test.orchestrator.listeners.OrchestrationXmlTestRunListener.generateDocument(OrchestrationXmlTestRunListener.java:191)
at androidx.test.orchestrator.listeners.OrchestrationXmlTestRunListener.orchestrationRunFinished(OrchestrationXmlTestRunListener.java:178)
at androidx.test.orchestrator.AndroidTestOrchestrator.finish(AndroidTestOrchestrator.java:443)
at androidx.test.orchestrator.AndroidTestOrchestrator.onStart(AndroidTestOrchestrator.java:210)
at android.app.Instrumentation$InstrumentationThread.run(Instrumentation.java:2145)
```

### AndroidX Test and Android OS Versions
Android **Automotive 9 / Polestar Emulator**
Android Test Orchestrator 1.2.0 (also tested without success on 1.3.0-alpha04)

### Link to a public git repo demonstrating the problem:
Not dependent on the app code, but on the **Automotive** emulator.

### Debug
I think this crash occurs because the Automotive emulator has two users set up, whereas a standard Android emulator only has one user.
On Automotive, `adb shell pm list users` prints:
```
Users:
UserInfo{0:Owner:13} running
UserInfo{10:Owner:12} running
```

On standard Android, `adb shell pm list users` prints:
```
Users:
UserInfo{0:Owner:13} running
```
I suspect that when the AndroidTestOrchestrator tries to grant the needed runtime permissions, these get assigned to the wrong user (ID 0), while it should be the user with ID 10.

Beitragsleitfaden

Beitragsleitfaden öffnen

Rechercherichtung

Beginnen Sie mit AndroidTestOrchestrator.grantRuntimePermissions() und onStart(), und untersuchen Sie anschließend das Verhalten mehrerer Benutzer des Automotive-Emulators anhand der bereitgestellten Ausgabe von adb shell pm list users. Reproduzieren Sie das Problem mit connectedAndroidTest und überprüfen Sie, dass der Orchestrator dem aktiven Benutzer Berechtigungen erteilt und den Testlauf ohne die gemeldeten Abstürze abschließt.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Bewertung

Tech-Stack
android, java
Bereich
mobile, testing-qa
Issue-Typ
Bug
Schwierigkeit
4/5
Geschätzter Aufwand
3-5 Tage
Aktivitätsstatus
Veraltet
Klarheit
Größtenteils klar
Anfängerfreundlichkeit
35/100

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.