| OLD | NEW |
| 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 171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 182 TEST_F(RootWindowTest, HideCursor) { | 182 TEST_F(RootWindowTest, HideCursor) { |
| 183 #endif // defined(OS_WIN) | 183 #endif // defined(OS_WIN) |
| 184 scoped_ptr<NonClientDelegate> delegate(new NonClientDelegate()); | 184 scoped_ptr<NonClientDelegate> delegate(new NonClientDelegate()); |
| 185 const int kWindowWidth = 123; | 185 const int kWindowWidth = 123; |
| 186 const int kWindowHeight = 45; | 186 const int kWindowHeight = 45; |
| 187 gfx::Rect bounds(100, 200, kWindowWidth, kWindowHeight); | 187 gfx::Rect bounds(100, 200, kWindowWidth, kWindowHeight); |
| 188 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate( | 188 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate( |
| 189 delegate.get(), -1234, bounds, NULL)); | 189 delegate.get(), -1234, bounds, NULL)); |
| 190 aura::Window* window_ptr = &*window; | 190 aura::Window* window_ptr = &*window; |
| 191 | 191 |
| 192 root_window()->ShowCursor(true); | 192 root_window()->OnCursorVisibilityChanged(true); |
| 193 // Send a mouse event to window. | 193 // Send a mouse event to window. |
| 194 gfx::Point point(101, 201); | 194 gfx::Point point(101, 201); |
| 195 gfx::Point local_point; | 195 gfx::Point local_point; |
| 196 ui::MouseEvent event(ui::ET_MOUSE_MOVED, point, point, 0); | 196 ui::MouseEvent event(ui::ET_MOUSE_MOVED, point, point, 0); |
| 197 root_window()->AsRootWindowHostDelegate()->OnHostMouseEvent(&event); | 197 root_window()->AsRootWindowHostDelegate()->OnHostMouseEvent(&event); |
| 198 | 198 |
| 199 // Location was in window. | 199 // Location was in window. |
| 200 local_point = delegate->mouse_event_location(); | 200 local_point = delegate->mouse_event_location(); |
| 201 aura::Window::ConvertPointToTarget(window_ptr, root_window(), &local_point); | 201 aura::Window::ConvertPointToTarget(window_ptr, root_window(), &local_point); |
| 202 EXPECT_TRUE(window->bounds().Contains(local_point)); | 202 EXPECT_TRUE(window->bounds().Contains(local_point)); |
| 203 | 203 |
| 204 // Location is now out of window. | 204 // Location is now out of window. |
| 205 root_window()->ShowCursor(false); | 205 root_window()->OnCursorVisibilityChanged(false); |
| 206 RunAllPendingInMessageLoop(); | 206 RunAllPendingInMessageLoop(); |
| 207 local_point = delegate->mouse_event_location(); | 207 local_point = delegate->mouse_event_location(); |
| 208 aura::Window::ConvertPointToTarget(window_ptr, root_window(), &local_point); | 208 aura::Window::ConvertPointToTarget(window_ptr, root_window(), &local_point); |
| 209 EXPECT_FALSE(window->bounds().Contains(local_point)); | 209 EXPECT_FALSE(window->bounds().Contains(local_point)); |
| 210 | 210 |
| 211 // Location is back in window. | 211 // Location is back in window. |
| 212 root_window()->ShowCursor(true); | 212 root_window()->OnCursorVisibilityChanged(true); |
| 213 RunAllPendingInMessageLoop(); | 213 RunAllPendingInMessageLoop(); |
| 214 local_point = delegate->mouse_event_location(); | 214 local_point = delegate->mouse_event_location(); |
| 215 aura::Window::ConvertPointToTarget(window_ptr, root_window(), &local_point); | 215 aura::Window::ConvertPointToTarget(window_ptr, root_window(), &local_point); |
| 216 EXPECT_TRUE(window->bounds().Contains(local_point)); | 216 EXPECT_TRUE(window->bounds().Contains(local_point)); |
| 217 } | 217 } |
| 218 | 218 |
| 219 // Check that we correctly track the state of the mouse buttons in response to | 219 // Check that we correctly track the state of the mouse buttons in response to |
| 220 // button press and release events. | 220 // button press and release events. |
| 221 TEST_F(RootWindowTest, MouseButtonState) { | 221 TEST_F(RootWindowTest, MouseButtonState) { |
| 222 EXPECT_FALSE(Env::GetInstance()->is_mouse_button_down()); | 222 EXPECT_FALSE(Env::GetInstance()->is_mouse_button_down()); |
| (...skipping 551 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 774 TEST_F(RootWindowTest, GestureRecognizerResetsTargetWhenParentHides) { | 774 TEST_F(RootWindowTest, GestureRecognizerResetsTargetWhenParentHides) { |
| 775 scoped_ptr<Window> w1(CreateWindow(1, root_window(), NULL)); | 775 scoped_ptr<Window> w1(CreateWindow(1, root_window(), NULL)); |
| 776 DetachesParentOnTapDelegate delegate; | 776 DetachesParentOnTapDelegate delegate; |
| 777 scoped_ptr<Window> parent(CreateWindow(22, w1.get(), NULL)); | 777 scoped_ptr<Window> parent(CreateWindow(22, w1.get(), NULL)); |
| 778 Window* child = CreateWindow(11, parent.get(), &delegate); | 778 Window* child = CreateWindow(11, parent.get(), &delegate); |
| 779 test::EventGenerator generator(root_window(), child); | 779 test::EventGenerator generator(root_window(), child); |
| 780 generator.GestureTapAt(gfx::Point(40, 40)); | 780 generator.GestureTapAt(gfx::Point(40, 40)); |
| 781 } | 781 } |
| 782 | 782 |
| 783 } // namespace aura | 783 } // namespace aura |
| OLD | NEW |