summaryrefslogtreecommitdiffstats
path: root/ash
diff options
context:
space:
mode:
authoroshima <oshima@chromium.org>2015-01-08 09:29:17 -0800
committerCommit bot <commit-bot@chromium.org>2015-01-08 17:30:43 +0000
commit8aa20b07174add633dd74957558e22c41ae35a61 (patch)
tree13a9e951c8ed0a61193198f80ecf3d27a56143b4 /ash
parentcda33846b3070d2374853fa1c264ff134db847a0 (diff)
downloadchromium_src-8aa20b07174add633dd74957558e22c41ae35a61.zip
chromium_src-8aa20b07174add633dd74957558e22c41ae35a61.tar.gz
chromium_src-8aa20b07174add633dd74957558e22c41ae35a61.tar.bz2
Use the display ID from WTH table to find the candidate id for new primary display.
using GetSecondaryDisplay can return wrong (too new) information when used during transition. BUG=426292,438840 TEST=covered by unittest R=jamescook@chromium.org Review URL: https://codereview.chromium.org/816543005 Cr-Commit-Position: refs/heads/master@{#310525}
Diffstat (limited to 'ash')
-rw-r--r--ash/display/display_controller.cc4
-rw-r--r--ash/display/display_controller_unittest.cc64
2 files changed, 47 insertions, 21 deletions
diff --git a/ash/display/display_controller.cc b/ash/display/display_controller.cc
index ca213cf..826fef8 100644
--- a/ash/display/display_controller.cc
+++ b/ash/display/display_controller.cc
@@ -630,11 +630,9 @@ void DisplayController::OnDisplayRemoved(const gfx::Display& display) {
primary_tree_host_for_replace_ = host_to_delete;
return;
}
- primary_display_id = ScreenUtil::GetSecondaryDisplay().id();
+ primary_display_id = window_tree_hosts_.begin()->first;
CHECK_NE(gfx::Display::kInvalidDisplayID, primary_display_id);
- CHECK_EQ(1U, window_tree_hosts_.count(primary_display_id));
-
AshWindowTreeHost* primary_host = host_to_delete;
// Delete the other host instead.
host_to_delete = window_tree_hosts_[primary_display_id];
diff --git a/ash/display/display_controller_unittest.cc b/ash/display/display_controller_unittest.cc
index 320c3a3..d298eee 100644
--- a/ash/display/display_controller_unittest.cc
+++ b/ash/display/display_controller_unittest.cc
@@ -539,10 +539,17 @@ TEST_F(DisplayControllerTest, SecondaryDisplayLayout) {
namespace {
DisplayInfo CreateDisplayInfo(int64 id,
- const gfx::Rect& bounds,
- float device_scale_factor) {
+ int y,
+ gfx::Display::Rotation rotation) {
DisplayInfo info(id, "", false);
- info.SetBounds(bounds);
+ info.SetBounds(gfx::Rect(0, y, 500, 500));
+ info.set_rotation(rotation);
+ return info;
+}
+
+DisplayInfo CreateMirroredDisplayInfo(int64 id,
+ float device_scale_factor) {
+ DisplayInfo info = CreateDisplayInfo(id, 0, gfx::Display::ROTATE_0);
info.set_device_scale_factor(device_scale_factor);
return info;
}
@@ -561,9 +568,9 @@ TEST_F(DisplayControllerTest, MirrorToDockedWithFullscreen) {
DisplayManager* display_manager = Shell::GetInstance()->display_manager();
const DisplayInfo internal_display_info =
- CreateDisplayInfo(1, gfx::Rect(0, 0, 500, 500), 2.0f);
+ CreateMirroredDisplayInfo(1, 2.0f);
const DisplayInfo external_display_info =
- CreateDisplayInfo(2, gfx::Rect(0, 0, 500, 500), 1.0f);
+ CreateMirroredDisplayInfo(2, 1.0f);
std::vector<DisplayInfo> display_info_list;
// Mirror.
@@ -1264,19 +1271,6 @@ TEST_F(DisplayControllerTest, ConvertHostToRootCoords) {
Shell::GetInstance()->RemovePreTargetHandler(&event_handler);
}
-namespace {
-
-DisplayInfo CreateDisplayInfo(int64 id,
- int y,
- gfx::Display::Rotation rotation) {
- DisplayInfo info(id, "", false);
- info.SetBounds(gfx::Rect(0, y, 500, 500));
- info.set_rotation(rotation);
- return info;
-}
-
-} // namespace
-
// Make sure that the compositor based mirroring can switch
// from/to dock mode.
TEST_F(DisplayControllerTest, DockToSingle) {
@@ -1320,6 +1314,40 @@ TEST_F(DisplayControllerTest, DockToSingle) {
GetRootTransform().IsIdentityOrIntegerTranslation());
}
+// Tests if switching two displays at the same time while the primary display
+// is swapped should not cause a crash. (crbug.com/426292)
+TEST_F(DisplayControllerTest, ReplaceSwappedPrimary) {
+ if (!SupportsMultipleDisplays())
+ return;
+ DisplayManager* display_manager = Shell::GetInstance()->display_manager();
+
+ const DisplayInfo first_display_info =
+ CreateDisplayInfo(10, 0, gfx::Display::ROTATE_0);
+ const DisplayInfo second_display_info =
+ CreateDisplayInfo(11, 1, gfx::Display::ROTATE_0);
+
+ std::vector<DisplayInfo> display_info_list;
+ // Extended
+ display_info_list.push_back(first_display_info);
+ display_info_list.push_back(second_display_info);
+ display_manager->OnNativeDisplaysChanged(display_info_list);
+
+ Shell::GetInstance()->display_controller()->SwapPrimaryDisplay();
+
+ EXPECT_EQ(11, Shell::GetScreen()->GetPrimaryDisplay().id());
+
+ display_info_list.clear();
+ const DisplayInfo new_first_display_info =
+ CreateDisplayInfo(20, 0, gfx::Display::ROTATE_0);
+ const DisplayInfo new_second_display_info =
+ CreateDisplayInfo(21, 1, gfx::Display::ROTATE_0);
+ display_info_list.push_back(new_first_display_info);
+ display_info_list.push_back(new_second_display_info);
+ display_manager->OnNativeDisplaysChanged(display_info_list);
+
+ EXPECT_EQ(20, Shell::GetScreen()->GetPrimaryDisplay().id());
+}
+
#if defined(USE_X11)
TEST_F(DisplayControllerTest, XWidowNameForRootWindow) {
EXPECT_EQ("aura_root_0", GetXWindowName(