Index: content/public/android/javatests/src/org/chromium/content/browser/AddressDetectionTest.java |
diff --git a/content/public/android/javatests/src/org/chromium/content/browser/AddressDetectionTest.java b/content/public/android/javatests/src/org/chromium/content/browser/AddressDetectionTest.java |
index 88ec026ffb65455af02ad78983064b3a0e503751..5afdfc4891a216b91d2dc25f31b4eec59891dce1 100644 |
--- a/content/public/android/javatests/src/org/chromium/content/browser/AddressDetectionTest.java |
+++ b/content/public/android/javatests/src/org/chromium/content/browser/AddressDetectionTest.java |
@@ -6,7 +6,13 @@ package org.chromium.content.browser; |
import android.support.test.filters.MediumTest; |
-import org.chromium.base.test.util.CommandLineFlags; |
+import org.junit.Assert; |
+import org.junit.Rule; |
+import org.junit.Test; |
+import org.junit.runner.RunWith; |
+ |
+import org.chromium.base.test.BaseJUnit4ClassRunner; |
+import org.chromium.base.test.util.CommandLineTestRule; |
import org.chromium.base.test.util.DisabledTest; |
import org.chromium.base.test.util.Feature; |
import org.chromium.base.test.util.RetryOnFailure; |
@@ -15,102 +21,131 @@ import org.chromium.content.common.ContentSwitches; |
/** |
* Test suite for geographical US address detection. |
*/ |
-@CommandLineFlags.Add({ContentSwitches.ENABLE_CONTENT_INTENT_DETECTION}) |
-public class AddressDetectionTest extends ContentDetectionTestBase { |
+@RunWith(BaseJUnit4ClassRunner.class) |
+public class AddressDetectionTest { |
+ @Rule |
+ public ContentDetectionActivityTestRule mActivityTestRule = |
+ new ContentDetectionActivityTestRule(); |
+ |
+ @Rule |
+ public CommandLineTestRule mCommandLineTestRule = |
+ new CommandLineTestRule(true).setFlags(ContentSwitches.ENABLE_CONTENT_INTENT_DETECTION); |
private static final String GEO_INTENT_PREFIX = "geo:0,0?q="; |
private boolean isExpectedGeoIntent(String intentUrl, String expectedContent) { |
if (intentUrl == null) return false; |
- final String expectedUrl = GEO_INTENT_PREFIX + urlForContent(expectedContent); |
+ final String expectedUrl = |
+ GEO_INTENT_PREFIX + mActivityTestRule.urlForContent(expectedContent); |
return intentUrl.equals(expectedUrl); |
} |
+ @Test |
@MediumTest |
@Feature({"ContentDetection", "TabContents"}) |
@RetryOnFailure |
public void testMultipleAddressesInText() throws Throwable { |
- startActivityWithTestUrl( |
+ mActivityTestRule.launchContentShellWithUrlSync( |
"content/test/data/android/content_detection/geo_address_multiple.html"); |
- assertTrue(isExpectedGeoIntent(scrollAndTapExpectingIntent("test1"), |
- "1600 Amphitheatre Parkway Mountain View, CA 94043")); |
+ Assert.assertTrue( |
+ isExpectedGeoIntent(mActivityTestRule.scrollAndTapExpectingIntent("test1"), |
+ "1600 Amphitheatre Parkway Mountain View, CA 94043")); |
- assertTrue(isExpectedGeoIntent(scrollAndTapExpectingIntent("test2"), |
- "76 Ninth Avenue 4th Floor New York, NY 10011")); |
+ Assert.assertTrue( |
+ isExpectedGeoIntent(mActivityTestRule.scrollAndTapExpectingIntent("test2"), |
+ "76 Ninth Avenue 4th Floor New York, NY 10011")); |
} |
+ @Test |
@MediumTest |
@Feature({"ContentDetection", "TabContents"}) |
@RetryOnFailure |
public void testSplitAddresses() throws Throwable { |
- startActivityWithTestUrl( |
+ mActivityTestRule.launchContentShellWithUrlSync( |
"content/test/data/android/content_detection/geo_address_split.html"); |
- assertTrue(isExpectedGeoIntent(scrollAndTapExpectingIntent("test1"), |
- "9606 North MoPac Expressway Suite 400 Austin, TX 78759")); |
+ Assert.assertTrue( |
+ isExpectedGeoIntent(mActivityTestRule.scrollAndTapExpectingIntent("test1"), |
+ "9606 North MoPac Expressway Suite 400 Austin, TX 78759")); |
- assertTrue(isExpectedGeoIntent(scrollAndTapExpectingIntent("test2"), |
- "1818 Library Street Suite 400, VA 20190")); |
+ Assert.assertTrue( |
+ isExpectedGeoIntent(mActivityTestRule.scrollAndTapExpectingIntent("test2"), |
+ "1818 Library Street Suite 400, VA 20190")); |
- assertTrue(isExpectedGeoIntent(scrollAndTapExpectingIntent("test3"), |
- "1818 Library Street Suite 400, VA 20190")); |
+ Assert.assertTrue( |
+ isExpectedGeoIntent(mActivityTestRule.scrollAndTapExpectingIntent("test3"), |
+ "1818 Library Street Suite 400, VA 20190")); |
- assertTrue(isExpectedGeoIntent(scrollAndTapExpectingIntent("test4"), |
- "1818 Library Street Suite 400, VA 20190")); |
+ Assert.assertTrue( |
+ isExpectedGeoIntent(mActivityTestRule.scrollAndTapExpectingIntent("test4"), |
+ "1818 Library Street Suite 400, VA 20190")); |
} |
//@MediumTest |
//@Feature({"ContentDetection", "TabContents"}) |
+ @Test |
@DisabledTest |
public void testAddressLimits() throws Throwable { |
- startActivityWithTestUrl( |
+ mActivityTestRule.launchContentShellWithUrlSync( |
"content/test/data/android/content_detection/geo_address_limits.html"); |
- assertTrue(isExpectedGeoIntent(scrollAndTapExpectingIntent("test1"), |
- "2590 Pearl Street Suite 100 Boulder, CO 80302")); |
+ Assert.assertTrue( |
+ isExpectedGeoIntent(mActivityTestRule.scrollAndTapExpectingIntent("test1"), |
+ "2590 Pearl Street Suite 100 Boulder, CO 80302")); |
- assertTrue(isExpectedGeoIntent(scrollAndTapExpectingIntent("test2"), |
- "6425 Penn Ave. Suite 700 Pittsburgh, PA 15206")); |
+ Assert.assertTrue( |
+ isExpectedGeoIntent(mActivityTestRule.scrollAndTapExpectingIntent("test2"), |
+ "6425 Penn Ave. Suite 700 Pittsburgh, PA 15206")); |
- assertTrue(isExpectedGeoIntent(scrollAndTapExpectingIntent("test3"), |
- "34 Main St. Boston, MA 02118")); |
+ Assert.assertTrue( |
+ isExpectedGeoIntent(mActivityTestRule.scrollAndTapExpectingIntent("test3"), |
+ "34 Main St. Boston, MA 02118")); |
- assertTrue(isExpectedGeoIntent(scrollAndTapExpectingIntent("test4"), |
- "1600 Amphitheatre Parkway Mountain View, CA 94043")); |
+ Assert.assertTrue( |
+ isExpectedGeoIntent(mActivityTestRule.scrollAndTapExpectingIntent("test4"), |
+ "1600 Amphitheatre Parkway Mountain View, CA 94043")); |
} |
+ @Test |
@MediumTest |
@Feature({"ContentDetection", "TabContents"}) |
@RetryOnFailure |
public void testRealAddresses() throws Throwable { |
- startActivityWithTestUrl( |
+ mActivityTestRule.launchContentShellWithUrlSync( |
"content/test/data/android/content_detection/geo_address_real.html"); |
- assertTrue(isExpectedGeoIntent(scrollAndTapExpectingIntent("test1"), |
- "57th Street and Lake Shore Drive Chicago, IL 60637")); |
+ Assert.assertTrue( |
+ isExpectedGeoIntent(mActivityTestRule.scrollAndTapExpectingIntent("test1"), |
+ "57th Street and Lake Shore Drive Chicago, IL 60637")); |
- assertTrue(isExpectedGeoIntent(scrollAndTapExpectingIntent("test2"), |
- "57th Street and Lake Shore Drive Chicago, IL 60637")); |
+ Assert.assertTrue( |
+ isExpectedGeoIntent(mActivityTestRule.scrollAndTapExpectingIntent("test2"), |
+ "57th Street and Lake Shore Drive Chicago, IL 60637")); |
- assertTrue(isExpectedGeoIntent(scrollAndTapExpectingIntent("test3"), |
- "57th Street and Lake Shore Drive Chicago, IL 60637")); |
+ Assert.assertTrue( |
+ isExpectedGeoIntent(mActivityTestRule.scrollAndTapExpectingIntent("test3"), |
+ "57th Street and Lake Shore Drive Chicago, IL 60637")); |
- assertTrue(isExpectedGeoIntent(scrollAndTapExpectingIntent("test4"), |
- "79th Street, New York, NY, 10024-5192")); |
+ Assert.assertTrue( |
+ isExpectedGeoIntent(mActivityTestRule.scrollAndTapExpectingIntent("test4"), |
+ "79th Street, New York, NY, 10024-5192")); |
} |
+ @Test |
@MediumTest |
@Feature({"ContentDetection", "TabContents"}) |
@RetryOnFailure |
public void testSpecialChars() throws Throwable { |
- startActivityWithTestUrl( |
+ mActivityTestRule.launchContentShellWithUrlSync( |
"content/test/data/android/content_detection/geo_address_special_chars.html"); |
- assertTrue(isExpectedGeoIntent(scrollAndTapExpectingIntent("test1"), |
- "100 34th Avenue , San Francisco, CA 94121")); |
+ Assert.assertTrue( |
+ isExpectedGeoIntent(mActivityTestRule.scrollAndTapExpectingIntent("test1"), |
+ "100 34th Avenue , San Francisco, CA 94121")); |
- assertTrue(isExpectedGeoIntent(scrollAndTapExpectingIntent("test2"), |
- "100 34th Avenue San Francisco, CA 94121")); |
+ Assert.assertTrue( |
+ isExpectedGeoIntent(mActivityTestRule.scrollAndTapExpectingIntent("test2"), |
+ "100 34th Avenue San Francisco, CA 94121")); |
} |
} |