Commit 7838d652 authored by Adithya Srinivasan's avatar Adithya Srinivasan Committed by Commit Bot

Portals: Override LocationUtils in android portals tests

Some permissions tests rely on a prompt being shown when requesting
location access, but location access is automatically denied when
geolocation is turned off in system settings. This causes flakes on
certain bots that don't have geolocation enabled.

Bug: 1094586
Change-Id: I08a6b5add43a90ea40ad99ec5272373ceaf03ad7
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2246925Reviewed-by: default avatarDavid Trainor <dtrainor@chromium.org>
Commit-Queue: Adithya Srinivasan <adithyas@chromium.org>
Cr-Commit-Position: refs/heads/master@{#779352}
parent b0600054
...@@ -49,6 +49,7 @@ import org.chromium.chrome.browser.tab.Tab; ...@@ -49,6 +49,7 @@ import org.chromium.chrome.browser.tab.Tab;
import org.chromium.chrome.test.ChromeActivityTestRule; import org.chromium.chrome.test.ChromeActivityTestRule;
import org.chromium.chrome.test.ChromeJUnit4ClassRunner; import org.chromium.chrome.test.ChromeJUnit4ClassRunner;
import org.chromium.chrome.test.util.browser.webapps.WebappTestPage; import org.chromium.chrome.test.util.browser.webapps.WebappTestPage;
import org.chromium.components.location.LocationUtils;
import org.chromium.components.permissions.PermissionDialogController; import org.chromium.components.permissions.PermissionDialogController;
import org.chromium.content_public.browser.WebContents; import org.chromium.content_public.browser.WebContents;
import org.chromium.content_public.browser.test.util.Coordinates; import org.chromium.content_public.browser.test.util.Coordinates;
...@@ -80,11 +81,20 @@ public class PortalsTest { ...@@ -80,11 +81,20 @@ public class PortalsTest {
@Before @Before
public void setUp() { public void setUp() {
mTestServer = EmbeddedTestServer.createAndStartServer(InstrumentationRegistry.getContext()); mTestServer = EmbeddedTestServer.createAndStartServer(InstrumentationRegistry.getContext());
// Some devices have geolocation disabled, so override LocationUtils to always show
// geolocation as enabled to prevent flakes in the permissions tests.
LocationUtils.setFactory(() -> new LocationUtils() {
@Override
public boolean isSystemLocationSettingEnabled() {
return true;
}
});
} }
@After @After
public void tearDown() { public void tearDown() {
mTestServer.stopAndDestroyServer(); mTestServer.stopAndDestroyServer();
LocationUtils.setFactory(null);
} }
private class TabContentsSwapObserver extends EmptyTabObserver { private class TabContentsSwapObserver extends EmptyTabObserver {
......
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