Commit c921ea04 authored by Finnur Thorarinsson's avatar Finnur Thorarinsson Committed by Commit Bot

[Android] Site Settings: Add NFC and Bluetooth test coverage for WebsitePermissionsFetcher

Bug: 960398
Change-Id: I750f8d18a5cb71a10e9e90a7174eb60f45dd1c95
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2115618Reviewed-by: default avatarReilly Grant <reillyg@chromium.org>
Commit-Queue: Finnur Thorarinsson <finnur@chromium.org>
Cr-Commit-Position: refs/heads/master@{#752660}
parent 80f5d675
...@@ -17,6 +17,8 @@ import org.junit.runner.RunWith; ...@@ -17,6 +17,8 @@ import org.junit.runner.RunWith;
import org.chromium.base.Callback; import org.chromium.base.Callback;
import org.chromium.base.test.util.CallbackHelper; import org.chromium.base.test.util.CallbackHelper;
import org.chromium.base.test.util.CommandLineFlags;
import org.chromium.chrome.browser.flags.ChromeSwitches;
import org.chromium.chrome.test.ChromeBrowserTestRule; import org.chromium.chrome.test.ChromeBrowserTestRule;
import org.chromium.chrome.test.ChromeJUnit4ClassRunner; import org.chromium.chrome.test.ChromeJUnit4ClassRunner;
import org.chromium.chrome.test.util.browser.Features.EnableFeatures; import org.chromium.chrome.test.util.browser.Features.EnableFeatures;
...@@ -35,10 +37,16 @@ import java.util.concurrent.TimeUnit; ...@@ -35,10 +37,16 @@ import java.util.concurrent.TimeUnit;
* Tests for WebsitePermissionsFetcher. * Tests for WebsitePermissionsFetcher.
*/ */
@RunWith(ChromeJUnit4ClassRunner.class) @RunWith(ChromeJUnit4ClassRunner.class)
@CommandLineFlags.Add({ChromeSwitches.DISABLE_FIRST_RUN_EXPERIENCE,
WebsitePermissionsFetcherTest.ENABLE_EXPERIMENTAL_WEB_PLATFORM_FEATURES})
public class WebsitePermissionsFetcherTest { public class WebsitePermissionsFetcherTest {
@Rule @Rule
public final ChromeBrowserTestRule mBrowserTestRule = new ChromeBrowserTestRule(); public final ChromeBrowserTestRule mBrowserTestRule = new ChromeBrowserTestRule();
/** Command line flag to enable experimental web platform features in tests. */
public static final String ENABLE_EXPERIMENTAL_WEB_PLATFORM_FEATURES =
"enable-experimental-web-platform-features";
private static final String[] PERMISSION_URLS = { private static final String[] PERMISSION_URLS = {
"http://www.google.com/", "http://www.google.com/",
"http://www.youtube.com/", "http://www.youtube.com/",
...@@ -621,12 +629,14 @@ public class WebsitePermissionsFetcherTest { ...@@ -621,12 +629,14 @@ public class WebsitePermissionsFetcherTest {
fetcher.setWebsitePreferenceBridgeForTesting(websitePreferenceBridge); fetcher.setWebsitePreferenceBridgeForTesting(websitePreferenceBridge);
String googleOrigin = "https://google.com"; String googleOrigin = "https://google.com";
ArrayList<Integer> permissionInfoTypes = new ArrayList<>( ArrayList<Integer> permissionInfoTypes = new ArrayList<>(Arrays.asList(
Arrays.asList(PermissionInfo.Type.AUGMENTED_REALITY, PermissionInfo.Type.CAMERA, PermissionInfo.Type.AUGMENTED_REALITY, PermissionInfo.Type.CAMERA,
PermissionInfo.Type.CLIPBOARD, PermissionInfo.Type.GEOLOCATION, PermissionInfo.Type.CLIPBOARD, PermissionInfo.Type.GEOLOCATION,
PermissionInfo.Type.MICROPHONE, PermissionInfo.Type.NOTIFICATION, PermissionInfo.Type.MICROPHONE, PermissionInfo.Type.NFC,
PermissionInfo.Type.PROTECTED_MEDIA_IDENTIFIER, PermissionInfo.Type.SENSORS, PermissionInfo.Type.NOTIFICATION, PermissionInfo.Type.PROTECTED_MEDIA_IDENTIFIER,
PermissionInfo.Type.VIRTUAL_REALITY)); PermissionInfo.Type.SENSORS, PermissionInfo.Type.VIRTUAL_REALITY));
// MIDI is excluded from the above list because it does not have a top level category.
Assert.assertEquals(11, PermissionInfo.Type.NUM_ENTRIES);
for (@PermissionInfo.Type int type : permissionInfoTypes) { for (@PermissionInfo.Type int type : permissionInfoTypes) {
PermissionInfo fakePermissionInfo = PermissionInfo fakePermissionInfo =
...@@ -656,9 +666,11 @@ public class WebsitePermissionsFetcherTest { ...@@ -656,9 +666,11 @@ public class WebsitePermissionsFetcherTest {
String preferenceSource = "preference"; String preferenceSource = "preference";
ArrayList<Integer> contentSettingExceptionTypes = new ArrayList<>(Arrays.asList( ArrayList<Integer> contentSettingExceptionTypes = new ArrayList<>(Arrays.asList(
ContentSettingException.Type.ADS, ContentSettingException.Type.AUTOMATIC_DOWNLOADS, ContentSettingException.Type.ADS, ContentSettingException.Type.AUTOMATIC_DOWNLOADS,
ContentSettingException.Type.BACKGROUND_SYNC, ContentSettingException.Type.COOKIE, ContentSettingException.Type.BACKGROUND_SYNC,
ContentSettingException.Type.JAVASCRIPT, ContentSettingException.Type.POPUP, ContentSettingException.Type.BLUETOOTH_SCANNING,
ContentSettingException.Type.SOUND)); ContentSettingException.Type.COOKIE, ContentSettingException.Type.JAVASCRIPT,
ContentSettingException.Type.POPUP, ContentSettingException.Type.SOUND));
Assert.assertEquals(8, ContentSettingException.Type.NUM_ENTRIES);
for (@ContentSettingsType int type : contentSettingExceptionTypes) { for (@ContentSettingsType int type : contentSettingExceptionTypes) {
@ContentSettingsType @ContentSettingsType
......
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