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/wm/system_gesture_event_filter_unittest.cc

Issue 1608053002: Remove now-unnecessary wrappers around gfx::Screen::GetScreen() (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@metro-mode-5
Patch Set: cros Created 4 years, 11 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
« no previous file with comments | « ash/wm/panels/panel_window_resizer.cc ('k') | ash/wm/toplevel_window_event_handler_unittest.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 (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/wm/system_gesture_event_filter.h" 5 #include "ash/wm/system_gesture_event_filter.h"
6 6
7 #include <vector> 7 #include <vector>
8 8
9 #include "ash/accelerators/accelerator_controller.h" 9 #include "ash/accelerators/accelerator_controller.h"
10 #include "ash/display/display_manager.h" 10 #include "ash/display/display_manager.h"
(...skipping 459 matching lines...) Expand 10 before | Expand all | Expand 10 after
470 const int kSteps = 15; 470 const int kSteps = 15;
471 const int kTouchPoints = 2; 471 const int kTouchPoints = 2;
472 gfx::Point points[kTouchPoints] = { 472 gfx::Point points[kTouchPoints] = {
473 gfx::Point(bounds.x() + bounds.width() / 2, bounds.y() + 5), 473 gfx::Point(bounds.x() + bounds.width() / 2, bounds.y() + 5),
474 gfx::Point(bounds.x() + bounds.width() / 2, bounds.y() + 5), 474 gfx::Point(bounds.x() + bounds.width() / 2, bounds.y() + 5),
475 }; 475 };
476 aura::Window* toplevel_window = toplevel->GetNativeWindow(); 476 aura::Window* toplevel_window = toplevel->GetNativeWindow();
477 ui::test::EventGenerator generator(root_window, toplevel_window); 477 ui::test::EventGenerator generator(root_window, toplevel_window);
478 478
479 // Check that dragging left snaps before reaching the screen edge. 479 // Check that dragging left snaps before reaching the screen edge.
480 gfx::Rect work_area = 480 gfx::Rect work_area = gfx::Screen::GetScreen()
481 Shell::GetScreen()->GetDisplayNearestWindow(root_window).work_area(); 481 ->GetDisplayNearestWindow(root_window)
482 .work_area();
482 int drag_x = work_area.x() + 20 - points[0].x(); 483 int drag_x = work_area.x() + 20 - points[0].x();
483 generator.GestureMultiFingerScroll( 484 generator.GestureMultiFingerScroll(
484 kTouchPoints, points, 120, kSteps, drag_x, 0); 485 kTouchPoints, points, 120, kSteps, drag_x, 0);
485 486
486 EXPECT_EQ(wm::GetDefaultLeftSnappedWindowBoundsInParent( 487 EXPECT_EQ(wm::GetDefaultLeftSnappedWindowBoundsInParent(
487 toplevel_window).ToString(), 488 toplevel_window).ToString(),
488 toplevel_window->bounds().ToString()); 489 toplevel_window->bounds().ToString());
489 } 490 }
490 491
491 TEST_F(SystemGestureEventFilterTest, DragRightNearEdgeSnaps) { 492 TEST_F(SystemGestureEventFilterTest, DragRightNearEdgeSnaps) {
492 gfx::Rect bounds(200, 150, 400, 100); 493 gfx::Rect bounds(200, 150, 400, 100);
493 aura::Window* root_window = Shell::GetPrimaryRootWindow(); 494 aura::Window* root_window = Shell::GetPrimaryRootWindow();
494 views::Widget* toplevel = views::Widget::CreateWindowWithContextAndBounds( 495 views::Widget* toplevel = views::Widget::CreateWindowWithContextAndBounds(
495 new ResizableWidgetDelegate, root_window, bounds); 496 new ResizableWidgetDelegate, root_window, bounds);
496 toplevel->Show(); 497 toplevel->Show();
497 498
498 const int kSteps = 15; 499 const int kSteps = 15;
499 const int kTouchPoints = 2; 500 const int kTouchPoints = 2;
500 gfx::Point points[kTouchPoints] = { 501 gfx::Point points[kTouchPoints] = {
501 gfx::Point(bounds.x() + bounds.width() / 2, bounds.y() + 5), 502 gfx::Point(bounds.x() + bounds.width() / 2, bounds.y() + 5),
502 gfx::Point(bounds.x() + bounds.width() / 2, bounds.y() + 5), 503 gfx::Point(bounds.x() + bounds.width() / 2, bounds.y() + 5),
503 }; 504 };
504 aura::Window* toplevel_window = toplevel->GetNativeWindow(); 505 aura::Window* toplevel_window = toplevel->GetNativeWindow();
505 ui::test::EventGenerator generator(root_window, toplevel_window); 506 ui::test::EventGenerator generator(root_window, toplevel_window);
506 507
507 // Check that dragging right snaps before reaching the screen edge. 508 // Check that dragging right snaps before reaching the screen edge.
508 gfx::Rect work_area = 509 gfx::Rect work_area = gfx::Screen::GetScreen()
509 Shell::GetScreen()->GetDisplayNearestWindow(root_window).work_area(); 510 ->GetDisplayNearestWindow(root_window)
511 .work_area();
510 int drag_x = work_area.right() - 20 - points[0].x(); 512 int drag_x = work_area.right() - 20 - points[0].x();
511 generator.GestureMultiFingerScroll( 513 generator.GestureMultiFingerScroll(
512 kTouchPoints, points, 120, kSteps, drag_x, 0); 514 kTouchPoints, points, 120, kSteps, drag_x, 0);
513 EXPECT_EQ(wm::GetDefaultRightSnappedWindowBoundsInParent( 515 EXPECT_EQ(wm::GetDefaultRightSnappedWindowBoundsInParent(
514 toplevel_window).ToString(), 516 toplevel_window).ToString(),
515 toplevel_window->bounds().ToString()); 517 toplevel_window->bounds().ToString());
516 } 518 }
517 519
518 // Tests that the window manager does not consume gesture events targeted to 520 // Tests that the window manager does not consume gesture events targeted to
519 // windows of type WINDOW_TYPE_CONTROL. This is important because the web 521 // windows of type WINDOW_TYPE_CONTROL. This is important because the web
(...skipping 21 matching lines...) Expand all
541 for (int i = 1; i <= 3; ++i) 543 for (int i = 1; i <= 3; ++i)
542 GetEventGenerator().ReleaseTouchId(i); 544 GetEventGenerator().ReleaseTouchId(i);
543 EXPECT_EQ(event_handler.num_gesture_events(), 545 EXPECT_EQ(event_handler.num_gesture_events(),
544 delegate.GetGestureCountAndReset()); 546 delegate.GetGestureCountAndReset());
545 547
546 aura::Env::GetInstance()->RemovePreTargetHandler(&event_handler); 548 aura::Env::GetInstance()->RemovePreTargetHandler(&event_handler);
547 } 549 }
548 550
549 } // namespace test 551 } // namespace test
550 } // namespace ash 552 } // namespace ash
OLDNEW
« no previous file with comments | « ash/wm/panels/panel_window_resizer.cc ('k') | ash/wm/toplevel_window_event_handler_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698