OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "ash/shelf/shelf_tooltip_manager.h" | 5 #include "ash/shelf/shelf_tooltip_manager.h" |
6 | 6 |
7 #include "ash/root_window_controller.h" | 7 #include "ash/root_window_controller.h" |
8 #include "ash/shelf/shelf_layout_manager.h" | 8 #include "ash/shelf/shelf_layout_manager.h" |
9 #include "ash/shelf/shelf_widget.h" | 9 #include "ash/shelf/shelf_widget.h" |
10 #include "ash/shell.h" | 10 #include "ash/shell.h" |
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
173 | 173 |
174 // ShowDelayed doesn't even run the timer for the hidden shelf. | 174 // ShowDelayed doesn't even run the timer for the hidden shelf. |
175 ShowDelayed(); | 175 ShowDelayed(); |
176 EXPECT_FALSE(IsTimerRunning()); | 176 EXPECT_FALSE(IsTimerRunning()); |
177 } | 177 } |
178 | 178 |
179 TEST_F(ShelfTooltipManagerTest, ShouldHideForEvents) { | 179 TEST_F(ShelfTooltipManagerTest, ShouldHideForEvents) { |
180 ShowImmediately(); | 180 ShowImmediately(); |
181 ASSERT_TRUE(TooltipIsVisible()); | 181 ASSERT_TRUE(TooltipIsVisible()); |
182 | 182 |
183 aura::RootWindow* root_window = Shell::GetInstance()->GetPrimaryRootWindow(); | 183 aura::Window* root_window = Shell::GetInstance()->GetPrimaryRootWindow(); |
184 ui::EventHandler* event_handler = GetEventHandler(); | 184 ui::EventHandler* event_handler = GetEventHandler(); |
185 | 185 |
186 // Should not hide for key events. | 186 // Should not hide for key events. |
187 ui::KeyEvent key_event(ui::ET_KEY_PRESSED, ui::VKEY_A, ui::EF_NONE, false); | 187 ui::KeyEvent key_event(ui::ET_KEY_PRESSED, ui::VKEY_A, ui::EF_NONE, false); |
188 SetEventTarget(root_window, &key_event); | 188 SetEventTarget(root_window, &key_event); |
189 event_handler->OnKeyEvent(&key_event); | 189 event_handler->OnKeyEvent(&key_event); |
190 EXPECT_FALSE(key_event.handled()); | 190 EXPECT_FALSE(key_event.handled()); |
191 EXPECT_TRUE(TooltipIsVisible()); | 191 EXPECT_TRUE(TooltipIsVisible()); |
192 | 192 |
193 // Should hide for touch events. | 193 // Should hide for touch events. |
(...skipping 21 matching lines...) Expand all Loading... |
215 event_handler->OnGestureEvent(&gesture_event); | 215 event_handler->OnGestureEvent(&gesture_event); |
216 EXPECT_FALSE(gesture_event.handled()); | 216 EXPECT_FALSE(gesture_event.handled()); |
217 RunAllPendingInMessageLoop(); | 217 RunAllPendingInMessageLoop(); |
218 EXPECT_FALSE(TooltipIsVisible()); | 218 EXPECT_FALSE(TooltipIsVisible()); |
219 } | 219 } |
220 | 220 |
221 TEST_F(ShelfTooltipManagerTest, HideForMouseMoveEvent) { | 221 TEST_F(ShelfTooltipManagerTest, HideForMouseMoveEvent) { |
222 ShowImmediately(); | 222 ShowImmediately(); |
223 ASSERT_TRUE(TooltipIsVisible()); | 223 ASSERT_TRUE(TooltipIsVisible()); |
224 | 224 |
225 aura::RootWindow* root_window = Shell::GetInstance()->GetPrimaryRootWindow(); | 225 aura::Window* root_window = Shell::GetInstance()->GetPrimaryRootWindow(); |
226 ui::EventHandler* event_handler = GetEventHandler(); | 226 ui::EventHandler* event_handler = GetEventHandler(); |
227 | 227 |
228 gfx::Rect tooltip_rect = GetTooltipWidget()->GetNativeWindow()->bounds(); | 228 gfx::Rect tooltip_rect = GetTooltipWidget()->GetNativeWindow()->bounds(); |
229 ASSERT_FALSE(tooltip_rect.IsEmpty()); | 229 ASSERT_FALSE(tooltip_rect.IsEmpty()); |
230 | 230 |
231 // Shouldn't hide if the mouse is in the tooltip. | 231 // Shouldn't hide if the mouse is in the tooltip. |
232 ui::MouseEvent mouse_event(ui::ET_MOUSE_MOVED, tooltip_rect.CenterPoint(), | 232 ui::MouseEvent mouse_event(ui::ET_MOUSE_MOVED, tooltip_rect.CenterPoint(), |
233 tooltip_rect.CenterPoint(), ui::EF_NONE); | 233 tooltip_rect.CenterPoint(), ui::EF_NONE); |
234 ui::LocatedEvent::TestApi test_api(&mouse_event); | 234 ui::LocatedEvent::TestApi test_api(&mouse_event); |
235 | 235 |
236 SetEventTarget(root_window, &mouse_event); | 236 SetEventTarget(root_window, &mouse_event); |
237 event_handler->OnMouseEvent(&mouse_event); | 237 event_handler->OnMouseEvent(&mouse_event); |
238 EXPECT_FALSE(mouse_event.handled()); | 238 EXPECT_FALSE(mouse_event.handled()); |
239 EXPECT_TRUE(TooltipIsVisible()); | 239 EXPECT_TRUE(TooltipIsVisible()); |
240 | 240 |
241 // Should hide if the mouse is out of the tooltip. | 241 // Should hide if the mouse is out of the tooltip. |
242 test_api.set_location(tooltip_rect.origin() + gfx::Vector2d(-1, -1)); | 242 test_api.set_location(tooltip_rect.origin() + gfx::Vector2d(-1, -1)); |
243 event_handler->OnMouseEvent(&mouse_event); | 243 event_handler->OnMouseEvent(&mouse_event); |
244 EXPECT_FALSE(mouse_event.handled()); | 244 EXPECT_FALSE(mouse_event.handled()); |
245 RunAllPendingInMessageLoop(); | 245 RunAllPendingInMessageLoop(); |
246 EXPECT_FALSE(TooltipIsVisible()); | 246 EXPECT_FALSE(TooltipIsVisible()); |
247 } | 247 } |
248 | 248 |
249 // Checks that tooltip is hidden when mouse is pressed in anywhere. | 249 // Checks that tooltip is hidden when mouse is pressed in anywhere. |
250 TEST_F(ShelfTooltipManagerTest, HideForMouseClickEvent) { | 250 TEST_F(ShelfTooltipManagerTest, HideForMouseClickEvent) { |
251 ShowImmediately(); | 251 ShowImmediately(); |
252 ASSERT_TRUE(TooltipIsVisible()); | 252 ASSERT_TRUE(TooltipIsVisible()); |
253 | 253 |
254 aura::RootWindow* root_window = Shell::GetInstance()->GetPrimaryRootWindow(); | 254 aura::Window* root_window = Shell::GetInstance()->GetPrimaryRootWindow(); |
255 ui::EventHandler* event_handler = GetEventHandler(); | 255 ui::EventHandler* event_handler = GetEventHandler(); |
256 | 256 |
257 gfx::Rect tooltip_rect = GetTooltipWidget()->GetNativeWindow()->bounds(); | 257 gfx::Rect tooltip_rect = GetTooltipWidget()->GetNativeWindow()->bounds(); |
258 ASSERT_FALSE(tooltip_rect.IsEmpty()); | 258 ASSERT_FALSE(tooltip_rect.IsEmpty()); |
259 | 259 |
260 // Should hide if the mouse is pressed in the tooltip. | 260 // Should hide if the mouse is pressed in the tooltip. |
261 ui::MouseEvent mouse_event(ui::ET_MOUSE_PRESSED, tooltip_rect.CenterPoint(), | 261 ui::MouseEvent mouse_event(ui::ET_MOUSE_PRESSED, tooltip_rect.CenterPoint(), |
262 tooltip_rect.CenterPoint(), ui::EF_NONE); | 262 tooltip_rect.CenterPoint(), ui::EF_NONE); |
263 | 263 |
264 SetEventTarget(root_window, &mouse_event); | 264 SetEventTarget(root_window, &mouse_event); |
(...skipping 11 matching lines...) Expand all Loading... |
276 | 276 |
277 SetEventTarget(root_window, &mouse_event); | 277 SetEventTarget(root_window, &mouse_event); |
278 event_handler->OnMouseEvent(&mouse_event); | 278 event_handler->OnMouseEvent(&mouse_event); |
279 EXPECT_FALSE(mouse_event.handled()); | 279 EXPECT_FALSE(mouse_event.handled()); |
280 RunAllPendingInMessageLoop(); | 280 RunAllPendingInMessageLoop(); |
281 EXPECT_FALSE(TooltipIsVisible()); | 281 EXPECT_FALSE(TooltipIsVisible()); |
282 } | 282 } |
283 | 283 |
284 } // namespace test | 284 } // namespace test |
285 } // namespace ash | 285 } // namespace ash |
OLD | NEW |