| Index: ash/display/display_manager_unittest.cc
|
| diff --git a/ash/display/display_manager_unittest.cc b/ash/display/display_manager_unittest.cc
|
| index ee87a58635cf9f72dd9b5a18d844a6fe26a8d1b0..0190acd09107a2a25b32b0c73576a72f10175cd1 100644
|
| --- a/ash/display/display_manager_unittest.cc
|
| +++ b/ash/display/display_manager_unittest.cc
|
| @@ -4,6 +4,7 @@
|
|
|
| #include "ash/display/display_manager.h"
|
|
|
| +#include "ash/accelerators/accelerator_commands.h"
|
| #include "ash/ash_switches.h"
|
| #include "ash/display/display_info.h"
|
| #include "ash/display/display_layout_store.h"
|
| @@ -1551,6 +1552,111 @@ TEST_F(DisplayManagerTest, UnifiedDesktopBasic) {
|
| EXPECT_EQ("400x500", ScreenUtil::GetSecondaryDisplay().size().ToString());
|
| }
|
|
|
| +TEST_F(DisplayManagerTest, UnifiedDesktopWith2xDSF) {
|
| + if (!SupportsMultipleDisplays())
|
| + return;
|
| + // Don't check root window destruction in unified mode.
|
| + Shell::GetPrimaryRootWindow()->RemoveObserver(this);
|
| +
|
| + test::DisplayManagerTestApi::EnableUnifiedDesktopForTest();
|
| + gfx::Screen* screen =
|
| + gfx::Screen::GetScreenByType(gfx::SCREEN_TYPE_ALTERNATE);
|
| +
|
| + // 2nd display is 2x.
|
| + UpdateDisplay("400x500,1000x800*2");
|
| + DisplayInfo info =
|
| + display_manager()->GetDisplayInfo(screen->GetPrimaryDisplay().id());
|
| + EXPECT_EQ(2u, info.display_modes().size());
|
| + EXPECT_EQ("1640x800", info.display_modes()[0].size.ToString());
|
| + EXPECT_EQ(2.0f, info.display_modes()[0].device_scale_factor);
|
| + EXPECT_EQ("1025x500", info.display_modes()[1].size.ToString());
|
| + EXPECT_EQ(1.0f, info.display_modes()[1].device_scale_factor);
|
| +
|
| + // It defaults to the highest resolution. With 2x DSF,
|
| + // (800 / 500 * 400 + 500) /2 = 820
|
| + EXPECT_EQ("820x400", screen->GetPrimaryDisplay().size().ToString());
|
| + EXPECT_EQ("820x400",
|
| + Shell::GetPrimaryRootWindow()->bounds().size().ToString());
|
| + accelerators::ZoomInternalDisplay(true);
|
| + // For 1x, 400 + 500 / 800 * 100 = 1025.
|
| + EXPECT_EQ("1025x500", screen->GetPrimaryDisplay().size().ToString());
|
| + EXPECT_EQ("1025x500",
|
| + Shell::GetPrimaryRootWindow()->bounds().size().ToString());
|
| +
|
| + // 1st display is 2x.
|
| + UpdateDisplay("1200x800*2,1000x1000");
|
| + info = display_manager()->GetDisplayInfo(screen->GetPrimaryDisplay().id());
|
| + EXPECT_EQ(2u, info.display_modes().size());
|
| + EXPECT_EQ("2000x800", info.display_modes()[0].size.ToString());
|
| + EXPECT_EQ(2.0f, info.display_modes()[0].device_scale_factor);
|
| + EXPECT_EQ("2500x1000", info.display_modes()[1].size.ToString());
|
| + EXPECT_EQ(1.0f, info.display_modes()[1].device_scale_factor);
|
| +
|
| + // It defaults to the highest resolution (1x).
|
| + // 1000 / 800 * 1200 + 1000 = 2500
|
| + EXPECT_EQ("2500x1000", screen->GetPrimaryDisplay().size().ToString());
|
| + EXPECT_EQ("2500x1000",
|
| + Shell::GetPrimaryRootWindow()->bounds().size().ToString());
|
| + accelerators::ZoomInternalDisplay(false);
|
| + // For 2x, (800 / 1000 * 1000 + 1200) / 2 = 1000
|
| + EXPECT_EQ("1000x400", screen->GetPrimaryDisplay().size().ToString());
|
| + EXPECT_EQ("1000x400",
|
| + Shell::GetPrimaryRootWindow()->bounds().size().ToString());
|
| +
|
| + // Both displays are 2x.
|
| + // 1st display is 2x.
|
| + UpdateDisplay("1200x800*2,1000x1000*2");
|
| + info = display_manager()->GetDisplayInfo(screen->GetPrimaryDisplay().id());
|
| + EXPECT_EQ(2u, info.display_modes().size());
|
| + EXPECT_EQ("2000x800", info.display_modes()[0].size.ToString());
|
| + EXPECT_EQ(2.0f, info.display_modes()[0].device_scale_factor);
|
| + EXPECT_EQ("2500x1000", info.display_modes()[1].size.ToString());
|
| + EXPECT_EQ(2.0f, info.display_modes()[1].device_scale_factor);
|
| +
|
| + EXPECT_EQ("1250x500", screen->GetPrimaryDisplay().size().ToString());
|
| + EXPECT_EQ("1250x500",
|
| + Shell::GetPrimaryRootWindow()->bounds().size().ToString());
|
| + accelerators::ZoomInternalDisplay(false);
|
| + EXPECT_EQ("1000x400", screen->GetPrimaryDisplay().size().ToString());
|
| + EXPECT_EQ("1000x400",
|
| + Shell::GetPrimaryRootWindow()->bounds().size().ToString());
|
| +
|
| + // Both displays have the same physical height, with the first display
|
| + // being 2x.
|
| + UpdateDisplay("1000x800*2,300x800");
|
| + info = display_manager()->GetDisplayInfo(screen->GetPrimaryDisplay().id());
|
| + EXPECT_EQ(2u, info.display_modes().size());
|
| + EXPECT_EQ("1300x800", info.display_modes()[0].size.ToString());
|
| + EXPECT_EQ(2.0f, info.display_modes()[0].device_scale_factor);
|
| + EXPECT_EQ("1300x800", info.display_modes()[1].size.ToString());
|
| + EXPECT_EQ(1.0f, info.display_modes()[1].device_scale_factor);
|
| +
|
| + EXPECT_EQ("650x400", screen->GetPrimaryDisplay().size().ToString());
|
| + EXPECT_EQ("650x400",
|
| + Shell::GetPrimaryRootWindow()->bounds().size().ToString());
|
| + accelerators::ZoomInternalDisplay(true);
|
| + EXPECT_EQ("1300x800", screen->GetPrimaryDisplay().size().ToString());
|
| + EXPECT_EQ("1300x800",
|
| + Shell::GetPrimaryRootWindow()->bounds().size().ToString());
|
| +
|
| + // Both displays have the same physical height, with the second display
|
| + // being 2x.
|
| + UpdateDisplay("1000x800,300x800*2");
|
| + EXPECT_EQ(2u, info.display_modes().size());
|
| + EXPECT_EQ("1300x800", info.display_modes()[0].size.ToString());
|
| + EXPECT_EQ(2.0f, info.display_modes()[0].device_scale_factor);
|
| + EXPECT_EQ("1300x800", info.display_modes()[1].size.ToString());
|
| + EXPECT_EQ(1.0f, info.display_modes()[1].device_scale_factor);
|
| +
|
| + EXPECT_EQ("1300x800", screen->GetPrimaryDisplay().size().ToString());
|
| + EXPECT_EQ("1300x800",
|
| + Shell::GetPrimaryRootWindow()->bounds().size().ToString());
|
| + accelerators::ZoomInternalDisplay(false);
|
| + EXPECT_EQ("650x400", screen->GetPrimaryDisplay().size().ToString());
|
| + EXPECT_EQ("650x400",
|
| + Shell::GetPrimaryRootWindow()->bounds().size().ToString());
|
| +}
|
| +
|
| // Updating displays again in unified desktop mode should not crash.
|
| // crbug.com/491094.
|
| TEST_F(DisplayManagerTest, ConfigureUnifiedTwice) {
|
|
|