ClickListenerTest.java revision 5d1f7b1de12d16ceb2c938c56701a3e8bfa558f7
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
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.Feature;
10
11/**
12 * Test suite for click listener validation in content detection.
13 */
14public class ClickListenerTest extends ContentDetectionTestBase {
15
16    @MediumTest
17    @Feature({"ContentDetection", "TabContents"})
18    public void testClickContentOnLink() throws Throwable {
19        startActivityWithTestUrl("content/content_detection/click_listeners.html");
20        assertWaitForPageScaleFactorMatch(1.0f);
21
22        // Clicks on addresses in links should change the url.
23        scrollAndTapNavigatingOut("linktest");
24        assertTrue(isCurrentTestUrl("content/content_detection/empty.html"));
25    }
26
27    @MediumTest
28    @Feature({"ContentDetection", "TabContents"})
29    public void testClickContentOnJSListener1() throws Throwable {
30        startActivityWithTestUrl("content/content_detection/click_listeners.html");
31        assertWaitForPageScaleFactorMatch(1.0f);
32
33        // Clicks on addresses in elements listening to click events should be
34        // processed normally without address detection.
35        scrollAndTapNavigatingOut("clicktest1");
36        assertTrue(isCurrentTestUrl("content/content_detection/empty.html"));
37    }
38
39    @MediumTest
40    @Feature({"ContentDetection", "TabContents"})
41    public void testClickContentOnJSListener2() throws Throwable {
42        startActivityWithTestUrl("content/content_detection/click_listeners.html");
43        assertWaitForPageScaleFactorMatch(1.0f);
44
45        // Same as previous test, but using addEventListener instead of onclick.
46        scrollAndTapNavigatingOut("clicktest2");
47        assertTrue(isCurrentTestUrl("content/content_detection/empty.html"));
48    }
49}
50