Index: ash/wm/window_manager_unittest.cc |
diff --git a/ash/wm/window_manager_unittest.cc b/ash/wm/window_manager_unittest.cc |
index 2968f734432fb3eef47968743778b04c03e28741..6f24d6d82996836786b986b9befe80095f09e5ca 100644 |
--- a/ash/wm/window_manager_unittest.cc |
+++ b/ash/wm/window_manager_unittest.cc |
@@ -143,7 +143,7 @@ TEST_F(WindowManagerTest, Focus) { |
Shell::GetInstance()->RemovePreTargetHandler( |
shell_test.input_method_event_filter()); |
- aura::RootWindow* root_window = Shell::GetPrimaryRootWindow(); |
+ aura::Window* root_window = Shell::GetPrimaryRootWindow(); |
root_window->SetBounds(gfx::Rect(0, 0, 510, 510)); |
// Supplied ids are negative so as not to collide with shell ids. |
@@ -183,21 +183,23 @@ TEST_F(WindowManagerTest, Focus) { |
aura::client::GetFocusClient(w121.get()); |
EXPECT_EQ(w121.get(), focus_client->GetFocusedWindow()); |
+ aura::WindowEventDispatcher* dispatcher = root_window->GetDispatcher(); |
+ |
// The key press should be sent to the focused sub-window. |
ui::KeyEvent keyev(ui::ET_KEY_PRESSED, ui::VKEY_E, 0, false); |
- root_window->AsRootWindowHostDelegate()->OnHostKeyEvent(&keyev); |
+ dispatcher->AsRootWindowHostDelegate()->OnHostKeyEvent(&keyev); |
EXPECT_EQ(ui::VKEY_E, w121delegate->last_key_code()); |
// Touch on a sub-window (w122) to focus it. |
gfx::Point click_point = w122->bounds().CenterPoint(); |
aura::Window::ConvertPointToTarget(w122->parent(), root_window, &click_point); |
ui::TouchEvent touchev(ui::ET_TOUCH_PRESSED, click_point, 0, getTime()); |
- root_window->AsRootWindowHostDelegate()->OnHostTouchEvent(&touchev); |
+ dispatcher->AsRootWindowHostDelegate()->OnHostTouchEvent(&touchev); |
focus_client = aura::client::GetFocusClient(w122.get()); |
EXPECT_EQ(w122.get(), focus_client->GetFocusedWindow()); |
// The key press should be sent to the focused sub-window. |
- root_window->AsRootWindowHostDelegate()->OnHostKeyEvent(&keyev); |
+ dispatcher->AsRootWindowHostDelegate()->OnHostKeyEvent(&keyev); |
EXPECT_EQ(ui::VKEY_E, w122delegate->last_key_code()); |
// Hiding the focused window will set the focus to its parent if |
@@ -234,7 +236,7 @@ TEST_F(WindowManagerTest, Focus) { |
EXPECT_EQ(aura::client::GetFocusClient(w12.get()), |
aura::client::GetFocusClient(w123.get())); |
EXPECT_EQ(NULL, aura::client::GetFocusClient(w12.get())->GetFocusedWindow()); |
- EXPECT_FALSE(root_window->AsRootWindowHostDelegate()->OnHostKeyEvent(&keyev)); |
+ EXPECT_FALSE(dispatcher->AsRootWindowHostDelegate()->OnHostKeyEvent(&keyev)); |
// Set the focus back to w123 |
aura::client::SetActivationDelegate(w1.get(), NULL); |
@@ -248,12 +250,12 @@ TEST_F(WindowManagerTest, Focus) { |
// parent window is not focusable. |
w12->RemoveChild(w123.get()); |
EXPECT_EQ(NULL, aura::client::GetFocusClient(w123.get())); |
- EXPECT_FALSE(root_window->AsRootWindowHostDelegate()->OnHostKeyEvent(&keyev)); |
+ EXPECT_FALSE(dispatcher->AsRootWindowHostDelegate()->OnHostKeyEvent(&keyev)); |
} |
// Various assertion testing for activating windows. |
TEST_F(WindowManagerTest, ActivateOnMouse) { |
- aura::RootWindow* root_window = Shell::GetPrimaryRootWindow(); |
+ aura::Window* root_window = Shell::GetPrimaryRootWindow(); |
test::TestActivationDelegate d1; |
aura::test::TestWindowDelegate wd; |
@@ -408,7 +410,7 @@ TEST_F(WindowManagerTest, PanelActivation) { |
// Essentially the same as ActivateOnMouse, but for touch events. |
TEST_F(WindowManagerTest, ActivateOnTouch) { |
- aura::RootWindow* root_window = Shell::GetPrimaryRootWindow(); |
+ aura::Window* root_window = Shell::GetPrimaryRootWindow(); |
test::TestActivationDelegate d1; |
aura::test::TestWindowDelegate wd; |
@@ -438,7 +440,9 @@ TEST_F(WindowManagerTest, ActivateOnTouch) { |
gfx::Point press_point = w2->bounds().CenterPoint(); |
aura::Window::ConvertPointToTarget(w2->parent(), root_window, &press_point); |
ui::TouchEvent touchev1(ui::ET_TOUCH_PRESSED, press_point, 0, getTime()); |
- root_window->AsRootWindowHostDelegate()->OnHostTouchEvent(&touchev1); |
+ |
+ aura::WindowEventDispatcher* dispatcher = root_window->GetDispatcher(); |
+ dispatcher->AsRootWindowHostDelegate()->OnHostTouchEvent(&touchev1); |
// Window2 should have become active. |
EXPECT_TRUE(wm::IsActiveWindow(w2.get())); |
@@ -455,7 +459,7 @@ TEST_F(WindowManagerTest, ActivateOnTouch) { |
aura::Window::ConvertPointToTarget(w1->parent(), root_window, &press_point); |
d1.set_activate(false); |
ui::TouchEvent touchev2(ui::ET_TOUCH_PRESSED, press_point, 1, getTime()); |
- root_window->AsRootWindowHostDelegate()->OnHostTouchEvent(&touchev2); |
+ dispatcher->AsRootWindowHostDelegate()->OnHostTouchEvent(&touchev2); |
// Window2 should still be active and focused. |
EXPECT_TRUE(wm::IsActiveWindow(w2.get())); |
@@ -479,7 +483,7 @@ TEST_F(WindowManagerTest, ActivateOnTouch) { |
} |
TEST_F(WindowManagerTest, MouseEventCursors) { |
- aura::RootWindow* root_window = Shell::GetPrimaryRootWindow(); |
+ aura::Window* root_window = Shell::GetPrimaryRootWindow(); |
// Create a window. |
const int kWindowLeft = 123; |
@@ -497,76 +501,78 @@ TEST_F(WindowManagerTest, MouseEventCursors) { |
gfx::Point point2(kWindowLeft + 1, kWindowTop + 1); |
aura::Window::ConvertPointToTarget(window->parent(), root_window, &point2); |
+ aura::WindowEventDispatcher* dispatcher = root_window->GetDispatcher(); |
+ |
// Cursor starts as a pointer (set during Shell::Init()). |
- EXPECT_EQ(ui::kCursorPointer, root_window->last_cursor().native_type()); |
+ EXPECT_EQ(ui::kCursorPointer, dispatcher->last_cursor().native_type()); |
{ |
// Resize edges and corners show proper cursors. |
window_delegate.set_hittest_code(HTBOTTOM); |
ui::MouseEvent move1(ui::ET_MOUSE_MOVED, point1, point1, 0x0); |
- root_window->AsRootWindowHostDelegate()->OnHostMouseEvent(&move1); |
- EXPECT_EQ(ui::kCursorSouthResize, root_window->last_cursor().native_type()); |
+ dispatcher->AsRootWindowHostDelegate()->OnHostMouseEvent(&move1); |
+ EXPECT_EQ(ui::kCursorSouthResize, dispatcher->last_cursor().native_type()); |
} |
{ |
window_delegate.set_hittest_code(HTBOTTOMLEFT); |
ui::MouseEvent move2(ui::ET_MOUSE_MOVED, point2, point2, 0x0); |
- root_window->AsRootWindowHostDelegate()->OnHostMouseEvent(&move2); |
+ dispatcher->AsRootWindowHostDelegate()->OnHostMouseEvent(&move2); |
EXPECT_EQ(ui::kCursorSouthWestResize, |
- root_window->last_cursor().native_type()); |
+ dispatcher->last_cursor().native_type()); |
} |
{ |
window_delegate.set_hittest_code(HTBOTTOMRIGHT); |
ui::MouseEvent move1(ui::ET_MOUSE_MOVED, point1, point1, 0x0); |
- root_window->AsRootWindowHostDelegate()->OnHostMouseEvent(&move1); |
+ dispatcher->AsRootWindowHostDelegate()->OnHostMouseEvent(&move1); |
EXPECT_EQ(ui::kCursorSouthEastResize, |
- root_window->last_cursor().native_type()); |
+ dispatcher->last_cursor().native_type()); |
} |
{ |
window_delegate.set_hittest_code(HTLEFT); |
ui::MouseEvent move2(ui::ET_MOUSE_MOVED, point2, point2, 0x0); |
- root_window->AsRootWindowHostDelegate()->OnHostMouseEvent(&move2); |
- EXPECT_EQ(ui::kCursorWestResize, root_window->last_cursor().native_type()); |
+ dispatcher->AsRootWindowHostDelegate()->OnHostMouseEvent(&move2); |
+ EXPECT_EQ(ui::kCursorWestResize, dispatcher->last_cursor().native_type()); |
} |
{ |
window_delegate.set_hittest_code(HTRIGHT); |
ui::MouseEvent move1(ui::ET_MOUSE_MOVED, point1, point1, 0x0); |
- root_window->AsRootWindowHostDelegate()->OnHostMouseEvent(&move1); |
- EXPECT_EQ(ui::kCursorEastResize, root_window->last_cursor().native_type()); |
+ dispatcher->AsRootWindowHostDelegate()->OnHostMouseEvent(&move1); |
+ EXPECT_EQ(ui::kCursorEastResize, dispatcher->last_cursor().native_type()); |
} |
{ |
window_delegate.set_hittest_code(HTTOP); |
ui::MouseEvent move2(ui::ET_MOUSE_MOVED, point2, point2, 0x0); |
- root_window->AsRootWindowHostDelegate()->OnHostMouseEvent(&move2); |
- EXPECT_EQ(ui::kCursorNorthResize, root_window->last_cursor().native_type()); |
+ dispatcher->AsRootWindowHostDelegate()->OnHostMouseEvent(&move2); |
+ EXPECT_EQ(ui::kCursorNorthResize, dispatcher->last_cursor().native_type()); |
} |
{ |
window_delegate.set_hittest_code(HTTOPLEFT); |
ui::MouseEvent move1(ui::ET_MOUSE_MOVED, point1, point1, 0x0); |
- root_window->AsRootWindowHostDelegate()->OnHostMouseEvent(&move1); |
+ dispatcher->AsRootWindowHostDelegate()->OnHostMouseEvent(&move1); |
EXPECT_EQ(ui::kCursorNorthWestResize, |
- root_window->last_cursor().native_type()); |
+ dispatcher->last_cursor().native_type()); |
} |
{ |
window_delegate.set_hittest_code(HTTOPRIGHT); |
ui::MouseEvent move2(ui::ET_MOUSE_MOVED, point2, point2, 0x0); |
- root_window->AsRootWindowHostDelegate()->OnHostMouseEvent(&move2); |
+ dispatcher->AsRootWindowHostDelegate()->OnHostMouseEvent(&move2); |
EXPECT_EQ(ui::kCursorNorthEastResize, |
- root_window->last_cursor().native_type()); |
+ dispatcher->last_cursor().native_type()); |
} |
{ |
// Client area uses null cursor. |
window_delegate.set_hittest_code(HTCLIENT); |
ui::MouseEvent move1(ui::ET_MOUSE_MOVED, point1, point1, 0x0); |
- root_window->AsRootWindowHostDelegate()->OnHostMouseEvent(&move1); |
- EXPECT_EQ(ui::kCursorNull, root_window->last_cursor().native_type()); |
+ dispatcher->AsRootWindowHostDelegate()->OnHostMouseEvent(&move1); |
+ EXPECT_EQ(ui::kCursorNull, dispatcher->last_cursor().native_type()); |
} |
} |
@@ -576,7 +582,7 @@ TEST_F(WindowManagerTest, MouseEventCursors) { |
#define MAYBE_TransformActivate TransformActivate |
#endif |
TEST_F(WindowManagerTest, MAYBE_TransformActivate) { |
- aura::RootWindow* root_window = Shell::GetPrimaryRootWindow(); |
+ aura::Window* root_window = Shell::GetPrimaryRootWindow(); |
gfx::Size size = root_window->bounds().size(); |
EXPECT_EQ(gfx::Rect(size).ToString(), |
Shell::GetScreen()->GetDisplayNearestPoint( |
@@ -601,13 +607,14 @@ TEST_F(WindowManagerTest, MAYBE_TransformActivate) { |
miss_point, |
miss_point, |
ui::EF_LEFT_MOUSE_BUTTON); |
- root_window->AsRootWindowHostDelegate()->OnHostMouseEvent(&mouseev1); |
+ aura::WindowEventDispatcher* dispatcher = root_window->GetDispatcher(); |
+ dispatcher->AsRootWindowHostDelegate()->OnHostMouseEvent(&mouseev1); |
EXPECT_EQ(NULL, aura::client::GetFocusClient(w1.get())->GetFocusedWindow()); |
ui::MouseEvent mouseup(ui::ET_MOUSE_RELEASED, |
miss_point, |
miss_point, |
ui::EF_LEFT_MOUSE_BUTTON); |
- root_window->AsRootWindowHostDelegate()->OnHostMouseEvent(&mouseup); |
+ dispatcher->AsRootWindowHostDelegate()->OnHostMouseEvent(&mouseup); |
gfx::Point hit_point(5, 15); |
transform.TransformPoint(&hit_point); |
@@ -615,7 +622,7 @@ TEST_F(WindowManagerTest, MAYBE_TransformActivate) { |
hit_point, |
hit_point, |
ui::EF_LEFT_MOUSE_BUTTON); |
- root_window->AsRootWindowHostDelegate()->OnHostMouseEvent(&mouseev2); |
+ dispatcher->AsRootWindowHostDelegate()->OnHostMouseEvent(&mouseev2); |
EXPECT_TRUE(wm::IsActiveWindow(w1.get())); |
EXPECT_EQ(w1.get(), |
aura::client::GetFocusClient(w1.get())->GetFocusedWindow()); |
@@ -628,7 +635,7 @@ TEST_F(WindowManagerTest, AdditionalFilters) { |
Shell::GetInstance()->RemovePreTargetHandler( |
shell_test.input_method_event_filter()); |
- aura::RootWindow* root_window = Shell::GetPrimaryRootWindow(); |
+ aura::Window* root_window = Shell::GetPrimaryRootWindow(); |
// Creates a window and make it active |
scoped_ptr<aura::Window> w1(CreateTestWindowInShell( |
@@ -647,10 +654,11 @@ TEST_F(WindowManagerTest, AdditionalFilters) { |
// Dispatches mouse and keyboard events. |
ui::KeyEvent key_event(ui::ET_KEY_PRESSED, ui::VKEY_A, 0, false); |
- root_window->AsRootWindowHostDelegate()->OnHostKeyEvent(&key_event); |
+ aura::WindowEventDispatcher* dispatcher = root_window->GetDispatcher(); |
+ dispatcher->AsRootWindowHostDelegate()->OnHostKeyEvent(&key_event); |
ui::MouseEvent mouse_pressed( |
ui::ET_MOUSE_PRESSED, gfx::Point(0, 0), gfx::Point(0, 0), 0x0); |
- root_window->AsRootWindowHostDelegate()->OnHostMouseEvent(&mouse_pressed); |
+ dispatcher->AsRootWindowHostDelegate()->OnHostMouseEvent(&mouse_pressed); |
// Both filters should get the events. |
EXPECT_EQ(1, f1->num_key_events()); |
@@ -666,10 +674,10 @@ TEST_F(WindowManagerTest, AdditionalFilters) { |
f1->set_mouse_event_handling_result(ui::ER_CONSUMED); |
// Dispatches events. |
- root_window->AsRootWindowHostDelegate()->OnHostKeyEvent(&key_event); |
+ dispatcher->AsRootWindowHostDelegate()->OnHostKeyEvent(&key_event); |
ui::MouseEvent mouse_released( |
ui::ET_MOUSE_RELEASED, gfx::Point(0, 0), gfx::Point(0, 0), 0x0); |
- root_window->AsRootWindowHostDelegate()->OnHostMouseEvent(&mouse_released); |
+ dispatcher->AsRootWindowHostDelegate()->OnHostMouseEvent(&mouse_released); |
// f1 should still get the events but f2 no longer gets them. |
EXPECT_EQ(1, f1->num_key_events()); |
@@ -684,8 +692,8 @@ TEST_F(WindowManagerTest, AdditionalFilters) { |
env_filter->RemoveHandler(f1.get()); |
// Dispatches events. |
- root_window->AsRootWindowHostDelegate()->OnHostKeyEvent(&key_event); |
- root_window->AsRootWindowHostDelegate()->OnHostMouseEvent(&mouse_pressed); |
+ dispatcher->AsRootWindowHostDelegate()->OnHostKeyEvent(&key_event); |
+ dispatcher->AsRootWindowHostDelegate()->OnHostMouseEvent(&mouse_pressed); |
// f1 should get no events since it's out and f2 should get them. |
EXPECT_EQ(0, f1->num_key_events()); |