This source file includes following definitions.
- isExpectedTelephoneIntent
- startActivityWithTestUrlAndCountryIso
- Feature
- testInternationalNumberIntents
- Feature
- testLocalUSNumbers
- Feature
- testLocalUKNumbers
- Feature
- testLocalFRNumbers
package org.chromium.content.browser;
import android.test.FlakyTest;
import org.chromium.base.test.util.Feature;
import org.chromium.content.common.ContentSwitches;
public class PhoneNumberDetectionTest extends ContentDetectionTestBase {
private static final String TELEPHONE_INTENT_PREFIX = "tel:";
private boolean isExpectedTelephoneIntent(String intentUrl, String expectedContent) {
if (intentUrl == null) return false;
final String expectedUrl = TELEPHONE_INTENT_PREFIX + urlForContent(expectedContent);
return intentUrl.equals(expectedUrl);
}
private void startActivityWithTestUrlAndCountryIso(String testUrl, String countryIso)
throws Throwable {
final String[] cmdlineArgs = countryIso == null ? null : new String[] {
"--" + ContentSwitches.NETWORK_COUNTRY_ISO + "=" + countryIso };
startActivityWithTestUrlAndCommandLineArgs(testUrl, cmdlineArgs);
}
@FlakyTest
@Feature({"ContentDetection", "TabContents"})
public void testInternationalNumberIntents() throws Throwable {
startActivityWithTestUrl("content/content_detection/phone_international.html");
assertWaitForPageScaleFactorMatch(1.0f);
String intentUrl = scrollAndTapExpectingIntent("US");
assertTrue(isExpectedTelephoneIntent(intentUrl, "+16502530000"));
intentUrl = scrollAndTapExpectingIntent("Australia");
assertTrue(isExpectedTelephoneIntent(intentUrl, "+61293744000"));
intentUrl = scrollAndTapExpectingIntent("China");
assertTrue(isExpectedTelephoneIntent(intentUrl, "+861062503000"));
intentUrl = scrollAndTapExpectingIntent("Hong Kong");
assertTrue(isExpectedTelephoneIntent(intentUrl, "+85239235400"));
intentUrl = scrollAndTapExpectingIntent("India");
assertTrue(isExpectedTelephoneIntent(intentUrl, "+918067218000"));
intentUrl = scrollAndTapExpectingIntent("Japan");
assertTrue(isExpectedTelephoneIntent(intentUrl, "+81363849000"));
intentUrl = scrollAndTapExpectingIntent("Korea");
assertTrue(isExpectedTelephoneIntent(intentUrl, "+8225319000"));
intentUrl = scrollAndTapExpectingIntent("Singapore");
assertTrue(isExpectedTelephoneIntent(intentUrl, "+6565218000"));
intentUrl = scrollAndTapExpectingIntent("Taiwan");
assertTrue(isExpectedTelephoneIntent(intentUrl, "+886287296000"));
intentUrl = scrollAndTapExpectingIntent("Kenya");
assertTrue(isExpectedTelephoneIntent(intentUrl, "+254203601000"));
intentUrl = scrollAndTapExpectingIntent("France");
assertTrue(isExpectedTelephoneIntent(intentUrl, "+33142685300"));
intentUrl = scrollAndTapExpectingIntent("Germany");
assertTrue(isExpectedTelephoneIntent(intentUrl, "+4940808179000"));
intentUrl = scrollAndTapExpectingIntent("Ireland");
assertTrue(isExpectedTelephoneIntent(intentUrl, "+35314361001"));
intentUrl = scrollAndTapExpectingIntent("Italy");
assertTrue(isExpectedTelephoneIntent(intentUrl, "+390236618300"));
intentUrl = scrollAndTapExpectingIntent("Netherlands");
assertTrue(isExpectedTelephoneIntent(intentUrl, "+31205045100"));
intentUrl = scrollAndTapExpectingIntent("Norway");
assertTrue(isExpectedTelephoneIntent(intentUrl, "+4722996288"));
intentUrl = scrollAndTapExpectingIntent("Poland");
assertTrue(isExpectedTelephoneIntent(intentUrl, "+48126815300"));
intentUrl = scrollAndTapExpectingIntent("Russia");
assertTrue(isExpectedTelephoneIntent(intentUrl, "+74956441400"));
intentUrl = scrollAndTapExpectingIntent("Spain");
assertTrue(isExpectedTelephoneIntent(intentUrl, "+34917486400"));
intentUrl = scrollAndTapExpectingIntent("Switzerland");
assertTrue(isExpectedTelephoneIntent(intentUrl, "+41446681800"));
intentUrl = scrollAndTapExpectingIntent("UK");
assertTrue(isExpectedTelephoneIntent(intentUrl, "+442070313000"));
intentUrl = scrollAndTapExpectingIntent("Canada");
assertTrue(isExpectedTelephoneIntent(intentUrl, "+15146708700"));
intentUrl = scrollAndTapExpectingIntent("Argentina");
assertTrue(isExpectedTelephoneIntent(intentUrl, "+541155303000"));
intentUrl = scrollAndTapExpectingIntent("Brazil");
assertTrue(isExpectedTelephoneIntent(intentUrl, "+553121286800"));
intentUrl = scrollAndTapExpectingIntent("Mexico");
assertTrue(isExpectedTelephoneIntent(intentUrl, "+525553428400"));
intentUrl = scrollAndTapExpectingIntent("Israel");
assertTrue(isExpectedTelephoneIntent(intentUrl, "+972747466245"));
intentUrl = scrollAndTapExpectingIntent("UAE");
assertTrue(isExpectedTelephoneIntent(intentUrl, "+97144509500"));
}
@FlakyTest
@Feature({"ContentDetection", "TabContents"})
public void testLocalUSNumbers() throws Throwable {
startActivityWithTestUrlAndCountryIso("content/content_detection/phone_local.html", "US");
assertWaitForPageScaleFactorMatch(1.0f);
String intentUrl = scrollAndTapExpectingIntent("US_1");
assertTrue(isExpectedTelephoneIntent(intentUrl, "+18884335788"));
intentUrl = scrollAndTapExpectingIntent("US_2");
assertTrue(isExpectedTelephoneIntent(intentUrl, "+17032936299"));
intentUrl = scrollAndTapExpectingIntent("US_3");
assertTrue(isExpectedTelephoneIntent(intentUrl, "+12024562121"));
intentUrl = scrollAndTapExpectingIntent("International");
assertTrue(isExpectedTelephoneIntent(intentUrl, "+31205045100"));
}
@FlakyTest
@Feature({"ContentDetection", "TabContents"})
public void testLocalUKNumbers() throws Throwable {
startActivityWithTestUrlAndCountryIso("content/content_detection/phone_local.html", "GB");
assertWaitForPageScaleFactorMatch(1.0f);
String intentUrl = scrollAndTapExpectingIntent("GB_1");
assertTrue(isExpectedTelephoneIntent(intentUrl, "+442073238299"));
intentUrl = scrollAndTapExpectingIntent("GB_2");
assertTrue(isExpectedTelephoneIntent(intentUrl, "+441227865330"));
intentUrl = scrollAndTapExpectingIntent("GB_3");
assertTrue(isExpectedTelephoneIntent(intentUrl, "+441963824686"));
intentUrl = scrollAndTapExpectingIntent("International");
assertTrue(isExpectedTelephoneIntent(intentUrl, "+31205045100"));
}
@FlakyTest
@Feature({"ContentDetection", "TabContents"})
public void testLocalFRNumbers() throws Throwable {
startActivityWithTestUrlAndCountryIso("content/content_detection/phone_local.html", "FR");
assertWaitForPageScaleFactorMatch(1.0f);
String intentUrl = scrollAndTapExpectingIntent("FR_1");
assertTrue(isExpectedTelephoneIntent(intentUrl, "+33140205050"));
intentUrl = scrollAndTapExpectingIntent("FR_2");
assertTrue(isExpectedTelephoneIntent(intentUrl, "+33326475534"));
intentUrl = scrollAndTapExpectingIntent("FR_3");
assertTrue(isExpectedTelephoneIntent(intentUrl, "+33237211992"));
intentUrl = scrollAndTapExpectingIntent("International");
assertTrue(isExpectedTelephoneIntent(intentUrl, "+31205045100"));
}
}