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

Unified Diff: ash/launcher/launcher_view_unittest.cc

Issue 24141003: ash: Fix crash in launcher tooltip manager (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase, fix nit Created 7 years, 3 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ash/launcher/launcher_view.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ash/launcher/launcher_view_unittest.cc
diff --git a/ash/launcher/launcher_view_unittest.cc b/ash/launcher/launcher_view_unittest.cc
index a92f969c10d227fcaa2bf1650a3adc6dd60a50d4..d8d9afa458ccae44797a2032227095d2728449f6 100644
--- a/ash/launcher/launcher_view_unittest.cc
+++ b/ash/launcher/launcher_view_unittest.cc
@@ -1083,6 +1083,55 @@ TEST_F(LauncherViewTest, LauncherTooltipTest) {
EXPECT_EQ(platform_button, GetTooltipAnchorView());
}
+// Verify a fix for crash caused by a tooltip update for a deleted launcher
+// button, see crbug.com/288838.
+TEST_F(LauncherViewTest, RemovingItemClosesTooltip) {
+ internal::LauncherButtonHost* button_host = launcher_view_;
+ internal::LauncherTooltipManager* tooltip_manager =
+ launcher_view_->tooltip_manager();
+
+ // Add an item to the launcher.
+ LauncherID app_button_id = AddAppShortcut();
+ internal::LauncherButton* app_button = GetButtonByID(app_button_id);
+
+ // Spawn a tooltip on that item.
+ button_host->MouseEnteredButton(app_button);
+ ShowTooltip();
+ EXPECT_TRUE(tooltip_manager->IsVisible());
+
+ // Remove the app shortcut while the tooltip is open. The tooltip should be
+ // closed.
+ RemoveByID(app_button_id);
+ EXPECT_FALSE(tooltip_manager->IsVisible());
+
+ // Change the shelf layout. This should not crash.
+ ash::Shell::GetInstance()->SetShelfAlignment(
+ ash::SHELF_ALIGNMENT_LEFT,
+ ash::Shell::GetPrimaryRootWindow());
+}
+
+// Changing the shelf alignment closes any open tooltip.
+TEST_F(LauncherViewTest, ShelfAlignmentClosesTooltip) {
+ internal::LauncherButtonHost* button_host = launcher_view_;
+ internal::LauncherTooltipManager* tooltip_manager =
+ launcher_view_->tooltip_manager();
+
+ // Add an item to the launcher.
+ LauncherID app_button_id = AddAppShortcut();
+ internal::LauncherButton* app_button = GetButtonByID(app_button_id);
+
+ // Spawn a tooltip on the item.
+ button_host->MouseEnteredButton(app_button);
+ ShowTooltip();
+ EXPECT_TRUE(tooltip_manager->IsVisible());
+
+ // Changing shelf alignment hides the tooltip.
+ ash::Shell::GetInstance()->SetShelfAlignment(
+ ash::SHELF_ALIGNMENT_LEFT,
+ ash::Shell::GetPrimaryRootWindow());
+ EXPECT_FALSE(tooltip_manager->IsVisible());
+}
+
TEST_F(LauncherViewTest, ShouldHideTooltipTest) {
LauncherID app_button_id = AddAppShortcut();
LauncherID platform_button_id = AddPlatformApp();
« no previous file with comments | « ash/launcher/launcher_view.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698