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

Side by Side Diff: ash/display/cursor_window_controller_unittest.cc

Issue 2833163002: Change ui cursor identifiers to an enum class. (Closed)
Patch Set: OK, it can't be explicit for mac. 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 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/shell.h" 9 #include "ash/shell.h"
10 #include "ash/test/ash_test_base.h" 10 #include "ash/test/ash_test_base.h"
(...skipping 12 matching lines...) Expand all
23 public: 23 public:
24 CursorWindowControllerTest() {} 24 CursorWindowControllerTest() {}
25 ~CursorWindowControllerTest() override {} 25 ~CursorWindowControllerTest() override {}
26 26
27 // test::AshTestBase: 27 // test::AshTestBase:
28 void SetUp() override { 28 void SetUp() override {
29 AshTestBase::SetUp(); 29 AshTestBase::SetUp();
30 SetCursorCompositionEnabled(true); 30 SetCursorCompositionEnabled(true);
31 } 31 }
32 32
33 int GetCursorType() const { return cursor_window_controller_->cursor_type_; } 33 ui::CursorType GetCursorType() const {
34 return cursor_window_controller_->cursor_type_;
35 }
34 36
35 const gfx::Point& GetCursorHotPoint() const { 37 const gfx::Point& GetCursorHotPoint() const {
36 return cursor_window_controller_->hot_point_; 38 return cursor_window_controller_->hot_point_;
37 } 39 }
38 40
39 aura::Window* GetCursorWindow() const { 41 aura::Window* GetCursorWindow() const {
40 return cursor_window_controller_->cursor_window_.get(); 42 return cursor_window_controller_->cursor_window_.get();
41 } 43 }
42 44
43 const gfx::ImageSkia& GetCursorImage() const { 45 const gfx::ImageSkia& GetCursorImage() const {
(...skipping 29 matching lines...) Expand all
73 aura::Window* primary_root = 75 aura::Window* primary_root =
74 window_tree_host_manager->GetRootWindowForDisplayId(primary_display_id); 76 window_tree_host_manager->GetRootWindowForDisplayId(primary_display_id);
75 aura::Window* secondary_root = 77 aura::Window* secondary_root =
76 window_tree_host_manager->GetRootWindowForDisplayId(secondary_display_id); 78 window_tree_host_manager->GetRootWindowForDisplayId(secondary_display_id);
77 79
78 ui::test::EventGenerator primary_generator(primary_root); 80 ui::test::EventGenerator primary_generator(primary_root);
79 primary_generator.MoveMouseToInHost(20, 50); 81 primary_generator.MoveMouseToInHost(20, 50);
80 82
81 EXPECT_TRUE(primary_root->Contains(GetCursorWindow())); 83 EXPECT_TRUE(primary_root->Contains(GetCursorWindow()));
82 EXPECT_EQ(primary_display_id, GetCursorDisplayId()); 84 EXPECT_EQ(primary_display_id, GetCursorDisplayId());
83 EXPECT_EQ(ui::kCursorNull, GetCursorType()); 85 EXPECT_EQ(ui::CursorType::kNull, GetCursorType());
84 gfx::Point hot_point = GetCursorHotPoint(); 86 gfx::Point hot_point = GetCursorHotPoint();
85 EXPECT_EQ("4,4", hot_point.ToString()); 87 EXPECT_EQ("4,4", hot_point.ToString());
86 gfx::Rect cursor_bounds = GetCursorWindow()->GetBoundsInScreen(); 88 gfx::Rect cursor_bounds = GetCursorWindow()->GetBoundsInScreen();
87 EXPECT_EQ(20, cursor_bounds.x() + hot_point.x()); 89 EXPECT_EQ(20, cursor_bounds.x() + hot_point.x());
88 EXPECT_EQ(50, cursor_bounds.y() + hot_point.y()); 90 EXPECT_EQ(50, cursor_bounds.y() + hot_point.y());
89 91
90 // The cursor can only be moved between displays via 92 // The cursor can only be moved between displays via
91 // WindowTreeHost::MoveCursorTo(). EventGenerator uses a hack to move the 93 // WindowTreeHost::MoveCursorTo(). EventGenerator uses a hack to move the
92 // cursor between displays. 94 // cursor between displays.
93 // Screen location: 220, 50 95 // Screen location: 220, 50
94 // Root location: 20, 50 96 // Root location: 20, 50
95 secondary_root->MoveCursorTo(gfx::Point(20, 50)); 97 secondary_root->MoveCursorTo(gfx::Point(20, 50));
96 98
97 // Chrome relies on WindowTreeHost::MoveCursorTo() dispatching a mouse move 99 // Chrome relies on WindowTreeHost::MoveCursorTo() dispatching a mouse move
98 // asynchronously. This is implemented in a platform specific way. Generate a 100 // asynchronously. This is implemented in a platform specific way. Generate a
99 // fake mouse move instead of waiting. 101 // fake mouse move instead of waiting.
100 gfx::Point new_cursor_position_in_host(20, 50); 102 gfx::Point new_cursor_position_in_host(20, 50);
101 secondary_root->GetHost()->ConvertDIPToPixels(&new_cursor_position_in_host); 103 secondary_root->GetHost()->ConvertDIPToPixels(&new_cursor_position_in_host);
102 ui::test::EventGenerator secondary_generator(secondary_root); 104 ui::test::EventGenerator secondary_generator(secondary_root);
103 secondary_generator.MoveMouseToInHost(new_cursor_position_in_host); 105 secondary_generator.MoveMouseToInHost(new_cursor_position_in_host);
104 106
105 EXPECT_TRUE(secondary_root->Contains(GetCursorWindow())); 107 EXPECT_TRUE(secondary_root->Contains(GetCursorWindow()));
106 EXPECT_EQ(secondary_display_id, GetCursorDisplayId()); 108 EXPECT_EQ(secondary_display_id, GetCursorDisplayId());
107 EXPECT_EQ(ui::kCursorNull, GetCursorType()); 109 EXPECT_EQ(ui::CursorType::kNull, GetCursorType());
108 hot_point = GetCursorHotPoint(); 110 hot_point = GetCursorHotPoint();
109 EXPECT_EQ("3,3", hot_point.ToString()); 111 EXPECT_EQ("3,3", hot_point.ToString());
110 cursor_bounds = GetCursorWindow()->GetBoundsInScreen(); 112 cursor_bounds = GetCursorWindow()->GetBoundsInScreen();
111 EXPECT_EQ(220, cursor_bounds.x() + hot_point.x()); 113 EXPECT_EQ(220, cursor_bounds.x() + hot_point.x());
112 EXPECT_EQ(50, cursor_bounds.y() + hot_point.y()); 114 EXPECT_EQ(50, cursor_bounds.y() + hot_point.y());
113 } 115 }
114 116
115 // Windows doesn't support compositor based cursor. 117 // Windows doesn't support compositor based cursor.
116 #if !defined(OS_WIN) 118 #if !defined(OS_WIN)
117 // Make sure that composition cursor inherits the visibility state. 119 // Make sure that composition cursor inherits the visibility state.
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
163 ASSERT_TRUE(display::test::DisplayManagerTestApi(display_manager()) 165 ASSERT_TRUE(display::test::DisplayManagerTestApi(display_manager())
164 .SetDisplayUIScale(primary_id, 2.0f)); 166 .SetDisplayUIScale(primary_id, 2.0f));
165 ASSERT_EQ( 167 ASSERT_EQ(
166 1.0f, 168 1.0f,
167 display::Screen::GetScreen()->GetPrimaryDisplay().device_scale_factor()); 169 display::Screen::GetScreen()->GetPrimaryDisplay().device_scale_factor());
168 EXPECT_TRUE(GetCursorImage().HasRepresentation(2.0f)); 170 EXPECT_TRUE(GetCursorImage().HasRepresentation(2.0f));
169 } 171 }
170 #endif 172 #endif
171 173
172 } // namespace ash 174 } // namespace ash
OLDNEW
« no previous file with comments | « ash/display/cursor_window_controller.cc ('k') | ash/display/mirror_window_controller_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698