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

Unified Diff: ui/aura/root_window_unittest.cc

Issue 147203004: aura: Remove event-dispatch methods from WindowTreeHostDelegate interface. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: win Created 6 years, 11 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ui/aura/root_window_host_x11_unittest.cc ('k') | ui/aura/test/aura_test_base.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/aura/root_window_unittest.cc
diff --git a/ui/aura/root_window_unittest.cc b/ui/aura/root_window_unittest.cc
index 0749851ac123ba6c30356169aa0e8e789976bc8e..abf8947ca9dd4b4514f88a43de511aa3eab19bc5 100644
--- a/ui/aura/root_window_unittest.cc
+++ b/ui/aura/root_window_unittest.cc
@@ -117,7 +117,7 @@ TEST_F(RootWindowTest, OnHostMouseEvent) {
ui::MouseEvent event1(
ui::ET_MOUSE_PRESSED, point, point, ui::EF_LEFT_MOUSE_BUTTON,
ui::EF_LEFT_MOUSE_BUTTON);
- dispatcher()->AsWindowTreeHostDelegate()->OnHostMouseEvent(&event1);
+ DispatchEventUsingWindowDispatcher(&event1);
// Event was tested for non-client area for the target window.
EXPECT_EQ(1, delegate1->non_client_count());
@@ -160,7 +160,7 @@ TEST_F(RootWindowTest, MouseButtonState) {
location,
ui::EF_LEFT_MOUSE_BUTTON,
ui::EF_LEFT_MOUSE_BUTTON));
- dispatcher()->AsWindowTreeHostDelegate()->OnHostMouseEvent(event.get());
+ DispatchEventUsingWindowDispatcher(event.get());
EXPECT_TRUE(Env::GetInstance()->IsMouseButtonDown());
// Additionally press the right.
@@ -170,7 +170,7 @@ TEST_F(RootWindowTest, MouseButtonState) {
location,
ui::EF_LEFT_MOUSE_BUTTON | ui::EF_RIGHT_MOUSE_BUTTON,
ui::EF_RIGHT_MOUSE_BUTTON));
- dispatcher()->AsWindowTreeHostDelegate()->OnHostMouseEvent(event.get());
+ DispatchEventUsingWindowDispatcher(event.get());
EXPECT_TRUE(Env::GetInstance()->IsMouseButtonDown());
// Release the left button.
@@ -180,7 +180,7 @@ TEST_F(RootWindowTest, MouseButtonState) {
location,
ui::EF_RIGHT_MOUSE_BUTTON,
ui::EF_LEFT_MOUSE_BUTTON));
- dispatcher()->AsWindowTreeHostDelegate()->OnHostMouseEvent(event.get());
+ DispatchEventUsingWindowDispatcher(event.get());
EXPECT_TRUE(Env::GetInstance()->IsMouseButtonDown());
// Release the right button. We should ignore the Shift-is-down flag.
@@ -190,7 +190,7 @@ TEST_F(RootWindowTest, MouseButtonState) {
location,
ui::EF_SHIFT_DOWN,
ui::EF_RIGHT_MOUSE_BUTTON));
- dispatcher()->AsWindowTreeHostDelegate()->OnHostMouseEvent(event.get());
+ DispatchEventUsingWindowDispatcher(event.get());
EXPECT_FALSE(Env::GetInstance()->IsMouseButtonDown());
// Press the middle button.
@@ -200,7 +200,7 @@ TEST_F(RootWindowTest, MouseButtonState) {
location,
ui::EF_MIDDLE_MOUSE_BUTTON,
ui::EF_MIDDLE_MOUSE_BUTTON));
- dispatcher()->AsWindowTreeHostDelegate()->OnHostMouseEvent(event.get());
+ DispatchEventUsingWindowDispatcher(event.get());
EXPECT_TRUE(Env::GetInstance()->IsMouseButtonDown());
}
@@ -345,13 +345,13 @@ TEST_F(RootWindowTest, IgnoreUnknownKeys) {
root_window()->SetEventFilter(filter); // passes ownership
ui::KeyEvent unknown_event(ui::ET_KEY_PRESSED, ui::VKEY_UNKNOWN, 0, false);
- EXPECT_FALSE(dispatcher()->AsWindowTreeHostDelegate()->OnHostKeyEvent(
- &unknown_event));
+ DispatchEventUsingWindowDispatcher(&unknown_event);
+ EXPECT_FALSE(unknown_event.handled());
EXPECT_EQ(0, filter->num_key_events());
ui::KeyEvent known_event(ui::ET_KEY_PRESSED, ui::VKEY_A, 0, false);
- EXPECT_TRUE(dispatcher()->AsWindowTreeHostDelegate()->OnHostKeyEvent(
- &known_event));
+ DispatchEventUsingWindowDispatcher(&known_event);
+ EXPECT_TRUE(known_event.handled());
EXPECT_EQ(1, filter->num_key_events());
}
@@ -363,8 +363,8 @@ TEST_F(RootWindowTest, NoDelegateWindowReceivesKeyEvents) {
test::TestEventHandler handler;
w1->AddPreTargetHandler(&handler);
ui::KeyEvent key_press(ui::ET_KEY_PRESSED, ui::VKEY_A, 0, false);
- EXPECT_TRUE(dispatcher()->AsWindowTreeHostDelegate()->OnHostKeyEvent(
- &key_press));
+ DispatchEventUsingWindowDispatcher(&key_press);
+ EXPECT_TRUE(key_press.handled());
EXPECT_EQ(1, handler.num_key_events());
w1->RemovePreTargetHandler(&handler);
@@ -379,14 +379,14 @@ TEST_F(RootWindowTest, TouchEventsOutsideBounds) {
gfx::Point position = root_window()->bounds().origin();
position.Offset(-10, -10);
ui::TouchEvent press(ui::ET_TOUCH_PRESSED, position, 0, base::TimeDelta());
- dispatcher()->AsWindowTreeHostDelegate()->OnHostTouchEvent(&press);
+ DispatchEventUsingWindowDispatcher(&press);
EXPECT_EQ(1, filter->num_touch_events());
position = root_window()->bounds().origin();
position.Offset(root_window()->bounds().width() + 10,
root_window()->bounds().height() + 10);
ui::TouchEvent release(ui::ET_TOUCH_RELEASED, position, 0, base::TimeDelta());
- dispatcher()->AsWindowTreeHostDelegate()->OnHostTouchEvent(&release);
+ DispatchEventUsingWindowDispatcher(&release);
EXPECT_EQ(2, filter->num_touch_events());
}
@@ -408,7 +408,7 @@ TEST_F(RootWindowTest, ScrollEventDispatch) {
0, -10,
0, -10,
2);
- dispatcher()->AsWindowTreeHostDelegate()->OnHostScrollEvent(&scroll1);
+ DispatchEventUsingWindowDispatcher(&scroll1);
EXPECT_EQ(1, filter->num_scroll_events());
// Scroll event on a window should be dispatched properly.
@@ -419,7 +419,7 @@ TEST_F(RootWindowTest, ScrollEventDispatch) {
-10, 0,
-10, 0,
2);
- dispatcher()->AsWindowTreeHostDelegate()->OnHostScrollEvent(&scroll2);
+ DispatchEventUsingWindowDispatcher(&scroll2);
EXPECT_EQ(2, filter->num_scroll_events());
}
@@ -610,8 +610,7 @@ TEST_F(RootWindowTest, MouseMovesHeld) {
ui::MouseEvent mouse_move_event(ui::ET_MOUSE_MOVED, gfx::Point(0, 0),
gfx::Point(0, 0), 0, 0);
- dispatcher()->AsWindowTreeHostDelegate()->OnHostMouseEvent(
- &mouse_move_event);
+ DispatchEventUsingWindowDispatcher(&mouse_move_event);
// Discard MOUSE_ENTER.
filter->Reset();
@@ -620,16 +619,14 @@ TEST_F(RootWindowTest, MouseMovesHeld) {
// Check that we don't immediately dispatch the MOUSE_DRAGGED event.
ui::MouseEvent mouse_dragged_event(ui::ET_MOUSE_DRAGGED, gfx::Point(0, 0),
gfx::Point(0, 0), 0, 0);
- dispatcher()->AsWindowTreeHostDelegate()->OnHostMouseEvent(
- &mouse_dragged_event);
+ DispatchEventUsingWindowDispatcher(&mouse_dragged_event);
EXPECT_TRUE(filter->events().empty());
// Check that we do dispatch the held MOUSE_DRAGGED event before another type
// of event.
ui::MouseEvent mouse_pressed_event(ui::ET_MOUSE_PRESSED, gfx::Point(0, 0),
gfx::Point(0, 0), 0, 0);
- dispatcher()->AsWindowTreeHostDelegate()->OnHostMouseEvent(
- &mouse_pressed_event);
+ DispatchEventUsingWindowDispatcher(&mouse_pressed_event);
EXPECT_EQ("MOUSE_DRAGGED MOUSE_PRESSED",
EventTypesToString(filter->events()));
filter->Reset();
@@ -637,21 +634,17 @@ TEST_F(RootWindowTest, MouseMovesHeld) {
// Check that we coalesce held MOUSE_DRAGGED events.
ui::MouseEvent mouse_dragged_event2(ui::ET_MOUSE_DRAGGED, gfx::Point(1, 1),
gfx::Point(1, 1), 0, 0);
- dispatcher()->AsWindowTreeHostDelegate()->OnHostMouseEvent(
- &mouse_dragged_event);
- dispatcher()->AsWindowTreeHostDelegate()->OnHostMouseEvent(
- &mouse_dragged_event2);
+ DispatchEventUsingWindowDispatcher(&mouse_dragged_event);
+ DispatchEventUsingWindowDispatcher(&mouse_dragged_event2);
EXPECT_TRUE(filter->events().empty());
- dispatcher()->AsWindowTreeHostDelegate()->OnHostMouseEvent(
- &mouse_pressed_event);
+ DispatchEventUsingWindowDispatcher(&mouse_pressed_event);
EXPECT_EQ("MOUSE_DRAGGED MOUSE_PRESSED",
EventTypesToString(filter->events()));
filter->Reset();
// Check that on ReleasePointerMoves, held events are not dispatched
// immediately, but posted instead.
- dispatcher()->AsWindowTreeHostDelegate()->OnHostMouseEvent(
- &mouse_dragged_event);
+ DispatchEventUsingWindowDispatcher(&mouse_dragged_event);
dispatcher()->ReleasePointerMoves();
EXPECT_TRUE(filter->events().empty());
RunAllPendingInMessageLoop();
@@ -661,11 +654,9 @@ TEST_F(RootWindowTest, MouseMovesHeld) {
// However if another message comes in before the dispatch of the posted
// event, check that the posted event is dispatched before this new event.
dispatcher()->HoldPointerMoves();
- dispatcher()->AsWindowTreeHostDelegate()->OnHostMouseEvent(
- &mouse_dragged_event);
+ DispatchEventUsingWindowDispatcher(&mouse_dragged_event);
dispatcher()->ReleasePointerMoves();
- dispatcher()->AsWindowTreeHostDelegate()->OnHostMouseEvent(
- &mouse_pressed_event);
+ DispatchEventUsingWindowDispatcher(&mouse_pressed_event);
EXPECT_EQ("MOUSE_DRAGGED MOUSE_PRESSED",
EventTypesToString(filter->events()));
filter->Reset();
@@ -675,11 +666,9 @@ TEST_F(RootWindowTest, MouseMovesHeld) {
// Check that if the other message is another MOUSE_DRAGGED, we still coalesce
// them.
dispatcher()->HoldPointerMoves();
- dispatcher()->AsWindowTreeHostDelegate()->OnHostMouseEvent(
- &mouse_dragged_event);
+ DispatchEventUsingWindowDispatcher(&mouse_dragged_event);
dispatcher()->ReleasePointerMoves();
- dispatcher()->AsWindowTreeHostDelegate()->OnHostMouseEvent(
- &mouse_dragged_event2);
+ DispatchEventUsingWindowDispatcher(&mouse_dragged_event2);
EXPECT_EQ("MOUSE_DRAGGED", EventTypesToString(filter->events()));
filter->Reset();
RunAllPendingInMessageLoop();
@@ -700,8 +689,7 @@ TEST_F(RootWindowTest, TouchMovesHeld) {
// test.
ui::TouchEvent touch_pressed_event(ui::ET_TOUCH_PRESSED, touch_location,
0, base::TimeDelta());
- dispatcher()->AsWindowTreeHostDelegate()->OnHostTouchEvent(
- &touch_pressed_event);
+ DispatchEventUsingWindowDispatcher(&touch_pressed_event);
filter->WaitUntilReceivedEvent(ui::ET_GESTURE_SHOW_PRESS);
filter->Reset();
@@ -710,14 +698,12 @@ TEST_F(RootWindowTest, TouchMovesHeld) {
// Check that we don't immediately dispatch the TOUCH_MOVED event.
ui::TouchEvent touch_moved_event(ui::ET_TOUCH_MOVED, touch_location,
0, base::TimeDelta());
- dispatcher()->AsWindowTreeHostDelegate()->OnHostTouchEvent(
- &touch_moved_event);
+ DispatchEventUsingWindowDispatcher(&touch_moved_event);
EXPECT_TRUE(filter->events().empty());
// Check that on ReleasePointerMoves, held events are not dispatched
// immediately, but posted instead.
- dispatcher()->AsWindowTreeHostDelegate()->OnHostTouchEvent(
- &touch_moved_event);
+ DispatchEventUsingWindowDispatcher(&touch_moved_event);
dispatcher()->ReleasePointerMoves();
EXPECT_TRUE(filter->events().empty());
@@ -731,10 +717,8 @@ TEST_F(RootWindowTest, TouchMovesHeld) {
0, base::TimeDelta());
filter->Reset();
dispatcher()->HoldPointerMoves();
- dispatcher()->AsWindowTreeHostDelegate()->OnHostTouchEvent(
- &touch_moved_event);
- dispatcher()->AsWindowTreeHostDelegate()->OnHostTouchEvent(
- &touch_released_event);
+ DispatchEventUsingWindowDispatcher(&touch_moved_event);
+ DispatchEventUsingWindowDispatcher(&touch_released_event);
EXPECT_EQ("TOUCH_MOVED TOUCH_RELEASED GESTURE_TAP_CANCEL GESTURE_END",
EventTypesToString(filter->events()));
filter->Reset();
@@ -821,20 +805,20 @@ TEST_F(RootWindowTest, DispatchSyntheticMouseEvents) {
// Dispatch a non-synthetic mouse event when mouse events are enabled.
ui::MouseEvent mouse1(ui::ET_MOUSE_MOVED, gfx::Point(10, 10),
gfx::Point(10, 10), 0, 0);
- dispatcher()->AsWindowTreeHostDelegate()->OnHostMouseEvent(&mouse1);
+ DispatchEventUsingWindowDispatcher(&mouse1);
EXPECT_FALSE(filter->events().empty());
filter->Reset();
// Dispatch a synthetic mouse event when mouse events are enabled.
ui::MouseEvent mouse2(ui::ET_MOUSE_MOVED, gfx::Point(10, 10),
gfx::Point(10, 10), ui::EF_IS_SYNTHESIZED, 0);
- dispatcher()->AsWindowTreeHostDelegate()->OnHostMouseEvent(&mouse2);
+ DispatchEventUsingWindowDispatcher(&mouse2);
EXPECT_FALSE(filter->events().empty());
filter->Reset();
// Dispatch a synthetic mouse event when mouse events are disabled.
cursor_client.DisableMouseEvents();
- dispatcher()->AsWindowTreeHostDelegate()->OnHostMouseEvent(&mouse2);
+ DispatchEventUsingWindowDispatcher(&mouse2);
EXPECT_TRUE(filter->events().empty());
}
@@ -856,7 +840,7 @@ TEST_F(RootWindowTest, DispatchMouseExitWhenCursorHidden) {
ui::MouseEvent mouse1(ui::ET_MOUSE_MOVED, mouse_location,
mouse_location, 0, 0);
EXPECT_TRUE(filter->events().empty());
- dispatcher()->AsWindowTreeHostDelegate()->OnHostMouseEvent(&mouse1);
+ DispatchEventUsingWindowDispatcher(&mouse1);
EXPECT_FALSE(filter->events().empty());
filter->Reset();
@@ -1371,8 +1355,6 @@ class DontResetHeldEventWindowDelegate : public test::TestWindowDelegate {
TEST_F(RootWindowTest, DontResetHeldEvent) {
DontResetHeldEventWindowDelegate delegate(root_window());
scoped_ptr<Window> w1(CreateNormalWindow(1, root_window(), &delegate));
- WindowTreeHostDelegate* root_window_delegate =
- static_cast<WindowTreeHostDelegate*>(root_window()->GetDispatcher());
w1->SetBounds(gfx::Rect(0, 0, 40, 40));
ui::MouseEvent pressed(ui::ET_MOUSE_PRESSED,
gfx::Point(10, 10), gfx::Point(10, 10),
@@ -1380,13 +1362,13 @@ TEST_F(RootWindowTest, DontResetHeldEvent) {
root_window()->GetDispatcher()->RepostEvent(pressed);
ui::MouseEvent pressed2(ui::ET_MOUSE_PRESSED,
gfx::Point(10, 10), gfx::Point(10, 10), 0, 0);
- // Invoke OnHostMouseEvent() to flush event scheduled by way of RepostEvent().
- root_window_delegate->OnHostMouseEvent(&pressed2);
+ // Dispatch an event to flush event scheduled by way of RepostEvent().
+ DispatchEventUsingWindowDispatcher(&pressed2);
// Delegate should have seen reposted event (identified by way of
- // EF_SHIFT_DOWN). Invoke OnHostMouseEvent() to flush the second
+ // EF_SHIFT_DOWN). Dispatch another event to flush the second
// RepostedEvent().
EXPECT_EQ(1, delegate.mouse_event_count());
- root_window_delegate->OnHostMouseEvent(&pressed2);
+ DispatchEventUsingWindowDispatcher(&pressed2);
EXPECT_EQ(2, delegate.mouse_event_count());
}
@@ -1464,7 +1446,7 @@ TEST_F(RootWindowTest, WindowHideCancelsActiveTouches) {
gfx::Point position1 = root_window()->bounds().origin();
ui::TouchEvent press(ui::ET_TOUCH_PRESSED, position1, 0, base::TimeDelta());
- dispatcher()->AsWindowTreeHostDelegate()->OnHostTouchEvent(&press);
+ DispatchEventUsingWindowDispatcher(&press);
EXPECT_EQ("TOUCH_PRESSED GESTURE_BEGIN GESTURE_TAP_DOWN",
EventTypesToString(filter->GetAndResetEvents()));
@@ -1486,13 +1468,13 @@ TEST_F(RootWindowTest, WindowHideCancelsActiveGestures) {
gfx::Point position1 = root_window()->bounds().origin();
gfx::Point position2 = root_window()->bounds().CenterPoint();
ui::TouchEvent press(ui::ET_TOUCH_PRESSED, position1, 0, base::TimeDelta());
- dispatcher()->AsWindowTreeHostDelegate()->OnHostTouchEvent(&press);
+ DispatchEventUsingWindowDispatcher(&press);
ui::TouchEvent move(ui::ET_TOUCH_MOVED, position2, 0, base::TimeDelta());
- dispatcher()->AsWindowTreeHostDelegate()->OnHostTouchEvent(&move);
+ DispatchEventUsingWindowDispatcher(&move);
ui::TouchEvent press2(ui::ET_TOUCH_PRESSED, position1, 1, base::TimeDelta());
- dispatcher()->AsWindowTreeHostDelegate()->OnHostTouchEvent(&press2);
+ DispatchEventUsingWindowDispatcher(&press2);
EXPECT_EQ("TOUCH_PRESSED GESTURE_BEGIN GESTURE_TAP_DOWN TOUCH_MOVED "
"GESTURE_TAP_CANCEL GESTURE_SCROLL_BEGIN GESTURE_SCROLL_UPDATE "
@@ -1523,11 +1505,11 @@ TEST_F(RootWindowTest, EndingEventDoesntRetarget) {
gfx::Point position = window1->bounds().origin();
ui::TouchEvent press(ui::ET_TOUCH_PRESSED, position, 0, base::TimeDelta());
- dispatcher()->AsWindowTreeHostDelegate()->OnHostTouchEvent(&press);
+ DispatchEventUsingWindowDispatcher(&press);
gfx::Point position2 = window1->bounds().CenterPoint();
ui::TouchEvent move(ui::ET_TOUCH_MOVED, position2, 0, base::TimeDelta());
- dispatcher()->AsWindowTreeHostDelegate()->OnHostTouchEvent(&move);
+ DispatchEventUsingWindowDispatcher(&move);
window2->SetCapture();
@@ -1646,8 +1628,7 @@ TEST_F(RootWindowTestInHighDPI, EventLocationTransform) {
ui::MouseEvent move(ui::ET_MOUSE_MOVED,
gfx::Point(30, 30), gfx::Point(30, 30),
ui::EF_NONE, ui::EF_NONE);
- ui::EventDispatchDetails details = dispatcher()->OnEventFromSource(&move);
- ASSERT_FALSE(details.dispatcher_destroyed);
+ DispatchEventUsingWindowDispatcher(&move);
EXPECT_EQ(0, handler_child.num_mouse_events());
EXPECT_EQ(1, handler_root.num_mouse_events());
}
@@ -1656,8 +1637,7 @@ TEST_F(RootWindowTestInHighDPI, EventLocationTransform) {
ui::MouseEvent move(ui::ET_MOUSE_MOVED,
gfx::Point(50, 50), gfx::Point(50, 50),
ui::EF_NONE, ui::EF_NONE);
- ui::EventDispatchDetails details = dispatcher()->OnEventFromSource(&move);
- ASSERT_FALSE(details.dispatcher_destroyed);
+ DispatchEventUsingWindowDispatcher(&move);
// The child receives an ENTER, and a MOVED event.
EXPECT_EQ(2, handler_child.num_mouse_events());
// The root receives both the ENTER and the MOVED events dispatched to
« no previous file with comments | « ui/aura/root_window_host_x11_unittest.cc ('k') | ui/aura/test/aura_test_base.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698