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.test.suitebuilder.annotation.LargeTest; |
| 8 import android.test.suitebuilder.annotation.MediumTest; |
| 9 |
7 import org.chromium.base.test.util.CommandLineFlags; | 10 import org.chromium.base.test.util.CommandLineFlags; |
8 import org.chromium.base.test.util.Feature; | 11 import org.chromium.base.test.util.Feature; |
9 import org.chromium.content.common.ContentSwitches; | 12 import org.chromium.content.common.ContentSwitches; |
10 | 13 |
11 /** | 14 /** |
12 * Test suite for phone number detection. | 15 * Test suite for phone number detection. |
13 */ | 16 */ |
14 public class PhoneNumberDetectionTest extends ContentDetectionTestBase { | 17 public class PhoneNumberDetectionTest extends ContentDetectionTestBase { |
15 | 18 |
16 private static final String TELEPHONE_INTENT_PREFIX = "tel:"; | 19 private static final String TELEPHONE_INTENT_PREFIX = "tel:"; |
17 | 20 |
18 private boolean isExpectedTelephoneIntent(String intentUrl, String expectedC
ontent) { | 21 private boolean isExpectedTelephoneIntent(String intentUrl, String expectedC
ontent) { |
19 if (intentUrl == null) return false; | 22 if (intentUrl == null) return false; |
20 final String expectedUrl = TELEPHONE_INTENT_PREFIX + urlForContent(expec
tedContent); | 23 final String expectedUrl = TELEPHONE_INTENT_PREFIX + urlForContent(expec
tedContent); |
21 return intentUrl.equals(expectedUrl); | 24 return intentUrl.equals(expectedUrl); |
22 } | 25 } |
23 | 26 |
24 /* @LargeTest */ | 27 @LargeTest |
25 @Feature({"ContentDetection", "TabContents"}) | 28 @Feature({"ContentDetection", "TabContents"}) |
26 @CommandLineFlags.Add(ContentSwitches.NETWORK_COUNTRY_ISO + "=US") | 29 @CommandLineFlags.Add(ContentSwitches.NETWORK_COUNTRY_ISO + "=US") |
27 public void testInternationalNumberIntents() throws Throwable { | 30 public void testInternationalNumberIntents() throws Throwable { |
28 startActivityWithTestUrl( | 31 startActivityWithTestUrl( |
29 "content/test/data/android/content_detection/phone_international
.html"); | 32 "content/test/data/android/content_detection/phone_international
.html"); |
30 assertWaitForPageScaleFactorMatch(1.0f); | 33 assertWaitForPageScaleFactorMatch(1.0f); |
31 | 34 |
32 // US: +1 650-253-0000. | 35 // US: +1 650-253-0000. |
33 String intentUrl = scrollAndTapExpectingIntent("US"); | 36 String intentUrl = scrollAndTapExpectingIntent("US"); |
34 assertTrue(isExpectedTelephoneIntent(intentUrl, "+16502530000")); | 37 assertTrue(isExpectedTelephoneIntent(intentUrl, "+16502530000")); |
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
131 | 134 |
132 // Israel: +972-74-746-6245. | 135 // Israel: +972-74-746-6245. |
133 intentUrl = scrollAndTapExpectingIntent("Israel"); | 136 intentUrl = scrollAndTapExpectingIntent("Israel"); |
134 assertTrue(isExpectedTelephoneIntent(intentUrl, "+972747466245")); | 137 assertTrue(isExpectedTelephoneIntent(intentUrl, "+972747466245")); |
135 | 138 |
136 // UAE: +971 4 4509500. | 139 // UAE: +971 4 4509500. |
137 intentUrl = scrollAndTapExpectingIntent("UAE"); | 140 intentUrl = scrollAndTapExpectingIntent("UAE"); |
138 assertTrue(isExpectedTelephoneIntent(intentUrl, "+97144509500")); | 141 assertTrue(isExpectedTelephoneIntent(intentUrl, "+97144509500")); |
139 } | 142 } |
140 | 143 |
141 /* @MediumTest */ | 144 @MediumTest |
142 @Feature({"ContentDetection", "TabContents"}) | 145 @Feature({"ContentDetection", "TabContents"}) |
143 @CommandLineFlags.Add(ContentSwitches.NETWORK_COUNTRY_ISO + "=US") | 146 @CommandLineFlags.Add(ContentSwitches.NETWORK_COUNTRY_ISO + "=US") |
144 public void testLocalUSNumbers() throws Throwable { | 147 public void testLocalUSNumbers() throws Throwable { |
145 startActivityWithTestUrl( | 148 startActivityWithTestUrl( |
146 "content/test/data/android/content_detection/phone_local.html"); | 149 "content/test/data/android/content_detection/phone_local.html"); |
147 assertWaitForPageScaleFactorMatch(1.0f); | 150 assertWaitForPageScaleFactorMatch(1.0f); |
148 | 151 |
149 // US_1: 1-888-433-5788. | 152 // US_1: 1-888-433-5788. |
150 String intentUrl = scrollAndTapExpectingIntent("US_1"); | 153 String intentUrl = scrollAndTapExpectingIntent("US_1"); |
151 assertTrue(isExpectedTelephoneIntent(intentUrl, "+18884335788")); | 154 assertTrue(isExpectedTelephoneIntent(intentUrl, "+18884335788")); |
152 | 155 |
153 // US_2: 703-293-6299. | 156 // US_2: 703-293-6299. |
154 intentUrl = scrollAndTapExpectingIntent("US_2"); | 157 intentUrl = scrollAndTapExpectingIntent("US_2"); |
155 assertTrue(isExpectedTelephoneIntent(intentUrl, "+17032936299")); | 158 assertTrue(isExpectedTelephoneIntent(intentUrl, "+17032936299")); |
156 | 159 |
157 // US_3: (202) 456-2121. | 160 // US_3: (202) 456-2121. |
158 intentUrl = scrollAndTapExpectingIntent("US_3"); | 161 intentUrl = scrollAndTapExpectingIntent("US_3"); |
159 assertTrue(isExpectedTelephoneIntent(intentUrl, "+12024562121")); | 162 assertTrue(isExpectedTelephoneIntent(intentUrl, "+12024562121")); |
160 | 163 |
161 // International numbers should still work. | 164 // International numbers should still work. |
162 intentUrl = scrollAndTapExpectingIntent("International"); | 165 intentUrl = scrollAndTapExpectingIntent("International"); |
163 assertTrue(isExpectedTelephoneIntent(intentUrl, "+31205045100")); | 166 assertTrue(isExpectedTelephoneIntent(intentUrl, "+31205045100")); |
164 } | 167 } |
165 | 168 |
166 /* @MediumTest */ | 169 @MediumTest |
167 @Feature({"ContentDetection", "TabContents"}) | 170 @Feature({"ContentDetection", "TabContents"}) |
168 @CommandLineFlags.Add(ContentSwitches.NETWORK_COUNTRY_ISO + "=GB") | 171 @CommandLineFlags.Add(ContentSwitches.NETWORK_COUNTRY_ISO + "=GB") |
169 public void testLocalUKNumbers() throws Throwable { | 172 public void testLocalUKNumbers() throws Throwable { |
170 startActivityWithTestUrl( | 173 startActivityWithTestUrl( |
171 "content/test/data/android/content_detection/phone_local.html"); | 174 "content/test/data/android/content_detection/phone_local.html"); |
172 assertWaitForPageScaleFactorMatch(1.0f); | 175 assertWaitForPageScaleFactorMatch(1.0f); |
173 | 176 |
174 // GB_1: (0) 20 7323 8299. | 177 // GB_1: (0) 20 7323 8299. |
175 String intentUrl = scrollAndTapExpectingIntent("GB_1"); | 178 String intentUrl = scrollAndTapExpectingIntent("GB_1"); |
176 assertTrue(isExpectedTelephoneIntent(intentUrl, "02073238299")); | 179 assertTrue(isExpectedTelephoneIntent(intentUrl, "02073238299")); |
177 | 180 |
178 // GB_2: 01227865330. | 181 // GB_2: 01227865330. |
179 intentUrl = scrollAndTapExpectingIntent("GB_2"); | 182 intentUrl = scrollAndTapExpectingIntent("GB_2"); |
180 assertTrue(isExpectedTelephoneIntent(intentUrl, "01227865330")); | 183 assertTrue(isExpectedTelephoneIntent(intentUrl, "01227865330")); |
181 | 184 |
182 // GB_3: 01963 824686. | 185 // GB_3: 01963 824686. |
183 intentUrl = scrollAndTapExpectingIntent("GB_3"); | 186 intentUrl = scrollAndTapExpectingIntent("GB_3"); |
184 assertTrue(isExpectedTelephoneIntent(intentUrl, "01963824686")); | 187 assertTrue(isExpectedTelephoneIntent(intentUrl, "01963824686")); |
185 | 188 |
186 // International numbers should still work. | 189 // International numbers should still work. |
187 intentUrl = scrollAndTapExpectingIntent("International"); | 190 intentUrl = scrollAndTapExpectingIntent("International"); |
188 assertTrue(isExpectedTelephoneIntent(intentUrl, "+31205045100")); | 191 assertTrue(isExpectedTelephoneIntent(intentUrl, "+31205045100")); |
189 } | 192 } |
190 | 193 |
191 /* @MediumTest */ | 194 @MediumTest |
192 @Feature({"ContentDetection", "TabContents"}) | 195 @Feature({"ContentDetection", "TabContents"}) |
193 @CommandLineFlags.Add(ContentSwitches.NETWORK_COUNTRY_ISO + "=FR") | 196 @CommandLineFlags.Add(ContentSwitches.NETWORK_COUNTRY_ISO + "=FR") |
194 public void testLocalFRNumbers() throws Throwable { | 197 public void testLocalFRNumbers() throws Throwable { |
195 startActivityWithTestUrl( | 198 startActivityWithTestUrl( |
196 "content/test/data/android/content_detection/phone_local.html"); | 199 "content/test/data/android/content_detection/phone_local.html"); |
197 assertWaitForPageScaleFactorMatch(1.0f); | 200 assertWaitForPageScaleFactorMatch(1.0f); |
198 | 201 |
199 // FR_1: 01 40 20 50 50. | 202 // FR_1: 01 40 20 50 50. |
200 String intentUrl = scrollAndTapExpectingIntent("FR_1"); | 203 String intentUrl = scrollAndTapExpectingIntent("FR_1"); |
201 assertTrue(isExpectedTelephoneIntent(intentUrl, "0140205050")); | 204 assertTrue(isExpectedTelephoneIntent(intentUrl, "0140205050")); |
202 | 205 |
203 // FR_2: 0326475534. | 206 // FR_2: 0326475534. |
204 intentUrl = scrollAndTapExpectingIntent("FR_2"); | 207 intentUrl = scrollAndTapExpectingIntent("FR_2"); |
205 assertTrue(isExpectedTelephoneIntent(intentUrl, "0326475534")); | 208 assertTrue(isExpectedTelephoneIntent(intentUrl, "0326475534")); |
206 | 209 |
207 // FR_3: (0) 237 211 992. | 210 // FR_3: (0) 237 211 992. |
208 intentUrl = scrollAndTapExpectingIntent("FR_3"); | 211 intentUrl = scrollAndTapExpectingIntent("FR_3"); |
209 assertTrue(isExpectedTelephoneIntent(intentUrl, "0237211992")); | 212 assertTrue(isExpectedTelephoneIntent(intentUrl, "0237211992")); |
210 | 213 |
211 // International numbers should still work. | 214 // International numbers should still work. |
212 intentUrl = scrollAndTapExpectingIntent("International"); | 215 intentUrl = scrollAndTapExpectingIntent("International"); |
213 assertTrue(isExpectedTelephoneIntent(intentUrl, "+31205045100")); | 216 assertTrue(isExpectedTelephoneIntent(intentUrl, "+31205045100")); |
214 } | 217 } |
215 } | 218 } |
OLD | NEW |