| 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/ash_switches.h" | 9 #include "ash/ash_switches.h" |
| 10 #include "ash/display/display_manager.h" | 10 #include "ash/display/display_manager.h" |
| 11 #include "ash/display/screen_orientation_controller_chromeos.h" | 11 #include "ash/display/screen_orientation_controller_chromeos.h" |
| 12 #include "ash/screen_util.h" | 12 #include "ash/screen_util.h" |
| 13 #include "ash/shell.h" | 13 #include "ash/shell.h" |
| 14 #include "ash/test/ash_test_base.h" | 14 #include "ash/test/ash_test_base.h" |
| 15 #include "ash/test/display_manager_test_api.h" | 15 #include "ash/test/display_manager_test_api.h" |
| 16 #include "ash/wm/maximize_mode/maximize_mode_controller.h" | 16 #include "ash/wm/maximize_mode/maximize_mode_controller.h" |
| 17 #include "base/command_line.h" | 17 #include "base/command_line.h" |
| 18 #include "base/macros.h" | 18 #include "base/macros.h" |
| 19 #include "base/strings/string_number_conversions.h" | 19 #include "base/strings/string_number_conversions.h" |
| 20 #include "base/strings/stringprintf.h" | 20 #include "base/strings/stringprintf.h" |
| 21 #include "extensions/common/api/system_display.h" | 21 #include "extensions/common/api/system_display.h" |
| 22 #include "ui/display/display.h" |
| 22 #include "ui/display/manager/display_layout.h" | 23 #include "ui/display/manager/display_layout.h" |
| 23 #include "ui/gfx/display.h" | |
| 24 #include "ui/gfx/geometry/rect.h" | 24 #include "ui/gfx/geometry/rect.h" |
| 25 | 25 |
| 26 namespace extensions { | 26 namespace extensions { |
| 27 namespace { | 27 namespace { |
| 28 | 28 |
| 29 class DisplayInfoProviderChromeosTest : public ash::test::AshTestBase { | 29 class DisplayInfoProviderChromeosTest : public ash::test::AshTestBase { |
| 30 public: | 30 public: |
| 31 DisplayInfoProviderChromeosTest() {} | 31 DisplayInfoProviderChromeosTest() {} |
| 32 | 32 |
| 33 ~DisplayInfoProviderChromeosTest() override {} | 33 ~DisplayInfoProviderChromeosTest() override {} |
| 34 | 34 |
| 35 void SetUp() override { | 35 void SetUp() override { |
| 36 base::CommandLine::ForCurrentProcess()->AppendSwitch( | 36 base::CommandLine::ForCurrentProcess()->AppendSwitch( |
| 37 ash::switches::kAshUseFirstDisplayAsInternal); | 37 ash::switches::kAshUseFirstDisplayAsInternal); |
| 38 ash::test::AshTestBase::SetUp(); | 38 ash::test::AshTestBase::SetUp(); |
| 39 } | 39 } |
| 40 | 40 |
| 41 protected: | 41 protected: |
| 42 void CallSetDisplayUnitInfo( | 42 void CallSetDisplayUnitInfo( |
| 43 const std::string& display_id, | 43 const std::string& display_id, |
| 44 const api::system_display::DisplayProperties& info, | 44 const api::system_display::DisplayProperties& info, |
| 45 bool* success, | 45 bool* success, |
| 46 std::string* error) { | 46 std::string* error) { |
| 47 // Reset error messsage. | 47 // Reset error messsage. |
| 48 (*error).clear(); | 48 (*error).clear(); |
| 49 *success = DisplayInfoProvider::Get()->SetInfo(display_id, info, error); | 49 *success = DisplayInfoProvider::Get()->SetInfo(display_id, info, error); |
| 50 } | 50 } |
| 51 | 51 |
| 52 bool DisplayExists(int64_t display_id) const { | 52 bool DisplayExists(int64_t display_id) const { |
| 53 const gfx::Display& display = | 53 const display::Display& display = |
| 54 GetDisplayManager()->GetDisplayForId(display_id); | 54 GetDisplayManager()->GetDisplayForId(display_id); |
| 55 return display.id() != gfx::Display::kInvalidDisplayID; | 55 return display.id() != display::Display::kInvalidDisplayID; |
| 56 } | 56 } |
| 57 | 57 |
| 58 ash::DisplayManager* GetDisplayManager() const { | 58 ash::DisplayManager* GetDisplayManager() const { |
| 59 return ash::Shell::GetInstance()->display_manager(); | 59 return ash::Shell::GetInstance()->display_manager(); |
| 60 } | 60 } |
| 61 | 61 |
| 62 std::string SystemInfoDisplayInsetsToString( | 62 std::string SystemInfoDisplayInsetsToString( |
| 63 const api::system_display::Insets& insets) const { | 63 const api::system_display::Insets& insets) const { |
| 64 // Order to match gfx::Insets::ToString(). | 64 // Order to match gfx::Insets::ToString(). |
| 65 return base::StringPrintf( | 65 return base::StringPrintf( |
| (...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 235 ASSERT_EQ(1u, result.size()); | 235 ASSERT_EQ(1u, result.size()); |
| 236 | 236 |
| 237 int64_t display_id; | 237 int64_t display_id; |
| 238 ASSERT_TRUE(base::StringToInt64(result[0].id, &display_id)) | 238 ASSERT_TRUE(base::StringToInt64(result[0].id, &display_id)) |
| 239 << "Display id must be convertable to integer: " << result[0].id; | 239 << "Display id must be convertable to integer: " << result[0].id; |
| 240 | 240 |
| 241 ASSERT_TRUE(DisplayExists(display_id)) << display_id << " not found"; | 241 ASSERT_TRUE(DisplayExists(display_id)) << display_id << " not found"; |
| 242 EXPECT_EQ("0,0 600x500", SystemInfoDisplayBoundsToString(result[0].bounds)); | 242 EXPECT_EQ("0,0 600x500", SystemInfoDisplayBoundsToString(result[0].bounds)); |
| 243 EXPECT_EQ(90, result[0].rotation); | 243 EXPECT_EQ(90, result[0].rotation); |
| 244 | 244 |
| 245 GetDisplayManager()->SetDisplayRotation(display_id, gfx::Display::ROTATE_270, | 245 GetDisplayManager()->SetDisplayRotation( |
| 246 gfx::Display::ROTATION_SOURCE_ACTIVE); | 246 display_id, display::Display::ROTATE_270, |
| 247 display::Display::ROTATION_SOURCE_ACTIVE); |
| 247 | 248 |
| 248 result = DisplayInfoProvider::Get()->GetAllDisplaysInfo(); | 249 result = DisplayInfoProvider::Get()->GetAllDisplaysInfo(); |
| 249 | 250 |
| 250 ASSERT_EQ(1u, result.size()); | 251 ASSERT_EQ(1u, result.size()); |
| 251 | 252 |
| 252 EXPECT_EQ(base::Int64ToString(display_id), result[0].id); | 253 EXPECT_EQ(base::Int64ToString(display_id), result[0].id); |
| 253 EXPECT_EQ("0,0 600x500", SystemInfoDisplayBoundsToString(result[0].bounds)); | 254 EXPECT_EQ("0,0 600x500", SystemInfoDisplayBoundsToString(result[0].bounds)); |
| 254 EXPECT_EQ(270, result[0].rotation); | 255 EXPECT_EQ(270, result[0].rotation); |
| 255 | 256 |
| 256 GetDisplayManager()->SetDisplayRotation(display_id, gfx::Display::ROTATE_180, | 257 GetDisplayManager()->SetDisplayRotation( |
| 257 gfx::Display::ROTATION_SOURCE_ACTIVE); | 258 display_id, display::Display::ROTATE_180, |
| 259 display::Display::ROTATION_SOURCE_ACTIVE); |
| 258 | 260 |
| 259 result = DisplayInfoProvider::Get()->GetAllDisplaysInfo(); | 261 result = DisplayInfoProvider::Get()->GetAllDisplaysInfo(); |
| 260 | 262 |
| 261 ASSERT_EQ(1u, result.size()); | 263 ASSERT_EQ(1u, result.size()); |
| 262 | 264 |
| 263 EXPECT_EQ(base::Int64ToString(display_id), result[0].id); | 265 EXPECT_EQ(base::Int64ToString(display_id), result[0].id); |
| 264 EXPECT_EQ("0,0 500x600", SystemInfoDisplayBoundsToString(result[0].bounds)); | 266 EXPECT_EQ("0,0 500x600", SystemInfoDisplayBoundsToString(result[0].bounds)); |
| 265 EXPECT_EQ(180, result[0].rotation); | 267 EXPECT_EQ(180, result[0].rotation); |
| 266 | 268 |
| 267 GetDisplayManager()->SetDisplayRotation(display_id, gfx::Display::ROTATE_0, | 269 GetDisplayManager()->SetDisplayRotation( |
| 268 gfx::Display::ROTATION_SOURCE_ACTIVE); | 270 display_id, display::Display::ROTATE_0, |
| 271 display::Display::ROTATION_SOURCE_ACTIVE); |
| 269 | 272 |
| 270 result = DisplayInfoProvider::Get()->GetAllDisplaysInfo(); | 273 result = DisplayInfoProvider::Get()->GetAllDisplaysInfo(); |
| 271 | 274 |
| 272 ASSERT_EQ(1u, result.size()); | 275 ASSERT_EQ(1u, result.size()); |
| 273 | 276 |
| 274 EXPECT_EQ(base::Int64ToString(display_id), result[0].id); | 277 EXPECT_EQ(base::Int64ToString(display_id), result[0].id); |
| 275 EXPECT_EQ("0,0 500x600", SystemInfoDisplayBoundsToString(result[0].bounds)); | 278 EXPECT_EQ("0,0 500x600", SystemInfoDisplayBoundsToString(result[0].bounds)); |
| 276 EXPECT_EQ(0, result[0].rotation); | 279 EXPECT_EQ(0, result[0].rotation); |
| 277 } | 280 } |
| 278 | 281 |
| (...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 427 result = DisplayInfoProvider::Get()->GetAllDisplaysInfo(); | 430 result = DisplayInfoProvider::Get()->GetAllDisplaysInfo(); |
| 428 ASSERT_EQ(2u, result.size()); | 431 ASSERT_EQ(2u, result.size()); |
| 429 EXPECT_EQ("0,0 600x600", SystemInfoDisplayBoundsToString(result[0].bounds)); | 432 EXPECT_EQ("0,0 600x600", SystemInfoDisplayBoundsToString(result[0].bounds)); |
| 430 EXPECT_EQ("80,600 400x520", | 433 EXPECT_EQ("80,600 400x520", |
| 431 SystemInfoDisplayBoundsToString(result[1].bounds)); | 434 SystemInfoDisplayBoundsToString(result[1].bounds)); |
| 432 } | 435 } |
| 433 | 436 |
| 434 TEST_F(DisplayInfoProviderChromeosTest, SetBoundsOriginLeftExact) { | 437 TEST_F(DisplayInfoProviderChromeosTest, SetBoundsOriginLeftExact) { |
| 435 UpdateDisplay("1200x600,520x400"); | 438 UpdateDisplay("1200x600,520x400"); |
| 436 | 439 |
| 437 const gfx::Display& secondary = ash::ScreenUtil::GetSecondaryDisplay(); | 440 const display::Display& secondary = ash::ScreenUtil::GetSecondaryDisplay(); |
| 438 api::system_display::DisplayProperties info; | 441 api::system_display::DisplayProperties info; |
| 439 info.bounds_origin_x.reset(new int(-520)); | 442 info.bounds_origin_x.reset(new int(-520)); |
| 440 info.bounds_origin_y.reset(new int(50)); | 443 info.bounds_origin_y.reset(new int(50)); |
| 441 | 444 |
| 442 bool success = false; | 445 bool success = false; |
| 443 std::string error; | 446 std::string error; |
| 444 CallSetDisplayUnitInfo( | 447 CallSetDisplayUnitInfo( |
| 445 base::Int64ToString(secondary.id()), info, &success, &error); | 448 base::Int64ToString(secondary.id()), info, &success, &error); |
| 446 | 449 |
| 447 ASSERT_TRUE(success); | 450 ASSERT_TRUE(success); |
| 448 ASSERT_TRUE(error.empty()); | 451 ASSERT_TRUE(error.empty()); |
| 449 | 452 |
| 450 EXPECT_EQ("-520,50 520x400", secondary.bounds().ToString()); | 453 EXPECT_EQ("-520,50 520x400", secondary.bounds().ToString()); |
| 451 } | 454 } |
| 452 | 455 |
| 453 TEST_F(DisplayInfoProviderChromeosTest, SetBoundsOriginRightExact) { | 456 TEST_F(DisplayInfoProviderChromeosTest, SetBoundsOriginRightExact) { |
| 454 UpdateDisplay("1200x600,520x400"); | 457 UpdateDisplay("1200x600,520x400"); |
| 455 | 458 |
| 456 const gfx::Display& secondary = ash::ScreenUtil::GetSecondaryDisplay(); | 459 const display::Display& secondary = ash::ScreenUtil::GetSecondaryDisplay(); |
| 457 api::system_display::DisplayProperties info; | 460 api::system_display::DisplayProperties info; |
| 458 info.bounds_origin_x.reset(new int(1200)); | 461 info.bounds_origin_x.reset(new int(1200)); |
| 459 info.bounds_origin_y.reset(new int(100)); | 462 info.bounds_origin_y.reset(new int(100)); |
| 460 | 463 |
| 461 bool success = false; | 464 bool success = false; |
| 462 std::string error; | 465 std::string error; |
| 463 CallSetDisplayUnitInfo( | 466 CallSetDisplayUnitInfo( |
| 464 base::Int64ToString(secondary.id()), info, &success, &error); | 467 base::Int64ToString(secondary.id()), info, &success, &error); |
| 465 | 468 |
| 466 ASSERT_TRUE(success); | 469 ASSERT_TRUE(success); |
| 467 ASSERT_TRUE(error.empty()); | 470 ASSERT_TRUE(error.empty()); |
| 468 | 471 |
| 469 EXPECT_EQ("1200,100 520x400", secondary.bounds().ToString()); | 472 EXPECT_EQ("1200,100 520x400", secondary.bounds().ToString()); |
| 470 } | 473 } |
| 471 | 474 |
| 472 TEST_F(DisplayInfoProviderChromeosTest, SetBoundsOriginTopExact) { | 475 TEST_F(DisplayInfoProviderChromeosTest, SetBoundsOriginTopExact) { |
| 473 UpdateDisplay("1200x600,520x400"); | 476 UpdateDisplay("1200x600,520x400"); |
| 474 | 477 |
| 475 const gfx::Display& secondary = ash::ScreenUtil::GetSecondaryDisplay(); | 478 const display::Display& secondary = ash::ScreenUtil::GetSecondaryDisplay(); |
| 476 api::system_display::DisplayProperties info; | 479 api::system_display::DisplayProperties info; |
| 477 info.bounds_origin_x.reset(new int(1100)); | 480 info.bounds_origin_x.reset(new int(1100)); |
| 478 info.bounds_origin_y.reset(new int(-400)); | 481 info.bounds_origin_y.reset(new int(-400)); |
| 479 | 482 |
| 480 bool success = false; | 483 bool success = false; |
| 481 std::string error; | 484 std::string error; |
| 482 CallSetDisplayUnitInfo( | 485 CallSetDisplayUnitInfo( |
| 483 base::Int64ToString(secondary.id()), info, &success, &error); | 486 base::Int64ToString(secondary.id()), info, &success, &error); |
| 484 | 487 |
| 485 ASSERT_TRUE(success); | 488 ASSERT_TRUE(success); |
| 486 ASSERT_TRUE(error.empty()); | 489 ASSERT_TRUE(error.empty()); |
| 487 | 490 |
| 488 EXPECT_EQ("1100,-400 520x400", secondary.bounds().ToString()); | 491 EXPECT_EQ("1100,-400 520x400", secondary.bounds().ToString()); |
| 489 } | 492 } |
| 490 | 493 |
| 491 TEST_F(DisplayInfoProviderChromeosTest, SetBoundsOriginBottomExact) { | 494 TEST_F(DisplayInfoProviderChromeosTest, SetBoundsOriginBottomExact) { |
| 492 UpdateDisplay("1200x600,520x400"); | 495 UpdateDisplay("1200x600,520x400"); |
| 493 | 496 |
| 494 const gfx::Display& secondary = ash::ScreenUtil::GetSecondaryDisplay(); | 497 const display::Display& secondary = ash::ScreenUtil::GetSecondaryDisplay(); |
| 495 api::system_display::DisplayProperties info; | 498 api::system_display::DisplayProperties info; |
| 496 info.bounds_origin_x.reset(new int(-350)); | 499 info.bounds_origin_x.reset(new int(-350)); |
| 497 info.bounds_origin_y.reset(new int(600)); | 500 info.bounds_origin_y.reset(new int(600)); |
| 498 | 501 |
| 499 bool success = false; | 502 bool success = false; |
| 500 std::string error; | 503 std::string error; |
| 501 CallSetDisplayUnitInfo( | 504 CallSetDisplayUnitInfo( |
| 502 base::Int64ToString(secondary.id()), info, &success, &error); | 505 base::Int64ToString(secondary.id()), info, &success, &error); |
| 503 | 506 |
| 504 ASSERT_TRUE(success); | 507 ASSERT_TRUE(success); |
| 505 ASSERT_TRUE(error.empty()); | 508 ASSERT_TRUE(error.empty()); |
| 506 | 509 |
| 507 EXPECT_EQ("-350,600 520x400", secondary.bounds().ToString()); | 510 EXPECT_EQ("-350,600 520x400", secondary.bounds().ToString()); |
| 508 } | 511 } |
| 509 | 512 |
| 510 TEST_F(DisplayInfoProviderChromeosTest, SetBoundsOriginSameCenter) { | 513 TEST_F(DisplayInfoProviderChromeosTest, SetBoundsOriginSameCenter) { |
| 511 UpdateDisplay("1200x600,520x400"); | 514 UpdateDisplay("1200x600,520x400"); |
| 512 | 515 |
| 513 const gfx::Display& secondary = ash::ScreenUtil::GetSecondaryDisplay(); | 516 const display::Display& secondary = ash::ScreenUtil::GetSecondaryDisplay(); |
| 514 api::system_display::DisplayProperties info; | 517 api::system_display::DisplayProperties info; |
| 515 info.bounds_origin_x.reset(new int(340)); | 518 info.bounds_origin_x.reset(new int(340)); |
| 516 info.bounds_origin_y.reset(new int(100)); | 519 info.bounds_origin_y.reset(new int(100)); |
| 517 | 520 |
| 518 bool success = false; | 521 bool success = false; |
| 519 std::string error; | 522 std::string error; |
| 520 CallSetDisplayUnitInfo( | 523 CallSetDisplayUnitInfo( |
| 521 base::Int64ToString(secondary.id()), info, &success, &error); | 524 base::Int64ToString(secondary.id()), info, &success, &error); |
| 522 | 525 |
| 523 ASSERT_TRUE(success); | 526 ASSERT_TRUE(success); |
| 524 ASSERT_TRUE(error.empty()); | 527 ASSERT_TRUE(error.empty()); |
| 525 | 528 |
| 526 EXPECT_EQ("1200,100 520x400", secondary.bounds().ToString()); | 529 EXPECT_EQ("1200,100 520x400", secondary.bounds().ToString()); |
| 527 } | 530 } |
| 528 | 531 |
| 529 TEST_F(DisplayInfoProviderChromeosTest, SetBoundsOriginLeftOutside) { | 532 TEST_F(DisplayInfoProviderChromeosTest, SetBoundsOriginLeftOutside) { |
| 530 UpdateDisplay("1200x600,520x400"); | 533 UpdateDisplay("1200x600,520x400"); |
| 531 | 534 |
| 532 const gfx::Display& secondary = ash::ScreenUtil::GetSecondaryDisplay(); | 535 const display::Display& secondary = ash::ScreenUtil::GetSecondaryDisplay(); |
| 533 api::system_display::DisplayProperties info; | 536 api::system_display::DisplayProperties info; |
| 534 info.bounds_origin_x.reset(new int(-1040)); | 537 info.bounds_origin_x.reset(new int(-1040)); |
| 535 info.bounds_origin_y.reset(new int(100)); | 538 info.bounds_origin_y.reset(new int(100)); |
| 536 | 539 |
| 537 bool success = false; | 540 bool success = false; |
| 538 std::string error; | 541 std::string error; |
| 539 CallSetDisplayUnitInfo( | 542 CallSetDisplayUnitInfo( |
| 540 base::Int64ToString(secondary.id()), info, &success, &error); | 543 base::Int64ToString(secondary.id()), info, &success, &error); |
| 541 | 544 |
| 542 ASSERT_TRUE(success); | 545 ASSERT_TRUE(success); |
| 543 ASSERT_TRUE(error.empty()); | 546 ASSERT_TRUE(error.empty()); |
| 544 | 547 |
| 545 EXPECT_EQ("-520,100 520x400", secondary.bounds().ToString()); | 548 EXPECT_EQ("-520,100 520x400", secondary.bounds().ToString()); |
| 546 } | 549 } |
| 547 | 550 |
| 548 TEST_F(DisplayInfoProviderChromeosTest, SetBoundsOriginTopOutside) { | 551 TEST_F(DisplayInfoProviderChromeosTest, SetBoundsOriginTopOutside) { |
| 549 UpdateDisplay("1200x600,520x400"); | 552 UpdateDisplay("1200x600,520x400"); |
| 550 | 553 |
| 551 const gfx::Display& secondary = ash::ScreenUtil::GetSecondaryDisplay(); | 554 const display::Display& secondary = ash::ScreenUtil::GetSecondaryDisplay(); |
| 552 api::system_display::DisplayProperties info; | 555 api::system_display::DisplayProperties info; |
| 553 info.bounds_origin_x.reset(new int(-360)); | 556 info.bounds_origin_x.reset(new int(-360)); |
| 554 info.bounds_origin_y.reset(new int(-301)); | 557 info.bounds_origin_y.reset(new int(-301)); |
| 555 | 558 |
| 556 bool success = false; | 559 bool success = false; |
| 557 std::string error; | 560 std::string error; |
| 558 CallSetDisplayUnitInfo( | 561 CallSetDisplayUnitInfo( |
| 559 base::Int64ToString(secondary.id()), info, &success, &error); | 562 base::Int64ToString(secondary.id()), info, &success, &error); |
| 560 | 563 |
| 561 ASSERT_TRUE(success); | 564 ASSERT_TRUE(success); |
| 562 ASSERT_TRUE(error.empty()); | 565 ASSERT_TRUE(error.empty()); |
| 563 | 566 |
| 564 EXPECT_EQ("-360,-400 520x400", secondary.bounds().ToString()); | 567 EXPECT_EQ("-360,-400 520x400", secondary.bounds().ToString()); |
| 565 } | 568 } |
| 566 | 569 |
| 567 TEST_F(DisplayInfoProviderChromeosTest, | 570 TEST_F(DisplayInfoProviderChromeosTest, |
| 568 SetBoundsOriginLeftButSharesBottomSide) { | 571 SetBoundsOriginLeftButSharesBottomSide) { |
| 569 UpdateDisplay("1200x600,1000x100"); | 572 UpdateDisplay("1200x600,1000x100"); |
| 570 | 573 |
| 571 const gfx::Display& secondary = ash::ScreenUtil::GetSecondaryDisplay(); | 574 const display::Display& secondary = ash::ScreenUtil::GetSecondaryDisplay(); |
| 572 api::system_display::DisplayProperties info; | 575 api::system_display::DisplayProperties info; |
| 573 info.bounds_origin_x.reset(new int(-650)); | 576 info.bounds_origin_x.reset(new int(-650)); |
| 574 info.bounds_origin_y.reset(new int(700)); | 577 info.bounds_origin_y.reset(new int(700)); |
| 575 | 578 |
| 576 bool success = false; | 579 bool success = false; |
| 577 std::string error; | 580 std::string error; |
| 578 CallSetDisplayUnitInfo( | 581 CallSetDisplayUnitInfo( |
| 579 base::Int64ToString(secondary.id()), info, &success, &error); | 582 base::Int64ToString(secondary.id()), info, &success, &error); |
| 580 | 583 |
| 581 ASSERT_TRUE(success); | 584 ASSERT_TRUE(success); |
| 582 ASSERT_TRUE(error.empty()); | 585 ASSERT_TRUE(error.empty()); |
| 583 | 586 |
| 584 EXPECT_EQ("-650,600 1000x100", secondary.bounds().ToString()); | 587 EXPECT_EQ("-650,600 1000x100", secondary.bounds().ToString()); |
| 585 } | 588 } |
| 586 | 589 |
| 587 TEST_F(DisplayInfoProviderChromeosTest, SetBoundsOriginRightButSharesTopSide) { | 590 TEST_F(DisplayInfoProviderChromeosTest, SetBoundsOriginRightButSharesTopSide) { |
| 588 UpdateDisplay("1200x600,1000x100"); | 591 UpdateDisplay("1200x600,1000x100"); |
| 589 | 592 |
| 590 const gfx::Display& secondary = ash::ScreenUtil::GetSecondaryDisplay(); | 593 const display::Display& secondary = ash::ScreenUtil::GetSecondaryDisplay(); |
| 591 api::system_display::DisplayProperties info; | 594 api::system_display::DisplayProperties info; |
| 592 info.bounds_origin_x.reset(new int(850)); | 595 info.bounds_origin_x.reset(new int(850)); |
| 593 info.bounds_origin_y.reset(new int(-150)); | 596 info.bounds_origin_y.reset(new int(-150)); |
| 594 | 597 |
| 595 bool success = false; | 598 bool success = false; |
| 596 std::string error; | 599 std::string error; |
| 597 CallSetDisplayUnitInfo( | 600 CallSetDisplayUnitInfo( |
| 598 base::Int64ToString(secondary.id()), info, &success, &error); | 601 base::Int64ToString(secondary.id()), info, &success, &error); |
| 599 | 602 |
| 600 ASSERT_TRUE(success); | 603 ASSERT_TRUE(success); |
| 601 ASSERT_TRUE(error.empty()); | 604 ASSERT_TRUE(error.empty()); |
| 602 | 605 |
| 603 EXPECT_EQ("850,-100 1000x100", secondary.bounds().ToString()); | 606 EXPECT_EQ("850,-100 1000x100", secondary.bounds().ToString()); |
| 604 } | 607 } |
| 605 | 608 |
| 606 TEST_F(DisplayInfoProviderChromeosTest, SetBoundsOriginTopButSharesLeftSide) { | 609 TEST_F(DisplayInfoProviderChromeosTest, SetBoundsOriginTopButSharesLeftSide) { |
| 607 UpdateDisplay("1200x600,1000x100/l"); | 610 UpdateDisplay("1200x600,1000x100/l"); |
| 608 | 611 |
| 609 const gfx::Display& secondary = ash::ScreenUtil::GetSecondaryDisplay(); | 612 const display::Display& secondary = ash::ScreenUtil::GetSecondaryDisplay(); |
| 610 api::system_display::DisplayProperties info; | 613 api::system_display::DisplayProperties info; |
| 611 info.bounds_origin_x.reset(new int(-150)); | 614 info.bounds_origin_x.reset(new int(-150)); |
| 612 info.bounds_origin_y.reset(new int(-650)); | 615 info.bounds_origin_y.reset(new int(-650)); |
| 613 | 616 |
| 614 bool success = false; | 617 bool success = false; |
| 615 std::string error; | 618 std::string error; |
| 616 CallSetDisplayUnitInfo( | 619 CallSetDisplayUnitInfo( |
| 617 base::Int64ToString(secondary.id()), info, &success, &error); | 620 base::Int64ToString(secondary.id()), info, &success, &error); |
| 618 | 621 |
| 619 ASSERT_TRUE(success); | 622 ASSERT_TRUE(success); |
| 620 ASSERT_TRUE(error.empty()); | 623 ASSERT_TRUE(error.empty()); |
| 621 | 624 |
| 622 EXPECT_EQ("-100,-650 100x1000", secondary.bounds().ToString()); | 625 EXPECT_EQ("-100,-650 100x1000", secondary.bounds().ToString()); |
| 623 } | 626 } |
| 624 | 627 |
| 625 TEST_F(DisplayInfoProviderChromeosTest, | 628 TEST_F(DisplayInfoProviderChromeosTest, |
| 626 SetBoundsOriginBottomButSharesRightSide) { | 629 SetBoundsOriginBottomButSharesRightSide) { |
| 627 UpdateDisplay("1200x600,1000x100/l"); | 630 UpdateDisplay("1200x600,1000x100/l"); |
| 628 | 631 |
| 629 const gfx::Display& secondary = ash::ScreenUtil::GetSecondaryDisplay(); | 632 const display::Display& secondary = ash::ScreenUtil::GetSecondaryDisplay(); |
| 630 api::system_display::DisplayProperties info; | 633 api::system_display::DisplayProperties info; |
| 631 info.bounds_origin_x.reset(new int(1350)); | 634 info.bounds_origin_x.reset(new int(1350)); |
| 632 info.bounds_origin_y.reset(new int(450)); | 635 info.bounds_origin_y.reset(new int(450)); |
| 633 | 636 |
| 634 bool success = false; | 637 bool success = false; |
| 635 std::string error; | 638 std::string error; |
| 636 CallSetDisplayUnitInfo( | 639 CallSetDisplayUnitInfo( |
| 637 base::Int64ToString(secondary.id()), info, &success, &error); | 640 base::Int64ToString(secondary.id()), info, &success, &error); |
| 638 | 641 |
| 639 ASSERT_TRUE(success); | 642 ASSERT_TRUE(success); |
| 640 ASSERT_TRUE(error.empty()); | 643 ASSERT_TRUE(error.empty()); |
| 641 | 644 |
| 642 EXPECT_EQ("1200,450 100x1000", secondary.bounds().ToString()); | 645 EXPECT_EQ("1200,450 100x1000", secondary.bounds().ToString()); |
| 643 } | 646 } |
| 644 | 647 |
| 645 TEST_F(DisplayInfoProviderChromeosTest, SetBoundsOriginPrimaryHiDPI) { | 648 TEST_F(DisplayInfoProviderChromeosTest, SetBoundsOriginPrimaryHiDPI) { |
| 646 UpdateDisplay("1200x600*2,500x500"); | 649 UpdateDisplay("1200x600*2,500x500"); |
| 647 | 650 |
| 648 const gfx::Display& secondary = ash::ScreenUtil::GetSecondaryDisplay(); | 651 const display::Display& secondary = ash::ScreenUtil::GetSecondaryDisplay(); |
| 649 api::system_display::DisplayProperties info; | 652 api::system_display::DisplayProperties info; |
| 650 info.bounds_origin_x.reset(new int(250)); | 653 info.bounds_origin_x.reset(new int(250)); |
| 651 info.bounds_origin_y.reset(new int(-100)); | 654 info.bounds_origin_y.reset(new int(-100)); |
| 652 | 655 |
| 653 bool success = false; | 656 bool success = false; |
| 654 std::string error; | 657 std::string error; |
| 655 CallSetDisplayUnitInfo( | 658 CallSetDisplayUnitInfo( |
| 656 base::Int64ToString(secondary.id()), info, &success, &error); | 659 base::Int64ToString(secondary.id()), info, &success, &error); |
| 657 | 660 |
| 658 ASSERT_TRUE(success); | 661 ASSERT_TRUE(success); |
| 659 ASSERT_TRUE(error.empty()); | 662 ASSERT_TRUE(error.empty()); |
| 660 | 663 |
| 661 EXPECT_EQ("600,-100 500x500", secondary.bounds().ToString()); | 664 EXPECT_EQ("600,-100 500x500", secondary.bounds().ToString()); |
| 662 } | 665 } |
| 663 | 666 |
| 664 TEST_F(DisplayInfoProviderChromeosTest, SetBoundsOriginSecondaryHiDPI) { | 667 TEST_F(DisplayInfoProviderChromeosTest, SetBoundsOriginSecondaryHiDPI) { |
| 665 UpdateDisplay("1200x600,600x1000*2"); | 668 UpdateDisplay("1200x600,600x1000*2"); |
| 666 | 669 |
| 667 const gfx::Display& secondary = ash::ScreenUtil::GetSecondaryDisplay(); | 670 const display::Display& secondary = ash::ScreenUtil::GetSecondaryDisplay(); |
| 668 api::system_display::DisplayProperties info; | 671 api::system_display::DisplayProperties info; |
| 669 info.bounds_origin_x.reset(new int(450)); | 672 info.bounds_origin_x.reset(new int(450)); |
| 670 info.bounds_origin_y.reset(new int(-100)); | 673 info.bounds_origin_y.reset(new int(-100)); |
| 671 | 674 |
| 672 bool success = false; | 675 bool success = false; |
| 673 std::string error; | 676 std::string error; |
| 674 CallSetDisplayUnitInfo( | 677 CallSetDisplayUnitInfo( |
| 675 base::Int64ToString(secondary.id()), info, &success, &error); | 678 base::Int64ToString(secondary.id()), info, &success, &error); |
| 676 | 679 |
| 677 ASSERT_TRUE(success); | 680 ASSERT_TRUE(success); |
| 678 ASSERT_TRUE(error.empty()); | 681 ASSERT_TRUE(error.empty()); |
| 679 | 682 |
| 680 EXPECT_EQ("450,-500 300x500", secondary.bounds().ToString()); | 683 EXPECT_EQ("450,-500 300x500", secondary.bounds().ToString()); |
| 681 } | 684 } |
| 682 | 685 |
| 683 TEST_F(DisplayInfoProviderChromeosTest, SetBoundsOriginOutOfBounds) { | 686 TEST_F(DisplayInfoProviderChromeosTest, SetBoundsOriginOutOfBounds) { |
| 684 UpdateDisplay("1200x600,600x1000*2"); | 687 UpdateDisplay("1200x600,600x1000*2"); |
| 685 | 688 |
| 686 const gfx::Display& secondary = ash::ScreenUtil::GetSecondaryDisplay(); | 689 const display::Display& secondary = ash::ScreenUtil::GetSecondaryDisplay(); |
| 687 api::system_display::DisplayProperties info; | 690 api::system_display::DisplayProperties info; |
| 688 info.bounds_origin_x.reset(new int(0x200001)); | 691 info.bounds_origin_x.reset(new int(0x200001)); |
| 689 info.bounds_origin_y.reset(new int(-100)); | 692 info.bounds_origin_y.reset(new int(-100)); |
| 690 | 693 |
| 691 bool success = false; | 694 bool success = false; |
| 692 std::string error; | 695 std::string error; |
| 693 CallSetDisplayUnitInfo( | 696 CallSetDisplayUnitInfo( |
| 694 base::Int64ToString(secondary.id()), info, &success, &error); | 697 base::Int64ToString(secondary.id()), info, &success, &error); |
| 695 | 698 |
| 696 ASSERT_FALSE(success); | 699 ASSERT_FALSE(success); |
| 697 ASSERT_EQ("Bounds origin x out of bounds.", error); | 700 ASSERT_EQ("Bounds origin x out of bounds.", error); |
| 698 | 701 |
| 699 EXPECT_EQ("1200,0 300x500", secondary.bounds().ToString()); | 702 EXPECT_EQ("1200,0 300x500", secondary.bounds().ToString()); |
| 700 } | 703 } |
| 701 | 704 |
| 702 TEST_F(DisplayInfoProviderChromeosTest, SetBoundsOriginOutOfBoundsNegative) { | 705 TEST_F(DisplayInfoProviderChromeosTest, SetBoundsOriginOutOfBoundsNegative) { |
| 703 UpdateDisplay("1200x600,600x1000*2"); | 706 UpdateDisplay("1200x600,600x1000*2"); |
| 704 | 707 |
| 705 const gfx::Display& secondary = ash::ScreenUtil::GetSecondaryDisplay(); | 708 const display::Display& secondary = ash::ScreenUtil::GetSecondaryDisplay(); |
| 706 api::system_display::DisplayProperties info; | 709 api::system_display::DisplayProperties info; |
| 707 info.bounds_origin_x.reset(new int(300)); | 710 info.bounds_origin_x.reset(new int(300)); |
| 708 info.bounds_origin_y.reset(new int(-0x200001)); | 711 info.bounds_origin_y.reset(new int(-0x200001)); |
| 709 | 712 |
| 710 bool success = false; | 713 bool success = false; |
| 711 std::string error; | 714 std::string error; |
| 712 CallSetDisplayUnitInfo( | 715 CallSetDisplayUnitInfo( |
| 713 base::Int64ToString(secondary.id()), info, &success, &error); | 716 base::Int64ToString(secondary.id()), info, &success, &error); |
| 714 | 717 |
| 715 ASSERT_FALSE(success); | 718 ASSERT_FALSE(success); |
| 716 ASSERT_EQ("Bounds origin y out of bounds.", error); | 719 ASSERT_EQ("Bounds origin y out of bounds.", error); |
| 717 | 720 |
| 718 EXPECT_EQ("1200,0 300x500", secondary.bounds().ToString()); | 721 EXPECT_EQ("1200,0 300x500", secondary.bounds().ToString()); |
| 719 } | 722 } |
| 720 | 723 |
| 721 TEST_F(DisplayInfoProviderChromeosTest, SetBoundsOriginMaxValues) { | 724 TEST_F(DisplayInfoProviderChromeosTest, SetBoundsOriginMaxValues) { |
| 722 UpdateDisplay("1200x4600,600x1000*2"); | 725 UpdateDisplay("1200x4600,600x1000*2"); |
| 723 | 726 |
| 724 const gfx::Display& secondary = ash::ScreenUtil::GetSecondaryDisplay(); | 727 const display::Display& secondary = ash::ScreenUtil::GetSecondaryDisplay(); |
| 725 api::system_display::DisplayProperties info; | 728 api::system_display::DisplayProperties info; |
| 726 info.bounds_origin_x.reset(new int(200000)); | 729 info.bounds_origin_x.reset(new int(200000)); |
| 727 info.bounds_origin_y.reset(new int(10)); | 730 info.bounds_origin_y.reset(new int(10)); |
| 728 | 731 |
| 729 bool success = false; | 732 bool success = false; |
| 730 std::string error; | 733 std::string error; |
| 731 CallSetDisplayUnitInfo( | 734 CallSetDisplayUnitInfo( |
| 732 base::Int64ToString(secondary.id()), info, &success, &error); | 735 base::Int64ToString(secondary.id()), info, &success, &error); |
| 733 | 736 |
| 734 ASSERT_TRUE(success); | 737 ASSERT_TRUE(success); |
| 735 EXPECT_TRUE(error.empty()); | 738 EXPECT_TRUE(error.empty()); |
| 736 | 739 |
| 737 EXPECT_EQ("1200,10 300x500", secondary.bounds().ToString()); | 740 EXPECT_EQ("1200,10 300x500", secondary.bounds().ToString()); |
| 738 } | 741 } |
| 739 | 742 |
| 740 TEST_F(DisplayInfoProviderChromeosTest, SetBoundsOriginOnPrimary) { | 743 TEST_F(DisplayInfoProviderChromeosTest, SetBoundsOriginOnPrimary) { |
| 741 UpdateDisplay("1200x600,600x1000*2"); | 744 UpdateDisplay("1200x600,600x1000*2"); |
| 742 | 745 |
| 743 const gfx::Display& secondary = ash::ScreenUtil::GetSecondaryDisplay(); | 746 const display::Display& secondary = ash::ScreenUtil::GetSecondaryDisplay(); |
| 744 api::system_display::DisplayProperties info; | 747 api::system_display::DisplayProperties info; |
| 745 info.bounds_origin_x.reset(new int(300)); | 748 info.bounds_origin_x.reset(new int(300)); |
| 746 info.is_primary.reset(new bool(true)); | 749 info.is_primary.reset(new bool(true)); |
| 747 | 750 |
| 748 bool success = false; | 751 bool success = false; |
| 749 std::string error; | 752 std::string error; |
| 750 CallSetDisplayUnitInfo( | 753 CallSetDisplayUnitInfo( |
| 751 base::Int64ToString(secondary.id()), info, &success, &error); | 754 base::Int64ToString(secondary.id()), info, &success, &error); |
| 752 | 755 |
| 753 ASSERT_FALSE(success); | 756 ASSERT_FALSE(success); |
| 754 ASSERT_EQ("Bounds origin not allowed for the primary display.", error); | 757 ASSERT_EQ("Bounds origin not allowed for the primary display.", error); |
| 755 | 758 |
| 756 EXPECT_EQ("1200,0 300x500", secondary.bounds().ToString()); | 759 EXPECT_EQ("1200,0 300x500", secondary.bounds().ToString()); |
| 757 // The operation failed because the primary property would be set before | 760 // The operation failed because the primary property would be set before |
| 758 // setting bounds. The primary display shouldn't have been changed, though. | 761 // setting bounds. The primary display shouldn't have been changed, though. |
| 759 EXPECT_NE(gfx::Screen::GetScreen()->GetPrimaryDisplay().id(), secondary.id()); | 762 EXPECT_NE(display::Screen::GetScreen()->GetPrimaryDisplay().id(), |
| 763 secondary.id()); |
| 760 } | 764 } |
| 761 | 765 |
| 762 TEST_F(DisplayInfoProviderChromeosTest, SetBoundsOriginWithMirroring) { | 766 TEST_F(DisplayInfoProviderChromeosTest, SetBoundsOriginWithMirroring) { |
| 763 UpdateDisplay("1200x600,600x1000*2"); | 767 UpdateDisplay("1200x600,600x1000*2"); |
| 764 | 768 |
| 765 const gfx::Display& secondary = ash::ScreenUtil::GetSecondaryDisplay(); | 769 const display::Display& secondary = ash::ScreenUtil::GetSecondaryDisplay(); |
| 766 const gfx::Display& primary = gfx::Screen::GetScreen()->GetPrimaryDisplay(); | 770 const display::Display& primary = |
| 771 display::Screen::GetScreen()->GetPrimaryDisplay(); |
| 767 | 772 |
| 768 api::system_display::DisplayProperties info; | 773 api::system_display::DisplayProperties info; |
| 769 info.bounds_origin_x.reset(new int(300)); | 774 info.bounds_origin_x.reset(new int(300)); |
| 770 info.mirroring_source_id.reset( | 775 info.mirroring_source_id.reset( |
| 771 new std::string(base::Int64ToString(primary.id()))); | 776 new std::string(base::Int64ToString(primary.id()))); |
| 772 | 777 |
| 773 bool success = false; | 778 bool success = false; |
| 774 std::string error; | 779 std::string error; |
| 775 CallSetDisplayUnitInfo( | 780 CallSetDisplayUnitInfo( |
| 776 base::Int64ToString(secondary.id()), info, &success, &error); | 781 base::Int64ToString(secondary.id()), info, &success, &error); |
| 777 | 782 |
| 778 ASSERT_FALSE(success); | 783 ASSERT_FALSE(success); |
| 779 ASSERT_EQ("No other parameter should be set alongside mirroringSourceId.", | 784 ASSERT_EQ("No other parameter should be set alongside mirroringSourceId.", |
| 780 error); | 785 error); |
| 781 } | 786 } |
| 782 | 787 |
| 783 TEST_F(DisplayInfoProviderChromeosTest, SetRotation) { | 788 TEST_F(DisplayInfoProviderChromeosTest, SetRotation) { |
| 784 UpdateDisplay("1200x600,600x1000*2"); | 789 UpdateDisplay("1200x600,600x1000*2"); |
| 785 | 790 |
| 786 const gfx::Display& secondary = ash::ScreenUtil::GetSecondaryDisplay(); | 791 const display::Display& secondary = ash::ScreenUtil::GetSecondaryDisplay(); |
| 787 api::system_display::DisplayProperties info; | 792 api::system_display::DisplayProperties info; |
| 788 info.rotation.reset(new int(90)); | 793 info.rotation.reset(new int(90)); |
| 789 | 794 |
| 790 bool success = false; | 795 bool success = false; |
| 791 std::string error; | 796 std::string error; |
| 792 CallSetDisplayUnitInfo( | 797 CallSetDisplayUnitInfo( |
| 793 base::Int64ToString(secondary.id()), info, &success, &error); | 798 base::Int64ToString(secondary.id()), info, &success, &error); |
| 794 | 799 |
| 795 ASSERT_TRUE(success); | 800 ASSERT_TRUE(success); |
| 796 EXPECT_TRUE(error.empty()); | 801 EXPECT_TRUE(error.empty()); |
| 797 | 802 |
| 798 EXPECT_EQ("1200,0 500x300", secondary.bounds().ToString()); | 803 EXPECT_EQ("1200,0 500x300", secondary.bounds().ToString()); |
| 799 EXPECT_EQ(gfx::Display::ROTATE_90, secondary.rotation()); | 804 EXPECT_EQ(display::Display::ROTATE_90, secondary.rotation()); |
| 800 | 805 |
| 801 info.rotation.reset(new int(270)); | 806 info.rotation.reset(new int(270)); |
| 802 CallSetDisplayUnitInfo( | 807 CallSetDisplayUnitInfo( |
| 803 base::Int64ToString(secondary.id()), info, &success, &error); | 808 base::Int64ToString(secondary.id()), info, &success, &error); |
| 804 | 809 |
| 805 ASSERT_TRUE(success); | 810 ASSERT_TRUE(success); |
| 806 EXPECT_TRUE(error.empty()); | 811 EXPECT_TRUE(error.empty()); |
| 807 | 812 |
| 808 EXPECT_EQ("1200,0 500x300", secondary.bounds().ToString()); | 813 EXPECT_EQ("1200,0 500x300", secondary.bounds().ToString()); |
| 809 EXPECT_EQ(gfx::Display::ROTATE_270, secondary.rotation()); | 814 EXPECT_EQ(display::Display::ROTATE_270, secondary.rotation()); |
| 810 | 815 |
| 811 info.rotation.reset(new int(180)); | 816 info.rotation.reset(new int(180)); |
| 812 // Switch primary display. | 817 // Switch primary display. |
| 813 info.is_primary.reset(new bool(true)); | 818 info.is_primary.reset(new bool(true)); |
| 814 CallSetDisplayUnitInfo( | 819 CallSetDisplayUnitInfo( |
| 815 base::Int64ToString(secondary.id()), info, &success, &error); | 820 base::Int64ToString(secondary.id()), info, &success, &error); |
| 816 | 821 |
| 817 ASSERT_TRUE(success); | 822 ASSERT_TRUE(success); |
| 818 EXPECT_TRUE(error.empty()); | 823 EXPECT_TRUE(error.empty()); |
| 819 | 824 |
| 820 EXPECT_EQ("0,0 300x500", secondary.bounds().ToString()); | 825 EXPECT_EQ("0,0 300x500", secondary.bounds().ToString()); |
| 821 EXPECT_EQ(gfx::Display::ROTATE_180, secondary.rotation()); | 826 EXPECT_EQ(display::Display::ROTATE_180, secondary.rotation()); |
| 822 EXPECT_EQ(gfx::Screen::GetScreen()->GetPrimaryDisplay().id(), secondary.id()); | 827 EXPECT_EQ(display::Screen::GetScreen()->GetPrimaryDisplay().id(), |
| 828 secondary.id()); |
| 823 | 829 |
| 824 info.rotation.reset(new int(0)); | 830 info.rotation.reset(new int(0)); |
| 825 CallSetDisplayUnitInfo( | 831 CallSetDisplayUnitInfo( |
| 826 base::Int64ToString(secondary.id()), info, &success, &error); | 832 base::Int64ToString(secondary.id()), info, &success, &error); |
| 827 | 833 |
| 828 ASSERT_TRUE(success); | 834 ASSERT_TRUE(success); |
| 829 EXPECT_TRUE(error.empty()); | 835 EXPECT_TRUE(error.empty()); |
| 830 | 836 |
| 831 EXPECT_EQ("0,0 300x500", secondary.bounds().ToString()); | 837 EXPECT_EQ("0,0 300x500", secondary.bounds().ToString()); |
| 832 EXPECT_EQ(gfx::Display::ROTATE_0, secondary.rotation()); | 838 EXPECT_EQ(display::Display::ROTATE_0, secondary.rotation()); |
| 833 EXPECT_EQ(gfx::Screen::GetScreen()->GetPrimaryDisplay().id(), secondary.id()); | 839 EXPECT_EQ(display::Screen::GetScreen()->GetPrimaryDisplay().id(), |
| 840 secondary.id()); |
| 834 } | 841 } |
| 835 | 842 |
| 836 // Tests that rotation changes made before entering maximize mode are restored | 843 // Tests that rotation changes made before entering maximize mode are restored |
| 837 // upon exiting maximize mode, and that a rotation lock is not set. | 844 // upon exiting maximize mode, and that a rotation lock is not set. |
| 838 TEST_F(DisplayInfoProviderChromeosTest, SetRotationBeforeMaximizeMode) { | 845 TEST_F(DisplayInfoProviderChromeosTest, SetRotationBeforeMaximizeMode) { |
| 839 ash::ScreenOrientationController* screen_orientation_controller = | 846 ash::ScreenOrientationController* screen_orientation_controller = |
| 840 ash::Shell::GetInstance()->screen_orientation_controller(); | 847 ash::Shell::GetInstance()->screen_orientation_controller(); |
| 841 api::system_display::DisplayProperties info; | 848 api::system_display::DisplayProperties info; |
| 842 info.rotation.reset(new int(90)); | 849 info.rotation.reset(new int(90)); |
| 843 | 850 |
| 844 bool success = false; | 851 bool success = false; |
| 845 std::string error; | 852 std::string error; |
| 846 CallSetDisplayUnitInfo(base::Int64ToString(gfx::Display::InternalDisplayId()), | 853 CallSetDisplayUnitInfo( |
| 847 info, &success, &error); | 854 base::Int64ToString(display::Display::InternalDisplayId()), info, |
| 855 &success, &error); |
| 848 | 856 |
| 849 ASSERT_TRUE(success); | 857 ASSERT_TRUE(success); |
| 850 EXPECT_TRUE(error.empty()); | 858 EXPECT_TRUE(error.empty()); |
| 851 EXPECT_FALSE(screen_orientation_controller->rotation_locked()); | 859 EXPECT_FALSE(screen_orientation_controller->rotation_locked()); |
| 852 | 860 |
| 853 // Entering maximize mode enables accelerometer screen rotations. | 861 // Entering maximize mode enables accelerometer screen rotations. |
| 854 ash::Shell::GetInstance() | 862 ash::Shell::GetInstance() |
| 855 ->maximize_mode_controller() | 863 ->maximize_mode_controller() |
| 856 ->EnableMaximizeModeWindowManager(true); | 864 ->EnableMaximizeModeWindowManager(true); |
| 857 // Rotation lock should not activate because DisplayInfoProvider::SetInfo() | 865 // Rotation lock should not activate because DisplayInfoProvider::SetInfo() |
| 858 // was called when not in maximize mode. | 866 // was called when not in maximize mode. |
| 859 EXPECT_FALSE(screen_orientation_controller->rotation_locked()); | 867 EXPECT_FALSE(screen_orientation_controller->rotation_locked()); |
| 860 | 868 |
| 861 // ScreenOrientationController rotations override display info. | 869 // ScreenOrientationController rotations override display info. |
| 862 screen_orientation_controller->SetDisplayRotation( | 870 screen_orientation_controller->SetDisplayRotation( |
| 863 gfx::Display::ROTATE_0, gfx::Display::ROTATION_SOURCE_ACTIVE); | 871 display::Display::ROTATE_0, display::Display::ROTATION_SOURCE_ACTIVE); |
| 864 EXPECT_EQ(gfx::Display::ROTATE_0, GetCurrentInternalDisplayRotation()); | 872 EXPECT_EQ(display::Display::ROTATE_0, GetCurrentInternalDisplayRotation()); |
| 865 | 873 |
| 866 // Exiting maximize mode should restore the initial rotation | 874 // Exiting maximize mode should restore the initial rotation |
| 867 ash::Shell::GetInstance() | 875 ash::Shell::GetInstance() |
| 868 ->maximize_mode_controller() | 876 ->maximize_mode_controller() |
| 869 ->EnableMaximizeModeWindowManager(false); | 877 ->EnableMaximizeModeWindowManager(false); |
| 870 EXPECT_EQ(gfx::Display::ROTATE_90, GetCurrentInternalDisplayRotation()); | 878 EXPECT_EQ(display::Display::ROTATE_90, GetCurrentInternalDisplayRotation()); |
| 871 } | 879 } |
| 872 | 880 |
| 873 // Tests that rotation changes made during maximize mode lock the display | 881 // Tests that rotation changes made during maximize mode lock the display |
| 874 // against accelerometer rotations. | 882 // against accelerometer rotations. |
| 875 TEST_F(DisplayInfoProviderChromeosTest, SetRotationDuringMaximizeMode) { | 883 TEST_F(DisplayInfoProviderChromeosTest, SetRotationDuringMaximizeMode) { |
| 876 // Entering maximize mode enables accelerometer screen rotations. | 884 // Entering maximize mode enables accelerometer screen rotations. |
| 877 ash::Shell::GetInstance() | 885 ash::Shell::GetInstance() |
| 878 ->maximize_mode_controller() | 886 ->maximize_mode_controller() |
| 879 ->EnableMaximizeModeWindowManager(true); | 887 ->EnableMaximizeModeWindowManager(true); |
| 880 | 888 |
| 881 ASSERT_FALSE(ash::Shell::GetInstance() | 889 ASSERT_FALSE(ash::Shell::GetInstance() |
| 882 ->screen_orientation_controller() | 890 ->screen_orientation_controller() |
| 883 ->rotation_locked()); | 891 ->rotation_locked()); |
| 884 | 892 |
| 885 api::system_display::DisplayProperties info; | 893 api::system_display::DisplayProperties info; |
| 886 info.rotation.reset(new int(90)); | 894 info.rotation.reset(new int(90)); |
| 887 | 895 |
| 888 bool success = false; | 896 bool success = false; |
| 889 std::string error; | 897 std::string error; |
| 890 CallSetDisplayUnitInfo(base::Int64ToString(gfx::Display::InternalDisplayId()), | 898 CallSetDisplayUnitInfo( |
| 891 info, &success, &error); | 899 base::Int64ToString(display::Display::InternalDisplayId()), info, |
| 900 &success, &error); |
| 892 | 901 |
| 893 ASSERT_TRUE(success); | 902 ASSERT_TRUE(success); |
| 894 EXPECT_TRUE(error.empty()); | 903 EXPECT_TRUE(error.empty()); |
| 895 EXPECT_TRUE(ash::Shell::GetInstance() | 904 EXPECT_TRUE(ash::Shell::GetInstance() |
| 896 ->screen_orientation_controller() | 905 ->screen_orientation_controller() |
| 897 ->rotation_locked()); | 906 ->rotation_locked()); |
| 898 } | 907 } |
| 899 | 908 |
| 900 TEST_F(DisplayInfoProviderChromeosTest, SetInvalidRotation) { | 909 TEST_F(DisplayInfoProviderChromeosTest, SetInvalidRotation) { |
| 901 UpdateDisplay("1200x600,600x1000*2"); | 910 UpdateDisplay("1200x600,600x1000*2"); |
| 902 | 911 |
| 903 const gfx::Display& secondary = ash::ScreenUtil::GetSecondaryDisplay(); | 912 const display::Display& secondary = ash::ScreenUtil::GetSecondaryDisplay(); |
| 904 api::system_display::DisplayProperties info; | 913 api::system_display::DisplayProperties info; |
| 905 info.rotation.reset(new int(91)); | 914 info.rotation.reset(new int(91)); |
| 906 | 915 |
| 907 bool success = false; | 916 bool success = false; |
| 908 std::string error; | 917 std::string error; |
| 909 CallSetDisplayUnitInfo( | 918 CallSetDisplayUnitInfo( |
| 910 base::Int64ToString(secondary.id()), info, &success, &error); | 919 base::Int64ToString(secondary.id()), info, &success, &error); |
| 911 | 920 |
| 912 ASSERT_FALSE(success); | 921 ASSERT_FALSE(success); |
| 913 EXPECT_EQ("Invalid rotation.", error); | 922 EXPECT_EQ("Invalid rotation.", error); |
| 914 } | 923 } |
| 915 | 924 |
| 916 TEST_F(DisplayInfoProviderChromeosTest, SetNegativeOverscan) { | 925 TEST_F(DisplayInfoProviderChromeosTest, SetNegativeOverscan) { |
| 917 UpdateDisplay("1200x600,600x1000*2"); | 926 UpdateDisplay("1200x600,600x1000*2"); |
| 918 | 927 |
| 919 const gfx::Display& secondary = ash::ScreenUtil::GetSecondaryDisplay(); | 928 const display::Display& secondary = ash::ScreenUtil::GetSecondaryDisplay(); |
| 920 api::system_display::DisplayProperties info; | 929 api::system_display::DisplayProperties info; |
| 921 info.overscan.reset(new api::system_display::Insets); | 930 info.overscan.reset(new api::system_display::Insets); |
| 922 info.overscan->left = -10; | 931 info.overscan->left = -10; |
| 923 | 932 |
| 924 bool success = false; | 933 bool success = false; |
| 925 std::string error; | 934 std::string error; |
| 926 CallSetDisplayUnitInfo( | 935 CallSetDisplayUnitInfo( |
| 927 base::Int64ToString(secondary.id()), info, &success, &error); | 936 base::Int64ToString(secondary.id()), info, &success, &error); |
| 928 | 937 |
| 929 ASSERT_FALSE(success); | 938 ASSERT_FALSE(success); |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 972 | 981 |
| 973 ASSERT_TRUE(success); | 982 ASSERT_TRUE(success); |
| 974 EXPECT_TRUE(error.empty()); | 983 EXPECT_TRUE(error.empty()); |
| 975 | 984 |
| 976 EXPECT_EQ("1200,0 300x500", secondary.bounds().ToString()); | 985 EXPECT_EQ("1200,0 300x500", secondary.bounds().ToString()); |
| 977 } | 986 } |
| 978 | 987 |
| 979 TEST_F(DisplayInfoProviderChromeosTest, SetOverscanLargerThanHorizontalBounds) { | 988 TEST_F(DisplayInfoProviderChromeosTest, SetOverscanLargerThanHorizontalBounds) { |
| 980 UpdateDisplay("1200x600,600x1000*2"); | 989 UpdateDisplay("1200x600,600x1000*2"); |
| 981 | 990 |
| 982 const gfx::Display& secondary = ash::ScreenUtil::GetSecondaryDisplay(); | 991 const display::Display& secondary = ash::ScreenUtil::GetSecondaryDisplay(); |
| 983 api::system_display::DisplayProperties info; | 992 api::system_display::DisplayProperties info; |
| 984 info.overscan.reset(new api::system_display::Insets); | 993 info.overscan.reset(new api::system_display::Insets); |
| 985 // Horizontal overscan is 151, which would make the bounds width 149. | 994 // Horizontal overscan is 151, which would make the bounds width 149. |
| 986 info.overscan->left = 50; | 995 info.overscan->left = 50; |
| 987 info.overscan->top = 10; | 996 info.overscan->top = 10; |
| 988 info.overscan->right = 101; | 997 info.overscan->right = 101; |
| 989 info.overscan->bottom = 20; | 998 info.overscan->bottom = 20; |
| 990 | 999 |
| 991 bool success = false; | 1000 bool success = false; |
| 992 std::string error; | 1001 std::string error; |
| 993 CallSetDisplayUnitInfo( | 1002 CallSetDisplayUnitInfo( |
| 994 base::Int64ToString(secondary.id()), info, &success, &error); | 1003 base::Int64ToString(secondary.id()), info, &success, &error); |
| 995 | 1004 |
| 996 ASSERT_FALSE(success); | 1005 ASSERT_FALSE(success); |
| 997 EXPECT_EQ("Horizontal overscan is more than half of the screen width.", | 1006 EXPECT_EQ("Horizontal overscan is more than half of the screen width.", |
| 998 error); | 1007 error); |
| 999 } | 1008 } |
| 1000 | 1009 |
| 1001 TEST_F(DisplayInfoProviderChromeosTest, SetOverscanLargerThanVerticalBounds) { | 1010 TEST_F(DisplayInfoProviderChromeosTest, SetOverscanLargerThanVerticalBounds) { |
| 1002 UpdateDisplay("1200x600,600x1000"); | 1011 UpdateDisplay("1200x600,600x1000"); |
| 1003 | 1012 |
| 1004 const gfx::Display& secondary = ash::ScreenUtil::GetSecondaryDisplay(); | 1013 const display::Display& secondary = ash::ScreenUtil::GetSecondaryDisplay(); |
| 1005 api::system_display::DisplayProperties info; | 1014 api::system_display::DisplayProperties info; |
| 1006 info.overscan.reset(new api::system_display::Insets); | 1015 info.overscan.reset(new api::system_display::Insets); |
| 1007 // Vertical overscan is 501, which would make the bounds height 499. | 1016 // Vertical overscan is 501, which would make the bounds height 499. |
| 1008 info.overscan->left = 20; | 1017 info.overscan->left = 20; |
| 1009 info.overscan->top = 250; | 1018 info.overscan->top = 250; |
| 1010 info.overscan->right = 101; | 1019 info.overscan->right = 101; |
| 1011 info.overscan->bottom = 251; | 1020 info.overscan->bottom = 251; |
| 1012 | 1021 |
| 1013 bool success = false; | 1022 bool success = false; |
| 1014 std::string error; | 1023 std::string error; |
| 1015 CallSetDisplayUnitInfo( | 1024 CallSetDisplayUnitInfo( |
| 1016 base::Int64ToString(secondary.id()), info, &success, &error); | 1025 base::Int64ToString(secondary.id()), info, &success, &error); |
| 1017 | 1026 |
| 1018 ASSERT_FALSE(success); | 1027 ASSERT_FALSE(success); |
| 1019 EXPECT_EQ("Vertical overscan is more than half of the screen height.", error); | 1028 EXPECT_EQ("Vertical overscan is more than half of the screen height.", error); |
| 1020 } | 1029 } |
| 1021 | 1030 |
| 1022 TEST_F(DisplayInfoProviderChromeosTest, SetOverscan) { | 1031 TEST_F(DisplayInfoProviderChromeosTest, SetOverscan) { |
| 1023 UpdateDisplay("1200x600,600x1000*2"); | 1032 UpdateDisplay("1200x600,600x1000*2"); |
| 1024 | 1033 |
| 1025 const gfx::Display& secondary = ash::ScreenUtil::GetSecondaryDisplay(); | 1034 const display::Display& secondary = ash::ScreenUtil::GetSecondaryDisplay(); |
| 1026 api::system_display::DisplayProperties info; | 1035 api::system_display::DisplayProperties info; |
| 1027 info.overscan.reset(new api::system_display::Insets); | 1036 info.overscan.reset(new api::system_display::Insets); |
| 1028 info.overscan->left = 20; | 1037 info.overscan->left = 20; |
| 1029 info.overscan->top = 199; | 1038 info.overscan->top = 199; |
| 1030 info.overscan->right = 130; | 1039 info.overscan->right = 130; |
| 1031 info.overscan->bottom = 51; | 1040 info.overscan->bottom = 51; |
| 1032 | 1041 |
| 1033 bool success = false; | 1042 bool success = false; |
| 1034 std::string error; | 1043 std::string error; |
| 1035 CallSetDisplayUnitInfo( | 1044 CallSetDisplayUnitInfo( |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1117 CallSetDisplayUnitInfo(base::Int64ToString(id), info, &success, &error); | 1126 CallSetDisplayUnitInfo(base::Int64ToString(id), info, &success, &error); |
| 1118 ASSERT_TRUE(success); | 1127 ASSERT_TRUE(success); |
| 1119 | 1128 |
| 1120 // Verify that other_mode now matches the active mode. | 1129 // Verify that other_mode now matches the active mode. |
| 1121 active_mode = GetDisplayManager()->GetActiveModeForDisplayId(id); | 1130 active_mode = GetDisplayManager()->GetActiveModeForDisplayId(id); |
| 1122 EXPECT_TRUE(active_mode.IsEquivalent(other_mode_ash)); | 1131 EXPECT_TRUE(active_mode.IsEquivalent(other_mode_ash)); |
| 1123 } | 1132 } |
| 1124 | 1133 |
| 1125 } // namespace | 1134 } // namespace |
| 1126 } // namespace extensions | 1135 } // namespace extensions |
| OLD | NEW |