Skip to content
Snippets Groups Projects
Commit 927fcba8 authored by Beatriz Rizental's avatar Beatriz Rizental Committed by Pier Angelo Vendrame
Browse files

TB 43243: [android] Implement Android launch test

Also remove exit call from terminate function.
It causes all espresso tests to crash on exit and otherwise doesn't do anything.
parent 4ee361e8
No related branches found
Tags tor-browser-132.0a1-15.0-1-build1
1 merge request!1410BB/TB 43413: Rebased onto 132.0a1
Pipeline #257501 passed
package org.mozilla.fenix
import androidx.test.ext.junit.rules.ActivityScenarioRule
import androidx.test.ext.junit.runners.AndroidJUnit4
import androidx.test.platform.app.InstrumentationRegistry
import androidx.test.uiautomator.UiDevice
import org.junit.Rule
import org.junit.Test
import org.junit.runner.RunWith
import java.util.concurrent.CountDownLatch
import java.util.concurrent.TimeUnit
@RunWith(AndroidJUnit4::class)
class LaunchTest {
@get:Rule
var rule: ActivityScenarioRule<HomeActivity> = ActivityScenarioRule(HomeActivity::class.java)
@Test
fun appLaunchesWithoutCrash() {
val device = UiDevice.getInstance(InstrumentationRegistry.getInstrumentation())
device.waitForIdle()
// Simulate a 30-second delay
val latch = CountDownLatch(1)
Thread {
try {
Thread.sleep(30_000)
latch.countDown()
} catch (e: InterruptedException) {
e.printStackTrace()
}
}.start()
latch.await(30, TimeUnit.SECONDS)
// If we got here, the app did not crash. Test passed.
}
}
......@@ -194,7 +194,6 @@ open class FenixApplication : LocaleAwareApplication(), Provider {
fun terminate() {
onTerminate()
System.exit(0)
}
override fun onTerminate() {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment