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

Side by Side Diff: chrome/browser/extensions/display_info_provider_chromeos_unittest.cc

Issue 2802603005: MD Settings: Display: Add unified desktop control and modify api (Closed)
Patch Set: Fix closure and tests 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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "extensions/browser/api/system_display/display_info_provider.h" 5 #include "extensions/browser/api/system_display/display_info_provider.h"
6 6
7 #include <stdint.h> 7 #include <stdint.h>
8 8
9 #include "ash/display/screen_orientation_controller_chromeos.h" 9 #include "ash/display/screen_orientation_controller_chromeos.h"
10 #include "ash/shell.h" 10 #include "ash/shell.h"
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
77 "%d,%d,%d,%d", insets.top, insets.left, insets.bottom, insets.right); 77 "%d,%d,%d,%d", insets.top, insets.left, insets.bottom, insets.right);
78 } 78 }
79 79
80 std::string SystemInfoDisplayBoundsToString( 80 std::string SystemInfoDisplayBoundsToString(
81 const api::system_display::Bounds& bounds) const { 81 const api::system_display::Bounds& bounds) const {
82 // Order to match gfx::Rect::ToString(). 82 // Order to match gfx::Rect::ToString().
83 return base::StringPrintf( 83 return base::StringPrintf(
84 "%d,%d %dx%d", bounds.left, bounds.top, bounds.width, bounds.height); 84 "%d,%d %dx%d", bounds.left, bounds.top, bounds.width, bounds.height);
85 } 85 }
86 86
87 DisplayUnitInfoList GetAllDisplaysInfo() {
88 return DisplayInfoProvider::Get()->GetAllDisplaysInfo(
89 false /* single unified */);
90 }
91
87 private: 92 private:
88 DISALLOW_COPY_AND_ASSIGN(DisplayInfoProviderChromeosTest); 93 DISALLOW_COPY_AND_ASSIGN(DisplayInfoProviderChromeosTest);
89 }; 94 };
90 95
91 TEST_F(DisplayInfoProviderChromeosTest, GetBasic) { 96 TEST_F(DisplayInfoProviderChromeosTest, GetBasic) {
92 UpdateDisplay("500x600,400x520"); 97 UpdateDisplay("500x600,400x520");
93 DisplayUnitInfoList result = DisplayInfoProvider::Get()->GetAllDisplaysInfo(); 98 DisplayUnitInfoList result = GetAllDisplaysInfo();
94 99
95 ASSERT_EQ(2u, result.size()); 100 ASSERT_EQ(2u, result.size());
96 101
97 int64_t display_id; 102 int64_t display_id;
98 ASSERT_TRUE(base::StringToInt64(result[0].id, &display_id)) 103 ASSERT_TRUE(base::StringToInt64(result[0].id, &display_id))
99 << "Display id must be convertable to integer: " << result[0].id; 104 << "Display id must be convertable to integer: " << result[0].id;
100 105
101 ASSERT_TRUE(DisplayExists(display_id)) << display_id << " not found"; 106 ASSERT_TRUE(DisplayExists(display_id)) << display_id << " not found";
102 EXPECT_EQ("0,0 500x600", SystemInfoDisplayBoundsToString(result[0].bounds)); 107 EXPECT_EQ("0,0 500x600", SystemInfoDisplayBoundsToString(result[0].bounds));
103 EXPECT_EQ("0,0,0,0", SystemInfoDisplayInsetsToString(result[0].overscan)); 108 EXPECT_EQ("0,0,0,0", SystemInfoDisplayInsetsToString(result[0].overscan));
(...skipping 20 matching lines...) Expand all
124 EXPECT_EQ(96, result[1].dpi_y); 129 EXPECT_EQ(96, result[1].dpi_y);
125 EXPECT_TRUE(result[1].mirroring_source_id.empty()); 130 EXPECT_TRUE(result[1].mirroring_source_id.empty());
126 EXPECT_TRUE(result[1].is_enabled); 131 EXPECT_TRUE(result[1].is_enabled);
127 } 132 }
128 133
129 TEST_F(DisplayInfoProviderChromeosTest, GetWithUnifiedDesktop) { 134 TEST_F(DisplayInfoProviderChromeosTest, GetWithUnifiedDesktop) {
130 UpdateDisplay("500x600,400x520"); 135 UpdateDisplay("500x600,400x520");
131 136
132 // Check initial state. 137 // Check initial state.
133 EXPECT_FALSE(GetDisplayManager()->IsInUnifiedMode()); 138 EXPECT_FALSE(GetDisplayManager()->IsInUnifiedMode());
134 DisplayUnitInfoList result = DisplayInfoProvider::Get()->GetAllDisplaysInfo(); 139 DisplayUnitInfoList result = GetAllDisplaysInfo();
135 140
136 ASSERT_EQ(2u, result.size()); 141 ASSERT_EQ(2u, result.size());
137 142
138 int64_t display_id; 143 int64_t display_id;
139 ASSERT_TRUE(base::StringToInt64(result[0].id, &display_id)) 144 ASSERT_TRUE(base::StringToInt64(result[0].id, &display_id))
140 << "Display id must be convertable to integer: " << result[0].id; 145 << "Display id must be convertable to integer: " << result[0].id;
141 146
142 ASSERT_TRUE(DisplayExists(display_id)) << display_id << " not found"; 147 ASSERT_TRUE(DisplayExists(display_id)) << display_id << " not found";
143 EXPECT_EQ("0,0 500x600", SystemInfoDisplayBoundsToString(result[0].bounds)); 148 EXPECT_EQ("0,0 500x600", SystemInfoDisplayBoundsToString(result[0].bounds));
144 EXPECT_EQ("0,0,0,0", SystemInfoDisplayInsetsToString(result[0].overscan)); 149 EXPECT_EQ("0,0,0,0", SystemInfoDisplayInsetsToString(result[0].overscan));
145 EXPECT_EQ(0, result[0].rotation); 150 EXPECT_EQ(0, result[0].rotation);
146 EXPECT_TRUE(result[0].is_primary); 151 EXPECT_TRUE(result[0].is_primary);
152 EXPECT_FALSE(result[0].is_unified);
147 EXPECT_EQ(96, result[0].dpi_x); 153 EXPECT_EQ(96, result[0].dpi_x);
148 EXPECT_EQ(96, result[0].dpi_y); 154 EXPECT_EQ(96, result[0].dpi_y);
149 EXPECT_TRUE(result[0].mirroring_source_id.empty()); 155 EXPECT_TRUE(result[0].mirroring_source_id.empty());
150 EXPECT_TRUE(result[0].is_enabled); 156 EXPECT_TRUE(result[0].is_enabled);
151 157
152 ASSERT_TRUE(base::StringToInt64(result[1].id, &display_id)) 158 ASSERT_TRUE(base::StringToInt64(result[1].id, &display_id))
153 << "Display id must be convertable to integer: " << result[0].id; 159 << "Display id must be convertable to integer: " << result[0].id;
154 160
155 ASSERT_TRUE(DisplayExists(display_id)) << display_id << " not found"; 161 ASSERT_TRUE(DisplayExists(display_id)) << display_id << " not found";
156 EXPECT_EQ(GetDisplayManager()->GetDisplayNameForId(display_id), 162 EXPECT_EQ(GetDisplayManager()->GetDisplayNameForId(display_id),
157 result[1].name); 163 result[1].name);
158 164
159 // Initial multipple display configuration. 165 // Initial multipple display configuration.
160 EXPECT_EQ("500,0 400x520", SystemInfoDisplayBoundsToString(result[1].bounds)); 166 EXPECT_EQ("500,0 400x520", SystemInfoDisplayBoundsToString(result[1].bounds));
161 EXPECT_EQ("0,0,0,0", SystemInfoDisplayInsetsToString(result[1].overscan)); 167 EXPECT_EQ("0,0,0,0", SystemInfoDisplayInsetsToString(result[1].overscan));
162 EXPECT_EQ(0, result[1].rotation); 168 EXPECT_EQ(0, result[1].rotation);
163 EXPECT_FALSE(result[1].is_primary); 169 EXPECT_FALSE(result[1].is_primary);
170 EXPECT_FALSE(result[0].is_unified);
164 EXPECT_EQ(96, result[1].dpi_x); 171 EXPECT_EQ(96, result[1].dpi_x);
165 EXPECT_EQ(96, result[1].dpi_y); 172 EXPECT_EQ(96, result[1].dpi_y);
166 EXPECT_TRUE(result[1].mirroring_source_id.empty()); 173 EXPECT_TRUE(result[1].mirroring_source_id.empty());
167 EXPECT_TRUE(result[1].is_enabled); 174 EXPECT_TRUE(result[1].is_enabled);
168 175
169 // Enable unified. 176 // Enable unified.
170 GetDisplayManager()->SetUnifiedDesktopEnabled(true); 177 GetDisplayManager()->SetUnifiedDesktopEnabled(true);
171 EXPECT_TRUE(GetDisplayManager()->IsInUnifiedMode()); 178 EXPECT_TRUE(GetDisplayManager()->IsInUnifiedMode());
172 179
173 result = DisplayInfoProvider::Get()->GetAllDisplaysInfo(); 180 result = GetAllDisplaysInfo();
174 181
175 ASSERT_EQ(2u, result.size()); 182 ASSERT_EQ(2u, result.size());
176 183
177 ASSERT_TRUE(base::StringToInt64(result[0].id, &display_id)) 184 ASSERT_TRUE(base::StringToInt64(result[0].id, &display_id))
178 << "Display id must be convertable to integer: " << result[0].id; 185 << "Display id must be convertable to integer: " << result[0].id;
179 186
180 EXPECT_EQ("0,0 500x600", SystemInfoDisplayBoundsToString(result[0].bounds)); 187 EXPECT_EQ("0,0 500x600", SystemInfoDisplayBoundsToString(result[0].bounds));
181 EXPECT_EQ("0,0,0,0", SystemInfoDisplayInsetsToString(result[0].overscan)); 188 EXPECT_EQ("0,0,0,0", SystemInfoDisplayInsetsToString(result[0].overscan));
182 EXPECT_EQ(0, result[0].rotation); 189 EXPECT_EQ(0, result[0].rotation);
183 EXPECT_TRUE(result[0].is_primary); 190 EXPECT_TRUE(result[0].is_primary);
191 EXPECT_TRUE(result[0].is_unified);
184 EXPECT_EQ(96, result[0].dpi_x); 192 EXPECT_EQ(96, result[0].dpi_x);
185 EXPECT_EQ(96, result[0].dpi_y); 193 EXPECT_EQ(96, result[0].dpi_y);
186 EXPECT_TRUE(result[0].mirroring_source_id.empty()); 194 EXPECT_TRUE(result[0].mirroring_source_id.empty());
187 EXPECT_TRUE(result[0].is_enabled); 195 EXPECT_TRUE(result[0].is_enabled);
188 196
189 ASSERT_TRUE(base::StringToInt64(result[1].id, &display_id)) 197 ASSERT_TRUE(base::StringToInt64(result[1].id, &display_id))
190 << "Display id must be convertable to integer: " << result[0].id; 198 << "Display id must be convertable to integer: " << result[0].id;
191 199
192 EXPECT_EQ(GetDisplayManager()->GetDisplayNameForId(display_id), 200 EXPECT_EQ(GetDisplayManager()->GetDisplayNameForId(display_id),
193 result[1].name); 201 result[1].name);
194 202
195 // After enabling unified the second display is scaled to meet the height for 203 // After enabling unified the second display is scaled to meet the height for
196 // the first. Which also affects the DPI below. 204 // the first. Which also affects the DPI below.
197 EXPECT_EQ("500,0 461x600", SystemInfoDisplayBoundsToString(result[1].bounds)); 205 EXPECT_EQ("500,0 461x600", SystemInfoDisplayBoundsToString(result[1].bounds));
198 EXPECT_EQ("0,0,0,0", SystemInfoDisplayInsetsToString(result[1].overscan)); 206 EXPECT_EQ("0,0,0,0", SystemInfoDisplayInsetsToString(result[1].overscan));
199 EXPECT_EQ(0, result[1].rotation); 207 EXPECT_EQ(0, result[1].rotation);
200 EXPECT_FALSE(result[1].is_primary); 208 EXPECT_FALSE(result[1].is_primary);
209 EXPECT_TRUE(result[1].is_unified);
201 EXPECT_FLOAT_EQ(111, round(result[1].dpi_x)); 210 EXPECT_FLOAT_EQ(111, round(result[1].dpi_x));
202 EXPECT_FLOAT_EQ(111, round(result[1].dpi_y)); 211 EXPECT_FLOAT_EQ(111, round(result[1].dpi_y));
203 EXPECT_TRUE(result[1].mirroring_source_id.empty()); 212 EXPECT_TRUE(result[1].mirroring_source_id.empty());
204 EXPECT_TRUE(result[1].is_enabled); 213 EXPECT_TRUE(result[1].is_enabled);
205 214
206 // Disable unified and check that once again it matches initial situation. 215 // Disable unified and check that once again it matches initial situation.
207 GetDisplayManager()->SetUnifiedDesktopEnabled(false); 216 GetDisplayManager()->SetUnifiedDesktopEnabled(false);
208 EXPECT_FALSE(GetDisplayManager()->IsInUnifiedMode()); 217 EXPECT_FALSE(GetDisplayManager()->IsInUnifiedMode());
209 result = DisplayInfoProvider::Get()->GetAllDisplaysInfo(); 218 result = GetAllDisplaysInfo();
210 219
211 ASSERT_EQ(2u, result.size()); 220 ASSERT_EQ(2u, result.size());
212 221
222 ASSERT_TRUE(base::StringToInt64(result[0].id, &display_id))
223 << "Display id must be convertable to integer: " << result[0].id;
224
225 ASSERT_TRUE(DisplayExists(display_id)) << display_id << " not found";
226 EXPECT_EQ("0,0 500x600", SystemInfoDisplayBoundsToString(result[0].bounds));
227 EXPECT_EQ("0,0,0,0", SystemInfoDisplayInsetsToString(result[0].overscan));
228 EXPECT_EQ(0, result[0].rotation);
229 EXPECT_TRUE(result[0].is_primary);
230 EXPECT_FALSE(result[0].is_unified);
231 EXPECT_EQ(96, result[0].dpi_x);
232 EXPECT_EQ(96, result[0].dpi_y);
233 EXPECT_TRUE(result[0].mirroring_source_id.empty());
234 EXPECT_TRUE(result[0].is_enabled);
235
236 ASSERT_TRUE(base::StringToInt64(result[1].id, &display_id))
237 << "Display id must be convertable to integer: " << result[0].id;
238
239 ASSERT_TRUE(DisplayExists(display_id)) << display_id << " not found";
240 EXPECT_EQ(GetDisplayManager()->GetDisplayNameForId(display_id),
241 result[1].name);
242 EXPECT_EQ("500,0 400x520", SystemInfoDisplayBoundsToString(result[1].bounds));
243 EXPECT_EQ("0,0,0,0", SystemInfoDisplayInsetsToString(result[1].overscan));
244 EXPECT_EQ(0, result[1].rotation);
245 EXPECT_FALSE(result[1].is_primary);
246 EXPECT_FALSE(result[1].is_unified);
247 EXPECT_EQ(96, result[1].dpi_x);
248 EXPECT_EQ(96, result[1].dpi_y);
249 EXPECT_TRUE(result[1].mirroring_source_id.empty());
250 EXPECT_TRUE(result[1].is_enabled);
251 }
252
253 TEST_F(DisplayInfoProviderChromeosTest, GetWithUnifiedDesktopForSettings) {
254 UpdateDisplay("500x600,400x520");
255
256 // Check initial state.
257 EXPECT_FALSE(GetDisplayManager()->IsInUnifiedMode());
258 DisplayUnitInfoList result =
259 DisplayInfoProvider::Get()->GetAllDisplaysInfo(true /* single unifed */);
260
261 ASSERT_EQ(2u, result.size());
262
263 int64_t display_id;
264 ASSERT_TRUE(base::StringToInt64(result[0].id, &display_id))
265 << "Display id must be convertable to integer: " << result[0].id;
266
267 ASSERT_TRUE(DisplayExists(display_id)) << display_id << " not found";
268 EXPECT_EQ("0,0 500x600", SystemInfoDisplayBoundsToString(result[0].bounds));
269 EXPECT_EQ("0,0,0,0", SystemInfoDisplayInsetsToString(result[0].overscan));
270 EXPECT_EQ(0, result[0].rotation);
271 EXPECT_TRUE(result[0].is_primary);
272 EXPECT_FALSE(result[0].is_unified);
273 EXPECT_EQ(96, result[0].dpi_x);
274 EXPECT_EQ(96, result[0].dpi_y);
275 EXPECT_TRUE(result[0].mirroring_source_id.empty());
276 EXPECT_TRUE(result[0].is_enabled);
277
278 ASSERT_TRUE(base::StringToInt64(result[1].id, &display_id))
279 << "Display id must be convertable to integer: " << result[0].id;
280
281 ASSERT_TRUE(DisplayExists(display_id)) << display_id << " not found";
282 EXPECT_EQ(GetDisplayManager()->GetDisplayNameForId(display_id),
283 result[1].name);
284
285 // Initial multipple display configuration.
286 EXPECT_EQ("500,0 400x520", SystemInfoDisplayBoundsToString(result[1].bounds));
287 EXPECT_EQ("0,0,0,0", SystemInfoDisplayInsetsToString(result[1].overscan));
288 EXPECT_EQ(0, result[1].rotation);
289 EXPECT_FALSE(result[1].is_primary);
290 EXPECT_FALSE(result[0].is_unified);
291 EXPECT_EQ(96, result[1].dpi_x);
292 EXPECT_EQ(96, result[1].dpi_y);
293 EXPECT_TRUE(result[1].mirroring_source_id.empty());
294 EXPECT_TRUE(result[1].is_enabled);
295
296 // Enable unified.
297 GetDisplayManager()->SetUnifiedDesktopEnabled(true);
298 EXPECT_TRUE(GetDisplayManager()->IsInUnifiedMode());
299
300 // For settings, GetAllDisplaysInfo will return a single unified display. The
301 // second display will be scaled to match the height of the first, so the
302 // height will be 600 and the new width will be 500 + [400 * 600/520 = 461] =
303 // 961.
304 result =
305 DisplayInfoProvider::Get()->GetAllDisplaysInfo(true /* single unified */);
306
307 ASSERT_EQ(1u, result.size());
308 ASSERT_TRUE(base::StringToInt64(result[0].id, &display_id))
309 << "Display id must be convertable to integer: " << result[0].id;
310
311 EXPECT_EQ("0,0 961x600", SystemInfoDisplayBoundsToString(result[0].bounds));
312 EXPECT_EQ("0,0,0,0", SystemInfoDisplayInsetsToString(result[0].overscan));
313 EXPECT_EQ(0, result[0].rotation);
314 EXPECT_TRUE(result[0].is_primary);
315 EXPECT_TRUE(result[0].is_unified);
316 EXPECT_EQ(96, result[0].dpi_x);
317 EXPECT_EQ(96, result[0].dpi_y);
318 EXPECT_TRUE(result[0].mirroring_source_id.empty());
319 EXPECT_TRUE(result[0].is_enabled);
320
321 // Disable unified and check that once again it matches initial situation.
322 GetDisplayManager()->SetUnifiedDesktopEnabled(false);
323 EXPECT_FALSE(GetDisplayManager()->IsInUnifiedMode());
324 result = GetAllDisplaysInfo();
325
326 ASSERT_EQ(2u, result.size());
327
213 ASSERT_TRUE(base::StringToInt64(result[0].id, &display_id)) 328 ASSERT_TRUE(base::StringToInt64(result[0].id, &display_id))
214 << "Display id must be convertable to integer: " << result[0].id; 329 << "Display id must be convertable to integer: " << result[0].id;
215 330
216 ASSERT_TRUE(DisplayExists(display_id)) << display_id << " not found"; 331 ASSERT_TRUE(DisplayExists(display_id)) << display_id << " not found";
217 EXPECT_EQ("0,0 500x600", SystemInfoDisplayBoundsToString(result[0].bounds)); 332 EXPECT_EQ("0,0 500x600", SystemInfoDisplayBoundsToString(result[0].bounds));
218 EXPECT_EQ("0,0,0,0", SystemInfoDisplayInsetsToString(result[0].overscan)); 333 EXPECT_EQ("0,0,0,0", SystemInfoDisplayInsetsToString(result[0].overscan));
219 EXPECT_EQ(0, result[0].rotation); 334 EXPECT_EQ(0, result[0].rotation);
220 EXPECT_TRUE(result[0].is_primary); 335 EXPECT_TRUE(result[0].is_primary);
336 EXPECT_FALSE(result[0].is_unified);
221 EXPECT_EQ(96, result[0].dpi_x); 337 EXPECT_EQ(96, result[0].dpi_x);
222 EXPECT_EQ(96, result[0].dpi_y); 338 EXPECT_EQ(96, result[0].dpi_y);
223 EXPECT_TRUE(result[0].mirroring_source_id.empty()); 339 EXPECT_TRUE(result[0].mirroring_source_id.empty());
224 EXPECT_TRUE(result[0].is_enabled); 340 EXPECT_TRUE(result[0].is_enabled);
225 341
226 ASSERT_TRUE(base::StringToInt64(result[1].id, &display_id)) 342 ASSERT_TRUE(base::StringToInt64(result[1].id, &display_id))
227 << "Display id must be convertable to integer: " << result[0].id; 343 << "Display id must be convertable to integer: " << result[0].id;
228 344
229 ASSERT_TRUE(DisplayExists(display_id)) << display_id << " not found"; 345 ASSERT_TRUE(DisplayExists(display_id)) << display_id << " not found";
230 EXPECT_EQ(GetDisplayManager()->GetDisplayNameForId(display_id), 346 EXPECT_EQ(GetDisplayManager()->GetDisplayNameForId(display_id),
231 result[1].name); 347 result[1].name);
232 EXPECT_EQ("500,0 400x520", SystemInfoDisplayBoundsToString(result[1].bounds)); 348 EXPECT_EQ("500,0 400x520", SystemInfoDisplayBoundsToString(result[1].bounds));
233 EXPECT_EQ("0,0,0,0", SystemInfoDisplayInsetsToString(result[1].overscan)); 349 EXPECT_EQ("0,0,0,0", SystemInfoDisplayInsetsToString(result[1].overscan));
234 EXPECT_EQ(0, result[1].rotation); 350 EXPECT_EQ(0, result[1].rotation);
235 EXPECT_FALSE(result[1].is_primary); 351 EXPECT_FALSE(result[1].is_primary);
352 EXPECT_FALSE(result[1].is_unified);
236 EXPECT_EQ(96, result[1].dpi_x); 353 EXPECT_EQ(96, result[1].dpi_x);
237 EXPECT_EQ(96, result[1].dpi_y); 354 EXPECT_EQ(96, result[1].dpi_y);
238 EXPECT_TRUE(result[1].mirroring_source_id.empty()); 355 EXPECT_TRUE(result[1].mirroring_source_id.empty());
239 EXPECT_TRUE(result[1].is_enabled); 356 EXPECT_TRUE(result[1].is_enabled);
240 } 357 }
241 358
242 TEST_F(DisplayInfoProviderChromeosTest, GetRotation) { 359 TEST_F(DisplayInfoProviderChromeosTest, GetRotation) {
243 UpdateDisplay("500x600/r"); 360 UpdateDisplay("500x600/r");
244 DisplayUnitInfoList result = DisplayInfoProvider::Get()->GetAllDisplaysInfo(); 361 DisplayUnitInfoList result = GetAllDisplaysInfo();
245 362
246 ASSERT_EQ(1u, result.size()); 363 ASSERT_EQ(1u, result.size());
247 364
248 int64_t display_id; 365 int64_t display_id;
249 ASSERT_TRUE(base::StringToInt64(result[0].id, &display_id)) 366 ASSERT_TRUE(base::StringToInt64(result[0].id, &display_id))
250 << "Display id must be convertable to integer: " << result[0].id; 367 << "Display id must be convertable to integer: " << result[0].id;
251 368
252 ASSERT_TRUE(DisplayExists(display_id)) << display_id << " not found"; 369 ASSERT_TRUE(DisplayExists(display_id)) << display_id << " not found";
253 EXPECT_EQ("0,0 600x500", SystemInfoDisplayBoundsToString(result[0].bounds)); 370 EXPECT_EQ("0,0 600x500", SystemInfoDisplayBoundsToString(result[0].bounds));
254 EXPECT_EQ(90, result[0].rotation); 371 EXPECT_EQ(90, result[0].rotation);
255 372
256 GetDisplayManager()->SetDisplayRotation( 373 GetDisplayManager()->SetDisplayRotation(
257 display_id, display::Display::ROTATE_270, 374 display_id, display::Display::ROTATE_270,
258 display::Display::ROTATION_SOURCE_ACTIVE); 375 display::Display::ROTATION_SOURCE_ACTIVE);
259 376
260 result = DisplayInfoProvider::Get()->GetAllDisplaysInfo(); 377 result = GetAllDisplaysInfo();
261 378
262 ASSERT_EQ(1u, result.size()); 379 ASSERT_EQ(1u, result.size());
263 380
264 EXPECT_EQ(base::Int64ToString(display_id), result[0].id); 381 EXPECT_EQ(base::Int64ToString(display_id), result[0].id);
265 EXPECT_EQ("0,0 600x500", SystemInfoDisplayBoundsToString(result[0].bounds)); 382 EXPECT_EQ("0,0 600x500", SystemInfoDisplayBoundsToString(result[0].bounds));
266 EXPECT_EQ(270, result[0].rotation); 383 EXPECT_EQ(270, result[0].rotation);
267 384
268 GetDisplayManager()->SetDisplayRotation( 385 GetDisplayManager()->SetDisplayRotation(
269 display_id, display::Display::ROTATE_180, 386 display_id, display::Display::ROTATE_180,
270 display::Display::ROTATION_SOURCE_ACTIVE); 387 display::Display::ROTATION_SOURCE_ACTIVE);
271 388
272 result = DisplayInfoProvider::Get()->GetAllDisplaysInfo(); 389 result = GetAllDisplaysInfo();
273 390
274 ASSERT_EQ(1u, result.size()); 391 ASSERT_EQ(1u, result.size());
275 392
276 EXPECT_EQ(base::Int64ToString(display_id), result[0].id); 393 EXPECT_EQ(base::Int64ToString(display_id), result[0].id);
277 EXPECT_EQ("0,0 500x600", SystemInfoDisplayBoundsToString(result[0].bounds)); 394 EXPECT_EQ("0,0 500x600", SystemInfoDisplayBoundsToString(result[0].bounds));
278 EXPECT_EQ(180, result[0].rotation); 395 EXPECT_EQ(180, result[0].rotation);
279 396
280 GetDisplayManager()->SetDisplayRotation( 397 GetDisplayManager()->SetDisplayRotation(
281 display_id, display::Display::ROTATE_0, 398 display_id, display::Display::ROTATE_0,
282 display::Display::ROTATION_SOURCE_ACTIVE); 399 display::Display::ROTATION_SOURCE_ACTIVE);
283 400
284 result = DisplayInfoProvider::Get()->GetAllDisplaysInfo(); 401 result = GetAllDisplaysInfo();
285 402
286 ASSERT_EQ(1u, result.size()); 403 ASSERT_EQ(1u, result.size());
287 404
288 EXPECT_EQ(base::Int64ToString(display_id), result[0].id); 405 EXPECT_EQ(base::Int64ToString(display_id), result[0].id);
289 EXPECT_EQ("0,0 500x600", SystemInfoDisplayBoundsToString(result[0].bounds)); 406 EXPECT_EQ("0,0 500x600", SystemInfoDisplayBoundsToString(result[0].bounds));
290 EXPECT_EQ(0, result[0].rotation); 407 EXPECT_EQ(0, result[0].rotation);
291 } 408 }
292 409
293 TEST_F(DisplayInfoProviderChromeosTest, GetDPI) { 410 TEST_F(DisplayInfoProviderChromeosTest, GetDPI) {
294 UpdateDisplay("500x600,400x520*2"); 411 UpdateDisplay("500x600,400x520*2");
295 DisplayUnitInfoList result; 412 DisplayUnitInfoList result;
296 result = DisplayInfoProvider::Get()->GetAllDisplaysInfo(); 413 result = GetAllDisplaysInfo();
297 414
298 ASSERT_EQ(2u, result.size()); 415 ASSERT_EQ(2u, result.size());
299 416
300 EXPECT_EQ("0,0 500x600", SystemInfoDisplayBoundsToString(result[0].bounds)); 417 EXPECT_EQ("0,0 500x600", SystemInfoDisplayBoundsToString(result[0].bounds));
301 EXPECT_EQ(96, result[0].dpi_x); 418 EXPECT_EQ(96, result[0].dpi_x);
302 EXPECT_EQ(96, result[0].dpi_y); 419 EXPECT_EQ(96, result[0].dpi_y);
303 420
304 EXPECT_EQ("500,0 200x260", SystemInfoDisplayBoundsToString(result[1].bounds)); 421 EXPECT_EQ("500,0 200x260", SystemInfoDisplayBoundsToString(result[1].bounds));
305 // DPI should be 96 (native dpi) * 200 (display) / 400 (native) when ui scale 422 // DPI should be 96 (native dpi) * 200 (display) / 400 (native) when ui scale
306 // is 2. 423 // is 2.
307 EXPECT_EQ(96 / 2, result[1].dpi_x); 424 EXPECT_EQ(96 / 2, result[1].dpi_x);
308 EXPECT_EQ(96 / 2, result[1].dpi_y); 425 EXPECT_EQ(96 / 2, result[1].dpi_y);
309 426
310 SwapPrimaryDisplay(); 427 SwapPrimaryDisplay();
311 428
312 result = DisplayInfoProvider::Get()->GetAllDisplaysInfo(); 429 result = GetAllDisplaysInfo();
313 430
314 ASSERT_EQ(2u, result.size()); 431 ASSERT_EQ(2u, result.size());
315 432
316 EXPECT_EQ("-500,0 500x600", 433 EXPECT_EQ("-500,0 500x600",
317 SystemInfoDisplayBoundsToString(result[0].bounds)); 434 SystemInfoDisplayBoundsToString(result[0].bounds));
318 EXPECT_EQ(96, result[0].dpi_x); 435 EXPECT_EQ(96, result[0].dpi_x);
319 EXPECT_EQ(96, result[0].dpi_y); 436 EXPECT_EQ(96, result[0].dpi_y);
320 437
321 EXPECT_EQ("0,0 200x260", SystemInfoDisplayBoundsToString(result[1].bounds)); 438 EXPECT_EQ("0,0 200x260", SystemInfoDisplayBoundsToString(result[1].bounds));
322 EXPECT_EQ(96 / 2, result[1].dpi_x); 439 EXPECT_EQ(96 / 2, result[1].dpi_x);
323 EXPECT_EQ(96 / 2, result[1].dpi_y); 440 EXPECT_EQ(96 / 2, result[1].dpi_y);
324 } 441 }
325 442
326 TEST_F(DisplayInfoProviderChromeosTest, GetVisibleArea) { 443 TEST_F(DisplayInfoProviderChromeosTest, GetVisibleArea) {
327 UpdateDisplay("640x720*2/o, 400x520/o"); 444 UpdateDisplay("640x720*2/o, 400x520/o");
328 DisplayUnitInfoList result; 445 DisplayUnitInfoList result;
329 result = DisplayInfoProvider::Get()->GetAllDisplaysInfo(); 446 result = GetAllDisplaysInfo();
330 447
331 ASSERT_EQ(2u, result.size()); 448 ASSERT_EQ(2u, result.size());
332 449
333 int64_t display_id; 450 int64_t display_id;
334 ASSERT_TRUE(base::StringToInt64(result[1].id, &display_id)) 451 ASSERT_TRUE(base::StringToInt64(result[1].id, &display_id))
335 << "Display id must be convertable to integer: " << result[1].id; 452 << "Display id must be convertable to integer: " << result[1].id;
336 ASSERT_TRUE(DisplayExists(display_id)) << display_id << " not found"; 453 ASSERT_TRUE(DisplayExists(display_id)) << display_id << " not found";
337 454
338 // Default overscan is 5%. 455 // Default overscan is 5%.
339 EXPECT_EQ("304,0 380x494", SystemInfoDisplayBoundsToString(result[1].bounds)); 456 EXPECT_EQ("304,0 380x494", SystemInfoDisplayBoundsToString(result[1].bounds));
340 EXPECT_EQ("13,10,13,10", SystemInfoDisplayInsetsToString(result[1].overscan)); 457 EXPECT_EQ("13,10,13,10", SystemInfoDisplayInsetsToString(result[1].overscan));
341 458
342 GetDisplayManager()->SetOverscanInsets(display_id, 459 GetDisplayManager()->SetOverscanInsets(display_id,
343 gfx::Insets(20, 30, 50, 60)); 460 gfx::Insets(20, 30, 50, 60));
344 result = DisplayInfoProvider::Get()->GetAllDisplaysInfo(); 461 result = GetAllDisplaysInfo();
345 462
346 ASSERT_EQ(2u, result.size()); 463 ASSERT_EQ(2u, result.size());
347 464
348 EXPECT_EQ(base::Int64ToString(display_id), result[1].id); 465 EXPECT_EQ(base::Int64ToString(display_id), result[1].id);
349 EXPECT_EQ("304,0 310x450", SystemInfoDisplayBoundsToString(result[1].bounds)); 466 EXPECT_EQ("304,0 310x450", SystemInfoDisplayBoundsToString(result[1].bounds));
350 EXPECT_EQ("20,30,50,60", SystemInfoDisplayInsetsToString(result[1].overscan)); 467 EXPECT_EQ("20,30,50,60", SystemInfoDisplayInsetsToString(result[1].overscan));
351 468
352 // Set insets for the primary screen. Note that it has 2x scale. 469 // Set insets for the primary screen. Note that it has 2x scale.
353 ASSERT_TRUE(base::StringToInt64(result[0].id, &display_id)) 470 ASSERT_TRUE(base::StringToInt64(result[0].id, &display_id))
354 << "Display id must be convertable to integer: " << result[0].id; 471 << "Display id must be convertable to integer: " << result[0].id;
355 ASSERT_TRUE(DisplayExists(display_id)) << display_id << " not found"; 472 ASSERT_TRUE(DisplayExists(display_id)) << display_id << " not found";
356 473
357 EXPECT_EQ("0,0 304x342", SystemInfoDisplayBoundsToString(result[0].bounds)); 474 EXPECT_EQ("0,0 304x342", SystemInfoDisplayBoundsToString(result[0].bounds));
358 EXPECT_EQ("9,8,9,8", SystemInfoDisplayInsetsToString(result[0].overscan)); 475 EXPECT_EQ("9,8,9,8", SystemInfoDisplayInsetsToString(result[0].overscan));
359 476
360 GetDisplayManager()->SetOverscanInsets(display_id, 477 GetDisplayManager()->SetOverscanInsets(display_id,
361 gfx::Insets(10, 20, 30, 40)); 478 gfx::Insets(10, 20, 30, 40));
362 result = DisplayInfoProvider::Get()->GetAllDisplaysInfo(); 479 result = GetAllDisplaysInfo();
363 480
364 ASSERT_EQ(2u, result.size()); 481 ASSERT_EQ(2u, result.size());
365 482
366 EXPECT_EQ(base::Int64ToString(display_id), result[0].id); 483 EXPECT_EQ(base::Int64ToString(display_id), result[0].id);
367 EXPECT_EQ("0,0 260x320", SystemInfoDisplayBoundsToString(result[0].bounds)); 484 EXPECT_EQ("0,0 260x320", SystemInfoDisplayBoundsToString(result[0].bounds));
368 EXPECT_EQ("10,20,30,40", SystemInfoDisplayInsetsToString(result[0].overscan)); 485 EXPECT_EQ("10,20,30,40", SystemInfoDisplayInsetsToString(result[0].overscan));
369 } 486 }
370 487
371 TEST_F(DisplayInfoProviderChromeosTest, GetMirroring) { 488 TEST_F(DisplayInfoProviderChromeosTest, GetMirroring) {
372 UpdateDisplay("600x600, 400x520/o"); 489 UpdateDisplay("600x600, 400x520/o");
373 DisplayUnitInfoList result; 490 DisplayUnitInfoList result;
374 result = DisplayInfoProvider::Get()->GetAllDisplaysInfo(); 491 result = GetAllDisplaysInfo();
375 492
376 ASSERT_EQ(2u, result.size()); 493 ASSERT_EQ(2u, result.size());
377 494
378 int64_t display_id_primary; 495 int64_t display_id_primary;
379 ASSERT_TRUE(base::StringToInt64(result[0].id, &display_id_primary)) 496 ASSERT_TRUE(base::StringToInt64(result[0].id, &display_id_primary))
380 << "Display id must be convertable to integer: " << result[0].id; 497 << "Display id must be convertable to integer: " << result[0].id;
381 ASSERT_TRUE(DisplayExists(display_id_primary)) << display_id_primary 498 ASSERT_TRUE(DisplayExists(display_id_primary)) << display_id_primary
382 << " not found"; 499 << " not found";
383 500
384 int64_t display_id_secondary; 501 int64_t display_id_secondary;
385 ASSERT_TRUE(base::StringToInt64(result[1].id, &display_id_secondary)) 502 ASSERT_TRUE(base::StringToInt64(result[1].id, &display_id_secondary))
386 << "Display id must be convertable to integer: " << result[1].id; 503 << "Display id must be convertable to integer: " << result[1].id;
387 ASSERT_TRUE(DisplayExists(display_id_secondary)) << display_id_secondary 504 ASSERT_TRUE(DisplayExists(display_id_secondary)) << display_id_secondary
388 << " not found"; 505 << " not found";
389 506
390 ASSERT_FALSE(GetDisplayManager()->IsInMirrorMode()); 507 ASSERT_FALSE(GetDisplayManager()->IsInMirrorMode());
391 EXPECT_TRUE(result[0].mirroring_source_id.empty()); 508 EXPECT_TRUE(result[0].mirroring_source_id.empty());
392 EXPECT_TRUE(result[1].mirroring_source_id.empty()); 509 EXPECT_TRUE(result[1].mirroring_source_id.empty());
393 510
394 GetDisplayManager()->SetMirrorMode(true); 511 GetDisplayManager()->SetMirrorMode(true);
395 ASSERT_TRUE(GetDisplayManager()->IsInMirrorMode()); 512 ASSERT_TRUE(GetDisplayManager()->IsInMirrorMode());
396 513
397 result = DisplayInfoProvider::Get()->GetAllDisplaysInfo(); 514 result = GetAllDisplaysInfo();
398 515
399 ASSERT_EQ(1u, result.size()); 516 ASSERT_EQ(1u, result.size());
400 EXPECT_EQ(base::Int64ToString(display_id_primary), result[0].id); 517 EXPECT_EQ(base::Int64ToString(display_id_primary), result[0].id);
401 EXPECT_EQ(base::Int64ToString(display_id_secondary), 518 EXPECT_EQ(base::Int64ToString(display_id_secondary),
402 result[0].mirroring_source_id); 519 result[0].mirroring_source_id);
403 520
404 GetDisplayManager()->SetMirrorMode(false); 521 GetDisplayManager()->SetMirrorMode(false);
405 ASSERT_FALSE(GetDisplayManager()->IsInMirrorMode()); 522 ASSERT_FALSE(GetDisplayManager()->IsInMirrorMode());
406 523
407 result = DisplayInfoProvider::Get()->GetAllDisplaysInfo(); 524 result = GetAllDisplaysInfo();
408 525
409 ASSERT_EQ(2u, result.size()); 526 ASSERT_EQ(2u, result.size());
410 EXPECT_EQ(base::Int64ToString(display_id_primary), result[0].id); 527 EXPECT_EQ(base::Int64ToString(display_id_primary), result[0].id);
411 EXPECT_TRUE(result[0].mirroring_source_id.empty()); 528 EXPECT_TRUE(result[0].mirroring_source_id.empty());
412 EXPECT_EQ(base::Int64ToString(display_id_secondary), result[1].id); 529 EXPECT_EQ(base::Int64ToString(display_id_secondary), result[1].id);
413 EXPECT_TRUE(result[1].mirroring_source_id.empty()); 530 EXPECT_TRUE(result[1].mirroring_source_id.empty());
414 } 531 }
415 532
416 TEST_F(DisplayInfoProviderChromeosTest, GetBounds) { 533 TEST_F(DisplayInfoProviderChromeosTest, GetBounds) {
417 UpdateDisplay("600x600, 400x520"); 534 UpdateDisplay("600x600, 400x520");
418 GetDisplayManager()->SetLayoutForCurrentDisplays( 535 GetDisplayManager()->SetLayoutForCurrentDisplays(
419 display::test::CreateDisplayLayout(display_manager(), 536 display::test::CreateDisplayLayout(display_manager(),
420 display::DisplayPlacement::LEFT, -40)); 537 display::DisplayPlacement::LEFT, -40));
421 538
422 DisplayUnitInfoList result = DisplayInfoProvider::Get()->GetAllDisplaysInfo(); 539 DisplayUnitInfoList result = GetAllDisplaysInfo();
423 540
424 ASSERT_EQ(2u, result.size()); 541 ASSERT_EQ(2u, result.size());
425 EXPECT_EQ("0,0 600x600", SystemInfoDisplayBoundsToString(result[0].bounds)); 542 EXPECT_EQ("0,0 600x600", SystemInfoDisplayBoundsToString(result[0].bounds));
426 EXPECT_EQ("-400,-40 400x520", 543 EXPECT_EQ("-400,-40 400x520",
427 SystemInfoDisplayBoundsToString(result[1].bounds)); 544 SystemInfoDisplayBoundsToString(result[1].bounds));
428 545
429 GetDisplayManager()->SetLayoutForCurrentDisplays( 546 GetDisplayManager()->SetLayoutForCurrentDisplays(
430 display::test::CreateDisplayLayout(display_manager(), 547 display::test::CreateDisplayLayout(display_manager(),
431 display::DisplayPlacement::TOP, 40)); 548 display::DisplayPlacement::TOP, 40));
432 549
433 result = DisplayInfoProvider::Get()->GetAllDisplaysInfo(); 550 result = GetAllDisplaysInfo();
434 551
435 ASSERT_EQ(2u, result.size()); 552 ASSERT_EQ(2u, result.size());
436 EXPECT_EQ("0,0 600x600", SystemInfoDisplayBoundsToString(result[0].bounds)); 553 EXPECT_EQ("0,0 600x600", SystemInfoDisplayBoundsToString(result[0].bounds));
437 EXPECT_EQ("40,-520 400x520", 554 EXPECT_EQ("40,-520 400x520",
438 SystemInfoDisplayBoundsToString(result[1].bounds)); 555 SystemInfoDisplayBoundsToString(result[1].bounds));
439 556
440 GetDisplayManager()->SetLayoutForCurrentDisplays( 557 GetDisplayManager()->SetLayoutForCurrentDisplays(
441 display::test::CreateDisplayLayout( 558 display::test::CreateDisplayLayout(
442 display_manager(), display::DisplayPlacement::BOTTOM, 80)); 559 display_manager(), display::DisplayPlacement::BOTTOM, 80));
443 560
444 result = DisplayInfoProvider::Get()->GetAllDisplaysInfo(); 561 result = GetAllDisplaysInfo();
445 ASSERT_EQ(2u, result.size()); 562 ASSERT_EQ(2u, result.size());
446 EXPECT_EQ("0,0 600x600", SystemInfoDisplayBoundsToString(result[0].bounds)); 563 EXPECT_EQ("0,0 600x600", SystemInfoDisplayBoundsToString(result[0].bounds));
447 EXPECT_EQ("80,600 400x520", 564 EXPECT_EQ("80,600 400x520",
448 SystemInfoDisplayBoundsToString(result[1].bounds)); 565 SystemInfoDisplayBoundsToString(result[1].bounds));
449 } 566 }
450 567
451 TEST_F(DisplayInfoProviderChromeosTest, Layout) { 568 TEST_F(DisplayInfoProviderChromeosTest, Layout) {
452 UpdateDisplay("500x400,500x400,500x400"); 569 UpdateDisplay("500x400,500x400,500x400");
453 570
454 DisplayUnitInfoList displays = 571 DisplayUnitInfoList displays = GetAllDisplaysInfo();
455 DisplayInfoProvider::Get()->GetAllDisplaysInfo();
456 std::string primary_id = displays[0].id; 572 std::string primary_id = displays[0].id;
457 ASSERT_EQ(3u, displays.size()); 573 ASSERT_EQ(3u, displays.size());
458 574
459 DisplayLayoutList layout = DisplayInfoProvider::Get()->GetDisplayLayout(); 575 DisplayLayoutList layout = DisplayInfoProvider::Get()->GetDisplayLayout();
460 576
461 ASSERT_EQ(2u, layout.size()); 577 ASSERT_EQ(2u, layout.size());
462 578
463 // Confirm layout. 579 // Confirm layout.
464 EXPECT_EQ(displays[1].id, layout[0].id); 580 EXPECT_EQ(displays[1].id, layout[0].id);
465 EXPECT_EQ(primary_id, layout[0].parent_id); 581 EXPECT_EQ(primary_id, layout[0].parent_id);
(...skipping 678 matching lines...) Expand 10 before | Expand all | Expand 10 after
1144 CallSetDisplayUnitInfo( 1260 CallSetDisplayUnitInfo(
1145 base::Int64ToString(internal_display_id), info, &success, &error); 1261 base::Int64ToString(internal_display_id), info, &success, &error);
1146 1262
1147 ASSERT_FALSE(success); 1263 ASSERT_FALSE(success);
1148 EXPECT_EQ("Overscan changes not allowed for the internal monitor.", error); 1264 EXPECT_EQ("Overscan changes not allowed for the internal monitor.", error);
1149 } 1265 }
1150 1266
1151 TEST_F(DisplayInfoProviderChromeosTest, DisplayMode) { 1267 TEST_F(DisplayInfoProviderChromeosTest, DisplayMode) {
1152 UpdateDisplay("1200x600,600x1000"); 1268 UpdateDisplay("1200x600,600x1000");
1153 1269
1154 DisplayUnitInfoList result = DisplayInfoProvider::Get()->GetAllDisplaysInfo(); 1270 DisplayUnitInfoList result = GetAllDisplaysInfo();
1155 ASSERT_GE(result.size(), 1u); 1271 ASSERT_GE(result.size(), 1u);
1156 const api::system_display::DisplayUnitInfo& primary_info = result[0]; 1272 const api::system_display::DisplayUnitInfo& primary_info = result[0];
1157 // Ensure that we have two modes for the primary display so that we can 1273 // Ensure that we have two modes for the primary display so that we can
1158 // test chaning modes. 1274 // test chaning modes.
1159 ASSERT_GE(primary_info.modes.size(), 2u); 1275 ASSERT_GE(primary_info.modes.size(), 2u);
1160 1276
1161 // Get the currently active mode and one other mode to switch to. 1277 // Get the currently active mode and one other mode to switch to.
1162 int64_t id; 1278 int64_t id;
1163 base::StringToInt64(primary_info.id, &id); 1279 base::StringToInt64(primary_info.id, &id);
1164 scoped_refptr<display::ManagedDisplayMode> active_mode = 1280 scoped_refptr<display::ManagedDisplayMode> active_mode =
(...skipping 278 matching lines...) Expand 10 before | Expand all | Expand 10 after
1443 EXPECT_EQ(pairs.pair1.touch_point.y, data.point_pairs[0].second.y()); 1559 EXPECT_EQ(pairs.pair1.touch_point.y, data.point_pairs[0].second.y());
1444 EXPECT_EQ(pairs.pair2.touch_point.y, data.point_pairs[1].second.y()); 1560 EXPECT_EQ(pairs.pair2.touch_point.y, data.point_pairs[1].second.y());
1445 EXPECT_EQ(pairs.pair3.touch_point.y, data.point_pairs[2].second.y()); 1561 EXPECT_EQ(pairs.pair3.touch_point.y, data.point_pairs[2].second.y());
1446 EXPECT_EQ(pairs.pair4.touch_point.y, data.point_pairs[3].second.y()); 1562 EXPECT_EQ(pairs.pair4.touch_point.y, data.point_pairs[3].second.y());
1447 1563
1448 EXPECT_EQ(bounds.width, data.bounds.width()); 1564 EXPECT_EQ(bounds.width, data.bounds.width());
1449 EXPECT_EQ(bounds.height, data.bounds.height()); 1565 EXPECT_EQ(bounds.height, data.bounds.height());
1450 } 1566 }
1451 } // namespace 1567 } // namespace
1452 } // namespace extensions 1568 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698