Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(205)

Side by Side Diff: ash/shelf/shelf_tooltip_manager_unittest.cc

Issue 1260453006: ui: events: Add a class to hold common touch and stylus properties (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Address build problems, add accessor and unit tests. Created 5 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 213 matching lines...) Expand 10 before | Expand all | Expand 10 after
224 ShowImmediately(); 224 ShowImmediately();
225 ASSERT_TRUE(TooltipIsVisible()); 225 ASSERT_TRUE(TooltipIsVisible());
226 226
227 aura::Window* root_window = Shell::GetInstance()->GetPrimaryRootWindow(); 227 aura::Window* root_window = Shell::GetInstance()->GetPrimaryRootWindow();
228 ui::EventHandler* event_handler = GetEventHandler(); 228 ui::EventHandler* event_handler = GetEventHandler();
229 229
230 gfx::Rect tooltip_rect = GetTooltipWidget()->GetNativeWindow()->bounds(); 230 gfx::Rect tooltip_rect = GetTooltipWidget()->GetNativeWindow()->bounds();
231 ASSERT_FALSE(tooltip_rect.IsEmpty()); 231 ASSERT_FALSE(tooltip_rect.IsEmpty());
232 232
233 // Shouldn't hide if the mouse is in the tooltip. 233 // Shouldn't hide if the mouse is in the tooltip.
234 ui::MouseEvent mouse_event(ui::ET_MOUSE_MOVED, tooltip_rect.CenterPoint(), 234 ui::MouseEvent mouse_event(
235 tooltip_rect.CenterPoint(), ui::EventTimeForNow(), 235 ui::ET_MOUSE_MOVED, tooltip_rect.CenterPoint(),
236 ui::EF_NONE, ui::EF_NONE); 236 tooltip_rect.CenterPoint(), ui::EventTimeForNow(), ui::EF_NONE,
237 ui::EF_NONE,
238 ui::PointerEventDetails(ui::EventPointerType::POINTER_TYPE_MOUSE));
237 ui::LocatedEventTestApi test_api(&mouse_event); 239 ui::LocatedEventTestApi test_api(&mouse_event);
238 240
239 SetEventTarget(root_window, &mouse_event); 241 SetEventTarget(root_window, &mouse_event);
240 event_handler->OnMouseEvent(&mouse_event); 242 event_handler->OnMouseEvent(&mouse_event);
241 EXPECT_FALSE(mouse_event.handled()); 243 EXPECT_FALSE(mouse_event.handled());
242 EXPECT_TRUE(TooltipIsVisible()); 244 EXPECT_TRUE(TooltipIsVisible());
243 245
244 // Should hide if the mouse is out of the tooltip. 246 // Should hide if the mouse is out of the tooltip.
245 test_api.set_location(tooltip_rect.origin() + gfx::Vector2d(-1, -1)); 247 test_api.set_location(tooltip_rect.origin() + gfx::Vector2d(-1, -1));
246 event_handler->OnMouseEvent(&mouse_event); 248 event_handler->OnMouseEvent(&mouse_event);
247 EXPECT_FALSE(mouse_event.handled()); 249 EXPECT_FALSE(mouse_event.handled());
248 RunAllPendingInMessageLoop(); 250 RunAllPendingInMessageLoop();
249 EXPECT_FALSE(TooltipIsVisible()); 251 EXPECT_FALSE(TooltipIsVisible());
250 } 252 }
251 253
252 // Checks that tooltip is hidden when mouse is pressed in anywhere. 254 // Checks that tooltip is hidden when mouse is pressed in anywhere.
253 TEST_F(ShelfTooltipManagerTest, HideForMouseClickEvent) { 255 TEST_F(ShelfTooltipManagerTest, HideForMouseClickEvent) {
254 ShowImmediately(); 256 ShowImmediately();
255 ASSERT_TRUE(TooltipIsVisible()); 257 ASSERT_TRUE(TooltipIsVisible());
256 258
257 aura::Window* root_window = Shell::GetInstance()->GetPrimaryRootWindow(); 259 aura::Window* root_window = Shell::GetInstance()->GetPrimaryRootWindow();
258 ui::EventHandler* event_handler = GetEventHandler(); 260 ui::EventHandler* event_handler = GetEventHandler();
259 261
260 gfx::Rect tooltip_rect = GetTooltipWidget()->GetNativeWindow()->bounds(); 262 gfx::Rect tooltip_rect = GetTooltipWidget()->GetNativeWindow()->bounds();
261 ASSERT_FALSE(tooltip_rect.IsEmpty()); 263 ASSERT_FALSE(tooltip_rect.IsEmpty());
262 264
263 // Should hide if the mouse is pressed in the tooltip. 265 // Should hide if the mouse is pressed in the tooltip.
264 ui::MouseEvent mouse_event(ui::ET_MOUSE_PRESSED, tooltip_rect.CenterPoint(), 266 ui::MouseEvent mouse_event(
265 tooltip_rect.CenterPoint(), ui::EventTimeForNow(), 267 ui::ET_MOUSE_PRESSED, tooltip_rect.CenterPoint(),
266 ui::EF_NONE, ui::EF_NONE); 268 tooltip_rect.CenterPoint(), ui::EventTimeForNow(), ui::EF_NONE,
269 ui::EF_NONE,
270 ui::PointerEventDetails(ui::EventPointerType::POINTER_TYPE_MOUSE));
267 271
268 SetEventTarget(root_window, &mouse_event); 272 SetEventTarget(root_window, &mouse_event);
269 event_handler->OnMouseEvent(&mouse_event); 273 event_handler->OnMouseEvent(&mouse_event);
270 EXPECT_FALSE(mouse_event.handled()); 274 EXPECT_FALSE(mouse_event.handled());
271 RunAllPendingInMessageLoop(); 275 RunAllPendingInMessageLoop();
272 EXPECT_FALSE(TooltipIsVisible()); 276 EXPECT_FALSE(TooltipIsVisible());
273 277
274 // Should hide if the mouse is pressed outside of the tooltip. 278 // Should hide if the mouse is pressed outside of the tooltip.
275 ShowImmediately(); 279 ShowImmediately();
276 ASSERT_TRUE(TooltipIsVisible()); 280 ASSERT_TRUE(TooltipIsVisible());
277 281
278 ui::LocatedEventTestApi test_api(&mouse_event); 282 ui::LocatedEventTestApi test_api(&mouse_event);
279 test_api.set_location(tooltip_rect.origin() + gfx::Vector2d(-1, -1)); 283 test_api.set_location(tooltip_rect.origin() + gfx::Vector2d(-1, -1));
280 284
281 SetEventTarget(root_window, &mouse_event); 285 SetEventTarget(root_window, &mouse_event);
282 event_handler->OnMouseEvent(&mouse_event); 286 event_handler->OnMouseEvent(&mouse_event);
283 EXPECT_FALSE(mouse_event.handled()); 287 EXPECT_FALSE(mouse_event.handled());
284 RunAllPendingInMessageLoop(); 288 RunAllPendingInMessageLoop();
285 EXPECT_FALSE(TooltipIsVisible()); 289 EXPECT_FALSE(TooltipIsVisible());
286 } 290 }
287 291
288 } // namespace test 292 } // namespace test
289 } // namespace ash 293 } // namespace ash
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698