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

Side by Side Diff: content/public/android/javatests/src/org/chromium/content/browser/EmailAddressDetectionTest.java

Issue 2766393004: Convert most of the rest of instrumentation tests in content (Closed)
Patch Set: Created 3 years, 9 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 unified diff | Download patch
OLDNEW
1 // Copyright 2012 The Chromium Authors. All rights reserved. 1 // Copyright 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 package org.chromium.content.browser; 5 package org.chromium.content.browser;
6 6
7 import android.support.test.filters.MediumTest; 7 import android.support.test.filters.MediumTest;
8 8
9 import org.junit.Assert;
10 import org.junit.Rule;
11 import org.junit.Test;
12 import org.junit.runner.RunWith;
13
14 import org.chromium.base.test.BaseJUnit4ClassRunner;
9 import org.chromium.base.test.util.CommandLineFlags; 15 import org.chromium.base.test.util.CommandLineFlags;
16 import org.chromium.base.test.util.CommandLineTestRule;
10 import org.chromium.base.test.util.Feature; 17 import org.chromium.base.test.util.Feature;
11 import org.chromium.base.test.util.RetryOnFailure; 18 import org.chromium.base.test.util.RetryOnFailure;
12 import org.chromium.content.common.ContentSwitches; 19 import org.chromium.content.common.ContentSwitches;
13 20
14 /** 21 /**
15 * Test suite for email address detection. 22 * Test suite for email address detection.
16 */ 23 */
24 @RunWith(BaseJUnit4ClassRunner.class)
17 @CommandLineFlags.Add({ContentSwitches.ENABLE_CONTENT_INTENT_DETECTION}) 25 @CommandLineFlags.Add({ContentSwitches.ENABLE_CONTENT_INTENT_DETECTION})
18 public class EmailAddressDetectionTest extends ContentDetectionTestBase { 26 public class EmailAddressDetectionTest {
27 @Rule
28 public ContentDetectionActivityTestRule mActivityTestRule =
29 new ContentDetectionActivityTestRule();
30
31 @Rule
32 public CommandLineTestRule mCommandLineTestRule =
33 new CommandLineTestRule(true).setFlags(ContentSwitches.ENABLE_CONTEN T_INTENT_DETECTION);
19 34
20 private static final String EMAIL_INTENT_PREFIX = "mailto:"; 35 private static final String EMAIL_INTENT_PREFIX = "mailto:";
21 36
22 private boolean isExpectedEmailIntent(String intentUrl, String expectedConte nt) { 37 private boolean isExpectedEmailIntent(String intentUrl, String expectedConte nt) {
23 if (intentUrl == null) return false; 38 if (intentUrl == null) return false;
24 final String expectedUrl = EMAIL_INTENT_PREFIX + urlForContent(expectedC ontent); 39 final String expectedUrl =
40 EMAIL_INTENT_PREFIX + mActivityTestRule.urlForContent(expectedCo ntent);
25 return intentUrl.equals(expectedUrl); 41 return intentUrl.equals(expectedUrl);
26 } 42 }
27 43
44 @Test
28 @MediumTest 45 @MediumTest
29 @Feature({"ContentDetection", "TabContents"}) 46 @Feature({"ContentDetection", "TabContents"})
30 @RetryOnFailure 47 @RetryOnFailure
31 public void testValidEmailAddresses() throws Throwable { 48 public void testValidEmailAddresses() throws Throwable {
32 startActivityWithTestUrl("content/test/data/android/content_detection/em ail.html"); 49 mActivityTestRule.launchContentShellWithUrlSync(
50 "content/test/data/android/content_detection/email.html");
33 51
34 // valid_1: i.want.a.pony@chromium.org. 52 // valid_1: i.want.a.pony@chromium.org.
35 String intentUrl = scrollAndTapExpectingIntent("valid_1"); 53 String intentUrl = mActivityTestRule.scrollAndTapExpectingIntent("valid_ 1");
36 assertTrue(isExpectedEmailIntent(intentUrl, "i.want.a.pony@chromium.org" )); 54 Assert.assertTrue(isExpectedEmailIntent(intentUrl, "i.want.a.pony@chromi um.org"));
37 55
38 // valid_2: nyan_cat@chromium.org. 56 // valid_2: nyan_cat@chromium.org.
39 intentUrl = scrollAndTapExpectingIntent("valid_2"); 57 intentUrl = mActivityTestRule.scrollAndTapExpectingIntent("valid_2");
40 assertTrue(isExpectedEmailIntent(intentUrl, "nyan_cat@chromium.org")); 58 Assert.assertTrue(isExpectedEmailIntent(intentUrl, "nyan_cat@chromium.or g"));
41 59
42 // valid_3: 123@456.com. 60 // valid_3: 123@456.com.
43 intentUrl = scrollAndTapExpectingIntent("valid_3"); 61 intentUrl = mActivityTestRule.scrollAndTapExpectingIntent("valid_3");
44 assertTrue(isExpectedEmailIntent(intentUrl, "123@456.com")); 62 Assert.assertTrue(isExpectedEmailIntent(intentUrl, "123@456.com"));
45 } 63 }
46 } 64 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698