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

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

Issue 101573006: Changes MouseEvent constructor to take changed_button_flags. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix test; needs updated expectations as mouse entered wasnt sent before because of env::mouse_butto… Created 7 years 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 | Annotate | Revision Log
« no previous file with comments | « ash/extended_desktop_unittest.cc ('k') | ash/shelf/shelf_view.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 ASSERT_TRUE(TooltipIsVisible()); 224 ASSERT_TRUE(TooltipIsVisible());
225 225
226 aura::Window* root_window = Shell::GetInstance()->GetPrimaryRootWindow(); 226 aura::Window* root_window = Shell::GetInstance()->GetPrimaryRootWindow();
227 ui::EventHandler* event_handler = GetEventHandler(); 227 ui::EventHandler* event_handler = GetEventHandler();
228 228
229 gfx::Rect tooltip_rect = GetTooltipWidget()->GetNativeWindow()->bounds(); 229 gfx::Rect tooltip_rect = GetTooltipWidget()->GetNativeWindow()->bounds();
230 ASSERT_FALSE(tooltip_rect.IsEmpty()); 230 ASSERT_FALSE(tooltip_rect.IsEmpty());
231 231
232 // Shouldn't hide if the mouse is in the tooltip. 232 // Shouldn't hide if the mouse is in the tooltip.
233 ui::MouseEvent mouse_event(ui::ET_MOUSE_MOVED, tooltip_rect.CenterPoint(), 233 ui::MouseEvent mouse_event(ui::ET_MOUSE_MOVED, tooltip_rect.CenterPoint(),
234 tooltip_rect.CenterPoint(), ui::EF_NONE); 234 tooltip_rect.CenterPoint(), ui::EF_NONE,
235 ui::EF_NONE);
235 ui::LocatedEventTestApi test_api(&mouse_event); 236 ui::LocatedEventTestApi test_api(&mouse_event);
236 237
237 SetEventTarget(root_window, &mouse_event); 238 SetEventTarget(root_window, &mouse_event);
238 event_handler->OnMouseEvent(&mouse_event); 239 event_handler->OnMouseEvent(&mouse_event);
239 EXPECT_FALSE(mouse_event.handled()); 240 EXPECT_FALSE(mouse_event.handled());
240 EXPECT_TRUE(TooltipIsVisible()); 241 EXPECT_TRUE(TooltipIsVisible());
241 242
242 // Should hide if the mouse is out of the tooltip. 243 // Should hide if the mouse is out of the tooltip.
243 test_api.set_location(tooltip_rect.origin() + gfx::Vector2d(-1, -1)); 244 test_api.set_location(tooltip_rect.origin() + gfx::Vector2d(-1, -1));
244 event_handler->OnMouseEvent(&mouse_event); 245 event_handler->OnMouseEvent(&mouse_event);
245 EXPECT_FALSE(mouse_event.handled()); 246 EXPECT_FALSE(mouse_event.handled());
246 RunAllPendingInMessageLoop(); 247 RunAllPendingInMessageLoop();
247 EXPECT_FALSE(TooltipIsVisible()); 248 EXPECT_FALSE(TooltipIsVisible());
248 } 249 }
249 250
250 // Checks that tooltip is hidden when mouse is pressed in anywhere. 251 // Checks that tooltip is hidden when mouse is pressed in anywhere.
251 TEST_F(ShelfTooltipManagerTest, HideForMouseClickEvent) { 252 TEST_F(ShelfTooltipManagerTest, HideForMouseClickEvent) {
252 ShowImmediately(); 253 ShowImmediately();
253 ASSERT_TRUE(TooltipIsVisible()); 254 ASSERT_TRUE(TooltipIsVisible());
254 255
255 aura::Window* root_window = Shell::GetInstance()->GetPrimaryRootWindow(); 256 aura::Window* root_window = Shell::GetInstance()->GetPrimaryRootWindow();
256 ui::EventHandler* event_handler = GetEventHandler(); 257 ui::EventHandler* event_handler = GetEventHandler();
257 258
258 gfx::Rect tooltip_rect = GetTooltipWidget()->GetNativeWindow()->bounds(); 259 gfx::Rect tooltip_rect = GetTooltipWidget()->GetNativeWindow()->bounds();
259 ASSERT_FALSE(tooltip_rect.IsEmpty()); 260 ASSERT_FALSE(tooltip_rect.IsEmpty());
260 261
261 // Should hide if the mouse is pressed in the tooltip. 262 // Should hide if the mouse is pressed in the tooltip.
262 ui::MouseEvent mouse_event(ui::ET_MOUSE_PRESSED, tooltip_rect.CenterPoint(), 263 ui::MouseEvent mouse_event(ui::ET_MOUSE_PRESSED, tooltip_rect.CenterPoint(),
263 tooltip_rect.CenterPoint(), ui::EF_NONE); 264 tooltip_rect.CenterPoint(), ui::EF_NONE,
265 ui::EF_NONE);
264 266
265 SetEventTarget(root_window, &mouse_event); 267 SetEventTarget(root_window, &mouse_event);
266 event_handler->OnMouseEvent(&mouse_event); 268 event_handler->OnMouseEvent(&mouse_event);
267 EXPECT_FALSE(mouse_event.handled()); 269 EXPECT_FALSE(mouse_event.handled());
268 RunAllPendingInMessageLoop(); 270 RunAllPendingInMessageLoop();
269 EXPECT_FALSE(TooltipIsVisible()); 271 EXPECT_FALSE(TooltipIsVisible());
270 272
271 // Should hide if the mouse is pressed outside of the tooltip. 273 // Should hide if the mouse is pressed outside of the tooltip.
272 ShowImmediately(); 274 ShowImmediately();
273 ASSERT_TRUE(TooltipIsVisible()); 275 ASSERT_TRUE(TooltipIsVisible());
274 276
275 ui::LocatedEventTestApi test_api(&mouse_event); 277 ui::LocatedEventTestApi test_api(&mouse_event);
276 test_api.set_location(tooltip_rect.origin() + gfx::Vector2d(-1, -1)); 278 test_api.set_location(tooltip_rect.origin() + gfx::Vector2d(-1, -1));
277 279
278 SetEventTarget(root_window, &mouse_event); 280 SetEventTarget(root_window, &mouse_event);
279 event_handler->OnMouseEvent(&mouse_event); 281 event_handler->OnMouseEvent(&mouse_event);
280 EXPECT_FALSE(mouse_event.handled()); 282 EXPECT_FALSE(mouse_event.handled());
281 RunAllPendingInMessageLoop(); 283 RunAllPendingInMessageLoop();
282 EXPECT_FALSE(TooltipIsVisible()); 284 EXPECT_FALSE(TooltipIsVisible());
283 } 285 }
284 286
285 } // namespace test 287 } // namespace test
286 } // namespace ash 288 } // namespace ash
OLDNEW
« no previous file with comments | « ash/extended_desktop_unittest.cc ('k') | ash/shelf/shelf_view.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698