Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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.content.ClipData; | |
| 8 import android.content.ClipboardManager; | |
| 9 import android.content.Context; | |
| 7 import android.test.suitebuilder.annotation.SmallTest; | 10 import android.test.suitebuilder.annotation.SmallTest; |
| 8 | 11 |
| 9 import org.chromium.base.test.util.Feature; | 12 import org.chromium.base.test.util.Feature; |
| 10 import org.chromium.base.test.util.UrlUtils; | 13 import org.chromium.base.test.util.UrlUtils; |
| 11 import org.chromium.content.browser.test.util.Criteria; | 14 import org.chromium.content.browser.test.util.Criteria; |
| 12 import org.chromium.content.browser.test.util.CriteriaHelper; | 15 import org.chromium.content.browser.test.util.CriteriaHelper; |
| 13 import org.chromium.content.browser.test.util.DOMUtils; | 16 import org.chromium.content.browser.test.util.DOMUtils; |
| 14 import org.chromium.content_shell_apk.ContentShellTestBase; | 17 import org.chromium.content_shell_apk.ContentShellTestBase; |
| 15 | 18 |
| 16 /** | 19 /** |
| (...skipping 17 matching lines...) Expand all Loading... | |
| 34 | 37 |
| 35 @Override | 38 @Override |
| 36 public void setUp() throws Exception { | 39 public void setUp() throws Exception { |
| 37 super.setUp(); | 40 super.setUp(); |
| 38 | 41 |
| 39 launchContentShellWithUrl(DATA_URL); | 42 launchContentShellWithUrl(DATA_URL); |
| 40 assertTrue("Page failed to load", waitForActiveShellToBeDoneLoading()); | 43 assertTrue("Page failed to load", waitForActiveShellToBeDoneLoading()); |
| 41 | 44 |
| 42 mContentViewCore = getContentViewCore(); | 45 mContentViewCore = getContentViewCore(); |
| 43 assertWaitForPageScaleFactorMatch(1.1f); | 46 assertWaitForPageScaleFactorMatch(1.1f); |
| 44 assertWaitForSelectActionBarStatus(false); | 47 assertWaitForSelectActionBarStatus(false); |
|
jdduke (slow)
2014/09/03 19:30:28
Maybe add a |assertWaitForPastePopupStatus(false);
AKVT
2014/09/03 19:32:49
Done. Thanks
| |
| 45 } | 48 } |
| 46 | 49 |
| 47 @SmallTest | 50 @SmallTest |
| 48 @Feature({"TextSelection"}) | 51 @Feature({"TextSelection"}) |
| 49 public void testSelectActionBarShownOnLongPressingPlainText() throws Excepti on { | 52 public void testSelectActionBarShownOnLongPressingPlainText() throws Excepti on { |
| 50 DOMUtils.longPressNode(this, mContentViewCore, "plain_text_1"); | 53 DOMUtils.longPressNode(this, mContentViewCore, "plain_text_1"); |
| 51 assertWaitForSelectActionBarStatus(true); | 54 assertWaitForSelectActionBarStatus(true); |
| 52 DOMUtils.longPressNode(this, mContentViewCore, "empty_input_text"); | 55 DOMUtils.longPressNode(this, mContentViewCore, "empty_input_text"); |
| 53 assertWaitForSelectActionBarStatus(false); | 56 assertWaitForSelectActionBarStatus(false); |
| 54 } | 57 } |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 86 DOMUtils.longPressNode(this, mContentViewCore, "plain_text_1"); | 89 DOMUtils.longPressNode(this, mContentViewCore, "plain_text_1"); |
| 87 assertWaitForSelectActionBarStatus(true); | 90 assertWaitForSelectActionBarStatus(true); |
| 88 DOMUtils.longPressNode(this, mContentViewCore, "empty_input_text"); | 91 DOMUtils.longPressNode(this, mContentViewCore, "empty_input_text"); |
| 89 assertWaitForSelectActionBarStatus(false); | 92 assertWaitForSelectActionBarStatus(false); |
| 90 DOMUtils.longPressNode(this, mContentViewCore, "plain_text_2"); | 93 DOMUtils.longPressNode(this, mContentViewCore, "plain_text_2"); |
| 91 assertWaitForSelectActionBarStatus(true); | 94 assertWaitForSelectActionBarStatus(true); |
| 92 DOMUtils.longPressNode(this, mContentViewCore, "empty_textarea"); | 95 DOMUtils.longPressNode(this, mContentViewCore, "empty_textarea"); |
| 93 assertWaitForSelectActionBarStatus(false); | 96 assertWaitForSelectActionBarStatus(false); |
| 94 } | 97 } |
| 95 | 98 |
| 99 @SmallTest | |
| 100 @Feature({"TextInput"}) | |
| 101 public void testPastePopupNotShownOnLongPressingNonEmptyInput() throws Throw able { | |
| 102 copyStringToClipboard(); | |
| 103 DOMUtils.longPressNode(this, mContentViewCore, "empty_input_text"); | |
| 104 assertWaitForPastePopupStatus(true); | |
| 105 DOMUtils.longPressNode(this, mContentViewCore, "input_text"); | |
| 106 assertWaitForSelectActionBarStatus(true); | |
| 107 assertWaitForPastePopupStatus(false); | |
| 108 } | |
| 109 | |
| 110 @SmallTest | |
| 111 @Feature({"TextInput"}) | |
| 112 public void testPastePopupClearedOnTappingEmptyInput() throws Throwable { | |
| 113 copyStringToClipboard(); | |
| 114 DOMUtils.longPressNode(this, mContentViewCore, "empty_input_text"); | |
| 115 assertWaitForPastePopupStatus(true); | |
| 116 DOMUtils.clickNode(this, mContentViewCore, "empty_input_text"); | |
| 117 assertWaitForPastePopupStatus(false); | |
| 118 } | |
| 119 | |
| 120 @SmallTest | |
| 121 @Feature({"TextInput"}) | |
| 122 public void testPastePopupClearedOnTappingNonEmptyInput() throws Throwable { | |
| 123 copyStringToClipboard(); | |
| 124 DOMUtils.longPressNode(this, mContentViewCore, "empty_input_text"); | |
| 125 assertWaitForPastePopupStatus(true); | |
| 126 DOMUtils.clickNode(this, mContentViewCore, "input_text"); | |
| 127 assertWaitForPastePopupStatus(false); | |
| 128 } | |
| 129 | |
| 130 @SmallTest | |
| 131 @Feature({"TextInput"}) | |
| 132 public void testPastePopupClearedOnTappingOutsideInput() throws Throwable { | |
| 133 copyStringToClipboard(); | |
| 134 DOMUtils.longPressNode(this, mContentViewCore, "empty_input_text"); | |
| 135 assertWaitForPastePopupStatus(true); | |
| 136 DOMUtils.clickNode(this, mContentViewCore, "plain_text_2"); | |
| 137 assertWaitForPastePopupStatus(false); | |
| 138 } | |
| 139 | |
| 140 @SmallTest | |
| 141 @Feature({"TextInput"}) | |
| 142 public void testPastePopupClearedOnLongPressingOutsideInput() throws Throwab le { | |
| 143 copyStringToClipboard(); | |
| 144 DOMUtils.longPressNode(this, mContentViewCore, "empty_input_text"); | |
| 145 assertWaitForPastePopupStatus(true); | |
| 146 DOMUtils.longPressNode(this, mContentViewCore, "plain_text_2"); | |
| 147 assertWaitForPastePopupStatus(false); | |
| 148 } | |
| 149 | |
| 150 private void copyStringToClipboard() { | |
| 151 ClipboardManager clipboardManager = | |
| 152 (ClipboardManager) getActivity().getSystemService( | |
| 153 Context.CLIPBOARD_SERVICE); | |
| 154 ClipData clip = ClipData.newPlainText("test", "Text to copy"); | |
| 155 clipboardManager.setPrimaryClip(clip); | |
| 156 } | |
| 157 | |
| 158 private void assertWaitForPastePopupStatus(final boolean show) throws Interr uptedException { | |
| 159 assertTrue(CriteriaHelper.pollForCriteria(new Criteria() { | |
| 160 @Override | |
| 161 public boolean isSatisfied() { | |
| 162 return show == mContentViewCore.getPastePopupForTest().isShowing (); | |
| 163 } | |
| 164 })); | |
| 165 } | |
| 166 | |
| 96 private void assertWaitForSelectActionBarStatus( | 167 private void assertWaitForSelectActionBarStatus( |
| 97 final boolean show) throws InterruptedException { | 168 final boolean show) throws InterruptedException { |
| 98 assertTrue(CriteriaHelper.pollForCriteria(new Criteria() { | 169 assertTrue(CriteriaHelper.pollForCriteria(new Criteria() { |
| 99 @Override | 170 @Override |
| 100 public boolean isSatisfied() { | 171 public boolean isSatisfied() { |
| 101 return show == mContentViewCore.isSelectActionBarShowing(); | 172 return show == mContentViewCore.isSelectActionBarShowing(); |
| 102 } | 173 } |
| 103 })); | 174 })); |
| 104 } | 175 } |
| 105 } | 176 } |
| OLD | NEW |