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

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

Issue 10545129: aura:Delay call to DispatchHeldMouseMove from RootWindow::ReleaseMouseMoves (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: nit Created 8 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 | Annotate | Revision Log
« 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 "testing/gtest/include/gtest/gtest.h" 9 #include "testing/gtest/include/gtest/gtest.h"
10 #include "ui/aura/client/event_client.h" 10 #include "ui/aura/client/event_client.h"
(...skipping 549 matching lines...) Expand 10 before | Expand all | Expand 10 after
560 root_window()->DispatchTouchEvent(&touch_pressed_event); 560 root_window()->DispatchTouchEvent(&touch_pressed_event);
561 root_window()->DispatchTouchEvent(&touch_released_event); 561 root_window()->DispatchTouchEvent(&touch_released_event);
562 EXPECT_EQ("TOUCH_PRESSED GESTURE_BEGIN GESTURE_TAP_DOWN TOUCH_RELEASED " 562 EXPECT_EQ("TOUCH_PRESSED GESTURE_BEGIN GESTURE_TAP_DOWN TOUCH_RELEASED "
563 "GESTURE_TAP MOUSE_EXITED MOUSE_ENTERED MOUSE_MOVED " 563 "GESTURE_TAP MOUSE_EXITED MOUSE_ENTERED MOUSE_MOVED "
564 "MOUSE_PRESSED MOUSE_RELEASED GESTURE_END", 564 "MOUSE_PRESSED MOUSE_RELEASED GESTURE_END",
565 EventTypesToString(filter->events())); 565 EventTypesToString(filter->events()));
566 filter->events().clear(); 566 filter->events().clear();
567 } 567 }
568 } 568 }
569 569
570 TEST_F(RootWindowTest, HoldMouseMove) {
571 EventFilterRecorder* filter = new EventFilterRecorder;
572 root_window()->SetEventFilter(filter); // passes ownership
573
574 test::TestWindowDelegate delegate;
575 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate(
576 &delegate, 1, gfx::Rect(0, 0, 100, 100), NULL));
577
578 MouseEvent mouse_move_event(ui::ET_MOUSE_MOVED, gfx::Point(0, 0),
579 gfx::Point(0, 0), 0);
580 root_window()->DispatchMouseEvent(&mouse_move_event);
581 // Discard MOUSE_ENTER.
582 filter->events().clear();
583
584 root_window()->HoldMouseMoves();
585
586 // Check that we don't immediately dispatch the MOUSE_DRAGGED event.
587 MouseEvent mouse_dragged_event(ui::ET_MOUSE_DRAGGED, gfx::Point(0, 0),
588 gfx::Point(0, 0), 0);
589 root_window()->DispatchMouseEvent(&mouse_dragged_event);
590 EXPECT_TRUE(filter->events().empty());
591
592 // Check that we do dispatch the held MOUSE_DRAGGED event before another type
593 // of event.
594 MouseEvent mouse_pressed_event(ui::ET_MOUSE_PRESSED, gfx::Point(0, 0),
595 gfx::Point(0, 0), 0);
596 root_window()->DispatchMouseEvent(&mouse_pressed_event);
597 EXPECT_EQ("MOUSE_DRAGGED MOUSE_PRESSED",
598 EventTypesToString(filter->events()));
599 filter->events().clear();
600
601 // Check that we coalesce held MOUSE_DRAGGED events.
602 MouseEvent mouse_dragged_event2(ui::ET_MOUSE_DRAGGED, gfx::Point(1, 1),
603 gfx::Point(1, 1), 0);
604 root_window()->DispatchMouseEvent(&mouse_dragged_event);
605 root_window()->DispatchMouseEvent(&mouse_dragged_event2);
606 EXPECT_TRUE(filter->events().empty());
607 root_window()->DispatchMouseEvent(&mouse_pressed_event);
608 EXPECT_EQ("MOUSE_DRAGGED MOUSE_PRESSED",
609 EventTypesToString(filter->events()));
610 filter->events().clear();
611
612 // Check that on ReleaseMouseMoves, held events are not dispatched
613 // immediately, but posted instead.
614 root_window()->DispatchMouseEvent(&mouse_dragged_event);
615 root_window()->ReleaseMouseMoves();
616 EXPECT_TRUE(filter->events().empty());
617 RunAllPendingInMessageLoop();
618 EXPECT_EQ("MOUSE_DRAGGED", EventTypesToString(filter->events()));
619 filter->events().clear();
620
621 // However if another message comes in before the dispatch,
622 // the Check that on ReleaseMouseMoves, held events are not dispatched
623 // immediately, but posted instead.
624 root_window()->HoldMouseMoves();
625 root_window()->DispatchMouseEvent(&mouse_dragged_event);
626 root_window()->ReleaseMouseMoves();
627 root_window()->DispatchMouseEvent(&mouse_pressed_event);
628 EXPECT_EQ("MOUSE_DRAGGED MOUSE_PRESSED",
629 EventTypesToString(filter->events()));
630 filter->events().clear();
631 RunAllPendingInMessageLoop();
632 EXPECT_TRUE(filter->events().empty());
633
634 // Check that if the other message is another MOUSE_DRAGGED, we still coalesce
635 // them.
636 root_window()->HoldMouseMoves();
637 root_window()->DispatchMouseEvent(&mouse_dragged_event);
638 root_window()->ReleaseMouseMoves();
639 root_window()->DispatchMouseEvent(&mouse_dragged_event2);
640 EXPECT_EQ("MOUSE_DRAGGED", EventTypesToString(filter->events()));
641 filter->events().clear();
642 RunAllPendingInMessageLoop();
643 EXPECT_TRUE(filter->events().empty());
644 }
645
570 } // namespace aura 646 } // 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