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/launcher/launcher_view.h" | 5 #include "ash/launcher/launcher_view.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "ash/ash_switches.h" | 10 #include "ash/ash_switches.h" |
(...skipping 1065 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1076 tooltip_manager->Close(); | 1076 tooltip_manager->Close(); |
1077 | 1077 |
1078 // Next time: enter app_button -> move immediately to tab_button. | 1078 // Next time: enter app_button -> move immediately to tab_button. |
1079 button_host->MouseEnteredButton(app_button); | 1079 button_host->MouseEnteredButton(app_button); |
1080 button_host->MouseExitedButton(app_button); | 1080 button_host->MouseExitedButton(app_button); |
1081 button_host->MouseEnteredButton(platform_button); | 1081 button_host->MouseEnteredButton(platform_button); |
1082 EXPECT_FALSE(tooltip_manager->IsVisible()); | 1082 EXPECT_FALSE(tooltip_manager->IsVisible()); |
1083 EXPECT_EQ(platform_button, GetTooltipAnchorView()); | 1083 EXPECT_EQ(platform_button, GetTooltipAnchorView()); |
1084 } | 1084 } |
1085 | 1085 |
| 1086 // Verify a fix for crash caused by a tooltip update for a deleted launcher |
| 1087 // button, see crbug.com/288838. |
| 1088 TEST_F(LauncherViewTest, RemovingItemClosesTooltip) { |
| 1089 internal::LauncherButtonHost* button_host = launcher_view_; |
| 1090 internal::LauncherTooltipManager* tooltip_manager = |
| 1091 launcher_view_->tooltip_manager(); |
| 1092 |
| 1093 // Add an item to the launcher. |
| 1094 LauncherID app_button_id = AddAppShortcut(); |
| 1095 internal::LauncherButton* app_button = GetButtonByID(app_button_id); |
| 1096 |
| 1097 // Spawn a tooltip on that item. |
| 1098 button_host->MouseEnteredButton(app_button); |
| 1099 ShowTooltip(); |
| 1100 EXPECT_TRUE(tooltip_manager->IsVisible()); |
| 1101 |
| 1102 // Remove the app shortcut while the tooltip is open. The tooltip should be |
| 1103 // closed. |
| 1104 RemoveByID(app_button_id); |
| 1105 EXPECT_FALSE(tooltip_manager->IsVisible()); |
| 1106 |
| 1107 // Change the shelf layout. This should not crash. |
| 1108 ash::Shell::GetInstance()->SetShelfAlignment( |
| 1109 ash::SHELF_ALIGNMENT_LEFT, |
| 1110 ash::Shell::GetPrimaryRootWindow()); |
| 1111 } |
| 1112 |
| 1113 // Changing the shelf alignment closes any open tooltip. |
| 1114 TEST_F(LauncherViewTest, ShelfAlignmentClosesTooltip) { |
| 1115 internal::LauncherButtonHost* button_host = launcher_view_; |
| 1116 internal::LauncherTooltipManager* tooltip_manager = |
| 1117 launcher_view_->tooltip_manager(); |
| 1118 |
| 1119 // Add an item to the launcher. |
| 1120 LauncherID app_button_id = AddAppShortcut(); |
| 1121 internal::LauncherButton* app_button = GetButtonByID(app_button_id); |
| 1122 |
| 1123 // Spawn a tooltip on the item. |
| 1124 button_host->MouseEnteredButton(app_button); |
| 1125 ShowTooltip(); |
| 1126 EXPECT_TRUE(tooltip_manager->IsVisible()); |
| 1127 |
| 1128 // Changing shelf alignment hides the tooltip. |
| 1129 ash::Shell::GetInstance()->SetShelfAlignment( |
| 1130 ash::SHELF_ALIGNMENT_LEFT, |
| 1131 ash::Shell::GetPrimaryRootWindow()); |
| 1132 EXPECT_FALSE(tooltip_manager->IsVisible()); |
| 1133 } |
| 1134 |
1086 TEST_F(LauncherViewTest, ShouldHideTooltipTest) { | 1135 TEST_F(LauncherViewTest, ShouldHideTooltipTest) { |
1087 LauncherID app_button_id = AddAppShortcut(); | 1136 LauncherID app_button_id = AddAppShortcut(); |
1088 LauncherID platform_button_id = AddPlatformApp(); | 1137 LauncherID platform_button_id = AddPlatformApp(); |
1089 | 1138 |
1090 // The tooltip shouldn't hide if the mouse is on normal buttons. | 1139 // The tooltip shouldn't hide if the mouse is on normal buttons. |
1091 for (int i = 0; i < test_api_->GetButtonCount(); i++) { | 1140 for (int i = 0; i < test_api_->GetButtonCount(); i++) { |
1092 internal::LauncherButton* button = test_api_->GetButton(i); | 1141 internal::LauncherButton* button = test_api_->GetButton(i); |
1093 if (!button) | 1142 if (!button) |
1094 continue; | 1143 continue; |
1095 | 1144 |
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1241 test_api_->GetButtonCount()); | 1290 test_api_->GetButtonCount()); |
1242 gfx::Rect ideal_bounds_0 = test_api_->GetIdealBoundsByIndex(0); | 1291 gfx::Rect ideal_bounds_0 = test_api_->GetIdealBoundsByIndex(0); |
1243 gfx::Rect ideal_bounds_1 = test_api_->GetIdealBoundsByIndex(1); | 1292 gfx::Rect ideal_bounds_1 = test_api_->GetIdealBoundsByIndex(1); |
1244 EXPECT_GT(ideal_bounds_0.width(), ideal_bounds_1.width()); | 1293 EXPECT_GT(ideal_bounds_0.width(), ideal_bounds_1.width()); |
1245 } | 1294 } |
1246 | 1295 |
1247 INSTANTIATE_TEST_CASE_P(LtrRtl, LauncherViewTextDirectionTest, testing::Bool()); | 1296 INSTANTIATE_TEST_CASE_P(LtrRtl, LauncherViewTextDirectionTest, testing::Bool()); |
1248 | 1297 |
1249 } // namespace test | 1298 } // namespace test |
1250 } // namespace ash | 1299 } // namespace ash |
OLD | NEW |