diff options
author | oshima <oshima@chromium.org> | 2015-08-20 02:09:56 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2015-08-20 09:10:55 +0000 |
commit | 5b67eb157932de54abbd02a3a02e4f412d92c9ee (patch) | |
tree | ce0412d49e78d9e8d7d5f48d3cbe64767fe843e9 /ash | |
parent | a326ed46c3923c0e3a29d030c10e3e76b3bdc288 (diff) | |
download | chromium_src-5b67eb157932de54abbd02a3a02e4f412d92c9ee.zip chromium_src-5b67eb157932de54abbd02a3a02e4f412d92c9ee.tar.gz chromium_src-5b67eb157932de54abbd02a3a02e4f412d92c9ee.tar.bz2 |
[Unified desktoip] Fix DHECK error when switching to/from mirror mode.
BUG=522805
TEST=DisplayManagerTest.UnifiedDesktiopWithHardwareMirroring
Review URL: https://codereview.chromium.org/1304473005
Cr-Commit-Position: refs/heads/master@{#344457}
Diffstat (limited to 'ash')
-rw-r--r-- | ash/display/display_manager.cc | 6 | ||||
-rw-r--r-- | ash/display/display_manager_unittest.cc | 40 |
2 files changed, 45 insertions, 1 deletions
diff --git a/ash/display/display_manager.cc b/ash/display/display_manager.cc index 6c0fca1..2ac027e 100644 --- a/ash/display/display_manager.cc +++ b/ash/display/display_manager.cc @@ -876,7 +876,11 @@ bool DisplayManager::IsInMirrorMode() const { void DisplayManager::SetUnifiedDesktopEnabled(bool enable) { unified_desktop_enabled_ = enable; - ReconfigureDisplays(); + // There is no need to update the displays in mirror mode. Doing + // this in hardware mirroring mode can cause crash because display + // info in hardware mirroring comes from DisplayConfigurator. + if (!IsInMirrorMode()) + ReconfigureDisplays(); } bool DisplayManager::IsInUnifiedMode() const { diff --git a/ash/display/display_manager_unittest.cc b/ash/display/display_manager_unittest.cc index 822452e..9c4876f 100644 --- a/ash/display/display_manager_unittest.cc +++ b/ash/display/display_manager_unittest.cc @@ -1567,6 +1567,46 @@ TEST_F(DisplayManagerTest, UnifiedDesktopBasic) { EXPECT_EQ("400x500", ScreenUtil::GetSecondaryDisplay().size().ToString()); } +TEST_F(DisplayManagerTest, UnifiedDesktopWithHardwareMirroring) { + if (!SupportsMultipleDisplays()) + return; + // Don't check root window destruction in unified mode. + Shell::GetPrimaryRootWindow()->RemoveObserver(this); + + // Enter to hardware mirroring. + DisplayInfo d1(1, "", false); + d1.SetBounds(gfx::Rect(0, 0, 500, 500)); + DisplayInfo d2(2, "", false); + d2.SetBounds(gfx::Rect(0, 0, 500, 500)); + std::vector<DisplayInfo> display_info_list; + display_info_list.push_back(d1); + display_info_list.push_back(d2); + display_manager()->OnNativeDisplaysChanged(display_info_list); + ASSERT_TRUE(display_manager()->IsInMirrorMode()); + display_manager()->SetUnifiedDesktopEnabled(true); + EXPECT_TRUE(display_manager()->IsInMirrorMode()); + + // The display manager automaticaclly switches to software mirroring + // if the displays are configured to use mirroring when running on desktop. + // This is a workdaround to force the display manager to forget + // the mirroing layout. + DisplayIdPair pair = CreateDisplayIdPair(1, 2); + DisplayLayout layout = + display_manager()->layout_store()->GetRegisteredDisplayLayout(pair); + layout.mirrored = false; + display_manager()->layout_store()->RegisterLayoutForDisplayIdPair(1, 2, + layout); + + // Exit from hardware mirroring. + d2.SetBounds(gfx::Rect(0, 500, 500, 500)); + display_info_list.clear(); + display_info_list.push_back(d1); + display_info_list.push_back(d2); + display_manager()->OnNativeDisplaysChanged(display_info_list); + EXPECT_FALSE(display_manager()->IsInMirrorMode()); + EXPECT_TRUE(display_manager()->IsInUnifiedMode()); +} + TEST_F(DisplayManagerTest, UnifiedDesktopEnabledWithExtended) { if (!SupportsMultipleDisplays()) return; |