| OLD | NEW |
| 1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 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.support.test.filters.MediumTest; | 7 import android.support.test.filters.MediumTest; |
| 8 | 8 |
| 9 import org.chromium.base.test.util.CommandLineFlags; | 9 import org.chromium.base.test.util.CommandLineFlags; |
| 10 import org.chromium.base.test.util.Feature; | 10 import org.chromium.base.test.util.Feature; |
| 11 import org.chromium.base.test.util.RetryOnFailure; | 11 import org.chromium.base.test.util.RetryOnFailure; |
| 12 import org.chromium.content.common.ContentSwitches; | 12 import org.chromium.content.common.ContentSwitches; |
| 13 import org.junit.Rule; |
| 14 import org.junit.Test; |
| 15 import org.chromium.base.test.BaseJUnit4ClassRunner; |
| 16 import org.junit.runner.RunWith; |
| 17 import org.junit.Assert; |
| 18 import org.chromium.content.browser.ContentDetectionActivityTestRule; |
| 13 | 19 |
| 14 /** | 20 /** |
| 15 * Test suite for click listener validation in content detection. | 21 * Test suite for click listener validation in content detection. |
| 16 */ | 22 */ |
| 23 @RunWith(BaseJUnit4ClassRunner.class) |
| 17 @CommandLineFlags.Add({ContentSwitches.ENABLE_CONTENT_INTENT_DETECTION}) | 24 @CommandLineFlags.Add({ContentSwitches.ENABLE_CONTENT_INTENT_DETECTION}) |
| 18 public class ClickListenerTest extends ContentDetectionTestBase { | 25 public class ClickListenerTest { |
| 19 | 26 |
| 27 @Rule |
| 28 public ContentDetectionActivityTestRule mActivityTestRule = new ContentDetec
tionActivityTestRule(); |
| 29 |
| 30 @Test |
| 20 @MediumTest | 31 @MediumTest |
| 21 @Feature({"ContentDetection", "TabContents"}) | 32 @Feature({"ContentDetection", "TabContents"}) |
| 22 @RetryOnFailure | 33 @RetryOnFailure |
| 23 public void testClickContentOnLink() throws Throwable { | 34 public void testClickContentOnLink() throws Throwable { |
| 24 startActivityWithTestUrl( | 35 mActivityTestRule.launchContentShellWithUrlSync( |
| 25 "content/test/data/android/content_detection/click_listeners.htm
l"); | 36 "content/test/data/android/content_detection/click_listeners.htm
l"); |
| 26 | 37 |
| 27 // Clicks on addresses in links should change the url. | 38 // Clicks on addresses in links should change the url. |
| 28 scrollAndTapNavigatingOut("linktest"); | 39 mActivityTestRule.scrollAndTapNavigatingOut("linktest"); |
| 29 assertTrue(isCurrentTestUrl("content/test/data/android/content_detection
/empty.html")); | 40 Assert.assertTrue(mActivityTestRule.isCurrentTestUrl("content/test/data/
android/content_detection/empty.html")); |
| 30 } | 41 } |
| 31 | 42 |
| 43 @Test |
| 32 @MediumTest | 44 @MediumTest |
| 33 @Feature({"ContentDetection", "TabContents"}) | 45 @Feature({"ContentDetection", "TabContents"}) |
| 34 public void testClickContentOnJSListener1() throws Throwable { | 46 public void testClickContentOnJSListener1() throws Throwable { |
| 35 startActivityWithTestUrl( | 47 mActivityTestRule.launchContentShellWithUrlSync( |
| 36 "content/test/data/android/content_detection/click_listeners.htm
l"); | 48 "content/test/data/android/content_detection/click_listeners.htm
l"); |
| 37 | 49 |
| 38 // Clicks on addresses in elements listening to click events should be | 50 // Clicks on addresses in elements listening to click events should be |
| 39 // processed normally without address detection. | 51 // processed normally without address detection. |
| 40 scrollAndTapNavigatingOut("clicktest1"); | 52 mActivityTestRule.scrollAndTapNavigatingOut("clicktest1"); |
| 41 assertTrue(isCurrentTestUrl("content/test/data/android/content_detection
/empty.html")); | 53 Assert.assertTrue(mActivityTestRule.isCurrentTestUrl("content/test/data/
android/content_detection/empty.html")); |
| 42 } | 54 } |
| 43 | 55 |
| 56 @Test |
| 44 @MediumTest | 57 @MediumTest |
| 45 @Feature({"ContentDetection", "TabContents"}) | 58 @Feature({"ContentDetection", "TabContents"}) |
| 46 public void testClickContentOnJSListener2() throws Throwable { | 59 public void testClickContentOnJSListener2() throws Throwable { |
| 47 startActivityWithTestUrl( | 60 mActivityTestRule.launchContentShellWithUrlSync( |
| 48 "content/test/data/android/content_detection/click_listeners.htm
l"); | 61 "content/test/data/android/content_detection/click_listeners.htm
l"); |
| 49 | 62 |
| 50 // Same as previous test, but using addEventListener instead of onclick. | 63 // Same as previous test, but using addEventListener instead of onclick. |
| 51 scrollAndTapNavigatingOut("clicktest2"); | 64 mActivityTestRule.scrollAndTapNavigatingOut("clicktest2"); |
| 52 assertTrue(isCurrentTestUrl("content/test/data/android/content_detection
/empty.html")); | 65 Assert.assertTrue(mActivityTestRule.isCurrentTestUrl("content/test/data/
android/content_detection/empty.html")); |
| 53 } | 66 } |
| 54 } | 67 } |
| OLD | NEW |