summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormukai <mukai@chromium.org>2014-10-14 14:28:25 -0700
committerCommit bot <commit-bot@chromium.org>2014-10-14 21:28:57 +0000
commit9afa39c161c8ffd23cb8fbcbedd344dc7d9f4fc4 (patch)
treef674bb54c4e9895f841782cf90eeac08e53c3bff
parent214a168378651a66a2872811d537a319cbed4216 (diff)
downloadchromium_src-9afa39c161c8ffd23cb8fbcbedd344dc7d9f4fc4.zip
chromium_src-9afa39c161c8ffd23cb8fbcbedd344dc7d9f4fc4.tar.gz
chromium_src-9afa39c161c8ffd23cb8fbcbedd344dc7d9f4fc4.tar.bz2
Do not check if the number of display is exactly 2.
When a display removal and a display add happens at the same time, the number of display is actually 3 during the display removal event. Therefore the check is too strict. BUG=414394 R=oshima@chromium.org TEST=the new test case covers Review URL: https://codereview.chromium.org/650403002 Cr-Commit-Position: refs/heads/master@{#299553}
-rw-r--r--ash/display/display_manager_unittest.cc30
-rw-r--r--ash/screen_util.cc2
2 files changed, 31 insertions, 1 deletions
diff --git a/ash/display/display_manager_unittest.cc b/ash/display/display_manager_unittest.cc
index aa2330c..1ce0045 100644
--- a/ash/display/display_manager_unittest.cc
+++ b/ash/display/display_manager_unittest.cc
@@ -572,6 +572,36 @@ TEST_F(DisplayManagerTest, TestNativeDisplaysChanged) {
EXPECT_FALSE(display_manager()->IsMirrored());
}
+// Make sure crash does not happen if add and remove happens at the same time.
+// See: crbug.com/414394
+TEST_F(DisplayManagerTest, DisplayAddRemoveAtTheSameTime) {
+ if (!SupportsMultipleDisplays())
+ return;
+
+ UpdateDisplay("100+0-500x500,0+501-400x400");
+
+ const int64 primary_id = DisplayController::GetPrimaryDisplayId();
+ const int64 secondary_id = ScreenUtil::GetSecondaryDisplay().id();
+
+ DisplayInfo primary_info = display_manager()->GetDisplayInfo(primary_id);
+ DisplayInfo secondary_info = display_manager()->GetDisplayInfo(secondary_id);
+
+ // An id which is different from primary and secondary.
+ const int64 third_id = primary_id + secondary_id;
+
+ DisplayInfo third_info =
+ CreateDisplayInfo(third_id, gfx::Rect(0, 0, 600, 600));
+
+ std::vector<DisplayInfo> display_info_list;
+ display_info_list.push_back(third_info);
+ display_info_list.push_back(secondary_info);
+ display_manager()->OnNativeDisplaysChanged(display_info_list);
+
+ EXPECT_EQ(third_id, DisplayController::GetPrimaryDisplayId());
+ EXPECT_EQ("600x600", GetDisplayForId(third_id).size().ToString());
+ EXPECT_EQ(secondary_id, ScreenUtil::GetSecondaryDisplay().id());
+}
+
#if defined(OS_WIN)
// TODO(scottmg): RootWindow doesn't get resized on Windows
// Ash. http://crbug.com/247916.
diff --git a/ash/screen_util.cc b/ash/screen_util.cc
index a412d70..0e19b9d 100644
--- a/ash/screen_util.cc
+++ b/ash/screen_util.cc
@@ -73,7 +73,7 @@ gfx::Rect ScreenUtil::ConvertRectFromScreen(aura::Window* window,
// static
const gfx::Display& ScreenUtil::GetSecondaryDisplay() {
DisplayManager* display_manager = GetDisplayManager();
- CHECK_EQ(2U, display_manager->GetNumDisplays());
+ CHECK_LE(2U, display_manager->GetNumDisplays());
return display_manager->GetDisplayAt(0).id() ==
Shell::GetScreen()->GetPrimaryDisplay().id() ?
display_manager->GetDisplayAt(1) : display_manager->GetDisplayAt(0);