Chromium Code Reviews
[email protected] (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1073)

Unified Diff: ash/display/display_controller_unittest.cc

Issue 99163006: GetDisplayNearestPoint returns nearest display when point is outside of any display (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: GetDisplayNearestPoint returns nearest display when point is outside of any display Created 6 years, 12 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ash/display/display_controller.cc ('k') | ash/extended_desktop_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ash/display/display_controller_unittest.cc
diff --git a/ash/display/display_controller_unittest.cc b/ash/display/display_controller_unittest.cc
index 98f93042958e388b86fdd6e39e98fa2932a8fe25..ffcd6b03e22ffc3a182c1bf299b47139388b398c 100644
--- a/ash/display/display_controller_unittest.cc
+++ b/ash/display/display_controller_unittest.cc
@@ -641,7 +641,7 @@ TEST_F(DisplayControllerTest, SwapPrimary) {
EXPECT_EQ(secondary_display.id(),
Shell::GetScreen()->GetPrimaryDisplay().id());
EXPECT_EQ(primary_display.id(), ScreenAsh::GetSecondaryDisplay().id());
- EXPECT_EQ(secondary_display.id(),
+ EXPECT_EQ(primary_display.id(),
Shell::GetScreen()->GetDisplayNearestPoint(
gfx::Point(-100, -100)).id());
EXPECT_EQ(secondary_display.id(),
@@ -684,6 +684,49 @@ TEST_F(DisplayControllerTest, SwapPrimary) {
EXPECT_TRUE(primary_root->Contains(shelf_window));
}
+TEST_F(DisplayControllerTest, FindNearestDisplay) {
+ if (!SupportsMultipleDisplays())
+ return;
+
+ DisplayController* display_controller =
+ Shell::GetInstance()->display_controller();
+ internal::DisplayManager* display_manager =
+ Shell::GetInstance()->display_manager();
+
+ UpdateDisplay("200x200,300x300");
+ DisplayLayout display_layout(DisplayLayout::RIGHT, 50);
+ display_manager->SetLayoutForCurrentDisplays(display_layout);
+
+ gfx::Display primary_display = Shell::GetScreen()->GetPrimaryDisplay();
+ gfx::Display secondary_display = ScreenAsh::GetSecondaryDisplay();
+ EXPECT_NE(primary_display.id(), secondary_display.id());
+ aura::Window* primary_root =
+ display_controller->GetRootWindowForDisplayId(primary_display.id());
+ aura::Window* secondary_root =
+ display_controller->GetRootWindowForDisplayId(secondary_display.id());
+ EXPECT_NE(primary_root, secondary_root);
+
+ // Test that points outside of any display return the nearest display.
+ EXPECT_EQ(primary_display.id(), Shell::GetScreen()->GetDisplayNearestPoint(
+ gfx::Point(-100, 0)).id());
+ EXPECT_EQ(primary_display.id(), Shell::GetScreen()->GetDisplayNearestPoint(
+ gfx::Point(0, -100)).id());
+ EXPECT_EQ(primary_display.id(), Shell::GetScreen()->GetDisplayNearestPoint(
+ gfx::Point(100, 100)).id());
+ EXPECT_EQ(primary_display.id(), Shell::GetScreen()->GetDisplayNearestPoint(
+ gfx::Point(224, 25)).id());
+ EXPECT_EQ(secondary_display.id(), Shell::GetScreen()->GetDisplayNearestPoint(
+ gfx::Point(226, 25)).id());
+ EXPECT_EQ(secondary_display.id(), Shell::GetScreen()->GetDisplayNearestPoint(
+ gfx::Point(600, 100)).id());
+ EXPECT_EQ(primary_display.id(), Shell::GetScreen()->GetDisplayNearestPoint(
+ gfx::Point(174, 225)).id());
+ EXPECT_EQ(secondary_display.id(), Shell::GetScreen()->GetDisplayNearestPoint(
+ gfx::Point(176, 225)).id());
+ EXPECT_EQ(secondary_display.id(), Shell::GetScreen()->GetDisplayNearestPoint(
+ gfx::Point(300, 400)).id());
+}
+
TEST_F(DisplayControllerTest, SwapPrimaryForLegacyShelfLayout) {
if (!SupportsMultipleDisplays())
return;
@@ -735,7 +778,7 @@ TEST_F(DisplayControllerTest, SwapPrimaryForLegacyShelfLayout) {
EXPECT_EQ(secondary_display.id(),
Shell::GetScreen()->GetPrimaryDisplay().id());
EXPECT_EQ(primary_display.id(), ScreenAsh::GetSecondaryDisplay().id());
- EXPECT_EQ(secondary_display.id(),
+ EXPECT_EQ(primary_display.id(),
Shell::GetScreen()->GetDisplayNearestPoint(
gfx::Point(-100, -100)).id());
EXPECT_EQ(secondary_display.id(),
« no previous file with comments | « ash/display/display_controller.cc ('k') | ash/extended_desktop_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698