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

Side by Side Diff: content/browser/web_contents/touch_editable_impl_aura_browsertest.cc

Issue 304883002: Enable touch text selection tests on all Aura platforms (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Replaced EXPECT_STREQ with EXPECT_EQ Created 6 years, 6 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
« no previous file with comments | « content/browser/web_contents/touch_editable_impl_aura.cc ('k') | content/content_tests.gypi » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 #include "content/browser/web_contents/touch_editable_impl_aura.h" 5 #include "content/browser/web_contents/touch_editable_impl_aura.h"
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/run_loop.h" 8 #include "base/run_loop.h"
9 #include "base/strings/utf_string_conversions.h" 9 #include "base/strings/utf_string_conversions.h"
10 #include "base/test/test_timeouts.h" 10 #include "base/test/test_timeouts.h"
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after
160 generator.GestureTapAt(gfx::Point(bounds.x() + 10, bounds.y() + 10)); 160 generator.GestureTapAt(gfx::Point(bounds.x() + 10, bounds.y() + 10));
161 EXPECT_EQ(GetRenderWidgetHostViewAura(touch_editable), rwhva); 161 EXPECT_EQ(GetRenderWidgetHostViewAura(touch_editable), rwhva);
162 162
163 scoped_ptr<base::Value> value = 163 scoped_ptr<base::Value> value =
164 content::ExecuteScriptAndGetValue(main_frame, "get_selection()"); 164 content::ExecuteScriptAndGetValue(main_frame, "get_selection()");
165 std::string selection; 165 std::string selection;
166 value->GetAsString(&selection); 166 value->GetAsString(&selection);
167 167
168 // Check if selection handles are showing. 168 // Check if selection handles are showing.
169 EXPECT_TRUE(GetTouchSelectionController(touch_editable)); 169 EXPECT_TRUE(GetTouchSelectionController(touch_editable));
170 EXPECT_STREQ("Some text we can select", selection.c_str()); 170 EXPECT_EQ("Some text we can select", selection);
171 171
172 // Lets move the handles a bit to modify the selection 172 // Lets move the handles a bit to modify the selection
173 touch_editable->Reset(); 173 touch_editable->Reset();
174 generator.GestureScrollSequence( 174 generator.GestureScrollSequence(
175 gfx::Point(10, 47), 175 gfx::Point(bounds.x() + 10, bounds.y() + 47),
176 gfx::Point(30, 47), 176 gfx::Point(bounds.x() + 30, bounds.y() + 47),
177 base::TimeDelta::FromMilliseconds(20), 177 base::TimeDelta::FromMilliseconds(20),
178 5); 178 5);
179 touch_editable->WaitForSelectionChangeCallback(); 179 touch_editable->WaitForSelectionChangeCallback();
180 180
181 EXPECT_TRUE(GetTouchSelectionController(touch_editable)); 181 EXPECT_TRUE(GetTouchSelectionController(touch_editable));
182 value = content::ExecuteScriptAndGetValue(main_frame, "get_selection()"); 182 value = content::ExecuteScriptAndGetValue(main_frame, "get_selection()");
183 value->GetAsString(&selection); 183 value->GetAsString(&selection);
184 184
185 // It is hard to tell what exactly the selection would be now. But it would 185 // It is hard to tell what exactly the selection would be now. But it would
186 // definitely be less than whatever was selected before. 186 // definitely be less than whatever was selected before.
(...skipping 27 matching lines...) Expand all
214 rwhva->OnGestureEvent(&long_press); 214 rwhva->OnGestureEvent(&long_press);
215 touch_editable->WaitForSelectionChangeCallback(); 215 touch_editable->WaitForSelectionChangeCallback();
216 216
217 // Check if selection handles are showing. 217 // Check if selection handles are showing.
218 EXPECT_TRUE(GetTouchSelectionController(touch_editable)); 218 EXPECT_TRUE(GetTouchSelectionController(touch_editable));
219 219
220 scoped_ptr<base::Value> value = 220 scoped_ptr<base::Value> value =
221 content::ExecuteScriptAndGetValue(main_frame, "get_selection()"); 221 content::ExecuteScriptAndGetValue(main_frame, "get_selection()");
222 std::string selection; 222 std::string selection;
223 value->GetAsString(&selection); 223 value->GetAsString(&selection);
224 EXPECT_STREQ("Some", selection.c_str()); 224 EXPECT_EQ("Some", selection);
225 225
226 // Start scrolling. Handles should get hidden. 226 // Start scrolling. Handles should get hidden.
227 ui::GestureEvent scroll_begin(ui::ET_GESTURE_SCROLL_BEGIN, 227 ui::GestureEvent scroll_begin(ui::ET_GESTURE_SCROLL_BEGIN,
228 10, 228 10,
229 10, 229 10,
230 0, 230 0,
231 ui::EventTimeForNow(), 231 ui::EventTimeForNow(),
232 ui::GestureEventDetails( 232 ui::GestureEventDetails(
233 ui::ET_GESTURE_SCROLL_BEGIN, 0, 0), 233 ui::ET_GESTURE_SCROLL_BEGIN, 0, 0),
234 1); 234 1);
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
275 rwhva->OnGestureEvent(&long_press); 275 rwhva->OnGestureEvent(&long_press);
276 touch_editable->WaitForSelectionChangeCallback(); 276 touch_editable->WaitForSelectionChangeCallback();
277 277
278 // Check if selection handles are showing. 278 // Check if selection handles are showing.
279 EXPECT_TRUE(GetTouchSelectionController(touch_editable)); 279 EXPECT_TRUE(GetTouchSelectionController(touch_editable));
280 280
281 scoped_ptr<base::Value> value = 281 scoped_ptr<base::Value> value =
282 content::ExecuteScriptAndGetValue(main_frame, "get_selection()"); 282 content::ExecuteScriptAndGetValue(main_frame, "get_selection()");
283 std::string selection; 283 std::string selection;
284 value->GetAsString(&selection); 284 value->GetAsString(&selection);
285 EXPECT_STREQ("Some", selection.c_str()); 285 EXPECT_EQ("Some", selection);
286 } 286 }
287 287
288 IN_PROC_BROWSER_TEST_F(TouchEditableImplAuraTest, 288 IN_PROC_BROWSER_TEST_F(TouchEditableImplAuraTest,
289 TouchSelectionOnDoubleTapTest) { 289 TouchSelectionOnDoubleTapTest) {
290 ASSERT_NO_FATAL_FAILURE(StartTestWithPage("files/touch_selection.html")); 290 ASSERT_NO_FATAL_FAILURE(StartTestWithPage("files/touch_selection.html"));
291 WebContentsImpl* web_contents = 291 WebContentsImpl* web_contents =
292 static_cast<WebContentsImpl*>(shell()->web_contents()); 292 static_cast<WebContentsImpl*>(shell()->web_contents());
293 RenderFrameHost* main_frame = web_contents->GetMainFrame(); 293 RenderFrameHost* main_frame = web_contents->GetMainFrame();
294 WebContentsViewAura* view_aura = 294 WebContentsViewAura* view_aura =
295 static_cast<WebContentsViewAura*>(web_contents->GetView()); 295 static_cast<WebContentsViewAura*>(web_contents->GetView());
(...skipping 15 matching lines...) Expand all
311 rwhva->OnGestureEvent(&double_tap); 311 rwhva->OnGestureEvent(&double_tap);
312 touch_editable->WaitForSelectionChangeCallback(); 312 touch_editable->WaitForSelectionChangeCallback();
313 313
314 // Check if selection handles are showing. 314 // Check if selection handles are showing.
315 EXPECT_TRUE(GetTouchSelectionController(touch_editable)); 315 EXPECT_TRUE(GetTouchSelectionController(touch_editable));
316 316
317 scoped_ptr<base::Value> value = 317 scoped_ptr<base::Value> value =
318 content::ExecuteScriptAndGetValue(main_frame, "get_selection()"); 318 content::ExecuteScriptAndGetValue(main_frame, "get_selection()");
319 std::string selection; 319 std::string selection;
320 value->GetAsString(&selection); 320 value->GetAsString(&selection);
321 EXPECT_STREQ("Some", selection.c_str()); 321 #if defined(OS_WIN)
322 // In Windows, the default behavior is to select the whitespace after the word
323 // when the word is selected.
324 EXPECT_EQ("Some ", selection);
325 #else
326 EXPECT_EQ("Some", selection);
327 #endif // defined (OS_WIN)
322 } 328 }
323 329
324 IN_PROC_BROWSER_TEST_F(TouchEditableImplAuraTest, 330 IN_PROC_BROWSER_TEST_F(TouchEditableImplAuraTest,
325 TouchCursorInTextfieldTest) { 331 TouchCursorInTextfieldTest) {
326 ASSERT_NO_FATAL_FAILURE(StartTestWithPage("files/touch_selection.html")); 332 ASSERT_NO_FATAL_FAILURE(StartTestWithPage("files/touch_selection.html"));
327 WebContentsImpl* web_contents = 333 WebContentsImpl* web_contents =
328 static_cast<WebContentsImpl*>(shell()->web_contents()); 334 static_cast<WebContentsImpl*>(shell()->web_contents());
329 RenderFrameHost* main_frame = web_contents->GetMainFrame(); 335 RenderFrameHost* main_frame = web_contents->GetMainFrame();
330 WebContentsViewAura* view_aura = static_cast<WebContentsViewAura*>( 336 WebContentsViewAura* view_aura = static_cast<WebContentsViewAura*>(
331 web_contents->GetView()); 337 web_contents->GetView());
(...skipping 22 matching lines...) Expand all
354 EXPECT_TRUE(GetTouchSelectionController(touch_editable)); 360 EXPECT_TRUE(GetTouchSelectionController(touch_editable));
355 361
356 scoped_ptr<base::Value> value = 362 scoped_ptr<base::Value> value =
357 content::ExecuteScriptAndGetValue(main_frame, "get_cursor_position()"); 363 content::ExecuteScriptAndGetValue(main_frame, "get_cursor_position()");
358 int cursor_pos = -1; 364 int cursor_pos = -1;
359 value->GetAsInteger(&cursor_pos); 365 value->GetAsInteger(&cursor_pos);
360 EXPECT_NE(-1, cursor_pos); 366 EXPECT_NE(-1, cursor_pos);
361 367
362 // Move the cursor handle. 368 // Move the cursor handle.
363 generator.GestureScrollSequence( 369 generator.GestureScrollSequence(
364 gfx::Point(50, 59), 370 gfx::Point(bounds.x() + 50, bounds.y() + 59),
365 gfx::Point(10, 59), 371 gfx::Point(bounds.x() + 10, bounds.y() + 59),
366 base::TimeDelta::FromMilliseconds(20), 372 base::TimeDelta::FromMilliseconds(20),
367 1); 373 1);
368 touch_editable->WaitForSelectionChangeCallback(); 374 touch_editable->WaitForSelectionChangeCallback();
369 EXPECT_TRUE(GetTouchSelectionController(touch_editable)); 375 EXPECT_TRUE(GetTouchSelectionController(touch_editable));
370 value = content::ExecuteScriptAndGetValue(main_frame, 376 value = content::ExecuteScriptAndGetValue(main_frame,
371 "get_cursor_position()"); 377 "get_cursor_position()");
372 int new_cursor_pos = -1; 378 int new_cursor_pos = -1;
373 value->GetAsInteger(&new_cursor_pos); 379 value->GetAsInteger(&new_cursor_pos);
374 EXPECT_NE(-1, new_cursor_pos); 380 EXPECT_NE(-1, new_cursor_pos);
375 // Cursor should have moved. 381 // Cursor should have moved.
376 EXPECT_NE(new_cursor_pos, cursor_pos); 382 EXPECT_NE(new_cursor_pos, cursor_pos);
377 } 383 }
378 384
379 } // namespace content 385 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/web_contents/touch_editable_impl_aura.cc ('k') | content/content_tests.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698