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

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

Issue 289583002: Lock rotation when screen is manually rotated. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Define sources for rotation Created 6 years, 7 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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 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/root_window_transformers.h" 5 #include "ash/display/root_window_transformers.h"
6 6
7 #include "ash/display/display_info.h" 7 #include "ash/display/display_info.h"
8 #include "ash/display/display_manager.h" 8 #include "ash/display/display_manager.h"
9 #include "ash/host/root_window_transformer.h" 9 #include "ash/host/root_window_transformer.h"
10 #include "ash/magnifier/magnification_controller.h" 10 #include "ash/magnifier/magnification_controller.h"
11 #include "ash/screen_util.h" 11 #include "ash/screen_util.h"
12 #include "ash/shelf/shelf.h" 12 #include "ash/shelf/shelf.h"
13 #include "ash/shelf/shelf_widget.h" 13 #include "ash/shelf/shelf_widget.h"
14 #include "ash/shell.h" 14 #include "ash/shell.h"
15 #include "ash/test/ash_test_base.h" 15 #include "ash/test/ash_test_base.h"
16 #include "ash/test/cursor_manager_test_api.h" 16 #include "ash/test/cursor_manager_test_api.h"
17 #include "ash/test/mirror_window_test_api.h" 17 #include "ash/test/mirror_window_test_api.h"
18 #include "base/synchronization/waitable_event.h" 18 #include "base/synchronization/waitable_event.h"
19 #include "ui/aura/env.h" 19 #include "ui/aura/env.h"
20 #include "ui/aura/test/event_generator.h" 20 #include "ui/aura/test/event_generator.h"
21 #include "ui/aura/window_event_dispatcher.h" 21 #include "ui/aura/window_event_dispatcher.h"
22 #include "ui/aura/window_tracker.h" 22 #include "ui/aura/window_tracker.h"
23 #include "ui/display/types/display_constants.h"
23 #include "ui/events/event_handler.h" 24 #include "ui/events/event_handler.h"
24 #include "ui/gfx/display.h" 25 #include "ui/gfx/display.h"
25 #include "ui/gfx/rect_conversions.h" 26 #include "ui/gfx/rect_conversions.h"
26 #include "ui/gfx/screen.h" 27 #include "ui/gfx/screen.h"
27 #include "ui/views/widget/widget.h" 28 #include "ui/views/widget/widget.h"
28 29
29 namespace ash { 30 namespace ash {
30 namespace { 31 namespace {
31 32
32 const char kDesktopBackgroundView[] = "DesktopBackgroundView"; 33 const char kDesktopBackgroundView[] = "DesktopBackgroundView";
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after
155 ScreenUtil::GetSecondaryDisplay().bounds().ToString()); 156 ScreenUtil::GetSecondaryDisplay().bounds().ToString());
156 generator1.MoveMouseToInHost(40, 80); 157 generator1.MoveMouseToInHost(40, 80);
157 EXPECT_EQ("50,90", event_handler.GetLocationAndReset()); 158 EXPECT_EQ("50,90", event_handler.GetLocationAndReset());
158 EXPECT_EQ("50,90", 159 EXPECT_EQ("50,90",
159 aura::Env::GetInstance()->last_mouse_location().ToString()); 160 aura::Env::GetInstance()->last_mouse_location().ToString());
160 EXPECT_EQ(gfx::Display::ROTATE_0, GetStoredRotation(display1.id())); 161 EXPECT_EQ(gfx::Display::ROTATE_0, GetStoredRotation(display1.id()));
161 EXPECT_EQ(gfx::Display::ROTATE_0, GetStoredRotation(display2_id)); 162 EXPECT_EQ(gfx::Display::ROTATE_0, GetStoredRotation(display2_id));
162 magnifier->SetEnabled(false); 163 magnifier->SetEnabled(false);
163 164
164 display_manager->SetDisplayRotation(display1.id(), 165 display_manager->SetDisplayRotation(display1.id(),
165 gfx::Display::ROTATE_90); 166 gfx::Display::ROTATE_90,
167 ui::USER);
166 // Move the cursor to the center of the first root window. 168 // Move the cursor to the center of the first root window.
167 generator1.MoveMouseToInHost(59, 100); 169 generator1.MoveMouseToInHost(59, 100);
168 170
169 magnifier->SetEnabled(true); 171 magnifier->SetEnabled(true);
170 EXPECT_EQ(2.0f, magnifier->GetScale()); 172 EXPECT_EQ(2.0f, magnifier->GetScale());
171 EXPECT_EQ("200x120", root_windows[0]->bounds().size().ToString()); 173 EXPECT_EQ("200x120", root_windows[0]->bounds().size().ToString());
172 EXPECT_EQ("150x200", root_windows[1]->bounds().size().ToString()); 174 EXPECT_EQ("150x200", root_windows[1]->bounds().size().ToString());
173 EXPECT_EQ("200,0 150x200", 175 EXPECT_EQ("200,0 150x200",
174 ScreenUtil::GetSecondaryDisplay().bounds().ToString()); 176 ScreenUtil::GetSecondaryDisplay().bounds().ToString());
175 generator1.MoveMouseToInHost(39, 120); 177 generator1.MoveMouseToInHost(39, 120);
176 EXPECT_EQ("110,70", event_handler.GetLocationAndReset()); 178 EXPECT_EQ("110,70", event_handler.GetLocationAndReset());
177 EXPECT_EQ("110,70", 179 EXPECT_EQ("110,70",
178 aura::Env::GetInstance()->last_mouse_location().ToString()); 180 aura::Env::GetInstance()->last_mouse_location().ToString());
179 EXPECT_EQ(gfx::Display::ROTATE_90, GetStoredRotation(display1.id())); 181 EXPECT_EQ(gfx::Display::ROTATE_90, GetStoredRotation(display1.id()));
180 EXPECT_EQ(gfx::Display::ROTATE_0, GetStoredRotation(display2_id)); 182 EXPECT_EQ(gfx::Display::ROTATE_0, GetStoredRotation(display2_id));
181 magnifier->SetEnabled(false); 183 magnifier->SetEnabled(false);
182 184
183 DisplayLayout display_layout(DisplayLayout::BOTTOM, 50); 185 DisplayLayout display_layout(DisplayLayout::BOTTOM, 50);
184 display_manager->SetLayoutForCurrentDisplays(display_layout); 186 display_manager->SetLayoutForCurrentDisplays(display_layout);
185 EXPECT_EQ("50,120 150x200", 187 EXPECT_EQ("50,120 150x200",
186 ScreenUtil::GetSecondaryDisplay().bounds().ToString()); 188 ScreenUtil::GetSecondaryDisplay().bounds().ToString());
187 189
188 display_manager->SetDisplayRotation(display2_id, 190 display_manager->SetDisplayRotation(display2_id,
189 gfx::Display::ROTATE_270); 191 gfx::Display::ROTATE_270,
192 ui::USER);
190 // Move the cursor to the center of the second root window. 193 // Move the cursor to the center of the second root window.
191 generator2.MoveMouseToInHost(151, 199); 194 generator2.MoveMouseToInHost(151, 199);
192 195
193 magnifier->SetEnabled(true); 196 magnifier->SetEnabled(true);
194 EXPECT_EQ("200x120", root_windows[0]->bounds().size().ToString()); 197 EXPECT_EQ("200x120", root_windows[0]->bounds().size().ToString());
195 EXPECT_EQ("200x150", root_windows[1]->bounds().size().ToString()); 198 EXPECT_EQ("200x150", root_windows[1]->bounds().size().ToString());
196 EXPECT_EQ("50,120 200x150", 199 EXPECT_EQ("50,120 200x150",
197 ScreenUtil::GetSecondaryDisplay().bounds().ToString()); 200 ScreenUtil::GetSecondaryDisplay().bounds().ToString());
198 generator2.MoveMouseToInHost(172, 219); 201 generator2.MoveMouseToInHost(172, 219);
199 EXPECT_EQ("95,80", event_handler.GetLocationAndReset()); 202 EXPECT_EQ("95,80", event_handler.GetLocationAndReset());
200 EXPECT_EQ("145,200", 203 EXPECT_EQ("145,200",
201 aura::Env::GetInstance()->last_mouse_location().ToString()); 204 aura::Env::GetInstance()->last_mouse_location().ToString());
202 EXPECT_EQ(gfx::Display::ROTATE_90, GetStoredRotation(display1.id())); 205 EXPECT_EQ(gfx::Display::ROTATE_90, GetStoredRotation(display1.id()));
203 EXPECT_EQ(gfx::Display::ROTATE_270, GetStoredRotation(display2_id)); 206 EXPECT_EQ(gfx::Display::ROTATE_270, GetStoredRotation(display2_id));
204 magnifier->SetEnabled(false); 207 magnifier->SetEnabled(false);
205 208
206 display_manager->SetDisplayRotation(display1.id(), 209 display_manager->SetDisplayRotation(display1.id(),
207 gfx::Display::ROTATE_180); 210 gfx::Display::ROTATE_180,
211 ui::USER);
208 // Move the cursor to the center of the first root window. 212 // Move the cursor to the center of the first root window.
209 generator1.MoveMouseToInHost(59, 99); 213 generator1.MoveMouseToInHost(59, 99);
210 214
211 magnifier->SetEnabled(true); 215 magnifier->SetEnabled(true);
212 EXPECT_EQ("120x200", root_windows[0]->bounds().size().ToString()); 216 EXPECT_EQ("120x200", root_windows[0]->bounds().size().ToString());
213 EXPECT_EQ("200x150", root_windows[1]->bounds().size().ToString()); 217 EXPECT_EQ("200x150", root_windows[1]->bounds().size().ToString());
214 // Dislay must share at least 100, so the x's offset becomes 20. 218 // Dislay must share at least 100, so the x's offset becomes 20.
215 EXPECT_EQ("20,200 200x150", 219 EXPECT_EQ("20,200 200x150",
216 ScreenUtil::GetSecondaryDisplay().bounds().ToString()); 220 ScreenUtil::GetSecondaryDisplay().bounds().ToString());
217 generator1.MoveMouseToInHost(39, 59); 221 generator1.MoveMouseToInHost(39, 59);
(...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after
402 // Y margin must be margin is (500 - 500/400 * 200) / 2 = 125. 406 // Y margin must be margin is (500 - 500/400 * 200) / 2 = 125.
403 EXPECT_EQ("0,125,0,125", transformer->GetHostInsets().ToString()); 407 EXPECT_EQ("0,125,0,125", transformer->GetHostInsets().ToString());
404 408
405 UpdateDisplay("200x400,500x500"); 409 UpdateDisplay("200x400,500x500");
406 // The aspect ratio is flipped, so X margin is now 125. 410 // The aspect ratio is flipped, so X margin is now 125.
407 transformer = test_api.CreateCurrentRootWindowTransformer(); 411 transformer = test_api.CreateCurrentRootWindowTransformer();
408 EXPECT_EQ("125,0,125,0", transformer->GetHostInsets().ToString()); 412 EXPECT_EQ("125,0,125,0", transformer->GetHostInsets().ToString());
409 } 413 }
410 414
411 } // namespace ash 415 } // namespace ash
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698