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

Side by Side Diff: ash/display/mirror_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
« no previous file with comments | « ash/display/cursor_window_controller_unittest.cc ('k') | ash/drag_drop/drag_drop_controller.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) 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/display/mirror_window_controller.h" 5 #include "ash/display/mirror_window_controller.h"
6 6
7 #include "ash/display/window_tree_host_manager.h" 7 #include "ash/display/window_tree_host_manager.h"
8 #include "ash/shell.h" 8 #include "ash/shell.h"
9 #include "ash/test/ash_test_base.h" 9 #include "ash/test/ash_test_base.h"
10 #include "ash/test/cursor_manager_test_api.h" 10 #include "ash/test/cursor_manager_test_api.h"
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
70 EXPECT_TRUE(test_api.GetCursorWindow()); 70 EXPECT_TRUE(test_api.GetCursorWindow());
71 EXPECT_EQ("50,50 100x100", window->bounds().ToString()); 71 EXPECT_EQ("50,50 100x100", window->bounds().ToString());
72 72
73 ui::test::EventGenerator generator(root); 73 ui::test::EventGenerator generator(root);
74 generator.MoveMouseTo(10, 10); 74 generator.MoveMouseTo(10, 10);
75 75
76 // Test if cursor movement is propertly reflected in mirror window. 76 // Test if cursor movement is propertly reflected in mirror window.
77 EXPECT_EQ("4,4", test_api.GetCursorHotPoint().ToString()); 77 EXPECT_EQ("4,4", test_api.GetCursorHotPoint().ToString());
78 EXPECT_EQ("10,10", 78 EXPECT_EQ("10,10",
79 test_api.GetCursorHotPointLocationInRootWindow().ToString()); 79 test_api.GetCursorHotPointLocationInRootWindow().ToString());
80 EXPECT_EQ(ui::kCursorNull, test_api.GetCurrentCursorType()); 80 EXPECT_EQ(ui::CursorType::kNull, test_api.GetCurrentCursorType());
81 EXPECT_TRUE(test_api.GetCursorWindow()->IsVisible()); 81 EXPECT_TRUE(test_api.GetCursorWindow()->IsVisible());
82 82
83 // Test if cursor type change is propertly reflected in mirror window. 83 // Test if cursor type change is propertly reflected in mirror window.
84 generator.MoveMouseTo(100, 100); 84 generator.MoveMouseTo(100, 100);
85 EXPECT_EQ("100,100", 85 EXPECT_EQ("100,100",
86 test_api.GetCursorHotPointLocationInRootWindow().ToString()); 86 test_api.GetCursorHotPointLocationInRootWindow().ToString());
87 EXPECT_EQ(ui::kCursorNorthResize, test_api.GetCurrentCursorType()); 87 EXPECT_EQ(ui::CursorType::kNorthResize, test_api.GetCurrentCursorType());
88 88
89 // Test if visibility change is propertly reflected in mirror window. 89 // Test if visibility change is propertly reflected in mirror window.
90 // A key event hides cursor. 90 // A key event hides cursor.
91 generator.PressKey(ui::VKEY_A, 0); 91 generator.PressKey(ui::VKEY_A, 0);
92 generator.ReleaseKey(ui::VKEY_A, 0); 92 generator.ReleaseKey(ui::VKEY_A, 0);
93 EXPECT_FALSE(test_api.GetCursorWindow()->IsVisible()); 93 EXPECT_FALSE(test_api.GetCursorWindow()->IsVisible());
94 94
95 // Mouse event makes it visible again. 95 // Mouse event makes it visible again.
96 generator.MoveMouseTo(300, 300); 96 generator.MoveMouseTo(300, 300);
97 EXPECT_EQ("300,300", 97 EXPECT_EQ("300,300",
98 test_api.GetCursorHotPointLocationInRootWindow().ToString()); 98 test_api.GetCursorHotPointLocationInRootWindow().ToString());
99 EXPECT_EQ(ui::kCursorNull, test_api.GetCurrentCursorType()); 99 EXPECT_EQ(ui::CursorType::kNull, test_api.GetCurrentCursorType());
100 EXPECT_TRUE(test_api.GetCursorWindow()->IsVisible()); 100 EXPECT_TRUE(test_api.GetCursorWindow()->IsVisible());
101 } 101 }
102 102
103 TEST_F(MirrorWindowControllerTest, MirrorCursorRotate) { 103 TEST_F(MirrorWindowControllerTest, MirrorCursorRotate) {
104 test::MirrorWindowTestApi test_api; 104 test::MirrorWindowTestApi test_api;
105 aura::test::TestWindowDelegate test_window_delegate; 105 aura::test::TestWindowDelegate test_window_delegate;
106 test_window_delegate.set_window_component(HTTOP); 106 test_window_delegate.set_window_component(HTTOP);
107 107
108 display_manager()->SetMultiDisplayMode(display::DisplayManager::MIRRORING); 108 display_manager()->SetMultiDisplayMode(display::DisplayManager::MIRRORING);
109 UpdateDisplay("400x400,400x400"); 109 UpdateDisplay("400x400,400x400");
110 aura::Window* root = Shell::Get()->GetPrimaryRootWindow(); 110 aura::Window* root = Shell::Get()->GetPrimaryRootWindow();
111 std::unique_ptr<aura::Window> window(aura::test::CreateTestWindowWithDelegate( 111 std::unique_ptr<aura::Window> window(aura::test::CreateTestWindowWithDelegate(
112 &test_window_delegate, 0, gfx::Rect(50, 50, 100, 100), root)); 112 &test_window_delegate, 0, gfx::Rect(50, 50, 100, 100), root));
113 window->Show(); 113 window->Show();
114 window->SetName("foo"); 114 window->SetName("foo");
115 115
116 EXPECT_TRUE(test_api.GetCursorWindow()); 116 EXPECT_TRUE(test_api.GetCursorWindow());
117 EXPECT_EQ("50,50 100x100", window->bounds().ToString()); 117 EXPECT_EQ("50,50 100x100", window->bounds().ToString());
118 118
119 ui::test::EventGenerator generator(root); 119 ui::test::EventGenerator generator(root);
120 generator.MoveMouseToInHost(100, 100); 120 generator.MoveMouseToInHost(100, 100);
121 121
122 // Test if cursor movement is propertly reflected in mirror window. 122 // Test if cursor movement is propertly reflected in mirror window.
123 EXPECT_EQ("11,12", test_api.GetCursorHotPoint().ToString()); 123 EXPECT_EQ("11,12", test_api.GetCursorHotPoint().ToString());
124 EXPECT_EQ("100,100", 124 EXPECT_EQ("100,100",
125 test_api.GetCursorHotPointLocationInRootWindow().ToString()); 125 test_api.GetCursorHotPointLocationInRootWindow().ToString());
126 EXPECT_EQ(ui::kCursorNorthResize, test_api.GetCurrentCursorType()); 126 EXPECT_EQ(ui::CursorType::kNorthResize, test_api.GetCurrentCursorType());
127 127
128 UpdateDisplay("400x400/r,400x400"); // 90 degrees. 128 UpdateDisplay("400x400/r,400x400"); // 90 degrees.
129 generator.MoveMouseToInHost(300, 100); 129 generator.MoveMouseToInHost(300, 100);
130 EXPECT_EQ(ui::kCursorNorthResize, test_api.GetCurrentCursorType()); 130 EXPECT_EQ(ui::CursorType::kNorthResize, test_api.GetCurrentCursorType());
131 // The size of cursor image is 25x25, so the rotated hot point must 131 // The size of cursor image is 25x25, so the rotated hot point must
132 // be (25-12, 11). 132 // be (25-12, 11).
133 EXPECT_EQ("13,11", test_api.GetCursorHotPoint().ToString()); 133 EXPECT_EQ("13,11", test_api.GetCursorHotPoint().ToString());
134 EXPECT_EQ("300,100", 134 EXPECT_EQ("300,100",
135 test_api.GetCursorHotPointLocationInRootWindow().ToString()); 135 test_api.GetCursorHotPointLocationInRootWindow().ToString());
136 136
137 UpdateDisplay("400x400/u,400x400"); // 180 degrees. 137 UpdateDisplay("400x400/u,400x400"); // 180 degrees.
138 generator.MoveMouseToInHost(300, 300); 138 generator.MoveMouseToInHost(300, 300);
139 EXPECT_EQ(ui::kCursorNorthResize, test_api.GetCurrentCursorType()); 139 EXPECT_EQ(ui::CursorType::kNorthResize, test_api.GetCurrentCursorType());
140 // Rotated hot point must be (25-11, 25-12). 140 // Rotated hot point must be (25-11, 25-12).
141 EXPECT_EQ("14,13", test_api.GetCursorHotPoint().ToString()); 141 EXPECT_EQ("14,13", test_api.GetCursorHotPoint().ToString());
142 EXPECT_EQ("300,300", 142 EXPECT_EQ("300,300",
143 test_api.GetCursorHotPointLocationInRootWindow().ToString()); 143 test_api.GetCursorHotPointLocationInRootWindow().ToString());
144 144
145 UpdateDisplay("400x400/l,400x400"); // 270 degrees. 145 UpdateDisplay("400x400/l,400x400"); // 270 degrees.
146 generator.MoveMouseToInHost(100, 300); 146 generator.MoveMouseToInHost(100, 300);
147 EXPECT_EQ(ui::kCursorNorthResize, test_api.GetCurrentCursorType()); 147 EXPECT_EQ(ui::CursorType::kNorthResize, test_api.GetCurrentCursorType());
148 // Rotated hot point must be (12, 25-11). 148 // Rotated hot point must be (12, 25-11).
149 EXPECT_EQ("12,14", test_api.GetCursorHotPoint().ToString()); 149 EXPECT_EQ("12,14", test_api.GetCursorHotPoint().ToString());
150 EXPECT_EQ("100,300", 150 EXPECT_EQ("100,300",
151 test_api.GetCursorHotPointLocationInRootWindow().ToString()); 151 test_api.GetCursorHotPointLocationInRootWindow().ToString());
152 } 152 }
153 153
154 // Make sure that the mirror cursor's location is same as 154 // Make sure that the mirror cursor's location is same as
155 // the source display's host location in the mirror root window's 155 // the source display's host location in the mirror root window's
156 // coordinates. 156 // coordinates.
157 TEST_F(MirrorWindowControllerTest, MirrorCursorLocations) { 157 TEST_F(MirrorWindowControllerTest, MirrorCursorLocations) {
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
218 // because the cursor's previous position is out of bounds. 218 // because the cursor's previous position is out of bounds.
219 // Check real cursor's position and properties. 219 // Check real cursor's position and properties.
220 EXPECT_EQ("100,100", env->last_mouse_location().ToString()); 220 EXPECT_EQ("100,100", env->last_mouse_location().ToString());
221 EXPECT_EQ(2.0f, cursor_test_api.GetCurrentCursor().device_scale_factor()); 221 EXPECT_EQ(2.0f, cursor_test_api.GetCurrentCursor().device_scale_factor());
222 EXPECT_EQ(display::Display::ROTATE_90, 222 EXPECT_EQ(display::Display::ROTATE_90,
223 cursor_test_api.GetCurrentCursorRotation()); 223 cursor_test_api.GetCurrentCursorRotation());
224 224
225 // Check mirrored cursor's location. 225 // Check mirrored cursor's location.
226 test::MirrorWindowTestApi test_api; 226 test::MirrorWindowTestApi test_api;
227 // The hot point location depends on the specific cursor. 227 // The hot point location depends on the specific cursor.
228 EXPECT_EQ(ui::kCursorNull, test_api.GetCurrentCursorType()); 228 EXPECT_EQ(ui::CursorType::kNull, test_api.GetCurrentCursorType());
229 // Rotated hot point must be (25-7, 7). 229 // Rotated hot point must be (25-7, 7).
230 EXPECT_EQ("18,7", test_api.GetCursorHotPoint().ToString()); 230 EXPECT_EQ("18,7", test_api.GetCursorHotPoint().ToString());
231 // New coordinates are not (200,200) because (200,200) is not the center of 231 // New coordinates are not (200,200) because (200,200) is not the center of
232 // the display. 232 // the display.
233 EXPECT_EQ("199,200", 233 EXPECT_EQ("199,200",
234 test_api.GetCursorHotPointLocationInRootWindow().ToString()); 234 test_api.GetCursorHotPointLocationInRootWindow().ToString());
235 } 235 }
236 236
237 // Make sure that the compositor based mirroring can switch 237 // Make sure that the compositor based mirroring can switch
238 // from/to dock mode. 238 // from/to dock mode.
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
281 } 281 }
282 282
283 TEST_F(MirrorOnBootTest, MirrorOnBoot) { 283 TEST_F(MirrorOnBootTest, MirrorOnBoot) {
284 EXPECT_TRUE(display_manager()->IsInMirrorMode()); 284 EXPECT_TRUE(display_manager()->IsInMirrorMode());
285 RunAllPendingInMessageLoop(); 285 RunAllPendingInMessageLoop();
286 test::MirrorWindowTestApi test_api; 286 test::MirrorWindowTestApi test_api;
287 EXPECT_TRUE(test_api.GetHost()); 287 EXPECT_TRUE(test_api.GetHost());
288 } 288 }
289 289
290 } // namespace ash 290 } // namespace ash
OLDNEW
« no previous file with comments | « ash/display/cursor_window_controller_unittest.cc ('k') | ash/drag_drop/drag_drop_controller.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698