OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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.FlakyTest; | 7 import android.test.FlakyTest; |
8 import android.test.suitebuilder.annotation.LargeTest; | 8 import android.test.suitebuilder.annotation.LargeTest; |
9 import android.test.suitebuilder.annotation.MediumTest; | 9 import android.test.suitebuilder.annotation.MediumTest; |
10 | 10 |
| 11 import org.chromium.base.CommandLine; |
11 import org.chromium.base.test.util.Feature; | 12 import org.chromium.base.test.util.Feature; |
12 import org.chromium.content.common.CommandLine; | 13 import org.chromium.content.common.ContentSwitches; |
13 | 14 |
14 /** | 15 /** |
15 * Test suite for phone number detection. | 16 * Test suite for phone number detection. |
16 */ | 17 */ |
17 public class PhoneNumberDetectionTest extends ContentDetectionTestBase { | 18 public class PhoneNumberDetectionTest extends ContentDetectionTestBase { |
18 | 19 |
19 private static final String TELEPHONE_INTENT_PREFIX = "tel:"; | 20 private static final String TELEPHONE_INTENT_PREFIX = "tel:"; |
20 | 21 |
21 private boolean isExpectedTelephoneIntent(String intentUrl, String expectedC
ontent) { | 22 private boolean isExpectedTelephoneIntent(String intentUrl, String expectedC
ontent) { |
22 if (intentUrl == null) return false; | 23 if (intentUrl == null) return false; |
23 final String expectedUrl = TELEPHONE_INTENT_PREFIX + urlForContent(expec
tedContent); | 24 final String expectedUrl = TELEPHONE_INTENT_PREFIX + urlForContent(expec
tedContent); |
24 return intentUrl.equals(expectedUrl); | 25 return intentUrl.equals(expectedUrl); |
25 } | 26 } |
26 | 27 |
27 /** | 28 /** |
28 * Starts the content shell activity with the provided test URL and setting
the local country | 29 * Starts the content shell activity with the provided test URL and setting
the local country |
29 * to the one provided by its 2-letter ISO code. | 30 * to the one provided by its 2-letter ISO code. |
30 * @param testUrl Test url to load. | 31 * @param testUrl Test url to load. |
31 * @param countryIso 2-letter ISO country code. If set to null only internat
ional numbers | 32 * @param countryIso 2-letter ISO country code. If set to null only internat
ional numbers |
32 * can be assumed to be supported. | 33 * can be assumed to be supported. |
33 */ | 34 */ |
34 private void startActivityWithTestUrlAndCountryIso(String testUrl, String co
untryIso) | 35 private void startActivityWithTestUrlAndCountryIso(String testUrl, String co
untryIso) |
35 throws Throwable { | 36 throws Throwable { |
36 final String[] cmdlineArgs = countryIso == null ? null : new String[] { | 37 final String[] cmdlineArgs = countryIso == null ? null : new String[] { |
37 "--" + CommandLine.NETWORK_COUNTRY_ISO + "=" + countryIso }; | 38 "--" + ContentSwitches.NETWORK_COUNTRY_ISO + "=" + countryIso }; |
38 startActivityWithTestUrlAndCommandLineArgs(testUrl, cmdlineArgs); | 39 startActivityWithTestUrlAndCommandLineArgs(testUrl, cmdlineArgs); |
39 } | 40 } |
40 | 41 |
41 /* @LargeTest */ | 42 /* @LargeTest */ |
42 @FlakyTest | 43 @FlakyTest |
43 @Feature({"ContentDetection", "TabContents"}) | 44 @Feature({"ContentDetection", "TabContents"}) |
44 public void testInternationalNumberIntents() throws Throwable { | 45 public void testInternationalNumberIntents() throws Throwable { |
45 startActivityWithTestUrl("content/content_detection/phone_international.
html"); | 46 startActivityWithTestUrl("content/content_detection/phone_international.
html"); |
46 assertWaitForPageScaleFactorMatch(1.0f); | 47 assertWaitForPageScaleFactorMatch(1.0f); |
47 | 48 |
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
219 | 220 |
220 // FR_3: (0) 237 211 992. | 221 // FR_3: (0) 237 211 992. |
221 intentUrl = scrollAndTapExpectingIntent("FR_3"); | 222 intentUrl = scrollAndTapExpectingIntent("FR_3"); |
222 assertTrue(isExpectedTelephoneIntent(intentUrl, "+33237211992")); | 223 assertTrue(isExpectedTelephoneIntent(intentUrl, "+33237211992")); |
223 | 224 |
224 // International numbers should still work. | 225 // International numbers should still work. |
225 intentUrl = scrollAndTapExpectingIntent("International"); | 226 intentUrl = scrollAndTapExpectingIntent("International"); |
226 assertTrue(isExpectedTelephoneIntent(intentUrl, "+31205045100")); | 227 assertTrue(isExpectedTelephoneIntent(intentUrl, "+31205045100")); |
227 } | 228 } |
228 } | 229 } |
OLD | NEW |