| Index: chrome/browser/extensions/display_info_provider_chromeos_unittest.cc
|
| diff --git a/chrome/browser/extensions/display_info_provider_chromeos_unittest.cc b/chrome/browser/extensions/display_info_provider_chromeos_unittest.cc
|
| index 2aeebe22ef4954b5595bf50152a07519cd898f6b..f4998a6570a46fb7ed2a52110b4a552e2a4f8f86 100644
|
| --- a/chrome/browser/extensions/display_info_provider_chromeos_unittest.cc
|
| +++ b/chrome/browser/extensions/display_info_provider_chromeos_unittest.cc
|
| @@ -84,13 +84,18 @@ class DisplayInfoProviderChromeosTest : public ash::test::AshTestBase {
|
| "%d,%d %dx%d", bounds.left, bounds.top, bounds.width, bounds.height);
|
| }
|
|
|
| + DisplayUnitInfoList GetAllDisplaysInfo() {
|
| + return DisplayInfoProvider::Get()->GetAllDisplaysInfo(
|
| + false /* single unified */);
|
| + }
|
| +
|
| private:
|
| DISALLOW_COPY_AND_ASSIGN(DisplayInfoProviderChromeosTest);
|
| };
|
|
|
| TEST_F(DisplayInfoProviderChromeosTest, GetBasic) {
|
| UpdateDisplay("500x600,400x520");
|
| - DisplayUnitInfoList result = DisplayInfoProvider::Get()->GetAllDisplaysInfo();
|
| + DisplayUnitInfoList result = GetAllDisplaysInfo();
|
|
|
| ASSERT_EQ(2u, result.size());
|
|
|
| @@ -131,7 +136,7 @@ TEST_F(DisplayInfoProviderChromeosTest, GetWithUnifiedDesktop) {
|
|
|
| // Check initial state.
|
| EXPECT_FALSE(GetDisplayManager()->IsInUnifiedMode());
|
| - DisplayUnitInfoList result = DisplayInfoProvider::Get()->GetAllDisplaysInfo();
|
| + DisplayUnitInfoList result = GetAllDisplaysInfo();
|
|
|
| ASSERT_EQ(2u, result.size());
|
|
|
| @@ -144,6 +149,7 @@ TEST_F(DisplayInfoProviderChromeosTest, GetWithUnifiedDesktop) {
|
| EXPECT_EQ("0,0,0,0", SystemInfoDisplayInsetsToString(result[0].overscan));
|
| EXPECT_EQ(0, result[0].rotation);
|
| EXPECT_TRUE(result[0].is_primary);
|
| + EXPECT_FALSE(result[0].is_unified);
|
| EXPECT_EQ(96, result[0].dpi_x);
|
| EXPECT_EQ(96, result[0].dpi_y);
|
| EXPECT_TRUE(result[0].mirroring_source_id.empty());
|
| @@ -161,6 +167,7 @@ TEST_F(DisplayInfoProviderChromeosTest, GetWithUnifiedDesktop) {
|
| EXPECT_EQ("0,0,0,0", SystemInfoDisplayInsetsToString(result[1].overscan));
|
| EXPECT_EQ(0, result[1].rotation);
|
| EXPECT_FALSE(result[1].is_primary);
|
| + EXPECT_FALSE(result[0].is_unified);
|
| EXPECT_EQ(96, result[1].dpi_x);
|
| EXPECT_EQ(96, result[1].dpi_y);
|
| EXPECT_TRUE(result[1].mirroring_source_id.empty());
|
| @@ -170,7 +177,7 @@ TEST_F(DisplayInfoProviderChromeosTest, GetWithUnifiedDesktop) {
|
| GetDisplayManager()->SetUnifiedDesktopEnabled(true);
|
| EXPECT_TRUE(GetDisplayManager()->IsInUnifiedMode());
|
|
|
| - result = DisplayInfoProvider::Get()->GetAllDisplaysInfo();
|
| + result = GetAllDisplaysInfo();
|
|
|
| ASSERT_EQ(2u, result.size());
|
|
|
| @@ -181,6 +188,7 @@ TEST_F(DisplayInfoProviderChromeosTest, GetWithUnifiedDesktop) {
|
| EXPECT_EQ("0,0,0,0", SystemInfoDisplayInsetsToString(result[0].overscan));
|
| EXPECT_EQ(0, result[0].rotation);
|
| EXPECT_TRUE(result[0].is_primary);
|
| + EXPECT_TRUE(result[0].is_unified);
|
| EXPECT_EQ(96, result[0].dpi_x);
|
| EXPECT_EQ(96, result[0].dpi_y);
|
| EXPECT_TRUE(result[0].mirroring_source_id.empty());
|
| @@ -198,6 +206,7 @@ TEST_F(DisplayInfoProviderChromeosTest, GetWithUnifiedDesktop) {
|
| EXPECT_EQ("0,0,0,0", SystemInfoDisplayInsetsToString(result[1].overscan));
|
| EXPECT_EQ(0, result[1].rotation);
|
| EXPECT_FALSE(result[1].is_primary);
|
| + EXPECT_TRUE(result[1].is_unified);
|
| EXPECT_FLOAT_EQ(111, round(result[1].dpi_x));
|
| EXPECT_FLOAT_EQ(111, round(result[1].dpi_y));
|
| EXPECT_TRUE(result[1].mirroring_source_id.empty());
|
| @@ -206,7 +215,113 @@ TEST_F(DisplayInfoProviderChromeosTest, GetWithUnifiedDesktop) {
|
| // Disable unified and check that once again it matches initial situation.
|
| GetDisplayManager()->SetUnifiedDesktopEnabled(false);
|
| EXPECT_FALSE(GetDisplayManager()->IsInUnifiedMode());
|
| - result = DisplayInfoProvider::Get()->GetAllDisplaysInfo();
|
| + result = GetAllDisplaysInfo();
|
| +
|
| + ASSERT_EQ(2u, result.size());
|
| +
|
| + ASSERT_TRUE(base::StringToInt64(result[0].id, &display_id))
|
| + << "Display id must be convertable to integer: " << result[0].id;
|
| +
|
| + ASSERT_TRUE(DisplayExists(display_id)) << display_id << " not found";
|
| + EXPECT_EQ("0,0 500x600", SystemInfoDisplayBoundsToString(result[0].bounds));
|
| + EXPECT_EQ("0,0,0,0", SystemInfoDisplayInsetsToString(result[0].overscan));
|
| + EXPECT_EQ(0, result[0].rotation);
|
| + EXPECT_TRUE(result[0].is_primary);
|
| + EXPECT_FALSE(result[0].is_unified);
|
| + EXPECT_EQ(96, result[0].dpi_x);
|
| + EXPECT_EQ(96, result[0].dpi_y);
|
| + EXPECT_TRUE(result[0].mirroring_source_id.empty());
|
| + EXPECT_TRUE(result[0].is_enabled);
|
| +
|
| + ASSERT_TRUE(base::StringToInt64(result[1].id, &display_id))
|
| + << "Display id must be convertable to integer: " << result[0].id;
|
| +
|
| + ASSERT_TRUE(DisplayExists(display_id)) << display_id << " not found";
|
| + EXPECT_EQ(GetDisplayManager()->GetDisplayNameForId(display_id),
|
| + result[1].name);
|
| + EXPECT_EQ("500,0 400x520", SystemInfoDisplayBoundsToString(result[1].bounds));
|
| + EXPECT_EQ("0,0,0,0", SystemInfoDisplayInsetsToString(result[1].overscan));
|
| + EXPECT_EQ(0, result[1].rotation);
|
| + EXPECT_FALSE(result[1].is_primary);
|
| + EXPECT_FALSE(result[1].is_unified);
|
| + EXPECT_EQ(96, result[1].dpi_x);
|
| + EXPECT_EQ(96, result[1].dpi_y);
|
| + EXPECT_TRUE(result[1].mirroring_source_id.empty());
|
| + EXPECT_TRUE(result[1].is_enabled);
|
| +}
|
| +
|
| +TEST_F(DisplayInfoProviderChromeosTest, GetWithUnifiedDesktopForSettings) {
|
| + UpdateDisplay("500x600,400x520");
|
| +
|
| + // Check initial state.
|
| + EXPECT_FALSE(GetDisplayManager()->IsInUnifiedMode());
|
| + DisplayUnitInfoList result =
|
| + DisplayInfoProvider::Get()->GetAllDisplaysInfo(true /* single unifed */);
|
| +
|
| + ASSERT_EQ(2u, result.size());
|
| +
|
| + int64_t display_id;
|
| + ASSERT_TRUE(base::StringToInt64(result[0].id, &display_id))
|
| + << "Display id must be convertable to integer: " << result[0].id;
|
| +
|
| + ASSERT_TRUE(DisplayExists(display_id)) << display_id << " not found";
|
| + EXPECT_EQ("0,0 500x600", SystemInfoDisplayBoundsToString(result[0].bounds));
|
| + EXPECT_EQ("0,0,0,0", SystemInfoDisplayInsetsToString(result[0].overscan));
|
| + EXPECT_EQ(0, result[0].rotation);
|
| + EXPECT_TRUE(result[0].is_primary);
|
| + EXPECT_FALSE(result[0].is_unified);
|
| + EXPECT_EQ(96, result[0].dpi_x);
|
| + EXPECT_EQ(96, result[0].dpi_y);
|
| + EXPECT_TRUE(result[0].mirroring_source_id.empty());
|
| + EXPECT_TRUE(result[0].is_enabled);
|
| +
|
| + ASSERT_TRUE(base::StringToInt64(result[1].id, &display_id))
|
| + << "Display id must be convertable to integer: " << result[0].id;
|
| +
|
| + ASSERT_TRUE(DisplayExists(display_id)) << display_id << " not found";
|
| + EXPECT_EQ(GetDisplayManager()->GetDisplayNameForId(display_id),
|
| + result[1].name);
|
| +
|
| + // Initial multipple display configuration.
|
| + EXPECT_EQ("500,0 400x520", SystemInfoDisplayBoundsToString(result[1].bounds));
|
| + EXPECT_EQ("0,0,0,0", SystemInfoDisplayInsetsToString(result[1].overscan));
|
| + EXPECT_EQ(0, result[1].rotation);
|
| + EXPECT_FALSE(result[1].is_primary);
|
| + EXPECT_FALSE(result[0].is_unified);
|
| + EXPECT_EQ(96, result[1].dpi_x);
|
| + EXPECT_EQ(96, result[1].dpi_y);
|
| + EXPECT_TRUE(result[1].mirroring_source_id.empty());
|
| + EXPECT_TRUE(result[1].is_enabled);
|
| +
|
| + // Enable unified.
|
| + GetDisplayManager()->SetUnifiedDesktopEnabled(true);
|
| + EXPECT_TRUE(GetDisplayManager()->IsInUnifiedMode());
|
| +
|
| + // For settings, GetAllDisplaysInfo will return a single unified display. The
|
| + // second display will be scaled to match the height of the first, so the
|
| + // height will be 600 and the new width will be 500 + [400 * 600/520 = 461] =
|
| + // 961.
|
| + result =
|
| + DisplayInfoProvider::Get()->GetAllDisplaysInfo(true /* single unified */);
|
| +
|
| + ASSERT_EQ(1u, result.size());
|
| + ASSERT_TRUE(base::StringToInt64(result[0].id, &display_id))
|
| + << "Display id must be convertable to integer: " << result[0].id;
|
| +
|
| + EXPECT_EQ("0,0 961x600", SystemInfoDisplayBoundsToString(result[0].bounds));
|
| + EXPECT_EQ("0,0,0,0", SystemInfoDisplayInsetsToString(result[0].overscan));
|
| + EXPECT_EQ(0, result[0].rotation);
|
| + EXPECT_TRUE(result[0].is_primary);
|
| + EXPECT_TRUE(result[0].is_unified);
|
| + EXPECT_EQ(96, result[0].dpi_x);
|
| + EXPECT_EQ(96, result[0].dpi_y);
|
| + EXPECT_TRUE(result[0].mirroring_source_id.empty());
|
| + EXPECT_TRUE(result[0].is_enabled);
|
| +
|
| + // Disable unified and check that once again it matches initial situation.
|
| + GetDisplayManager()->SetUnifiedDesktopEnabled(false);
|
| + EXPECT_FALSE(GetDisplayManager()->IsInUnifiedMode());
|
| + result = GetAllDisplaysInfo();
|
|
|
| ASSERT_EQ(2u, result.size());
|
|
|
| @@ -218,6 +333,7 @@ TEST_F(DisplayInfoProviderChromeosTest, GetWithUnifiedDesktop) {
|
| EXPECT_EQ("0,0,0,0", SystemInfoDisplayInsetsToString(result[0].overscan));
|
| EXPECT_EQ(0, result[0].rotation);
|
| EXPECT_TRUE(result[0].is_primary);
|
| + EXPECT_FALSE(result[0].is_unified);
|
| EXPECT_EQ(96, result[0].dpi_x);
|
| EXPECT_EQ(96, result[0].dpi_y);
|
| EXPECT_TRUE(result[0].mirroring_source_id.empty());
|
| @@ -233,6 +349,7 @@ TEST_F(DisplayInfoProviderChromeosTest, GetWithUnifiedDesktop) {
|
| EXPECT_EQ("0,0,0,0", SystemInfoDisplayInsetsToString(result[1].overscan));
|
| EXPECT_EQ(0, result[1].rotation);
|
| EXPECT_FALSE(result[1].is_primary);
|
| + EXPECT_FALSE(result[1].is_unified);
|
| EXPECT_EQ(96, result[1].dpi_x);
|
| EXPECT_EQ(96, result[1].dpi_y);
|
| EXPECT_TRUE(result[1].mirroring_source_id.empty());
|
| @@ -241,7 +358,7 @@ TEST_F(DisplayInfoProviderChromeosTest, GetWithUnifiedDesktop) {
|
|
|
| TEST_F(DisplayInfoProviderChromeosTest, GetRotation) {
|
| UpdateDisplay("500x600/r");
|
| - DisplayUnitInfoList result = DisplayInfoProvider::Get()->GetAllDisplaysInfo();
|
| + DisplayUnitInfoList result = GetAllDisplaysInfo();
|
|
|
| ASSERT_EQ(1u, result.size());
|
|
|
| @@ -257,7 +374,7 @@ TEST_F(DisplayInfoProviderChromeosTest, GetRotation) {
|
| display_id, display::Display::ROTATE_270,
|
| display::Display::ROTATION_SOURCE_ACTIVE);
|
|
|
| - result = DisplayInfoProvider::Get()->GetAllDisplaysInfo();
|
| + result = GetAllDisplaysInfo();
|
|
|
| ASSERT_EQ(1u, result.size());
|
|
|
| @@ -269,7 +386,7 @@ TEST_F(DisplayInfoProviderChromeosTest, GetRotation) {
|
| display_id, display::Display::ROTATE_180,
|
| display::Display::ROTATION_SOURCE_ACTIVE);
|
|
|
| - result = DisplayInfoProvider::Get()->GetAllDisplaysInfo();
|
| + result = GetAllDisplaysInfo();
|
|
|
| ASSERT_EQ(1u, result.size());
|
|
|
| @@ -281,7 +398,7 @@ TEST_F(DisplayInfoProviderChromeosTest, GetRotation) {
|
| display_id, display::Display::ROTATE_0,
|
| display::Display::ROTATION_SOURCE_ACTIVE);
|
|
|
| - result = DisplayInfoProvider::Get()->GetAllDisplaysInfo();
|
| + result = GetAllDisplaysInfo();
|
|
|
| ASSERT_EQ(1u, result.size());
|
|
|
| @@ -293,7 +410,7 @@ TEST_F(DisplayInfoProviderChromeosTest, GetRotation) {
|
| TEST_F(DisplayInfoProviderChromeosTest, GetDPI) {
|
| UpdateDisplay("500x600,400x520*2");
|
| DisplayUnitInfoList result;
|
| - result = DisplayInfoProvider::Get()->GetAllDisplaysInfo();
|
| + result = GetAllDisplaysInfo();
|
|
|
| ASSERT_EQ(2u, result.size());
|
|
|
| @@ -309,7 +426,7 @@ TEST_F(DisplayInfoProviderChromeosTest, GetDPI) {
|
|
|
| SwapPrimaryDisplay();
|
|
|
| - result = DisplayInfoProvider::Get()->GetAllDisplaysInfo();
|
| + result = GetAllDisplaysInfo();
|
|
|
| ASSERT_EQ(2u, result.size());
|
|
|
| @@ -326,7 +443,7 @@ TEST_F(DisplayInfoProviderChromeosTest, GetDPI) {
|
| TEST_F(DisplayInfoProviderChromeosTest, GetVisibleArea) {
|
| UpdateDisplay("640x720*2/o, 400x520/o");
|
| DisplayUnitInfoList result;
|
| - result = DisplayInfoProvider::Get()->GetAllDisplaysInfo();
|
| + result = GetAllDisplaysInfo();
|
|
|
| ASSERT_EQ(2u, result.size());
|
|
|
| @@ -341,7 +458,7 @@ TEST_F(DisplayInfoProviderChromeosTest, GetVisibleArea) {
|
|
|
| GetDisplayManager()->SetOverscanInsets(display_id,
|
| gfx::Insets(20, 30, 50, 60));
|
| - result = DisplayInfoProvider::Get()->GetAllDisplaysInfo();
|
| + result = GetAllDisplaysInfo();
|
|
|
| ASSERT_EQ(2u, result.size());
|
|
|
| @@ -359,7 +476,7 @@ TEST_F(DisplayInfoProviderChromeosTest, GetVisibleArea) {
|
|
|
| GetDisplayManager()->SetOverscanInsets(display_id,
|
| gfx::Insets(10, 20, 30, 40));
|
| - result = DisplayInfoProvider::Get()->GetAllDisplaysInfo();
|
| + result = GetAllDisplaysInfo();
|
|
|
| ASSERT_EQ(2u, result.size());
|
|
|
| @@ -371,7 +488,7 @@ TEST_F(DisplayInfoProviderChromeosTest, GetVisibleArea) {
|
| TEST_F(DisplayInfoProviderChromeosTest, GetMirroring) {
|
| UpdateDisplay("600x600, 400x520/o");
|
| DisplayUnitInfoList result;
|
| - result = DisplayInfoProvider::Get()->GetAllDisplaysInfo();
|
| + result = GetAllDisplaysInfo();
|
|
|
| ASSERT_EQ(2u, result.size());
|
|
|
| @@ -394,7 +511,7 @@ TEST_F(DisplayInfoProviderChromeosTest, GetMirroring) {
|
| GetDisplayManager()->SetMirrorMode(true);
|
| ASSERT_TRUE(GetDisplayManager()->IsInMirrorMode());
|
|
|
| - result = DisplayInfoProvider::Get()->GetAllDisplaysInfo();
|
| + result = GetAllDisplaysInfo();
|
|
|
| ASSERT_EQ(1u, result.size());
|
| EXPECT_EQ(base::Int64ToString(display_id_primary), result[0].id);
|
| @@ -404,7 +521,7 @@ TEST_F(DisplayInfoProviderChromeosTest, GetMirroring) {
|
| GetDisplayManager()->SetMirrorMode(false);
|
| ASSERT_FALSE(GetDisplayManager()->IsInMirrorMode());
|
|
|
| - result = DisplayInfoProvider::Get()->GetAllDisplaysInfo();
|
| + result = GetAllDisplaysInfo();
|
|
|
| ASSERT_EQ(2u, result.size());
|
| EXPECT_EQ(base::Int64ToString(display_id_primary), result[0].id);
|
| @@ -419,7 +536,7 @@ TEST_F(DisplayInfoProviderChromeosTest, GetBounds) {
|
| display::test::CreateDisplayLayout(display_manager(),
|
| display::DisplayPlacement::LEFT, -40));
|
|
|
| - DisplayUnitInfoList result = DisplayInfoProvider::Get()->GetAllDisplaysInfo();
|
| + DisplayUnitInfoList result = GetAllDisplaysInfo();
|
|
|
| ASSERT_EQ(2u, result.size());
|
| EXPECT_EQ("0,0 600x600", SystemInfoDisplayBoundsToString(result[0].bounds));
|
| @@ -430,7 +547,7 @@ TEST_F(DisplayInfoProviderChromeosTest, GetBounds) {
|
| display::test::CreateDisplayLayout(display_manager(),
|
| display::DisplayPlacement::TOP, 40));
|
|
|
| - result = DisplayInfoProvider::Get()->GetAllDisplaysInfo();
|
| + result = GetAllDisplaysInfo();
|
|
|
| ASSERT_EQ(2u, result.size());
|
| EXPECT_EQ("0,0 600x600", SystemInfoDisplayBoundsToString(result[0].bounds));
|
| @@ -441,7 +558,7 @@ TEST_F(DisplayInfoProviderChromeosTest, GetBounds) {
|
| display::test::CreateDisplayLayout(
|
| display_manager(), display::DisplayPlacement::BOTTOM, 80));
|
|
|
| - result = DisplayInfoProvider::Get()->GetAllDisplaysInfo();
|
| + result = GetAllDisplaysInfo();
|
| ASSERT_EQ(2u, result.size());
|
| EXPECT_EQ("0,0 600x600", SystemInfoDisplayBoundsToString(result[0].bounds));
|
| EXPECT_EQ("80,600 400x520",
|
| @@ -451,8 +568,7 @@ TEST_F(DisplayInfoProviderChromeosTest, GetBounds) {
|
| TEST_F(DisplayInfoProviderChromeosTest, Layout) {
|
| UpdateDisplay("500x400,500x400,500x400");
|
|
|
| - DisplayUnitInfoList displays =
|
| - DisplayInfoProvider::Get()->GetAllDisplaysInfo();
|
| + DisplayUnitInfoList displays = GetAllDisplaysInfo();
|
| std::string primary_id = displays[0].id;
|
| ASSERT_EQ(3u, displays.size());
|
|
|
| @@ -1151,7 +1267,7 @@ TEST_F(DisplayInfoProviderChromeosTest, SetOverscanForInternal) {
|
| TEST_F(DisplayInfoProviderChromeosTest, DisplayMode) {
|
| UpdateDisplay("1200x600,600x1000");
|
|
|
| - DisplayUnitInfoList result = DisplayInfoProvider::Get()->GetAllDisplaysInfo();
|
| + DisplayUnitInfoList result = GetAllDisplaysInfo();
|
| ASSERT_GE(result.size(), 1u);
|
| const api::system_display::DisplayUnitInfo& primary_info = result[0];
|
| // Ensure that we have two modes for the primary display so that we can
|
|
|