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

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

Issue 963103003: Fix touch editing handles not shown after trying overscroll (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Added test Created 5 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
« no previous file with comments | « content/browser/web_contents/touch_editable_impl_aura.cc ('k') | no next file » | 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 320 matching lines...) Expand 10 before | Expand all | Expand 10 after
331 10, 331 10,
332 0, 332 0,
333 ui::EventTimeForNow(), 333 ui::EventTimeForNow(),
334 ui::GestureEventDetails(ui::ET_SCROLL_FLING_START, 1, 0)); 334 ui::GestureEventDetails(ui::ET_SCROLL_FLING_START, 1, 0));
335 rwhva->OnGestureEvent(&fling_start); 335 rwhva->OnGestureEvent(&fling_start);
336 touch_editable->WaitForFlingStopCallback(); 336 touch_editable->WaitForFlingStopCallback();
337 EXPECT_TRUE(GetTouchSelectionController(touch_editable)); 337 EXPECT_TRUE(GetTouchSelectionController(touch_editable));
338 } 338 }
339 339
340 IN_PROC_BROWSER_TEST_F(TouchEditableImplAuraTest, 340 IN_PROC_BROWSER_TEST_F(TouchEditableImplAuraTest,
341 TestTouchSelectionWhenOverscrolling) {
342 ASSERT_NO_FATAL_FAILURE(StartTestWithPage("files/touch_selection.html"));
343 WebContentsImpl* web_contents =
344 static_cast<WebContentsImpl*>(shell()->web_contents());
345 RenderFrameHost* main_frame = web_contents->GetMainFrame();
346 WebContentsViewAura* view_aura = static_cast<WebContentsViewAura*>(
347 web_contents->GetView());
348 TestTouchEditableImplAura* touch_editable = new TestTouchEditableImplAura;
349 view_aura->SetTouchEditableForTest(touch_editable);
350 RenderWidgetHostViewAura* rwhva = static_cast<RenderWidgetHostViewAura*>(
351 web_contents->GetRenderWidgetHostView());
352 EXPECT_EQ(GetRenderWidgetHostViewAura(touch_editable), rwhva);
353
354 // Long press to select word.
355 ui::GestureEvent long_press(
356 10,
357 10,
358 0,
359 ui::EventTimeForNow(),
360 ui::GestureEventDetails(ui::ET_GESTURE_LONG_PRESS));
361 touch_editable->Reset();
362 rwhva->OnGestureEvent(&long_press);
363 touch_editable->WaitForSelectionChangeCallback();
364
365 // Check if selection handles are showing.
366 EXPECT_TRUE(GetTouchSelectionController(touch_editable));
367
368 scoped_ptr<base::Value> value =
369 content::ExecuteScriptAndGetValue(main_frame, "get_selection()");
370 std::string selection;
371 value->GetAsString(&selection);
372 EXPECT_STREQ("Some", selection.c_str());
373
374 // Overscroll is preceded with a scroll. Handles should get hidden.
375 ui::GestureEvent scroll_begin(
376 10,
377 10,
378 0,
379 ui::EventTimeForNow(),
380 ui::GestureEventDetails(ui::ET_GESTURE_SCROLL_BEGIN, 0, 0));
381 rwhva->OnGestureEvent(&scroll_begin);
382 EXPECT_FALSE(GetTouchSelectionController(touch_editable));
383
384 // Then overscroll itself starts. Handles should remain hidden.
385 touch_editable->OverscrollStarted();
386 EXPECT_FALSE(GetTouchSelectionController(touch_editable));
387
388 // We might have multiple overscroll-starts in one overscroll session. Handles
389 // should still remain hidden.
390 touch_editable->OverscrollStarted();
391 EXPECT_FALSE(GetTouchSelectionController(touch_editable));
392
393 // An overscroll session ends with a single overscroll-complete. Handles
394 // should still remain hidden as the scroll is still in progress.
395 touch_editable->OverscrollCompleted();
396 EXPECT_FALSE(GetTouchSelectionController(touch_editable));
397
398 // And, finally an scroll-end. Handles should come back.
399 ui::GestureEvent scroll_end(
400 10,
401 10,
402 0,
403 ui::EventTimeForNow(),
404 ui::GestureEventDetails(ui::ET_GESTURE_SCROLL_END));
405 rwhva->OnGestureEvent(&scroll_end);
406 EXPECT_TRUE(GetTouchSelectionController(touch_editable));
407 }
408
409 IN_PROC_BROWSER_TEST_F(TouchEditableImplAuraTest,
341 TouchSelectionOnLongPressTest) { 410 TouchSelectionOnLongPressTest) {
342 ASSERT_NO_FATAL_FAILURE(StartTestWithPage("files/touch_selection.html")); 411 ASSERT_NO_FATAL_FAILURE(StartTestWithPage("files/touch_selection.html"));
343 WebContentsImpl* web_contents = 412 WebContentsImpl* web_contents =
344 static_cast<WebContentsImpl*>(shell()->web_contents()); 413 static_cast<WebContentsImpl*>(shell()->web_contents());
345 RenderFrameHost* main_frame = web_contents->GetMainFrame(); 414 RenderFrameHost* main_frame = web_contents->GetMainFrame();
346 WebContentsViewAura* view_aura = static_cast<WebContentsViewAura*>( 415 WebContentsViewAura* view_aura = static_cast<WebContentsViewAura*>(
347 web_contents->GetView()); 416 web_contents->GetView());
348 TestTouchEditableImplAura* touch_editable = new TestTouchEditableImplAura; 417 TestTouchEditableImplAura* touch_editable = new TestTouchEditableImplAura;
349 view_aura->SetTouchEditableForTest(touch_editable); 418 view_aura->SetTouchEditableForTest(touch_editable);
350 RenderWidgetHostViewAura* rwhva = static_cast<RenderWidgetHostViewAura*>( 419 RenderWidgetHostViewAura* rwhva = static_cast<RenderWidgetHostViewAura*>(
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
459 value = content::ExecuteScriptAndGetValue(main_frame, 528 value = content::ExecuteScriptAndGetValue(main_frame,
460 "get_cursor_position()"); 529 "get_cursor_position()");
461 int new_cursor_pos = -1; 530 int new_cursor_pos = -1;
462 value->GetAsInteger(&new_cursor_pos); 531 value->GetAsInteger(&new_cursor_pos);
463 EXPECT_NE(-1, new_cursor_pos); 532 EXPECT_NE(-1, new_cursor_pos);
464 // Cursor should have moved. 533 // Cursor should have moved.
465 EXPECT_NE(new_cursor_pos, cursor_pos); 534 EXPECT_NE(new_cursor_pos, cursor_pos);
466 } 535 }
467 536
468 } // namespace content 537 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/web_contents/touch_editable_impl_aura.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698