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

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

Issue 1743493002: Cleanup ash shelf accessor functions. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Revert ash/shelf/shelf_widget.cc for browser_tests crash... Created 4 years, 9 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_view.cc ('k') | ash/shell.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 <utility> 8 #include <utility>
9 #include <vector> 9 #include <vector>
10 10
(...skipping 963 matching lines...) Expand 10 before | Expand all | Expand 10 after
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
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
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
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
OLDNEW
« no previous file with comments | « ash/shelf/shelf_view.cc ('k') | ash/shell.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698