OLD | NEW |
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.chromium.base.test.util.CommandLineFlags; | 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; |
| 15 import org.chromium.base.test.util.CommandLineTestRule; |
10 import org.chromium.base.test.util.DisabledTest; | 16 import org.chromium.base.test.util.DisabledTest; |
11 import org.chromium.base.test.util.Feature; | 17 import org.chromium.base.test.util.Feature; |
12 import org.chromium.base.test.util.RetryOnFailure; | 18 import org.chromium.base.test.util.RetryOnFailure; |
13 import org.chromium.content.common.ContentSwitches; | 19 import org.chromium.content.common.ContentSwitches; |
14 | 20 |
15 /** | 21 /** |
16 * Test suite for geographical US address detection. | 22 * Test suite for geographical US address detection. |
17 */ | 23 */ |
18 @CommandLineFlags.Add({ContentSwitches.ENABLE_CONTENT_INTENT_DETECTION}) | 24 @RunWith(BaseJUnit4ClassRunner.class) |
19 public class AddressDetectionTest extends ContentDetectionTestBase { | 25 public class AddressDetectionTest { |
| 26 @Rule |
| 27 public ContentDetectionActivityTestRule mActivityTestRule = |
| 28 new ContentDetectionActivityTestRule(); |
| 29 |
| 30 @Rule |
| 31 public CommandLineTestRule mCommandLineTestRule = |
| 32 new CommandLineTestRule(true).setFlags(ContentSwitches.ENABLE_CONTEN
T_INTENT_DETECTION); |
20 | 33 |
21 private static final String GEO_INTENT_PREFIX = "geo:0,0?q="; | 34 private static final String GEO_INTENT_PREFIX = "geo:0,0?q="; |
22 | 35 |
23 private boolean isExpectedGeoIntent(String intentUrl, String expectedContent
) { | 36 private boolean isExpectedGeoIntent(String intentUrl, String expectedContent
) { |
24 if (intentUrl == null) return false; | 37 if (intentUrl == null) return false; |
25 final String expectedUrl = GEO_INTENT_PREFIX + urlForContent(expectedCon
tent); | 38 final String expectedUrl = |
| 39 GEO_INTENT_PREFIX + mActivityTestRule.urlForContent(expectedCont
ent); |
26 return intentUrl.equals(expectedUrl); | 40 return intentUrl.equals(expectedUrl); |
27 } | 41 } |
28 | 42 |
| 43 @Test |
29 @MediumTest | 44 @MediumTest |
30 @Feature({"ContentDetection", "TabContents"}) | 45 @Feature({"ContentDetection", "TabContents"}) |
31 @RetryOnFailure | 46 @RetryOnFailure |
32 public void testMultipleAddressesInText() throws Throwable { | 47 public void testMultipleAddressesInText() throws Throwable { |
33 startActivityWithTestUrl( | 48 mActivityTestRule.launchContentShellWithUrlSync( |
34 "content/test/data/android/content_detection/geo_address_multipl
e.html"); | 49 "content/test/data/android/content_detection/geo_address_multipl
e.html"); |
35 | 50 |
36 assertTrue(isExpectedGeoIntent(scrollAndTapExpectingIntent("test1"), | 51 Assert.assertTrue( |
37 "1600 Amphitheatre Parkway Mountain View, CA 94043")); | 52 isExpectedGeoIntent(mActivityTestRule.scrollAndTapExpectingInten
t("test1"), |
| 53 "1600 Amphitheatre Parkway Mountain View, CA 94043")); |
38 | 54 |
39 assertTrue(isExpectedGeoIntent(scrollAndTapExpectingIntent("test2"), | 55 Assert.assertTrue( |
40 "76 Ninth Avenue 4th Floor New York, NY 10011")); | 56 isExpectedGeoIntent(mActivityTestRule.scrollAndTapExpectingInten
t("test2"), |
| 57 "76 Ninth Avenue 4th Floor New York, NY 10011")); |
41 } | 58 } |
42 | 59 |
| 60 @Test |
43 @MediumTest | 61 @MediumTest |
44 @Feature({"ContentDetection", "TabContents"}) | 62 @Feature({"ContentDetection", "TabContents"}) |
45 @RetryOnFailure | 63 @RetryOnFailure |
46 public void testSplitAddresses() throws Throwable { | 64 public void testSplitAddresses() throws Throwable { |
47 startActivityWithTestUrl( | 65 mActivityTestRule.launchContentShellWithUrlSync( |
48 "content/test/data/android/content_detection/geo_address_split.h
tml"); | 66 "content/test/data/android/content_detection/geo_address_split.h
tml"); |
49 | 67 |
50 assertTrue(isExpectedGeoIntent(scrollAndTapExpectingIntent("test1"), | 68 Assert.assertTrue( |
51 "9606 North MoPac Expressway Suite 400 Austin, TX 78759")); | 69 isExpectedGeoIntent(mActivityTestRule.scrollAndTapExpectingInten
t("test1"), |
| 70 "9606 North MoPac Expressway Suite 400 Austin, TX 78759"
)); |
52 | 71 |
53 assertTrue(isExpectedGeoIntent(scrollAndTapExpectingIntent("test2"), | 72 Assert.assertTrue( |
54 "1818 Library Street Suite 400, VA 20190")); | 73 isExpectedGeoIntent(mActivityTestRule.scrollAndTapExpectingInten
t("test2"), |
| 74 "1818 Library Street Suite 400, VA 20190")); |
55 | 75 |
56 assertTrue(isExpectedGeoIntent(scrollAndTapExpectingIntent("test3"), | 76 Assert.assertTrue( |
57 "1818 Library Street Suite 400, VA 20190")); | 77 isExpectedGeoIntent(mActivityTestRule.scrollAndTapExpectingInten
t("test3"), |
| 78 "1818 Library Street Suite 400, VA 20190")); |
58 | 79 |
59 assertTrue(isExpectedGeoIntent(scrollAndTapExpectingIntent("test4"), | 80 Assert.assertTrue( |
60 "1818 Library Street Suite 400, VA 20190")); | 81 isExpectedGeoIntent(mActivityTestRule.scrollAndTapExpectingInten
t("test4"), |
| 82 "1818 Library Street Suite 400, VA 20190")); |
61 } | 83 } |
62 | 84 |
63 //@MediumTest | 85 //@MediumTest |
64 //@Feature({"ContentDetection", "TabContents"}) | 86 //@Feature({"ContentDetection", "TabContents"}) |
| 87 @Test |
65 @DisabledTest | 88 @DisabledTest |
66 public void testAddressLimits() throws Throwable { | 89 public void testAddressLimits() throws Throwable { |
67 startActivityWithTestUrl( | 90 mActivityTestRule.launchContentShellWithUrlSync( |
68 "content/test/data/android/content_detection/geo_address_limits.
html"); | 91 "content/test/data/android/content_detection/geo_address_limits.
html"); |
69 | 92 |
70 assertTrue(isExpectedGeoIntent(scrollAndTapExpectingIntent("test1"), | 93 Assert.assertTrue( |
71 "2590 Pearl Street Suite 100 Boulder, CO 80302")); | 94 isExpectedGeoIntent(mActivityTestRule.scrollAndTapExpectingInten
t("test1"), |
| 95 "2590 Pearl Street Suite 100 Boulder, CO 80302")); |
72 | 96 |
73 assertTrue(isExpectedGeoIntent(scrollAndTapExpectingIntent("test2"), | 97 Assert.assertTrue( |
74 "6425 Penn Ave. Suite 700 Pittsburgh, PA 15206")); | 98 isExpectedGeoIntent(mActivityTestRule.scrollAndTapExpectingInten
t("test2"), |
| 99 "6425 Penn Ave. Suite 700 Pittsburgh, PA 15206")); |
75 | 100 |
76 assertTrue(isExpectedGeoIntent(scrollAndTapExpectingIntent("test3"), | 101 Assert.assertTrue( |
77 "34 Main St. Boston, MA 02118")); | 102 isExpectedGeoIntent(mActivityTestRule.scrollAndTapExpectingInten
t("test3"), |
| 103 "34 Main St. Boston, MA 02118")); |
78 | 104 |
79 assertTrue(isExpectedGeoIntent(scrollAndTapExpectingIntent("test4"), | 105 Assert.assertTrue( |
80 "1600 Amphitheatre Parkway Mountain View, CA 94043")); | 106 isExpectedGeoIntent(mActivityTestRule.scrollAndTapExpectingInten
t("test4"), |
| 107 "1600 Amphitheatre Parkway Mountain View, CA 94043")); |
81 } | 108 } |
82 | 109 |
| 110 @Test |
83 @MediumTest | 111 @MediumTest |
84 @Feature({"ContentDetection", "TabContents"}) | 112 @Feature({"ContentDetection", "TabContents"}) |
85 @RetryOnFailure | 113 @RetryOnFailure |
86 public void testRealAddresses() throws Throwable { | 114 public void testRealAddresses() throws Throwable { |
87 startActivityWithTestUrl( | 115 mActivityTestRule.launchContentShellWithUrlSync( |
88 "content/test/data/android/content_detection/geo_address_real.ht
ml"); | 116 "content/test/data/android/content_detection/geo_address_real.ht
ml"); |
89 | 117 |
90 assertTrue(isExpectedGeoIntent(scrollAndTapExpectingIntent("test1"), | 118 Assert.assertTrue( |
91 "57th Street and Lake Shore Drive Chicago, IL 60637")); | 119 isExpectedGeoIntent(mActivityTestRule.scrollAndTapExpectingInten
t("test1"), |
| 120 "57th Street and Lake Shore Drive Chicago, IL 60637")); |
92 | 121 |
93 assertTrue(isExpectedGeoIntent(scrollAndTapExpectingIntent("test2"), | 122 Assert.assertTrue( |
94 "57th Street and Lake Shore Drive Chicago, IL 60637")); | 123 isExpectedGeoIntent(mActivityTestRule.scrollAndTapExpectingInten
t("test2"), |
| 124 "57th Street and Lake Shore Drive Chicago, IL 60637")); |
95 | 125 |
96 assertTrue(isExpectedGeoIntent(scrollAndTapExpectingIntent("test3"), | 126 Assert.assertTrue( |
97 "57th Street and Lake Shore Drive Chicago, IL 60637")); | 127 isExpectedGeoIntent(mActivityTestRule.scrollAndTapExpectingInten
t("test3"), |
| 128 "57th Street and Lake Shore Drive Chicago, IL 60637")); |
98 | 129 |
99 assertTrue(isExpectedGeoIntent(scrollAndTapExpectingIntent("test4"), | 130 Assert.assertTrue( |
100 "79th Street, New York, NY, 10024-5192")); | 131 isExpectedGeoIntent(mActivityTestRule.scrollAndTapExpectingInten
t("test4"), |
| 132 "79th Street, New York, NY, 10024-5192")); |
101 } | 133 } |
102 | 134 |
| 135 @Test |
103 @MediumTest | 136 @MediumTest |
104 @Feature({"ContentDetection", "TabContents"}) | 137 @Feature({"ContentDetection", "TabContents"}) |
105 @RetryOnFailure | 138 @RetryOnFailure |
106 public void testSpecialChars() throws Throwable { | 139 public void testSpecialChars() throws Throwable { |
107 startActivityWithTestUrl( | 140 mActivityTestRule.launchContentShellWithUrlSync( |
108 "content/test/data/android/content_detection/geo_address_special
_chars.html"); | 141 "content/test/data/android/content_detection/geo_address_special
_chars.html"); |
109 | 142 |
110 assertTrue(isExpectedGeoIntent(scrollAndTapExpectingIntent("test1"), | 143 Assert.assertTrue( |
111 "100 34th Avenue , San Francisco, CA 94121")); | 144 isExpectedGeoIntent(mActivityTestRule.scrollAndTapExpectingInten
t("test1"), |
| 145 "100 34th Avenue , San Francisco, CA 94121")); |
112 | 146 |
113 assertTrue(isExpectedGeoIntent(scrollAndTapExpectingIntent("test2"), | 147 Assert.assertTrue( |
114 "100 34th Avenue San Francisco, CA 94121")); | 148 isExpectedGeoIntent(mActivityTestRule.scrollAndTapExpectingInten
t("test2"), |
| 149 "100 34th Avenue San Francisco, CA 94121")); |
115 } | 150 } |
116 } | 151 } |
OLD | NEW |