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/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 942 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
953 // Add 20 panel icons, and expect to have overflow. | 953 // Add 20 panel icons, and expect to have overflow. |
954 for (int i = 0; i < 20; ++i) { | 954 for (int i = 0; i < 20; ++i) { |
955 ShelfID id = AddPanel(); | 955 ShelfID id = AddPanel(); |
956 button_ids.push_back(id); | 956 button_ids.push_back(id); |
957 } | 957 } |
958 ASSERT_LT(button_ids.size(), 10000U); | 958 ASSERT_LT(button_ids.size(), 10000U); |
959 EXPECT_TRUE(test_api_->IsOverflowButtonVisible()); | 959 EXPECT_TRUE(test_api_->IsOverflowButtonVisible()); |
960 | 960 |
961 // Test that any two successive visible icons never overlap in all shelf | 961 // Test that any two successive visible icons never overlap in all shelf |
962 // alignment types. | 962 // alignment types. |
963 const ShelfAlignment kAlignments[] = { | 963 const wm::ShelfAlignment kAlignments[] = { |
964 SHELF_ALIGNMENT_LEFT, SHELF_ALIGNMENT_RIGHT, SHELF_ALIGNMENT_BOTTOM, | 964 wm::SHELF_ALIGNMENT_LEFT, wm::SHELF_ALIGNMENT_RIGHT, |
965 SHELF_ALIGNMENT_BOTTOM_LOCKED, | 965 wm::SHELF_ALIGNMENT_BOTTOM, wm::SHELF_ALIGNMENT_BOTTOM_LOCKED, |
966 }; | 966 }; |
967 | 967 |
968 for (ShelfAlignment alignment : kAlignments) { | 968 for (wm::ShelfAlignment alignment : kAlignments) { |
969 shelf_view_->shelf()->SetAlignment(alignment); | 969 shelf_view_->shelf()->SetAlignment(alignment); |
970 // For every 2 successive visible icons, expect that their bounds don't | 970 // For every 2 successive visible icons, expect that their bounds don't |
971 // intersect. | 971 // intersect. |
972 for (int i = 1; i < test_api_->GetButtonCount() - 1; ++i) { | 972 for (int i = 1; i < test_api_->GetButtonCount() - 1; ++i) { |
973 if (!(test_api_->GetButton(i)->visible() && | 973 if (!(test_api_->GetButton(i)->visible() && |
974 test_api_->GetButton(i + 1)->visible())) { | 974 test_api_->GetButton(i + 1)->visible())) { |
975 continue; | 975 continue; |
976 } | 976 } |
977 | 977 |
978 const gfx::Rect& bounds1 = test_api_->GetBoundsByIndex(i); | 978 const gfx::Rect& bounds1 = test_api_->GetBoundsByIndex(i); |
979 const gfx::Rect& bounds2 = test_api_->GetBoundsByIndex(i + 1); | 979 const gfx::Rect& bounds2 = test_api_->GetBoundsByIndex(i + 1); |
980 EXPECT_FALSE(bounds1.Intersects(bounds2)); | 980 EXPECT_FALSE(bounds1.Intersects(bounds2)); |
981 } | 981 } |
982 } | 982 } |
983 } | 983 } |
984 | 984 |
985 // Making sure the overflow bubble arrow correctly tracks with shelf position. | 985 // Making sure the overflow bubble arrow correctly tracks with shelf position. |
986 TEST_F(ShelfViewTest, OverflowArrowForShelfPosition) { | 986 TEST_F(ShelfViewTest, OverflowArrowForShelfPosition) { |
987 const ShelfAlignment kAlignments[] = { | 987 const wm::ShelfAlignment kAlignments[] = { |
988 SHELF_ALIGNMENT_BOTTOM, SHELF_ALIGNMENT_LEFT, SHELF_ALIGNMENT_RIGHT, | 988 wm::SHELF_ALIGNMENT_BOTTOM, wm::SHELF_ALIGNMENT_LEFT, |
989 SHELF_ALIGNMENT_BOTTOM_LOCKED, | 989 wm::SHELF_ALIGNMENT_RIGHT, wm::SHELF_ALIGNMENT_BOTTOM_LOCKED, |
990 }; | 990 }; |
991 | 991 |
992 // These must match what is expected for each alignment above. | 992 // These must match what is expected for each alignment above. |
993 const views::BubbleBorder::Arrow kArrows[] = { | 993 const views::BubbleBorder::Arrow kArrows[] = { |
994 views::BubbleBorder::BOTTOM_LEFT, views::BubbleBorder::LEFT_TOP, | 994 views::BubbleBorder::BOTTOM_LEFT, views::BubbleBorder::LEFT_TOP, |
995 views::BubbleBorder::RIGHT_TOP, views::BubbleBorder::BOTTOM_LEFT, | 995 views::BubbleBorder::RIGHT_TOP, views::BubbleBorder::BOTTOM_LEFT, |
996 }; | 996 }; |
997 | 997 |
998 for (size_t i = 0; i < arraysize(kAlignments); i++) { | 998 for (size_t i = 0; i < arraysize(kAlignments); i++) { |
999 shelf_view_->shelf()->SetAlignment(kAlignments[i]); | 999 shelf_view_->shelf()->SetAlignment(kAlignments[i]); |
(...skipping 404 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1404 // Spawn a tooltip on that item. | 1404 // Spawn a tooltip on that item. |
1405 tooltip_manager->ShowTooltip(app_button); | 1405 tooltip_manager->ShowTooltip(app_button); |
1406 EXPECT_TRUE(tooltip_manager->IsVisible()); | 1406 EXPECT_TRUE(tooltip_manager->IsVisible()); |
1407 | 1407 |
1408 // Remove the app shortcut while the tooltip is open. The tooltip should be | 1408 // Remove the app shortcut while the tooltip is open. The tooltip should be |
1409 // closed. | 1409 // closed. |
1410 RemoveByID(app_button_id); | 1410 RemoveByID(app_button_id); |
1411 EXPECT_FALSE(tooltip_manager->IsVisible()); | 1411 EXPECT_FALSE(tooltip_manager->IsVisible()); |
1412 | 1412 |
1413 // Change the shelf layout. This should not crash. | 1413 // Change the shelf layout. This should not crash. |
1414 Shell::GetInstance()->SetShelfAlignment(SHELF_ALIGNMENT_LEFT, | 1414 Shell::GetInstance()->SetShelfAlignment(wm::SHELF_ALIGNMENT_LEFT, |
1415 Shell::GetPrimaryRootWindow()); | 1415 Shell::GetPrimaryRootWindow()); |
1416 } | 1416 } |
1417 | 1417 |
1418 // Changing the shelf alignment closes any open tooltip. | 1418 // Changing the shelf alignment closes any open tooltip. |
1419 TEST_F(ShelfViewTest, ShelfAlignmentClosesTooltip) { | 1419 TEST_F(ShelfViewTest, ShelfAlignmentClosesTooltip) { |
1420 ShelfTooltipManager* tooltip_manager = test_api_->tooltip_manager(); | 1420 ShelfTooltipManager* tooltip_manager = test_api_->tooltip_manager(); |
1421 | 1421 |
1422 // Add an item to the shelf. | 1422 // Add an item to the shelf. |
1423 ShelfID app_button_id = AddAppShortcut(); | 1423 ShelfID app_button_id = AddAppShortcut(); |
1424 ShelfButton* app_button = GetButtonByID(app_button_id); | 1424 ShelfButton* app_button = GetButtonByID(app_button_id); |
1425 | 1425 |
1426 // Spawn a tooltip on the item. | 1426 // Spawn a tooltip on the 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 // Changing shelf alignment hides the tooltip. | 1430 // Changing shelf alignment hides the tooltip. |
1431 Shell::GetInstance()->SetShelfAlignment(SHELF_ALIGNMENT_LEFT, | 1431 Shell::GetInstance()->SetShelfAlignment(wm::SHELF_ALIGNMENT_LEFT, |
1432 Shell::GetPrimaryRootWindow()); | 1432 Shell::GetPrimaryRootWindow()); |
1433 EXPECT_FALSE(tooltip_manager->IsVisible()); | 1433 EXPECT_FALSE(tooltip_manager->IsVisible()); |
1434 } | 1434 } |
1435 | 1435 |
1436 TEST_F(ShelfViewTest, ShouldHideTooltipTest) { | 1436 TEST_F(ShelfViewTest, ShouldHideTooltipTest) { |
1437 ShelfID app_button_id = AddAppShortcut(); | 1437 ShelfID app_button_id = AddAppShortcut(); |
1438 ShelfID platform_button_id = AddPlatformApp(); | 1438 ShelfID platform_button_id = AddPlatformApp(); |
1439 | 1439 |
1440 // The tooltip shouldn't hide if the mouse is on normal buttons. | 1440 // The tooltip shouldn't hide if the mouse is on normal buttons. |
1441 for (int i = 0; i < test_api_->GetButtonCount(); i++) { | 1441 for (int i = 0; i < test_api_->GetButtonCount(); i++) { |
(...skipping 320 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1762 TEST_F(ShelfViewTest, CheckRipOffFromLeftShelfAlignmentWithMultiMonitor) { | 1762 TEST_F(ShelfViewTest, CheckRipOffFromLeftShelfAlignmentWithMultiMonitor) { |
1763 // win8-aura doesn't support multiple display. | 1763 // win8-aura doesn't support multiple display. |
1764 if (!SupportsMultipleDisplays()) | 1764 if (!SupportsMultipleDisplays()) |
1765 return; | 1765 return; |
1766 | 1766 |
1767 UpdateDisplay("800x600,800x600"); | 1767 UpdateDisplay("800x600,800x600"); |
1768 ASSERT_EQ(2U, Shell::GetAllRootWindows().size()); | 1768 ASSERT_EQ(2U, Shell::GetAllRootWindows().size()); |
1769 | 1769 |
1770 aura::Window* second_root = Shell::GetAllRootWindows()[1]; | 1770 aura::Window* second_root = Shell::GetAllRootWindows()[1]; |
1771 | 1771 |
1772 Shell::GetInstance()->SetShelfAlignment(SHELF_ALIGNMENT_LEFT, second_root); | 1772 Shell::GetInstance()->SetShelfAlignment(wm::SHELF_ALIGNMENT_LEFT, |
1773 ASSERT_EQ(SHELF_ALIGNMENT_LEFT, | 1773 second_root); |
| 1774 ASSERT_EQ(wm::SHELF_ALIGNMENT_LEFT, |
1774 Shell::GetInstance()->GetShelfAlignment(second_root)); | 1775 Shell::GetInstance()->GetShelfAlignment(second_root)); |
1775 | 1776 |
1776 // Initially, app list and browser shortcut are added. | 1777 // Initially, app list and browser shortcut are added. |
1777 EXPECT_EQ(2, model_->item_count()); | 1778 EXPECT_EQ(2, model_->item_count()); |
1778 int browser_index = model_->GetItemIndexForType(TYPE_BROWSER_SHORTCUT); | 1779 int browser_index = model_->GetItemIndexForType(TYPE_BROWSER_SHORTCUT); |
1779 EXPECT_GT(browser_index, 0); | 1780 EXPECT_GT(browser_index, 0); |
1780 | 1781 |
1781 Shelf* secondary_shelf = Shelf::ForWindow(second_root); | 1782 Shelf* secondary_shelf = Shelf::ForWindow(second_root); |
1782 ShelfView* shelf_view_for_secondary = | 1783 ShelfView* shelf_view_for_secondary = |
1783 ShelfTestAPI(secondary_shelf).shelf_view(); | 1784 ShelfTestAPI(secondary_shelf).shelf_view(); |
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1950 test_api_->RunMessageLoopUntilAnimationsDone(); | 1951 test_api_->RunMessageLoopUntilAnimationsDone(); |
1951 CheckAllItemsAreInBounds(); | 1952 CheckAllItemsAreInBounds(); |
1952 } | 1953 } |
1953 | 1954 |
1954 INSTANTIATE_TEST_CASE_P(LtrRtl, ShelfViewTextDirectionTest, testing::Bool()); | 1955 INSTANTIATE_TEST_CASE_P(LtrRtl, ShelfViewTextDirectionTest, testing::Bool()); |
1955 INSTANTIATE_TEST_CASE_P(VisibleBounds, ShelfViewVisibleBoundsTest, | 1956 INSTANTIATE_TEST_CASE_P(VisibleBounds, ShelfViewVisibleBoundsTest, |
1956 testing::Bool()); | 1957 testing::Bool()); |
1957 | 1958 |
1958 } // namespace test | 1959 } // namespace test |
1959 } // namespace ash | 1960 } // namespace ash |
OLD | NEW |