Chromium Code Reviews| 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 "ash/launcher/launcher_tooltip_manager.h" | 5 #include "ash/launcher/launcher_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 199 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 210 ui::ET_GESTURE_BEGIN, 0, 0, ui::EF_NONE, | 210 ui::ET_GESTURE_BEGIN, 0, 0, ui::EF_NONE, |
| 211 base::TimeDelta::FromMilliseconds(base::Time::Now().ToDoubleT() * 1000), | 211 base::TimeDelta::FromMilliseconds(base::Time::Now().ToDoubleT() * 1000), |
| 212 ui::GestureEventDetails(ui::ET_GESTURE_BEGIN, 0.0f, 0.0f), 0); | 212 ui::GestureEventDetails(ui::ET_GESTURE_BEGIN, 0.0f, 0.0f), 0); |
| 213 SetEventTarget(tooltip_widget->GetNativeWindow(), &gesture_event); | 213 SetEventTarget(tooltip_widget->GetNativeWindow(), &gesture_event); |
| 214 event_handler->OnGestureEvent(&gesture_event); | 214 event_handler->OnGestureEvent(&gesture_event); |
| 215 EXPECT_FALSE(gesture_event.handled()); | 215 EXPECT_FALSE(gesture_event.handled()); |
| 216 RunAllPendingInMessageLoop(); | 216 RunAllPendingInMessageLoop(); |
| 217 EXPECT_FALSE(TooltipIsVisible()); | 217 EXPECT_FALSE(TooltipIsVisible()); |
| 218 } | 218 } |
| 219 | 219 |
| 220 TEST_F(LauncherTooltipManagerTest, HideForMouseEvent) { | 220 TEST_F(LauncherTooltipManagerTest, HideForMouseMoveEvent) { |
| 221 ShowImmediately(); | 221 ShowImmediately(); |
| 222 ASSERT_TRUE(TooltipIsVisible()); | 222 ASSERT_TRUE(TooltipIsVisible()); |
| 223 | 223 |
| 224 aura::RootWindow* root_window = Shell::GetInstance()->GetPrimaryRootWindow(); | 224 aura::RootWindow* root_window = Shell::GetInstance()->GetPrimaryRootWindow(); |
| 225 ui::EventHandler* event_handler = GetEventHandler(); | 225 ui::EventHandler* event_handler = GetEventHandler(); |
| 226 | 226 |
| 227 gfx::Rect tooltip_rect = GetTooltipWidget()->GetNativeWindow()->bounds(); | 227 gfx::Rect tooltip_rect = GetTooltipWidget()->GetNativeWindow()->bounds(); |
| 228 ASSERT_FALSE(tooltip_rect.IsEmpty()); | 228 ASSERT_FALSE(tooltip_rect.IsEmpty()); |
| 229 | 229 |
| 230 // Shouldn't hide if the mouse is in the tooltip. | 230 // Shouldn't hide if the mouse is in the tooltip. |
| 231 ui::MouseEvent mouse_event(ui::ET_MOUSE_MOVED, tooltip_rect.CenterPoint(), | 231 ui::MouseEvent mouse_event(ui::ET_MOUSE_MOVED, tooltip_rect.CenterPoint(), |
| 232 tooltip_rect.CenterPoint(), ui::EF_NONE); | 232 tooltip_rect.CenterPoint(), ui::EF_NONE); |
| 233 ui::LocatedEvent::TestApi test_api(&mouse_event); | 233 ui::LocatedEvent::TestApi test_api(&mouse_event); |
| 234 | 234 |
| 235 SetEventTarget(root_window, &mouse_event); | 235 SetEventTarget(root_window, &mouse_event); |
| 236 event_handler->OnMouseEvent(&mouse_event); | 236 event_handler->OnMouseEvent(&mouse_event); |
| 237 EXPECT_FALSE(mouse_event.handled()); | 237 EXPECT_FALSE(mouse_event.handled()); |
| 238 EXPECT_TRUE(TooltipIsVisible()); | 238 EXPECT_TRUE(TooltipIsVisible()); |
| 239 | 239 |
| 240 // Should hide if the mouse is out of the tooltip. | 240 // Should hide if the mouse is out of the tooltip. |
| 241 test_api.set_location(tooltip_rect.origin() + gfx::Vector2d(-1, -1)); | 241 test_api.set_location(tooltip_rect.origin() + gfx::Vector2d(-1, -1)); |
| 242 event_handler->OnMouseEvent(&mouse_event); | 242 event_handler->OnMouseEvent(&mouse_event); |
| 243 EXPECT_FALSE(mouse_event.handled()); | 243 EXPECT_FALSE(mouse_event.handled()); |
| 244 RunAllPendingInMessageLoop(); | 244 RunAllPendingInMessageLoop(); |
| 245 EXPECT_FALSE(TooltipIsVisible()); | 245 EXPECT_FALSE(TooltipIsVisible()); |
| 246 } | 246 } |
| 247 | 247 |
|
Mr4D (OOO till 08-26)
2013/09/04 03:21:47
Please add a comment for what the test does.
simonhong_
2013/09/04 04:18:17
Done.
| |
| 248 TEST_F(LauncherTooltipManagerTest, HideForMouseClickEvent) { | |
| 249 ShowImmediately(); | |
| 250 ASSERT_TRUE(TooltipIsVisible()); | |
| 251 | |
| 252 aura::RootWindow* root_window = Shell::GetInstance()->GetPrimaryRootWindow(); | |
| 253 ui::EventHandler* event_handler = GetEventHandler(); | |
| 254 | |
| 255 gfx::Rect tooltip_rect = GetTooltipWidget()->GetNativeWindow()->bounds(); | |
| 256 ASSERT_FALSE(tooltip_rect.IsEmpty()); | |
| 257 | |
| 258 // Should hide if the mouse is pressed in the tooltip. | |
| 259 ui::MouseEvent mouse_event(ui::ET_MOUSE_PRESSED, tooltip_rect.CenterPoint(), | |
| 260 tooltip_rect.CenterPoint(), ui::EF_NONE); | |
| 261 | |
| 262 SetEventTarget(root_window, &mouse_event); | |
| 263 event_handler->OnMouseEvent(&mouse_event); | |
| 264 EXPECT_FALSE(mouse_event.handled()); | |
| 265 RunAllPendingInMessageLoop(); | |
| 266 EXPECT_FALSE(TooltipIsVisible()); | |
| 267 | |
| 268 // Should hide if the mouse is pressed outside of the tooltip. | |
| 269 ShowImmediately(); | |
| 270 ASSERT_TRUE(TooltipIsVisible()); | |
| 271 | |
| 272 ui::LocatedEvent::TestApi test_api(&mouse_event); | |
| 273 test_api.set_location(tooltip_rect.origin() + gfx::Vector2d(-1, -1)); | |
| 274 | |
| 275 SetEventTarget(root_window, &mouse_event); | |
| 276 event_handler->OnMouseEvent(&mouse_event); | |
| 277 EXPECT_FALSE(mouse_event.handled()); | |
| 278 RunAllPendingInMessageLoop(); | |
| 279 EXPECT_FALSE(TooltipIsVisible()); | |
| 280 } | |
| 281 | |
| 248 } // namespace test | 282 } // namespace test |
| 249 } // namespace ash | 283 } // namespace ash |
| OLD | NEW |