| Index: content/public/android/javatests/src/org/chromium/content/browser/EmailAddressDetectionTest.java
|
| diff --git a/content/public/android/javatests/src/org/chromium/content/browser/EmailAddressDetectionTest.java b/content/public/android/javatests/src/org/chromium/content/browser/EmailAddressDetectionTest.java
|
| index e9a23f3e5566c451b848adbbdaf47de218268932..f0661c0e7a9a008be52732860a48096bf9a6c45d 100644
|
| --- a/content/public/android/javatests/src/org/chromium/content/browser/EmailAddressDetectionTest.java
|
| +++ b/content/public/android/javatests/src/org/chromium/content/browser/EmailAddressDetectionTest.java
|
| @@ -6,7 +6,14 @@ package org.chromium.content.browser;
|
|
|
| import android.support.test.filters.MediumTest;
|
|
|
| +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.CommandLineFlags;
|
| +import org.chromium.base.test.util.CommandLineTestRule;
|
| import org.chromium.base.test.util.Feature;
|
| import org.chromium.base.test.util.RetryOnFailure;
|
| import org.chromium.content.common.ContentSwitches;
|
| @@ -14,33 +21,44 @@ import org.chromium.content.common.ContentSwitches;
|
| /**
|
| * Test suite for email address detection.
|
| */
|
| +@RunWith(BaseJUnit4ClassRunner.class)
|
| @CommandLineFlags.Add({ContentSwitches.ENABLE_CONTENT_INTENT_DETECTION})
|
| -public class EmailAddressDetectionTest extends ContentDetectionTestBase {
|
| +public class EmailAddressDetectionTest {
|
| + @Rule
|
| + public ContentDetectionActivityTestRule mActivityTestRule =
|
| + new ContentDetectionActivityTestRule();
|
| +
|
| + @Rule
|
| + public CommandLineTestRule mCommandLineTestRule =
|
| + new CommandLineTestRule(true).setFlags(ContentSwitches.ENABLE_CONTENT_INTENT_DETECTION);
|
|
|
| private static final String EMAIL_INTENT_PREFIX = "mailto:";
|
|
|
| private boolean isExpectedEmailIntent(String intentUrl, String expectedContent) {
|
| if (intentUrl == null) return false;
|
| - final String expectedUrl = EMAIL_INTENT_PREFIX + urlForContent(expectedContent);
|
| + final String expectedUrl =
|
| + EMAIL_INTENT_PREFIX + mActivityTestRule.urlForContent(expectedContent);
|
| return intentUrl.equals(expectedUrl);
|
| }
|
|
|
| + @Test
|
| @MediumTest
|
| @Feature({"ContentDetection", "TabContents"})
|
| @RetryOnFailure
|
| public void testValidEmailAddresses() throws Throwable {
|
| - startActivityWithTestUrl("content/test/data/android/content_detection/email.html");
|
| + mActivityTestRule.launchContentShellWithUrlSync(
|
| + "content/test/data/android/content_detection/email.html");
|
|
|
| // valid_1: i.want.a.pony@chromium.org.
|
| - String intentUrl = scrollAndTapExpectingIntent("valid_1");
|
| - assertTrue(isExpectedEmailIntent(intentUrl, "i.want.a.pony@chromium.org"));
|
| + String intentUrl = mActivityTestRule.scrollAndTapExpectingIntent("valid_1");
|
| + Assert.assertTrue(isExpectedEmailIntent(intentUrl, "i.want.a.pony@chromium.org"));
|
|
|
| // valid_2: nyan_cat@chromium.org.
|
| - intentUrl = scrollAndTapExpectingIntent("valid_2");
|
| - assertTrue(isExpectedEmailIntent(intentUrl, "nyan_cat@chromium.org"));
|
| + intentUrl = mActivityTestRule.scrollAndTapExpectingIntent("valid_2");
|
| + Assert.assertTrue(isExpectedEmailIntent(intentUrl, "nyan_cat@chromium.org"));
|
|
|
| // valid_3: 123@456.com.
|
| - intentUrl = scrollAndTapExpectingIntent("valid_3");
|
| - assertTrue(isExpectedEmailIntent(intentUrl, "123@456.com"));
|
| + intentUrl = mActivityTestRule.scrollAndTapExpectingIntent("valid_3");
|
| + Assert.assertTrue(isExpectedEmailIntent(intentUrl, "123@456.com"));
|
| }
|
| }
|
|
|