OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 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 | 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/display/cursor_window_controller.h" | 5 #include "ash/display/cursor_window_controller.h" |
6 | 6 |
7 #include "ash/display/display_util.h" | 7 #include "ash/display/display_util.h" |
8 #include "ash/display/window_tree_host_manager.h" | 8 #include "ash/display/window_tree_host_manager.h" |
9 #include "ash/screen_util.h" | 9 #include "ash/screen_util.h" |
10 #include "ash/shell.h" | 10 #include "ash/shell.h" |
(...skipping 26 matching lines...) Expand all Loading... |
37 } | 37 } |
38 | 38 |
39 aura::Window* GetCursorWindow() const { | 39 aura::Window* GetCursorWindow() const { |
40 return cursor_window_controller_->cursor_window_.get(); | 40 return cursor_window_controller_->cursor_window_.get(); |
41 } | 41 } |
42 | 42 |
43 const gfx::ImageSkia& GetCursorImage() const { | 43 const gfx::ImageSkia& GetCursorImage() const { |
44 return cursor_window_controller_->GetCursorImageForTest(); | 44 return cursor_window_controller_->GetCursorImageForTest(); |
45 } | 45 } |
46 | 46 |
47 int64 GetCursorDisplayId() const { | 47 int64_t GetCursorDisplayId() const { |
48 return cursor_window_controller_->display_.id(); | 48 return cursor_window_controller_->display_.id(); |
49 } | 49 } |
50 | 50 |
51 void SetCursorCompositionEnabled(bool enabled) { | 51 void SetCursorCompositionEnabled(bool enabled) { |
52 cursor_window_controller_ = Shell::GetInstance() | 52 cursor_window_controller_ = Shell::GetInstance() |
53 ->window_tree_host_manager() | 53 ->window_tree_host_manager() |
54 ->cursor_window_controller(); | 54 ->cursor_window_controller(); |
55 cursor_window_controller_->SetCursorCompositingEnabled(enabled); | 55 cursor_window_controller_->SetCursorCompositingEnabled(enabled); |
56 } | 56 } |
57 | 57 |
58 private: | 58 private: |
59 // Not owned. | 59 // Not owned. |
60 CursorWindowController* cursor_window_controller_; | 60 CursorWindowController* cursor_window_controller_; |
61 | 61 |
62 DISALLOW_COPY_AND_ASSIGN(CursorWindowControllerTest); | 62 DISALLOW_COPY_AND_ASSIGN(CursorWindowControllerTest); |
63 }; | 63 }; |
64 | 64 |
65 // Test that the composited cursor moves to another display when the real cursor | 65 // Test that the composited cursor moves to another display when the real cursor |
66 // moves to another display. | 66 // moves to another display. |
67 TEST_F(CursorWindowControllerTest, MoveToDifferentDisplay) { | 67 TEST_F(CursorWindowControllerTest, MoveToDifferentDisplay) { |
68 if (!SupportsMultipleDisplays()) | 68 if (!SupportsMultipleDisplays()) |
69 return; | 69 return; |
70 | 70 |
71 UpdateDisplay("200x200,200x200*2/r"); | 71 UpdateDisplay("200x200,200x200*2/r"); |
72 | 72 |
73 WindowTreeHostManager* window_tree_host_manager = | 73 WindowTreeHostManager* window_tree_host_manager = |
74 Shell::GetInstance()->window_tree_host_manager(); | 74 Shell::GetInstance()->window_tree_host_manager(); |
75 int64 primary_display_id = window_tree_host_manager->GetPrimaryDisplayId(); | 75 int64_t primary_display_id = window_tree_host_manager->GetPrimaryDisplayId(); |
76 int64 secondary_display_id = ScreenUtil::GetSecondaryDisplay().id(); | 76 int64_t secondary_display_id = ScreenUtil::GetSecondaryDisplay().id(); |
77 aura::Window* primary_root = | 77 aura::Window* primary_root = |
78 window_tree_host_manager->GetRootWindowForDisplayId(primary_display_id); | 78 window_tree_host_manager->GetRootWindowForDisplayId(primary_display_id); |
79 aura::Window* secondary_root = | 79 aura::Window* secondary_root = |
80 window_tree_host_manager->GetRootWindowForDisplayId(secondary_display_id); | 80 window_tree_host_manager->GetRootWindowForDisplayId(secondary_display_id); |
81 | 81 |
82 ui::test::EventGenerator primary_generator(primary_root); | 82 ui::test::EventGenerator primary_generator(primary_root); |
83 primary_generator.MoveMouseToInHost(20, 50); | 83 primary_generator.MoveMouseToInHost(20, 50); |
84 | 84 |
85 EXPECT_TRUE(primary_root->Contains(GetCursorWindow())); | 85 EXPECT_TRUE(primary_root->Contains(GetCursorWindow())); |
86 EXPECT_EQ(primary_display_id, GetCursorDisplayId()); | 86 EXPECT_EQ(primary_display_id, GetCursorDisplayId()); |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
147 // Cursor was shown. | 147 // Cursor was shown. |
148 SetCursorCompositionEnabled(true); | 148 SetCursorCompositionEnabled(true); |
149 ASSERT_TRUE(GetCursorWindow()); | 149 ASSERT_TRUE(GetCursorWindow()); |
150 EXPECT_TRUE(GetCursorWindow()->IsVisible()); | 150 EXPECT_TRUE(GetCursorWindow()->IsVisible()); |
151 } | 151 } |
152 | 152 |
153 // Make sure that composition cursor stays big even when | 153 // Make sure that composition cursor stays big even when |
154 // the DSF becomes 1x as a result of zooming out. | 154 // the DSF becomes 1x as a result of zooming out. |
155 TEST_F(CursorWindowControllerTest, DSF) { | 155 TEST_F(CursorWindowControllerTest, DSF) { |
156 UpdateDisplay("1000x500*2"); | 156 UpdateDisplay("1000x500*2"); |
157 int64 primary_id = Shell::GetScreen()->GetPrimaryDisplay().id(); | 157 int64_t primary_id = Shell::GetScreen()->GetPrimaryDisplay().id(); |
158 | 158 |
159 test::ScopedSetInternalDisplayId set_internal(primary_id); | 159 test::ScopedSetInternalDisplayId set_internal(primary_id); |
160 SetCursorCompositionEnabled(true); | 160 SetCursorCompositionEnabled(true); |
161 ASSERT_EQ(2.0f, | 161 ASSERT_EQ(2.0f, |
162 Shell::GetScreen()->GetPrimaryDisplay().device_scale_factor()); | 162 Shell::GetScreen()->GetPrimaryDisplay().device_scale_factor()); |
163 EXPECT_TRUE(GetCursorImage().HasRepresentation(2.0f)); | 163 EXPECT_TRUE(GetCursorImage().HasRepresentation(2.0f)); |
164 | 164 |
165 ASSERT_TRUE(SetDisplayUIScale(primary_id, 2.0f)); | 165 ASSERT_TRUE(SetDisplayUIScale(primary_id, 2.0f)); |
166 ASSERT_EQ(1.0f, | 166 ASSERT_EQ(1.0f, |
167 Shell::GetScreen()->GetPrimaryDisplay().device_scale_factor()); | 167 Shell::GetScreen()->GetPrimaryDisplay().device_scale_factor()); |
168 EXPECT_TRUE(GetCursorImage().HasRepresentation(2.0f)); | 168 EXPECT_TRUE(GetCursorImage().HasRepresentation(2.0f)); |
169 } | 169 } |
170 #endif | 170 #endif |
171 | 171 |
172 } // namespace ash | 172 } // namespace ash |
OLD | NEW |