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

Side by Side Diff: ash/system/tray/system_tray_unittest.cc

Issue 2961313003: Touch gestures for System Tray/ IME/ Stylus/ Notifications (Closed)
Patch Set: Fixed nits. Created 3 years, 5 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/system/tray/system_tray_bubble.cc ('k') | ash/system/tray/tray_background_view.h » ('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/system/tray/system_tray.h" 5 #include "ash/system/tray/system_tray.h"
6 6
7 #include <string> 7 #include <string>
8 #include <vector> 8 #include <vector>
9 9
10 #include "ash/accelerators/accelerator_controller.h" 10 #include "ash/accelerators/accelerator_controller.h"
11 #include "ash/accessibility_delegate.h" 11 #include "ash/accessibility_delegate.h"
12 #include "ash/public/cpp/shell_window_ids.h" 12 #include "ash/public/cpp/shell_window_ids.h"
13 #include "ash/root_window_controller.h" 13 #include "ash/root_window_controller.h"
14 #include "ash/shelf/shelf.h" 14 #include "ash/shelf/shelf.h"
15 #include "ash/shelf/shelf_widget.h" 15 #include "ash/shelf/shelf_widget.h"
16 #include "ash/shell.h" 16 #include "ash/shell.h"
17 #include "ash/system/status_area_widget.h" 17 #include "ash/system/status_area_widget.h"
18 #include "ash/system/tray/system_tray_bubble.h" 18 #include "ash/system/tray/system_tray_bubble.h"
19 #include "ash/system/tray/system_tray_item.h" 19 #include "ash/system/tray/system_tray_item.h"
20 #include "ash/system/tray/tray_constants.h" 20 #include "ash/system/tray/tray_constants.h"
21 #include "ash/system/tray_drag_controller.h"
21 #include "ash/system/web_notification/web_notification_tray.h" 22 #include "ash/system/web_notification/web_notification_tray.h"
22 #include "ash/test/ash_test_base.h" 23 #include "ash/test/ash_test_base.h"
23 #include "ash/test/status_area_widget_test_helper.h" 24 #include "ash/test/status_area_widget_test_helper.h"
24 #include "ash/test/test_system_tray_item.h" 25 #include "ash/test/test_system_tray_item.h"
25 #include "ash/wm/maximize_mode/maximize_mode_controller.h" 26 #include "ash/wm/maximize_mode/maximize_mode_controller.h"
26 #include "ash/wm/window_util.h" 27 #include "ash/wm/window_util.h"
27 #include "base/memory/ptr_util.h" 28 #include "base/memory/ptr_util.h"
28 #include "base/run_loop.h" 29 #include "base/run_loop.h"
29 #include "base/test/histogram_tester.h" 30 #include "base/test/histogram_tester.h"
30 #include "ui/base/ui_base_types.h" 31 #include "ui/base/ui_base_types.h"
(...skipping 19 matching lines...) Expand all
50 ~ModalWidgetDelegate() override {} 51 ~ModalWidgetDelegate() override {}
51 52
52 ui::ModalType GetModalType() const override { return ui::MODAL_TYPE_SYSTEM; } 53 ui::ModalType GetModalType() const override { return ui::MODAL_TYPE_SYSTEM; }
53 54
54 private: 55 private:
55 DISALLOW_COPY_AND_ASSIGN(ModalWidgetDelegate); 56 DISALLOW_COPY_AND_ASSIGN(ModalWidgetDelegate);
56 }; 57 };
57 58
58 } // namespace 59 } // namespace
59 60
61 // TODO(minch): move swiping related tests from SystemTrayTest to
62 // TraybackgroundView / TrayDragController. crbug.com/745073
60 class SystemTrayTest : public AshTestBase { 63 class SystemTrayTest : public AshTestBase {
61 public: 64 public:
62 SystemTrayTest() {} 65 SystemTrayTest() {}
63 ~SystemTrayTest() override {} 66 ~SystemTrayTest() override {}
64 67
65 // Swiping on the system tray and ends with finger released. 68 // Swiping on the system tray and ends with finger released. Note, |start| is
69 // based on the system tray or system tray bubble's coordinate space.
66 void SendGestureEvent(gfx::Point& start, 70 void SendGestureEvent(gfx::Point& start,
67 float delta, 71 float delta,
68 bool is_fling, 72 bool is_fling,
69 float velocity_y) { 73 float velocity_y,
70 SystemTray* system_tray = GetPrimarySystemTray(); 74 float scroll_y_hint = -1.0f,
75 bool drag_on_bubble = false) {
71 base::TimeTicks timestamp = base::TimeTicks::Now(); 76 base::TimeTicks timestamp = base::TimeTicks::Now();
72 SendScrollStartAndUpdate(start, delta, timestamp); 77 SendScrollStartAndUpdate(start, delta, timestamp, scroll_y_hint,
78 drag_on_bubble);
73 79
74 ui::GestureEventDetails details = 80 ui::GestureEventDetails details =
75 is_fling 81 is_fling
76 ? ui::GestureEventDetails(ui::ET_SCROLL_FLING_START, 0, velocity_y) 82 ? ui::GestureEventDetails(ui::ET_SCROLL_FLING_START, 0, velocity_y)
77 : ui::GestureEventDetails(ui::ET_GESTURE_SCROLL_END); 83 : ui::GestureEventDetails(ui::ET_GESTURE_SCROLL_END);
78 ui::GestureEvent event = ui::GestureEvent(start.x(), start.y() + delta, 84 ui::GestureEvent event = ui::GestureEvent(start.x(), start.y() + delta,
79 ui::EF_NONE, timestamp, details); 85 ui::EF_NONE, timestamp, details);
80 system_tray->OnGestureEvent(&event); 86 DispatchGestureEvent(&event, drag_on_bubble);
81 } 87 }
82 88
83 // Swiping on the system tray without releasing the finger. 89 // Swiping on the system tray without releasing the finger.
84 void SendScrollStartAndUpdate(gfx::Point& start, 90 void SendScrollStartAndUpdate(gfx::Point& start,
85 float delta, 91 float delta,
86 base::TimeTicks& timestamp) { 92 base::TimeTicks& timestamp,
87 SystemTray* system_tray = GetPrimarySystemTray(); 93 float scroll_y_hint = -1.0f,
88 ui::GestureEventDetails begin_details(ui::ET_GESTURE_SCROLL_BEGIN); 94 bool drag_on_bubble = false) {
95 ui::GestureEventDetails begin_details(ui::ET_GESTURE_SCROLL_BEGIN, 0,
96 scroll_y_hint);
89 ui::GestureEvent begin_event = ui::GestureEvent( 97 ui::GestureEvent begin_event = ui::GestureEvent(
90 start.x(), start.y(), ui::EF_NONE, timestamp, begin_details); 98 start.x(), start.y(), ui::EF_NONE, timestamp, begin_details);
91 system_tray->OnGestureEvent(&begin_event); 99 DispatchGestureEvent(&begin_event, drag_on_bubble);
92 100
93 ui::GestureEventDetails update_details(ui::ET_GESTURE_SCROLL_UPDATE, 0, 101 ui::GestureEventDetails update_details(ui::ET_GESTURE_SCROLL_UPDATE, 0,
94 delta); 102 delta);
95 timestamp += base::TimeDelta::FromMilliseconds(100); 103 timestamp += base::TimeDelta::FromMilliseconds(100);
96 ui::GestureEvent update_event = ui::GestureEvent( 104 ui::GestureEvent update_event = ui::GestureEvent(
97 start.x(), start.y() + delta, ui::EF_NONE, timestamp, update_details); 105 start.x(), start.y() + delta, ui::EF_NONE, timestamp, update_details);
98 system_tray->OnGestureEvent(&update_event); 106 DispatchGestureEvent(&update_event, drag_on_bubble);
107 }
108
109 // Dispatches |event| to target according to |drag_on_bubble|.
110 void DispatchGestureEvent(ui::GestureEvent* event, bool drag_on_bubble) {
111 SystemTray* system_tray = GetPrimarySystemTray();
112 views::View* target = drag_on_bubble
113 ? system_tray->GetSystemBubble()->bubble_view()
114 : static_cast<views::View*>(system_tray);
115 ui::Event::DispatcherApi(event).set_target(target);
116 target->OnGestureEvent(event);
99 } 117 }
100 118
101 // Open the default system tray bubble to get the height of the bubble and 119 // Open the default system tray bubble to get the height of the bubble and
102 // then close it. 120 // then close it.
103 float GetSystemBubbleHeight() { 121 float GetSystemBubbleHeight() {
104 SystemTray* system_tray = GetPrimarySystemTray(); 122 SystemTray* system_tray = GetPrimarySystemTray();
105 system_tray->ShowDefaultView(BUBBLE_CREATE_NEW); 123 system_tray->ShowDefaultView(BUBBLE_CREATE_NEW);
106 gfx::Rect bounds = GetSystemBubbleBoundsInScreen(); 124 gfx::Rect bounds = GetSystemBubbleBoundsInScreen();
107 system_tray->CloseSystemBubble(); 125 system_tray->CloseSystemBubble();
108 return bounds.height(); 126 return bounds.height();
(...skipping 10 matching lines...) Expand all
119 private: 137 private:
120 DISALLOW_COPY_AND_ASSIGN(SystemTrayTest); 138 DISALLOW_COPY_AND_ASSIGN(SystemTrayTest);
121 }; 139 };
122 140
123 // Swiping on the overlap area of shelf and system tray bubble during the 141 // Swiping on the overlap area of shelf and system tray bubble during the
124 // animation should close the bubble. 142 // animation should close the bubble.
125 TEST_F(SystemTrayTest, SwipingOnShelfDuringAnimation) { 143 TEST_F(SystemTrayTest, SwipingOnShelfDuringAnimation) {
126 Shelf* shelf = GetPrimaryShelf(); 144 Shelf* shelf = GetPrimaryShelf();
127 SystemTray* system_tray = GetPrimarySystemTray(); 145 SystemTray* system_tray = GetPrimarySystemTray();
128 gfx::Point start = system_tray->GetLocalBounds().CenterPoint(); 146 gfx::Point start = system_tray->GetLocalBounds().CenterPoint();
129 shelf->SetAlignment(SHELF_ALIGNMENT_BOTTOM); 147 EXPECT_EQ(SHELF_ALIGNMENT_BOTTOM, shelf->alignment());
130 Shell::Get()->maximize_mode_controller()->EnableMaximizeModeWindowManager( 148 Shell::Get()->maximize_mode_controller()->EnableMaximizeModeWindowManager(
131 true); 149 true);
132 150
133 gfx::Rect shelf_bounds_in_screen = 151 gfx::Rect shelf_bounds_in_screen =
134 shelf->shelf_widget()->GetWindowBoundsInScreen(); 152 shelf->shelf_widget()->GetWindowBoundsInScreen();
135 153
136 system_tray->ShowDefaultView(BUBBLE_CREATE_NEW); 154 system_tray->ShowDefaultView(BUBBLE_CREATE_NEW);
137 gfx::Rect original_bounds = GetSystemBubbleBoundsInScreen(); 155 gfx::Rect original_bounds = GetSystemBubbleBoundsInScreen();
138 system_tray->CloseSystemBubble(); 156 system_tray->CloseSystemBubble();
139 157
(...skipping 16 matching lines...) Expand all
156 174
157 // Dragging the shelf during up animation should close the bubble. 175 // Dragging the shelf during up animation should close the bubble.
158 if (current_bounds.y() != original_bounds.y()) { 176 if (current_bounds.y() != original_bounds.y()) {
159 generator.GestureScrollSequence(point_on_shelf_start, point_on_shelf_end, 177 generator.GestureScrollSequence(point_on_shelf_start, point_on_shelf_end,
160 base::TimeDelta::FromMilliseconds(100), 5); 178 base::TimeDelta::FromMilliseconds(100), 5);
161 EXPECT_FALSE(system_tray->HasSystemBubble()); 179 EXPECT_FALSE(system_tray->HasSystemBubble());
162 } 180 }
163 181
164 // Fling down on the shelf with a velocity that exceeds |kFlingVelocity|. 182 // Fling down on the shelf with a velocity that exceeds |kFlingVelocity|.
165 EXPECT_FALSE(system_tray->HasSystemBubble()); 183 EXPECT_FALSE(system_tray->HasSystemBubble());
166 SendGestureEvent(start, delta, true, SystemTray::kFlingVelocity + 1); 184 SendGestureEvent(start, delta, true, TrayDragController::kFlingVelocity + 1);
167 current_bounds = GetSystemBubbleBoundsInScreen(); 185 current_bounds = GetSystemBubbleBoundsInScreen();
168 EXPECT_TRUE(system_tray->HasSystemBubble()); 186 EXPECT_TRUE(system_tray->HasSystemBubble());
169 187
170 // Dragging the shelf during down animation should close the bubble. 188 // Dragging the shelf during down animation should close the bubble.
171 if (current_bounds.y() != original_bounds.y()) { 189 if (current_bounds.y() != original_bounds.y()) {
172 generator.GestureScrollSequence(point_on_shelf_start, point_on_shelf_end, 190 generator.GestureScrollSequence(point_on_shelf_start, point_on_shelf_end,
173 base::TimeDelta::FromMilliseconds(100), 5); 191 base::TimeDelta::FromMilliseconds(100), 5);
174 EXPECT_FALSE(system_tray->HasSystemBubble()); 192 EXPECT_FALSE(system_tray->HasSystemBubble());
175 } 193 }
176 } 194 }
177 195
178 // Swiping on the system tray ends with fling event. 196 // Swiping on the system tray ends with fling event.
179 TEST_F(SystemTrayTest, FlingOnSystemTray) { 197 TEST_F(SystemTrayTest, FlingOnSystemTray) {
180 Shelf* shelf = GetPrimaryShelf(); 198 Shelf* shelf = GetPrimaryShelf();
181 SystemTray* system_tray = GetPrimarySystemTray(); 199 SystemTray* system_tray = GetPrimarySystemTray();
182 gfx::Point start = system_tray->GetBoundsInScreen().CenterPoint(); 200 gfx::Point start = system_tray->GetLocalBounds().CenterPoint();
183 shelf->SetAlignment(SHELF_ALIGNMENT_BOTTOM); 201 EXPECT_EQ(SHELF_ALIGNMENT_BOTTOM, shelf->alignment());
184 Shell::Get()->maximize_mode_controller()->EnableMaximizeModeWindowManager( 202 Shell::Get()->maximize_mode_controller()->EnableMaximizeModeWindowManager(
185 true); 203 true);
186 204
187 // Fling up on the system tray should show the bubble if the |velocity_y| is 205 // Fling up on the system tray should show the bubble if the |velocity_y| is
188 // larger than |kFlingVelocity| and the dragging amount is larger than one 206 // larger than |kFlingVelocity| and the dragging amount is larger than one
189 // third of the height of the bubble. 207 // third of the height of the bubble.
190 float delta = -GetSystemBubbleHeight(); 208 float delta = -GetSystemBubbleHeight();
191 SendGestureEvent(start, delta, true, -(SystemTray::kFlingVelocity + 1)); 209 SendGestureEvent(start, delta, true,
210 -(TrayDragController::kFlingVelocity + 1));
192 EXPECT_TRUE(system_tray->HasSystemBubble()); 211 EXPECT_TRUE(system_tray->HasSystemBubble());
193 system_tray->CloseSystemBubble(); 212 system_tray->CloseSystemBubble();
194 213
195 // Fling up on the system tray should show the bubble if the |velocity_y| is 214 // Fling up on the system tray should show the bubble if the |velocity_y| is
196 // larger than |kFlingVelocity| even the dragging amount is less than one 215 // larger than |kFlingVelocity| even the dragging amount is less than one
197 // third of the height of the bubble. 216 // third of the height of the bubble.
198 delta /= 4; 217 delta /= 4;
199 SendGestureEvent(start, delta, true, -(SystemTray::kFlingVelocity + 1)); 218 SendGestureEvent(start, delta, true,
219 -(TrayDragController::kFlingVelocity + 1));
200 EXPECT_TRUE(system_tray->HasSystemBubble()); 220 EXPECT_TRUE(system_tray->HasSystemBubble());
201 system_tray->CloseSystemBubble(); 221 system_tray->CloseSystemBubble();
202 222
203 // Fling up on the system tray should show the bubble if the |velocity_y| is 223 // Fling up on the system tray should show the bubble if the |velocity_y| is
204 // less than |kFlingVelocity| but the dragging amount if larger than one third 224 // less than |kFlingVelocity| but the dragging amount if larger than one third
205 // of the height of the bubble. 225 // of the height of the bubble.
206 delta = -GetSystemBubbleHeight(); 226 delta = -GetSystemBubbleHeight();
207 SendGestureEvent(start, delta, true, -(SystemTray::kFlingVelocity - 1)); 227 SendGestureEvent(start, delta, true,
228 -(TrayDragController::kFlingVelocity - 1));
208 EXPECT_TRUE(system_tray->HasSystemBubble()); 229 EXPECT_TRUE(system_tray->HasSystemBubble());
209 system_tray->CloseSystemBubble(); 230 system_tray->CloseSystemBubble();
210 231
211 // Fling up on the system tray should close the bubble if the |velocity_y| 232 // Fling up on the system tray should close the bubble if the |velocity_y|
212 // is less than |kFlingVelocity| and the dragging amount is less than one 233 // is less than |kFlingVelocity| and the dragging amount is less than one
213 // third of the height of the bubble. 234 // third of the height of the bubble.
214 delta /= 4; 235 delta /= 4;
215 SendGestureEvent(start, delta, true, -(SystemTray::kFlingVelocity - 1)); 236 SendGestureEvent(start, delta, true,
237 -(TrayDragController::kFlingVelocity - 1));
216 EXPECT_FALSE(system_tray->HasSystemBubble()); 238 EXPECT_FALSE(system_tray->HasSystemBubble());
217 239
218 // Fling down on the system tray should close the bubble if the |velocity_y| 240 // Fling down on the system tray should close the bubble if the |velocity_y|
219 // is larger than kFLingVelocity. 241 // is larger than kFLingVelocity.
220 SendGestureEvent(start, delta, true, SystemTray::kFlingVelocity + 1); 242 SendGestureEvent(start, delta, true, TrayDragController::kFlingVelocity + 1);
221 EXPECT_FALSE(system_tray->HasSystemBubble()); 243 EXPECT_FALSE(system_tray->HasSystemBubble());
222 244
223 // Fling down on the system tray should close the bubble if the |velocity_y| 245 // Fling down on the system tray should close the bubble if the |velocity_y|
224 // is larger than |kFlingVelocity| even the dragging amount is larger than one 246 // is larger than |kFlingVelocity| even the dragging amount is larger than one
225 // third of the height of the bubble. 247 // third of the height of the bubble.
226 delta = -GetSystemBubbleHeight(); 248 delta = -GetSystemBubbleHeight();
227 SendGestureEvent(start, delta, true, SystemTray::kFlingVelocity + 1); 249 SendGestureEvent(start, delta, true, TrayDragController::kFlingVelocity + 1);
228 EXPECT_FALSE(system_tray->HasSystemBubble()); 250 EXPECT_FALSE(system_tray->HasSystemBubble());
229 251
230 // Fling down on the system tray should open the bubble if the |velocity_y| is 252 // Fling down on the system tray should open the bubble if the |velocity_y| is
231 // less than |kFlingVelocity| but the dragging amount exceed one third of the 253 // less than |kFlingVelocity| but the dragging amount exceed one third of the
232 // height of the bubble. 254 // height of the bubble.
233 SendGestureEvent(start, delta, true, SystemTray::kFlingVelocity - 1); 255 SendGestureEvent(start, delta, true, TrayDragController::kFlingVelocity - 1);
234 EXPECT_TRUE(system_tray->HasSystemBubble()); 256 EXPECT_TRUE(system_tray->HasSystemBubble());
235 system_tray->CloseSystemBubble(); 257 system_tray->CloseSystemBubble();
236 258
237 // Fling down on the system tray should close the bubble if the |velocity_y| 259 // Fling down on the system tray should close the bubble if the |velocity_y|
238 // is less than |kFlingVelocity| and the dragging amount is less than one 260 // is less than |kFlingVelocity| and the dragging amount is less than one
239 // third of the height of the bubble. 261 // third of the height of the bubble.
240 delta /= 4; 262 delta /= 4;
241 SendGestureEvent(start, delta, true, SystemTray::kFlingVelocity - 1); 263 SendGestureEvent(start, delta, true, TrayDragController::kFlingVelocity - 1);
242 EXPECT_FALSE(system_tray->HasSystemBubble()); 264 EXPECT_FALSE(system_tray->HasSystemBubble());
243 } 265 }
244 266
245 // Touch outside the system tray bubble during swiping should close the bubble. 267 // Touch outside the system tray bubble during swiping should close the bubble.
246 TEST_F(SystemTrayTest, TapOutsideCloseBubble) { 268 TEST_F(SystemTrayTest, TapOutsideCloseBubble) {
247 Shelf* shelf = GetPrimaryShelf(); 269 Shelf* shelf = GetPrimaryShelf();
248 SystemTray* system_tray = GetPrimarySystemTray(); 270 SystemTray* system_tray = GetPrimarySystemTray();
249 gfx::Point start = system_tray->GetLocalBounds().CenterPoint(); 271 gfx::Point start = system_tray->GetLocalBounds().CenterPoint();
250 shelf->SetAlignment(SHELF_ALIGNMENT_BOTTOM); 272 EXPECT_EQ(SHELF_ALIGNMENT_BOTTOM, shelf->alignment());
251 273
252 float delta = -GetSystemBubbleHeight(); 274 float delta = -GetSystemBubbleHeight();
253 Shell::Get()->maximize_mode_controller()->EnableMaximizeModeWindowManager( 275 Shell::Get()->maximize_mode_controller()->EnableMaximizeModeWindowManager(
254 true); 276 true);
255 base::TimeTicks timestamp = base::TimeTicks::Now(); 277 base::TimeTicks timestamp = base::TimeTicks::Now();
256 SendScrollStartAndUpdate(start, delta, timestamp); 278 SendScrollStartAndUpdate(start, delta, timestamp);
257 EXPECT_TRUE(system_tray->HasSystemBubble()); 279 EXPECT_TRUE(system_tray->HasSystemBubble());
258 280
259 ui::test::EventGenerator& generator = GetEventGenerator(); 281 ui::test::EventGenerator& generator = GetEventGenerator();
260 gfx::Rect bounds = GetSystemBubbleBoundsInScreen(); 282 gfx::Rect bounds = GetSystemBubbleBoundsInScreen();
261 gfx::Point point_outside = gfx::Point(bounds.x() - 5, bounds.y() - 5); 283 gfx::Point point_outside = gfx::Point(bounds.x() - 5, bounds.y() - 5);
262 generator.GestureTapAt(point_outside); 284 generator.GestureTapAt(point_outside);
263 EXPECT_FALSE(system_tray->HasSystemBubble()); 285 EXPECT_FALSE(system_tray->HasSystemBubble());
264 } 286 }
265 287
266 // Swiping on the system tray ends with scroll event. 288 // Swiping on the system tray ends with scroll event.
267 TEST_F(SystemTrayTest, SwipingOnSystemTray) { 289 TEST_F(SystemTrayTest, SwipingOnSystemTray) {
268 Shelf* shelf = GetPrimaryShelf(); 290 Shelf* shelf = GetPrimaryShelf();
269 SystemTray* system_tray = GetPrimarySystemTray(); 291 SystemTray* system_tray = GetPrimarySystemTray();
270 gfx::Point start = system_tray->GetLocalBounds().CenterPoint(); 292 gfx::Point start = system_tray->GetLocalBounds().CenterPoint();
271 shelf->SetAlignment(SHELF_ALIGNMENT_BOTTOM); 293 EXPECT_EQ(SHELF_ALIGNMENT_BOTTOM, shelf->alignment());
272 294
273 // Swiping up on the system tray has no effect if it is not in maximize mode. 295 // Swiping up on the system tray has no effect if it is not in maximize mode.
274 float delta = -GetSystemBubbleHeight(); 296 float delta = -GetSystemBubbleHeight();
275 Shell::Get()->maximize_mode_controller()->EnableMaximizeModeWindowManager( 297 Shell::Get()->maximize_mode_controller()->EnableMaximizeModeWindowManager(
276 false); 298 false);
277 EXPECT_FALSE(system_tray->HasSystemBubble()); 299 EXPECT_FALSE(system_tray->HasSystemBubble());
278 SendGestureEvent(start, delta, false, 0); 300 SendGestureEvent(start, delta, false, 0);
279 EXPECT_FALSE(system_tray->HasSystemBubble()); 301 EXPECT_FALSE(system_tray->HasSystemBubble());
280 302
281 // Swiping up on the system tray should show the system tray bubble if it is 303 // Swiping up on the system tray should show the system tray bubble if it is
(...skipping 23 matching lines...) Expand all
305 shelf->SetAlignment(SHELF_ALIGNMENT_LEFT); 327 shelf->SetAlignment(SHELF_ALIGNMENT_LEFT);
306 SendGestureEvent(start, delta, false, 0); 328 SendGestureEvent(start, delta, false, 0);
307 EXPECT_FALSE(system_tray->HasSystemBubble()); 329 EXPECT_FALSE(system_tray->HasSystemBubble());
308 330
309 // Swiping up on system tray should not show the system tray bubble if the 331 // Swiping up on system tray should not show the system tray bubble if the
310 // shelf is right alignment. 332 // shelf is right alignment.
311 shelf->SetAlignment(SHELF_ALIGNMENT_RIGHT); 333 shelf->SetAlignment(SHELF_ALIGNMENT_RIGHT);
312 SendGestureEvent(start, delta, false, 0); 334 SendGestureEvent(start, delta, false, 0);
313 EXPECT_FALSE(system_tray->HasSystemBubble()); 335 EXPECT_FALSE(system_tray->HasSystemBubble());
314 336
315 // Swiping down on the shelf should not show the system tray bubble. 337 // Beginning to scroll downward on the shelf should not show the system tray
338 // bubble, even if the drag then moves upwards.
316 shelf->SetAlignment(SHELF_ALIGNMENT_BOTTOM); 339 shelf->SetAlignment(SHELF_ALIGNMENT_BOTTOM);
317 delta = -delta; 340 SendGestureEvent(start, delta, false, 0, 1);
318 SendGestureEvent(start, delta, false, 0);
319 EXPECT_FALSE(system_tray->HasSystemBubble()); 341 EXPECT_FALSE(system_tray->HasSystemBubble());
320 } 342 }
321 343
344 // Tests for swiping down on an open system tray bubble in order to
345 // close it.
346 TEST_F(SystemTrayTest, SwipingOnSystemTrayBubble) {
347 Shelf* shelf = GetPrimaryShelf();
348 SystemTray* system_tray = GetPrimarySystemTray();
349 EXPECT_EQ(SHELF_ALIGNMENT_BOTTOM, shelf->alignment());
350
351 // Beginning to scroll downward and then swiping down more than one third of
352 // the bubble's height should close the bubble. This only takes effect in
353 // maximize mode.
354 Shell::Get()->maximize_mode_controller()->EnableMaximizeModeWindowManager(
355 true);
356 system_tray->ShowDefaultView(BUBBLE_CREATE_NEW);
357 gfx::Rect bounds =
358 system_tray->GetSystemBubble()->bubble_view()->GetLocalBounds();
359 float delta = bounds.height() / 2;
360 gfx::Point start(bounds.x() + 5, bounds.y() + 5);
361 SendGestureEvent(start, delta, false, 0, 1, true);
362 EXPECT_FALSE(system_tray->HasSystemBubble());
363
364 // Beginning to scroll upward and then swiping down more than one third of the
365 // bubble's height should also close the bubble.
366 system_tray->ShowDefaultView(BUBBLE_CREATE_NEW);
367 SendGestureEvent(start, delta, false, 0, -1, true);
368 EXPECT_FALSE(system_tray->HasSystemBubble());
369
370 // Swiping on the bubble has no effect if it is not in maximize mode.
371 Shell::Get()->maximize_mode_controller()->EnableMaximizeModeWindowManager(
372 false);
373 system_tray->ShowDefaultView(BUBBLE_CREATE_NEW);
374 SendGestureEvent(start, delta, false, 0, -1, true);
375 EXPECT_TRUE(system_tray->HasSystemBubble());
376 }
377
322 // Verifies only the visible default views are recorded in the 378 // Verifies only the visible default views are recorded in the
323 // "Ash.SystemMenu.DefaultView.VisibleItems" histogram. 379 // "Ash.SystemMenu.DefaultView.VisibleItems" histogram.
324 TEST_F(SystemTrayTest, OnlyVisibleItemsRecorded) { 380 TEST_F(SystemTrayTest, OnlyVisibleItemsRecorded) {
325 SystemTray* tray = GetPrimarySystemTray(); 381 SystemTray* tray = GetPrimarySystemTray();
326 ASSERT_TRUE(tray->GetWidget()); 382 ASSERT_TRUE(tray->GetWidget());
327 383
328 TestSystemTrayItem* test_item = new TestSystemTrayItem(); 384 TestSystemTrayItem* test_item = new TestSystemTrayItem();
329 tray->AddTrayItem(base::WrapUnique(test_item)); 385 tray->AddTrayItem(base::WrapUnique(test_item));
330 386
331 base::HistogramTester histogram_tester; 387 base::HistogramTester histogram_tester;
(...skipping 514 matching lines...) Expand 10 before | Expand all | Expand 10 after
846 RunAllPendingInMessageLoop(); 902 RunAllPendingInMessageLoop();
847 903
848 EXPECT_EQ(0, notification_tray->tray_bubble_height_for_test()); 904 EXPECT_EQ(0, notification_tray->tray_bubble_height_for_test());
849 } 905 }
850 906
851 TEST_F(SystemTrayTest, SeparatorThickness) { 907 TEST_F(SystemTrayTest, SeparatorThickness) {
852 EXPECT_EQ(kSeparatorWidth, views::Separator::kThickness); 908 EXPECT_EQ(kSeparatorWidth, views::Separator::kThickness);
853 } 909 }
854 910
855 } // namespace ash 911 } // namespace ash
OLDNEW
« no previous file with comments | « ash/system/tray/system_tray_bubble.cc ('k') | ash/system/tray/tray_background_view.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698