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

Side by Side Diff: ash/shelf/shelf_layout_manager_unittest.cc

Issue 2823133002: Clean up some ash constants. (Closed)
Patch Set: ditto Created 3 years, 8 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 unified diff | Download patch
« no previous file with comments | « ash/shelf/shelf_layout_manager.cc ('k') | ash/shelf/shelf_view.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "ash/shelf/shelf_layout_manager.h" 5 #include "ash/shelf/shelf_layout_manager.h"
6 6
7 #include "ash/accelerators/accelerator_controller.h" 7 #include "ash/accelerators/accelerator_controller.h"
8 #include "ash/accelerators/accelerator_table.h" 8 #include "ash/accelerators/accelerator_table.h"
9 #include "ash/focus_cycler.h" 9 #include "ash/focus_cycler.h"
10 #include "ash/public/cpp/config.h" 10 #include "ash/public/cpp/config.h"
(...skipping 684 matching lines...) Expand 10 before | Expand all | Expand 10 after
695 ShelfLayoutManager* layout_manager = GetShelfLayoutManager(); 695 ShelfLayoutManager* layout_manager = GetShelfLayoutManager();
696 shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS); 696 shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS);
697 views::Widget* widget = CreateTestWidget(); 697 views::Widget* widget = CreateTestWidget();
698 widget->Maximize(); 698 widget->Maximize();
699 EXPECT_EQ(SHELF_AUTO_HIDE, shelf->GetVisibilityState()); 699 EXPECT_EQ(SHELF_AUTO_HIDE, shelf->GetVisibilityState());
700 EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, shelf->GetAutoHideState()); 700 EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, shelf->GetAutoHideState());
701 701
702 // LayoutShelf() forces the animation to completion, at which point the 702 // LayoutShelf() forces the animation to completion, at which point the
703 // shelf should go off the screen. 703 // shelf should go off the screen.
704 layout_manager->LayoutShelf(); 704 layout_manager->LayoutShelf();
705 const int shelf_insets = GetShelfConstant(SHELF_INSETS_FOR_AUTO_HIDE);
706 705
707 display::Display display = display::Screen::GetScreen()->GetPrimaryDisplay(); 706 display::Display display = display::Screen::GetScreen()->GetPrimaryDisplay();
708 const int display_bottom = display.bounds().bottom(); 707 const int display_bottom = display.bounds().bottom();
709 EXPECT_EQ(display_bottom - kShelfAutoHideSize, 708 EXPECT_EQ(display_bottom - kShelfAutoHideSize,
710 GetShelfWidget()->GetWindowBoundsInScreen().y()); 709 GetShelfWidget()->GetWindowBoundsInScreen().y());
711 EXPECT_EQ(display_bottom - shelf_insets, display.work_area().bottom()); 710 EXPECT_EQ(display_bottom, display.work_area().bottom());
712 711
713 // Move the mouse to the bottom of the screen. 712 // Move the mouse to the bottom of the screen.
714 generator.MoveMouseTo(0, display_bottom - 1); 713 generator.MoveMouseTo(0, display_bottom - 1);
715 714
716 // Shelf should be shown again (but it shouldn't have changed the work area). 715 // Shelf should be shown again (but it shouldn't have changed the work area).
717 SetState(layout_manager, SHELF_AUTO_HIDE); 716 SetState(layout_manager, SHELF_AUTO_HIDE);
718 EXPECT_EQ(SHELF_AUTO_HIDE_SHOWN, shelf->GetAutoHideState()); 717 EXPECT_EQ(SHELF_AUTO_HIDE_SHOWN, shelf->GetAutoHideState());
719 layout_manager->LayoutShelf(); 718 layout_manager->LayoutShelf();
720 EXPECT_EQ(display_bottom - layout_manager->GetIdealBounds().height(), 719 EXPECT_EQ(display_bottom - layout_manager->GetIdealBounds().height(),
721 GetShelfWidget()->GetWindowBoundsInScreen().y()); 720 GetShelfWidget()->GetWindowBoundsInScreen().y());
722 EXPECT_EQ(display_bottom - shelf_insets, display.work_area().bottom()); 721 EXPECT_EQ(display_bottom, display.work_area().bottom());
723 722
724 // Move mouse back up. 723 // Move mouse back up.
725 generator.MoveMouseTo(0, 0); 724 generator.MoveMouseTo(0, 0);
726 SetState(layout_manager, SHELF_AUTO_HIDE); 725 SetState(layout_manager, SHELF_AUTO_HIDE);
727 EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, shelf->GetAutoHideState()); 726 EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, shelf->GetAutoHideState());
728 layout_manager->LayoutShelf(); 727 layout_manager->LayoutShelf();
729 EXPECT_EQ(display_bottom - kShelfAutoHideSize, 728 EXPECT_EQ(display_bottom - kShelfAutoHideSize,
730 GetShelfWidget()->GetWindowBoundsInScreen().y()); 729 GetShelfWidget()->GetWindowBoundsInScreen().y());
731 730
732 // Drag mouse to bottom of screen. 731 // Drag mouse to bottom of screen.
(...skipping 557 matching lines...) Expand 10 before | Expand all | Expand 10 after
1290 EXPECT_EQ(layout_manager->GetIdealBounds().width(), 1289 EXPECT_EQ(layout_manager->GetIdealBounds().width(),
1291 display.GetWorkAreaInsets().left()); 1290 display.GetWorkAreaInsets().left());
1292 EXPECT_EQ(0, display.GetWorkAreaInsets().top()); 1291 EXPECT_EQ(0, display.GetWorkAreaInsets().top());
1293 EXPECT_EQ(0, display.GetWorkAreaInsets().bottom()); 1292 EXPECT_EQ(0, display.GetWorkAreaInsets().bottom());
1294 EXPECT_EQ(0, display.GetWorkAreaInsets().right()); 1293 EXPECT_EQ(0, display.GetWorkAreaInsets().right());
1295 EXPECT_EQ(display.bounds().x(), shelf_bounds.x()); 1294 EXPECT_EQ(display.bounds().x(), shelf_bounds.x());
1296 EXPECT_EQ(display.bounds().y(), shelf_bounds.y()); 1295 EXPECT_EQ(display.bounds().y(), shelf_bounds.y());
1297 EXPECT_EQ(display.bounds().height(), shelf_bounds.height()); 1296 EXPECT_EQ(display.bounds().height(), shelf_bounds.height());
1298 shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS); 1297 shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS);
1299 display = display::Screen::GetScreen()->GetPrimaryDisplay(); 1298 display = display::Screen::GetScreen()->GetPrimaryDisplay();
1300 EXPECT_EQ(GetShelfConstant(SHELF_INSETS_FOR_AUTO_HIDE), 1299 EXPECT_EQ(0, display.GetWorkAreaInsets().left());
1301 display.GetWorkAreaInsets().left()); 1300 EXPECT_EQ(0, display.work_area().x());
1302 EXPECT_EQ(GetShelfConstant(SHELF_INSETS_FOR_AUTO_HIDE),
1303 display.work_area().x());
1304 1301
1305 shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_NEVER); 1302 shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_NEVER);
1306 shelf->SetAlignment(SHELF_ALIGNMENT_RIGHT); 1303 shelf->SetAlignment(SHELF_ALIGNMENT_RIGHT);
1307 shelf_bounds = GetShelfWidget()->GetWindowBoundsInScreen(); 1304 shelf_bounds = GetShelfWidget()->GetWindowBoundsInScreen();
1308 display = display::Screen::GetScreen()->GetPrimaryDisplay(); 1305 display = display::Screen::GetScreen()->GetPrimaryDisplay();
1309 ASSERT_NE(-1, display.id()); 1306 ASSERT_NE(-1, display.id());
1310 EXPECT_EQ(layout_manager->GetIdealBounds().width(), 1307 EXPECT_EQ(layout_manager->GetIdealBounds().width(),
1311 display.GetWorkAreaInsets().right()); 1308 display.GetWorkAreaInsets().right());
1312 EXPECT_GE(shelf_bounds.width(), 1309 EXPECT_GE(shelf_bounds.width(),
1313 GetShelfWidget()->GetContentsView()->GetPreferredSize().width()); 1310 GetShelfWidget()->GetContentsView()->GetPreferredSize().width());
1314 EXPECT_EQ(SHELF_ALIGNMENT_RIGHT, GetPrimarySystemTray()->shelf_alignment()); 1311 EXPECT_EQ(SHELF_ALIGNMENT_RIGHT, GetPrimarySystemTray()->shelf_alignment());
1315 status_bounds = gfx::Rect(status_area_widget->GetWindowBoundsInScreen()); 1312 status_bounds = gfx::Rect(status_area_widget->GetWindowBoundsInScreen());
1316 // TODO(estade): Re-enable this check. See crbug.com/660928. 1313 // TODO(estade): Re-enable this check. See crbug.com/660928.
1317 // EXPECT_GE( 1314 // EXPECT_GE(
1318 // status_bounds.width(), 1315 // status_bounds.width(),
1319 // status_area_widget->GetContentsView()->GetPreferredSize().width()); 1316 // status_area_widget->GetContentsView()->GetPreferredSize().width());
1320 EXPECT_EQ(layout_manager->GetIdealBounds().width(), 1317 EXPECT_EQ(layout_manager->GetIdealBounds().width(),
1321 display.GetWorkAreaInsets().right()); 1318 display.GetWorkAreaInsets().right());
1322 EXPECT_EQ(0, display.GetWorkAreaInsets().top()); 1319 EXPECT_EQ(0, display.GetWorkAreaInsets().top());
1323 EXPECT_EQ(0, display.GetWorkAreaInsets().bottom()); 1320 EXPECT_EQ(0, display.GetWorkAreaInsets().bottom());
1324 EXPECT_EQ(0, display.GetWorkAreaInsets().left()); 1321 EXPECT_EQ(0, display.GetWorkAreaInsets().left());
1325 EXPECT_EQ(display.work_area().right(), shelf_bounds.x()); 1322 EXPECT_EQ(display.work_area().right(), shelf_bounds.x());
1326 EXPECT_EQ(display.bounds().y(), shelf_bounds.y()); 1323 EXPECT_EQ(display.bounds().y(), shelf_bounds.y());
1327 EXPECT_EQ(display.bounds().height(), shelf_bounds.height()); 1324 EXPECT_EQ(display.bounds().height(), shelf_bounds.height());
1328 shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS); 1325 shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS);
1329 display = display::Screen::GetScreen()->GetPrimaryDisplay(); 1326 display = display::Screen::GetScreen()->GetPrimaryDisplay();
1330 EXPECT_EQ(GetShelfConstant(SHELF_INSETS_FOR_AUTO_HIDE), 1327 EXPECT_EQ(0, display.GetWorkAreaInsets().right());
1331 display.GetWorkAreaInsets().right()); 1328 EXPECT_EQ(0, display.bounds().right() - display.work_area().right());
1332 EXPECT_EQ(GetShelfConstant(SHELF_INSETS_FOR_AUTO_HIDE),
1333 display.bounds().right() - display.work_area().right());
1334 } 1329 }
1335 1330
1336 TEST_F(ShelfLayoutManagerTest, GestureDrag) { 1331 TEST_F(ShelfLayoutManagerTest, GestureDrag) {
1337 // TODO: investigate failure in mash, http://crbug.com/695686. 1332 // TODO: investigate failure in mash, http://crbug.com/695686.
1338 if (Shell::GetAshConfig() == Config::MASH) 1333 if (Shell::GetAshConfig() == Config::MASH)
1339 return; 1334 return;
1340 1335
1341 // Slop is an implementation detail of gesture recognition, and complicates 1336 // Slop is an implementation detail of gesture recognition, and complicates
1342 // these tests. Ignore it. 1337 // these tests. Ignore it.
1343 ui::GestureConfiguration::GetInstance() 1338 ui::GestureConfiguration::GetInstance()
(...skipping 496 matching lines...) Expand 10 before | Expand all | Expand 10 after
1840 // Open keyboard in sticky mode. 1835 // Open keyboard in sticky mode.
1841 kb_controller->ShowKeyboard(true); 1836 kb_controller->ShowKeyboard(true);
1842 layout_manager->OnKeyboardBoundsChanging(keyboard_bounds()); 1837 layout_manager->OnKeyboardBoundsChanging(keyboard_bounds());
1843 1838
1844 // Work area should be changed. 1839 // Work area should be changed.
1845 EXPECT_NE(orig_work_area, 1840 EXPECT_NE(orig_work_area,
1846 display::Screen::GetScreen()->GetPrimaryDisplay().work_area()); 1841 display::Screen::GetScreen()->GetPrimaryDisplay().work_area());
1847 } 1842 }
1848 1843
1849 } // namespace ash 1844 } // namespace ash
OLDNEW
« no previous file with comments | « ash/shelf/shelf_layout_manager.cc ('k') | ash/shelf/shelf_view.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698