| 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; | 7 import android.content.ClipData; |
| 8 import android.content.ClipboardManager; | 8 import android.content.ClipboardManager; |
| 9 import android.content.Context; | 9 import android.content.Context; |
| 10 import android.test.suitebuilder.annotation.SmallTest; | 10 import android.test.suitebuilder.annotation.SmallTest; |
| (...skipping 14 matching lines...) Expand all Loading... |
| 25 "<html><head><meta name=\"viewport\"" + | 25 "<html><head><meta name=\"viewport\"" + |
| 26 "content=\"width=device-width, initial-scale=1.1, maximum-scale=1.5\
" /></head>" + | 26 "content=\"width=device-width, initial-scale=1.1, maximum-scale=1.5\
" /></head>" + |
| 27 "<body><form action=\"about:blank\">" + | 27 "<body><form action=\"about:blank\">" + |
| 28 "<input id=\"empty_input_text\" type=\"text\" />" + | 28 "<input id=\"empty_input_text\" type=\"text\" />" + |
| 29 "<br/><p><span id=\"plain_text_1\">This is Plain Text One</span></p>
" + | 29 "<br/><p><span id=\"plain_text_1\">This is Plain Text One</span></p>
" + |
| 30 "<br/><p><span id=\"plain_text_2\">This is Plain Text Two</span></p>
" + | 30 "<br/><p><span id=\"plain_text_2\">This is Plain Text Two</span></p>
" + |
| 31 "<br/><input id=\"empty_input_text\" type=\"text\" />" + | 31 "<br/><input id=\"empty_input_text\" type=\"text\" />" + |
| 32 "<br/><input id=\"input_text\" type=\"text\" value=\"Sample Text\" /
>" + | 32 "<br/><input id=\"input_text\" type=\"text\" value=\"Sample Text\" /
>" + |
| 33 "<br/><textarea id=\"empty_textarea\" rows=\"2\" cols=\"20\"></texta
rea>" + | 33 "<br/><textarea id=\"empty_textarea\" rows=\"2\" cols=\"20\"></texta
rea>" + |
| 34 "<br/><textarea id=\"textarea\" rows=\"2\" cols=\"20\">Sample Text</
textarea>" + | 34 "<br/><textarea id=\"textarea\" rows=\"2\" cols=\"20\">Sample Text</
textarea>" + |
| 35 "<br/><input id=\"readonly_text\" type=\"text\" readonly value=\"Sam
ple Text\"/>" + |
| 36 "<br/><input id=\"disabled_text\" type=\"text\" disabled value=\"Sam
ple Text\" />" + |
| 35 "</form></body></html>"); | 37 "</form></body></html>"); |
| 36 | 38 |
| 37 private ContentViewCore mContentViewCore; | 39 private ContentViewCore mContentViewCore; |
| 38 | 40 |
| 39 @Override | 41 @Override |
| 40 public void setUp() throws Exception { | 42 public void setUp() throws Exception { |
| 41 super.setUp(); | 43 super.setUp(); |
| 42 | 44 |
| 43 launchContentShellWithUrl(DATA_URL); | 45 launchContentShellWithUrl(DATA_URL); |
| 44 assertTrue("Page failed to load", waitForActiveShellToBeDoneLoading()); | 46 assertTrue("Page failed to load", waitForActiveShellToBeDoneLoading()); |
| (...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 166 @SmallTest | 168 @SmallTest |
| 167 @Feature({"TextInput"}) | 169 @Feature({"TextInput"}) |
| 168 public void testPastePopupClearedOnLongPressingOutsideInput() throws Throwab
le { | 170 public void testPastePopupClearedOnLongPressingOutsideInput() throws Throwab
le { |
| 169 copyStringToClipboard(); | 171 copyStringToClipboard(); |
| 170 DOMUtils.longPressNode(this, mContentViewCore, "empty_input_text"); | 172 DOMUtils.longPressNode(this, mContentViewCore, "empty_input_text"); |
| 171 assertWaitForPastePopupStatus(true); | 173 assertWaitForPastePopupStatus(true); |
| 172 DOMUtils.longPressNode(this, mContentViewCore, "plain_text_2"); | 174 DOMUtils.longPressNode(this, mContentViewCore, "plain_text_2"); |
| 173 assertWaitForPastePopupStatus(false); | 175 assertWaitForPastePopupStatus(false); |
| 174 } | 176 } |
| 175 | 177 |
| 178 @SmallTest |
| 179 @Feature({"TextInput"}) |
| 180 public void testPastePopupNotShownOnLongPressingReadOnlyInput() throws Throw
able { |
| 181 copyStringToClipboard(); |
| 182 DOMUtils.longPressNode(this, mContentViewCore, "empty_input_text"); |
| 183 assertWaitForPastePopupStatus(true); |
| 184 assertTrue(mContentViewCore.hasInsertion()); |
| 185 DOMUtils.longPressNode(this, mContentViewCore, "readonly_text"); |
| 186 assertWaitForPastePopupStatus(false); |
| 187 assertFalse(mContentViewCore.hasInsertion()); |
| 188 } |
| 189 |
| 190 @SmallTest |
| 191 @Feature({"TextInput"}) |
| 192 public void testPastePopupNotShownOnLongPressingDisabledInput() throws Throw
able { |
| 193 copyStringToClipboard(); |
| 194 DOMUtils.longPressNode(this, mContentViewCore, "empty_input_text"); |
| 195 assertWaitForPastePopupStatus(true); |
| 196 assertTrue(mContentViewCore.hasInsertion()); |
| 197 DOMUtils.longPressNode(this, mContentViewCore, "disabled_text"); |
| 198 assertWaitForPastePopupStatus(false); |
| 199 assertFalse(mContentViewCore.hasInsertion()); |
| 200 } |
| 201 |
| 176 private void assertWaitForSelectActionBarVisible( | 202 private void assertWaitForSelectActionBarVisible( |
| 177 final boolean visible) throws InterruptedException { | 203 final boolean visible) throws InterruptedException { |
| 178 assertTrue(CriteriaHelper.pollForCriteria(new Criteria() { | 204 assertTrue(CriteriaHelper.pollForCriteria(new Criteria() { |
| 179 @Override | 205 @Override |
| 180 public boolean isSatisfied() { | 206 public boolean isSatisfied() { |
| 181 return visible == mContentViewCore.isSelectActionBarShowing(); | 207 return visible == mContentViewCore.isSelectActionBarShowing(); |
| 182 } | 208 } |
| 183 })); | 209 })); |
| 184 } | 210 } |
| 185 | 211 |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 231 | 257 |
| 232 private void assertWaitForPastePopupStatus(final boolean show) throws Interr
uptedException { | 258 private void assertWaitForPastePopupStatus(final boolean show) throws Interr
uptedException { |
| 233 assertTrue(CriteriaHelper.pollForCriteria(new Criteria() { | 259 assertTrue(CriteriaHelper.pollForCriteria(new Criteria() { |
| 234 @Override | 260 @Override |
| 235 public boolean isSatisfied() { | 261 public boolean isSatisfied() { |
| 236 return show == mContentViewCore.getPastePopupForTest().isShowing
(); | 262 return show == mContentViewCore.getPastePopupForTest().isShowing
(); |
| 237 } | 263 } |
| 238 })); | 264 })); |
| 239 } | 265 } |
| 240 } | 266 } |
| OLD | NEW |