Restrict use of hardware-secure codecs based on the RendererPreference.
[chromium-blink-merge.git] / ash / display / unified_mouse_warp_controller_unittest.cc
blob1dfa168ee2df865b1513e542c240840906ac3c8d
1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "ash/display/unified_mouse_warp_controller.h"
7 #include "ash/display/display_layout_store.h"
8 #include "ash/display/display_manager.h"
9 #include "ash/display/mouse_cursor_event_filter.h"
10 #include "ash/shell.h"
11 #include "ash/test/ash_test_base.h"
12 #include "ash/test/display_manager_test_api.h"
13 #include "ui/aura/env.h"
14 #include "ui/events/test/event_generator.h"
15 #include "ui/gfx/display.h"
16 #include "ui/gfx/screen.h"
18 namespace ash {
20 class UnifiedMouseWarpControllerTest : public test::AshTestBase {
21 public:
22 UnifiedMouseWarpControllerTest() {}
23 ~UnifiedMouseWarpControllerTest() override {}
25 void SetUp() override {
26 test::AshTestBase::SetUp();
27 DisplayManager* display_manager = Shell::GetInstance()->display_manager();
28 display_manager->SetDefaultMultiDisplayMode(DisplayManager::UNIFIED);
29 display_manager->SetMultiDisplayMode(DisplayManager::UNIFIED);
32 protected:
33 bool TestIfMouseWarpsAt(const gfx::Point& point_in_screen) {
34 return test::DisplayManagerTestApi::TestIfMouseWarpsAt(GetEventGenerator(),
35 point_in_screen);
38 MouseCursorEventFilter* event_filter() {
39 return Shell::GetInstance()->mouse_cursor_filter();
42 UnifiedMouseWarpController* mouse_warp_controller() {
43 return static_cast<UnifiedMouseWarpController*>(
44 event_filter()->mouse_warp_controller_for_test());
47 private:
48 DISALLOW_COPY_AND_ASSIGN(UnifiedMouseWarpControllerTest);
51 // Verifies if MouseCursorEventFilter's bounds calculation works correctly.
52 TEST_F(UnifiedMouseWarpControllerTest, BoundaryTest) {
53 if (!SupportsMultipleDisplays())
54 return;
56 UpdateDisplay("400x400,0+450-700x500");
57 aura::Window::Windows root_windows = Shell::GetAllRootWindows();
58 // Let the UnifiedMouseWarpController compute the bounds by
59 // generating a mouse move event.
60 GetEventGenerator().MoveMouseTo(gfx::Point(0, 0));
62 EXPECT_EQ("399,0 1x400",
63 mouse_warp_controller()->first_edge_bounds_in_native_.ToString());
64 EXPECT_EQ("0,450 1x400",
65 mouse_warp_controller()->second_edge_bounds_in_native_.ToString());
68 // Verifies if the mouse pointer correctly moves to another display in
69 // unified desktop mode.
70 TEST_F(UnifiedMouseWarpControllerTest, WarpMouse) {
71 if (!SupportsMultipleDisplays())
72 return;
74 UpdateDisplay("500x500,500x500");
75 ASSERT_EQ(1, gfx::Screen::GetScreenFor(Shell::GetPrimaryRootWindow())
76 ->GetNumDisplays());
78 EXPECT_FALSE(TestIfMouseWarpsAt(gfx::Point(11, 11)));
80 // Touch the right edge of the first display. Pointer should warp.
81 EXPECT_TRUE(TestIfMouseWarpsAt(gfx::Point(499, 11)));
82 EXPECT_EQ("501,11", // by 2px.
83 aura::Env::GetInstance()->last_mouse_location().ToString());
85 // Touch the left edge of the second display. Pointer should warp.
86 EXPECT_TRUE(TestIfMouseWarpsAt(gfx::Point(500, 11)));
87 EXPECT_EQ("498,11", // by 2px.
88 aura::Env::GetInstance()->last_mouse_location().ToString());
90 // Touch the left edge of the first display.
91 EXPECT_FALSE(TestIfMouseWarpsAt(gfx::Point(0, 11)));
92 // Touch the top edge of the first display.
93 EXPECT_FALSE(TestIfMouseWarpsAt(gfx::Point(11, 0)));
94 // Touch the bottom edge of the first display.
95 EXPECT_FALSE(TestIfMouseWarpsAt(gfx::Point(11, 499)));
96 // Touch the right edge of the second display.
97 EXPECT_FALSE(TestIfMouseWarpsAt(gfx::Point(999, 11)));
98 // Touch the top edge of the second display.
99 EXPECT_FALSE(TestIfMouseWarpsAt(gfx::Point(11, 0)));
100 // Touch the bottom edge of the second display.
101 EXPECT_FALSE(TestIfMouseWarpsAt(gfx::Point(11, 499)));
104 } // namespace aura