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