| 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 944 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 955 for (int i = 0; i < 20; ++i) { | 955 for (int i = 0; i < 20; ++i) { |
| 956 ShelfID id = AddPanel(); | 956 ShelfID id = AddPanel(); |
| 957 button_ids.push_back(id); | 957 button_ids.push_back(id); |
| 958 } | 958 } |
| 959 ASSERT_LT(button_ids.size(), 10000U); | 959 ASSERT_LT(button_ids.size(), 10000U); |
| 960 EXPECT_TRUE(test_api_->IsOverflowButtonVisible()); | 960 EXPECT_TRUE(test_api_->IsOverflowButtonVisible()); |
| 961 | 961 |
| 962 // Test that any two successive visible icons never overlap in all shelf | 962 // Test that any two successive visible icons never overlap in all shelf |
| 963 // alignment types. | 963 // alignment types. |
| 964 const ShelfAlignment kAlignments[] = { | 964 const ShelfAlignment kAlignments[] = { |
| 965 SHELF_ALIGNMENT_LEFT, | 965 SHELF_ALIGNMENT_LEFT, SHELF_ALIGNMENT_RIGHT, SHELF_ALIGNMENT_BOTTOM, |
| 966 SHELF_ALIGNMENT_RIGHT, | 966 SHELF_ALIGNMENT_LOCKED, |
| 967 SHELF_ALIGNMENT_BOTTOM | |
| 968 }; | 967 }; |
| 969 | 968 |
| 970 for (ShelfAlignment alignment : kAlignments) { | 969 for (ShelfAlignment alignment : kAlignments) { |
| 971 shelf_view_->shelf()->SetAlignment(alignment); | 970 shelf_view_->shelf()->SetAlignment(alignment); |
| 972 // For every 2 successive visible icons, expect that their bounds don't | 971 // For every 2 successive visible icons, expect that their bounds don't |
| 973 // intersect. | 972 // intersect. |
| 974 for (int i = 1; i < test_api_->GetButtonCount() - 1; ++i) { | 973 for (int i = 1; i < test_api_->GetButtonCount() - 1; ++i) { |
| 975 if (!(test_api_->GetButton(i)->visible() && | 974 if (!(test_api_->GetButton(i)->visible() && |
| 976 test_api_->GetButton(i + 1)->visible())) { | 975 test_api_->GetButton(i + 1)->visible())) { |
| 977 continue; | 976 continue; |
| 978 } | 977 } |
| 979 | 978 |
| 980 const gfx::Rect& bounds1 = test_api_->GetBoundsByIndex(i); | 979 const gfx::Rect& bounds1 = test_api_->GetBoundsByIndex(i); |
| 981 const gfx::Rect& bounds2 = test_api_->GetBoundsByIndex(i + 1); | 980 const gfx::Rect& bounds2 = test_api_->GetBoundsByIndex(i + 1); |
| 982 EXPECT_FALSE(bounds1.Intersects(bounds2)); | 981 EXPECT_FALSE(bounds1.Intersects(bounds2)); |
| 983 } | 982 } |
| 984 } | 983 } |
| 985 } | 984 } |
| 986 | 985 |
| 987 // Making sure the overflow bubble arrow correctly tracks with shelf position. | 986 // Making sure the overflow bubble arrow correctly tracks with shelf position. |
| 988 TEST_F(ShelfViewTest, OverflowArrowForShelfPosition) { | 987 TEST_F(ShelfViewTest, OverflowArrowForShelfPosition) { |
| 989 const ShelfAlignment kAlignments[] = { | 988 const ShelfAlignment kAlignments[] = { |
| 990 SHELF_ALIGNMENT_BOTTOM, SHELF_ALIGNMENT_LEFT, SHELF_ALIGNMENT_RIGHT}; | 989 SHELF_ALIGNMENT_BOTTOM, SHELF_ALIGNMENT_LEFT, SHELF_ALIGNMENT_RIGHT, |
| 990 SHELF_ALIGNMENT_LOCKED, |
| 991 }; |
| 991 | 992 |
| 992 // These must match what is expected for each alignment above. | 993 // These must match what is expected for each alignment above. |
| 993 const views::BubbleBorder::Arrow kArrows[] = { | 994 const views::BubbleBorder::Arrow kArrows[] = { |
| 994 views::BubbleBorder::BOTTOM_LEFT, views::BubbleBorder::LEFT_TOP, | 995 views::BubbleBorder::BOTTOM_LEFT, views::BubbleBorder::LEFT_TOP, |
| 995 views::BubbleBorder::RIGHT_TOP}; | 996 views::BubbleBorder::RIGHT_TOP, views::BubbleBorder::BOTTOM_LEFT, |
| 997 }; |
| 996 | 998 |
| 997 for (size_t i = 0; i < arraysize(kAlignments); i++) { | 999 for (size_t i = 0; i < arraysize(kAlignments); i++) { |
| 998 shelf_view_->shelf()->SetAlignment(kAlignments[i]); | 1000 shelf_view_->shelf()->SetAlignment(kAlignments[i]); |
| 999 | 1001 |
| 1000 // Make sure there are enough icons to trigger the overflow in new | 1002 // Make sure there are enough icons to trigger the overflow in new |
| 1001 // orientation. | 1003 // orientation. |
| 1002 AddButtonsUntilOverflow(); | 1004 AddButtonsUntilOverflow(); |
| 1003 test_api_->ShowOverflowBubble(); | 1005 test_api_->ShowOverflowBubble(); |
| 1004 ASSERT_TRUE(test_api_->overflow_bubble() && | 1006 ASSERT_TRUE(test_api_->overflow_bubble() && |
| 1005 test_api_->overflow_bubble()->IsShowing()); | 1007 test_api_->overflow_bubble()->IsShowing()); |
| (...skipping 943 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1949 test_api_->RunMessageLoopUntilAnimationsDone(); | 1951 test_api_->RunMessageLoopUntilAnimationsDone(); |
| 1950 CheckAllItemsAreInBounds(); | 1952 CheckAllItemsAreInBounds(); |
| 1951 } | 1953 } |
| 1952 | 1954 |
| 1953 INSTANTIATE_TEST_CASE_P(LtrRtl, ShelfViewTextDirectionTest, testing::Bool()); | 1955 INSTANTIATE_TEST_CASE_P(LtrRtl, ShelfViewTextDirectionTest, testing::Bool()); |
| 1954 INSTANTIATE_TEST_CASE_P(VisibleBounds, ShelfViewVisibleBoundsTest, | 1956 INSTANTIATE_TEST_CASE_P(VisibleBounds, ShelfViewVisibleBoundsTest, |
| 1955 testing::Bool()); | 1957 testing::Bool()); |
| 1956 | 1958 |
| 1957 } // namespace test | 1959 } // namespace test |
| 1958 } // namespace ash | 1960 } // namespace ash |
| OLD | NEW |