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
3 // found in the LICENSE file.
5 package org.chromium.content.browser;
7 import android.test.suitebuilder.annotation.MediumTest;
9 import org.chromium.base.test.util.DisabledTest;
10 import org.chromium.base.test.util.Feature;
13 * Test suite for geographical US address detection.
15 public class AddressDetectionTest extends ContentDetectionTestBase {
17 private static final String GEO_INTENT_PREFIX = "geo:0,0?q=";
19 private boolean isExpectedGeoIntent(String intentUrl, String expectedContent) {
20 if (intentUrl == null) return false;
21 final String expectedUrl = GEO_INTENT_PREFIX + urlForContent(expectedContent);
22 return intentUrl.equals(expectedUrl);
26 @Feature({"ContentDetection", "TabContents"})
27 public void testMultipleAddressesInText() throws Throwable {
28 startActivityWithTestUrl("content/content_detection/geo_address_multiple.html");
29 assertWaitForPageScaleFactorMatch(1.0f);
31 assertTrue(isExpectedGeoIntent(scrollAndTapExpectingIntent("test1"),
32 "1600 Amphitheatre Parkway Mountain View, CA 94043"));
34 assertTrue(isExpectedGeoIntent(scrollAndTapExpectingIntent("test2"),
35 "76 Ninth Avenue 4th Floor New York, NY 10011"));
39 @Feature({"ContentDetection", "TabContents"})
40 public void testSplitAddresses() throws Throwable {
41 startActivityWithTestUrl("content/content_detection/geo_address_split.html");
42 assertWaitForPageScaleFactorMatch(1.0f);
44 assertTrue(isExpectedGeoIntent(scrollAndTapExpectingIntent("test1"),
45 "9606 North MoPac Expressway Suite 400 Austin, TX 78759"));
47 assertTrue(isExpectedGeoIntent(scrollAndTapExpectingIntent("test2"),
48 "1818 Library Street Suite 400, VA 20190"));
50 assertTrue(isExpectedGeoIntent(scrollAndTapExpectingIntent("test3"),
51 "1818 Library Street Suite 400, VA 20190"));
53 assertTrue(isExpectedGeoIntent(scrollAndTapExpectingIntent("test4"),
54 "1818 Library Street Suite 400, VA 20190"));
58 @Feature({"ContentDetection", "TabContents"})
59 public void testAddressLimits() throws Throwable {
60 startActivityWithTestUrl("content/content_detection/geo_address_limits.html");
61 assertWaitForPageScaleFactorMatch(1.0f);
63 assertTrue(isExpectedGeoIntent(scrollAndTapExpectingIntent("test1"),
64 "2590 Pearl Street Suite 100 Boulder, CO 80302"));
66 assertTrue(isExpectedGeoIntent(scrollAndTapExpectingIntent("test2"),
67 "6425 Penn Ave. Suite 700 Pittsburgh, PA 15206"));
69 assertTrue(isExpectedGeoIntent(scrollAndTapExpectingIntent("test3"),
70 "34 Main St. Boston, MA 02118"));
72 assertTrue(isExpectedGeoIntent(scrollAndTapExpectingIntent("test4"),
73 "1600 Amphitheatre Parkway Mountain View, CA 94043"));
77 @Feature({"ContentDetection", "TabContents"})
78 public void testRealAddresses() throws Throwable {
79 startActivityWithTestUrl("content/content_detection/geo_address_real.html");
80 assertWaitForPageScaleFactorMatch(1.0f);
82 assertTrue(isExpectedGeoIntent(scrollAndTapExpectingIntent("test1"),
83 "57th Street and Lake Shore Drive Chicago, IL 60637"));
85 assertTrue(isExpectedGeoIntent(scrollAndTapExpectingIntent("test2"),
86 "57th Street and Lake Shore Drive Chicago, IL 60637"));
88 assertTrue(isExpectedGeoIntent(scrollAndTapExpectingIntent("test3"),
89 "57th Street and Lake Shore Drive Chicago, IL 60637"));
91 assertTrue(isExpectedGeoIntent(scrollAndTapExpectingIntent("test4"),
92 "79th Street, New York, NY, 10024-5192"));
96 @Feature({"ContentDetection", "TabContents"})
97 public void testSpecialChars() throws Throwable {
98 startActivityWithTestUrl("content/content_detection/geo_address_special_chars.html");
99 assertWaitForPageScaleFactorMatch(1.0f);
101 assertTrue(isExpectedGeoIntent(scrollAndTapExpectingIntent("test1"),
102 "100 34th Avenue , San Francisco, CA 94121"));
104 assertTrue(isExpectedGeoIntent(scrollAndTapExpectingIntent("test2"),
105 "100 34th Avenue San Francisco, CA 94121"));