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

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

Issue 2020623004: ash: Move shelf alignment and auto-hide calls from Shell to Shelf (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 4 years, 6 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.h ('k') | ash/shelf/shelf_widget_unittest.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_view.h" 5 #include "ash/shelf/shelf_view.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <memory> 8 #include <memory>
9 #include <utility> 9 #include <utility>
10 #include <vector> 10 #include <vector>
(...skipping 1415 matching lines...) Expand 10 before | Expand all | Expand 10 after
1426 // Spawn a tooltip on that item. 1426 // Spawn a tooltip on that item.
1427 tooltip_manager->ShowTooltip(app_button); 1427 tooltip_manager->ShowTooltip(app_button);
1428 EXPECT_TRUE(tooltip_manager->IsVisible()); 1428 EXPECT_TRUE(tooltip_manager->IsVisible());
1429 1429
1430 // Remove the app shortcut while the tooltip is open. The tooltip should be 1430 // Remove the app shortcut while the tooltip is open. The tooltip should be
1431 // closed. 1431 // closed.
1432 RemoveByID(app_button_id); 1432 RemoveByID(app_button_id);
1433 EXPECT_FALSE(tooltip_manager->IsVisible()); 1433 EXPECT_FALSE(tooltip_manager->IsVisible());
1434 1434
1435 // Change the shelf layout. This should not crash. 1435 // Change the shelf layout. This should not crash.
1436 Shell::GetInstance()->SetShelfAlignment(wm::SHELF_ALIGNMENT_LEFT, 1436 Shelf::ForPrimaryDisplay()->SetAlignment(wm::SHELF_ALIGNMENT_LEFT);
1437 Shell::GetPrimaryRootWindow());
1438 } 1437 }
1439 1438
1440 // Changing the shelf alignment closes any open tooltip. 1439 // Changing the shelf alignment closes any open tooltip.
1441 TEST_F(ShelfViewTest, ShelfAlignmentClosesTooltip) { 1440 TEST_F(ShelfViewTest, ShelfAlignmentClosesTooltip) {
1442 ShelfTooltipManager* tooltip_manager = test_api_->tooltip_manager(); 1441 ShelfTooltipManager* tooltip_manager = test_api_->tooltip_manager();
1443 1442
1444 // Add an item to the shelf. 1443 // Add an item to the shelf.
1445 ShelfID app_button_id = AddAppShortcut(); 1444 ShelfID app_button_id = AddAppShortcut();
1446 ShelfButton* app_button = GetButtonByID(app_button_id); 1445 ShelfButton* app_button = GetButtonByID(app_button_id);
1447 1446
1448 // Spawn a tooltip on the item. 1447 // Spawn a tooltip on the item.
1449 tooltip_manager->ShowTooltip(app_button); 1448 tooltip_manager->ShowTooltip(app_button);
1450 EXPECT_TRUE(tooltip_manager->IsVisible()); 1449 EXPECT_TRUE(tooltip_manager->IsVisible());
1451 1450
1452 // Changing shelf alignment hides the tooltip. 1451 // Changing shelf alignment hides the tooltip.
1453 Shell::GetInstance()->SetShelfAlignment(wm::SHELF_ALIGNMENT_LEFT, 1452 Shelf::ForPrimaryDisplay()->SetAlignment(wm::SHELF_ALIGNMENT_LEFT);
1454 Shell::GetPrimaryRootWindow());
1455 EXPECT_FALSE(tooltip_manager->IsVisible()); 1453 EXPECT_FALSE(tooltip_manager->IsVisible());
1456 } 1454 }
1457 1455
1458 TEST_F(ShelfViewTest, ShouldHideTooltipTest) { 1456 TEST_F(ShelfViewTest, ShouldHideTooltipTest) {
1459 ShelfID app_button_id = AddAppShortcut(); 1457 ShelfID app_button_id = AddAppShortcut();
1460 ShelfID platform_button_id = AddPlatformApp(); 1458 ShelfID platform_button_id = AddPlatformApp();
1461 1459
1462 // The tooltip shouldn't hide if the mouse is on normal buttons. 1460 // The tooltip shouldn't hide if the mouse is on normal buttons.
1463 for (int i = 0; i < test_api_->GetButtonCount(); i++) { 1461 for (int i = 0; i < test_api_->GetButtonCount(); i++) {
1464 ShelfButton* button = test_api_->GetButton(i); 1462 ShelfButton* button = test_api_->GetButton(i);
(...skipping 318 matching lines...) Expand 10 before | Expand all | Expand 10 after
1783 // Checks the rip an item off from left aligned shelf in secondary monitor. 1781 // Checks the rip an item off from left aligned shelf in secondary monitor.
1784 TEST_F(ShelfViewTest, CheckRipOffFromLeftShelfAlignmentWithMultiMonitor) { 1782 TEST_F(ShelfViewTest, CheckRipOffFromLeftShelfAlignmentWithMultiMonitor) {
1785 // win8-aura doesn't support multiple display. 1783 // win8-aura doesn't support multiple display.
1786 if (!SupportsMultipleDisplays()) 1784 if (!SupportsMultipleDisplays())
1787 return; 1785 return;
1788 1786
1789 UpdateDisplay("800x600,800x600"); 1787 UpdateDisplay("800x600,800x600");
1790 ASSERT_EQ(2U, Shell::GetAllRootWindows().size()); 1788 ASSERT_EQ(2U, Shell::GetAllRootWindows().size());
1791 1789
1792 aura::Window* second_root = Shell::GetAllRootWindows()[1]; 1790 aura::Window* second_root = Shell::GetAllRootWindows()[1];
1791 Shelf* secondary_shelf = Shelf::ForWindow(second_root);
1793 1792
1794 Shell::GetInstance()->SetShelfAlignment(wm::SHELF_ALIGNMENT_LEFT, 1793 secondary_shelf->SetAlignment(wm::SHELF_ALIGNMENT_LEFT);
1795 second_root); 1794 ASSERT_EQ(wm::SHELF_ALIGNMENT_LEFT, secondary_shelf->alignment());
1796 ASSERT_EQ(wm::SHELF_ALIGNMENT_LEFT,
1797 Shell::GetInstance()->GetShelfAlignment(second_root));
1798 1795
1799 // Initially, app list and browser shortcut are added. 1796 // Initially, app list and browser shortcut are added.
1800 EXPECT_EQ(2, model_->item_count()); 1797 EXPECT_EQ(2, model_->item_count());
1801 int browser_index = model_->GetItemIndexForType(TYPE_BROWSER_SHORTCUT); 1798 int browser_index = model_->GetItemIndexForType(TYPE_BROWSER_SHORTCUT);
1802 EXPECT_GT(browser_index, 0); 1799 EXPECT_GT(browser_index, 0);
1803 1800
1804 Shelf* secondary_shelf = Shelf::ForWindow(second_root);
1805 ShelfView* shelf_view_for_secondary = 1801 ShelfView* shelf_view_for_secondary =
1806 ShelfTestAPI(secondary_shelf).shelf_view(); 1802 ShelfTestAPI(secondary_shelf).shelf_view();
1807 1803
1808 ShelfViewTestAPI test_api_for_secondary_shelf_view(shelf_view_for_secondary); 1804 ShelfViewTestAPI test_api_for_secondary_shelf_view(shelf_view_for_secondary);
1809 ShelfButton* button = 1805 ShelfButton* button =
1810 test_api_for_secondary_shelf_view.GetButton(browser_index); 1806 test_api_for_secondary_shelf_view.GetButton(browser_index);
1811 1807
1812 // Fetch the start point of dragging. 1808 // Fetch the start point of dragging.
1813 gfx::Point start_point = button->GetBoundsInScreen().CenterPoint(); 1809 gfx::Point start_point = button->GetBoundsInScreen().CenterPoint();
1814 ::wm::ConvertPointFromScreen(second_root, &start_point); 1810 ::wm::ConvertPointFromScreen(second_root, &start_point);
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after
1989 test_api_->RunMessageLoopUntilAnimationsDone(); 1985 test_api_->RunMessageLoopUntilAnimationsDone();
1990 CheckAllItemsAreInBounds(); 1986 CheckAllItemsAreInBounds();
1991 } 1987 }
1992 1988
1993 INSTANTIATE_TEST_CASE_P(LtrRtl, ShelfViewTextDirectionTest, testing::Bool()); 1989 INSTANTIATE_TEST_CASE_P(LtrRtl, ShelfViewTextDirectionTest, testing::Bool());
1994 INSTANTIATE_TEST_CASE_P(VisibleBounds, ShelfViewVisibleBoundsTest, 1990 INSTANTIATE_TEST_CASE_P(VisibleBounds, ShelfViewVisibleBoundsTest,
1995 testing::Bool()); 1991 testing::Bool());
1996 1992
1997 } // namespace test 1993 } // namespace test
1998 } // namespace ash 1994 } // namespace ash
OLDNEW
« no previous file with comments | « ash/shelf/shelf_layout_manager.h ('k') | ash/shelf/shelf_widget_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698