| 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 "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/common/wm/maximize_mode/maximize_mode_controller.h" | 9 #include "ash/common/wm/maximize_mode/maximize_mode_controller.h" |
| 10 #include "ash/common/wm_shell.h" | 10 #include "ash/common/wm_shell.h" |
| 11 #include "ash/display/display_manager.h" | 11 #include "ash/display/display_manager.h" |
| 12 #include "ash/display/screen_orientation_controller_chromeos.h" | 12 #include "ash/display/screen_orientation_controller_chromeos.h" |
| 13 #include "ash/screen_util.h" | |
| 14 #include "ash/shell.h" | 13 #include "ash/shell.h" |
| 15 #include "ash/test/ash_test_base.h" | 14 #include "ash/test/ash_test_base.h" |
| 16 #include "ash/test/display_manager_test_api.h" | 15 #include "ash/test/display_manager_test_api.h" |
| 17 #include "base/command_line.h" | 16 #include "base/command_line.h" |
| 18 #include "base/macros.h" | 17 #include "base/macros.h" |
| 19 #include "base/strings/string_number_conversions.h" | 18 #include "base/strings/string_number_conversions.h" |
| 20 #include "base/strings/stringprintf.h" | 19 #include "base/strings/stringprintf.h" |
| 21 #include "extensions/common/api/system_display.h" | 20 #include "extensions/common/api/system_display.h" |
| 22 #include "ui/display/display.h" | 21 #include "ui/display/display.h" |
| 23 #include "ui/display/display_switches.h" | 22 #include "ui/display/display_switches.h" |
| (...skipping 269 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 293 EXPECT_EQ("0,0 500x600", SystemInfoDisplayBoundsToString(result[0].bounds)); | 292 EXPECT_EQ("0,0 500x600", SystemInfoDisplayBoundsToString(result[0].bounds)); |
| 294 EXPECT_EQ(96, result[0].dpi_x); | 293 EXPECT_EQ(96, result[0].dpi_x); |
| 295 EXPECT_EQ(96, result[0].dpi_y); | 294 EXPECT_EQ(96, result[0].dpi_y); |
| 296 | 295 |
| 297 EXPECT_EQ("500,0 200x260", SystemInfoDisplayBoundsToString(result[1].bounds)); | 296 EXPECT_EQ("500,0 200x260", SystemInfoDisplayBoundsToString(result[1].bounds)); |
| 298 // DPI should be 96 (native dpi) * 200 (display) / 400 (native) when ui scale | 297 // DPI should be 96 (native dpi) * 200 (display) / 400 (native) when ui scale |
| 299 // is 2. | 298 // is 2. |
| 300 EXPECT_EQ(96 / 2, result[1].dpi_x); | 299 EXPECT_EQ(96 / 2, result[1].dpi_x); |
| 301 EXPECT_EQ(96 / 2, result[1].dpi_y); | 300 EXPECT_EQ(96 / 2, result[1].dpi_y); |
| 302 | 301 |
| 303 ash::test::SwapPrimaryDisplay(); | 302 SwapPrimaryDisplay(); |
| 304 | 303 |
| 305 result = DisplayInfoProvider::Get()->GetAllDisplaysInfo(); | 304 result = DisplayInfoProvider::Get()->GetAllDisplaysInfo(); |
| 306 | 305 |
| 307 ASSERT_EQ(2u, result.size()); | 306 ASSERT_EQ(2u, result.size()); |
| 308 | 307 |
| 309 EXPECT_EQ("-500,0 500x600", | 308 EXPECT_EQ("-500,0 500x600", |
| 310 SystemInfoDisplayBoundsToString(result[0].bounds)); | 309 SystemInfoDisplayBoundsToString(result[0].bounds)); |
| 311 EXPECT_EQ(96, result[0].dpi_x); | 310 EXPECT_EQ(96, result[0].dpi_x); |
| 312 EXPECT_EQ(96, result[0].dpi_y); | 311 EXPECT_EQ(96, result[0].dpi_y); |
| 313 | 312 |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 402 ASSERT_EQ(2u, result.size()); | 401 ASSERT_EQ(2u, result.size()); |
| 403 EXPECT_EQ(base::Int64ToString(display_id_primary), result[0].id); | 402 EXPECT_EQ(base::Int64ToString(display_id_primary), result[0].id); |
| 404 EXPECT_TRUE(result[0].mirroring_source_id.empty()); | 403 EXPECT_TRUE(result[0].mirroring_source_id.empty()); |
| 405 EXPECT_EQ(base::Int64ToString(display_id_secondary), result[1].id); | 404 EXPECT_EQ(base::Int64ToString(display_id_secondary), result[1].id); |
| 406 EXPECT_TRUE(result[1].mirroring_source_id.empty()); | 405 EXPECT_TRUE(result[1].mirroring_source_id.empty()); |
| 407 } | 406 } |
| 408 | 407 |
| 409 TEST_F(DisplayInfoProviderChromeosTest, GetBounds) { | 408 TEST_F(DisplayInfoProviderChromeosTest, GetBounds) { |
| 410 UpdateDisplay("600x600, 400x520"); | 409 UpdateDisplay("600x600, 400x520"); |
| 411 GetDisplayManager()->SetLayoutForCurrentDisplays( | 410 GetDisplayManager()->SetLayoutForCurrentDisplays( |
| 412 ash::test::CreateDisplayLayout(display::DisplayPlacement::LEFT, -40)); | 411 ash::test::CreateDisplayLayout(display_manager(), |
| 412 display::DisplayPlacement::LEFT, -40)); |
| 413 | 413 |
| 414 DisplayUnitInfoList result = DisplayInfoProvider::Get()->GetAllDisplaysInfo(); | 414 DisplayUnitInfoList result = DisplayInfoProvider::Get()->GetAllDisplaysInfo(); |
| 415 | 415 |
| 416 ASSERT_EQ(2u, result.size()); | 416 ASSERT_EQ(2u, result.size()); |
| 417 EXPECT_EQ("0,0 600x600", SystemInfoDisplayBoundsToString(result[0].bounds)); | 417 EXPECT_EQ("0,0 600x600", SystemInfoDisplayBoundsToString(result[0].bounds)); |
| 418 EXPECT_EQ("-400,-40 400x520", | 418 EXPECT_EQ("-400,-40 400x520", |
| 419 SystemInfoDisplayBoundsToString(result[1].bounds)); | 419 SystemInfoDisplayBoundsToString(result[1].bounds)); |
| 420 | 420 |
| 421 GetDisplayManager()->SetLayoutForCurrentDisplays( | 421 GetDisplayManager()->SetLayoutForCurrentDisplays( |
| 422 ash::test::CreateDisplayLayout(display::DisplayPlacement::TOP, 40)); | 422 ash::test::CreateDisplayLayout(display_manager(), |
| 423 display::DisplayPlacement::TOP, 40)); |
| 423 | 424 |
| 424 result = DisplayInfoProvider::Get()->GetAllDisplaysInfo(); | 425 result = DisplayInfoProvider::Get()->GetAllDisplaysInfo(); |
| 425 | 426 |
| 426 ASSERT_EQ(2u, result.size()); | 427 ASSERT_EQ(2u, result.size()); |
| 427 EXPECT_EQ("0,0 600x600", SystemInfoDisplayBoundsToString(result[0].bounds)); | 428 EXPECT_EQ("0,0 600x600", SystemInfoDisplayBoundsToString(result[0].bounds)); |
| 428 EXPECT_EQ("40,-520 400x520", | 429 EXPECT_EQ("40,-520 400x520", |
| 429 SystemInfoDisplayBoundsToString(result[1].bounds)); | 430 SystemInfoDisplayBoundsToString(result[1].bounds)); |
| 430 | 431 |
| 431 GetDisplayManager()->SetLayoutForCurrentDisplays( | 432 GetDisplayManager()->SetLayoutForCurrentDisplays( |
| 432 ash::test::CreateDisplayLayout(display::DisplayPlacement::BOTTOM, 80)); | 433 ash::test::CreateDisplayLayout(display_manager(), |
| 434 display::DisplayPlacement::BOTTOM, 80)); |
| 433 | 435 |
| 434 result = DisplayInfoProvider::Get()->GetAllDisplaysInfo(); | 436 result = DisplayInfoProvider::Get()->GetAllDisplaysInfo(); |
| 435 ASSERT_EQ(2u, result.size()); | 437 ASSERT_EQ(2u, result.size()); |
| 436 EXPECT_EQ("0,0 600x600", SystemInfoDisplayBoundsToString(result[0].bounds)); | 438 EXPECT_EQ("0,0 600x600", SystemInfoDisplayBoundsToString(result[0].bounds)); |
| 437 EXPECT_EQ("80,600 400x520", | 439 EXPECT_EQ("80,600 400x520", |
| 438 SystemInfoDisplayBoundsToString(result[1].bounds)); | 440 SystemInfoDisplayBoundsToString(result[1].bounds)); |
| 439 } | 441 } |
| 440 | 442 |
| 441 TEST_F(DisplayInfoProviderChromeosTest, Layout) { | 443 TEST_F(DisplayInfoProviderChromeosTest, Layout) { |
| 442 UpdateDisplay("500x400,500x400,500x400"); | 444 UpdateDisplay("500x400,500x400,500x400"); |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 488 | 490 |
| 489 // Test setting invalid layout fails. | 491 // Test setting invalid layout fails. |
| 490 layout[0].parent_id = displays[2].id; | 492 layout[0].parent_id = displays[2].id; |
| 491 layout[1].parent_id = displays[1].id; | 493 layout[1].parent_id = displays[1].id; |
| 492 EXPECT_FALSE(DisplayInfoProvider::Get()->SetDisplayLayout(layout)); | 494 EXPECT_FALSE(DisplayInfoProvider::Get()->SetDisplayLayout(layout)); |
| 493 } | 495 } |
| 494 | 496 |
| 495 TEST_F(DisplayInfoProviderChromeosTest, SetBoundsOriginLeftExact) { | 497 TEST_F(DisplayInfoProviderChromeosTest, SetBoundsOriginLeftExact) { |
| 496 UpdateDisplay("1200x600,520x400"); | 498 UpdateDisplay("1200x600,520x400"); |
| 497 | 499 |
| 498 const display::Display& secondary = ash::ScreenUtil::GetSecondaryDisplay(); | 500 const display::Display& secondary = display_manager()->GetSecondaryDisplay(); |
| 499 api::system_display::DisplayProperties info; | 501 api::system_display::DisplayProperties info; |
| 500 info.bounds_origin_x.reset(new int(-520)); | 502 info.bounds_origin_x.reset(new int(-520)); |
| 501 info.bounds_origin_y.reset(new int(50)); | 503 info.bounds_origin_y.reset(new int(50)); |
| 502 | 504 |
| 503 bool success = false; | 505 bool success = false; |
| 504 std::string error; | 506 std::string error; |
| 505 CallSetDisplayUnitInfo( | 507 CallSetDisplayUnitInfo( |
| 506 base::Int64ToString(secondary.id()), info, &success, &error); | 508 base::Int64ToString(secondary.id()), info, &success, &error); |
| 507 | 509 |
| 508 ASSERT_TRUE(success); | 510 ASSERT_TRUE(success); |
| 509 ASSERT_TRUE(error.empty()); | 511 ASSERT_TRUE(error.empty()); |
| 510 | 512 |
| 511 EXPECT_EQ("-520,50 520x400", secondary.bounds().ToString()); | 513 EXPECT_EQ("-520,50 520x400", secondary.bounds().ToString()); |
| 512 } | 514 } |
| 513 | 515 |
| 514 TEST_F(DisplayInfoProviderChromeosTest, SetBoundsOriginRightExact) { | 516 TEST_F(DisplayInfoProviderChromeosTest, SetBoundsOriginRightExact) { |
| 515 UpdateDisplay("1200x600,520x400"); | 517 UpdateDisplay("1200x600,520x400"); |
| 516 | 518 |
| 517 const display::Display& secondary = ash::ScreenUtil::GetSecondaryDisplay(); | 519 const display::Display& secondary = display_manager()->GetSecondaryDisplay(); |
| 518 api::system_display::DisplayProperties info; | 520 api::system_display::DisplayProperties info; |
| 519 info.bounds_origin_x.reset(new int(1200)); | 521 info.bounds_origin_x.reset(new int(1200)); |
| 520 info.bounds_origin_y.reset(new int(100)); | 522 info.bounds_origin_y.reset(new int(100)); |
| 521 | 523 |
| 522 bool success = false; | 524 bool success = false; |
| 523 std::string error; | 525 std::string error; |
| 524 CallSetDisplayUnitInfo( | 526 CallSetDisplayUnitInfo( |
| 525 base::Int64ToString(secondary.id()), info, &success, &error); | 527 base::Int64ToString(secondary.id()), info, &success, &error); |
| 526 | 528 |
| 527 ASSERT_TRUE(success); | 529 ASSERT_TRUE(success); |
| 528 ASSERT_TRUE(error.empty()); | 530 ASSERT_TRUE(error.empty()); |
| 529 | 531 |
| 530 EXPECT_EQ("1200,100 520x400", secondary.bounds().ToString()); | 532 EXPECT_EQ("1200,100 520x400", secondary.bounds().ToString()); |
| 531 } | 533 } |
| 532 | 534 |
| 533 TEST_F(DisplayInfoProviderChromeosTest, SetBoundsOriginTopExact) { | 535 TEST_F(DisplayInfoProviderChromeosTest, SetBoundsOriginTopExact) { |
| 534 UpdateDisplay("1200x600,520x400"); | 536 UpdateDisplay("1200x600,520x400"); |
| 535 | 537 |
| 536 const display::Display& secondary = ash::ScreenUtil::GetSecondaryDisplay(); | 538 const display::Display& secondary = display_manager()->GetSecondaryDisplay(); |
| 537 api::system_display::DisplayProperties info; | 539 api::system_display::DisplayProperties info; |
| 538 info.bounds_origin_x.reset(new int(1100)); | 540 info.bounds_origin_x.reset(new int(1100)); |
| 539 info.bounds_origin_y.reset(new int(-400)); | 541 info.bounds_origin_y.reset(new int(-400)); |
| 540 | 542 |
| 541 bool success = false; | 543 bool success = false; |
| 542 std::string error; | 544 std::string error; |
| 543 CallSetDisplayUnitInfo( | 545 CallSetDisplayUnitInfo( |
| 544 base::Int64ToString(secondary.id()), info, &success, &error); | 546 base::Int64ToString(secondary.id()), info, &success, &error); |
| 545 | 547 |
| 546 ASSERT_TRUE(success); | 548 ASSERT_TRUE(success); |
| 547 ASSERT_TRUE(error.empty()); | 549 ASSERT_TRUE(error.empty()); |
| 548 | 550 |
| 549 EXPECT_EQ("1100,-400 520x400", secondary.bounds().ToString()); | 551 EXPECT_EQ("1100,-400 520x400", secondary.bounds().ToString()); |
| 550 } | 552 } |
| 551 | 553 |
| 552 TEST_F(DisplayInfoProviderChromeosTest, SetBoundsOriginBottomExact) { | 554 TEST_F(DisplayInfoProviderChromeosTest, SetBoundsOriginBottomExact) { |
| 553 UpdateDisplay("1200x600,520x400"); | 555 UpdateDisplay("1200x600,520x400"); |
| 554 | 556 |
| 555 const display::Display& secondary = ash::ScreenUtil::GetSecondaryDisplay(); | 557 const display::Display& secondary = display_manager()->GetSecondaryDisplay(); |
| 556 api::system_display::DisplayProperties info; | 558 api::system_display::DisplayProperties info; |
| 557 info.bounds_origin_x.reset(new int(-350)); | 559 info.bounds_origin_x.reset(new int(-350)); |
| 558 info.bounds_origin_y.reset(new int(600)); | 560 info.bounds_origin_y.reset(new int(600)); |
| 559 | 561 |
| 560 bool success = false; | 562 bool success = false; |
| 561 std::string error; | 563 std::string error; |
| 562 CallSetDisplayUnitInfo( | 564 CallSetDisplayUnitInfo( |
| 563 base::Int64ToString(secondary.id()), info, &success, &error); | 565 base::Int64ToString(secondary.id()), info, &success, &error); |
| 564 | 566 |
| 565 ASSERT_TRUE(success); | 567 ASSERT_TRUE(success); |
| 566 ASSERT_TRUE(error.empty()); | 568 ASSERT_TRUE(error.empty()); |
| 567 | 569 |
| 568 EXPECT_EQ("-350,600 520x400", secondary.bounds().ToString()); | 570 EXPECT_EQ("-350,600 520x400", secondary.bounds().ToString()); |
| 569 } | 571 } |
| 570 | 572 |
| 571 TEST_F(DisplayInfoProviderChromeosTest, SetBoundsOriginSameCenter) { | 573 TEST_F(DisplayInfoProviderChromeosTest, SetBoundsOriginSameCenter) { |
| 572 UpdateDisplay("1200x600,520x400"); | 574 UpdateDisplay("1200x600,520x400"); |
| 573 | 575 |
| 574 const display::Display& secondary = ash::ScreenUtil::GetSecondaryDisplay(); | 576 const display::Display& secondary = display_manager()->GetSecondaryDisplay(); |
| 575 api::system_display::DisplayProperties info; | 577 api::system_display::DisplayProperties info; |
| 576 info.bounds_origin_x.reset(new int(340)); | 578 info.bounds_origin_x.reset(new int(340)); |
| 577 info.bounds_origin_y.reset(new int(100)); | 579 info.bounds_origin_y.reset(new int(100)); |
| 578 | 580 |
| 579 bool success = false; | 581 bool success = false; |
| 580 std::string error; | 582 std::string error; |
| 581 CallSetDisplayUnitInfo( | 583 CallSetDisplayUnitInfo( |
| 582 base::Int64ToString(secondary.id()), info, &success, &error); | 584 base::Int64ToString(secondary.id()), info, &success, &error); |
| 583 | 585 |
| 584 ASSERT_TRUE(success); | 586 ASSERT_TRUE(success); |
| 585 ASSERT_TRUE(error.empty()); | 587 ASSERT_TRUE(error.empty()); |
| 586 | 588 |
| 587 EXPECT_EQ("1200,100 520x400", secondary.bounds().ToString()); | 589 EXPECT_EQ("1200,100 520x400", secondary.bounds().ToString()); |
| 588 } | 590 } |
| 589 | 591 |
| 590 TEST_F(DisplayInfoProviderChromeosTest, SetBoundsOriginLeftOutside) { | 592 TEST_F(DisplayInfoProviderChromeosTest, SetBoundsOriginLeftOutside) { |
| 591 UpdateDisplay("1200x600,520x400"); | 593 UpdateDisplay("1200x600,520x400"); |
| 592 | 594 |
| 593 const display::Display& secondary = ash::ScreenUtil::GetSecondaryDisplay(); | 595 const display::Display& secondary = display_manager()->GetSecondaryDisplay(); |
| 594 api::system_display::DisplayProperties info; | 596 api::system_display::DisplayProperties info; |
| 595 info.bounds_origin_x.reset(new int(-1040)); | 597 info.bounds_origin_x.reset(new int(-1040)); |
| 596 info.bounds_origin_y.reset(new int(100)); | 598 info.bounds_origin_y.reset(new int(100)); |
| 597 | 599 |
| 598 bool success = false; | 600 bool success = false; |
| 599 std::string error; | 601 std::string error; |
| 600 CallSetDisplayUnitInfo( | 602 CallSetDisplayUnitInfo( |
| 601 base::Int64ToString(secondary.id()), info, &success, &error); | 603 base::Int64ToString(secondary.id()), info, &success, &error); |
| 602 | 604 |
| 603 ASSERT_TRUE(success); | 605 ASSERT_TRUE(success); |
| 604 ASSERT_TRUE(error.empty()); | 606 ASSERT_TRUE(error.empty()); |
| 605 | 607 |
| 606 EXPECT_EQ("-520,100 520x400", secondary.bounds().ToString()); | 608 EXPECT_EQ("-520,100 520x400", secondary.bounds().ToString()); |
| 607 } | 609 } |
| 608 | 610 |
| 609 TEST_F(DisplayInfoProviderChromeosTest, SetBoundsOriginTopOutside) { | 611 TEST_F(DisplayInfoProviderChromeosTest, SetBoundsOriginTopOutside) { |
| 610 UpdateDisplay("1200x600,520x400"); | 612 UpdateDisplay("1200x600,520x400"); |
| 611 | 613 |
| 612 const display::Display& secondary = ash::ScreenUtil::GetSecondaryDisplay(); | 614 const display::Display& secondary = display_manager()->GetSecondaryDisplay(); |
| 613 api::system_display::DisplayProperties info; | 615 api::system_display::DisplayProperties info; |
| 614 info.bounds_origin_x.reset(new int(-360)); | 616 info.bounds_origin_x.reset(new int(-360)); |
| 615 info.bounds_origin_y.reset(new int(-301)); | 617 info.bounds_origin_y.reset(new int(-301)); |
| 616 | 618 |
| 617 bool success = false; | 619 bool success = false; |
| 618 std::string error; | 620 std::string error; |
| 619 CallSetDisplayUnitInfo( | 621 CallSetDisplayUnitInfo( |
| 620 base::Int64ToString(secondary.id()), info, &success, &error); | 622 base::Int64ToString(secondary.id()), info, &success, &error); |
| 621 | 623 |
| 622 ASSERT_TRUE(success); | 624 ASSERT_TRUE(success); |
| 623 ASSERT_TRUE(error.empty()); | 625 ASSERT_TRUE(error.empty()); |
| 624 | 626 |
| 625 EXPECT_EQ("-360,-400 520x400", secondary.bounds().ToString()); | 627 EXPECT_EQ("-360,-400 520x400", secondary.bounds().ToString()); |
| 626 } | 628 } |
| 627 | 629 |
| 628 TEST_F(DisplayInfoProviderChromeosTest, | 630 TEST_F(DisplayInfoProviderChromeosTest, |
| 629 SetBoundsOriginLeftButSharesBottomSide) { | 631 SetBoundsOriginLeftButSharesBottomSide) { |
| 630 UpdateDisplay("1200x600,1000x100"); | 632 UpdateDisplay("1200x600,1000x100"); |
| 631 | 633 |
| 632 const display::Display& secondary = ash::ScreenUtil::GetSecondaryDisplay(); | 634 const display::Display& secondary = display_manager()->GetSecondaryDisplay(); |
| 633 api::system_display::DisplayProperties info; | 635 api::system_display::DisplayProperties info; |
| 634 info.bounds_origin_x.reset(new int(-650)); | 636 info.bounds_origin_x.reset(new int(-650)); |
| 635 info.bounds_origin_y.reset(new int(700)); | 637 info.bounds_origin_y.reset(new int(700)); |
| 636 | 638 |
| 637 bool success = false; | 639 bool success = false; |
| 638 std::string error; | 640 std::string error; |
| 639 CallSetDisplayUnitInfo( | 641 CallSetDisplayUnitInfo( |
| 640 base::Int64ToString(secondary.id()), info, &success, &error); | 642 base::Int64ToString(secondary.id()), info, &success, &error); |
| 641 | 643 |
| 642 ASSERT_TRUE(success); | 644 ASSERT_TRUE(success); |
| 643 ASSERT_TRUE(error.empty()); | 645 ASSERT_TRUE(error.empty()); |
| 644 | 646 |
| 645 EXPECT_EQ("-650,600 1000x100", secondary.bounds().ToString()); | 647 EXPECT_EQ("-650,600 1000x100", secondary.bounds().ToString()); |
| 646 } | 648 } |
| 647 | 649 |
| 648 TEST_F(DisplayInfoProviderChromeosTest, SetBoundsOriginRightButSharesTopSide) { | 650 TEST_F(DisplayInfoProviderChromeosTest, SetBoundsOriginRightButSharesTopSide) { |
| 649 UpdateDisplay("1200x600,1000x100"); | 651 UpdateDisplay("1200x600,1000x100"); |
| 650 | 652 |
| 651 const display::Display& secondary = ash::ScreenUtil::GetSecondaryDisplay(); | 653 const display::Display& secondary = display_manager()->GetSecondaryDisplay(); |
| 652 api::system_display::DisplayProperties info; | 654 api::system_display::DisplayProperties info; |
| 653 info.bounds_origin_x.reset(new int(850)); | 655 info.bounds_origin_x.reset(new int(850)); |
| 654 info.bounds_origin_y.reset(new int(-150)); | 656 info.bounds_origin_y.reset(new int(-150)); |
| 655 | 657 |
| 656 bool success = false; | 658 bool success = false; |
| 657 std::string error; | 659 std::string error; |
| 658 CallSetDisplayUnitInfo( | 660 CallSetDisplayUnitInfo( |
| 659 base::Int64ToString(secondary.id()), info, &success, &error); | 661 base::Int64ToString(secondary.id()), info, &success, &error); |
| 660 | 662 |
| 661 ASSERT_TRUE(success); | 663 ASSERT_TRUE(success); |
| 662 ASSERT_TRUE(error.empty()); | 664 ASSERT_TRUE(error.empty()); |
| 663 | 665 |
| 664 EXPECT_EQ("850,-100 1000x100", secondary.bounds().ToString()); | 666 EXPECT_EQ("850,-100 1000x100", secondary.bounds().ToString()); |
| 665 } | 667 } |
| 666 | 668 |
| 667 TEST_F(DisplayInfoProviderChromeosTest, SetBoundsOriginTopButSharesLeftSide) { | 669 TEST_F(DisplayInfoProviderChromeosTest, SetBoundsOriginTopButSharesLeftSide) { |
| 668 UpdateDisplay("1200x600,1000x100/l"); | 670 UpdateDisplay("1200x600,1000x100/l"); |
| 669 | 671 |
| 670 const display::Display& secondary = ash::ScreenUtil::GetSecondaryDisplay(); | 672 const display::Display& secondary = display_manager()->GetSecondaryDisplay(); |
| 671 api::system_display::DisplayProperties info; | 673 api::system_display::DisplayProperties info; |
| 672 info.bounds_origin_x.reset(new int(-150)); | 674 info.bounds_origin_x.reset(new int(-150)); |
| 673 info.bounds_origin_y.reset(new int(-650)); | 675 info.bounds_origin_y.reset(new int(-650)); |
| 674 | 676 |
| 675 bool success = false; | 677 bool success = false; |
| 676 std::string error; | 678 std::string error; |
| 677 CallSetDisplayUnitInfo( | 679 CallSetDisplayUnitInfo( |
| 678 base::Int64ToString(secondary.id()), info, &success, &error); | 680 base::Int64ToString(secondary.id()), info, &success, &error); |
| 679 | 681 |
| 680 ASSERT_TRUE(success); | 682 ASSERT_TRUE(success); |
| 681 ASSERT_TRUE(error.empty()); | 683 ASSERT_TRUE(error.empty()); |
| 682 | 684 |
| 683 EXPECT_EQ("-100,-650 100x1000", secondary.bounds().ToString()); | 685 EXPECT_EQ("-100,-650 100x1000", secondary.bounds().ToString()); |
| 684 } | 686 } |
| 685 | 687 |
| 686 TEST_F(DisplayInfoProviderChromeosTest, | 688 TEST_F(DisplayInfoProviderChromeosTest, |
| 687 SetBoundsOriginBottomButSharesRightSide) { | 689 SetBoundsOriginBottomButSharesRightSide) { |
| 688 UpdateDisplay("1200x600,1000x100/l"); | 690 UpdateDisplay("1200x600,1000x100/l"); |
| 689 | 691 |
| 690 const display::Display& secondary = ash::ScreenUtil::GetSecondaryDisplay(); | 692 const display::Display& secondary = display_manager()->GetSecondaryDisplay(); |
| 691 api::system_display::DisplayProperties info; | 693 api::system_display::DisplayProperties info; |
| 692 info.bounds_origin_x.reset(new int(1350)); | 694 info.bounds_origin_x.reset(new int(1350)); |
| 693 info.bounds_origin_y.reset(new int(450)); | 695 info.bounds_origin_y.reset(new int(450)); |
| 694 | 696 |
| 695 bool success = false; | 697 bool success = false; |
| 696 std::string error; | 698 std::string error; |
| 697 CallSetDisplayUnitInfo( | 699 CallSetDisplayUnitInfo( |
| 698 base::Int64ToString(secondary.id()), info, &success, &error); | 700 base::Int64ToString(secondary.id()), info, &success, &error); |
| 699 | 701 |
| 700 ASSERT_TRUE(success); | 702 ASSERT_TRUE(success); |
| 701 ASSERT_TRUE(error.empty()); | 703 ASSERT_TRUE(error.empty()); |
| 702 | 704 |
| 703 EXPECT_EQ("1200,450 100x1000", secondary.bounds().ToString()); | 705 EXPECT_EQ("1200,450 100x1000", secondary.bounds().ToString()); |
| 704 } | 706 } |
| 705 | 707 |
| 706 TEST_F(DisplayInfoProviderChromeosTest, SetBoundsOriginPrimaryHiDPI) { | 708 TEST_F(DisplayInfoProviderChromeosTest, SetBoundsOriginPrimaryHiDPI) { |
| 707 UpdateDisplay("1200x600*2,500x500"); | 709 UpdateDisplay("1200x600*2,500x500"); |
| 708 | 710 |
| 709 const display::Display& secondary = ash::ScreenUtil::GetSecondaryDisplay(); | 711 const display::Display& secondary = display_manager()->GetSecondaryDisplay(); |
| 710 api::system_display::DisplayProperties info; | 712 api::system_display::DisplayProperties info; |
| 711 info.bounds_origin_x.reset(new int(250)); | 713 info.bounds_origin_x.reset(new int(250)); |
| 712 info.bounds_origin_y.reset(new int(-100)); | 714 info.bounds_origin_y.reset(new int(-100)); |
| 713 | 715 |
| 714 bool success = false; | 716 bool success = false; |
| 715 std::string error; | 717 std::string error; |
| 716 CallSetDisplayUnitInfo( | 718 CallSetDisplayUnitInfo( |
| 717 base::Int64ToString(secondary.id()), info, &success, &error); | 719 base::Int64ToString(secondary.id()), info, &success, &error); |
| 718 | 720 |
| 719 ASSERT_TRUE(success); | 721 ASSERT_TRUE(success); |
| 720 ASSERT_TRUE(error.empty()); | 722 ASSERT_TRUE(error.empty()); |
| 721 | 723 |
| 722 EXPECT_EQ("600,-100 500x500", secondary.bounds().ToString()); | 724 EXPECT_EQ("600,-100 500x500", secondary.bounds().ToString()); |
| 723 } | 725 } |
| 724 | 726 |
| 725 TEST_F(DisplayInfoProviderChromeosTest, SetBoundsOriginSecondaryHiDPI) { | 727 TEST_F(DisplayInfoProviderChromeosTest, SetBoundsOriginSecondaryHiDPI) { |
| 726 UpdateDisplay("1200x600,600x1000*2"); | 728 UpdateDisplay("1200x600,600x1000*2"); |
| 727 | 729 |
| 728 const display::Display& secondary = ash::ScreenUtil::GetSecondaryDisplay(); | 730 const display::Display& secondary = display_manager()->GetSecondaryDisplay(); |
| 729 api::system_display::DisplayProperties info; | 731 api::system_display::DisplayProperties info; |
| 730 info.bounds_origin_x.reset(new int(450)); | 732 info.bounds_origin_x.reset(new int(450)); |
| 731 info.bounds_origin_y.reset(new int(-100)); | 733 info.bounds_origin_y.reset(new int(-100)); |
| 732 | 734 |
| 733 bool success = false; | 735 bool success = false; |
| 734 std::string error; | 736 std::string error; |
| 735 CallSetDisplayUnitInfo( | 737 CallSetDisplayUnitInfo( |
| 736 base::Int64ToString(secondary.id()), info, &success, &error); | 738 base::Int64ToString(secondary.id()), info, &success, &error); |
| 737 | 739 |
| 738 ASSERT_TRUE(success); | 740 ASSERT_TRUE(success); |
| 739 ASSERT_TRUE(error.empty()); | 741 ASSERT_TRUE(error.empty()); |
| 740 | 742 |
| 741 EXPECT_EQ("450,-500 300x500", secondary.bounds().ToString()); | 743 EXPECT_EQ("450,-500 300x500", secondary.bounds().ToString()); |
| 742 } | 744 } |
| 743 | 745 |
| 744 TEST_F(DisplayInfoProviderChromeosTest, SetBoundsOriginOutOfBounds) { | 746 TEST_F(DisplayInfoProviderChromeosTest, SetBoundsOriginOutOfBounds) { |
| 745 UpdateDisplay("1200x600,600x1000*2"); | 747 UpdateDisplay("1200x600,600x1000*2"); |
| 746 | 748 |
| 747 const display::Display& secondary = ash::ScreenUtil::GetSecondaryDisplay(); | 749 const display::Display& secondary = display_manager()->GetSecondaryDisplay(); |
| 748 api::system_display::DisplayProperties info; | 750 api::system_display::DisplayProperties info; |
| 749 info.bounds_origin_x.reset(new int(0x200001)); | 751 info.bounds_origin_x.reset(new int(0x200001)); |
| 750 info.bounds_origin_y.reset(new int(-100)); | 752 info.bounds_origin_y.reset(new int(-100)); |
| 751 | 753 |
| 752 bool success = false; | 754 bool success = false; |
| 753 std::string error; | 755 std::string error; |
| 754 CallSetDisplayUnitInfo( | 756 CallSetDisplayUnitInfo( |
| 755 base::Int64ToString(secondary.id()), info, &success, &error); | 757 base::Int64ToString(secondary.id()), info, &success, &error); |
| 756 | 758 |
| 757 ASSERT_FALSE(success); | 759 ASSERT_FALSE(success); |
| 758 ASSERT_EQ("Bounds origin x out of bounds.", error); | 760 ASSERT_EQ("Bounds origin x out of bounds.", error); |
| 759 | 761 |
| 760 EXPECT_EQ("1200,0 300x500", secondary.bounds().ToString()); | 762 EXPECT_EQ("1200,0 300x500", secondary.bounds().ToString()); |
| 761 } | 763 } |
| 762 | 764 |
| 763 TEST_F(DisplayInfoProviderChromeosTest, SetBoundsOriginOutOfBoundsNegative) { | 765 TEST_F(DisplayInfoProviderChromeosTest, SetBoundsOriginOutOfBoundsNegative) { |
| 764 UpdateDisplay("1200x600,600x1000*2"); | 766 UpdateDisplay("1200x600,600x1000*2"); |
| 765 | 767 |
| 766 const display::Display& secondary = ash::ScreenUtil::GetSecondaryDisplay(); | 768 const display::Display& secondary = display_manager()->GetSecondaryDisplay(); |
| 767 api::system_display::DisplayProperties info; | 769 api::system_display::DisplayProperties info; |
| 768 info.bounds_origin_x.reset(new int(300)); | 770 info.bounds_origin_x.reset(new int(300)); |
| 769 info.bounds_origin_y.reset(new int(-0x200001)); | 771 info.bounds_origin_y.reset(new int(-0x200001)); |
| 770 | 772 |
| 771 bool success = false; | 773 bool success = false; |
| 772 std::string error; | 774 std::string error; |
| 773 CallSetDisplayUnitInfo( | 775 CallSetDisplayUnitInfo( |
| 774 base::Int64ToString(secondary.id()), info, &success, &error); | 776 base::Int64ToString(secondary.id()), info, &success, &error); |
| 775 | 777 |
| 776 ASSERT_FALSE(success); | 778 ASSERT_FALSE(success); |
| 777 ASSERT_EQ("Bounds origin y out of bounds.", error); | 779 ASSERT_EQ("Bounds origin y out of bounds.", error); |
| 778 | 780 |
| 779 EXPECT_EQ("1200,0 300x500", secondary.bounds().ToString()); | 781 EXPECT_EQ("1200,0 300x500", secondary.bounds().ToString()); |
| 780 } | 782 } |
| 781 | 783 |
| 782 TEST_F(DisplayInfoProviderChromeosTest, SetBoundsOriginMaxValues) { | 784 TEST_F(DisplayInfoProviderChromeosTest, SetBoundsOriginMaxValues) { |
| 783 UpdateDisplay("1200x4600,600x1000*2"); | 785 UpdateDisplay("1200x4600,600x1000*2"); |
| 784 | 786 |
| 785 const display::Display& secondary = ash::ScreenUtil::GetSecondaryDisplay(); | 787 const display::Display& secondary = display_manager()->GetSecondaryDisplay(); |
| 786 api::system_display::DisplayProperties info; | 788 api::system_display::DisplayProperties info; |
| 787 info.bounds_origin_x.reset(new int(200000)); | 789 info.bounds_origin_x.reset(new int(200000)); |
| 788 info.bounds_origin_y.reset(new int(10)); | 790 info.bounds_origin_y.reset(new int(10)); |
| 789 | 791 |
| 790 bool success = false; | 792 bool success = false; |
| 791 std::string error; | 793 std::string error; |
| 792 CallSetDisplayUnitInfo( | 794 CallSetDisplayUnitInfo( |
| 793 base::Int64ToString(secondary.id()), info, &success, &error); | 795 base::Int64ToString(secondary.id()), info, &success, &error); |
| 794 | 796 |
| 795 ASSERT_TRUE(success); | 797 ASSERT_TRUE(success); |
| 796 EXPECT_TRUE(error.empty()); | 798 EXPECT_TRUE(error.empty()); |
| 797 | 799 |
| 798 EXPECT_EQ("1200,10 300x500", secondary.bounds().ToString()); | 800 EXPECT_EQ("1200,10 300x500", secondary.bounds().ToString()); |
| 799 } | 801 } |
| 800 | 802 |
| 801 TEST_F(DisplayInfoProviderChromeosTest, SetBoundsOriginOnPrimary) { | 803 TEST_F(DisplayInfoProviderChromeosTest, SetBoundsOriginOnPrimary) { |
| 802 UpdateDisplay("1200x600,600x1000*2"); | 804 UpdateDisplay("1200x600,600x1000*2"); |
| 803 | 805 |
| 804 const display::Display& secondary = ash::ScreenUtil::GetSecondaryDisplay(); | 806 const display::Display& secondary = display_manager()->GetSecondaryDisplay(); |
| 805 api::system_display::DisplayProperties info; | 807 api::system_display::DisplayProperties info; |
| 806 info.bounds_origin_x.reset(new int(300)); | 808 info.bounds_origin_x.reset(new int(300)); |
| 807 info.is_primary.reset(new bool(true)); | 809 info.is_primary.reset(new bool(true)); |
| 808 | 810 |
| 809 bool success = false; | 811 bool success = false; |
| 810 std::string error; | 812 std::string error; |
| 811 CallSetDisplayUnitInfo( | 813 CallSetDisplayUnitInfo( |
| 812 base::Int64ToString(secondary.id()), info, &success, &error); | 814 base::Int64ToString(secondary.id()), info, &success, &error); |
| 813 | 815 |
| 814 ASSERT_FALSE(success); | 816 ASSERT_FALSE(success); |
| 815 ASSERT_EQ("Bounds origin not allowed for the primary display.", error); | 817 ASSERT_EQ("Bounds origin not allowed for the primary display.", error); |
| 816 | 818 |
| 817 EXPECT_EQ("1200,0 300x500", secondary.bounds().ToString()); | 819 EXPECT_EQ("1200,0 300x500", secondary.bounds().ToString()); |
| 818 // The operation failed because the primary property would be set before | 820 // The operation failed because the primary property would be set before |
| 819 // setting bounds. The primary display shouldn't have been changed, though. | 821 // setting bounds. The primary display shouldn't have been changed, though. |
| 820 EXPECT_NE(display::Screen::GetScreen()->GetPrimaryDisplay().id(), | 822 EXPECT_NE(display::Screen::GetScreen()->GetPrimaryDisplay().id(), |
| 821 secondary.id()); | 823 secondary.id()); |
| 822 } | 824 } |
| 823 | 825 |
| 824 TEST_F(DisplayInfoProviderChromeosTest, SetBoundsOriginWithMirroring) { | 826 TEST_F(DisplayInfoProviderChromeosTest, SetBoundsOriginWithMirroring) { |
| 825 UpdateDisplay("1200x600,600x1000*2"); | 827 UpdateDisplay("1200x600,600x1000*2"); |
| 826 | 828 |
| 827 const display::Display& secondary = ash::ScreenUtil::GetSecondaryDisplay(); | 829 const display::Display& secondary = display_manager()->GetSecondaryDisplay(); |
| 828 const display::Display& primary = | 830 const display::Display& primary = |
| 829 display::Screen::GetScreen()->GetPrimaryDisplay(); | 831 display::Screen::GetScreen()->GetPrimaryDisplay(); |
| 830 | 832 |
| 831 api::system_display::DisplayProperties info; | 833 api::system_display::DisplayProperties info; |
| 832 info.bounds_origin_x.reset(new int(300)); | 834 info.bounds_origin_x.reset(new int(300)); |
| 833 info.mirroring_source_id.reset( | 835 info.mirroring_source_id.reset( |
| 834 new std::string(base::Int64ToString(primary.id()))); | 836 new std::string(base::Int64ToString(primary.id()))); |
| 835 | 837 |
| 836 bool success = false; | 838 bool success = false; |
| 837 std::string error; | 839 std::string error; |
| 838 CallSetDisplayUnitInfo( | 840 CallSetDisplayUnitInfo( |
| 839 base::Int64ToString(secondary.id()), info, &success, &error); | 841 base::Int64ToString(secondary.id()), info, &success, &error); |
| 840 | 842 |
| 841 ASSERT_FALSE(success); | 843 ASSERT_FALSE(success); |
| 842 ASSERT_EQ("No other parameter should be set alongside mirroringSourceId.", | 844 ASSERT_EQ("No other parameter should be set alongside mirroringSourceId.", |
| 843 error); | 845 error); |
| 844 } | 846 } |
| 845 | 847 |
| 846 TEST_F(DisplayInfoProviderChromeosTest, SetRotation) { | 848 TEST_F(DisplayInfoProviderChromeosTest, SetRotation) { |
| 847 UpdateDisplay("1200x600,600x1000*2"); | 849 UpdateDisplay("1200x600,600x1000*2"); |
| 848 | 850 |
| 849 const display::Display& secondary = ash::ScreenUtil::GetSecondaryDisplay(); | 851 const display::Display& secondary = display_manager()->GetSecondaryDisplay(); |
| 850 api::system_display::DisplayProperties info; | 852 api::system_display::DisplayProperties info; |
| 851 info.rotation.reset(new int(90)); | 853 info.rotation.reset(new int(90)); |
| 852 | 854 |
| 853 bool success = false; | 855 bool success = false; |
| 854 std::string error; | 856 std::string error; |
| 855 CallSetDisplayUnitInfo( | 857 CallSetDisplayUnitInfo( |
| 856 base::Int64ToString(secondary.id()), info, &success, &error); | 858 base::Int64ToString(secondary.id()), info, &success, &error); |
| 857 | 859 |
| 858 ASSERT_TRUE(success); | 860 ASSERT_TRUE(success); |
| 859 EXPECT_TRUE(error.empty()); | 861 EXPECT_TRUE(error.empty()); |
| (...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 960 ASSERT_TRUE(success); | 962 ASSERT_TRUE(success); |
| 961 EXPECT_TRUE(error.empty()); | 963 EXPECT_TRUE(error.empty()); |
| 962 EXPECT_TRUE(ash::Shell::GetInstance() | 964 EXPECT_TRUE(ash::Shell::GetInstance() |
| 963 ->screen_orientation_controller() | 965 ->screen_orientation_controller() |
| 964 ->rotation_locked()); | 966 ->rotation_locked()); |
| 965 } | 967 } |
| 966 | 968 |
| 967 TEST_F(DisplayInfoProviderChromeosTest, SetInvalidRotation) { | 969 TEST_F(DisplayInfoProviderChromeosTest, SetInvalidRotation) { |
| 968 UpdateDisplay("1200x600,600x1000*2"); | 970 UpdateDisplay("1200x600,600x1000*2"); |
| 969 | 971 |
| 970 const display::Display& secondary = ash::ScreenUtil::GetSecondaryDisplay(); | 972 const display::Display& secondary = display_manager()->GetSecondaryDisplay(); |
| 971 api::system_display::DisplayProperties info; | 973 api::system_display::DisplayProperties info; |
| 972 info.rotation.reset(new int(91)); | 974 info.rotation.reset(new int(91)); |
| 973 | 975 |
| 974 bool success = false; | 976 bool success = false; |
| 975 std::string error; | 977 std::string error; |
| 976 CallSetDisplayUnitInfo( | 978 CallSetDisplayUnitInfo( |
| 977 base::Int64ToString(secondary.id()), info, &success, &error); | 979 base::Int64ToString(secondary.id()), info, &success, &error); |
| 978 | 980 |
| 979 ASSERT_FALSE(success); | 981 ASSERT_FALSE(success); |
| 980 EXPECT_EQ("Invalid rotation.", error); | 982 EXPECT_EQ("Invalid rotation.", error); |
| 981 } | 983 } |
| 982 | 984 |
| 983 TEST_F(DisplayInfoProviderChromeosTest, SetNegativeOverscan) { | 985 TEST_F(DisplayInfoProviderChromeosTest, SetNegativeOverscan) { |
| 984 UpdateDisplay("1200x600,600x1000*2"); | 986 UpdateDisplay("1200x600,600x1000*2"); |
| 985 | 987 |
| 986 const display::Display& secondary = ash::ScreenUtil::GetSecondaryDisplay(); | 988 const display::Display& secondary = display_manager()->GetSecondaryDisplay(); |
| 987 api::system_display::DisplayProperties info; | 989 api::system_display::DisplayProperties info; |
| 988 info.overscan.reset(new api::system_display::Insets); | 990 info.overscan.reset(new api::system_display::Insets); |
| 989 info.overscan->left = -10; | 991 info.overscan->left = -10; |
| 990 | 992 |
| 991 bool success = false; | 993 bool success = false; |
| 992 std::string error; | 994 std::string error; |
| 993 CallSetDisplayUnitInfo( | 995 CallSetDisplayUnitInfo( |
| 994 base::Int64ToString(secondary.id()), info, &success, &error); | 996 base::Int64ToString(secondary.id()), info, &success, &error); |
| 995 | 997 |
| 996 ASSERT_FALSE(success); | 998 ASSERT_FALSE(success); |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1039 | 1041 |
| 1040 ASSERT_TRUE(success); | 1042 ASSERT_TRUE(success); |
| 1041 EXPECT_TRUE(error.empty()); | 1043 EXPECT_TRUE(error.empty()); |
| 1042 | 1044 |
| 1043 EXPECT_EQ("1200,0 300x500", secondary.bounds().ToString()); | 1045 EXPECT_EQ("1200,0 300x500", secondary.bounds().ToString()); |
| 1044 } | 1046 } |
| 1045 | 1047 |
| 1046 TEST_F(DisplayInfoProviderChromeosTest, SetOverscanLargerThanHorizontalBounds) { | 1048 TEST_F(DisplayInfoProviderChromeosTest, SetOverscanLargerThanHorizontalBounds) { |
| 1047 UpdateDisplay("1200x600,600x1000*2"); | 1049 UpdateDisplay("1200x600,600x1000*2"); |
| 1048 | 1050 |
| 1049 const display::Display& secondary = ash::ScreenUtil::GetSecondaryDisplay(); | 1051 const display::Display& secondary = display_manager()->GetSecondaryDisplay(); |
| 1050 api::system_display::DisplayProperties info; | 1052 api::system_display::DisplayProperties info; |
| 1051 info.overscan.reset(new api::system_display::Insets); | 1053 info.overscan.reset(new api::system_display::Insets); |
| 1052 // Horizontal overscan is 151, which would make the bounds width 149. | 1054 // Horizontal overscan is 151, which would make the bounds width 149. |
| 1053 info.overscan->left = 50; | 1055 info.overscan->left = 50; |
| 1054 info.overscan->top = 10; | 1056 info.overscan->top = 10; |
| 1055 info.overscan->right = 101; | 1057 info.overscan->right = 101; |
| 1056 info.overscan->bottom = 20; | 1058 info.overscan->bottom = 20; |
| 1057 | 1059 |
| 1058 bool success = false; | 1060 bool success = false; |
| 1059 std::string error; | 1061 std::string error; |
| 1060 CallSetDisplayUnitInfo( | 1062 CallSetDisplayUnitInfo( |
| 1061 base::Int64ToString(secondary.id()), info, &success, &error); | 1063 base::Int64ToString(secondary.id()), info, &success, &error); |
| 1062 | 1064 |
| 1063 ASSERT_FALSE(success); | 1065 ASSERT_FALSE(success); |
| 1064 EXPECT_EQ("Horizontal overscan is more than half of the screen width.", | 1066 EXPECT_EQ("Horizontal overscan is more than half of the screen width.", |
| 1065 error); | 1067 error); |
| 1066 } | 1068 } |
| 1067 | 1069 |
| 1068 TEST_F(DisplayInfoProviderChromeosTest, SetOverscanLargerThanVerticalBounds) { | 1070 TEST_F(DisplayInfoProviderChromeosTest, SetOverscanLargerThanVerticalBounds) { |
| 1069 UpdateDisplay("1200x600,600x1000"); | 1071 UpdateDisplay("1200x600,600x1000"); |
| 1070 | 1072 |
| 1071 const display::Display& secondary = ash::ScreenUtil::GetSecondaryDisplay(); | 1073 const display::Display& secondary = display_manager()->GetSecondaryDisplay(); |
| 1072 api::system_display::DisplayProperties info; | 1074 api::system_display::DisplayProperties info; |
| 1073 info.overscan.reset(new api::system_display::Insets); | 1075 info.overscan.reset(new api::system_display::Insets); |
| 1074 // Vertical overscan is 501, which would make the bounds height 499. | 1076 // Vertical overscan is 501, which would make the bounds height 499. |
| 1075 info.overscan->left = 20; | 1077 info.overscan->left = 20; |
| 1076 info.overscan->top = 250; | 1078 info.overscan->top = 250; |
| 1077 info.overscan->right = 101; | 1079 info.overscan->right = 101; |
| 1078 info.overscan->bottom = 251; | 1080 info.overscan->bottom = 251; |
| 1079 | 1081 |
| 1080 bool success = false; | 1082 bool success = false; |
| 1081 std::string error; | 1083 std::string error; |
| 1082 CallSetDisplayUnitInfo( | 1084 CallSetDisplayUnitInfo( |
| 1083 base::Int64ToString(secondary.id()), info, &success, &error); | 1085 base::Int64ToString(secondary.id()), info, &success, &error); |
| 1084 | 1086 |
| 1085 ASSERT_FALSE(success); | 1087 ASSERT_FALSE(success); |
| 1086 EXPECT_EQ("Vertical overscan is more than half of the screen height.", error); | 1088 EXPECT_EQ("Vertical overscan is more than half of the screen height.", error); |
| 1087 } | 1089 } |
| 1088 | 1090 |
| 1089 TEST_F(DisplayInfoProviderChromeosTest, SetOverscan) { | 1091 TEST_F(DisplayInfoProviderChromeosTest, SetOverscan) { |
| 1090 UpdateDisplay("1200x600,600x1000*2"); | 1092 UpdateDisplay("1200x600,600x1000*2"); |
| 1091 | 1093 |
| 1092 const display::Display& secondary = ash::ScreenUtil::GetSecondaryDisplay(); | 1094 const display::Display& secondary = display_manager()->GetSecondaryDisplay(); |
| 1093 api::system_display::DisplayProperties info; | 1095 api::system_display::DisplayProperties info; |
| 1094 info.overscan.reset(new api::system_display::Insets); | 1096 info.overscan.reset(new api::system_display::Insets); |
| 1095 info.overscan->left = 20; | 1097 info.overscan->left = 20; |
| 1096 info.overscan->top = 199; | 1098 info.overscan->top = 199; |
| 1097 info.overscan->right = 130; | 1099 info.overscan->right = 130; |
| 1098 info.overscan->bottom = 51; | 1100 info.overscan->bottom = 51; |
| 1099 | 1101 |
| 1100 bool success = false; | 1102 bool success = false; |
| 1101 std::string error; | 1103 std::string error; |
| 1102 CallSetDisplayUnitInfo( | 1104 CallSetDisplayUnitInfo( |
| 1103 base::Int64ToString(secondary.id()), info, &success, &error); | 1105 base::Int64ToString(secondary.id()), info, &success, &error); |
| 1104 | 1106 |
| 1105 ASSERT_TRUE(success); | 1107 ASSERT_TRUE(success); |
| 1106 EXPECT_TRUE(error.empty()); | 1108 EXPECT_TRUE(error.empty()); |
| 1107 | 1109 |
| 1108 EXPECT_EQ("1200,0 150x250", secondary.bounds().ToString()); | 1110 EXPECT_EQ("1200,0 150x250", secondary.bounds().ToString()); |
| 1109 const gfx::Insets overscan = | 1111 const gfx::Insets overscan = |
| 1110 GetDisplayManager()->GetOverscanInsets(secondary.id()); | 1112 GetDisplayManager()->GetOverscanInsets(secondary.id()); |
| 1111 | 1113 |
| 1112 EXPECT_EQ(20, overscan.left()); | 1114 EXPECT_EQ(20, overscan.left()); |
| 1113 EXPECT_EQ(199, overscan.top()); | 1115 EXPECT_EQ(199, overscan.top()); |
| 1114 EXPECT_EQ(130, overscan.right()); | 1116 EXPECT_EQ(130, overscan.right()); |
| 1115 EXPECT_EQ(51, overscan.bottom()); | 1117 EXPECT_EQ(51, overscan.bottom()); |
| 1116 } | 1118 } |
| 1117 | 1119 |
| 1118 TEST_F(DisplayInfoProviderChromeosTest, SetOverscanForInternal) { | 1120 TEST_F(DisplayInfoProviderChromeosTest, SetOverscanForInternal) { |
| 1119 UpdateDisplay("1200x600,600x1000*2"); | 1121 UpdateDisplay("1200x600,600x1000*2"); |
| 1120 const int64_t internal_display_id = | 1122 const int64_t internal_display_id = |
| 1121 ash::test::DisplayManagerTestApi().SetFirstDisplayAsInternalDisplay(); | 1123 ash::test::DisplayManagerTestApi( |
| 1124 ash::Shell::GetInstance()->display_manager()) |
| 1125 .SetFirstDisplayAsInternalDisplay(); |
| 1122 | 1126 |
| 1123 api::system_display::DisplayProperties info; | 1127 api::system_display::DisplayProperties info; |
| 1124 info.overscan.reset(new api::system_display::Insets); | 1128 info.overscan.reset(new api::system_display::Insets); |
| 1125 // Vertical overscan is 501, which would make the bounds height 499. | 1129 // Vertical overscan is 501, which would make the bounds height 499. |
| 1126 info.overscan->left = 20; | 1130 info.overscan->left = 20; |
| 1127 info.overscan->top = 20; | 1131 info.overscan->top = 20; |
| 1128 info.overscan->right = 20; | 1132 info.overscan->right = 20; |
| 1129 info.overscan->bottom = 20; | 1133 info.overscan->bottom = 20; |
| 1130 | 1134 |
| 1131 bool success = false; | 1135 bool success = false; |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1186 CallSetDisplayUnitInfo(base::Int64ToString(id), info, &success, &error); | 1190 CallSetDisplayUnitInfo(base::Int64ToString(id), info, &success, &error); |
| 1187 ASSERT_TRUE(success); | 1191 ASSERT_TRUE(success); |
| 1188 | 1192 |
| 1189 // Verify that other_mode now matches the active mode. | 1193 // Verify that other_mode now matches the active mode. |
| 1190 active_mode = GetDisplayManager()->GetActiveModeForDisplayId(id); | 1194 active_mode = GetDisplayManager()->GetActiveModeForDisplayId(id); |
| 1191 EXPECT_TRUE(active_mode->IsEquivalent(other_mode_ash)); | 1195 EXPECT_TRUE(active_mode->IsEquivalent(other_mode_ash)); |
| 1192 } | 1196 } |
| 1193 | 1197 |
| 1194 } // namespace | 1198 } // namespace |
| 1195 } // namespace extensions | 1199 } // namespace extensions |
| OLD | NEW |