android / android/android-test
finish() from onStop() doesn't set ActivityScenario's state to DESTROYED
- Lingua principale
- Java
- Stelle
- 1.2k
- Fork
- 342
- Merge medio
- 11h 29m
- PR unite (30g)
- 2
Descrizione
### Description
```
public class FinishOnStopActivity extends Activity {
@Override
protected void onStop() {
super.onStop();
finish();
}
}
```
```
...
@Test
public void finishOnStopActivityShouldBeDestroyed() throws Exception {
try (ActivityScenario scenario = ActivityScenario.launch(FinishOnStopActivity.class)) {
// Call onStop()
scenario.moveToState(State.CREATED);
ShadowLooper.runUiThreadTasks();
// This line succeeds, but the DESTROYED check fails.
// scenario.onActivity(activity -> assertThat(activity.isFinishing()).isTrue());
assertThat(scenario.getState()).isEqualTo(State.DESTROYED);
}
}
...
```
With this test, the State is actually CREATED even though the activity is marked as finishing.
### Expected Results
The test should pass, since the activity is being destroyed.
### Actual Results
The test doesn't pass, the state remains `CREATED`.
### AndroidX Test and Android OS Versions
1.4.0-beta02
I tested on Robolectric
Guida per i contributori
Apri la guida per i contributori
Direzione di ricerca
Inizia con la transizione di stato di ActivityScenario esercitata dalla riproduzione di FinishOnStopActivity ed esegui il test fornito su Robolectric. Traccia cosa succede dopo moveToState(State.CREATED) e le attività del thread UI accodate. Il lavoro è completo quando un’attività che chiama finish() da onStop() viene segnalata come State.DESTROYED anziché CREATED.
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à
- 3/5
- Tempo stimato
- 1-2 giorni
- Stato di attività
- Ferma
- Chiarezza
- Abbastanza chiara
- Idoneità per principianti
- 35/100