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

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

Issue 1838833002: Move DisplayLayout and DisplayLayoutBuilder From ash To ui/display (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@screenwinmove
Patch Set: Fix comment Created 4 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 (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/display/screen_position_controller.h" 5 #include "ash/display/screen_position_controller.h"
6 6
7 #include "ash/display/display_manager.h" 7 #include "ash/display/display_manager.h"
8 #include "ash/screen_util.h" 8 #include "ash/screen_util.h"
9 #include "ash/shell.h" 9 #include "ash/shell.h"
10 #include "ash/shell_window_ids.h" 10 #include "ash/shell_window_ids.h"
11 #include "ash/test/ash_test_base.h" 11 #include "ash/test/ash_test_base.h"
12 #include "ash/test/shell_test_api.h" 12 #include "ash/test/shell_test_api.h"
13 #include "ui/aura/env.h" 13 #include "ui/aura/env.h"
14 #include "ui/aura/test/test_window_delegate.h" 14 #include "ui/aura/test/test_window_delegate.h"
15 #include "ui/aura/window_tracker.h" 15 #include "ui/aura/window_tracker.h"
16 #include "ui/aura/window_tree_host.h" 16 #include "ui/aura/window_tree_host.h"
17 #include "ui/base/layout.h" 17 #include "ui/base/layout.h"
18 #include "ui/display/manager/display_layout.h"
18 #include "ui/events/test/event_generator.h" 19 #include "ui/events/test/event_generator.h"
19 #include "ui/gfx/screen.h" 20 #include "ui/gfx/screen.h"
20 21
21 #if defined(OS_WIN) 22 #if defined(OS_WIN)
22 // TODO(scottmg): RootWindow doesn't get resized immediately on Windows 23 // TODO(scottmg): RootWindow doesn't get resized immediately on Windows
23 // Ash. http://crbug.com/247916. 24 // Ash. http://crbug.com/247916.
24 #define MAYBE_ConvertHostPointToScreen DISABLED_ConvertHostPointToScreen 25 #define MAYBE_ConvertHostPointToScreen DISABLED_ConvertHostPointToScreen
25 #define MAYBE_ConvertHostPointToScreenHiDPI DISABLED_ConvertHostPointToScreenHiD PI 26 #define MAYBE_ConvertHostPointToScreenHiDPI DISABLED_ConvertHostPointToScreenHiD PI
26 #define MAYBE_ConvertHostPointToScreenRotate DISABLED_ConvertHostPointToScreenRo tate 27 #define MAYBE_ConvertHostPointToScreenRotate DISABLED_ConvertHostPointToScreenRo tate
27 #define MAYBE_ConvertHostPointToScreenUIScale DISABLED_ConvertHostPointToScreenU IScale 28 #define MAYBE_ConvertHostPointToScreenUIScale DISABLED_ConvertHostPointToScreenU IScale
28 #define MAYBE_ConvertToScreenWhileRemovingSecondaryDisplay \ 29 #define MAYBE_ConvertToScreenWhileRemovingSecondaryDisplay \
29 DISABLED_ConvertToScreenWhileRemovingSecondaryDisplay 30 DISABLED_ConvertToScreenWhileRemovingSecondaryDisplay
30 #else 31 #else
31 #define MAYBE_ConvertHostPointToScreen ConvertHostPointToScreen 32 #define MAYBE_ConvertHostPointToScreen ConvertHostPointToScreen
32 #define MAYBE_ConvertHostPointToScreenHiDPI ConvertHostPointToScreenHiDPI 33 #define MAYBE_ConvertHostPointToScreenHiDPI ConvertHostPointToScreenHiDPI
33 #define MAYBE_ConvertHostPointToScreenRotate ConvertHostPointToScreenRotate 34 #define MAYBE_ConvertHostPointToScreenRotate ConvertHostPointToScreenRotate
34 #define MAYBE_ConvertHostPointToScreenUIScale ConvertHostPointToScreenUIScale 35 #define MAYBE_ConvertHostPointToScreenUIScale ConvertHostPointToScreenUIScale
35 #define MAYBE_ConvertToScreenWhileRemovingSecondaryDisplay \ 36 #define MAYBE_ConvertToScreenWhileRemovingSecondaryDisplay \
36 ConvertToScreenWhileRemovingSecondaryDisplay 37 ConvertToScreenWhileRemovingSecondaryDisplay
37 #endif 38 #endif
38 39
39 namespace ash { 40 namespace ash {
40 namespace test { 41 namespace test {
41 42
42 namespace { 43 namespace {
43 44
44 void SetSecondaryDisplayLayout(DisplayPlacement::Position position) { 45 void SetSecondaryDisplayLayout(display::DisplayPlacement::Position position) {
45 scoped_ptr<DisplayLayout> layout(Shell::GetInstance() 46 scoped_ptr<display::DisplayLayout> layout(Shell::GetInstance()
46 ->display_manager() 47 ->display_manager()
47 ->GetCurrentDisplayLayout() 48 ->GetCurrentDisplayLayout()
48 .Copy()); 49 .Copy());
49 layout->placement_list[0].position = position; 50 layout->placement_list[0].position = position;
50 Shell::GetInstance()->display_manager()->SetLayoutForCurrentDisplays( 51 Shell::GetInstance()->display_manager()->SetLayoutForCurrentDisplays(
51 std::move(layout)); 52 std::move(layout));
52 } 53 }
53 54
54 ScreenPositionController* GetScreenPositionController() { 55 ScreenPositionController* GetScreenPositionController() {
55 ShellTestApi test_api(Shell::GetInstance()); 56 ShellTestApi test_api(Shell::GetInstance());
56 return test_api.screen_position_controller(); 57 return test_api.screen_position_controller();
57 } 58 }
58 59
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
110 root_windows[0]->GetHost()->GetBounds().size().ToString()); 111 root_windows[0]->GetHost()->GetBounds().size().ToString());
111 EXPECT_EQ("100,500", 112 EXPECT_EQ("100,500",
112 root_windows[1]->GetHost()->GetBounds().origin().ToString()); 113 root_windows[1]->GetHost()->GetBounds().origin().ToString());
113 EXPECT_EQ("200x200", 114 EXPECT_EQ("200x200",
114 root_windows[1]->GetHost()->GetBounds().size().ToString()); 115 root_windows[1]->GetHost()->GetBounds().size().ToString());
115 116
116 const gfx::Point window_pos(100, 100); 117 const gfx::Point window_pos(100, 100);
117 window_->SetBoundsInScreen( 118 window_->SetBoundsInScreen(
118 gfx::Rect(window_pos, gfx::Size(100, 100)), 119 gfx::Rect(window_pos, gfx::Size(100, 100)),
119 gfx::Screen::GetScreen()->GetDisplayNearestPoint(window_pos)); 120 gfx::Screen::GetScreen()->GetDisplayNearestPoint(window_pos));
120 SetSecondaryDisplayLayout(DisplayPlacement::RIGHT); 121 SetSecondaryDisplayLayout(display::DisplayPlacement::RIGHT);
121 // The point is on the primary root window. 122 // The point is on the primary root window.
122 EXPECT_EQ("50,50", ConvertHostPointToScreen(50, 50)); 123 EXPECT_EQ("50,50", ConvertHostPointToScreen(50, 50));
123 // The point is out of the all root windows. 124 // The point is out of the all root windows.
124 EXPECT_EQ("250,250", ConvertHostPointToScreen(250, 250)); 125 EXPECT_EQ("250,250", ConvertHostPointToScreen(250, 250));
125 // The point is on the secondary display. 126 // The point is on the secondary display.
126 EXPECT_EQ("250,0", ConvertHostPointToScreen(50, 400)); 127 EXPECT_EQ("250,0", ConvertHostPointToScreen(50, 400));
127 128
128 SetSecondaryDisplayLayout(DisplayPlacement::BOTTOM); 129 SetSecondaryDisplayLayout(display::DisplayPlacement::BOTTOM);
129 // The point is on the primary root window. 130 // The point is on the primary root window.
130 EXPECT_EQ("50,50", ConvertHostPointToScreen(50, 50)); 131 EXPECT_EQ("50,50", ConvertHostPointToScreen(50, 50));
131 // The point is out of the all root windows. 132 // The point is out of the all root windows.
132 EXPECT_EQ("250,250", ConvertHostPointToScreen(250, 250)); 133 EXPECT_EQ("250,250", ConvertHostPointToScreen(250, 250));
133 // The point is on the secondary display. 134 // The point is on the secondary display.
134 EXPECT_EQ("50,200", ConvertHostPointToScreen(50, 400)); 135 EXPECT_EQ("50,200", ConvertHostPointToScreen(50, 400));
135 136
136 SetSecondaryDisplayLayout(DisplayPlacement::LEFT); 137 SetSecondaryDisplayLayout(display::DisplayPlacement::LEFT);
137 // The point is on the primary root window. 138 // The point is on the primary root window.
138 EXPECT_EQ("50,50", ConvertHostPointToScreen(50, 50)); 139 EXPECT_EQ("50,50", ConvertHostPointToScreen(50, 50));
139 // The point is out of the all root windows. 140 // The point is out of the all root windows.
140 EXPECT_EQ("250,250", ConvertHostPointToScreen(250, 250)); 141 EXPECT_EQ("250,250", ConvertHostPointToScreen(250, 250));
141 // The point is on the secondary display. 142 // The point is on the secondary display.
142 EXPECT_EQ("-150,0", ConvertHostPointToScreen(50, 400)); 143 EXPECT_EQ("-150,0", ConvertHostPointToScreen(50, 400));
143 144
144 SetSecondaryDisplayLayout(DisplayPlacement::TOP); 145 SetSecondaryDisplayLayout(display::DisplayPlacement::TOP);
145 // The point is on the primary root window. 146 // The point is on the primary root window.
146 EXPECT_EQ("50,50", ConvertHostPointToScreen(50, 50)); 147 EXPECT_EQ("50,50", ConvertHostPointToScreen(50, 50));
147 // The point is out of the all root windows. 148 // The point is out of the all root windows.
148 EXPECT_EQ("250,250", ConvertHostPointToScreen(250, 250)); 149 EXPECT_EQ("250,250", ConvertHostPointToScreen(250, 250));
149 // The point is on the secondary display. 150 // The point is on the secondary display.
150 EXPECT_EQ("50,-200", ConvertHostPointToScreen(50, 400)); 151 EXPECT_EQ("50,-200", ConvertHostPointToScreen(50, 400));
151 152
152 SetSecondaryDisplayLayout(DisplayPlacement::RIGHT); 153 SetSecondaryDisplayLayout(display::DisplayPlacement::RIGHT);
153 const gfx::Point window_pos2(300, 100); 154 const gfx::Point window_pos2(300, 100);
154 window_->SetBoundsInScreen( 155 window_->SetBoundsInScreen(
155 gfx::Rect(window_pos2, gfx::Size(100, 100)), 156 gfx::Rect(window_pos2, gfx::Size(100, 100)),
156 gfx::Screen::GetScreen()->GetDisplayNearestPoint(window_pos2)); 157 gfx::Screen::GetScreen()->GetDisplayNearestPoint(window_pos2));
157 // The point is on the secondary display. 158 // The point is on the secondary display.
158 EXPECT_EQ("250,50", ConvertHostPointToScreen(50, 50)); 159 EXPECT_EQ("250,50", ConvertHostPointToScreen(50, 50));
159 // The point is out of the all root windows. 160 // The point is out of the all root windows.
160 EXPECT_EQ("450,250", ConvertHostPointToScreen(250, 250)); 161 EXPECT_EQ("450,250", ConvertHostPointToScreen(250, 250));
161 // The point is on the primary root window. 162 // The point is on the primary root window.
162 EXPECT_EQ("50,0", ConvertHostPointToScreen(50, -400)); 163 EXPECT_EQ("50,0", ConvertHostPointToScreen(50, -400));
163 164
164 SetSecondaryDisplayLayout(DisplayPlacement::BOTTOM); 165 SetSecondaryDisplayLayout(display::DisplayPlacement::BOTTOM);
165 // The point is on the secondary display. 166 // The point is on the secondary display.
166 EXPECT_EQ("50,250", ConvertHostPointToScreen(50, 50)); 167 EXPECT_EQ("50,250", ConvertHostPointToScreen(50, 50));
167 // The point is out of the all root windows. 168 // The point is out of the all root windows.
168 EXPECT_EQ("250,450", ConvertHostPointToScreen(250, 250)); 169 EXPECT_EQ("250,450", ConvertHostPointToScreen(250, 250));
169 // The point is on the primary root window. 170 // The point is on the primary root window.
170 EXPECT_EQ("50,0", ConvertHostPointToScreen(50, -400)); 171 EXPECT_EQ("50,0", ConvertHostPointToScreen(50, -400));
171 172
172 SetSecondaryDisplayLayout(DisplayPlacement::LEFT); 173 SetSecondaryDisplayLayout(display::DisplayPlacement::LEFT);
173 // The point is on the secondary display. 174 // The point is on the secondary display.
174 EXPECT_EQ("-150,50", ConvertHostPointToScreen(50, 50)); 175 EXPECT_EQ("-150,50", ConvertHostPointToScreen(50, 50));
175 // The point is out of the all root windows. 176 // The point is out of the all root windows.
176 EXPECT_EQ("50,250", ConvertHostPointToScreen(250, 250)); 177 EXPECT_EQ("50,250", ConvertHostPointToScreen(250, 250));
177 // The point is on the primary root window. 178 // The point is on the primary root window.
178 EXPECT_EQ("50,0", ConvertHostPointToScreen(50, -400)); 179 EXPECT_EQ("50,0", ConvertHostPointToScreen(50, -400));
179 180
180 SetSecondaryDisplayLayout(DisplayPlacement::TOP); 181 SetSecondaryDisplayLayout(display::DisplayPlacement::TOP);
181 // The point is on the secondary display. 182 // The point is on the secondary display.
182 EXPECT_EQ("50,-150", ConvertHostPointToScreen(50, 50)); 183 EXPECT_EQ("50,-150", ConvertHostPointToScreen(50, 50));
183 // The point is out of the all root windows. 184 // The point is out of the all root windows.
184 EXPECT_EQ("250,50", ConvertHostPointToScreen(250, 250)); 185 EXPECT_EQ("250,50", ConvertHostPointToScreen(250, 250));
185 // The point is on the primary root window. 186 // The point is on the primary root window.
186 EXPECT_EQ("50,0", ConvertHostPointToScreen(50, -400)); 187 EXPECT_EQ("50,0", ConvertHostPointToScreen(50, -400));
187 } 188 }
188 189
189 TEST_F(ScreenPositionControllerTest, MAYBE_ConvertHostPointToScreenHiDPI) { 190 TEST_F(ScreenPositionControllerTest, MAYBE_ConvertHostPointToScreenHiDPI) {
190 UpdateDisplay("50+50-200x200*2,50+300-300x300"); 191 UpdateDisplay("50+50-200x200*2,50+300-300x300");
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after
355 // destroyed. 356 // destroyed.
356 EXPECT_FALSE(tracker.Contains(root_windows[1])); 357 EXPECT_FALSE(tracker.Contains(root_windows[1]));
357 358
358 // Check that we could convert all of the mouse events we got to screen 359 // Check that we could convert all of the mouse events we got to screen
359 // coordinates. 360 // coordinates.
360 EXPECT_TRUE(event_handler->could_convert_to_screen()); 361 EXPECT_TRUE(event_handler->could_convert_to_screen());
361 } 362 }
362 363
363 } // namespace test 364 } // namespace test
364 } // namespace ash 365 } // namespace ash
OLDNEW
« no previous file with comments | « ash/display/root_window_transformers_unittest.cc ('k') | ash/display/unified_mouse_warp_controller.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698