commit 5a194359da8104fa7498e7a29e85d49aa91b7d76 parent 6240aa495dc68abb85652a126a5a023d58a696f6 Author: Beatriz Rizental <brizental@torproject.org> Date: Tue, 14 Jan 2025 17:55:22 +0100 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. Diffstat:
| A | mobile/android/fenix/app/src/androidTest/java/org/mozilla/fenix/AppStartupTest.kt | | | 40 | ++++++++++++++++++++++++++++++++++++++++ |
1 file changed, 40 insertions(+), 0 deletions(-)
diff --git a/mobile/android/fenix/app/src/androidTest/java/org/mozilla/fenix/AppStartupTest.kt b/mobile/android/fenix/app/src/androidTest/java/org/mozilla/fenix/AppStartupTest.kt @@ -0,0 +1,40 @@ +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. + } +}