diff options
Diffstat (limited to '')
-rw-r--r-- | mobile/android/geckoview/src/androidTest/java/org/mozilla/geckoview/test/ProfileLockedTest.kt | 52 |
1 files changed, 52 insertions, 0 deletions
diff --git a/mobile/android/geckoview/src/androidTest/java/org/mozilla/geckoview/test/ProfileLockedTest.kt b/mobile/android/geckoview/src/androidTest/java/org/mozilla/geckoview/test/ProfileLockedTest.kt new file mode 100644 index 0000000000..7c47ade0f7 --- /dev/null +++ b/mobile/android/geckoview/src/androidTest/java/org/mozilla/geckoview/test/ProfileLockedTest.kt @@ -0,0 +1,52 @@ +package org.mozilla.geckoview.test + +import androidx.test.ext.junit.runners.AndroidJUnit4 +import androidx.test.filters.MediumTest +import androidx.test.platform.app.InstrumentationRegistry +import org.hamcrest.CoreMatchers.equalTo +import org.junit.Test +import org.junit.runner.RunWith +import org.mozilla.geckoview.test.TestRuntimeService.RuntimeInstance +import org.mozilla.geckoview.test.rule.GeckoSessionTestRule.ClosedSessionAtStart + +@RunWith(AndroidJUnit4::class) +@MediumTest +class ProfileLockedTest : BaseSessionTest() { + private val targetContext + get() = InstrumentationRegistry.getInstrumentation().targetContext + + @Test + @ClosedSessionAtStart + fun profileLocked() { + val runtime0 = RuntimeInstance.start( + targetContext, + TestRuntimeService.instance0::class.java, + temporaryProfile.get(), + ) + + // Start the first runtime and wait until it's ready + sessionRule.waitForResult(runtime0.started) + + assertThat("The service should be connected now", runtime0.isConnected, equalTo(true)) + + // Now start a _second_ runtime with the same profile folder, this will kill the first + // runtime + val runtime1 = RuntimeInstance.start( + targetContext, + TestRuntimeService.instance1::class.java, + temporaryProfile.get(), + ) + + // Wait for the first runtime to disconnect + sessionRule.waitForResult(runtime0.disconnected) + + // GeckoRuntime will quit after killing the offending process + sessionRule.waitForResult(runtime1.quitted) + + assertThat( + "The service shouldn't be connected anymore", + runtime0.isConnected, + equalTo(false), + ) + } +} |