Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(453)

Side by Side Diff: content/public/android/javatests/src/org/chromium/content/browser/ContentViewCoreSelectionTest.java

Issue 2766393004: Convert most of the rest of instrumentation tests in content (Closed)
Patch Set: Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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.content.Intent; 10 import android.content.Intent;
11 import android.support.test.filters.SmallTest; 11 import android.support.test.filters.SmallTest;
12 import android.text.TextUtils; 12 import android.text.TextUtils;
13 13
14 import org.junit.Assert;
15 import org.junit.Before;
16 import org.junit.Rule;
17 import org.junit.Test;
18 import org.junit.runner.RunWith;
19
14 import org.chromium.base.ThreadUtils; 20 import org.chromium.base.ThreadUtils;
21 import org.chromium.base.test.BaseJUnit4ClassRunner;
15 import org.chromium.base.test.util.DisabledTest; 22 import org.chromium.base.test.util.DisabledTest;
16 import org.chromium.base.test.util.Feature; 23 import org.chromium.base.test.util.Feature;
17 import org.chromium.base.test.util.UrlUtils; 24 import org.chromium.base.test.util.UrlUtils;
18 import org.chromium.content.browser.input.ChromiumBaseInputConnection; 25 import org.chromium.content.browser.input.ChromiumBaseInputConnection;
19 import org.chromium.content.browser.input.ImeTestUtils; 26 import org.chromium.content.browser.input.ImeTestUtils;
20 import org.chromium.content.browser.test.util.Criteria; 27 import org.chromium.content.browser.test.util.Criteria;
21 import org.chromium.content.browser.test.util.CriteriaHelper; 28 import org.chromium.content.browser.test.util.CriteriaHelper;
22 import org.chromium.content.browser.test.util.DOMUtils; 29 import org.chromium.content.browser.test.util.DOMUtils;
23 import org.chromium.content_shell_apk.ContentShellTestBase; 30 import org.chromium.content_shell_apk.ContentShellActivityTestRule;
24 31
25 import java.util.concurrent.Callable; 32 import java.util.concurrent.Callable;
26 33
27 /** 34 /**
28 * Integration tests for text selection-related behavior. 35 * Integration tests for text selection-related behavior.
29 */ 36 */
30 public class ContentViewCoreSelectionTest extends ContentShellTestBase { 37 @RunWith(BaseJUnit4ClassRunner.class)
38 public class ContentViewCoreSelectionTest {
39 @Rule
40 public ContentShellActivityTestRule mActivityTestRule = new ContentShellActi vityTestRule();
31 private static final String DATA_URL = UrlUtils.encodeHtmlDataUri( 41 private static final String DATA_URL = UrlUtils.encodeHtmlDataUri(
32 "<html><head><meta name=\"viewport\"" 42 "<html><head><meta name=\"viewport\""
33 + "content=\"width=device-width, initial-scale=1.1, maximum-scale=1. 5\" /></head>" 43 + "content=\"width=device-width, initial-scale=1.1, maximum-scale=1. 5\" /></head>"
34 + "<body><form action=\"about:blank\">" 44 + "<body><form action=\"about:blank\">"
35 + "<input id=\"empty_input_text\" type=\"text\" />" 45 + "<input id=\"empty_input_text\" type=\"text\" />"
36 + "<br/><input id=\"input_text\" type=\"text\" value=\"SampleInputTe xt\" />" 46 + "<br/><input id=\"input_text\" type=\"text\" value=\"SampleInputTe xt\" />"
37 + "<br/><textarea id=\"textarea\" rows=\"2\" cols=\"20\">SampleTextA rea</textarea>" 47 + "<br/><textarea id=\"textarea\" rows=\"2\" cols=\"20\">SampleTextA rea</textarea>"
38 + "<br/><input id=\"password\" type=\"password\" value=\"SamplePassw ord\" size=\"10\"/>" 48 + "<br/><input id=\"password\" type=\"password\" value=\"SamplePassw ord\" size=\"10\"/>"
39 + "<br/><p><span id=\"plain_text_1\">SamplePlainTextOne</span></p>" 49 + "<br/><p><span id=\"plain_text_1\">SamplePlainTextOne</span></p>"
40 + "<br/><p><span id=\"plain_text_2\">SamplePlainTextTwo</span></p>" 50 + "<br/><p><span id=\"plain_text_2\">SamplePlainTextTwo</span></p>"
41 + "<br/><input id=\"disabled_text\" type=\"text\" disabled value=\"S ample Text\" />" 51 + "<br/><input id=\"disabled_text\" type=\"text\" disabled value=\"S ample Text\" />"
42 + "</form></body></html>"); 52 + "</form></body></html>");
43 private ContentViewCore mContentViewCore; 53 private ContentViewCore mContentViewCore;
44 private SelectionPopupController mSelectionPopupController; 54 private SelectionPopupController mSelectionPopupController;
45 55
46 @Override 56 @Before
47 public void setUp() throws Exception { 57 public void setUp() throws Exception {
48 super.setUp(); 58 mActivityTestRule.launchContentShellWithUrl(DATA_URL);
59 mActivityTestRule.waitForActiveShellToBeDoneLoading();
49 60
50 launchContentShellWithUrl(DATA_URL); 61 mContentViewCore = mActivityTestRule.getContentViewCore();
51 waitForActiveShellToBeDoneLoading();
52
53 mContentViewCore = getContentViewCore();
54 mSelectionPopupController = mContentViewCore.getSelectionPopupController ForTesting(); 62 mSelectionPopupController = mContentViewCore.getSelectionPopupController ForTesting();
55 waitForSelectActionBarVisible(false); 63 waitForSelectActionBarVisible(false);
56 waitForPastePopupStatus(false); 64 waitForPastePopupStatus(false);
57 } 65 }
58 66
67 @Test
59 @SmallTest 68 @SmallTest
60 @Feature({"TextSelection"}) 69 @Feature({"TextSelection"})
61 @DisabledTest(message = "crbug.com/592428") 70 @DisabledTest(message = "crbug.com/592428")
62 public void testSelectionClearedAfterLossOfFocus() throws Throwable { 71 public void testSelectionClearedAfterLossOfFocus() throws Throwable {
63 requestFocusOnUiThread(true); 72 requestFocusOnUiThread(true);
64 73
65 DOMUtils.longPressNode(mContentViewCore, "textarea"); 74 DOMUtils.longPressNode(mContentViewCore, "textarea");
66 waitForSelectActionBarVisible(true); 75 waitForSelectActionBarVisible(true);
67 76
68 requestFocusOnUiThread(false); 77 requestFocusOnUiThread(false);
69 waitForSelectActionBarVisible(false); 78 waitForSelectActionBarVisible(false);
70 assertFalse(mSelectionPopupController.hasSelection()); 79 Assert.assertFalse(mSelectionPopupController.hasSelection());
71 80
72 requestFocusOnUiThread(true); 81 requestFocusOnUiThread(true);
73 waitForSelectActionBarVisible(false); 82 waitForSelectActionBarVisible(false);
74 assertFalse(mSelectionPopupController.hasSelection()); 83 Assert.assertFalse(mSelectionPopupController.hasSelection());
75 } 84 }
76 85
86 @Test
77 @SmallTest 87 @SmallTest
78 @Feature({"TextSelection"}) 88 @Feature({"TextSelection"})
79 @DisabledTest(message = "crbug.com/592428") 89 @DisabledTest(message = "crbug.com/592428")
80 public void testSelectionPreservedAfterLossOfFocusIfRequested() throws Throw able { 90 public void testSelectionPreservedAfterLossOfFocusIfRequested() throws Throw able {
81 requestFocusOnUiThread(true); 91 requestFocusOnUiThread(true);
82 92
83 DOMUtils.longPressNode(mContentViewCore, "textarea"); 93 DOMUtils.longPressNode(mContentViewCore, "textarea");
84 waitForSelectActionBarVisible(true); 94 waitForSelectActionBarVisible(true);
85 assertTrue(mSelectionPopupController.hasSelection()); 95 Assert.assertTrue(mSelectionPopupController.hasSelection());
86 96
87 mContentViewCore.preserveSelectionOnNextLossOfFocus(); 97 mContentViewCore.preserveSelectionOnNextLossOfFocus();
88 requestFocusOnUiThread(false); 98 requestFocusOnUiThread(false);
89 waitForSelectActionBarVisible(false); 99 waitForSelectActionBarVisible(false);
90 assertTrue(mSelectionPopupController.hasSelection()); 100 Assert.assertTrue(mSelectionPopupController.hasSelection());
91 101
92 requestFocusOnUiThread(true); 102 requestFocusOnUiThread(true);
93 waitForSelectActionBarVisible(true); 103 waitForSelectActionBarVisible(true);
94 assertTrue(mSelectionPopupController.hasSelection()); 104 Assert.assertTrue(mSelectionPopupController.hasSelection());
95 105
96 // Losing focus yet again should properly clear the selection. 106 // Losing focus yet again should properly clear the selection.
97 requestFocusOnUiThread(false); 107 requestFocusOnUiThread(false);
98 waitForSelectActionBarVisible(false); 108 waitForSelectActionBarVisible(false);
99 assertFalse(mSelectionPopupController.hasSelection()); 109 Assert.assertFalse(mSelectionPopupController.hasSelection());
100 } 110 }
101 111
112 @Test
102 @SmallTest 113 @SmallTest
103 @Feature({"TextSelection"}) 114 @Feature({"TextSelection"})
104 @DisabledTest(message = "crbug.com/592428") 115 @DisabledTest(message = "crbug.com/592428")
105 public void testSelectionPreservedAfterReshown() throws Throwable { 116 public void testSelectionPreservedAfterReshown() throws Throwable {
106 DOMUtils.longPressNode(mContentViewCore, "textarea"); 117 DOMUtils.longPressNode(mContentViewCore, "textarea");
107 waitForSelectActionBarVisible(true); 118 waitForSelectActionBarVisible(true);
108 assertTrue(mSelectionPopupController.hasSelection()); 119 Assert.assertTrue(mSelectionPopupController.hasSelection());
109 120
110 setVisibileOnUiThread(false); 121 setVisibileOnUiThread(false);
111 waitForSelectActionBarVisible(false); 122 waitForSelectActionBarVisible(false);
112 assertTrue(mSelectionPopupController.hasSelection()); 123 Assert.assertTrue(mSelectionPopupController.hasSelection());
113 124
114 setVisibileOnUiThread(true); 125 setVisibileOnUiThread(true);
115 waitForSelectActionBarVisible(true); 126 waitForSelectActionBarVisible(true);
116 assertTrue(mSelectionPopupController.hasSelection()); 127 Assert.assertTrue(mSelectionPopupController.hasSelection());
117 } 128 }
118 129
130 @Test
119 @SmallTest 131 @SmallTest
120 @Feature({"TextSelection"}) 132 @Feature({"TextSelection"})
121 @DisabledTest(message = "crbug.com/592428") 133 @DisabledTest(message = "crbug.com/592428")
122 public void testSelectionPreservedAfterReattached() throws Throwable { 134 public void testSelectionPreservedAfterReattached() throws Throwable {
123 DOMUtils.longPressNode(mContentViewCore, "textarea"); 135 DOMUtils.longPressNode(mContentViewCore, "textarea");
124 waitForSelectActionBarVisible(true); 136 waitForSelectActionBarVisible(true);
125 assertTrue(mSelectionPopupController.hasSelection()); 137 Assert.assertTrue(mSelectionPopupController.hasSelection());
126 138
127 setAttachedOnUiThread(false); 139 setAttachedOnUiThread(false);
128 waitForSelectActionBarVisible(false); 140 waitForSelectActionBarVisible(false);
129 assertTrue(mSelectionPopupController.hasSelection()); 141 Assert.assertTrue(mSelectionPopupController.hasSelection());
130 142
131 setAttachedOnUiThread(true); 143 setAttachedOnUiThread(true);
132 waitForSelectActionBarVisible(true); 144 waitForSelectActionBarVisible(true);
133 assertTrue(mSelectionPopupController.hasSelection()); 145 Assert.assertTrue(mSelectionPopupController.hasSelection());
134 } 146 }
135 147
136 /* 148 /*
137 @SmallTest 149 @SmallTest
138 @Feature({"TextInput"}) 150 @Feature({"TextInput"})
139 */ 151 */
152 @Test
140 @DisabledTest(message = "https://crbug.com/592428") 153 @DisabledTest(message = "https://crbug.com/592428")
141 public void testPastePopupNotShownOnLongPressingNonEmptyInput() throws Throw able { 154 public void testPastePopupNotShownOnLongPressingNonEmptyInput() throws Throw able {
142 copyStringToClipboard("SampleTextToCopy"); 155 copyStringToClipboard("SampleTextToCopy");
143 DOMUtils.longPressNode(mContentViewCore, "empty_input_text"); 156 DOMUtils.longPressNode(mContentViewCore, "empty_input_text");
144 waitForPastePopupStatus(true); 157 waitForPastePopupStatus(true);
145 DOMUtils.longPressNode(mContentViewCore, "input_text"); 158 DOMUtils.longPressNode(mContentViewCore, "input_text");
146 waitForSelectActionBarVisible(true); 159 waitForSelectActionBarVisible(true);
147 waitForPastePopupStatus(false); 160 waitForPastePopupStatus(false);
148 } 161 }
149 162
163 @Test
150 @SmallTest 164 @SmallTest
151 @Feature({"TextInput"}) 165 @Feature({"TextInput"})
152 public void testPastePopupClearedOnTappingEmptyInput() throws Throwable { 166 public void testPastePopupClearedOnTappingEmptyInput() throws Throwable {
153 copyStringToClipboard("SampleTextToCopy"); 167 copyStringToClipboard("SampleTextToCopy");
154 DOMUtils.longPressNode(mContentViewCore, "empty_input_text"); 168 DOMUtils.longPressNode(mContentViewCore, "empty_input_text");
155 waitForPastePopupStatus(true); 169 waitForPastePopupStatus(true);
156 DOMUtils.clickNode(mContentViewCore, "empty_input_text"); 170 DOMUtils.clickNode(mContentViewCore, "empty_input_text");
157 waitForPastePopupStatus(false); 171 waitForPastePopupStatus(false);
158 } 172 }
159 173
174 @Test
160 @SmallTest 175 @SmallTest
161 @Feature({"TextInput"}) 176 @Feature({"TextInput"})
162 public void testPastePopupClearedOnTappingNonEmptyInput() throws Throwable { 177 public void testPastePopupClearedOnTappingNonEmptyInput() throws Throwable {
163 copyStringToClipboard("SampleTextToCopy"); 178 copyStringToClipboard("SampleTextToCopy");
164 DOMUtils.longPressNode(mContentViewCore, "empty_input_text"); 179 DOMUtils.longPressNode(mContentViewCore, "empty_input_text");
165 waitForPastePopupStatus(true); 180 waitForPastePopupStatus(true);
166 DOMUtils.clickNode(mContentViewCore, "input_text"); 181 DOMUtils.clickNode(mContentViewCore, "input_text");
167 waitForPastePopupStatus(false); 182 waitForPastePopupStatus(false);
168 } 183 }
169 184
185 @Test
170 @SmallTest 186 @SmallTest
171 @Feature({"TextInput"}) 187 @Feature({"TextInput"})
172 public void testPastePopupClearedOnTappingOutsideInput() throws Throwable { 188 public void testPastePopupClearedOnTappingOutsideInput() throws Throwable {
173 copyStringToClipboard("SampleTextToCopy"); 189 copyStringToClipboard("SampleTextToCopy");
174 DOMUtils.longPressNode(mContentViewCore, "empty_input_text"); 190 DOMUtils.longPressNode(mContentViewCore, "empty_input_text");
175 waitForPastePopupStatus(true); 191 waitForPastePopupStatus(true);
176 DOMUtils.clickNode(mContentViewCore, "plain_text_2"); 192 DOMUtils.clickNode(mContentViewCore, "plain_text_2");
177 waitForPastePopupStatus(false); 193 waitForPastePopupStatus(false);
178 } 194 }
179 195
196 @Test
180 @SmallTest 197 @SmallTest
181 @Feature({"TextInput"}) 198 @Feature({"TextInput"})
182 public void testPastePopupClearedOnLongPressingOutsideInput() throws Throwab le { 199 public void testPastePopupClearedOnLongPressingOutsideInput() throws Throwab le {
183 copyStringToClipboard("SampleTextToCopy"); 200 copyStringToClipboard("SampleTextToCopy");
184 DOMUtils.longPressNode(mContentViewCore, "empty_input_text"); 201 DOMUtils.longPressNode(mContentViewCore, "empty_input_text");
185 waitForPastePopupStatus(true); 202 waitForPastePopupStatus(true);
186 DOMUtils.longPressNode(mContentViewCore, "plain_text_2"); 203 DOMUtils.longPressNode(mContentViewCore, "plain_text_2");
187 waitForPastePopupStatus(false); 204 waitForPastePopupStatus(false);
188 } 205 }
189 206
207 @Test
190 @SmallTest 208 @SmallTest
191 @Feature({"TextInput"}) 209 @Feature({"TextInput"})
192 public void testPastePopupNotShownOnLongPressingDisabledInput() throws Throw able { 210 public void testPastePopupNotShownOnLongPressingDisabledInput() throws Throw able {
193 copyStringToClipboard("SampleTextToCopy"); 211 copyStringToClipboard("SampleTextToCopy");
194 DOMUtils.longPressNode(mContentViewCore, "empty_input_text"); 212 DOMUtils.longPressNode(mContentViewCore, "empty_input_text");
195 waitForPastePopupStatus(true); 213 waitForPastePopupStatus(true);
196 waitForInsertion(true); 214 waitForInsertion(true);
197 DOMUtils.longPressNode(mContentViewCore, "disabled_text"); 215 DOMUtils.longPressNode(mContentViewCore, "disabled_text");
198 waitForPastePopupStatus(false); 216 waitForPastePopupStatus(false);
199 waitForInsertion(false); 217 waitForInsertion(false);
200 } 218 }
201 219
202 /* 220 /*
203 @SmallTest 221 @SmallTest
204 @Feature({"TextInput"}) 222 @Feature({"TextInput"})
205 */ 223 */
224 @Test
206 @DisabledTest(message = "https://crbug.com/592428") 225 @DisabledTest(message = "https://crbug.com/592428")
207 public void testPastePopupDismissedOnDestroy() throws Throwable { 226 public void testPastePopupDismissedOnDestroy() throws Throwable {
208 copyStringToClipboard("SampleTextToCopy"); 227 copyStringToClipboard("SampleTextToCopy");
209 DOMUtils.longPressNode(mContentViewCore, "empty_input_text"); 228 DOMUtils.longPressNode(mContentViewCore, "empty_input_text");
210 waitForPastePopupStatus(true); 229 waitForPastePopupStatus(true);
211 ThreadUtils.runOnUiThreadBlocking(new Runnable() { 230 ThreadUtils.runOnUiThreadBlocking(new Runnable() {
212 @Override 231 @Override
213 public void run() { 232 public void run() {
214 mContentViewCore.destroy(); 233 mContentViewCore.destroy();
215 } 234 }
216 }); 235 });
217 waitForPastePopupStatus(false); 236 waitForPastePopupStatus(false);
218 } 237 }
219 238
239 @Test
220 @SmallTest 240 @SmallTest
221 @Feature({"TextInput"}) 241 @Feature({"TextInput"})
222 @DisabledTest(message = "crbug.com/592428") 242 @DisabledTest(message = "crbug.com/592428")
223 public void testActionBarConfiguredCorrectlyForInput() throws Throwable { 243 public void testActionBarConfiguredCorrectlyForInput() throws Throwable {
224 DOMUtils.longPressNode(mContentViewCore, "input_text"); 244 DOMUtils.longPressNode(mContentViewCore, "input_text");
225 waitForSelectActionBarVisible(true); 245 waitForSelectActionBarVisible(true);
226 assertTrue(mSelectionPopupController.hasSelection()); 246 Assert.assertTrue(mSelectionPopupController.hasSelection());
227 assertTrue(mSelectionPopupController.isActionModeValid()); 247 Assert.assertTrue(mSelectionPopupController.isActionModeValid());
228 assertTrue(mSelectionPopupController.isSelectionEditable()); 248 Assert.assertTrue(mSelectionPopupController.isSelectionEditable());
229 assertFalse(mSelectionPopupController.isSelectionPassword()); 249 Assert.assertFalse(mSelectionPopupController.isSelectionPassword());
230 } 250 }
231 251
252 @Test
232 @SmallTest 253 @SmallTest
233 @Feature({"TextInput"}) 254 @Feature({"TextInput"})
234 @DisabledTest(message = "crbug.com/592428") 255 @DisabledTest(message = "crbug.com/592428")
235 public void testActionBarConfiguredCorrectlyForPassword() throws Throwable { 256 public void testActionBarConfiguredCorrectlyForPassword() throws Throwable {
236 DOMUtils.longPressNode(mContentViewCore, "password"); 257 DOMUtils.longPressNode(mContentViewCore, "password");
237 waitForSelectActionBarVisible(true); 258 waitForSelectActionBarVisible(true);
238 assertTrue(mSelectionPopupController.hasSelection()); 259 Assert.assertTrue(mSelectionPopupController.hasSelection());
239 assertTrue(mSelectionPopupController.isActionModeValid()); 260 Assert.assertTrue(mSelectionPopupController.isActionModeValid());
240 assertTrue(mSelectionPopupController.isSelectionEditable()); 261 Assert.assertTrue(mSelectionPopupController.isSelectionEditable());
241 assertTrue(mSelectionPopupController.isSelectionPassword()); 262 Assert.assertTrue(mSelectionPopupController.isSelectionPassword());
242 } 263 }
243 264
265 @Test
244 @SmallTest 266 @SmallTest
245 @Feature({"TextInput"}) 267 @Feature({"TextInput"})
246 @DisabledTest(message = "crbug.com/592428") 268 @DisabledTest(message = "crbug.com/592428")
247 public void testActionBarConfiguredCorrectlyForPlainText() throws Throwable { 269 public void testActionBarConfiguredCorrectlyForPlainText() throws Throwable {
248 DOMUtils.longPressNode(mContentViewCore, "plain_text_1"); 270 DOMUtils.longPressNode(mContentViewCore, "plain_text_1");
249 waitForSelectActionBarVisible(true); 271 waitForSelectActionBarVisible(true);
250 assertTrue(mSelectionPopupController.hasSelection()); 272 Assert.assertTrue(mSelectionPopupController.hasSelection());
251 assertTrue(mSelectionPopupController.isActionModeValid()); 273 Assert.assertTrue(mSelectionPopupController.isActionModeValid());
252 assertFalse(mSelectionPopupController.isSelectionEditable()); 274 Assert.assertFalse(mSelectionPopupController.isSelectionEditable());
253 assertFalse(mSelectionPopupController.isSelectionPassword()); 275 Assert.assertFalse(mSelectionPopupController.isSelectionPassword());
254 } 276 }
255 277
278 @Test
256 @SmallTest 279 @SmallTest
257 @Feature({"TextInput"}) 280 @Feature({"TextInput"})
258 @DisabledTest(message = "crbug.com/592428") 281 @DisabledTest(message = "crbug.com/592428")
259 public void testActionBarConfiguredCorrectlyForTextArea() throws Throwable { 282 public void testActionBarConfiguredCorrectlyForTextArea() throws Throwable {
260 DOMUtils.longPressNode(mContentViewCore, "textarea"); 283 DOMUtils.longPressNode(mContentViewCore, "textarea");
261 waitForSelectActionBarVisible(true); 284 waitForSelectActionBarVisible(true);
262 assertTrue(mSelectionPopupController.hasSelection()); 285 Assert.assertTrue(mSelectionPopupController.hasSelection());
263 assertTrue(mSelectionPopupController.isActionModeValid()); 286 Assert.assertTrue(mSelectionPopupController.isActionModeValid());
264 assertTrue(mSelectionPopupController.isSelectionEditable()); 287 Assert.assertTrue(mSelectionPopupController.isSelectionEditable());
265 assertFalse(mSelectionPopupController.isSelectionPassword()); 288 Assert.assertFalse(mSelectionPopupController.isSelectionPassword());
266 } 289 }
267 290
291 @Test
268 @SmallTest 292 @SmallTest
269 @Feature({"TextInput"}) 293 @Feature({"TextInput"})
270 @DisabledTest(message = "crbug.com/592428") 294 @DisabledTest(message = "crbug.com/592428")
271 public void testSelectActionBarPlainTextCopy() throws Exception { 295 public void testSelectActionBarPlainTextCopy() throws Exception {
272 DOMUtils.longPressNode(mContentViewCore, "plain_text_1"); 296 DOMUtils.longPressNode(mContentViewCore, "plain_text_1");
273 waitForSelectActionBarVisible(true); 297 waitForSelectActionBarVisible(true);
274 assertTrue(mSelectionPopupController.hasSelection()); 298 Assert.assertTrue(mSelectionPopupController.hasSelection());
275 assertTrue(mSelectionPopupController.isActionModeValid()); 299 Assert.assertTrue(mSelectionPopupController.isActionModeValid());
276 selectActionBarCopy(); 300 selectActionBarCopy();
277 waitForClipboardContents(mContentViewCore.getContext(), "SamplePlainText One"); 301 waitForClipboardContents(mContentViewCore.getContext(), "SamplePlainText One");
278 } 302 }
279 303
304 @Test
280 @SmallTest 305 @SmallTest
281 @Feature({"TextInput"}) 306 @Feature({"TextInput"})
282 @DisabledTest(message = "crbug.com/592428") 307 @DisabledTest(message = "crbug.com/592428")
283 public void testSelectActionBarInputCopy() throws Exception { 308 public void testSelectActionBarInputCopy() throws Exception {
284 DOMUtils.longPressNode(mContentViewCore, "input_text"); 309 DOMUtils.longPressNode(mContentViewCore, "input_text");
285 waitForSelectActionBarVisible(true); 310 waitForSelectActionBarVisible(true);
286 assertTrue(mSelectionPopupController.hasSelection()); 311 Assert.assertTrue(mSelectionPopupController.hasSelection());
287 assertTrue(mSelectionPopupController.isActionModeValid()); 312 Assert.assertTrue(mSelectionPopupController.isActionModeValid());
288 selectActionBarCopy(); 313 selectActionBarCopy();
289 waitForClipboardContents(mContentViewCore.getContext(), "SampleInputText "); 314 waitForClipboardContents(mContentViewCore.getContext(), "SampleInputText ");
290 } 315 }
291 316
317 @Test
292 @SmallTest 318 @SmallTest
293 @Feature({"TextInput"}) 319 @Feature({"TextInput"})
294 @DisabledTest(message = "crbug.com/592428") 320 @DisabledTest(message = "crbug.com/592428")
295 public void testSelectActionBarPasswordCopy() throws Exception { 321 public void testSelectActionBarPasswordCopy() throws Exception {
296 DOMUtils.longPressNode(mContentViewCore, "plain_text_1"); 322 DOMUtils.longPressNode(mContentViewCore, "plain_text_1");
297 waitForSelectActionBarVisible(true); 323 waitForSelectActionBarVisible(true);
298 assertTrue(mSelectionPopupController.hasSelection()); 324 Assert.assertTrue(mSelectionPopupController.hasSelection());
299 assertTrue(mSelectionPopupController.isActionModeValid()); 325 Assert.assertTrue(mSelectionPopupController.isActionModeValid());
300 selectActionBarCopy(); 326 selectActionBarCopy();
301 waitForClipboardContents(mContentViewCore.getContext(), "SamplePlainText One"); 327 waitForClipboardContents(mContentViewCore.getContext(), "SamplePlainText One");
302 DOMUtils.longPressNode(mContentViewCore, "password"); 328 DOMUtils.longPressNode(mContentViewCore, "password");
303 waitForSelectActionBarVisible(true); 329 waitForSelectActionBarVisible(true);
304 assertTrue(mSelectionPopupController.hasSelection()); 330 Assert.assertTrue(mSelectionPopupController.hasSelection());
305 assertTrue(mSelectionPopupController.isActionModeValid()); 331 Assert.assertTrue(mSelectionPopupController.isActionModeValid());
306 selectActionBarCopy(); 332 selectActionBarCopy();
307 // Copy option won't be there for Password, hence no change in Clipboard 333 // Copy option won't be there for Password, hence no change in Clipboard
308 // Validating with previous Clipboard content 334 // Validating with previous Clipboard content
309 waitForClipboardContents(mContentViewCore.getContext(), "SamplePlainText One"); 335 waitForClipboardContents(mContentViewCore.getContext(), "SamplePlainText One");
310 } 336 }
311 337
338 @Test
312 @SmallTest 339 @SmallTest
313 @Feature({"TextInput"}) 340 @Feature({"TextInput"})
314 @DisabledTest(message = "crbug.com/592428") 341 @DisabledTest(message = "crbug.com/592428")
315 public void testSelectActionBarTextAreaCopy() throws Exception { 342 public void testSelectActionBarTextAreaCopy() throws Exception {
316 DOMUtils.longPressNode(mContentViewCore, "textarea"); 343 DOMUtils.longPressNode(mContentViewCore, "textarea");
317 waitForSelectActionBarVisible(true); 344 waitForSelectActionBarVisible(true);
318 assertTrue(mSelectionPopupController.hasSelection()); 345 Assert.assertTrue(mSelectionPopupController.hasSelection());
319 assertTrue(mSelectionPopupController.isActionModeValid()); 346 Assert.assertTrue(mSelectionPopupController.isActionModeValid());
320 selectActionBarCopy(); 347 selectActionBarCopy();
321 waitForClipboardContents(mContentViewCore.getContext(), "SampleTextArea" ); 348 waitForClipboardContents(mContentViewCore.getContext(), "SampleTextArea" );
322 } 349 }
323 350
351 @Test
324 @SmallTest 352 @SmallTest
325 @Feature({"TextSelection"}) 353 @Feature({"TextSelection"})
326 @DisabledTest(message = "crbug.com/592428") 354 @DisabledTest(message = "crbug.com/592428")
327 public void testSelectActionBarPlainTextCut() throws Exception { 355 public void testSelectActionBarPlainTextCut() throws Throwable {
328 copyStringToClipboard("SampleTextToCopy"); 356 copyStringToClipboard("SampleTextToCopy");
329 DOMUtils.longPressNode(mContentViewCore, "plain_text_1"); 357 DOMUtils.longPressNode(mContentViewCore, "plain_text_1");
330 waitForSelectActionBarVisible(true); 358 waitForSelectActionBarVisible(true);
331 assertTrue(mSelectionPopupController.hasSelection()); 359 Assert.assertTrue(mSelectionPopupController.hasSelection());
332 assertEquals(mSelectionPopupController.getSelectedText(), "SamplePlainTe xtOne"); 360 Assert.assertEquals(mSelectionPopupController.getSelectedText(), "Sample PlainTextOne");
333 assertTrue(mSelectionPopupController.isActionModeValid()); 361 Assert.assertTrue(mSelectionPopupController.isActionModeValid());
334 selectActionBarCut(); 362 selectActionBarCut();
335 waitForSelectActionBarVisible(true); 363 waitForSelectActionBarVisible(true);
336 assertTrue(mSelectionPopupController.hasSelection()); 364 Assert.assertTrue(mSelectionPopupController.hasSelection());
337 // Cut option won't be available for plain text. 365 // Cut option won't be available for plain text.
338 // Hence validating previous Clipboard content. 366 // Hence validating previous Clipboard content.
339 waitForClipboardContents(mContentViewCore.getContext(), "SampleTextToCop y"); 367 waitForClipboardContents(mContentViewCore.getContext(), "SampleTextToCop y");
340 } 368 }
341 369
370 @Test
342 @SmallTest 371 @SmallTest
343 @Feature({"TextInput"}) 372 @Feature({"TextInput"})
344 @DisabledTest(message = "crbug.com/592428") 373 @DisabledTest(message = "crbug.com/592428")
345 public void testSelectActionBarInputCut() throws Exception { 374 public void testSelectActionBarInputCut() throws Exception {
346 DOMUtils.longPressNode(mContentViewCore, "input_text"); 375 DOMUtils.longPressNode(mContentViewCore, "input_text");
347 waitForSelectActionBarVisible(true); 376 waitForSelectActionBarVisible(true);
348 assertTrue(mSelectionPopupController.hasSelection()); 377 Assert.assertTrue(mSelectionPopupController.hasSelection());
349 assertEquals(mSelectionPopupController.getSelectedText(), "SampleInputTe xt"); 378 Assert.assertEquals(mSelectionPopupController.getSelectedText(), "Sample InputText");
350 assertTrue(mSelectionPopupController.isActionModeValid()); 379 Assert.assertTrue(mSelectionPopupController.isActionModeValid());
351 selectActionBarCut(); 380 selectActionBarCut();
352 waitForSelectActionBarVisible(false); 381 waitForSelectActionBarVisible(false);
353 assertFalse(mSelectionPopupController.hasSelection()); 382 Assert.assertFalse(mSelectionPopupController.hasSelection());
354 waitForClipboardContents(mContentViewCore.getContext(), "SampleInputText "); 383 waitForClipboardContents(mContentViewCore.getContext(), "SampleInputText ");
355 assertEquals(mSelectionPopupController.getSelectedText(), ""); 384 Assert.assertEquals(mSelectionPopupController.getSelectedText(), "");
356 } 385 }
357 386
358 @SmallTest 387 @Test
359 @Feature({"TextInput"}) 388 @SmallTest
360 @DisabledTest(message = "crbug.com/592428") 389 @Feature({"TextInput"})
361 public void testSelectActionBarPasswordCut() throws Exception { 390 @DisabledTest(message = "crbug.com/592428")
391 public void testSelectActionBarPasswordCut() throws Throwable {
362 copyStringToClipboard("SampleTextToCopy"); 392 copyStringToClipboard("SampleTextToCopy");
363 DOMUtils.longPressNode(mContentViewCore, "password"); 393 DOMUtils.longPressNode(mContentViewCore, "password");
364 waitForSelectActionBarVisible(true); 394 waitForSelectActionBarVisible(true);
365 assertTrue(mSelectionPopupController.hasSelection()); 395 Assert.assertTrue(mSelectionPopupController.hasSelection());
366 assertTrue(mSelectionPopupController.isActionModeValid()); 396 Assert.assertTrue(mSelectionPopupController.isActionModeValid());
367 selectActionBarCut(); 397 selectActionBarCut();
368 waitForSelectActionBarVisible(true); 398 waitForSelectActionBarVisible(true);
369 assertTrue(mSelectionPopupController.hasSelection()); 399 Assert.assertTrue(mSelectionPopupController.hasSelection());
370 // Cut option won't be there for Password, hence no change in Clipboard 400 // Cut option won't be there for Password, hence no change in Clipboard
371 // Validating with previous Clipboard content 401 // Validating with previous Clipboard content
372 waitForClipboardContents(mContentViewCore.getContext(), "SampleTextToCop y"); 402 waitForClipboardContents(mContentViewCore.getContext(), "SampleTextToCop y");
373 } 403 }
374 404
405 @Test
375 @SmallTest 406 @SmallTest
376 @Feature({"TextInput"}) 407 @Feature({"TextInput"})
377 @DisabledTest(message = "crbug.com/592428") 408 @DisabledTest(message = "crbug.com/592428")
378 public void testSelectActionBarTextAreaCut() throws Exception { 409 public void testSelectActionBarTextAreaCut() throws Exception {
379 DOMUtils.longPressNode(mContentViewCore, "textarea"); 410 DOMUtils.longPressNode(mContentViewCore, "textarea");
380 waitForSelectActionBarVisible(true); 411 waitForSelectActionBarVisible(true);
381 assertTrue(mSelectionPopupController.hasSelection()); 412 Assert.assertTrue(mSelectionPopupController.hasSelection());
382 assertEquals(mSelectionPopupController.getSelectedText(), "SampleTextAre a"); 413 Assert.assertEquals(mSelectionPopupController.getSelectedText(), "Sample TextArea");
383 assertTrue(mSelectionPopupController.isActionModeValid()); 414 Assert.assertTrue(mSelectionPopupController.isActionModeValid());
384 selectActionBarCut(); 415 selectActionBarCut();
385 waitForSelectActionBarVisible(false); 416 waitForSelectActionBarVisible(false);
386 assertFalse(mSelectionPopupController.hasSelection()); 417 Assert.assertFalse(mSelectionPopupController.hasSelection());
387 waitForClipboardContents(mContentViewCore.getContext(), "SampleTextArea" ); 418 waitForClipboardContents(mContentViewCore.getContext(), "SampleTextArea" );
388 assertEquals(mSelectionPopupController.getSelectedText(), ""); 419 Assert.assertEquals(mSelectionPopupController.getSelectedText(), "");
389 } 420 }
390 421
422 @Test
391 @SmallTest 423 @SmallTest
392 @Feature({"TextSelection"}) 424 @Feature({"TextSelection"})
393 @DisabledTest(message = "crbug.com/592428") 425 @DisabledTest(message = "crbug.com/592428")
394 public void testSelectActionBarPlainTextSelectAll() throws Exception { 426 public void testSelectActionBarPlainTextSelectAll() throws Exception {
395 DOMUtils.longPressNode(mContentViewCore, "plain_text_1"); 427 DOMUtils.longPressNode(mContentViewCore, "plain_text_1");
396 waitForSelectActionBarVisible(true); 428 waitForSelectActionBarVisible(true);
397 assertTrue(mSelectionPopupController.hasSelection()); 429 Assert.assertTrue(mSelectionPopupController.hasSelection());
398 assertTrue(mSelectionPopupController.isActionModeValid()); 430 Assert.assertTrue(mSelectionPopupController.isActionModeValid());
399 selectActionBarSelectAll(); 431 selectActionBarSelectAll();
400 assertTrue(mSelectionPopupController.hasSelection()); 432 Assert.assertTrue(mSelectionPopupController.hasSelection());
401 waitForSelectActionBarVisible(true); 433 waitForSelectActionBarVisible(true);
402 } 434 }
403 435
436 @Test
404 @SmallTest 437 @SmallTest
405 @Feature({"TextInput"}) 438 @Feature({"TextInput"})
406 @DisabledTest(message = "crbug.com/592428") 439 @DisabledTest(message = "crbug.com/592428")
407 public void testSelectActionBarInputSelectAll() throws Exception { 440 public void testSelectActionBarInputSelectAll() throws Exception {
408 DOMUtils.longPressNode(mContentViewCore, "input_text"); 441 DOMUtils.longPressNode(mContentViewCore, "input_text");
409 waitForSelectActionBarVisible(true); 442 waitForSelectActionBarVisible(true);
410 assertTrue(mSelectionPopupController.hasSelection()); 443 Assert.assertTrue(mSelectionPopupController.hasSelection());
411 assertTrue(mSelectionPopupController.isActionModeValid()); 444 Assert.assertTrue(mSelectionPopupController.isActionModeValid());
412 selectActionBarSelectAll(); 445 selectActionBarSelectAll();
413 assertTrue(mSelectionPopupController.hasSelection()); 446 Assert.assertTrue(mSelectionPopupController.hasSelection());
414 waitForSelectActionBarVisible(true); 447 waitForSelectActionBarVisible(true);
415 assertEquals(mSelectionPopupController.getSelectedText(), "SampleInputTe xt"); 448 Assert.assertEquals(mSelectionPopupController.getSelectedText(), "Sample InputText");
416 } 449 }
417 450
451 @Test
418 @SmallTest 452 @SmallTest
419 @Feature({"TextInput"}) 453 @Feature({"TextInput"})
420 @DisabledTest(message = "crbug.com/592428") 454 @DisabledTest(message = "crbug.com/592428")
421 public void testSelectActionBarPasswordSelectAll() throws Exception { 455 public void testSelectActionBarPasswordSelectAll() throws Exception {
422 DOMUtils.longPressNode(mContentViewCore, "password"); 456 DOMUtils.longPressNode(mContentViewCore, "password");
423 waitForSelectActionBarVisible(true); 457 waitForSelectActionBarVisible(true);
424 assertTrue(mSelectionPopupController.hasSelection()); 458 Assert.assertTrue(mSelectionPopupController.hasSelection());
425 assertTrue(mSelectionPopupController.isActionModeValid()); 459 Assert.assertTrue(mSelectionPopupController.isActionModeValid());
426 selectActionBarSelectAll(); 460 selectActionBarSelectAll();
427 assertTrue(mSelectionPopupController.hasSelection()); 461 Assert.assertTrue(mSelectionPopupController.hasSelection());
428 waitForSelectActionBarVisible(true); 462 waitForSelectActionBarVisible(true);
429 } 463 }
430 464
465 @Test
431 @SmallTest 466 @SmallTest
432 @Feature({"TextInput"}) 467 @Feature({"TextInput"})
433 @DisabledTest(message = "crbug.com/592428") 468 @DisabledTest(message = "crbug.com/592428")
434 public void testSelectActionBarTextAreaSelectAll() throws Exception { 469 public void testSelectActionBarTextAreaSelectAll() throws Exception {
435 DOMUtils.longPressNode(mContentViewCore, "textarea"); 470 DOMUtils.longPressNode(mContentViewCore, "textarea");
436 waitForSelectActionBarVisible(true); 471 waitForSelectActionBarVisible(true);
437 assertTrue(mSelectionPopupController.hasSelection()); 472 Assert.assertTrue(mSelectionPopupController.hasSelection());
438 assertTrue(mSelectionPopupController.isActionModeValid()); 473 Assert.assertTrue(mSelectionPopupController.isActionModeValid());
439 selectActionBarSelectAll(); 474 selectActionBarSelectAll();
440 assertTrue(mSelectionPopupController.hasSelection()); 475 Assert.assertTrue(mSelectionPopupController.hasSelection());
441 waitForSelectActionBarVisible(true); 476 waitForSelectActionBarVisible(true);
442 assertEquals(mSelectionPopupController.getSelectedText(), "SampleTextAre a"); 477 Assert.assertEquals(mSelectionPopupController.getSelectedText(), "Sample TextArea");
443 } 478 }
444 479
445 private CharSequence getTextBeforeCursor(final int length, final int flags) { 480 private CharSequence getTextBeforeCursor(final int length, final int flags) {
446 final ChromiumBaseInputConnection connection = 481 final ChromiumBaseInputConnection connection =
447 mContentViewCore.getImeAdapterForTest().getInputConnectionForTes t(); 482 mContentViewCore.getImeAdapterForTest().getInputConnectionForTes t();
448 return ImeTestUtils.runBlockingOnHandlerNoException( 483 return ImeTestUtils.runBlockingOnHandlerNoException(
449 connection.getHandler(), new Callable<CharSequence>() { 484 connection.getHandler(), new Callable<CharSequence>() {
450 @Override 485 @Override
451 public CharSequence call() throws Exception { 486 public CharSequence call() throws Exception {
452 return connection.getTextBeforeCursor(length, flags); 487 return connection.getTextBeforeCursor(length, flags);
453 } 488 }
454 }); 489 });
455 } 490 }
456 491
457 /** 492 /**
458 * @SmallTest 493 * @SmallTest
459 * @Feature({"TextSelection", "TextInput"}) 494 * @Feature({"TextSelection", "TextInput"})
460 */ 495 */
496 @Test
461 @DisabledTest(message = "http://crbug.com/606942") 497 @DisabledTest(message = "http://crbug.com/606942")
462 public void testCursorPositionAfterHidingActionMode() throws Exception { 498 public void testCursorPositionAfterHidingActionMode() throws Exception {
463 DOMUtils.longPressNode(mContentViewCore, "textarea"); 499 DOMUtils.longPressNode(mContentViewCore, "textarea");
464 waitForSelectActionBarVisible(true); 500 waitForSelectActionBarVisible(true);
465 assertTrue(mSelectionPopupController.hasSelection()); 501 Assert.assertTrue(mSelectionPopupController.hasSelection());
466 assertTrue(mSelectionPopupController.isActionModeValid()); 502 Assert.assertTrue(mSelectionPopupController.isActionModeValid());
467 selectActionBarSelectAll(); 503 selectActionBarSelectAll();
468 assertTrue(mSelectionPopupController.hasSelection()); 504 Assert.assertTrue(mSelectionPopupController.hasSelection());
469 waitForSelectActionBarVisible(true); 505 waitForSelectActionBarVisible(true);
470 assertEquals(mSelectionPopupController.getSelectedText(), "SampleTextAre a"); 506 Assert.assertEquals(mSelectionPopupController.getSelectedText(), "Sample TextArea");
471 hideSelectActionMode(); 507 hideSelectActionMode();
472 waitForSelectActionBarVisible(false); 508 waitForSelectActionBarVisible(false);
473 CriteriaHelper.pollInstrumentationThread( 509 CriteriaHelper.pollInstrumentationThread(
474 Criteria.equals("SampleTextArea", new Callable<CharSequence>() { 510 Criteria.equals("SampleTextArea", new Callable<CharSequence>() {
475 @Override 511 @Override
476 public CharSequence call() { 512 public CharSequence call() {
477 return getTextBeforeCursor(50, 0); 513 return getTextBeforeCursor(50, 0);
478 } 514 }
479 })); 515 }));
480 } 516 }
481 517
518 @Test
482 @SmallTest 519 @SmallTest
483 @Feature({"TextSelection"}) 520 @Feature({"TextSelection"})
484 @DisabledTest(message = "crbug.com/592428") 521 @DisabledTest(message = "crbug.com/592428")
485 public void testSelectActionBarPlainTextPaste() throws Exception { 522 public void testSelectActionBarPlainTextPaste() throws Throwable {
486 copyStringToClipboard("SampleTextToCopy"); 523 copyStringToClipboard("SampleTextToCopy");
487 DOMUtils.longPressNode(mContentViewCore, "plain_text_1"); 524 DOMUtils.longPressNode(mContentViewCore, "plain_text_1");
488 waitForSelectActionBarVisible(true); 525 waitForSelectActionBarVisible(true);
489 assertTrue(mSelectionPopupController.hasSelection()); 526 Assert.assertTrue(mSelectionPopupController.hasSelection());
490 assertTrue(mSelectionPopupController.isActionModeValid()); 527 Assert.assertTrue(mSelectionPopupController.isActionModeValid());
491 selectActionBarPaste(); 528 selectActionBarPaste();
492 DOMUtils.longPressNode(mContentViewCore, "plain_text_1"); 529 DOMUtils.longPressNode(mContentViewCore, "plain_text_1");
493 waitForSelectActionBarVisible(true); 530 waitForSelectActionBarVisible(true);
494 assertTrue(mSelectionPopupController.hasSelection()); 531 Assert.assertTrue(mSelectionPopupController.hasSelection());
495 // Paste option won't be available for plain text. 532 // Paste option won't be available for plain text.
496 // Hence content won't be changed. 533 // Hence content won't be changed.
497 assertNotSame(mSelectionPopupController.getSelectedText(), "SampleTextTo Copy"); 534 Assert.assertNotSame(mSelectionPopupController.getSelectedText(), "Sampl eTextToCopy");
498 } 535 }
499 536
537 @Test
500 @SmallTest 538 @SmallTest
501 @Feature({"TextInput"}) 539 @Feature({"TextInput"})
502 @DisabledTest(message = "crbug.com/592428") 540 @DisabledTest(message = "crbug.com/592428")
503 public void testSelectActionBarInputPaste() throws Exception { 541 public void testSelectActionBarInputPaste() throws Throwable {
504 copyStringToClipboard("SampleTextToCopy"); 542 copyStringToClipboard("SampleTextToCopy");
505 543
506 // Select the input field. 544 // Select the input field.
507 DOMUtils.longPressNode(mContentViewCore, "input_text"); 545 DOMUtils.longPressNode(mContentViewCore, "input_text");
508 waitForSelectActionBarVisible(true); 546 waitForSelectActionBarVisible(true);
509 assertTrue(mSelectionPopupController.hasSelection()); 547 Assert.assertTrue(mSelectionPopupController.hasSelection());
510 548
511 // Paste into the input field. 549 // Paste into the input field.
512 assertTrue(mSelectionPopupController.isActionModeValid()); 550 Assert.assertTrue(mSelectionPopupController.isActionModeValid());
513 selectActionBarPaste(); 551 selectActionBarPaste();
514 waitForSelectActionBarVisible(false); 552 waitForSelectActionBarVisible(false);
515 assertFalse(mSelectionPopupController.hasSelection()); 553 Assert.assertFalse(mSelectionPopupController.hasSelection());
516 554
517 // Ensure the new text matches the pasted text. 555 // Ensure the new text matches the pasted text.
518 DOMUtils.longPressNode(mContentViewCore, "input_text"); 556 DOMUtils.longPressNode(mContentViewCore, "input_text");
519 waitForSelectActionBarVisible(true); 557 waitForSelectActionBarVisible(true);
520 assertTrue(mSelectionPopupController.hasSelection()); 558 Assert.assertTrue(mSelectionPopupController.hasSelection());
521 assertEquals("SampleTextToCopy", mSelectionPopupController.getSelectedTe xt()); 559 Assert.assertEquals("SampleTextToCopy", mSelectionPopupController.getSel ectedText());
522 } 560 }
523 561
524 /* 562 /*
525 @SmallTest 563 @SmallTest
526 @Feature({"TextInput"}) 564 @Feature({"TextInput"})
527 */ 565 */
566 @Test
528 @DisabledTest(message = "https://crbug.com/592428") 567 @DisabledTest(message = "https://crbug.com/592428")
529 public void testSelectActionBarPasswordPaste() throws Exception { 568 public void testSelectActionBarPasswordPaste() throws Throwable {
530 copyStringToClipboard("SamplePassword2"); 569 copyStringToClipboard("SamplePassword2");
531 570
532 // Select the password field. 571 // Select the password field.
533 DOMUtils.longPressNode(mContentViewCore, "password"); 572 DOMUtils.longPressNode(mContentViewCore, "password");
534 waitForSelectActionBarVisible(true); 573 waitForSelectActionBarVisible(true);
535 assertTrue(mSelectionPopupController.hasSelection()); 574 Assert.assertTrue(mSelectionPopupController.hasSelection());
536 assertEquals(mSelectionPopupController.getSelectedText().length(), 575 Assert.assertEquals(
537 "SamplePassword".length()); 576 mSelectionPopupController.getSelectedText().length(), "SamplePas sword".length());
538 577
539 // Paste "SamplePassword2" into the password field, replacing 578 // Paste "SamplePassword2" into the password field, replacing
540 // "SamplePassword". 579 // "SamplePassword".
541 assertTrue(mSelectionPopupController.isActionModeValid()); 580 Assert.assertTrue(mSelectionPopupController.isActionModeValid());
542 selectActionBarPaste(); 581 selectActionBarPaste();
543 waitForSelectActionBarVisible(false); 582 waitForSelectActionBarVisible(false);
544 assertFalse(mSelectionPopupController.hasSelection()); 583 Assert.assertFalse(mSelectionPopupController.hasSelection());
545 584
546 // Ensure the new text matches the pasted text. Note that we can't 585 // Ensure the new text matches the pasted text. Note that we can't
547 // actually compare strings as password field selections only provide 586 // actually compare strings as password field selections only provide
548 // a placeholder with the correct length. 587 // a placeholder with the correct length.
549 DOMUtils.longPressNode(mContentViewCore, "password"); 588 DOMUtils.longPressNode(mContentViewCore, "password");
550 waitForSelectActionBarVisible(true); 589 waitForSelectActionBarVisible(true);
551 assertTrue(mSelectionPopupController.hasSelection()); 590 Assert.assertTrue(mSelectionPopupController.hasSelection());
552 assertEquals(mSelectionPopupController.getSelectedText().length(), 591 Assert.assertEquals(
553 "SamplePassword2".length()); 592 mSelectionPopupController.getSelectedText().length(), "SamplePas sword2".length());
554 } 593 }
555 594
595 @Test
556 @SmallTest 596 @SmallTest
557 @Feature({"TextInput"}) 597 @Feature({"TextInput"})
558 @DisabledTest(message = "crbug.com/592428") 598 @DisabledTest(message = "crbug.com/592428")
559 public void testSelectActionBarTextAreaPaste() throws Exception { 599 public void testSelectActionBarTextAreaPaste() throws Throwable {
560 copyStringToClipboard("SampleTextToCopy"); 600 copyStringToClipboard("SampleTextToCopy");
561 DOMUtils.longPressNode(mContentViewCore, "textarea"); 601 DOMUtils.longPressNode(mContentViewCore, "textarea");
562 waitForSelectActionBarVisible(true); 602 waitForSelectActionBarVisible(true);
563 assertTrue(mSelectionPopupController.hasSelection()); 603 Assert.assertTrue(mSelectionPopupController.hasSelection());
564 assertTrue(mSelectionPopupController.isActionModeValid()); 604 Assert.assertTrue(mSelectionPopupController.isActionModeValid());
565 selectActionBarPaste(); 605 selectActionBarPaste();
566 DOMUtils.clickNode(mContentViewCore, "plain_text_1"); 606 DOMUtils.clickNode(mContentViewCore, "plain_text_1");
567 DOMUtils.longPressNode(mContentViewCore, "textarea"); 607 DOMUtils.longPressNode(mContentViewCore, "textarea");
568 waitForSelectActionBarVisible(true); 608 waitForSelectActionBarVisible(true);
569 assertTrue(mSelectionPopupController.hasSelection()); 609 Assert.assertTrue(mSelectionPopupController.hasSelection());
570 assertEquals(mSelectionPopupController.getSelectedText(), "SampleTextToC opy"); 610 Assert.assertEquals(mSelectionPopupController.getSelectedText(), "Sample TextToCopy");
571 } 611 }
572 612
613 @Test
573 @SmallTest 614 @SmallTest
574 @Feature({"TextInput"}) 615 @Feature({"TextInput"})
575 @DisabledTest(message = "crbug.com/592428") 616 @DisabledTest(message = "crbug.com/592428")
576 public void testSelectActionBarSearchAndShareLaunchesNewTask() throws Except ion { 617 public void testSelectActionBarSearchAndShareLaunchesNewTask() throws Except ion {
577 DOMUtils.longPressNode(mContentViewCore, "textarea"); 618 DOMUtils.longPressNode(mContentViewCore, "textarea");
578 waitForSelectActionBarVisible(true); 619 waitForSelectActionBarVisible(true);
579 assertTrue(mSelectionPopupController.hasSelection()); 620 Assert.assertTrue(mSelectionPopupController.hasSelection());
580 assertTrue(mSelectionPopupController.isActionModeValid()); 621 Assert.assertTrue(mSelectionPopupController.isActionModeValid());
581 selectActionBarSearch(); 622 selectActionBarSearch();
582 Intent i = getActivity().getLastSentIntent(); 623 Intent i = mActivityTestRule.getActivity().getLastSentIntent();
583 int new_task_flag = Intent.FLAG_ACTIVITY_NEW_TASK; 624 int new_task_flag = Intent.FLAG_ACTIVITY_NEW_TASK;
584 assertEquals(i.getFlags() & new_task_flag, new_task_flag); 625 Assert.assertEquals(i.getFlags() & new_task_flag, new_task_flag);
585 626
586 selectActionBarShare(); 627 selectActionBarShare();
587 i = getActivity().getLastSentIntent(); 628 i = mActivityTestRule.getActivity().getLastSentIntent();
588 assertEquals(i.getFlags() & new_task_flag, new_task_flag); 629 Assert.assertEquals(i.getFlags() & new_task_flag, new_task_flag);
589 } 630 }
590 631
591 private void selectActionBarPaste() { 632 private void selectActionBarPaste() {
592 ThreadUtils.runOnUiThreadBlocking(new Runnable() { 633 ThreadUtils.runOnUiThreadBlocking(new Runnable() {
593 @Override 634 @Override
594 public void run() { 635 public void run() {
595 mSelectionPopupController.paste(); 636 mSelectionPopupController.paste();
596 } 637 }
597 }); 638 });
598 } 639 }
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
704 private void requestFocusOnUiThread(final boolean gainFocus) { 745 private void requestFocusOnUiThread(final boolean gainFocus) {
705 final ContentViewCore contentViewCore = mContentViewCore; 746 final ContentViewCore contentViewCore = mContentViewCore;
706 ThreadUtils.runOnUiThreadBlocking(new Runnable() { 747 ThreadUtils.runOnUiThreadBlocking(new Runnable() {
707 @Override 748 @Override
708 public void run() { 749 public void run() {
709 contentViewCore.onFocusChanged(gainFocus, true); 750 contentViewCore.onFocusChanged(gainFocus, true);
710 } 751 }
711 }); 752 });
712 } 753 }
713 754
714 private void copyStringToClipboard(String string) { 755 private void copyStringToClipboard(final String string) throws Throwable {
715 ClipboardManager clipboardManager = 756 mActivityTestRule.runOnUiThread(new Runnable() {
716 (ClipboardManager) getActivity().getSystemService( 757 @Override
717 Context.CLIPBOARD_SERVICE); 758 public void run() {
718 ClipData clip = ClipData.newPlainText("test", string); 759 ClipboardManager clipboardManager =
719 clipboardManager.setPrimaryClip(clip); 760 (ClipboardManager) mActivityTestRule.getActivity().getSy stemService(
761 Context.CLIPBOARD_SERVICE);
762 ClipData clip = ClipData.newPlainText("test", string);
763 clipboardManager.setPrimaryClip(clip);
764 }
765 });
720 } 766 }
721 767
722 private void waitForPastePopupStatus(final boolean show) { 768 private void waitForPastePopupStatus(final boolean show) {
723 CriteriaHelper.pollUiThread(Criteria.equals(show, new Callable<Boolean>( ) { 769 CriteriaHelper.pollUiThread(Criteria.equals(show, new Callable<Boolean>( ) {
724 @Override 770 @Override
725 public Boolean call() { 771 public Boolean call() {
726 return mSelectionPopupController.isPastePopupShowing(); 772 return mSelectionPopupController.isPastePopupShowing();
727 } 773 }
728 })); 774 }));
729 } 775 }
730 776
731 private void waitForInsertion(final boolean show) { 777 private void waitForInsertion(final boolean show) {
732 CriteriaHelper.pollUiThread(Criteria.equals(show, new Callable<Boolean>( ) { 778 CriteriaHelper.pollUiThread(Criteria.equals(show, new Callable<Boolean>( ) {
733 @Override 779 @Override
734 public Boolean call() { 780 public Boolean call() {
735 return mSelectionPopupController.isInsertion(); 781 return mSelectionPopupController.isInsertion();
736 } 782 }
737 })); 783 }));
738 } 784 }
739 } 785 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698