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

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

Issue 2786693002: Add PointerDetails to ui::MouseEvent's constructors (Closed)
Patch Set: mouse event constructor Created 3 years, 8 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 (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 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/common/shelf/shelf_widget.h" 5 #include "ash/common/shelf/shelf_widget.h"
6 6
7 #include "ash/common/shelf/shelf_constants.h" 7 #include "ash/common/shelf/shelf_constants.h"
8 #include "ash/common/shelf/shelf_layout_manager.h" 8 #include "ash/common/shelf/shelf_layout_manager.h"
9 #include "ash/common/shelf/shelf_view.h" 9 #include "ash/common/shelf/shelf_view.h"
10 #include "ash/common/shelf/wm_shelf.h" 10 #include "ash/common/shelf/wm_shelf.h"
(...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after
215 EXPECT_TRUE(widget_bounds.Intersects(shelf_bounds)); 215 EXPECT_TRUE(widget_bounds.Intersects(shelf_bounds));
216 216
217 aura::Window* root = widget->GetNativeWindow()->GetRootWindow(); 217 aura::Window* root = widget->GetNativeWindow()->GetRootWindow();
218 ui::EventTargeter* targeter = 218 ui::EventTargeter* targeter =
219 root->GetHost()->dispatcher()->GetDefaultEventTargeter(); 219 root->GetHost()->dispatcher()->GetDefaultEventTargeter();
220 { 220 {
221 // Create a mouse-event targeting the top of the shelf widget. The 221 // Create a mouse-event targeting the top of the shelf widget. The
222 // window-targeter should find |widget| as the target (instead of the 222 // window-targeter should find |widget| as the target (instead of the
223 // shelf). 223 // shelf).
224 gfx::Point event_location(widget_bounds.x() + 5, shelf_bounds.y() + 1); 224 gfx::Point event_location(widget_bounds.x() + 5, shelf_bounds.y() + 1);
225 ui::MouseEvent mouse(ui::ET_MOUSE_MOVED, event_location, event_location, 225 ui::MouseEvent mouse(
226 ui::EventTimeForNow(), ui::EF_NONE, ui::EF_NONE); 226 ui::ET_MOUSE_MOVED, event_location, event_location,
227 ui::EventTimeForNow(), ui::EF_NONE, ui::EF_NONE,
228 ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_MOUSE));
227 ui::EventTarget* target = targeter->FindTargetForEvent(root, &mouse); 229 ui::EventTarget* target = targeter->FindTargetForEvent(root, &mouse);
228 EXPECT_EQ(widget->GetNativeWindow(), target); 230 EXPECT_EQ(widget->GetNativeWindow(), target);
229 } 231 }
230 232
231 // Change shelf alignment to verify that the targeter insets are updated. 233 // Change shelf alignment to verify that the targeter insets are updated.
232 WmShelf* shelf = GetPrimaryShelf(); 234 WmShelf* shelf = GetPrimaryShelf();
233 shelf->SetAlignment(SHELF_ALIGNMENT_LEFT); 235 shelf->SetAlignment(SHELF_ALIGNMENT_LEFT);
234 shelf_layout_manager->LayoutShelf(); 236 shelf_layout_manager->LayoutShelf();
235 shelf_bounds = shelf_widget->GetWindowBoundsInScreen(); 237 shelf_bounds = shelf_widget->GetWindowBoundsInScreen();
236 { 238 {
237 // Create a mouse-event targeting the right edge of the shelf widget. The 239 // Create a mouse-event targeting the right edge of the shelf widget. The
238 // window-targeter should find |widget| as the target (instead of the 240 // window-targeter should find |widget| as the target (instead of the
239 // shelf). 241 // shelf).
240 gfx::Point event_location(shelf_bounds.right() - 1, widget_bounds.y() + 5); 242 gfx::Point event_location(shelf_bounds.right() - 1, widget_bounds.y() + 5);
241 ui::MouseEvent mouse(ui::ET_MOUSE_MOVED, event_location, event_location, 243 ui::MouseEvent mouse(
242 ui::EventTimeForNow(), ui::EF_NONE, ui::EF_NONE); 244 ui::ET_MOUSE_MOVED, event_location, event_location,
245 ui::EventTimeForNow(), ui::EF_NONE, ui::EF_NONE,
246 ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_MOUSE));
243 ui::EventTarget* target = targeter->FindTargetForEvent(root, &mouse); 247 ui::EventTarget* target = targeter->FindTargetForEvent(root, &mouse);
244 EXPECT_EQ(widget->GetNativeWindow(), target); 248 EXPECT_EQ(widget->GetNativeWindow(), target);
245 } 249 }
246 250
247 // Now restore shelf alignment (bottom) and auto-hide (hidden) the shelf. 251 // Now restore shelf alignment (bottom) and auto-hide (hidden) the shelf.
248 shelf->SetAlignment(SHELF_ALIGNMENT_BOTTOM); 252 shelf->SetAlignment(SHELF_ALIGNMENT_BOTTOM);
249 shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS); 253 shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS);
250 shelf_layout_manager->LayoutShelf(); 254 shelf_layout_manager->LayoutShelf();
251 EXPECT_EQ(SHELF_AUTO_HIDE, shelf_layout_manager->visibility_state()); 255 EXPECT_EQ(SHELF_AUTO_HIDE, shelf_layout_manager->visibility_state());
252 EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, shelf_layout_manager->auto_hide_state()); 256 EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, shelf_layout_manager->auto_hide_state());
253 shelf_bounds = shelf_widget->GetWindowBoundsInScreen(); 257 shelf_bounds = shelf_widget->GetWindowBoundsInScreen();
254 EXPECT_TRUE(!shelf_bounds.IsEmpty()); 258 EXPECT_TRUE(!shelf_bounds.IsEmpty());
255 259
256 // Move |widget| so it still overlaps the shelf. 260 // Move |widget| so it still overlaps the shelf.
257 widget->SetBounds(gfx::Rect(0, 261 widget->SetBounds(gfx::Rect(0,
258 shelf_bounds.y() - kWindowHeight + kOverlapSize, 262 shelf_bounds.y() - kWindowHeight + kOverlapSize,
259 kWindowWidth, kWindowHeight)); 263 kWindowWidth, kWindowHeight));
260 widget_bounds = widget->GetWindowBoundsInScreen(); 264 widget_bounds = widget->GetWindowBoundsInScreen();
261 EXPECT_TRUE(widget_bounds.Intersects(shelf_bounds)); 265 EXPECT_TRUE(widget_bounds.Intersects(shelf_bounds));
262 { 266 {
263 // Create a mouse-event targeting the top of the shelf widget. This time, 267 // Create a mouse-event targeting the top of the shelf widget. This time,
264 // window-target should find the shelf as the target. 268 // window-target should find the shelf as the target.
265 gfx::Point event_location(widget_bounds.x() + 5, shelf_bounds.y() + 1); 269 gfx::Point event_location(widget_bounds.x() + 5, shelf_bounds.y() + 1);
266 ui::MouseEvent mouse(ui::ET_MOUSE_MOVED, event_location, event_location, 270 ui::MouseEvent mouse(
267 ui::EventTimeForNow(), ui::EF_NONE, ui::EF_NONE); 271 ui::ET_MOUSE_MOVED, event_location, event_location,
272 ui::EventTimeForNow(), ui::EF_NONE, ui::EF_NONE,
273 ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_MOUSE));
268 ui::EventTarget* target = targeter->FindTargetForEvent(root, &mouse); 274 ui::EventTarget* target = targeter->FindTargetForEvent(root, &mouse);
269 EXPECT_EQ(shelf_widget->GetNativeWindow(), target); 275 EXPECT_EQ(shelf_widget->GetNativeWindow(), target);
270 } 276 }
271 } 277 }
272 278
273 // Tests that the shelf has a slightly larger hit-region for touch-events when 279 // Tests that the shelf has a slightly larger hit-region for touch-events when
274 // it's in the auto-hidden state. 280 // it's in the auto-hidden state.
275 TEST_F(ShelfWidgetTest, HiddenShelfHitTestTouch) { 281 TEST_F(ShelfWidgetTest, HiddenShelfHitTestTouch) {
276 WmShelf* shelf = GetPrimaryShelf(); 282 WmShelf* shelf = GetPrimaryShelf();
277 ShelfWidget* shelf_widget = GetShelfWidget(); 283 ShelfWidget* shelf_widget = GetShelfWidget();
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after
412 } 418 }
413 419
414 TEST_F(ShelfWidgetTestWithInitializer, CreateLockedShelf) { 420 TEST_F(ShelfWidgetTestWithInitializer, CreateLockedShelf) {
415 // The auto hide state 'HIDDEN' is returned for any non-auto-hide behavior. 421 // The auto hide state 'HIDDEN' is returned for any non-auto-hide behavior.
416 TestCreateShelfWithInitialValues(SHELF_ALIGNMENT_BOTTOM_LOCKED, 422 TestCreateShelfWithInitialValues(SHELF_ALIGNMENT_BOTTOM_LOCKED,
417 SHELF_AUTO_HIDE_BEHAVIOR_NEVER, 423 SHELF_AUTO_HIDE_BEHAVIOR_NEVER,
418 SHELF_VISIBLE, SHELF_AUTO_HIDE_HIDDEN); 424 SHELF_VISIBLE, SHELF_AUTO_HIDE_HIDDEN);
419 } 425 }
420 426
421 } // namespace ash 427 } // namespace ash
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698