Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2359)

Unified Diff: chrome/android/javatests/src/org/chromium/chrome/browser/omnibox/geo/GeolocationHeaderTest.java

Issue 2853423003: Revert of Convert ChromeActivityTestCaseBase direct children to JUnit4 (Closed)
Patch Set: Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/android/javatests/src/org/chromium/chrome/browser/omnibox/geo/GeolocationHeaderTest.java
diff --git a/chrome/android/javatests/src/org/chromium/chrome/browser/omnibox/geo/GeolocationHeaderTest.java b/chrome/android/javatests/src/org/chromium/chrome/browser/omnibox/geo/GeolocationHeaderTest.java
index bc688f8de91ebabe883c19384136ba4490cbbe50..a0ed7d3429259a163628d6eff1b601469abc1ee5 100644
--- a/chrome/android/javatests/src/org/chromium/chrome/browser/omnibox/geo/GeolocationHeaderTest.java
+++ b/chrome/android/javatests/src/org/chromium/chrome/browser/omnibox/geo/GeolocationHeaderTest.java
@@ -10,37 +10,22 @@
import android.os.SystemClock;
import android.support.test.filters.SmallTest;
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-
import org.chromium.base.ThreadUtils;
import org.chromium.base.library_loader.ProcessInitException;
import org.chromium.base.test.util.CommandLineFlags;
import org.chromium.base.test.util.Feature;
import org.chromium.chrome.browser.ChromeActivity;
-import org.chromium.chrome.browser.ChromeSwitches;
import org.chromium.chrome.browser.preferences.PrefServiceBridge;
import org.chromium.chrome.browser.preferences.website.ContentSetting;
import org.chromium.chrome.browser.preferences.website.GeolocationInfo;
import org.chromium.chrome.browser.preferences.website.WebsitePreferenceBridge;
import org.chromium.chrome.browser.tab.Tab;
-import org.chromium.chrome.test.ChromeActivityTestRule;
-import org.chromium.chrome.test.ChromeJUnit4ClassRunner;
+import org.chromium.chrome.test.ChromeActivityTestCaseBase;
/**
* Tests for GeolocationHeader and GeolocationTracker.
*/
-@RunWith(ChromeJUnit4ClassRunner.class)
-@CommandLineFlags.Add({ChromeSwitches.DISABLE_FIRST_RUN_EXPERIENCE,
- ChromeActivityTestRule.DISABLE_NETWORK_PREDICTION_FLAG})
-public class GeolocationHeaderTest {
- @Rule
- public ChromeActivityTestRule<ChromeActivity> mActivityTestRule =
- new ChromeActivityTestRule<>(ChromeActivity.class);
-
+public class GeolocationHeaderTest extends ChromeActivityTestCaseBase<ChromeActivity> {
private static final String SEARCH_URL_1 = "https://www.google.com/search?q=potatoes";
private static final String SEARCH_URL_2 = "https://www.google.co.jp/webhp?#q=dinosaurs";
private static final String ENABLE_CONSISTENT_GEOLOCATION_FEATURE =
@@ -49,9 +34,13 @@
"disable-features=ConsistentOmniboxGeolocation";
private static final String GOOGLE_BASE_URL_SWITCH = "google-base-url=https://www.google.com";
- @Before
- public void setUp() throws InterruptedException {
- mActivityTestRule.startMainActivityOnBlankPage();
+ public GeolocationHeaderTest() {
+ super(ChromeActivity.class);
+ }
+
+ @Override
+ protected void setUp() throws Exception {
+ super.setUp();
ThreadUtils.runOnUiThreadBlocking(new Runnable() {
@Override
public void run() {
@@ -60,7 +49,6 @@
});
}
- @Test
@SmallTest
@Feature({"Location"})
@CommandLineFlags.Add(DISABLE_CONSISTENT_GEOLOCATION_FEATURE)
@@ -85,7 +73,6 @@
assertNullHeader("http://www.google.com/webhp?#q=dinosaurs", false);
}
- @Test
@SmallTest
@Feature({"Location"})
@CommandLineFlags.Add({ENABLE_CONSISTENT_GEOLOCATION_FEATURE, GOOGLE_BASE_URL_SWITCH})
@@ -112,7 +99,6 @@
assertNullHeader("http://www.google.com/webhp?#q=dinosaurs", false);
}
- @Test
@SmallTest
@Feature({"Location"})
@CommandLineFlags.Add(DISABLE_CONSISTENT_GEOLOCATION_FEATURE)
@@ -125,7 +111,6 @@
checkHeaderWithPermissions(ContentSetting.BLOCK, true);
}
- @Test
@SmallTest
@Feature({"Location"})
@CommandLineFlags.Add({ENABLE_CONSISTENT_GEOLOCATION_FEATURE, GOOGLE_BASE_URL_SWITCH})
@@ -140,7 +125,6 @@
checkHeaderWithPermissionAndSetting(ContentSetting.BLOCK, false, true);
}
- @Test
@SmallTest
@Feature({"Location"})
@CommandLineFlags.Add(DISABLE_CONSISTENT_GEOLOCATION_FEATURE)
@@ -168,7 +152,7 @@
infoHttps.setContentSetting(httpsPermission);
String header = GeolocationHeader.getGeoHeader(
"https://www.google.de/search?q=kartoffelsalat",
- mActivityTestRule.getActivity().getActivityTab());
+ getActivity().getActivityTab());
assertHeaderState(header, shouldBeNull);
}
});
@@ -184,7 +168,7 @@
infoHttps.setContentSetting(httpsPermission);
WebsitePreferenceBridge.setDSEGeolocationSetting(settingValue);
String header = GeolocationHeader.getGeoHeader(
- SEARCH_URL_1, mActivityTestRule.getActivity().getActivityTab());
+ SEARCH_URL_1, getActivity().getActivityTab());
assertHeaderState(header, shouldBeNull);
}
});
@@ -196,8 +180,8 @@
@Override
public void run() {
setMockLocation(latitute, longitude, time);
- String header = GeolocationHeader.getGeoHeader(
- SEARCH_URL_1, mActivityTestRule.getActivity().getActivityTab());
+ String header = GeolocationHeader.getGeoHeader(SEARCH_URL_1,
+ getActivity().getActivityTab());
assertHeaderState(header, shouldBeNull);
}
});
@@ -205,9 +189,9 @@
private void assertHeaderState(String header, boolean shouldBeNull) {
if (shouldBeNull) {
- Assert.assertNull(header);
+ assertNull(header);
} else {
- Assert.assertNotNull(header);
+ assertNotNull(header);
}
}
@@ -226,29 +210,34 @@
private void assertNullHeader(final String url, final boolean isIncognito) {
try {
- final Tab tab = mActivityTestRule.loadUrlInNewTab("about:blank", isIncognito);
+ final Tab tab = loadUrlInNewTab("about:blank", isIncognito);
ThreadUtils.runOnUiThreadBlocking(new Runnable() {
@Override
public void run() {
- Assert.assertNull(GeolocationHeader.getGeoHeader(url, tab));
+ assertNull(GeolocationHeader.getGeoHeader(url, tab));
}
});
} catch (InterruptedException e) {
- Assert.fail(e.getMessage());
+ fail(e.getMessage());
}
}
private void assertNonNullHeader(final String url, final boolean isIncognito) {
try {
- final Tab tab = mActivityTestRule.loadUrlInNewTab("about:blank", isIncognito);
+ final Tab tab = loadUrlInNewTab("about:blank", isIncognito);
ThreadUtils.runOnUiThreadBlocking(new Runnable() {
@Override
public void run() {
- Assert.assertNotNull(GeolocationHeader.getGeoHeader(url, tab));
+ assertNotNull(GeolocationHeader.getGeoHeader(url, tab));
}
});
} catch (InterruptedException e) {
- Assert.fail(e.getMessage());
- }
+ fail(e.getMessage());
+ }
+ }
+
+ @Override
+ public void startMainActivity() throws InterruptedException {
+ startMainActivityOnBlankPage();
}
}

Powered by Google App Engine
This is Rietveld 408576698