EmailAddressDetectionTest.java revision 2a99a7e74a7f215066514fe81d2bfa6639d9eddd
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.
4
5package org.chromium.content.browser;
6
7import android.test.suitebuilder.annotation.MediumTest;
8
9import org.chromium.base.test.util.DisabledTest;
10import org.chromium.base.test.util.Feature;
11
12/**
13 * Test suite for email address detection.
14 */
15public class EmailAddressDetectionTest extends ContentDetectionTestBase {
16
17    private static final String EMAIL_INTENT_PREFIX = "mailto:";
18
19    private boolean isExpectedEmailIntent(String intentUrl, String expectedContent) {
20        if (intentUrl == null) return false;
21        final String expectedUrl = EMAIL_INTENT_PREFIX + urlForContent(expectedContent);
22        return intentUrl.equals(expectedUrl);
23    }
24
25    /*
26    @MediumTest
27    @Feature({"ContentDetection", "TabContents"})
28    http://crbug.com/172786
29    */
30    @DisabledTest
31    public void testValidEmailAddresses() throws Throwable {
32        startActivityWithTestUrl("content/content_detection/email.html");
33
34        // valid_1: i.want.a.pony@chromium.org.
35        String intentUrl = scrollAndTapExpectingIntent("valid_1");
36        assertTrue(isExpectedEmailIntent(intentUrl, "i.want.a.pony@chromium.org"));
37
38        // valid_2: nyan_cat@chromium.org.
39        intentUrl = scrollAndTapExpectingIntent("valid_2");
40        assertTrue(isExpectedEmailIntent(intentUrl, "nyan_cat@chromium.org"));
41
42        // valid_3: 123@456.com.
43        intentUrl = scrollAndTapExpectingIntent("valid_3");
44        assertTrue(isExpectedEmailIntent(intentUrl, "123@456.com"));
45    }
46}
47