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

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

Issue 1108343002: Revert of Merge Prevent DisplayPreferences from saving incorrect rotations. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@2357
Patch Set: Created 5 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
« no previous file with comments | « ash/display/root_window_transformers.cc ('k') | ash/rotator/screen_rotation_animator.h » ('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 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"
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
100 float touch_radius_x_; 100 float touch_radius_x_;
101 float touch_radius_y_; 101 float touch_radius_y_;
102 float scroll_x_offset_; 102 float scroll_x_offset_;
103 float scroll_y_offset_; 103 float scroll_y_offset_;
104 float scroll_x_offset_ordinal_; 104 float scroll_x_offset_ordinal_;
105 float scroll_y_offset_ordinal_; 105 float scroll_y_offset_ordinal_;
106 106
107 DISALLOW_COPY_AND_ASSIGN(TestEventHandler); 107 DISALLOW_COPY_AND_ASSIGN(TestEventHandler);
108 }; 108 };
109 109
110 gfx::Display::Rotation GetStoredRotation(int64 id) {
111 return Shell::GetInstance()->display_manager()->GetDisplayInfo(id).rotation();
112 }
113
110 float GetStoredUIScale(int64 id) { 114 float GetStoredUIScale(int64 id) {
111 return Shell::GetInstance()->display_manager()->GetDisplayInfo(id). 115 return Shell::GetInstance()->display_manager()->GetDisplayInfo(id).
112 GetEffectiveUIScale(); 116 GetEffectiveUIScale();
113 } 117 }
114 118
115 } // namespace 119 } // namespace
116 120
117 typedef test::AshTestBase RootWindowTransformersTest; 121 typedef test::AshTestBase RootWindowTransformersTest;
118 122
119 #if defined(OS_WIN) 123 #if defined(OS_WIN)
(...skipping 27 matching lines...) Expand all
147 magnifier->SetEnabled(true); 151 magnifier->SetEnabled(true);
148 EXPECT_EQ(2.0f, magnifier->GetScale()); 152 EXPECT_EQ(2.0f, magnifier->GetScale());
149 EXPECT_EQ("120x200", root_windows[0]->bounds().size().ToString()); 153 EXPECT_EQ("120x200", root_windows[0]->bounds().size().ToString());
150 EXPECT_EQ("150x200", root_windows[1]->bounds().size().ToString()); 154 EXPECT_EQ("150x200", root_windows[1]->bounds().size().ToString());
151 EXPECT_EQ("120,0 150x200", 155 EXPECT_EQ("120,0 150x200",
152 ScreenUtil::GetSecondaryDisplay().bounds().ToString()); 156 ScreenUtil::GetSecondaryDisplay().bounds().ToString());
153 generator1.MoveMouseToInHost(40, 80); 157 generator1.MoveMouseToInHost(40, 80);
154 EXPECT_EQ("50,90", event_handler.GetLocationAndReset()); 158 EXPECT_EQ("50,90", event_handler.GetLocationAndReset());
155 EXPECT_EQ("50,90", 159 EXPECT_EQ("50,90",
156 aura::Env::GetInstance()->last_mouse_location().ToString()); 160 aura::Env::GetInstance()->last_mouse_location().ToString());
157 EXPECT_EQ(gfx::Display::ROTATE_0, GetActiveDisplayRotation(display1.id())); 161 EXPECT_EQ(gfx::Display::ROTATE_0, GetStoredRotation(display1.id()));
158 EXPECT_EQ(gfx::Display::ROTATE_0, GetActiveDisplayRotation(display2_id)); 162 EXPECT_EQ(gfx::Display::ROTATE_0, GetStoredRotation(display2_id));
159 magnifier->SetEnabled(false); 163 magnifier->SetEnabled(false);
160 164
161 display_manager->SetDisplayRotation(display1.id(), gfx::Display::ROTATE_90, 165 display_manager->SetDisplayRotation(display1.id(),
162 gfx::Display::ROTATION_SOURCE_ACTIVE); 166 gfx::Display::ROTATE_90);
163 // Move the cursor to the center of the first root window. 167 // Move the cursor to the center of the first root window.
164 generator1.MoveMouseToInHost(59, 100); 168 generator1.MoveMouseToInHost(59, 100);
165 169
166 magnifier->SetEnabled(true); 170 magnifier->SetEnabled(true);
167 EXPECT_EQ(2.0f, magnifier->GetScale()); 171 EXPECT_EQ(2.0f, magnifier->GetScale());
168 EXPECT_EQ("200x120", root_windows[0]->bounds().size().ToString()); 172 EXPECT_EQ("200x120", root_windows[0]->bounds().size().ToString());
169 EXPECT_EQ("150x200", root_windows[1]->bounds().size().ToString()); 173 EXPECT_EQ("150x200", root_windows[1]->bounds().size().ToString());
170 EXPECT_EQ("200,0 150x200", 174 EXPECT_EQ("200,0 150x200",
171 ScreenUtil::GetSecondaryDisplay().bounds().ToString()); 175 ScreenUtil::GetSecondaryDisplay().bounds().ToString());
172 generator1.MoveMouseToInHost(39, 120); 176 generator1.MoveMouseToInHost(39, 120);
173 EXPECT_EQ("110,70", event_handler.GetLocationAndReset()); 177 EXPECT_EQ("110,70", event_handler.GetLocationAndReset());
174 EXPECT_EQ("110,70", 178 EXPECT_EQ("110,70",
175 aura::Env::GetInstance()->last_mouse_location().ToString()); 179 aura::Env::GetInstance()->last_mouse_location().ToString());
176 EXPECT_EQ(gfx::Display::ROTATE_90, GetActiveDisplayRotation(display1.id())); 180 EXPECT_EQ(gfx::Display::ROTATE_90, GetStoredRotation(display1.id()));
177 EXPECT_EQ(gfx::Display::ROTATE_0, GetActiveDisplayRotation(display2_id)); 181 EXPECT_EQ(gfx::Display::ROTATE_0, GetStoredRotation(display2_id));
178 magnifier->SetEnabled(false); 182 magnifier->SetEnabled(false);
179 183
180 DisplayLayout display_layout(DisplayLayout::BOTTOM, 50); 184 DisplayLayout display_layout(DisplayLayout::BOTTOM, 50);
181 display_manager->SetLayoutForCurrentDisplays(display_layout); 185 display_manager->SetLayoutForCurrentDisplays(display_layout);
182 EXPECT_EQ("50,120 150x200", 186 EXPECT_EQ("50,120 150x200",
183 ScreenUtil::GetSecondaryDisplay().bounds().ToString()); 187 ScreenUtil::GetSecondaryDisplay().bounds().ToString());
184 188
185 display_manager->SetDisplayRotation(display2_id, gfx::Display::ROTATE_270, 189 display_manager->SetDisplayRotation(display2_id,
186 gfx::Display::ROTATION_SOURCE_ACTIVE); 190 gfx::Display::ROTATE_270);
187 // Move the cursor to the center of the second root window. 191 // Move the cursor to the center of the second root window.
188 generator2.MoveMouseToInHost(151, 199); 192 generator2.MoveMouseToInHost(151, 199);
189 193
190 magnifier->SetEnabled(true); 194 magnifier->SetEnabled(true);
191 EXPECT_EQ("200x120", root_windows[0]->bounds().size().ToString()); 195 EXPECT_EQ("200x120", root_windows[0]->bounds().size().ToString());
192 EXPECT_EQ("200x150", root_windows[1]->bounds().size().ToString()); 196 EXPECT_EQ("200x150", root_windows[1]->bounds().size().ToString());
193 EXPECT_EQ("50,120 200x150", 197 EXPECT_EQ("50,120 200x150",
194 ScreenUtil::GetSecondaryDisplay().bounds().ToString()); 198 ScreenUtil::GetSecondaryDisplay().bounds().ToString());
195 generator2.MoveMouseToInHost(172, 219); 199 generator2.MoveMouseToInHost(172, 219);
196 EXPECT_EQ("95,80", event_handler.GetLocationAndReset()); 200 EXPECT_EQ("95,80", event_handler.GetLocationAndReset());
197 EXPECT_EQ("145,200", 201 EXPECT_EQ("145,200",
198 aura::Env::GetInstance()->last_mouse_location().ToString()); 202 aura::Env::GetInstance()->last_mouse_location().ToString());
199 EXPECT_EQ(gfx::Display::ROTATE_90, GetActiveDisplayRotation(display1.id())); 203 EXPECT_EQ(gfx::Display::ROTATE_90, GetStoredRotation(display1.id()));
200 EXPECT_EQ(gfx::Display::ROTATE_270, GetActiveDisplayRotation(display2_id)); 204 EXPECT_EQ(gfx::Display::ROTATE_270, GetStoredRotation(display2_id));
201 magnifier->SetEnabled(false); 205 magnifier->SetEnabled(false);
202 206
203 display_manager->SetDisplayRotation(display1.id(), gfx::Display::ROTATE_180, 207 display_manager->SetDisplayRotation(display1.id(),
204 gfx::Display::ROTATION_SOURCE_ACTIVE); 208 gfx::Display::ROTATE_180);
205 // Move the cursor to the center of the first root window. 209 // Move the cursor to the center of the first root window.
206 generator1.MoveMouseToInHost(59, 99); 210 generator1.MoveMouseToInHost(59, 99);
207 211
208 magnifier->SetEnabled(true); 212 magnifier->SetEnabled(true);
209 EXPECT_EQ("120x200", root_windows[0]->bounds().size().ToString()); 213 EXPECT_EQ("120x200", root_windows[0]->bounds().size().ToString());
210 EXPECT_EQ("200x150", root_windows[1]->bounds().size().ToString()); 214 EXPECT_EQ("200x150", root_windows[1]->bounds().size().ToString());
211 // Dislay must share at least 100, so the x's offset becomes 20. 215 // Dislay must share at least 100, so the x's offset becomes 20.
212 EXPECT_EQ("20,200 200x150", 216 EXPECT_EQ("20,200 200x150",
213 ScreenUtil::GetSecondaryDisplay().bounds().ToString()); 217 ScreenUtil::GetSecondaryDisplay().bounds().ToString());
214 generator1.MoveMouseToInHost(39, 59); 218 generator1.MoveMouseToInHost(39, 59);
215 EXPECT_EQ("70,120", event_handler.GetLocationAndReset()); 219 EXPECT_EQ("70,120", event_handler.GetLocationAndReset());
216 EXPECT_EQ(gfx::Display::ROTATE_180, GetActiveDisplayRotation(display1.id())); 220 EXPECT_EQ(gfx::Display::ROTATE_180, GetStoredRotation(display1.id()));
217 EXPECT_EQ(gfx::Display::ROTATE_270, GetActiveDisplayRotation(display2_id)); 221 EXPECT_EQ(gfx::Display::ROTATE_270, GetStoredRotation(display2_id));
218 magnifier->SetEnabled(false); 222 magnifier->SetEnabled(false);
219 223
220 Shell::GetInstance()->RemovePreTargetHandler(&event_handler); 224 Shell::GetInstance()->RemovePreTargetHandler(&event_handler);
221 } 225 }
222 226
223 TEST_F(RootWindowTransformersTest, ScaleAndMagnify) { 227 TEST_F(RootWindowTransformersTest, ScaleAndMagnify) {
224 if (!SupportsMultipleDisplays()) 228 if (!SupportsMultipleDisplays())
225 return; 229 return;
226 230
227 TestEventHandler event_handler; 231 TestEventHandler event_handler;
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after
400 // Y margin must be margin is (500 - 500/400 * 200) / 2 = 125. 404 // Y margin must be margin is (500 - 500/400 * 200) / 2 = 125.
401 EXPECT_EQ("0,125,0,125", transformer->GetHostInsets().ToString()); 405 EXPECT_EQ("0,125,0,125", transformer->GetHostInsets().ToString());
402 406
403 UpdateDisplay("200x400,500x500"); 407 UpdateDisplay("200x400,500x500");
404 // The aspect ratio is flipped, so X margin is now 125. 408 // The aspect ratio is flipped, so X margin is now 125.
405 transformer = test_api.CreateCurrentRootWindowTransformer(); 409 transformer = test_api.CreateCurrentRootWindowTransformer();
406 EXPECT_EQ("125,0,125,0", transformer->GetHostInsets().ToString()); 410 EXPECT_EQ("125,0,125,0", transformer->GetHostInsets().ToString());
407 } 411 }
408 412
409 } // namespace ash 413 } // namespace ash
OLDNEW
« no previous file with comments | « ash/display/root_window_transformers.cc ('k') | ash/rotator/screen_rotation_animator.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698