android / android/android-test

Orchestrator fails to run tests on Android Automotive / Polestar

Aperta
#555 2 commenti 0 reazioni 0 assegnatari Vedi su GitHub
Lingua principale
Java
Stelle
1.2k
Fork
342
Merge medio
11h 29m
PR unite (30g)
2

Descrizione

### 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.

Guida per i contributori

Apri la guida per i contributori

Direzione di ricerca

Inizia con AndroidTestOrchestrator.grantRuntimePermissions() e onStart(), quindi esamina il comportamento multiutente dell’emulatore Automotive utilizzando l’output fornito di adb shell pm list users. Riproduci il problema con connectedAndroidTest e verifica che l’orchestrator conceda le autorizzazioni all’utente attivo e completi l’esecuzione dei test senza gli arresti anomali segnalati.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Valutazione

Stack tecnologico
android, java
Ambito
mobile, testing-qa
Tipo di issue
Bug
Difficoltà
4/5
Tempo stimato
3-5 giorni
Stato di attività
Ferma
Chiarezza
Abbastanza chiara
Idoneità per principianti
35/100

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.