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 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
140 EXPECT_EQ(gfx::Point(1, 1), delegate1->non_client_location()); | 140 EXPECT_EQ(gfx::Point(1, 1), delegate1->non_client_location()); |
141 // Mouse event was received by target window. | 141 // Mouse event was received by target window. |
142 EXPECT_EQ(1, delegate1->mouse_event_count()); | 142 EXPECT_EQ(1, delegate1->mouse_event_count()); |
143 EXPECT_EQ(0, delegate2->mouse_event_count()); | 143 EXPECT_EQ(0, delegate2->mouse_event_count()); |
144 // Event was in local coordinates. | 144 // Event was in local coordinates. |
145 EXPECT_EQ(gfx::Point(1, 1), delegate1->mouse_event_location()); | 145 EXPECT_EQ(gfx::Point(1, 1), delegate1->mouse_event_location()); |
146 // Non-client flag was set. | 146 // Non-client flag was set. |
147 EXPECT_TRUE(delegate1->mouse_event_flags() & ui::EF_IS_NON_CLIENT); | 147 EXPECT_TRUE(delegate1->mouse_event_flags() & ui::EF_IS_NON_CLIENT); |
148 } | 148 } |
149 | 149 |
| 150 #if defined(OS_WIN) |
| 151 // Temporarily disabled for windows. See crbug.com/112222. |
| 152 TEST_F(RootWindowTest, DISABLED_HideCursor) { |
| 153 #else |
| 154 TEST_F(RootWindowTest, HideCursor) { |
| 155 #endif // defined(OS_WIN) |
| 156 scoped_ptr<NonClientDelegate> delegate(new NonClientDelegate()); |
| 157 const int kWindowWidth = 123; |
| 158 const int kWindowHeight = 45; |
| 159 gfx::Rect bounds(100, 200, kWindowWidth, kWindowHeight); |
| 160 scoped_ptr<aura::Window> window(CreateTestWindowWithDelegate( |
| 161 delegate.get(), -1234, bounds, NULL)); |
| 162 aura::Window* window_ptr = &*window; |
| 163 |
| 164 root_window()->ShowCursor(true); |
| 165 // Send a mouse event to window. |
| 166 gfx::Point point(101, 201); |
| 167 gfx::Point local_point; |
| 168 ui::MouseEvent event(ui::ET_MOUSE_MOVED, point, point, 0); |
| 169 root_window()->AsRootWindowHostDelegate()->OnHostMouseEvent(&event); |
| 170 |
| 171 // Location was in window. |
| 172 local_point = delegate->mouse_event_location(); |
| 173 aura::Window::ConvertPointToTarget(window_ptr, root_window(), &local_point); |
| 174 EXPECT_TRUE(window->bounds().Contains(local_point)); |
| 175 |
| 176 // Location is now out of window. |
| 177 root_window()->ShowCursor(false); |
| 178 RunAllPendingInMessageLoop(); |
| 179 local_point = delegate->mouse_event_location(); |
| 180 aura::Window::ConvertPointToTarget(window_ptr, root_window(), &local_point); |
| 181 EXPECT_FALSE(window->bounds().Contains(local_point)); |
| 182 |
| 183 // Location is back in window. |
| 184 root_window()->ShowCursor(true); |
| 185 RunAllPendingInMessageLoop(); |
| 186 local_point = delegate->mouse_event_location(); |
| 187 aura::Window::ConvertPointToTarget(window_ptr, root_window(), &local_point); |
| 188 EXPECT_TRUE(window->bounds().Contains(local_point)); |
| 189 } |
| 190 |
150 // Check that we correctly track the state of the mouse buttons in response to | 191 // Check that we correctly track the state of the mouse buttons in response to |
151 // button press and release events. | 192 // button press and release events. |
152 TEST_F(RootWindowTest, MouseButtonState) { | 193 TEST_F(RootWindowTest, MouseButtonState) { |
153 EXPECT_FALSE(Env::GetInstance()->is_mouse_button_down()); | 194 EXPECT_FALSE(Env::GetInstance()->is_mouse_button_down()); |
154 | 195 |
155 gfx::Point location; | 196 gfx::Point location; |
156 scoped_ptr<ui::MouseEvent> event; | 197 scoped_ptr<ui::MouseEvent> event; |
157 | 198 |
158 // Press the left button. | 199 // Press the left button. |
159 event.reset(new ui::MouseEvent( | 200 event.reset(new ui::MouseEvent( |
(...skipping 378 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
538 root_window()->ReleaseMouseMoves(); | 579 root_window()->ReleaseMouseMoves(); |
539 root_window()->AsRootWindowHostDelegate()->OnHostMouseEvent( | 580 root_window()->AsRootWindowHostDelegate()->OnHostMouseEvent( |
540 &mouse_dragged_event2); | 581 &mouse_dragged_event2); |
541 EXPECT_EQ("MOUSE_DRAGGED", EventTypesToString(filter->events())); | 582 EXPECT_EQ("MOUSE_DRAGGED", EventTypesToString(filter->events())); |
542 filter->events().clear(); | 583 filter->events().clear(); |
543 RunAllPendingInMessageLoop(); | 584 RunAllPendingInMessageLoop(); |
544 EXPECT_TRUE(filter->events().empty()); | 585 EXPECT_TRUE(filter->events().empty()); |
545 } | 586 } |
546 | 587 |
547 } // namespace aura | 588 } // namespace aura |
OLD | NEW |