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

Side by Side Diff: ash/common/shelf/shelf_tooltip_manager_unittest.cc

Issue 2383833003: Show tooltips in SHELF_AUTO_HIDE ShelfVisibilityState. (Closed)
Patch Set: Fix auto-hide shown and hidden behavior; fix tests. Created 4 years, 2 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/common/shelf/shelf_tooltip_manager.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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/common/shelf/shelf_tooltip_manager.h" 5 #include "ash/common/shelf/shelf_tooltip_manager.h"
6 6
7 #include "ash/common/shelf/app_list_button.h" 7 #include "ash/common/shelf/app_list_button.h"
8 #include "ash/common/shelf/shelf_model.h" 8 #include "ash/common/shelf/shelf_model.h"
9 #include "ash/common/shelf/shelf_view.h" 9 #include "ash/common/shelf/shelf_view.h"
10 #include "ash/common/shelf/wm_shelf.h" 10 #include "ash/common/shelf/wm_shelf.h"
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
116 116
117 // Do not show the view if the shelf is hidden. 117 // Do not show the view if the shelf is hidden.
118 tooltip_manager_->ShowTooltip(shelf_view_->GetAppListButton()); 118 tooltip_manager_->ShowTooltip(shelf_view_->GetAppListButton());
119 EXPECT_FALSE(tooltip_manager_->IsVisible()); 119 EXPECT_FALSE(tooltip_manager_->IsVisible());
120 120
121 // ShowTooltipWithDelay doesn't even start the timer for the hidden shelf. 121 // ShowTooltipWithDelay doesn't even start the timer for the hidden shelf.
122 tooltip_manager_->ShowTooltipWithDelay(shelf_view_->GetAppListButton()); 122 tooltip_manager_->ShowTooltipWithDelay(shelf_view_->GetAppListButton());
123 EXPECT_FALSE(IsTimerRunning()); 123 EXPECT_FALSE(IsTimerRunning());
124 } 124 }
125 125
126 TEST_F(ShelfTooltipManagerTest, HideWhenShelfIsAutoHide) { 126 TEST_F(ShelfTooltipManagerTest, HideWhenShelfIsAutoHideHidden) {
127 // Create a visible window so auto-hide behavior is enforced. 127 // Create a visible window so auto-hide behavior can actually hide the shelf.
128 std::unique_ptr<views::Widget> widget = CreateTestWidget(); 128 std::unique_ptr<views::Widget> widget = CreateTestWidget();
129 tooltip_manager_->ShowTooltip(shelf_view_->GetAppListButton()); 129 tooltip_manager_->ShowTooltip(shelf_view_->GetAppListButton());
130 ASSERT_TRUE(tooltip_manager_->IsVisible()); 130 ASSERT_TRUE(tooltip_manager_->IsVisible());
131 131
132 GetPrimaryShelf()->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS); 132 GetPrimaryShelf()->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS);
133 GetPrimaryShelf()->UpdateAutoHideState(); 133 GetPrimaryShelf()->UpdateAutoHideState();
134 ASSERT_EQ(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS,
135 GetPrimaryShelf()->auto_hide_behavior());
134 ASSERT_EQ(SHELF_AUTO_HIDE_HIDDEN, GetPrimaryShelf()->GetAutoHideState()); 136 ASSERT_EQ(SHELF_AUTO_HIDE_HIDDEN, GetPrimaryShelf()->GetAutoHideState());
135 137
136 // Tooltip visibility change for auto hide may take time. 138 // Tooltip visibility change for auto hide may take time.
137 EXPECT_TRUE(tooltip_manager_->IsVisible()); 139 EXPECT_TRUE(tooltip_manager_->IsVisible());
138 RunAllPendingInMessageLoop(); 140 RunAllPendingInMessageLoop();
139 EXPECT_FALSE(tooltip_manager_->IsVisible()); 141 EXPECT_FALSE(tooltip_manager_->IsVisible());
140 142
141 // Do not show the view if the shelf is hidden. 143 // Do not show the view if the shelf is hidden.
142 tooltip_manager_->ShowTooltip(shelf_view_->GetAppListButton()); 144 tooltip_manager_->ShowTooltip(shelf_view_->GetAppListButton());
143 EXPECT_FALSE(tooltip_manager_->IsVisible()); 145 EXPECT_FALSE(tooltip_manager_->IsVisible());
144 146
145 // ShowTooltipWithDelay doesn't even run the timer for the hidden shelf. 147 // ShowTooltipWithDelay doesn't even run the timer for the hidden shelf.
146 tooltip_manager_->ShowTooltipWithDelay(shelf_view_->GetAppListButton()); 148 tooltip_manager_->ShowTooltipWithDelay(shelf_view_->GetAppListButton());
147 EXPECT_FALSE(IsTimerRunning()); 149 EXPECT_FALSE(IsTimerRunning());
150
151 // Close the window to show the auto-hide shelf; tooltips should now show.
152 widget.reset();
153 GetPrimaryShelf()->UpdateAutoHideState();
154 ASSERT_EQ(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS,
155 GetPrimaryShelf()->auto_hide_behavior());
156 ASSERT_EQ(SHELF_AUTO_HIDE_SHOWN, GetPrimaryShelf()->GetAutoHideState());
157
158 // The tooltip should show for an auto-hide-shown shelf.
159 tooltip_manager_->ShowTooltip(shelf_view_->GetAppListButton());
160 EXPECT_TRUE(tooltip_manager_->IsVisible());
161
162 // ShowTooltipWithDelay should run the timer for an auto-hide-shown shelf.
163 tooltip_manager_->ShowTooltipWithDelay(shelf_view_->GetAppListButton());
164 EXPECT_TRUE(IsTimerRunning());
148 } 165 }
149 166
150 TEST_F(ShelfTooltipManagerTest, HideForEvents) { 167 TEST_F(ShelfTooltipManagerTest, HideForEvents) {
151 ui::test::EventGenerator& generator = GetEventGenerator(); 168 ui::test::EventGenerator& generator = GetEventGenerator();
152 gfx::Rect shelf_bounds = shelf_view_->GetBoundsInScreen(); 169 gfx::Rect shelf_bounds = shelf_view_->GetBoundsInScreen();
153 170
154 // Should hide if the mouse exits the shelf area. 171 // Should hide if the mouse exits the shelf area.
155 tooltip_manager_->ShowTooltip(shelf_view_->GetAppListButton()); 172 tooltip_manager_->ShowTooltip(shelf_view_->GetAppListButton());
156 ASSERT_TRUE(tooltip_manager_->IsVisible()); 173 ASSERT_TRUE(tooltip_manager_->IsVisible());
157 generator.MoveMouseTo(shelf_bounds.CenterPoint()); 174 generator.MoveMouseTo(shelf_bounds.CenterPoint());
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
211 228
212 // Should not hide for key events. 229 // Should not hide for key events.
213 tooltip_manager_->ShowTooltip(shelf_view_->GetAppListButton()); 230 tooltip_manager_->ShowTooltip(shelf_view_->GetAppListButton());
214 ASSERT_TRUE(tooltip_manager_->IsVisible()); 231 ASSERT_TRUE(tooltip_manager_->IsVisible());
215 generator.PressKey(ui::VKEY_A, ui::EF_NONE); 232 generator.PressKey(ui::VKEY_A, ui::EF_NONE);
216 EXPECT_TRUE(tooltip_manager_->IsVisible()); 233 EXPECT_TRUE(tooltip_manager_->IsVisible());
217 } 234 }
218 235
219 } // namespace test 236 } // namespace test
220 } // namespace ash 237 } // namespace ash
OLDNEW
« no previous file with comments | « ash/common/shelf/shelf_tooltip_manager.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698