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

Side by Side Diff: ui/aura/root_window_unittest.cc

Issue 160563002: Aura: don't synthesize mouse moves while holding pointer. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Added check for synthetic event Created 6 years, 10 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 | « ui/aura/root_window.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 "ui/aura/root_window.h" 5 #include "ui/aura/root_window.h"
6 6
7 #include <vector> 7 #include <vector>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/run_loop.h" 10 #include "base/run_loop.h"
(...skipping 613 matching lines...) Expand 10 before | Expand all | Expand 10 after
624 // Check that we do dispatch the held MOUSE_DRAGGED event before another type 624 // Check that we do dispatch the held MOUSE_DRAGGED event before another type
625 // of event. 625 // of event.
626 ui::MouseEvent mouse_pressed_event(ui::ET_MOUSE_PRESSED, gfx::Point(0, 0), 626 ui::MouseEvent mouse_pressed_event(ui::ET_MOUSE_PRESSED, gfx::Point(0, 0),
627 gfx::Point(0, 0), 0, 0); 627 gfx::Point(0, 0), 0, 0);
628 DispatchEventUsingWindowDispatcher(&mouse_pressed_event); 628 DispatchEventUsingWindowDispatcher(&mouse_pressed_event);
629 EXPECT_EQ("MOUSE_DRAGGED MOUSE_PRESSED", 629 EXPECT_EQ("MOUSE_DRAGGED MOUSE_PRESSED",
630 EventTypesToString(filter->events())); 630 EventTypesToString(filter->events()));
631 filter->Reset(); 631 filter->Reset();
632 632
633 // Check that we coalesce held MOUSE_DRAGGED events. 633 // Check that we coalesce held MOUSE_DRAGGED events.
634 ui::MouseEvent mouse_dragged_event2(ui::ET_MOUSE_DRAGGED, gfx::Point(1, 1), 634 ui::MouseEvent mouse_dragged_event2(ui::ET_MOUSE_DRAGGED, gfx::Point(10, 10),
635 gfx::Point(1, 1), 0, 0); 635 gfx::Point(10, 10), 0, 0);
636 DispatchEventUsingWindowDispatcher(&mouse_dragged_event); 636 DispatchEventUsingWindowDispatcher(&mouse_dragged_event);
637 DispatchEventUsingWindowDispatcher(&mouse_dragged_event2); 637 DispatchEventUsingWindowDispatcher(&mouse_dragged_event2);
638 EXPECT_TRUE(filter->events().empty()); 638 EXPECT_TRUE(filter->events().empty());
639 DispatchEventUsingWindowDispatcher(&mouse_pressed_event); 639 DispatchEventUsingWindowDispatcher(&mouse_pressed_event);
640 EXPECT_EQ("MOUSE_DRAGGED MOUSE_PRESSED", 640 EXPECT_EQ("MOUSE_DRAGGED MOUSE_PRESSED",
641 EventTypesToString(filter->events())); 641 EventTypesToString(filter->events()));
642 filter->Reset(); 642 filter->Reset();
643 643
644 // Check that on ReleasePointerMoves, held events are not dispatched 644 // Check that on ReleasePointerMoves, held events are not dispatched
645 // immediately, but posted instead. 645 // immediately, but posted instead.
(...skipping 19 matching lines...) Expand all
665 // Check that if the other message is another MOUSE_DRAGGED, we still coalesce 665 // Check that if the other message is another MOUSE_DRAGGED, we still coalesce
666 // them. 666 // them.
667 dispatcher()->HoldPointerMoves(); 667 dispatcher()->HoldPointerMoves();
668 DispatchEventUsingWindowDispatcher(&mouse_dragged_event); 668 DispatchEventUsingWindowDispatcher(&mouse_dragged_event);
669 dispatcher()->ReleasePointerMoves(); 669 dispatcher()->ReleasePointerMoves();
670 DispatchEventUsingWindowDispatcher(&mouse_dragged_event2); 670 DispatchEventUsingWindowDispatcher(&mouse_dragged_event2);
671 EXPECT_EQ("MOUSE_DRAGGED", EventTypesToString(filter->events())); 671 EXPECT_EQ("MOUSE_DRAGGED", EventTypesToString(filter->events()));
672 filter->Reset(); 672 filter->Reset();
673 RunAllPendingInMessageLoop(); 673 RunAllPendingInMessageLoop();
674 EXPECT_TRUE(filter->events().empty()); 674 EXPECT_TRUE(filter->events().empty());
675
676 // Check that synthetic mouse move event has a right location when issued
677 // while holding pointer moves.
678 ui::MouseEvent mouse_dragged_event3(ui::ET_MOUSE_DRAGGED, gfx::Point(28, 28),
679 gfx::Point(28, 28), 0, 0);
680 dispatcher()->HoldPointerMoves();
681 DispatchEventUsingWindowDispatcher(&mouse_dragged_event);
682 DispatchEventUsingWindowDispatcher(&mouse_dragged_event2);
683 window->SetBounds(gfx::Rect(15, 15, 80, 80));
684 DispatchEventUsingWindowDispatcher(&mouse_dragged_event3);
685 RunAllPendingInMessageLoop();
686 EXPECT_TRUE(filter->events().empty());
687 dispatcher()->ReleasePointerMoves();
688 RunAllPendingInMessageLoop();
689 EXPECT_EQ("MOUSE_MOVED", EventTypesToString(filter->events()));
690 EXPECT_EQ(gfx::Point(13, 13), filter->mouse_location(0));
691 filter->Reset();
675 } 692 }
676 693
677 TEST_F(RootWindowTest, TouchMovesHeld) { 694 TEST_F(RootWindowTest, TouchMovesHeld) {
678 EventFilterRecorder* filter = new EventFilterRecorder; 695 EventFilterRecorder* filter = new EventFilterRecorder;
679 root_window()->SetEventFilter(filter); // passes ownership 696 root_window()->SetEventFilter(filter); // passes ownership
680 697
681 test::TestWindowDelegate delegate; 698 test::TestWindowDelegate delegate;
682 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate( 699 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate(
683 &delegate, 1, gfx::Rect(50, 50, 100, 100), root_window())); 700 &delegate, 1, gfx::Rect(50, 50, 100, 100), root_window()));
684 701
(...skipping 1090 matching lines...) Expand 10 before | Expand all | Expand 10 after
1775 delegate.set_window(window.Pass()); 1792 delegate.set_window(window.Pass());
1776 EXPECT_TRUE(delegate.has_window()); 1793 EXPECT_TRUE(delegate.has_window());
1777 1794
1778 generator.MoveMouseTo(100, 100); 1795 generator.MoveMouseTo(100, 100);
1779 EXPECT_FALSE(delegate.has_window()); 1796 EXPECT_FALSE(delegate.has_window());
1780 EXPECT_EQ("100,100", 1797 EXPECT_EQ("100,100",
1781 Env::GetInstance()->last_mouse_location().ToString()); 1798 Env::GetInstance()->last_mouse_location().ToString());
1782 } 1799 }
1783 1800
1784 } // namespace aura 1801 } // namespace aura
OLDNEW
« no previous file with comments | « ui/aura/root_window.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698