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

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

Issue 12746002: Re-implement overscan & Implement Display Rotation (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 7 years, 9 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 | Annotate | Revision Log
« no previous file with comments | « ash/display/display_manager.cc ('k') | ash/system/chromeos/tray_display.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) 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/display_manager.h" 5 #include "ash/display/display_manager.h"
6 6
7 #include "ash/display/display_controller.h" 7 #include "ash/display/display_controller.h"
8 #include "ash/screen_ash.h" 8 #include "ash/screen_ash.h"
9 #include "ash/shell.h" 9 #include "ash/shell.h"
10 #include "ash/test/ash_test_base.h" 10 #include "ash/test/ash_test_base.h"
(...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after
226 const DisplayInfo& display_info1 = GetDisplayInfoAt(0); 226 const DisplayInfo& display_info1 = GetDisplayInfoAt(0);
227 const DisplayInfo& display_info2 = GetDisplayInfoAt(1); 227 const DisplayInfo& display_info2 = GetDisplayInfoAt(1);
228 display_manager()->SetOverscanInsets( 228 display_manager()->SetOverscanInsets(
229 display_info2.id(), gfx::Insets(13, 12, 11, 10)); 229 display_info2.id(), gfx::Insets(13, 12, 11, 10));
230 230
231 std::vector<gfx::Display> changed_displays = changed(); 231 std::vector<gfx::Display> changed_displays = changed();
232 EXPECT_EQ(1u, changed_displays.size()); 232 EXPECT_EQ(1u, changed_displays.size());
233 EXPECT_EQ(display_info2.id(), changed_displays[0].id()); 233 EXPECT_EQ(display_info2.id(), changed_displays[0].id());
234 EXPECT_EQ("0,0 500x500", 234 EXPECT_EQ("0,0 500x500",
235 GetDisplayInfoAt(0).bounds_in_pixel().ToString()); 235 GetDisplayInfoAt(0).bounds_in_pixel().ToString());
236 EXPECT_EQ("12,514 378x376", 236 DisplayInfo updated_display_info2 = GetDisplayInfoAt(1);
237 GetDisplayInfoAt(1).bounds_in_pixel().ToString()); 237 EXPECT_EQ("0,501 400x400",
238 updated_display_info2.bounds_in_pixel().ToString());
239 EXPECT_EQ("378x376",
240 updated_display_info2.size_in_pixel().ToString());
241 EXPECT_EQ("13,12,11,10",
242 updated_display_info2.overscan_insets_in_dip().ToString());
243 EXPECT_EQ("500,0 378x376",
244 ScreenAsh::GetSecondaryDisplay().bounds().ToString());
238 245
239 // Make sure that SetOverscanInsets() is idempotent. 246 // Make sure that SetOverscanInsets() is idempotent.
240 display_manager()->SetOverscanInsets(display_info1.id(), gfx::Insets()); 247 display_manager()->SetOverscanInsets(display_info1.id(), gfx::Insets());
241 display_manager()->SetOverscanInsets( 248 display_manager()->SetOverscanInsets(
242 display_info2.id(), gfx::Insets(13, 12, 11, 10)); 249 display_info2.id(), gfx::Insets(13, 12, 11, 10));
243 EXPECT_EQ("0,0 500x500", 250 EXPECT_EQ("0,0 500x500",
244 GetDisplayInfoAt(0).bounds_in_pixel().ToString()); 251 GetDisplayInfoAt(0).bounds_in_pixel().ToString());
245 EXPECT_EQ("12,514 378x376", 252 updated_display_info2 = GetDisplayInfoAt(1);
246 GetDisplayInfoAt(1).bounds_in_pixel().ToString()); 253 EXPECT_EQ("0,501 400x400",
254 updated_display_info2.bounds_in_pixel().ToString());
255 EXPECT_EQ("378x376",
256 updated_display_info2.size_in_pixel().ToString());
257 EXPECT_EQ("13,12,11,10",
258 updated_display_info2.overscan_insets_in_dip().ToString());
247 259
248 display_manager()->SetOverscanInsets( 260 display_manager()->SetOverscanInsets(
249 display_info2.id(), gfx::Insets(10, 11, 12, 13)); 261 display_info2.id(), gfx::Insets(10, 11, 12, 13));
250 EXPECT_EQ("0,0 500x500", 262 EXPECT_EQ("0,0 500x500",
251 GetDisplayInfoAt(0).bounds_in_pixel().ToString()); 263 GetDisplayInfoAt(0).bounds_in_pixel().ToString());
252 EXPECT_EQ("11,511 376x378", 264 EXPECT_EQ("376x378",
253 GetDisplayInfoAt(1).bounds_in_pixel().ToString()); 265 GetDisplayInfoAt(1).size_in_pixel().ToString());
266 EXPECT_EQ("10,11,12,13",
267 GetDisplayInfoAt(1).overscan_insets_in_dip().ToString());
254 268
255 // Recreate a new 2nd display. It won't apply the overscan inset because the 269 // Recreate a new 2nd display. It won't apply the overscan inset because the
256 // new display has a different ID. 270 // new display has a different ID.
257 UpdateDisplay("0+0-500x500"); 271 UpdateDisplay("0+0-500x500");
258 UpdateDisplay("0+0-500x500,0+501-400x400"); 272 UpdateDisplay("0+0-500x500,0+501-400x400");
259 EXPECT_EQ("0,0 500x500", 273 EXPECT_EQ("0,0 500x500",
260 GetDisplayInfoAt(0).bounds_in_pixel().ToString()); 274 GetDisplayInfoAt(0).bounds_in_pixel().ToString());
261 EXPECT_EQ("0,501 400x400", 275 EXPECT_EQ("0,501 400x400",
262 GetDisplayInfoAt(1).bounds_in_pixel().ToString()); 276 GetDisplayInfoAt(1).bounds_in_pixel().ToString());
263 277
264 // Recreate the displays with the same ID. It should apply the overscan 278 // Recreate the displays with the same ID. It should apply the overscan
265 // inset. 279 // inset.
266 UpdateDisplay("0+0-500x500"); 280 UpdateDisplay("0+0-500x500");
267 std::vector<DisplayInfo> display_info_list; 281 std::vector<DisplayInfo> display_info_list;
268 display_info_list.push_back(display_info1); 282 display_info_list.push_back(display_info1);
269 display_info_list.push_back(display_info2); 283 display_info_list.push_back(display_info2);
270 display_manager()->OnNativeDisplaysChanged(display_info_list); 284 display_manager()->OnNativeDisplaysChanged(display_info_list);
271 EXPECT_EQ("1,1 500x500", 285 EXPECT_EQ("1,1 500x500",
272 GetDisplayInfoAt(0).bounds_in_pixel().ToString()); 286 GetDisplayInfoAt(0).bounds_in_pixel().ToString());
273 EXPECT_EQ("11,511 376x378", 287 updated_display_info2 = GetDisplayInfoAt(1);
274 GetDisplayInfoAt(1).bounds_in_pixel().ToString()); 288 EXPECT_EQ("376x378",
289 updated_display_info2.size_in_pixel().ToString());
290 EXPECT_EQ("10,11,12,13",
291 updated_display_info2.overscan_insets_in_dip().ToString());
275 292
276 // HiDPI but overscan display. The specified insets size should be doubled. 293 // HiDPI but overscan display. The specified insets size should be doubled.
277 UpdateDisplay("0+0-500x500,0+501-400x400*2"); 294 UpdateDisplay("0+0-500x500,0+501-400x400*2");
278 display_manager()->SetOverscanInsets( 295 display_manager()->SetOverscanInsets(
279 display_manager()->GetDisplayAt(1)->id(), gfx::Insets(4, 5, 6, 7)); 296 display_manager()->GetDisplayAt(1)->id(), gfx::Insets(4, 5, 6, 7));
280 EXPECT_EQ("0,0 500x500", 297 EXPECT_EQ("0,0 500x500",
281 GetDisplayInfoAt(0).bounds_in_pixel().ToString()); 298 GetDisplayInfoAt(0).bounds_in_pixel().ToString());
282 EXPECT_EQ("10,509 376x380", 299 updated_display_info2 = GetDisplayInfoAt(1);
283 GetDisplayInfoAt(1).bounds_in_pixel().ToString()); 300 EXPECT_EQ("0,501 400x400",
284 EXPECT_EQ("188x190", display_manager()->GetDisplayAt(1)->size().ToString()); 301 updated_display_info2.bounds_in_pixel().ToString());
302 EXPECT_EQ("376x380",
303 updated_display_info2.size_in_pixel().ToString());
304 EXPECT_EQ("4,5,6,7",
305 updated_display_info2.overscan_insets_in_dip().ToString());
306 EXPECT_EQ("8,10,12,14",
307 updated_display_info2.GetOverscanInsetsInPixel().ToString());
285 308
286 // Make sure switching primary display applies the overscan offset only once. 309 // Make sure switching primary display applies the overscan offset only once.
287 ash::Shell::GetInstance()->display_controller()->SetPrimaryDisplay( 310 ash::Shell::GetInstance()->display_controller()->SetPrimaryDisplay(
288 ScreenAsh::GetSecondaryDisplay()); 311 ScreenAsh::GetSecondaryDisplay());
312 EXPECT_EQ("-500,0 500x500",
313 ScreenAsh::GetSecondaryDisplay().bounds().ToString());
289 EXPECT_EQ("0,0 500x500", 314 EXPECT_EQ("0,0 500x500",
290 GetDisplayInfo(ScreenAsh::GetSecondaryDisplay()). 315 GetDisplayInfo(ScreenAsh::GetSecondaryDisplay()).
291 bounds_in_pixel().ToString()); 316 bounds_in_pixel().ToString());
292 EXPECT_EQ("10,509 376x380", 317 EXPECT_EQ("0,501 400x400",
293 GetDisplayInfo(gfx::Screen::GetNativeScreen()->GetPrimaryDisplay()). 318 GetDisplayInfo(Shell::GetScreen()->GetPrimaryDisplay()).
294 bounds_in_pixel().ToString()); 319 bounds_in_pixel().ToString());
320 EXPECT_EQ("0,0 188x190",
321 Shell::GetScreen()->GetPrimaryDisplay().bounds().ToString());
295 } 322 }
296 323
297 TEST_F(DisplayManagerTest, ZeroOverscanInsets) { 324 TEST_F(DisplayManagerTest, ZeroOverscanInsets) {
298 // Make sure the display change events is emitted for overscan inset changes. 325 // Make sure the display change events is emitted for overscan inset changes.
299 UpdateDisplay("0+0-500x500,0+501-400x400"); 326 UpdateDisplay("0+0-500x500,0+501-400x400");
300 ASSERT_EQ(2u, display_manager()->GetNumDisplays()); 327 ASSERT_EQ(2u, display_manager()->GetNumDisplays());
301 int64 display2_id = display_manager()->GetDisplayAt(1)->id(); 328 int64 display2_id = display_manager()->GetDisplayAt(1)->id();
302 329
303 reset(); 330 reset();
304 display_manager()->SetOverscanInsets(display2_id, gfx::Insets(0, 0, 0, 0)); 331 display_manager()->SetOverscanInsets(display2_id, gfx::Insets(0, 0, 0, 0));
(...skipping 252 matching lines...) Expand 10 before | Expand all | Expand 10 after
557 UpdateDisplay("200x200,400x400"); 584 UpdateDisplay("200x200,400x400");
558 585
559 std::vector<DisplayInfo> display_info_list; 586 std::vector<DisplayInfo> display_info_list;
560 display_info_list.push_back(GetDisplayInfoAt(0)); 587 display_info_list.push_back(GetDisplayInfoAt(0));
561 display_info_list.push_back(GetDisplayInfoAt(1)); 588 display_info_list.push_back(GetDisplayInfoAt(1));
562 display_info_list[1].set_has_overscan_for_test(true); 589 display_info_list[1].set_has_overscan_for_test(true);
563 int64 id = display_info_list[1].id(); 590 int64 id = display_info_list[1].id();
564 // SetDefaultOverscanInsets(&display_info_list[1]); 591 // SetDefaultOverscanInsets(&display_info_list[1]);
565 display_manager()->OnNativeDisplaysChanged(display_info_list); 592 display_manager()->OnNativeDisplaysChanged(display_info_list);
566 // It has overscan insets, although SetOverscanInsets() isn't called. 593 // It has overscan insets, although SetOverscanInsets() isn't called.
567 EXPECT_EQ("11,211 380x380", 594 EXPECT_EQ("380x380",
568 GetDisplayInfoAt(1).bounds_in_pixel().ToString()); 595 GetDisplayInfoAt(1).size_in_pixel().ToString());
569 596
570 // If custom overscan insets is specified, the specified value is used. 597 // If custom overscan insets is specified, the specified value is used.
571 display_manager()->SetOverscanInsets(id, gfx::Insets(5, 6, 7, 8)); 598 display_manager()->SetOverscanInsets(id, gfx::Insets(5, 6, 7, 8));
572 display_manager()->OnNativeDisplaysChanged(display_info_list); 599 display_manager()->OnNativeDisplaysChanged(display_info_list);
573 EXPECT_EQ("7,206 386x388", 600 EXPECT_EQ("386x388",
574 GetDisplayInfoAt(1).bounds_in_pixel().ToString()); 601 GetDisplayInfoAt(1).size_in_pixel().ToString());
575 602
576 // Do not overscan even though it has 'has_overscan' flag, if the custom 603 // Do not overscan even though it has 'has_overscan' flag, if the custom
577 // insets is empty. 604 // insets is empty.
578 display_manager()->SetOverscanInsets(id, gfx::Insets()); 605 display_manager()->SetOverscanInsets(id, gfx::Insets());
579 display_manager()->OnNativeDisplaysChanged(display_info_list); 606 display_manager()->OnNativeDisplaysChanged(display_info_list);
580 EXPECT_EQ("1,201 400x400", 607 EXPECT_EQ("400x400",
581 GetDisplayInfoAt(1).bounds_in_pixel().ToString()); 608 GetDisplayInfoAt(1).size_in_pixel().ToString());
582 609
583 // Clearing the custom overscan should set the bounds to 610 // Clearing the custom overscan should set the bounds to
584 // original. 611 // original.
585 display_manager()->ClearCustomOverscanInsets(id); 612 display_manager()->ClearCustomOverscanInsets(id);
586 EXPECT_EQ("11,211 380x380", 613 EXPECT_EQ("380x380",
614 GetDisplayInfoAt(1).size_in_pixel().ToString());
615 }
616
617 TEST_F(DisplayManagerTest, Rotate) {
618 UpdateDisplay("100x200/r,300x400/l");
619 EXPECT_EQ("1,1 100x200",
620 GetDisplayInfoAt(0).bounds_in_pixel().ToString());
621 EXPECT_EQ("200x100",
622 GetDisplayInfoAt(0).size_in_pixel().ToString());
623
624 EXPECT_EQ("1,201 300x400",
587 GetDisplayInfoAt(1).bounds_in_pixel().ToString()); 625 GetDisplayInfoAt(1).bounds_in_pixel().ToString());
626 EXPECT_EQ("400x300",
627 GetDisplayInfoAt(1).size_in_pixel().ToString());
628 UpdateDisplay("100x200/b,300x400");
629 EXPECT_EQ("1,1 100x200",
630 GetDisplayInfoAt(0).bounds_in_pixel().ToString());
631 EXPECT_EQ("100x200",
632 GetDisplayInfoAt(0).size_in_pixel().ToString());
633
634 EXPECT_EQ("1,201 300x400",
635 GetDisplayInfoAt(1).bounds_in_pixel().ToString());
636 EXPECT_EQ("300x400",
637 GetDisplayInfoAt(1).size_in_pixel().ToString());
588 } 638 }
589 639
590 } // namespace internal 640 } // namespace internal
591 } // namespace ash 641 } // namespace ash
OLDNEW
« no previous file with comments | « ash/display/display_manager.cc ('k') | ash/system/chromeos/tray_display.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698