Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(194)

Unified Diff: ash/shelf/shelf_layout_manager_unittest.cc

Issue 850833004: Fix shelf dimming on secondary display (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 11 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 | « no previous file | ash/shelf/shelf_widget.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ash/shelf/shelf_layout_manager_unittest.cc
diff --git a/ash/shelf/shelf_layout_manager_unittest.cc b/ash/shelf/shelf_layout_manager_unittest.cc
index 1ad54a81bee5b5b926772c202a3d901ebc3ec6f7..7d84adc67dc73020b133be40db0f86fed4230df7 100644
--- a/ash/shelf/shelf_layout_manager_unittest.cc
+++ b/ash/shelf/shelf_layout_manager_unittest.cc
@@ -1118,7 +1118,7 @@ TEST_F(ShelfLayoutManagerTest, SetAutoHideBehavior) {
}
// Basic assertions around the dimming of the shelf.
-TEST_F(ShelfLayoutManagerTest, TestDimmingBehavior) {
+TEST_F(ShelfLayoutManagerTest, DimmingBehavior) {
// Since ShelfLayoutManager queries for mouse location, move the mouse so
// it isn't over the shelf.
ui::test::EventGenerator generator(Shell::GetPrimaryRootWindow(),
@@ -1191,8 +1191,63 @@ TEST_F(ShelfLayoutManagerTest, TestDimmingBehavior) {
EXPECT_EQ(-1, shelf->shelf_widget()->GetDimmingAlphaForTest());
}
+// Test that dimming works correctly with multiple displays.
+TEST_F(ShelfLayoutManagerTest, DimmingBehaviorDualDisplay) {
+ if (!SupportsMultipleDisplays())
+ return;
+
+ // Create two displays.
+ Shell* shell = Shell::GetInstance();
+ UpdateDisplay("0+0-200x200,+200+0-100x100");
+ EXPECT_EQ(2U, shell->display_manager()->GetNumDisplays());
+
+ DisplayController* display_controller = shell->display_controller();
+ aura::Window::Windows root_windows = display_controller->GetAllRootWindows();
+ EXPECT_EQ(root_windows.size(), 2U);
+
+ std::vector<ShelfWidget*> shelf_widgets;
+ for (auto& root_window : root_windows) {
+ ShelfLayoutManager* shelf =
+ GetRootWindowController(root_window)->GetShelfLayoutManager();
+ shelf_widgets.push_back(shelf->shelf_widget());
+
+ // For disabling the dimming animation to work, the animation must be
+ // disabled prior to creating the dimmer.
+ shelf_widgets.back()->DisableDimmingAnimationsForTest();
+
+ // Create a maximized window to create the dimmer.
+ views::Widget* widget = new views::Widget;
+ views::Widget::InitParams params(views::Widget::InitParams::TYPE_WINDOW);
+ params.context = root_window;
+ params.bounds = root_window->GetBoundsInScreen();
+ params.show_state = ui::SHOW_STATE_MAXIMIZED;
+ widget->Init(params);
+ widget->Show();
+ }
+
+ ui::test::EventGenerator& generator(GetEventGenerator());
+
+ generator.MoveMouseTo(root_windows[0]->GetBoundsInScreen().CenterPoint());
+ EXPECT_LT(0, shelf_widgets[0]->GetDimmingAlphaForTest());
+ EXPECT_LT(0, shelf_widgets[1]->GetDimmingAlphaForTest());
+
+ generator.MoveMouseTo(
+ shelf_widgets[0]->GetWindowBoundsInScreen().CenterPoint());
+ EXPECT_EQ(0, shelf_widgets[0]->GetDimmingAlphaForTest());
+ EXPECT_LT(0, shelf_widgets[1]->GetDimmingAlphaForTest());
+
+ generator.MoveMouseTo(
+ shelf_widgets[1]->GetWindowBoundsInScreen().CenterPoint());
+ EXPECT_LT(0, shelf_widgets[0]->GetDimmingAlphaForTest());
+ EXPECT_EQ(0, shelf_widgets[1]->GetDimmingAlphaForTest());
+
+ generator.MoveMouseTo(root_windows[1]->GetBoundsInScreen().CenterPoint());
+ EXPECT_LT(0, shelf_widgets[0]->GetDimmingAlphaForTest());
+ EXPECT_LT(0, shelf_widgets[1]->GetDimmingAlphaForTest());
+}
+
// Assertions around the dimming of the shelf in conjunction with menus.
-TEST_F(ShelfLayoutManagerTest, TestDimmingBehaviorWithMenus) {
+TEST_F(ShelfLayoutManagerTest, DimmingBehaviorWithMenus) {
// Since ShelfLayoutManager queries for mouse location, move the mouse so
// it isn't over the shelf.
ui::test::EventGenerator generator(Shell::GetPrimaryRootWindow(),
« no previous file with comments | « no previous file | ash/shelf/shelf_widget.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698