forked from Samagra-Development/odk-collect-extension
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request getodk#5366 from seadowg/restore-crash
Prevent most common restore crashes
- Loading branch information
Showing
7 changed files
with
82 additions
and
42 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
31 changes: 31 additions & 0 deletions
31
collect_app/src/test/java/org/odk/collect/android/activities/FormHierarchyActivityTest.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
package org.odk.collect.android.activities | ||
|
||
import android.content.Context | ||
import android.content.Intent | ||
import androidx.lifecycle.Lifecycle | ||
import androidx.test.core.app.ActivityScenario | ||
import androidx.test.core.app.ApplicationProvider | ||
import androidx.test.ext.junit.runners.AndroidJUnit4 | ||
import org.hamcrest.MatcherAssert.assertThat | ||
import org.hamcrest.Matchers.equalTo | ||
import org.junit.Test | ||
import org.junit.runner.RunWith | ||
|
||
@RunWith(AndroidJUnit4::class) | ||
class FormHierarchyActivityTest { | ||
|
||
/** | ||
* This can happen if the app process is restored after being kicked from memory. | ||
*/ | ||
@Test | ||
fun whenFormHasNotLoadedYet_finishes() { | ||
val context = ApplicationProvider.getApplicationContext<Context>() | ||
val intent = Intent(context, FormHierarchyActivity::class.java).also { | ||
it.putExtra(FormHierarchyActivity.EXTRA_SESSION_ID, "blah") | ||
} | ||
|
||
ActivityScenario.launch<FormHierarchyActivity>(intent).use { scenario -> | ||
assertThat(scenario.state, equalTo(Lifecycle.State.DESTROYED)) | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters