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

Side by Side Diff: chrome/browser/ui/views/drag_and_drop_interactive_uitest.cc

Issue 2577553002: Wait for mousemove DOM event, before simulating mousedown for dragstart tests. (Closed)
Patch Set: Expanded a comment as suggested by lfg@ (to refer to bug 647378). Created 4 years 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 | « no previous file | chrome/test/data/drag_and_drop/image_source.html » ('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 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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 <algorithm> 5 #include <algorithm>
6 #include <initializer_list> 6 #include <initializer_list>
7 #include <memory> 7 #include <memory>
8 #include <string> 8 #include <string>
9 #include <vector> 9 #include <vector>
10 10
(...skipping 561 matching lines...) Expand 10 before | Expand all | Expand 10 after
572 const std::string& filename) { 572 const std::string& filename) {
573 AssertTestPageIsLoaded(); 573 AssertTestPageIsLoaded();
574 return NavigateNamedFrame("right", origin, filename); 574 return NavigateNamedFrame("right", origin, filename);
575 } 575 }
576 576
577 //////////////////////////////////////////////////////////// 577 ////////////////////////////////////////////////////////////
578 // Simulation of starting a drag-and-drop (using the mouse). 578 // Simulation of starting a drag-and-drop (using the mouse).
579 579
580 bool SimulateMouseDownAndDragStartInLeftFrame() { 580 bool SimulateMouseDownAndDragStartInLeftFrame() {
581 AssertTestPageIsLoaded(); 581 AssertTestPageIsLoaded();
582 if (!SimulateMouseMove(kMiddleOfLeftFrame) || !SimulateMouseDown() || 582
583 !SimulateMouseMove(expected_location_of_drag_start_in_left_frame())) 583 // Waiting until the mousemove and mousedown events reach the right renderer
584 // is needed to avoid flakiness reported in https://crbug.com/671445 (which
585 // has its root cause in https://crbug.com/647378). Once the latter bug
586 // is fixed, we should no longer need to wait for these events (because
587 // fixing https://crbug.com/647378 should guarantee that events arrive
588 // to the renderer in the right order).
589 DOMDragEventWaiter mouse_move_event_waiter("mousemove", left_frame());
590 DOMDragEventWaiter mouse_down_event_waiter("mousedown", left_frame());
591
592 if (!SimulateMouseMove(kMiddleOfLeftFrame))
593 return false;
594 if (!mouse_move_event_waiter.WaitForNextMatchingEvent(nullptr))
595 return false;
596
597 if (!SimulateMouseDown())
598 return false;
599 if (!mouse_down_event_waiter.WaitForNextMatchingEvent(nullptr))
600 return false;
601
602 if (!SimulateMouseMove(expected_location_of_drag_start_in_left_frame()))
584 return false; 603 return false;
585 604
586 return true; 605 return true;
587 } 606 }
588 607
589 gfx::Point expected_location_of_drag_start_in_left_frame() { 608 gfx::Point expected_location_of_drag_start_in_left_frame() {
590 // TODO(crbug.com/653490): The delta below should exceed kDragThresholdX and 609 // TODO(crbug.com/653490): The delta below should exceed kDragThresholdX and
591 // kDragThresholdY from MouseEventManager.cpp in blink. Ideally, it would 610 // kDragThresholdY from MouseEventManager.cpp in blink. Ideally, it would
592 // come from the OS instead. 611 // come from the OS instead.
593 return kMiddleOfLeftFrame + gfx::Vector2d(10, 10); 612 return kMiddleOfLeftFrame + gfx::Vector2d(10, 10);
(...skipping 545 matching lines...) Expand 10 before | Expand all | Expand 10 after
1139 "dragend"})); 1158 "dragend"}));
1140 } 1159 }
1141 1160
1142 INSTANTIATE_TEST_CASE_P( 1161 INSTANTIATE_TEST_CASE_P(
1143 SameSiteSubframe, DragAndDropBrowserTest, ::testing::Values(false)); 1162 SameSiteSubframe, DragAndDropBrowserTest, ::testing::Values(false));
1144 1163
1145 INSTANTIATE_TEST_CASE_P( 1164 INSTANTIATE_TEST_CASE_P(
1146 CrossSiteSubframe, DragAndDropBrowserTest, ::testing::Values(true)); 1165 CrossSiteSubframe, DragAndDropBrowserTest, ::testing::Values(true));
1147 1166
1148 } // namespace chrome 1167 } // namespace chrome
OLDNEW
« no previous file with comments | « no previous file | chrome/test/data/drag_and_drop/image_source.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698