OLD | NEW |
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/common/shelf/shelf_view.h" | 5 #include "ash/common/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 1387 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1398 // Spawn a tooltip on that item. | 1398 // Spawn a tooltip on that item. |
1399 tooltip_manager->ShowTooltip(app_button); | 1399 tooltip_manager->ShowTooltip(app_button); |
1400 EXPECT_TRUE(tooltip_manager->IsVisible()); | 1400 EXPECT_TRUE(tooltip_manager->IsVisible()); |
1401 | 1401 |
1402 // Remove the app shortcut while the tooltip is open. The tooltip should be | 1402 // Remove the app shortcut while the tooltip is open. The tooltip should be |
1403 // closed. | 1403 // closed. |
1404 RemoveByID(app_button_id); | 1404 RemoveByID(app_button_id); |
1405 EXPECT_FALSE(tooltip_manager->IsVisible()); | 1405 EXPECT_FALSE(tooltip_manager->IsVisible()); |
1406 | 1406 |
1407 // Change the shelf layout. This should not crash. | 1407 // Change the shelf layout. This should not crash. |
1408 Shelf::ForPrimaryDisplay()->SetAlignment(SHELF_ALIGNMENT_LEFT); | 1408 GetPrimaryShelf()->SetAlignment(SHELF_ALIGNMENT_LEFT); |
1409 } | 1409 } |
1410 | 1410 |
1411 // Changing the shelf alignment closes any open tooltip. | 1411 // Changing the shelf alignment closes any open tooltip. |
1412 TEST_F(ShelfViewTest, ShelfAlignmentClosesTooltip) { | 1412 TEST_F(ShelfViewTest, ShelfAlignmentClosesTooltip) { |
1413 ShelfTooltipManager* tooltip_manager = test_api_->tooltip_manager(); | 1413 ShelfTooltipManager* tooltip_manager = test_api_->tooltip_manager(); |
1414 | 1414 |
1415 // Add an item to the shelf. | 1415 // Add an item to the shelf. |
1416 ShelfID app_button_id = AddAppShortcut(); | 1416 ShelfID app_button_id = AddAppShortcut(); |
1417 ShelfButton* app_button = GetButtonByID(app_button_id); | 1417 ShelfButton* app_button = GetButtonByID(app_button_id); |
1418 | 1418 |
1419 // Spawn a tooltip on the item. | 1419 // Spawn a tooltip on the item. |
1420 tooltip_manager->ShowTooltip(app_button); | 1420 tooltip_manager->ShowTooltip(app_button); |
1421 EXPECT_TRUE(tooltip_manager->IsVisible()); | 1421 EXPECT_TRUE(tooltip_manager->IsVisible()); |
1422 | 1422 |
1423 // Changing shelf alignment hides the tooltip. | 1423 // Changing shelf alignment hides the tooltip. |
1424 Shelf::ForPrimaryDisplay()->SetAlignment(SHELF_ALIGNMENT_LEFT); | 1424 GetPrimaryShelf()->SetAlignment(SHELF_ALIGNMENT_LEFT); |
1425 EXPECT_FALSE(tooltip_manager->IsVisible()); | 1425 EXPECT_FALSE(tooltip_manager->IsVisible()); |
1426 } | 1426 } |
1427 | 1427 |
1428 TEST_F(ShelfViewTest, ShouldHideTooltipTest) { | 1428 TEST_F(ShelfViewTest, ShouldHideTooltipTest) { |
1429 ShelfID app_button_id = AddAppShortcut(); | 1429 ShelfID app_button_id = AddAppShortcut(); |
1430 ShelfID platform_button_id = AddPlatformApp(); | 1430 ShelfID platform_button_id = AddPlatformApp(); |
1431 | 1431 |
1432 // The tooltip shouldn't hide if the mouse is on normal buttons. | 1432 // The tooltip shouldn't hide if the mouse is on normal buttons. |
1433 for (int i = 0; i < test_api_->GetButtonCount(); i++) { | 1433 for (int i = 0; i < test_api_->GetButtonCount(); i++) { |
1434 ShelfButton* button = test_api_->GetButton(i); | 1434 ShelfButton* button = test_api_->GetButton(i); |
(...skipping 317 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1752 // Checks the rip an item off from left aligned shelf in secondary monitor. | 1752 // Checks the rip an item off from left aligned shelf in secondary monitor. |
1753 TEST_F(ShelfViewTest, CheckRipOffFromLeftShelfAlignmentWithMultiMonitor) { | 1753 TEST_F(ShelfViewTest, CheckRipOffFromLeftShelfAlignmentWithMultiMonitor) { |
1754 // win8-aura doesn't support multiple display. | 1754 // win8-aura doesn't support multiple display. |
1755 if (!SupportsMultipleDisplays()) | 1755 if (!SupportsMultipleDisplays()) |
1756 return; | 1756 return; |
1757 | 1757 |
1758 UpdateDisplay("800x600,800x600"); | 1758 UpdateDisplay("800x600,800x600"); |
1759 ASSERT_EQ(2U, WmShell::Get()->GetAllRootWindows().size()); | 1759 ASSERT_EQ(2U, WmShell::Get()->GetAllRootWindows().size()); |
1760 | 1760 |
1761 WmWindow* second_root = WmShell::Get()->GetAllRootWindows()[1]; | 1761 WmWindow* second_root = WmShell::Get()->GetAllRootWindows()[1]; |
1762 Shelf* secondary_shelf = Shelf::ForWindow(second_root); | 1762 WmShelf* secondary_shelf = second_root->GetRootWindowController()->GetShelf(); |
1763 | 1763 |
1764 secondary_shelf->SetAlignment(SHELF_ALIGNMENT_LEFT); | 1764 secondary_shelf->SetAlignment(SHELF_ALIGNMENT_LEFT); |
1765 ASSERT_EQ(SHELF_ALIGNMENT_LEFT, secondary_shelf->alignment()); | 1765 ASSERT_EQ(SHELF_ALIGNMENT_LEFT, secondary_shelf->alignment()); |
1766 | 1766 |
1767 // Initially, app list and browser shortcut are added. | 1767 // Initially, app list and browser shortcut are added. |
1768 EXPECT_EQ(2, model_->item_count()); | 1768 EXPECT_EQ(2, model_->item_count()); |
1769 int browser_index = model_->GetItemIndexForType(TYPE_BROWSER_SHORTCUT); | 1769 int browser_index = model_->GetItemIndexForType(TYPE_BROWSER_SHORTCUT); |
1770 EXPECT_GT(browser_index, 0); | 1770 EXPECT_GT(browser_index, 0); |
1771 | 1771 |
1772 ShelfView* shelf_view_for_secondary = | 1772 ShelfView* shelf_view_for_secondary = |
1773 ShelfTestAPI(secondary_shelf).shelf_view(); | 1773 secondary_shelf->GetShelfViewForTesting(); |
1774 | 1774 |
1775 ShelfViewTestAPI test_api_for_secondary_shelf_view(shelf_view_for_secondary); | 1775 ShelfViewTestAPI test_api_for_secondary_shelf_view(shelf_view_for_secondary); |
1776 ShelfButton* button = | 1776 ShelfButton* button = |
1777 test_api_for_secondary_shelf_view.GetButton(browser_index); | 1777 test_api_for_secondary_shelf_view.GetButton(browser_index); |
1778 | 1778 |
1779 // Fetch the start point of dragging. | 1779 // Fetch the start point of dragging. |
1780 gfx::Point start_point = button->GetBoundsInScreen().CenterPoint(); | 1780 gfx::Point start_point = button->GetBoundsInScreen().CenterPoint(); |
1781 start_point = second_root->ConvertPointFromScreen(start_point); | 1781 start_point = second_root->ConvertPointFromScreen(start_point); |
1782 | 1782 |
1783 ui::test::EventGenerator generator(Shell::GetAllRootWindows()[1], | 1783 ui::test::EventGenerator generator(Shell::GetAllRootWindows()[1], |
(...skipping 784 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2568 test_api_->CloseMenu(); | 2568 test_api_->CloseMenu(); |
2569 EXPECT_EQ(views::InkDropState::HIDDEN, | 2569 EXPECT_EQ(views::InkDropState::HIDDEN, |
2570 browser_button_ink_drop_->GetTargetInkDropState()); | 2570 browser_button_ink_drop_->GetTargetInkDropState()); |
2571 EXPECT_THAT(browser_button_ink_drop_->GetAndResetRequestedStates(), | 2571 EXPECT_THAT(browser_button_ink_drop_->GetAndResetRequestedStates(), |
2572 ElementsAre(views::InkDropState::ACTIVATED, | 2572 ElementsAre(views::InkDropState::ACTIVATED, |
2573 views::InkDropState::DEACTIVATED)); | 2573 views::InkDropState::DEACTIVATED)); |
2574 } | 2574 } |
2575 | 2575 |
2576 } // namespace test | 2576 } // namespace test |
2577 } // namespace ash | 2577 } // namespace ash |
OLD | NEW |