| OLD | NEW |
| 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 216 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 227 display_manager()->SetOverscanInsets( | 227 display_manager()->SetOverscanInsets( |
| 228 display2.id(), gfx::Insets(13, 12, 11, 10)); | 228 display2.id(), gfx::Insets(13, 12, 11, 10)); |
| 229 std::vector<gfx::Display> changed_displays = changed(); | 229 std::vector<gfx::Display> changed_displays = changed(); |
| 230 EXPECT_EQ(1u, changed_displays.size()); | 230 EXPECT_EQ(1u, changed_displays.size()); |
| 231 EXPECT_EQ(display2.id(), changed_displays[0].id()); | 231 EXPECT_EQ(display2.id(), changed_displays[0].id()); |
| 232 EXPECT_EQ("0,0 500x500", | 232 EXPECT_EQ("0,0 500x500", |
| 233 display_manager()->GetDisplayAt(0)->bounds_in_pixel().ToString()); | 233 display_manager()->GetDisplayAt(0)->bounds_in_pixel().ToString()); |
| 234 EXPECT_EQ("12,514 378x376", | 234 EXPECT_EQ("12,514 378x376", |
| 235 display_manager()->GetDisplayAt(1)->bounds_in_pixel().ToString()); | 235 display_manager()->GetDisplayAt(1)->bounds_in_pixel().ToString()); |
| 236 | 236 |
| 237 // Make sure that SetOverscanInsets() is idempotent. |
| 238 display_manager()->SetOverscanInsets(display1.id(), gfx::Insets()); |
| 239 display_manager()->SetOverscanInsets( |
| 240 display2.id(), gfx::Insets(13, 12, 11, 10)); |
| 241 EXPECT_EQ("0,0 500x500", |
| 242 display_manager()->GetDisplayAt(0)->bounds_in_pixel().ToString()); |
| 243 EXPECT_EQ("12,514 378x376", |
| 244 display_manager()->GetDisplayAt(1)->bounds_in_pixel().ToString()); |
| 245 |
| 237 display_manager()->SetOverscanInsets( | 246 display_manager()->SetOverscanInsets( |
| 238 display2.id(), gfx::Insets(10, 11, 12, 13)); | 247 display2.id(), gfx::Insets(10, 11, 12, 13)); |
| 239 EXPECT_EQ("0,0 500x500", | 248 EXPECT_EQ("0,0 500x500", |
| 240 display_manager()->GetDisplayAt(0)->bounds_in_pixel().ToString()); | 249 display_manager()->GetDisplayAt(0)->bounds_in_pixel().ToString()); |
| 241 EXPECT_EQ("11,511 376x378", | 250 EXPECT_EQ("11,511 376x378", |
| 242 display_manager()->GetDisplayAt(1)->bounds_in_pixel().ToString()); | 251 display_manager()->GetDisplayAt(1)->bounds_in_pixel().ToString()); |
| 243 | 252 |
| 244 // Recreate a new 2nd display. It won't apply the overscan inset because the | 253 // Recreate a new 2nd display. It won't apply the overscan inset because the |
| 245 // new display has a different ID. | 254 // new display has a different ID. |
| 246 UpdateDisplay("0+0-500x500"); | 255 UpdateDisplay("0+0-500x500"); |
| (...skipping 18 matching lines...) Expand all Loading... |
| 265 // HiDPI but overscan display. The specified insets size should be doubled. | 274 // HiDPI but overscan display. The specified insets size should be doubled. |
| 266 UpdateDisplay("0+0-500x500"); | 275 UpdateDisplay("0+0-500x500"); |
| 267 UpdateDisplay("0+0-500x500,0+501-400x400*2"); | 276 UpdateDisplay("0+0-500x500,0+501-400x400*2"); |
| 268 display_manager()->SetOverscanInsets( | 277 display_manager()->SetOverscanInsets( |
| 269 display_manager()->GetDisplayAt(1)->id(), gfx::Insets(4, 5, 6, 7)); | 278 display_manager()->GetDisplayAt(1)->id(), gfx::Insets(4, 5, 6, 7)); |
| 270 EXPECT_EQ("0,0 500x500", | 279 EXPECT_EQ("0,0 500x500", |
| 271 display_manager()->GetDisplayAt(0)->bounds_in_pixel().ToString()); | 280 display_manager()->GetDisplayAt(0)->bounds_in_pixel().ToString()); |
| 272 EXPECT_EQ("10,509 376x380", | 281 EXPECT_EQ("10,509 376x380", |
| 273 display_manager()->GetDisplayAt(1)->bounds_in_pixel().ToString()); | 282 display_manager()->GetDisplayAt(1)->bounds_in_pixel().ToString()); |
| 274 EXPECT_EQ("188x190", display_manager()->GetDisplayAt(1)->size().ToString()); | 283 EXPECT_EQ("188x190", display_manager()->GetDisplayAt(1)->size().ToString()); |
| 284 |
| 285 // Make sure switching primary display applies the overscan offset only once. |
| 286 ash::Shell::GetInstance()->display_controller()->SetPrimaryDisplay( |
| 287 ScreenAsh::GetSecondaryDisplay()); |
| 288 EXPECT_EQ("0,0 500x500", |
| 289 ScreenAsh::GetSecondaryDisplay().bounds_in_pixel().ToString()); |
| 290 EXPECT_EQ("10,509 376x380", gfx::Screen::GetNativeScreen()-> |
| 291 GetPrimaryDisplay().bounds_in_pixel().ToString()); |
| 275 } | 292 } |
| 276 | 293 |
| 277 TEST_F(DisplayManagerTest, MAYBE_ZeroOverscanInsets) { | 294 TEST_F(DisplayManagerTest, MAYBE_ZeroOverscanInsets) { |
| 278 // Make sure the display change events is emitted for overscan inset changes. | 295 // Make sure the display change events is emitted for overscan inset changes. |
| 279 UpdateDisplay("0+0-500x500,0+501-400x400"); | 296 UpdateDisplay("0+0-500x500,0+501-400x400"); |
| 280 ASSERT_EQ(2u, display_manager()->GetNumDisplays()); | 297 ASSERT_EQ(2u, display_manager()->GetNumDisplays()); |
| 281 int64 display2_id = display_manager()->GetDisplayAt(1)->id(); | 298 int64 display2_id = display_manager()->GetDisplayAt(1)->id(); |
| 282 | 299 |
| 283 reset(); | 300 reset(); |
| 284 display_manager()->SetOverscanInsets(display2_id, gfx::Insets(0, 0, 0, 0)); | 301 display_manager()->SetOverscanInsets(display2_id, gfx::Insets(0, 0, 0, 0)); |
| (...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 494 // OnNativeDisplaysChanged may change the display bounds. Here makes sure | 511 // OnNativeDisplaysChanged may change the display bounds. Here makes sure |
| 495 // nothing changed if the exactly same displays are specified. | 512 // nothing changed if the exactly same displays are specified. |
| 496 display_manager()->OnNativeDisplaysChanged(displays); | 513 display_manager()->OnNativeDisplaysChanged(displays); |
| 497 EXPECT_EQ("-500,0 500x500", | 514 EXPECT_EQ("-500,0 500x500", |
| 498 FindDisplayForId(internal_display_id).bounds().ToString()); | 515 FindDisplayForId(internal_display_id).bounds().ToString()); |
| 499 EXPECT_EQ("0,0 100x100", FindDisplayForId(10).bounds().ToString()); | 516 EXPECT_EQ("0,0 100x100", FindDisplayForId(10).bounds().ToString()); |
| 500 } | 517 } |
| 501 | 518 |
| 502 } // namespace internal | 519 } // namespace internal |
| 503 } // namespace ash | 520 } // namespace ash |
| OLD | NEW |