Commit 31c43a08 authored by Michael Thiessen's avatar Michael Thiessen Committed by Commit Bot

Fix state leaked by ExternalNavigationHandler unit tests

We were leaking the overridden ApplicationContext, leading to other
tests failing when interacting with mocks created by the
ExternalNavigationHandler.

Not sure why this isn't occurring on bots, but it does locally.

Change-Id: Ie283a6f96f69dec2a8e70c4ed11e025f6e475c68
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2353121Reviewed-by: default avatarYaron Friedman <yfriedman@chromium.org>
Commit-Queue: Michael Thiessen <mthiesse@chromium.org>
Cr-Commit-Position: refs/heads/master@{#797433}
parent 99f34300
......@@ -23,6 +23,7 @@ import android.test.mock.MockPackageManager;
import androidx.browser.customtabs.CustomTabsIntent;
import androidx.test.filters.SmallTest;
import org.junit.After;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
......@@ -147,6 +148,8 @@ public class ExternalNavigationHandlerTest {
private final TestExternalNavigationDelegate mDelegate;
private ExternalNavigationHandlerForTesting mUrlHandler;
private Context mApplicationContextToRestore;
public ExternalNavigationHandlerTest() {
mDelegate = new TestExternalNavigationDelegate();
mUrlHandler = new ExternalNavigationHandlerForTesting(mDelegate);
......@@ -154,12 +157,19 @@ public class ExternalNavigationHandlerTest {
@Before
public void setUp() {
mApplicationContextToRestore = ContextUtils.getApplicationContext();
mContext = new TestContext(InstrumentationRegistry.getTargetContext(), mDelegate);
ContextUtils.initApplicationContextForTests(mContext);
NativeLibraryTestUtils.loadNativeLibraryNoBrowserProcess();
}
@After
public void tearDown() {
ContextUtils.initApplicationContextForTests(mApplicationContextToRestore);
}
@Test
@SmallTest
public void testStartActivityToTrustedPackageWithoutUserGesture() {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment