| OLD | NEW |
| 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 "chrome/browser/extensions/api/system_display/display_info_provider.h" | 5 #include "extensions/browser/api/system_display/display_info_provider.h" |
| 6 | 6 |
| 7 #include "ash/display/display_controller.h" | 7 #include "ash/display/display_controller.h" |
| 8 #include "ash/display/display_manager.h" | 8 #include "ash/display/display_manager.h" |
| 9 #include "ash/screen_util.h" | 9 #include "ash/screen_util.h" |
| 10 #include "ash/shell.h" | 10 #include "ash/shell.h" |
| 11 #include "ash/test/ash_test_base.h" | 11 #include "ash/test/ash_test_base.h" |
| 12 #include "ash/test/display_manager_test_api.h" | 12 #include "ash/test/display_manager_test_api.h" |
| 13 #include "base/strings/string_number_conversions.h" | 13 #include "base/strings/string_number_conversions.h" |
| 14 #include "base/strings/stringprintf.h" | 14 #include "base/strings/stringprintf.h" |
| 15 #include "chrome/common/extensions/api/system_display.h" | 15 #include "extensions/common/api/system_display.h" |
| 16 #include "ui/gfx/display.h" | 16 #include "ui/gfx/display.h" |
| 17 #include "ui/gfx/rect.h" | 17 #include "ui/gfx/rect.h" |
| 18 | 18 |
| 19 namespace extensions { | 19 namespace extensions { |
| 20 namespace { | 20 namespace { |
| 21 | 21 |
| 22 class DisplayInfoProviderChromeosTest : public ash::test::AshTestBase { | 22 class DisplayInfoProviderChromeosTest : public ash::test::AshTestBase { |
| 23 public: | 23 public: |
| 24 DisplayInfoProviderChromeosTest() {} | 24 DisplayInfoProviderChromeosTest() {} |
| 25 | 25 |
| 26 virtual ~DisplayInfoProviderChromeosTest() {} | 26 virtual ~DisplayInfoProviderChromeosTest() {} |
| 27 | 27 |
| 28 protected: | 28 protected: |
| 29 void CallSetDisplayUnitInfo( | 29 void CallSetDisplayUnitInfo( |
| 30 const std::string& display_id, | 30 const std::string& display_id, |
| 31 const api::system_display::DisplayProperties& info, | 31 const core_api::system_display::DisplayProperties& info, |
| 32 bool* success, | 32 bool* success, |
| 33 std::string* error) { | 33 std::string* error) { |
| 34 // Reset error messsage. | 34 // Reset error messsage. |
| 35 (*error).clear(); | 35 (*error).clear(); |
| 36 *success = DisplayInfoProvider::Get()->SetInfo(display_id, info, error); | 36 *success = DisplayInfoProvider::Get()->SetInfo(display_id, info, error); |
| 37 } | 37 } |
| 38 | 38 |
| 39 bool DisplayExists(int64 display_id) const { | 39 bool DisplayExists(int64 display_id) const { |
| 40 const gfx::Display& display = | 40 const gfx::Display& display = |
| 41 GetDisplayManager()->GetDisplayForId(display_id); | 41 GetDisplayManager()->GetDisplayForId(display_id); |
| 42 return display.id() != gfx::Display::kInvalidDisplayID; | 42 return display.id() != gfx::Display::kInvalidDisplayID; |
| 43 } | 43 } |
| 44 | 44 |
| 45 ash::DisplayManager* GetDisplayManager() const { | 45 ash::DisplayManager* GetDisplayManager() const { |
| 46 return ash::Shell::GetInstance()->display_manager(); | 46 return ash::Shell::GetInstance()->display_manager(); |
| 47 } | 47 } |
| 48 | 48 |
| 49 ash::DisplayController* GetDisplayController() const { | 49 ash::DisplayController* GetDisplayController() const { |
| 50 return ash::Shell::GetInstance()->display_controller(); | 50 return ash::Shell::GetInstance()->display_controller(); |
| 51 } | 51 } |
| 52 | 52 |
| 53 std::string SystemInfoDisplayInsetsToString( | 53 std::string SystemInfoDisplayInsetsToString( |
| 54 const api::system_display::Insets& insets) const { | 54 const core_api::system_display::Insets& insets) const { |
| 55 // Order to match gfx::Insets::ToString(). | 55 // Order to match gfx::Insets::ToString(). |
| 56 return base::StringPrintf( | 56 return base::StringPrintf( |
| 57 "%d,%d,%d,%d", insets.top, insets.left, insets.bottom, insets.right); | 57 "%d,%d,%d,%d", insets.top, insets.left, insets.bottom, insets.right); |
| 58 } | 58 } |
| 59 | 59 |
| 60 std::string SystemInfoDisplayBoundsToString( | 60 std::string SystemInfoDisplayBoundsToString( |
| 61 const api::system_display::Bounds& bounds) const { | 61 const core_api::system_display::Bounds& bounds) const { |
| 62 // Order to match gfx::Rect::ToString(). | 62 // Order to match gfx::Rect::ToString(). |
| 63 return base::StringPrintf( | 63 return base::StringPrintf( |
| 64 "%d,%d %dx%d", bounds.left, bounds.top, bounds.width, bounds.height); | 64 "%d,%d %dx%d", bounds.left, bounds.top, bounds.width, bounds.height); |
| 65 } | 65 } |
| 66 | 66 |
| 67 private: | 67 private: |
| 68 DISALLOW_COPY_AND_ASSIGN(DisplayInfoProviderChromeosTest); | 68 DISALLOW_COPY_AND_ASSIGN(DisplayInfoProviderChromeosTest); |
| 69 }; | 69 }; |
| 70 | 70 |
| 71 TEST_F(DisplayInfoProviderChromeosTest, GetBasic) { | 71 TEST_F(DisplayInfoProviderChromeosTest, GetBasic) { |
| (...skipping 236 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 308 ASSERT_EQ(2u, result.size()); | 308 ASSERT_EQ(2u, result.size()); |
| 309 EXPECT_EQ("0,0 600x600", SystemInfoDisplayBoundsToString(result[0]->bounds)); | 309 EXPECT_EQ("0,0 600x600", SystemInfoDisplayBoundsToString(result[0]->bounds)); |
| 310 EXPECT_EQ("80,600 400x520", | 310 EXPECT_EQ("80,600 400x520", |
| 311 SystemInfoDisplayBoundsToString(result[1]->bounds)); | 311 SystemInfoDisplayBoundsToString(result[1]->bounds)); |
| 312 } | 312 } |
| 313 | 313 |
| 314 TEST_F(DisplayInfoProviderChromeosTest, SetBoundsOriginLeftExact) { | 314 TEST_F(DisplayInfoProviderChromeosTest, SetBoundsOriginLeftExact) { |
| 315 UpdateDisplay("1200x600,520x400"); | 315 UpdateDisplay("1200x600,520x400"); |
| 316 | 316 |
| 317 const gfx::Display& secondary = ash::ScreenUtil::GetSecondaryDisplay(); | 317 const gfx::Display& secondary = ash::ScreenUtil::GetSecondaryDisplay(); |
| 318 api::system_display::DisplayProperties info; | 318 core_api::system_display::DisplayProperties info; |
| 319 info.bounds_origin_x.reset(new int(-520)); | 319 info.bounds_origin_x.reset(new int(-520)); |
| 320 info.bounds_origin_y.reset(new int(50)); | 320 info.bounds_origin_y.reset(new int(50)); |
| 321 | 321 |
| 322 bool success = false; | 322 bool success = false; |
| 323 std::string error; | 323 std::string error; |
| 324 CallSetDisplayUnitInfo( | 324 CallSetDisplayUnitInfo( |
| 325 base::Int64ToString(secondary.id()), info, &success, &error); | 325 base::Int64ToString(secondary.id()), info, &success, &error); |
| 326 | 326 |
| 327 ASSERT_TRUE(success); | 327 ASSERT_TRUE(success); |
| 328 ASSERT_TRUE(error.empty()); | 328 ASSERT_TRUE(error.empty()); |
| 329 | 329 |
| 330 EXPECT_EQ("-520,50 520x400", secondary.bounds().ToString()); | 330 EXPECT_EQ("-520,50 520x400", secondary.bounds().ToString()); |
| 331 } | 331 } |
| 332 | 332 |
| 333 TEST_F(DisplayInfoProviderChromeosTest, SetBoundsOriginRightExact) { | 333 TEST_F(DisplayInfoProviderChromeosTest, SetBoundsOriginRightExact) { |
| 334 UpdateDisplay("1200x600,520x400"); | 334 UpdateDisplay("1200x600,520x400"); |
| 335 | 335 |
| 336 const gfx::Display& secondary = ash::ScreenUtil::GetSecondaryDisplay(); | 336 const gfx::Display& secondary = ash::ScreenUtil::GetSecondaryDisplay(); |
| 337 api::system_display::DisplayProperties info; | 337 core_api::system_display::DisplayProperties info; |
| 338 info.bounds_origin_x.reset(new int(1200)); | 338 info.bounds_origin_x.reset(new int(1200)); |
| 339 info.bounds_origin_y.reset(new int(100)); | 339 info.bounds_origin_y.reset(new int(100)); |
| 340 | 340 |
| 341 bool success = false; | 341 bool success = false; |
| 342 std::string error; | 342 std::string error; |
| 343 CallSetDisplayUnitInfo( | 343 CallSetDisplayUnitInfo( |
| 344 base::Int64ToString(secondary.id()), info, &success, &error); | 344 base::Int64ToString(secondary.id()), info, &success, &error); |
| 345 | 345 |
| 346 ASSERT_TRUE(success); | 346 ASSERT_TRUE(success); |
| 347 ASSERT_TRUE(error.empty()); | 347 ASSERT_TRUE(error.empty()); |
| 348 | 348 |
| 349 EXPECT_EQ("1200,100 520x400", secondary.bounds().ToString()); | 349 EXPECT_EQ("1200,100 520x400", secondary.bounds().ToString()); |
| 350 } | 350 } |
| 351 | 351 |
| 352 TEST_F(DisplayInfoProviderChromeosTest, SetBoundsOriginTopExact) { | 352 TEST_F(DisplayInfoProviderChromeosTest, SetBoundsOriginTopExact) { |
| 353 UpdateDisplay("1200x600,520x400"); | 353 UpdateDisplay("1200x600,520x400"); |
| 354 | 354 |
| 355 const gfx::Display& secondary = ash::ScreenUtil::GetSecondaryDisplay(); | 355 const gfx::Display& secondary = ash::ScreenUtil::GetSecondaryDisplay(); |
| 356 api::system_display::DisplayProperties info; | 356 core_api::system_display::DisplayProperties info; |
| 357 info.bounds_origin_x.reset(new int(1100)); | 357 info.bounds_origin_x.reset(new int(1100)); |
| 358 info.bounds_origin_y.reset(new int(-400)); | 358 info.bounds_origin_y.reset(new int(-400)); |
| 359 | 359 |
| 360 bool success = false; | 360 bool success = false; |
| 361 std::string error; | 361 std::string error; |
| 362 CallSetDisplayUnitInfo( | 362 CallSetDisplayUnitInfo( |
| 363 base::Int64ToString(secondary.id()), info, &success, &error); | 363 base::Int64ToString(secondary.id()), info, &success, &error); |
| 364 | 364 |
| 365 ASSERT_TRUE(success); | 365 ASSERT_TRUE(success); |
| 366 ASSERT_TRUE(error.empty()); | 366 ASSERT_TRUE(error.empty()); |
| 367 | 367 |
| 368 EXPECT_EQ("1100,-400 520x400", secondary.bounds().ToString()); | 368 EXPECT_EQ("1100,-400 520x400", secondary.bounds().ToString()); |
| 369 } | 369 } |
| 370 | 370 |
| 371 TEST_F(DisplayInfoProviderChromeosTest, SetBoundsOriginBottomExact) { | 371 TEST_F(DisplayInfoProviderChromeosTest, SetBoundsOriginBottomExact) { |
| 372 UpdateDisplay("1200x600,520x400"); | 372 UpdateDisplay("1200x600,520x400"); |
| 373 | 373 |
| 374 const gfx::Display& secondary = ash::ScreenUtil::GetSecondaryDisplay(); | 374 const gfx::Display& secondary = ash::ScreenUtil::GetSecondaryDisplay(); |
| 375 api::system_display::DisplayProperties info; | 375 core_api::system_display::DisplayProperties info; |
| 376 info.bounds_origin_x.reset(new int(-350)); | 376 info.bounds_origin_x.reset(new int(-350)); |
| 377 info.bounds_origin_y.reset(new int(600)); | 377 info.bounds_origin_y.reset(new int(600)); |
| 378 | 378 |
| 379 bool success = false; | 379 bool success = false; |
| 380 std::string error; | 380 std::string error; |
| 381 CallSetDisplayUnitInfo( | 381 CallSetDisplayUnitInfo( |
| 382 base::Int64ToString(secondary.id()), info, &success, &error); | 382 base::Int64ToString(secondary.id()), info, &success, &error); |
| 383 | 383 |
| 384 ASSERT_TRUE(success); | 384 ASSERT_TRUE(success); |
| 385 ASSERT_TRUE(error.empty()); | 385 ASSERT_TRUE(error.empty()); |
| 386 | 386 |
| 387 EXPECT_EQ("-350,600 520x400", secondary.bounds().ToString()); | 387 EXPECT_EQ("-350,600 520x400", secondary.bounds().ToString()); |
| 388 } | 388 } |
| 389 | 389 |
| 390 TEST_F(DisplayInfoProviderChromeosTest, SetBoundsOriginSameCenter) { | 390 TEST_F(DisplayInfoProviderChromeosTest, SetBoundsOriginSameCenter) { |
| 391 UpdateDisplay("1200x600,520x400"); | 391 UpdateDisplay("1200x600,520x400"); |
| 392 | 392 |
| 393 const gfx::Display& secondary = ash::ScreenUtil::GetSecondaryDisplay(); | 393 const gfx::Display& secondary = ash::ScreenUtil::GetSecondaryDisplay(); |
| 394 api::system_display::DisplayProperties info; | 394 core_api::system_display::DisplayProperties info; |
| 395 info.bounds_origin_x.reset(new int(340)); | 395 info.bounds_origin_x.reset(new int(340)); |
| 396 info.bounds_origin_y.reset(new int(100)); | 396 info.bounds_origin_y.reset(new int(100)); |
| 397 | 397 |
| 398 bool success = false; | 398 bool success = false; |
| 399 std::string error; | 399 std::string error; |
| 400 CallSetDisplayUnitInfo( | 400 CallSetDisplayUnitInfo( |
| 401 base::Int64ToString(secondary.id()), info, &success, &error); | 401 base::Int64ToString(secondary.id()), info, &success, &error); |
| 402 | 402 |
| 403 ASSERT_TRUE(success); | 403 ASSERT_TRUE(success); |
| 404 ASSERT_TRUE(error.empty()); | 404 ASSERT_TRUE(error.empty()); |
| 405 | 405 |
| 406 EXPECT_EQ("1200,100 520x400", secondary.bounds().ToString()); | 406 EXPECT_EQ("1200,100 520x400", secondary.bounds().ToString()); |
| 407 } | 407 } |
| 408 | 408 |
| 409 TEST_F(DisplayInfoProviderChromeosTest, SetBoundsOriginLeftOutside) { | 409 TEST_F(DisplayInfoProviderChromeosTest, SetBoundsOriginLeftOutside) { |
| 410 UpdateDisplay("1200x600,520x400"); | 410 UpdateDisplay("1200x600,520x400"); |
| 411 | 411 |
| 412 const gfx::Display& secondary = ash::ScreenUtil::GetSecondaryDisplay(); | 412 const gfx::Display& secondary = ash::ScreenUtil::GetSecondaryDisplay(); |
| 413 api::system_display::DisplayProperties info; | 413 core_api::system_display::DisplayProperties info; |
| 414 info.bounds_origin_x.reset(new int(-1040)); | 414 info.bounds_origin_x.reset(new int(-1040)); |
| 415 info.bounds_origin_y.reset(new int(100)); | 415 info.bounds_origin_y.reset(new int(100)); |
| 416 | 416 |
| 417 bool success = false; | 417 bool success = false; |
| 418 std::string error; | 418 std::string error; |
| 419 CallSetDisplayUnitInfo( | 419 CallSetDisplayUnitInfo( |
| 420 base::Int64ToString(secondary.id()), info, &success, &error); | 420 base::Int64ToString(secondary.id()), info, &success, &error); |
| 421 | 421 |
| 422 ASSERT_TRUE(success); | 422 ASSERT_TRUE(success); |
| 423 ASSERT_TRUE(error.empty()); | 423 ASSERT_TRUE(error.empty()); |
| 424 | 424 |
| 425 EXPECT_EQ("-520,100 520x400", secondary.bounds().ToString()); | 425 EXPECT_EQ("-520,100 520x400", secondary.bounds().ToString()); |
| 426 } | 426 } |
| 427 | 427 |
| 428 TEST_F(DisplayInfoProviderChromeosTest, SetBoundsOriginTopOutside) { | 428 TEST_F(DisplayInfoProviderChromeosTest, SetBoundsOriginTopOutside) { |
| 429 UpdateDisplay("1200x600,520x400"); | 429 UpdateDisplay("1200x600,520x400"); |
| 430 | 430 |
| 431 const gfx::Display& secondary = ash::ScreenUtil::GetSecondaryDisplay(); | 431 const gfx::Display& secondary = ash::ScreenUtil::GetSecondaryDisplay(); |
| 432 api::system_display::DisplayProperties info; | 432 core_api::system_display::DisplayProperties info; |
| 433 info.bounds_origin_x.reset(new int(-360)); | 433 info.bounds_origin_x.reset(new int(-360)); |
| 434 info.bounds_origin_y.reset(new int(-301)); | 434 info.bounds_origin_y.reset(new int(-301)); |
| 435 | 435 |
| 436 bool success = false; | 436 bool success = false; |
| 437 std::string error; | 437 std::string error; |
| 438 CallSetDisplayUnitInfo( | 438 CallSetDisplayUnitInfo( |
| 439 base::Int64ToString(secondary.id()), info, &success, &error); | 439 base::Int64ToString(secondary.id()), info, &success, &error); |
| 440 | 440 |
| 441 ASSERT_TRUE(success); | 441 ASSERT_TRUE(success); |
| 442 ASSERT_TRUE(error.empty()); | 442 ASSERT_TRUE(error.empty()); |
| 443 | 443 |
| 444 EXPECT_EQ("-360,-400 520x400", secondary.bounds().ToString()); | 444 EXPECT_EQ("-360,-400 520x400", secondary.bounds().ToString()); |
| 445 } | 445 } |
| 446 | 446 |
| 447 TEST_F(DisplayInfoProviderChromeosTest, | 447 TEST_F(DisplayInfoProviderChromeosTest, |
| 448 SetBoundsOriginLeftButSharesBottomSide) { | 448 SetBoundsOriginLeftButSharesBottomSide) { |
| 449 UpdateDisplay("1200x600,1000x100"); | 449 UpdateDisplay("1200x600,1000x100"); |
| 450 | 450 |
| 451 const gfx::Display& secondary = ash::ScreenUtil::GetSecondaryDisplay(); | 451 const gfx::Display& secondary = ash::ScreenUtil::GetSecondaryDisplay(); |
| 452 api::system_display::DisplayProperties info; | 452 core_api::system_display::DisplayProperties info; |
| 453 info.bounds_origin_x.reset(new int(-650)); | 453 info.bounds_origin_x.reset(new int(-650)); |
| 454 info.bounds_origin_y.reset(new int(700)); | 454 info.bounds_origin_y.reset(new int(700)); |
| 455 | 455 |
| 456 bool success = false; | 456 bool success = false; |
| 457 std::string error; | 457 std::string error; |
| 458 CallSetDisplayUnitInfo( | 458 CallSetDisplayUnitInfo( |
| 459 base::Int64ToString(secondary.id()), info, &success, &error); | 459 base::Int64ToString(secondary.id()), info, &success, &error); |
| 460 | 460 |
| 461 ASSERT_TRUE(success); | 461 ASSERT_TRUE(success); |
| 462 ASSERT_TRUE(error.empty()); | 462 ASSERT_TRUE(error.empty()); |
| 463 | 463 |
| 464 EXPECT_EQ("-650,600 1000x100", secondary.bounds().ToString()); | 464 EXPECT_EQ("-650,600 1000x100", secondary.bounds().ToString()); |
| 465 } | 465 } |
| 466 | 466 |
| 467 TEST_F(DisplayInfoProviderChromeosTest, SetBoundsOriginRightButSharesTopSide) { | 467 TEST_F(DisplayInfoProviderChromeosTest, SetBoundsOriginRightButSharesTopSide) { |
| 468 UpdateDisplay("1200x600,1000x100"); | 468 UpdateDisplay("1200x600,1000x100"); |
| 469 | 469 |
| 470 const gfx::Display& secondary = ash::ScreenUtil::GetSecondaryDisplay(); | 470 const gfx::Display& secondary = ash::ScreenUtil::GetSecondaryDisplay(); |
| 471 api::system_display::DisplayProperties info; | 471 core_api::system_display::DisplayProperties info; |
| 472 info.bounds_origin_x.reset(new int(850)); | 472 info.bounds_origin_x.reset(new int(850)); |
| 473 info.bounds_origin_y.reset(new int(-150)); | 473 info.bounds_origin_y.reset(new int(-150)); |
| 474 | 474 |
| 475 bool success = false; | 475 bool success = false; |
| 476 std::string error; | 476 std::string error; |
| 477 CallSetDisplayUnitInfo( | 477 CallSetDisplayUnitInfo( |
| 478 base::Int64ToString(secondary.id()), info, &success, &error); | 478 base::Int64ToString(secondary.id()), info, &success, &error); |
| 479 | 479 |
| 480 ASSERT_TRUE(success); | 480 ASSERT_TRUE(success); |
| 481 ASSERT_TRUE(error.empty()); | 481 ASSERT_TRUE(error.empty()); |
| 482 | 482 |
| 483 EXPECT_EQ("850,-100 1000x100", secondary.bounds().ToString()); | 483 EXPECT_EQ("850,-100 1000x100", secondary.bounds().ToString()); |
| 484 } | 484 } |
| 485 | 485 |
| 486 TEST_F(DisplayInfoProviderChromeosTest, SetBoundsOriginTopButSharesLeftSide) { | 486 TEST_F(DisplayInfoProviderChromeosTest, SetBoundsOriginTopButSharesLeftSide) { |
| 487 UpdateDisplay("1200x600,1000x100/l"); | 487 UpdateDisplay("1200x600,1000x100/l"); |
| 488 | 488 |
| 489 const gfx::Display& secondary = ash::ScreenUtil::GetSecondaryDisplay(); | 489 const gfx::Display& secondary = ash::ScreenUtil::GetSecondaryDisplay(); |
| 490 api::system_display::DisplayProperties info; | 490 core_api::system_display::DisplayProperties info; |
| 491 info.bounds_origin_x.reset(new int(-150)); | 491 info.bounds_origin_x.reset(new int(-150)); |
| 492 info.bounds_origin_y.reset(new int(-650)); | 492 info.bounds_origin_y.reset(new int(-650)); |
| 493 | 493 |
| 494 bool success = false; | 494 bool success = false; |
| 495 std::string error; | 495 std::string error; |
| 496 CallSetDisplayUnitInfo( | 496 CallSetDisplayUnitInfo( |
| 497 base::Int64ToString(secondary.id()), info, &success, &error); | 497 base::Int64ToString(secondary.id()), info, &success, &error); |
| 498 | 498 |
| 499 ASSERT_TRUE(success); | 499 ASSERT_TRUE(success); |
| 500 ASSERT_TRUE(error.empty()); | 500 ASSERT_TRUE(error.empty()); |
| 501 | 501 |
| 502 EXPECT_EQ("-100,-650 100x1000", secondary.bounds().ToString()); | 502 EXPECT_EQ("-100,-650 100x1000", secondary.bounds().ToString()); |
| 503 } | 503 } |
| 504 | 504 |
| 505 TEST_F(DisplayInfoProviderChromeosTest, | 505 TEST_F(DisplayInfoProviderChromeosTest, |
| 506 SetBoundsOriginBottomButSharesRightSide) { | 506 SetBoundsOriginBottomButSharesRightSide) { |
| 507 UpdateDisplay("1200x600,1000x100/l"); | 507 UpdateDisplay("1200x600,1000x100/l"); |
| 508 | 508 |
| 509 const gfx::Display& secondary = ash::ScreenUtil::GetSecondaryDisplay(); | 509 const gfx::Display& secondary = ash::ScreenUtil::GetSecondaryDisplay(); |
| 510 api::system_display::DisplayProperties info; | 510 core_api::system_display::DisplayProperties info; |
| 511 info.bounds_origin_x.reset(new int(1350)); | 511 info.bounds_origin_x.reset(new int(1350)); |
| 512 info.bounds_origin_y.reset(new int(450)); | 512 info.bounds_origin_y.reset(new int(450)); |
| 513 | 513 |
| 514 bool success = false; | 514 bool success = false; |
| 515 std::string error; | 515 std::string error; |
| 516 CallSetDisplayUnitInfo( | 516 CallSetDisplayUnitInfo( |
| 517 base::Int64ToString(secondary.id()), info, &success, &error); | 517 base::Int64ToString(secondary.id()), info, &success, &error); |
| 518 | 518 |
| 519 ASSERT_TRUE(success); | 519 ASSERT_TRUE(success); |
| 520 ASSERT_TRUE(error.empty()); | 520 ASSERT_TRUE(error.empty()); |
| 521 | 521 |
| 522 EXPECT_EQ("1200,450 100x1000", secondary.bounds().ToString()); | 522 EXPECT_EQ("1200,450 100x1000", secondary.bounds().ToString()); |
| 523 } | 523 } |
| 524 | 524 |
| 525 TEST_F(DisplayInfoProviderChromeosTest, SetBoundsOriginPrimaryHiDPI) { | 525 TEST_F(DisplayInfoProviderChromeosTest, SetBoundsOriginPrimaryHiDPI) { |
| 526 UpdateDisplay("1200x600*2,500x500"); | 526 UpdateDisplay("1200x600*2,500x500"); |
| 527 | 527 |
| 528 const gfx::Display& secondary = ash::ScreenUtil::GetSecondaryDisplay(); | 528 const gfx::Display& secondary = ash::ScreenUtil::GetSecondaryDisplay(); |
| 529 api::system_display::DisplayProperties info; | 529 core_api::system_display::DisplayProperties info; |
| 530 info.bounds_origin_x.reset(new int(250)); | 530 info.bounds_origin_x.reset(new int(250)); |
| 531 info.bounds_origin_y.reset(new int(-100)); | 531 info.bounds_origin_y.reset(new int(-100)); |
| 532 | 532 |
| 533 bool success = false; | 533 bool success = false; |
| 534 std::string error; | 534 std::string error; |
| 535 CallSetDisplayUnitInfo( | 535 CallSetDisplayUnitInfo( |
| 536 base::Int64ToString(secondary.id()), info, &success, &error); | 536 base::Int64ToString(secondary.id()), info, &success, &error); |
| 537 | 537 |
| 538 ASSERT_TRUE(success); | 538 ASSERT_TRUE(success); |
| 539 ASSERT_TRUE(error.empty()); | 539 ASSERT_TRUE(error.empty()); |
| 540 | 540 |
| 541 EXPECT_EQ("600,-100 500x500", secondary.bounds().ToString()); | 541 EXPECT_EQ("600,-100 500x500", secondary.bounds().ToString()); |
| 542 } | 542 } |
| 543 | 543 |
| 544 TEST_F(DisplayInfoProviderChromeosTest, SetBoundsOriginSecondaryHiDPI) { | 544 TEST_F(DisplayInfoProviderChromeosTest, SetBoundsOriginSecondaryHiDPI) { |
| 545 UpdateDisplay("1200x600,600x1000*2"); | 545 UpdateDisplay("1200x600,600x1000*2"); |
| 546 | 546 |
| 547 const gfx::Display& secondary = ash::ScreenUtil::GetSecondaryDisplay(); | 547 const gfx::Display& secondary = ash::ScreenUtil::GetSecondaryDisplay(); |
| 548 api::system_display::DisplayProperties info; | 548 core_api::system_display::DisplayProperties info; |
| 549 info.bounds_origin_x.reset(new int(450)); | 549 info.bounds_origin_x.reset(new int(450)); |
| 550 info.bounds_origin_y.reset(new int(-100)); | 550 info.bounds_origin_y.reset(new int(-100)); |
| 551 | 551 |
| 552 bool success = false; | 552 bool success = false; |
| 553 std::string error; | 553 std::string error; |
| 554 CallSetDisplayUnitInfo( | 554 CallSetDisplayUnitInfo( |
| 555 base::Int64ToString(secondary.id()), info, &success, &error); | 555 base::Int64ToString(secondary.id()), info, &success, &error); |
| 556 | 556 |
| 557 ASSERT_TRUE(success); | 557 ASSERT_TRUE(success); |
| 558 ASSERT_TRUE(error.empty()); | 558 ASSERT_TRUE(error.empty()); |
| 559 | 559 |
| 560 EXPECT_EQ("450,-500 300x500", secondary.bounds().ToString()); | 560 EXPECT_EQ("450,-500 300x500", secondary.bounds().ToString()); |
| 561 } | 561 } |
| 562 | 562 |
| 563 TEST_F(DisplayInfoProviderChromeosTest, SetBoundsOriginOutOfBounds) { | 563 TEST_F(DisplayInfoProviderChromeosTest, SetBoundsOriginOutOfBounds) { |
| 564 UpdateDisplay("1200x600,600x1000*2"); | 564 UpdateDisplay("1200x600,600x1000*2"); |
| 565 | 565 |
| 566 const gfx::Display& secondary = ash::ScreenUtil::GetSecondaryDisplay(); | 566 const gfx::Display& secondary = ash::ScreenUtil::GetSecondaryDisplay(); |
| 567 api::system_display::DisplayProperties info; | 567 core_api::system_display::DisplayProperties info; |
| 568 info.bounds_origin_x.reset(new int(0x200001)); | 568 info.bounds_origin_x.reset(new int(0x200001)); |
| 569 info.bounds_origin_y.reset(new int(-100)); | 569 info.bounds_origin_y.reset(new int(-100)); |
| 570 | 570 |
| 571 bool success = false; | 571 bool success = false; |
| 572 std::string error; | 572 std::string error; |
| 573 CallSetDisplayUnitInfo( | 573 CallSetDisplayUnitInfo( |
| 574 base::Int64ToString(secondary.id()), info, &success, &error); | 574 base::Int64ToString(secondary.id()), info, &success, &error); |
| 575 | 575 |
| 576 ASSERT_FALSE(success); | 576 ASSERT_FALSE(success); |
| 577 ASSERT_EQ("Bounds origin x out of bounds.", error); | 577 ASSERT_EQ("Bounds origin x out of bounds.", error); |
| 578 | 578 |
| 579 EXPECT_EQ("1200,0 300x500", secondary.bounds().ToString()); | 579 EXPECT_EQ("1200,0 300x500", secondary.bounds().ToString()); |
| 580 } | 580 } |
| 581 | 581 |
| 582 TEST_F(DisplayInfoProviderChromeosTest, SetBoundsOriginOutOfBoundsNegative) { | 582 TEST_F(DisplayInfoProviderChromeosTest, SetBoundsOriginOutOfBoundsNegative) { |
| 583 UpdateDisplay("1200x600,600x1000*2"); | 583 UpdateDisplay("1200x600,600x1000*2"); |
| 584 | 584 |
| 585 const gfx::Display& secondary = ash::ScreenUtil::GetSecondaryDisplay(); | 585 const gfx::Display& secondary = ash::ScreenUtil::GetSecondaryDisplay(); |
| 586 api::system_display::DisplayProperties info; | 586 core_api::system_display::DisplayProperties info; |
| 587 info.bounds_origin_x.reset(new int(300)); | 587 info.bounds_origin_x.reset(new int(300)); |
| 588 info.bounds_origin_y.reset(new int(-0x200001)); | 588 info.bounds_origin_y.reset(new int(-0x200001)); |
| 589 | 589 |
| 590 bool success = false; | 590 bool success = false; |
| 591 std::string error; | 591 std::string error; |
| 592 CallSetDisplayUnitInfo( | 592 CallSetDisplayUnitInfo( |
| 593 base::Int64ToString(secondary.id()), info, &success, &error); | 593 base::Int64ToString(secondary.id()), info, &success, &error); |
| 594 | 594 |
| 595 ASSERT_FALSE(success); | 595 ASSERT_FALSE(success); |
| 596 ASSERT_EQ("Bounds origin y out of bounds.", error); | 596 ASSERT_EQ("Bounds origin y out of bounds.", error); |
| 597 | 597 |
| 598 EXPECT_EQ("1200,0 300x500", secondary.bounds().ToString()); | 598 EXPECT_EQ("1200,0 300x500", secondary.bounds().ToString()); |
| 599 } | 599 } |
| 600 | 600 |
| 601 TEST_F(DisplayInfoProviderChromeosTest, SetBoundsOriginMaxValues) { | 601 TEST_F(DisplayInfoProviderChromeosTest, SetBoundsOriginMaxValues) { |
| 602 UpdateDisplay("1200x4600,600x1000*2"); | 602 UpdateDisplay("1200x4600,600x1000*2"); |
| 603 | 603 |
| 604 const gfx::Display& secondary = ash::ScreenUtil::GetSecondaryDisplay(); | 604 const gfx::Display& secondary = ash::ScreenUtil::GetSecondaryDisplay(); |
| 605 api::system_display::DisplayProperties info; | 605 core_api::system_display::DisplayProperties info; |
| 606 info.bounds_origin_x.reset(new int(200000)); | 606 info.bounds_origin_x.reset(new int(200000)); |
| 607 info.bounds_origin_y.reset(new int(10)); | 607 info.bounds_origin_y.reset(new int(10)); |
| 608 | 608 |
| 609 bool success = false; | 609 bool success = false; |
| 610 std::string error; | 610 std::string error; |
| 611 CallSetDisplayUnitInfo( | 611 CallSetDisplayUnitInfo( |
| 612 base::Int64ToString(secondary.id()), info, &success, &error); | 612 base::Int64ToString(secondary.id()), info, &success, &error); |
| 613 | 613 |
| 614 ASSERT_TRUE(success); | 614 ASSERT_TRUE(success); |
| 615 EXPECT_TRUE(error.empty()); | 615 EXPECT_TRUE(error.empty()); |
| 616 | 616 |
| 617 EXPECT_EQ("1200,10 300x500", secondary.bounds().ToString()); | 617 EXPECT_EQ("1200,10 300x500", secondary.bounds().ToString()); |
| 618 } | 618 } |
| 619 | 619 |
| 620 TEST_F(DisplayInfoProviderChromeosTest, SetBoundsOriginOnPrimary) { | 620 TEST_F(DisplayInfoProviderChromeosTest, SetBoundsOriginOnPrimary) { |
| 621 UpdateDisplay("1200x600,600x1000*2"); | 621 UpdateDisplay("1200x600,600x1000*2"); |
| 622 | 622 |
| 623 const gfx::Display& secondary = ash::ScreenUtil::GetSecondaryDisplay(); | 623 const gfx::Display& secondary = ash::ScreenUtil::GetSecondaryDisplay(); |
| 624 api::system_display::DisplayProperties info; | 624 core_api::system_display::DisplayProperties info; |
| 625 info.bounds_origin_x.reset(new int(300)); | 625 info.bounds_origin_x.reset(new int(300)); |
| 626 info.is_primary.reset(new bool(true)); | 626 info.is_primary.reset(new bool(true)); |
| 627 | 627 |
| 628 bool success = false; | 628 bool success = false; |
| 629 std::string error; | 629 std::string error; |
| 630 CallSetDisplayUnitInfo( | 630 CallSetDisplayUnitInfo( |
| 631 base::Int64ToString(secondary.id()), info, &success, &error); | 631 base::Int64ToString(secondary.id()), info, &success, &error); |
| 632 | 632 |
| 633 ASSERT_FALSE(success); | 633 ASSERT_FALSE(success); |
| 634 ASSERT_EQ("Bounds origin not allowed for the primary display.", error); | 634 ASSERT_EQ("Bounds origin not allowed for the primary display.", error); |
| 635 | 635 |
| 636 EXPECT_EQ("1200,0 300x500", secondary.bounds().ToString()); | 636 EXPECT_EQ("1200,0 300x500", secondary.bounds().ToString()); |
| 637 // The operation failed because the primary property would be set before | 637 // The operation failed because the primary property would be set before |
| 638 // setting bounds. The primary display shouldn't have been changed, though. | 638 // setting bounds. The primary display shouldn't have been changed, though. |
| 639 EXPECT_NE(ash::Shell::GetScreen()->GetPrimaryDisplay().id(), secondary.id()); | 639 EXPECT_NE(ash::Shell::GetScreen()->GetPrimaryDisplay().id(), secondary.id()); |
| 640 } | 640 } |
| 641 | 641 |
| 642 TEST_F(DisplayInfoProviderChromeosTest, SetBoundsOriginWithMirroring) { | 642 TEST_F(DisplayInfoProviderChromeosTest, SetBoundsOriginWithMirroring) { |
| 643 UpdateDisplay("1200x600,600x1000*2"); | 643 UpdateDisplay("1200x600,600x1000*2"); |
| 644 | 644 |
| 645 const gfx::Display& secondary = ash::ScreenUtil::GetSecondaryDisplay(); | 645 const gfx::Display& secondary = ash::ScreenUtil::GetSecondaryDisplay(); |
| 646 const gfx::Display& primary = ash::Shell::GetScreen()->GetPrimaryDisplay(); | 646 const gfx::Display& primary = ash::Shell::GetScreen()->GetPrimaryDisplay(); |
| 647 | 647 |
| 648 api::system_display::DisplayProperties info; | 648 core_api::system_display::DisplayProperties info; |
| 649 info.bounds_origin_x.reset(new int(300)); | 649 info.bounds_origin_x.reset(new int(300)); |
| 650 info.mirroring_source_id.reset( | 650 info.mirroring_source_id.reset( |
| 651 new std::string(base::Int64ToString(primary.id()))); | 651 new std::string(base::Int64ToString(primary.id()))); |
| 652 | 652 |
| 653 bool success = false; | 653 bool success = false; |
| 654 std::string error; | 654 std::string error; |
| 655 CallSetDisplayUnitInfo( | 655 CallSetDisplayUnitInfo( |
| 656 base::Int64ToString(secondary.id()), info, &success, &error); | 656 base::Int64ToString(secondary.id()), info, &success, &error); |
| 657 | 657 |
| 658 ASSERT_FALSE(success); | 658 ASSERT_FALSE(success); |
| 659 ASSERT_EQ("No other parameter should be set alongside mirroringSourceId.", | 659 ASSERT_EQ("No other parameter should be set alongside mirroringSourceId.", |
| 660 error); | 660 error); |
| 661 } | 661 } |
| 662 | 662 |
| 663 TEST_F(DisplayInfoProviderChromeosTest, SetRotation) { | 663 TEST_F(DisplayInfoProviderChromeosTest, SetRotation) { |
| 664 UpdateDisplay("1200x600,600x1000*2"); | 664 UpdateDisplay("1200x600,600x1000*2"); |
| 665 | 665 |
| 666 const gfx::Display& secondary = ash::ScreenUtil::GetSecondaryDisplay(); | 666 const gfx::Display& secondary = ash::ScreenUtil::GetSecondaryDisplay(); |
| 667 api::system_display::DisplayProperties info; | 667 core_api::system_display::DisplayProperties info; |
| 668 info.rotation.reset(new int(90)); | 668 info.rotation.reset(new int(90)); |
| 669 | 669 |
| 670 bool success = false; | 670 bool success = false; |
| 671 std::string error; | 671 std::string error; |
| 672 CallSetDisplayUnitInfo( | 672 CallSetDisplayUnitInfo( |
| 673 base::Int64ToString(secondary.id()), info, &success, &error); | 673 base::Int64ToString(secondary.id()), info, &success, &error); |
| 674 | 674 |
| 675 ASSERT_TRUE(success); | 675 ASSERT_TRUE(success); |
| 676 EXPECT_TRUE(error.empty()); | 676 EXPECT_TRUE(error.empty()); |
| 677 | 677 |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 710 | 710 |
| 711 EXPECT_EQ("0,0 300x500", secondary.bounds().ToString()); | 711 EXPECT_EQ("0,0 300x500", secondary.bounds().ToString()); |
| 712 EXPECT_EQ(gfx::Display::ROTATE_0, secondary.rotation()); | 712 EXPECT_EQ(gfx::Display::ROTATE_0, secondary.rotation()); |
| 713 EXPECT_EQ(ash::Shell::GetScreen()->GetPrimaryDisplay().id(), secondary.id()); | 713 EXPECT_EQ(ash::Shell::GetScreen()->GetPrimaryDisplay().id(), secondary.id()); |
| 714 } | 714 } |
| 715 | 715 |
| 716 TEST_F(DisplayInfoProviderChromeosTest, SetInvalidRotation) { | 716 TEST_F(DisplayInfoProviderChromeosTest, SetInvalidRotation) { |
| 717 UpdateDisplay("1200x600,600x1000*2"); | 717 UpdateDisplay("1200x600,600x1000*2"); |
| 718 | 718 |
| 719 const gfx::Display& secondary = ash::ScreenUtil::GetSecondaryDisplay(); | 719 const gfx::Display& secondary = ash::ScreenUtil::GetSecondaryDisplay(); |
| 720 api::system_display::DisplayProperties info; | 720 core_api::system_display::DisplayProperties info; |
| 721 info.rotation.reset(new int(91)); | 721 info.rotation.reset(new int(91)); |
| 722 | 722 |
| 723 bool success = false; | 723 bool success = false; |
| 724 std::string error; | 724 std::string error; |
| 725 CallSetDisplayUnitInfo( | 725 CallSetDisplayUnitInfo( |
| 726 base::Int64ToString(secondary.id()), info, &success, &error); | 726 base::Int64ToString(secondary.id()), info, &success, &error); |
| 727 | 727 |
| 728 ASSERT_FALSE(success); | 728 ASSERT_FALSE(success); |
| 729 EXPECT_EQ("Invalid rotation.", error); | 729 EXPECT_EQ("Invalid rotation.", error); |
| 730 } | 730 } |
| 731 | 731 |
| 732 TEST_F(DisplayInfoProviderChromeosTest, SetNegativeOverscan) { | 732 TEST_F(DisplayInfoProviderChromeosTest, SetNegativeOverscan) { |
| 733 UpdateDisplay("1200x600,600x1000*2"); | 733 UpdateDisplay("1200x600,600x1000*2"); |
| 734 | 734 |
| 735 const gfx::Display& secondary = ash::ScreenUtil::GetSecondaryDisplay(); | 735 const gfx::Display& secondary = ash::ScreenUtil::GetSecondaryDisplay(); |
| 736 api::system_display::DisplayProperties info; | 736 core_api::system_display::DisplayProperties info; |
| 737 info.overscan.reset(new api::system_display::Insets); | 737 info.overscan.reset(new core_api::system_display::Insets); |
| 738 info.overscan->left = -10; | 738 info.overscan->left = -10; |
| 739 | 739 |
| 740 bool success = false; | 740 bool success = false; |
| 741 std::string error; | 741 std::string error; |
| 742 CallSetDisplayUnitInfo( | 742 CallSetDisplayUnitInfo( |
| 743 base::Int64ToString(secondary.id()), info, &success, &error); | 743 base::Int64ToString(secondary.id()), info, &success, &error); |
| 744 | 744 |
| 745 ASSERT_FALSE(success); | 745 ASSERT_FALSE(success); |
| 746 EXPECT_EQ("Negative overscan not allowed.", error); | 746 EXPECT_EQ("Negative overscan not allowed.", error); |
| 747 | 747 |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 789 ASSERT_TRUE(success); | 789 ASSERT_TRUE(success); |
| 790 EXPECT_TRUE(error.empty()); | 790 EXPECT_TRUE(error.empty()); |
| 791 | 791 |
| 792 EXPECT_EQ("1200,0 300x500", secondary.bounds().ToString()); | 792 EXPECT_EQ("1200,0 300x500", secondary.bounds().ToString()); |
| 793 } | 793 } |
| 794 | 794 |
| 795 TEST_F(DisplayInfoProviderChromeosTest, SetOverscanLargerThanHorizontalBounds) { | 795 TEST_F(DisplayInfoProviderChromeosTest, SetOverscanLargerThanHorizontalBounds) { |
| 796 UpdateDisplay("1200x600,600x1000*2"); | 796 UpdateDisplay("1200x600,600x1000*2"); |
| 797 | 797 |
| 798 const gfx::Display& secondary = ash::ScreenUtil::GetSecondaryDisplay(); | 798 const gfx::Display& secondary = ash::ScreenUtil::GetSecondaryDisplay(); |
| 799 api::system_display::DisplayProperties info; | 799 core_api::system_display::DisplayProperties info; |
| 800 info.overscan.reset(new api::system_display::Insets); | 800 info.overscan.reset(new core_api::system_display::Insets); |
| 801 // Horizontal overscan is 151, which would make the bounds width 149. | 801 // Horizontal overscan is 151, which would make the bounds width 149. |
| 802 info.overscan->left = 50; | 802 info.overscan->left = 50; |
| 803 info.overscan->top = 10; | 803 info.overscan->top = 10; |
| 804 info.overscan->right = 101; | 804 info.overscan->right = 101; |
| 805 info.overscan->bottom = 20; | 805 info.overscan->bottom = 20; |
| 806 | 806 |
| 807 bool success = false; | 807 bool success = false; |
| 808 std::string error; | 808 std::string error; |
| 809 CallSetDisplayUnitInfo( | 809 CallSetDisplayUnitInfo( |
| 810 base::Int64ToString(secondary.id()), info, &success, &error); | 810 base::Int64ToString(secondary.id()), info, &success, &error); |
| 811 | 811 |
| 812 ASSERT_FALSE(success); | 812 ASSERT_FALSE(success); |
| 813 EXPECT_EQ("Horizontal overscan is more than half of the screen width.", | 813 EXPECT_EQ("Horizontal overscan is more than half of the screen width.", |
| 814 error); | 814 error); |
| 815 } | 815 } |
| 816 | 816 |
| 817 TEST_F(DisplayInfoProviderChromeosTest, SetOverscanLargerThanVerticalBounds) { | 817 TEST_F(DisplayInfoProviderChromeosTest, SetOverscanLargerThanVerticalBounds) { |
| 818 UpdateDisplay("1200x600,600x1000"); | 818 UpdateDisplay("1200x600,600x1000"); |
| 819 | 819 |
| 820 const gfx::Display& secondary = ash::ScreenUtil::GetSecondaryDisplay(); | 820 const gfx::Display& secondary = ash::ScreenUtil::GetSecondaryDisplay(); |
| 821 api::system_display::DisplayProperties info; | 821 core_api::system_display::DisplayProperties info; |
| 822 info.overscan.reset(new api::system_display::Insets); | 822 info.overscan.reset(new core_api::system_display::Insets); |
| 823 // Vertical overscan is 501, which would make the bounds height 499. | 823 // Vertical overscan is 501, which would make the bounds height 499. |
| 824 info.overscan->left = 20; | 824 info.overscan->left = 20; |
| 825 info.overscan->top = 250; | 825 info.overscan->top = 250; |
| 826 info.overscan->right = 101; | 826 info.overscan->right = 101; |
| 827 info.overscan->bottom = 251; | 827 info.overscan->bottom = 251; |
| 828 | 828 |
| 829 bool success = false; | 829 bool success = false; |
| 830 std::string error; | 830 std::string error; |
| 831 CallSetDisplayUnitInfo( | 831 CallSetDisplayUnitInfo( |
| 832 base::Int64ToString(secondary.id()), info, &success, &error); | 832 base::Int64ToString(secondary.id()), info, &success, &error); |
| 833 | 833 |
| 834 ASSERT_FALSE(success); | 834 ASSERT_FALSE(success); |
| 835 EXPECT_EQ("Vertical overscan is more than half of the screen height.", error); | 835 EXPECT_EQ("Vertical overscan is more than half of the screen height.", error); |
| 836 } | 836 } |
| 837 | 837 |
| 838 TEST_F(DisplayInfoProviderChromeosTest, SetOverscan) { | 838 TEST_F(DisplayInfoProviderChromeosTest, SetOverscan) { |
| 839 UpdateDisplay("1200x600,600x1000*2"); | 839 UpdateDisplay("1200x600,600x1000*2"); |
| 840 | 840 |
| 841 const gfx::Display& secondary = ash::ScreenUtil::GetSecondaryDisplay(); | 841 const gfx::Display& secondary = ash::ScreenUtil::GetSecondaryDisplay(); |
| 842 api::system_display::DisplayProperties info; | 842 core_api::system_display::DisplayProperties info; |
| 843 info.overscan.reset(new api::system_display::Insets); | 843 info.overscan.reset(new core_api::system_display::Insets); |
| 844 info.overscan->left = 20; | 844 info.overscan->left = 20; |
| 845 info.overscan->top = 199; | 845 info.overscan->top = 199; |
| 846 info.overscan->right = 130; | 846 info.overscan->right = 130; |
| 847 info.overscan->bottom = 51; | 847 info.overscan->bottom = 51; |
| 848 | 848 |
| 849 bool success = false; | 849 bool success = false; |
| 850 std::string error; | 850 std::string error; |
| 851 CallSetDisplayUnitInfo( | 851 CallSetDisplayUnitInfo( |
| 852 base::Int64ToString(secondary.id()), info, &success, &error); | 852 base::Int64ToString(secondary.id()), info, &success, &error); |
| 853 | 853 |
| 854 ASSERT_TRUE(success); | 854 ASSERT_TRUE(success); |
| 855 EXPECT_TRUE(error.empty()); | 855 EXPECT_TRUE(error.empty()); |
| 856 | 856 |
| 857 EXPECT_EQ("1200,0 150x250", secondary.bounds().ToString()); | 857 EXPECT_EQ("1200,0 150x250", secondary.bounds().ToString()); |
| 858 const gfx::Insets overscan = | 858 const gfx::Insets overscan = |
| 859 GetDisplayManager()->GetOverscanInsets(secondary.id()); | 859 GetDisplayManager()->GetOverscanInsets(secondary.id()); |
| 860 | 860 |
| 861 EXPECT_EQ(20, overscan.left()); | 861 EXPECT_EQ(20, overscan.left()); |
| 862 EXPECT_EQ(199, overscan.top()); | 862 EXPECT_EQ(199, overscan.top()); |
| 863 EXPECT_EQ(130, overscan.right()); | 863 EXPECT_EQ(130, overscan.right()); |
| 864 EXPECT_EQ(51, overscan.bottom()); | 864 EXPECT_EQ(51, overscan.bottom()); |
| 865 } | 865 } |
| 866 | 866 |
| 867 TEST_F(DisplayInfoProviderChromeosTest, SetOverscanForInternal) { | 867 TEST_F(DisplayInfoProviderChromeosTest, SetOverscanForInternal) { |
| 868 UpdateDisplay("1200x600,600x1000*2"); | 868 UpdateDisplay("1200x600,600x1000*2"); |
| 869 const int64 internal_display_id = | 869 const int64 internal_display_id = |
| 870 ash::test::DisplayManagerTestApi(GetDisplayManager()) | 870 ash::test::DisplayManagerTestApi(GetDisplayManager()) |
| 871 .SetFirstDisplayAsInternalDisplay(); | 871 .SetFirstDisplayAsInternalDisplay(); |
| 872 | 872 |
| 873 api::system_display::DisplayProperties info; | 873 core_api::system_display::DisplayProperties info; |
| 874 info.overscan.reset(new api::system_display::Insets); | 874 info.overscan.reset(new core_api::system_display::Insets); |
| 875 // Vertical overscan is 501, which would make the bounds height 499. | 875 // Vertical overscan is 501, which would make the bounds height 499. |
| 876 info.overscan->left = 20; | 876 info.overscan->left = 20; |
| 877 info.overscan->top = 20; | 877 info.overscan->top = 20; |
| 878 info.overscan->right = 20; | 878 info.overscan->right = 20; |
| 879 info.overscan->bottom = 20; | 879 info.overscan->bottom = 20; |
| 880 | 880 |
| 881 bool success = false; | 881 bool success = false; |
| 882 std::string error; | 882 std::string error; |
| 883 CallSetDisplayUnitInfo( | 883 CallSetDisplayUnitInfo( |
| 884 base::Int64ToString(internal_display_id), info, &success, &error); | 884 base::Int64ToString(internal_display_id), info, &success, &error); |
| 885 | 885 |
| 886 ASSERT_FALSE(success); | 886 ASSERT_FALSE(success); |
| 887 EXPECT_EQ("Overscan changes not allowed for the internal monitor.", error); | 887 EXPECT_EQ("Overscan changes not allowed for the internal monitor.", error); |
| 888 } | 888 } |
| 889 | 889 |
| 890 } // namespace | 890 } // namespace |
| 891 } // namespace extensions | 891 } // namespace extensions |
| OLD | NEW |