| 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 <utility> | 8 #include <utility> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| (...skipping 963 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 974 // Test that any two successive visible icons never overlap in all shelf | 974 // Test that any two successive visible icons never overlap in all shelf |
| 975 // alignment types. | 975 // alignment types. |
| 976 const ShelfAlignment kAlignments[] = { | 976 const ShelfAlignment kAlignments[] = { |
| 977 SHELF_ALIGNMENT_LEFT, | 977 SHELF_ALIGNMENT_LEFT, |
| 978 SHELF_ALIGNMENT_RIGHT, | 978 SHELF_ALIGNMENT_RIGHT, |
| 979 SHELF_ALIGNMENT_TOP, | 979 SHELF_ALIGNMENT_TOP, |
| 980 SHELF_ALIGNMENT_BOTTOM | 980 SHELF_ALIGNMENT_BOTTOM |
| 981 }; | 981 }; |
| 982 | 982 |
| 983 for (ShelfAlignment alignment : kAlignments) { | 983 for (ShelfAlignment alignment : kAlignments) { |
| 984 EXPECT_TRUE(shelf_view_->shelf_layout_manager()->SetAlignment(alignment)); | 984 shelf_view_->shelf()->SetAlignment(alignment); |
| 985 // For every 2 successive visible icons, expect that their bounds don't | 985 // For every 2 successive visible icons, expect that their bounds don't |
| 986 // intersect. | 986 // intersect. |
| 987 for (int i = 1; i < test_api_->GetButtonCount() - 1; ++i) { | 987 for (int i = 1; i < test_api_->GetButtonCount() - 1; ++i) { |
| 988 if (!(test_api_->GetButton(i)->visible() && | 988 if (!(test_api_->GetButton(i)->visible() && |
| 989 test_api_->GetButton(i + 1)->visible())) { | 989 test_api_->GetButton(i + 1)->visible())) { |
| 990 continue; | 990 continue; |
| 991 } | 991 } |
| 992 | 992 |
| 993 const gfx::Rect& bounds1 = test_api_->GetBoundsByIndex(i); | 993 const gfx::Rect& bounds1 = test_api_->GetBoundsByIndex(i); |
| 994 const gfx::Rect& bounds2 = test_api_->GetBoundsByIndex(i + 1); | 994 const gfx::Rect& bounds2 = test_api_->GetBoundsByIndex(i + 1); |
| (...skipping 338 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1333 model_->Set(index, item); | 1333 model_->Set(index, item); |
| 1334 ASSERT_EQ(ShelfButton::STATE_ACTIVE, button->state()); | 1334 ASSERT_EQ(ShelfButton::STATE_ACTIVE, button->state()); |
| 1335 item.status = STATUS_ATTENTION; | 1335 item.status = STATUS_ATTENTION; |
| 1336 model_->Set(index, item); | 1336 model_->Set(index, item); |
| 1337 ASSERT_EQ(ShelfButton::STATE_ATTENTION, button->state()); | 1337 ASSERT_EQ(ShelfButton::STATE_ATTENTION, button->state()); |
| 1338 } | 1338 } |
| 1339 | 1339 |
| 1340 // Confirm that shelf item bounds are correctly updated on shelf changes. | 1340 // Confirm that shelf item bounds are correctly updated on shelf changes. |
| 1341 TEST_F(ShelfViewTest, ShelfItemBoundsCheck) { | 1341 TEST_F(ShelfViewTest, ShelfItemBoundsCheck) { |
| 1342 VerifyShelfItemBoundsAreValid(); | 1342 VerifyShelfItemBoundsAreValid(); |
| 1343 shelf_view_->shelf_layout_manager()->SetAutoHideBehavior( | 1343 shelf_view_->shelf()->shelf_layout_manager()->SetAutoHideBehavior( |
| 1344 SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS); | 1344 SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS); |
| 1345 test_api_->RunMessageLoopUntilAnimationsDone(); | 1345 test_api_->RunMessageLoopUntilAnimationsDone(); |
| 1346 VerifyShelfItemBoundsAreValid(); | 1346 VerifyShelfItemBoundsAreValid(); |
| 1347 shelf_view_->shelf_layout_manager()->SetAutoHideBehavior( | 1347 shelf_view_->shelf()->shelf_layout_manager()->SetAutoHideBehavior( |
| 1348 SHELF_AUTO_HIDE_BEHAVIOR_NEVER); | 1348 SHELF_AUTO_HIDE_BEHAVIOR_NEVER); |
| 1349 test_api_->RunMessageLoopUntilAnimationsDone(); | 1349 test_api_->RunMessageLoopUntilAnimationsDone(); |
| 1350 VerifyShelfItemBoundsAreValid(); | 1350 VerifyShelfItemBoundsAreValid(); |
| 1351 } | 1351 } |
| 1352 | 1352 |
| 1353 TEST_F(ShelfViewTest, ShelfTooltipTest) { | 1353 TEST_F(ShelfViewTest, ShelfTooltipTest) { |
| 1354 ASSERT_EQ(test_api_->GetLastVisibleIndex() + 1, | 1354 ASSERT_EQ(test_api_->GetLastVisibleIndex() + 1, |
| 1355 test_api_->GetButtonCount()); | 1355 test_api_->GetButtonCount()); |
| 1356 | 1356 |
| 1357 // Prepare some items to the shelf. | 1357 // Prepare some items to the shelf. |
| (...skipping 30 matching lines...) Expand all Loading... |
| 1388 tooltip_manager->Close(); | 1388 tooltip_manager->Close(); |
| 1389 | 1389 |
| 1390 // Next time: enter app_button -> move immediately to tab_button. | 1390 // Next time: enter app_button -> move immediately to tab_button. |
| 1391 button_host->MouseEnteredButton(app_button); | 1391 button_host->MouseEnteredButton(app_button); |
| 1392 button_host->MouseExitedButton(app_button); | 1392 button_host->MouseExitedButton(app_button); |
| 1393 button_host->MouseEnteredButton(platform_button); | 1393 button_host->MouseEnteredButton(platform_button); |
| 1394 EXPECT_FALSE(tooltip_manager->IsVisible()); | 1394 EXPECT_FALSE(tooltip_manager->IsVisible()); |
| 1395 EXPECT_EQ(platform_button, GetTooltipAnchorView()); | 1395 EXPECT_EQ(platform_button, GetTooltipAnchorView()); |
| 1396 } | 1396 } |
| 1397 | 1397 |
| 1398 // Verify a fix for crash caused by a tooltip update for a deletedshelf | 1398 // Verify a fix for crash caused by a tooltip update for a deleted shelf |
| 1399 // button, see crbug.com/288838. | 1399 // button, see crbug.com/288838. |
| 1400 TEST_F(ShelfViewTest, RemovingItemClosesTooltip) { | 1400 TEST_F(ShelfViewTest, RemovingItemClosesTooltip) { |
| 1401 ShelfButtonHost* button_host = shelf_view_; | 1401 ShelfButtonHost* button_host = shelf_view_; |
| 1402 ShelfTooltipManager* tooltip_manager = shelf_view_->tooltip_manager(); | 1402 ShelfTooltipManager* tooltip_manager = shelf_view_->tooltip_manager(); |
| 1403 | 1403 |
| 1404 // Add an item to the shelf. | 1404 // Add an item to the shelf. |
| 1405 ShelfID app_button_id = AddAppShortcut(); | 1405 ShelfID app_button_id = AddAppShortcut(); |
| 1406 ShelfButton* app_button = GetButtonByID(app_button_id); | 1406 ShelfButton* app_button = GetButtonByID(app_button_id); |
| 1407 | 1407 |
| 1408 // Spawn a tooltip on that item. | 1408 // Spawn a tooltip on that item. |
| (...skipping 549 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1958 test_api_->RunMessageLoopUntilAnimationsDone(); | 1958 test_api_->RunMessageLoopUntilAnimationsDone(); |
| 1959 CheckAllItemsAreInBounds(); | 1959 CheckAllItemsAreInBounds(); |
| 1960 } | 1960 } |
| 1961 | 1961 |
| 1962 INSTANTIATE_TEST_CASE_P(LtrRtl, ShelfViewTextDirectionTest, testing::Bool()); | 1962 INSTANTIATE_TEST_CASE_P(LtrRtl, ShelfViewTextDirectionTest, testing::Bool()); |
| 1963 INSTANTIATE_TEST_CASE_P(VisibleBounds, ShelfViewVisibleBoundsTest, | 1963 INSTANTIATE_TEST_CASE_P(VisibleBounds, ShelfViewVisibleBoundsTest, |
| 1964 testing::Bool()); | 1964 testing::Bool()); |
| 1965 | 1965 |
| 1966 } // namespace test | 1966 } // namespace test |
| 1967 } // namespace ash | 1967 } // namespace ash |
| OLD | NEW |