brizental pushed to branch tor-browser-152.0a1-16.0-2 at The Tor Project / Applications / Tor Browser Commits: 8bf5e1ff by Beatriz Rizental at 2026-06-24T21:04:06+02:00 fixup! TB 43243: [android] Implement Android launch test tor-browser-bundle-testsuite#40109: Get AndroidTest test working again. Also create a base TestRule for future TorBrowser tests. - - - - - 2 changed files: - mobile/android/fenix/app/src/androidTest/java/org/mozilla/fenix/AppStartupTest.kt → mobile/android/fenix/app/src/androidTest/java/org/mozilla/fenix/torbrowser/AppStartupTest.kt - + mobile/android/fenix/app/src/androidTest/java/org/mozilla/fenix/torbrowser/HomeActivityScenarioRule.kt Changes: ===================================== mobile/android/fenix/app/src/androidTest/java/org/mozilla/fenix/AppStartupTest.kt → mobile/android/fenix/app/src/androidTest/java/org/mozilla/fenix/torbrowser/AppStartupTest.kt ===================================== @@ -1,6 +1,5 @@ -package org.mozilla.fenix +package org.mozilla.fenix.torbrowser -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 @@ -10,12 +9,11 @@ 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) + var rule = HomeActivityScenarioRule() @Test fun appLaunchesWithoutCrash() { ===================================== mobile/android/fenix/app/src/androidTest/java/org/mozilla/fenix/torbrowser/HomeActivityScenarioRule.kt ===================================== @@ -0,0 +1,33 @@ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +package org.mozilla.fenix.torbrowser + +import androidx.test.ext.junit.rules.ActivityScenarioRule +import org.junit.rules.TestRule +import org.junit.runner.Description +import org.junit.runners.model.Statement +import org.mozilla.fenix.HomeActivity +import org.mozilla.fenix.ext.components + +class HomeActivityScenarioRule : TestRule { + private val delegate = ActivityScenarioRule<HomeActivity>(HomeActivity::class.java) + + val scenario get() = delegate.scenario + + // ActivityScenarioRule waits for the DESTROYED lifecycle state during teardown, which means + // HomeActivity.onDestroy runs synchronously before the rule returns. onDestroy calls shutDown() -> + // exitProcess(0) when isFinishing, which kills the instrumentation process. Setting this flag + // prevents that code path so tests can report their results normally. + override fun apply(base: Statement, description: Description): Statement { + return delegate.apply(object : Statement() { + override fun evaluate() { + delegate.scenario.onActivity { activity -> + activity.applicationContext.components.notificationsDelegate.shouldShutDownWithOnDestroyWhenIsFinishing = false + } + base.evaluate() + } + }, description) + } +} View it on GitLab: https://gitlab.torproject.org/tpo/applications/tor-browser/-/commit/8bf5e1ff... -- View it on GitLab: https://gitlab.torproject.org/tpo/applications/tor-browser/-/commit/8bf5e1ff... You're receiving this email because of your account on gitlab.torproject.org. Manage all notifications: https://gitlab.torproject.org/-/profile/notifications | Help: https://gitlab.torproject.org/help