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

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

Issue 2961313003: Touch gestures for System Tray/ IME/ Stylus/ Notifications (Closed)
Patch Set: 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
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"
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
59 } // namespace 59 } // namespace
60 60
61 class SystemTrayTest : public AshTestBase { 61 class SystemTrayTest : public AshTestBase {
62 public: 62 public:
63 SystemTrayTest() {} 63 SystemTrayTest() {}
64 ~SystemTrayTest() override {} 64 ~SystemTrayTest() override {}
65 65
66 // Swiping on the system tray and ends with finger released. 66 // Swiping on the system tray and ends with finger released.
67 void SendGestureEvent(gfx::Point& start, 67 void SendGestureEvent(gfx::Point& start,
68 float delta, 68 float delta,
69 float begin_scroll_y_hint,
69 bool is_fling, 70 bool is_fling,
70 float velocity_y) { 71 float velocity_y,
72 bool is_on_bubble) {
sammiequon 2017/06/29 21:28:19 what happens when |is_on_bubble| is true but |star
minch1 2017/06/30 17:02:30 Since |start| can be point on the system tray, els
sammiequon 2017/06/30 17:46:02 Acknowledged.
71 SystemTray* system_tray = GetPrimarySystemTray(); 73 SystemTray* system_tray = GetPrimarySystemTray();
72 base::TimeTicks timestamp = base::TimeTicks::Now(); 74 base::TimeTicks timestamp = base::TimeTicks::Now();
73 SendScrollStartAndUpdate(start, delta, timestamp); 75 SendScrollStartAndUpdate(start, delta, begin_scroll_y_hint, timestamp,
sammiequon 2017/06/29 21:28:19 AFAICT, |velocity_y| tells the direction as well?
minch1 2017/06/30 17:02:30 I think the |velocity_y| is only for fling event?
sammiequon 2017/06/30 17:46:02 Acknowledged.
76 is_on_bubble);
74 77
75 ui::GestureEventDetails details = 78 ui::GestureEventDetails details =
76 is_fling 79 is_fling
77 ? ui::GestureEventDetails(ui::ET_SCROLL_FLING_START, 0, velocity_y) 80 ? ui::GestureEventDetails(ui::ET_SCROLL_FLING_START, 0, velocity_y)
78 : ui::GestureEventDetails(ui::ET_GESTURE_SCROLL_END); 81 : ui::GestureEventDetails(ui::ET_GESTURE_SCROLL_END);
79 ui::GestureEvent event = ui::GestureEvent(start.x(), start.y() + delta, 82 ui::GestureEvent event = ui::GestureEvent(start.x(), start.y() + delta,
80 ui::EF_NONE, timestamp, details); 83 ui::EF_NONE, timestamp, details);
81 system_tray->OnGestureEvent(&event); 84 if (is_on_bubble) {
85 system_tray->ProcessGestureEventOnBubbleView(
86 &event, system_tray->GetSystemBubble()->bubble_view());
87 } else {
88 system_tray->OnGestureEvent(&event);
89 }
82 } 90 }
83 91
84 // Swiping on the system tray without releasing the finger. 92 // Swiping on the system tray without releasing the finger.
85 void SendScrollStartAndUpdate(gfx::Point& start, 93 void SendScrollStartAndUpdate(gfx::Point& start,
86 float delta, 94 float delta,
87 base::TimeTicks& timestamp) { 95 float begin_scroll_y_hint,
96 base::TimeTicks& timestamp,
97 bool is_on_bubble) {
88 SystemTray* system_tray = GetPrimarySystemTray(); 98 SystemTray* system_tray = GetPrimarySystemTray();
89 ui::GestureEventDetails begin_details(ui::ET_GESTURE_SCROLL_BEGIN); 99 ui::GestureEventDetails begin_details(ui::ET_GESTURE_SCROLL_BEGIN, 0,
100 begin_scroll_y_hint);
90 ui::GestureEvent begin_event = ui::GestureEvent( 101 ui::GestureEvent begin_event = ui::GestureEvent(
91 start.x(), start.y(), ui::EF_NONE, timestamp, begin_details); 102 start.x(), start.y(), ui::EF_NONE, timestamp, begin_details);
92 system_tray->OnGestureEvent(&begin_event); 103
104 if (is_on_bubble) {
105 system_tray->ProcessGestureEventOnBubbleView(
106 &begin_event, system_tray->GetSystemBubble()->bubble_view());
107 } else {
108 system_tray->OnGestureEvent(&begin_event);
109 }
93 110
94 ui::GestureEventDetails update_details(ui::ET_GESTURE_SCROLL_UPDATE, 0, 111 ui::GestureEventDetails update_details(ui::ET_GESTURE_SCROLL_UPDATE, 0,
95 delta); 112 delta);
96 timestamp += base::TimeDelta::FromMilliseconds(100); 113 timestamp += base::TimeDelta::FromMilliseconds(100);
97 ui::GestureEvent update_event = ui::GestureEvent( 114 ui::GestureEvent update_event = ui::GestureEvent(
98 start.x(), start.y() + delta, ui::EF_NONE, timestamp, update_details); 115 start.x(), start.y() + delta, ui::EF_NONE, timestamp, update_details);
99 system_tray->OnGestureEvent(&update_event); 116
117 if (is_on_bubble) {
118 system_tray->ProcessGestureEventOnBubbleView(
119 &update_event, system_tray->GetSystemBubble()->bubble_view());
120 } else {
121 system_tray->OnGestureEvent(&update_event);
122 }
100 } 123 }
101 124
102 // Open the default system tray bubble to get the height of the bubble and 125 // Open the default system tray bubble to get the height of the bubble and
103 // then close it. 126 // then close it.
104 float GetSystemBubbleHeight() { 127 float GetSystemBubbleHeight() {
105 SystemTray* system_tray = GetPrimarySystemTray(); 128 SystemTray* system_tray = GetPrimarySystemTray();
106 system_tray->ShowDefaultView(BUBBLE_CREATE_NEW); 129 system_tray->ShowDefaultView(BUBBLE_CREATE_NEW);
107 gfx::Rect bounds = GetSystemBubbleBoundsInScreen(); 130 gfx::Rect bounds = GetSystemBubbleBoundsInScreen();
108 system_tray->CloseSystemBubble(); 131 system_tray->CloseSystemBubble();
109 return bounds.height(); 132 return bounds.height();
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
144 167
145 ui::test::EventGenerator& generator = GetEventGenerator(); 168 ui::test::EventGenerator& generator = GetEventGenerator();
146 gfx::Point point_on_shelf_start = 169 gfx::Point point_on_shelf_start =
147 gfx::Point(original_bounds.x() + 5, shelf_bounds_in_screen.y() + 5); 170 gfx::Point(original_bounds.x() + 5, shelf_bounds_in_screen.y() + 5);
148 gfx::Point point_on_shelf_end(point_on_shelf_start.x(), 171 gfx::Point point_on_shelf_end(point_on_shelf_start.x(),
149 shelf_bounds_in_screen.bottom()); 172 shelf_bounds_in_screen.bottom());
150 173
151 // Swiping up exceed one third of the height of the bubble should show the 174 // Swiping up exceed one third of the height of the bubble should show the
152 // bubble. 175 // bubble.
153 float delta = -original_bounds.height() / 2; 176 float delta = -original_bounds.height() / 2;
154 SendGestureEvent(start, delta, false, 0); 177 SendGestureEvent(start, delta, -1, false, 0, false);
155 EXPECT_TRUE(system_tray->HasSystemBubble()); 178 EXPECT_TRUE(system_tray->HasSystemBubble());
156 gfx::Rect current_bounds = GetSystemBubbleBoundsInScreen(); 179 gfx::Rect current_bounds = GetSystemBubbleBoundsInScreen();
157 180
158 // Dragging the shelf during up animation should close the bubble. 181 // Dragging the shelf during up animation should close the bubble.
159 if (current_bounds.y() != original_bounds.y()) { 182 if (current_bounds.y() != original_bounds.y()) {
160 generator.GestureScrollSequence(point_on_shelf_start, point_on_shelf_end, 183 generator.GestureScrollSequence(point_on_shelf_start, point_on_shelf_end,
161 base::TimeDelta::FromMilliseconds(100), 5); 184 base::TimeDelta::FromMilliseconds(100), 5);
162 EXPECT_FALSE(system_tray->HasSystemBubble()); 185 EXPECT_FALSE(system_tray->HasSystemBubble());
163 } 186 }
164 187
165 // Fling down on the shelf with a velocity that exceeds |kFlingVelocity|. 188 // Fling down on the shelf with a velocity that exceeds |kFlingVelocity|.
166 EXPECT_FALSE(system_tray->HasSystemBubble()); 189 EXPECT_FALSE(system_tray->HasSystemBubble());
167 SendGestureEvent(start, delta, true, SystemTray::kFlingVelocity + 1); 190 SendGestureEvent(start, delta, -1, true, SystemTray::kFlingVelocity + 1,
191 false);
168 current_bounds = GetSystemBubbleBoundsInScreen(); 192 current_bounds = GetSystemBubbleBoundsInScreen();
169 EXPECT_TRUE(system_tray->HasSystemBubble()); 193 EXPECT_TRUE(system_tray->HasSystemBubble());
170 194
171 // Dragging the shelf during down animation should close the bubble. 195 // Dragging the shelf during down animation should close the bubble.
172 if (current_bounds.y() != original_bounds.y()) { 196 if (current_bounds.y() != original_bounds.y()) {
173 generator.GestureScrollSequence(point_on_shelf_start, point_on_shelf_end, 197 generator.GestureScrollSequence(point_on_shelf_start, point_on_shelf_end,
174 base::TimeDelta::FromMilliseconds(100), 5); 198 base::TimeDelta::FromMilliseconds(100), 5);
175 EXPECT_FALSE(system_tray->HasSystemBubble()); 199 EXPECT_FALSE(system_tray->HasSystemBubble());
176 } 200 }
177 } 201 }
178 202
179 // Swiping on the system tray ends with fling event. 203 // Swiping on the system tray ends with fling event.
180 TEST_F(SystemTrayTest, FlingOnSystemTray) { 204 TEST_F(SystemTrayTest, FlingOnSystemTray) {
181 Shelf* shelf = GetPrimaryShelf(); 205 Shelf* shelf = GetPrimaryShelf();
182 SystemTray* system_tray = GetPrimarySystemTray(); 206 SystemTray* system_tray = GetPrimarySystemTray();
183 gfx::Point start = system_tray->GetBoundsInScreen().CenterPoint(); 207 gfx::Point start = system_tray->GetBoundsInScreen().CenterPoint();
184 shelf->SetAlignment(SHELF_ALIGNMENT_BOTTOM); 208 shelf->SetAlignment(SHELF_ALIGNMENT_BOTTOM);
185 Shell::Get()->maximize_mode_controller()->EnableMaximizeModeWindowManager( 209 Shell::Get()->maximize_mode_controller()->EnableMaximizeModeWindowManager(
186 true); 210 true);
187 211
188 // Fling up on the system tray should show the bubble if the |velocity_y| is 212 // Fling up on the system tray should show the bubble if the |velocity_y| is
189 // larger than |kFlingVelocity| and the dragging amount is larger than one 213 // larger than |kFlingVelocity| and the dragging amount is larger than one
190 // third of the height of the bubble. 214 // third of the height of the bubble.
191 float delta = -GetSystemBubbleHeight(); 215 float delta = -GetSystemBubbleHeight();
192 SendGestureEvent(start, delta, true, -(SystemTray::kFlingVelocity + 1)); 216 SendGestureEvent(start, delta, -1, true, -(SystemTray::kFlingVelocity + 1),
217 false);
193 EXPECT_TRUE(system_tray->HasSystemBubble()); 218 EXPECT_TRUE(system_tray->HasSystemBubble());
194 system_tray->CloseSystemBubble(); 219 system_tray->CloseSystemBubble();
195 220
196 // Fling up on the system tray should show the bubble if the |velocity_y| is 221 // Fling up on the system tray should show the bubble if the |velocity_y| is
197 // larger than |kFlingVelocity| even the dragging amount is less than one 222 // larger than |kFlingVelocity| even the dragging amount is less than one
198 // third of the height of the bubble. 223 // third of the height of the bubble.
199 delta /= 4; 224 delta /= 4;
200 SendGestureEvent(start, delta, true, -(SystemTray::kFlingVelocity + 1)); 225 SendGestureEvent(start, delta, -1, true, -(SystemTray::kFlingVelocity + 1),
226 false);
201 EXPECT_TRUE(system_tray->HasSystemBubble()); 227 EXPECT_TRUE(system_tray->HasSystemBubble());
202 system_tray->CloseSystemBubble(); 228 system_tray->CloseSystemBubble();
203 229
204 // Fling up on the system tray should show the bubble if the |velocity_y| is 230 // Fling up on the system tray should show the bubble if the |velocity_y| is
205 // less than |kFlingVelocity| but the dragging amount if larger than one third 231 // less than |kFlingVelocity| but the dragging amount if larger than one third
206 // of the height of the bubble. 232 // of the height of the bubble.
207 delta = -GetSystemBubbleHeight(); 233 delta = -GetSystemBubbleHeight();
208 SendGestureEvent(start, delta, true, -(SystemTray::kFlingVelocity - 1)); 234 SendGestureEvent(start, delta, -1, true, -(SystemTray::kFlingVelocity - 1),
235 false);
209 EXPECT_TRUE(system_tray->HasSystemBubble()); 236 EXPECT_TRUE(system_tray->HasSystemBubble());
210 system_tray->CloseSystemBubble(); 237 system_tray->CloseSystemBubble();
211 238
212 // Fling up on the system tray should close the bubble if the |velocity_y| 239 // Fling up on the system tray should close the bubble if the |velocity_y|
213 // is less than |kFlingVelocity| and the dragging amount is less than one 240 // is less than |kFlingVelocity| and the dragging amount is less than one
214 // third of the height of the bubble. 241 // third of the height of the bubble.
215 delta /= 4; 242 delta /= 4;
216 SendGestureEvent(start, delta, true, -(SystemTray::kFlingVelocity - 1)); 243 SendGestureEvent(start, delta, -1, true, -(SystemTray::kFlingVelocity - 1),
244 false);
217 EXPECT_FALSE(system_tray->HasSystemBubble()); 245 EXPECT_FALSE(system_tray->HasSystemBubble());
218 246
219 // Fling down on the system tray should close the bubble if the |velocity_y| 247 // Fling down on the system tray should close the bubble if the |velocity_y|
220 // is larger than kFLingVelocity. 248 // is larger than kFLingVelocity.
221 SendGestureEvent(start, delta, true, SystemTray::kFlingVelocity + 1); 249 SendGestureEvent(start, delta, -1, true, SystemTray::kFlingVelocity + 1,
250 false);
222 EXPECT_FALSE(system_tray->HasSystemBubble()); 251 EXPECT_FALSE(system_tray->HasSystemBubble());
223 252
224 // Fling down on the system tray should close the bubble if the |velocity_y| 253 // Fling down on the system tray should close the bubble if the |velocity_y|
225 // is larger than |kFlingVelocity| even the dragging amount is larger than one 254 // is larger than |kFlingVelocity| even the dragging amount is larger than one
226 // third of the height of the bubble. 255 // third of the height of the bubble.
227 delta = -GetSystemBubbleHeight(); 256 delta = -GetSystemBubbleHeight();
228 SendGestureEvent(start, delta, true, SystemTray::kFlingVelocity + 1); 257 SendGestureEvent(start, delta, -1, true, SystemTray::kFlingVelocity + 1,
258 false);
229 EXPECT_FALSE(system_tray->HasSystemBubble()); 259 EXPECT_FALSE(system_tray->HasSystemBubble());
230 260
231 // Fling down on the system tray should open the bubble if the |velocity_y| is 261 // Fling down on the system tray should open the bubble if the |velocity_y| is
232 // less than |kFlingVelocity| but the dragging amount exceed one third of the 262 // less than |kFlingVelocity| but the dragging amount exceed one third of the
233 // height of the bubble. 263 // height of the bubble.
234 SendGestureEvent(start, delta, true, SystemTray::kFlingVelocity - 1); 264 SendGestureEvent(start, delta, -1, true, SystemTray::kFlingVelocity - 1,
265 false);
235 EXPECT_TRUE(system_tray->HasSystemBubble()); 266 EXPECT_TRUE(system_tray->HasSystemBubble());
236 system_tray->CloseSystemBubble(); 267 system_tray->CloseSystemBubble();
237 268
238 // Fling down on the system tray should close the bubble if the |velocity_y| 269 // Fling down on the system tray should close the bubble if the |velocity_y|
239 // is less than |kFlingVelocity| and the dragging amount is less than one 270 // is less than |kFlingVelocity| and the dragging amount is less than one
240 // third of the height of the bubble. 271 // third of the height of the bubble.
241 delta /= 4; 272 delta /= 4;
242 SendGestureEvent(start, delta, true, SystemTray::kFlingVelocity - 1); 273 SendGestureEvent(start, delta, -1, true, SystemTray::kFlingVelocity - 1,
274 false);
243 EXPECT_FALSE(system_tray->HasSystemBubble()); 275 EXPECT_FALSE(system_tray->HasSystemBubble());
244 } 276 }
245 277
246 // Touch outside the system tray bubble during swiping should close the bubble. 278 // Touch outside the system tray bubble during swiping should close the bubble.
247 TEST_F(SystemTrayTest, TapOutsideCloseBubble) { 279 TEST_F(SystemTrayTest, TapOutsideCloseBubble) {
248 Shelf* shelf = GetPrimaryShelf(); 280 Shelf* shelf = GetPrimaryShelf();
249 SystemTray* system_tray = GetPrimarySystemTray(); 281 SystemTray* system_tray = GetPrimarySystemTray();
250 gfx::Point start = system_tray->GetLocalBounds().CenterPoint(); 282 gfx::Point start = system_tray->GetLocalBounds().CenterPoint();
251 shelf->SetAlignment(SHELF_ALIGNMENT_BOTTOM); 283 shelf->SetAlignment(SHELF_ALIGNMENT_BOTTOM);
252 284
253 float delta = -GetSystemBubbleHeight(); 285 float delta = -GetSystemBubbleHeight();
254 Shell::Get()->maximize_mode_controller()->EnableMaximizeModeWindowManager( 286 Shell::Get()->maximize_mode_controller()->EnableMaximizeModeWindowManager(
255 true); 287 true);
256 base::TimeTicks timestamp = base::TimeTicks::Now(); 288 base::TimeTicks timestamp = base::TimeTicks::Now();
257 SendScrollStartAndUpdate(start, delta, timestamp); 289 SendScrollStartAndUpdate(start, delta, -1, timestamp, false);
258 EXPECT_TRUE(system_tray->HasSystemBubble()); 290 EXPECT_TRUE(system_tray->HasSystemBubble());
259 291
260 ui::test::EventGenerator& generator = GetEventGenerator(); 292 ui::test::EventGenerator& generator = GetEventGenerator();
261 gfx::Rect bounds = GetSystemBubbleBoundsInScreen(); 293 gfx::Rect bounds = GetSystemBubbleBoundsInScreen();
262 gfx::Point point_outside = gfx::Point(bounds.x() - 5, bounds.y() - 5); 294 gfx::Point point_outside = gfx::Point(bounds.x() - 5, bounds.y() - 5);
263 generator.GestureTapAt(point_outside); 295 generator.GestureTapAt(point_outside);
264 EXPECT_FALSE(system_tray->HasSystemBubble()); 296 EXPECT_FALSE(system_tray->HasSystemBubble());
265 } 297 }
266 298
267 // Swiping on the system tray ends with scroll event. 299 // Swiping on the system tray ends with scroll event.
268 TEST_F(SystemTrayTest, SwipingOnSystemTray) { 300 TEST_F(SystemTrayTest, SwipingOnSystemTray) {
269 Shelf* shelf = GetPrimaryShelf(); 301 Shelf* shelf = GetPrimaryShelf();
270 SystemTray* system_tray = GetPrimarySystemTray(); 302 SystemTray* system_tray = GetPrimarySystemTray();
271 gfx::Point start = system_tray->GetLocalBounds().CenterPoint(); 303 gfx::Point start = system_tray->GetLocalBounds().CenterPoint();
272 shelf->SetAlignment(SHELF_ALIGNMENT_BOTTOM); 304 shelf->SetAlignment(SHELF_ALIGNMENT_BOTTOM);
273 305
274 // Swiping up on the system tray has no effect if it is not in maximize mode. 306 // Swiping up on the system tray has no effect if it is not in maximize mode.
275 float delta = -GetSystemBubbleHeight(); 307 float delta = -GetSystemBubbleHeight();
276 Shell::Get()->maximize_mode_controller()->EnableMaximizeModeWindowManager( 308 Shell::Get()->maximize_mode_controller()->EnableMaximizeModeWindowManager(
277 false); 309 false);
278 EXPECT_FALSE(system_tray->HasSystemBubble()); 310 EXPECT_FALSE(system_tray->HasSystemBubble());
279 SendGestureEvent(start, delta, false, 0); 311 SendGestureEvent(start, delta, -1, false, 0, false);
280 EXPECT_FALSE(system_tray->HasSystemBubble()); 312 EXPECT_FALSE(system_tray->HasSystemBubble());
281 313
282 // Swiping up on the system tray should show the system tray bubble if it is 314 // Swiping up on the system tray should show the system tray bubble if it is
283 // in maximize mode. 315 // in maximize mode.
284 Shell::Get()->maximize_mode_controller()->EnableMaximizeModeWindowManager( 316 Shell::Get()->maximize_mode_controller()->EnableMaximizeModeWindowManager(
285 true); 317 true);
286 SendGestureEvent(start, delta, false, 0); 318 SendGestureEvent(start, delta, -1, false, 0, false);
287 EXPECT_TRUE(system_tray->HasSystemBubble()); 319 EXPECT_TRUE(system_tray->HasSystemBubble());
288 system_tray->CloseSystemBubble(); 320 system_tray->CloseSystemBubble();
289 321
290 // Swiping up less than one third of the bubble's height should not show the 322 // Swiping up less than one third of the bubble's height should not show the
291 // bubble. 323 // bubble.
292 delta /= 4; 324 delta /= 4;
293 SendGestureEvent(start, delta, false, 0); 325 SendGestureEvent(start, delta, -1, false, 0, false);
294 EXPECT_FALSE(system_tray->HasSystemBubble()); 326 EXPECT_FALSE(system_tray->HasSystemBubble());
295 327
296 // Swiping up more than one third of the bubble's height should show the 328 // Swiping up more than one third of the bubble's height should show the
297 // bubble. 329 // bubble.
298 delta = -GetSystemBubbleHeight() / 2; 330 delta = -GetSystemBubbleHeight() / 2;
299 SendGestureEvent(start, delta, false, 0); 331 SendGestureEvent(start, delta, -1, false, 0, false);
300 EXPECT_TRUE(system_tray->HasSystemBubble()); 332 EXPECT_TRUE(system_tray->HasSystemBubble());
301 system_tray->CloseSystemBubble(); 333 system_tray->CloseSystemBubble();
302 334
303 // Swiping up on system tray should not show the system tray bubble if the 335 // Swiping up on system tray should not show the system tray bubble if the
304 // shelf is left alignment. 336 // shelf is left alignment.
305 delta = -GetSystemBubbleHeight(); 337 delta = -GetSystemBubbleHeight();
306 shelf->SetAlignment(SHELF_ALIGNMENT_LEFT); 338 shelf->SetAlignment(SHELF_ALIGNMENT_LEFT);
307 SendGestureEvent(start, delta, false, 0); 339 SendGestureEvent(start, delta, -1, false, 0, false);
308 EXPECT_FALSE(system_tray->HasSystemBubble()); 340 EXPECT_FALSE(system_tray->HasSystemBubble());
309 341
310 // Swiping up on system tray should not show the system tray bubble if the 342 // Swiping up on system tray should not show the system tray bubble if the
311 // shelf is right alignment. 343 // shelf is right alignment.
312 shelf->SetAlignment(SHELF_ALIGNMENT_RIGHT); 344 shelf->SetAlignment(SHELF_ALIGNMENT_RIGHT);
313 SendGestureEvent(start, delta, false, 0); 345 SendGestureEvent(start, delta, -1, false, 0, false);
314 EXPECT_FALSE(system_tray->HasSystemBubble()); 346 EXPECT_FALSE(system_tray->HasSystemBubble());
315 347
316 // Swiping down on the shelf should not show the system tray bubble. 348 // Begins to scroll downward on the shelf should not show the system tray
349 // bubble.
317 shelf->SetAlignment(SHELF_ALIGNMENT_BOTTOM); 350 shelf->SetAlignment(SHELF_ALIGNMENT_BOTTOM);
318 delta = -delta; 351 SendGestureEvent(start, delta, 1, false, 0, false);
319 SendGestureEvent(start, delta, false, 0);
320 EXPECT_FALSE(system_tray->HasSystemBubble()); 352 EXPECT_FALSE(system_tray->HasSystemBubble());
321 } 353 }
322 354
355 // Swiping on opened system tray bubble.
356 TEST_F(SystemTrayTest, SwipingOnSystemTrayBubble) {
357 Shelf* shelf = GetPrimaryShelf();
358 SystemTray* system_tray = GetPrimarySystemTray();
359 shelf->SetAlignment(SHELF_ALIGNMENT_BOTTOM);
360 Shell::Get()->maximize_mode_controller()->EnableMaximizeModeWindowManager(
361 true);
362
363 // Begins to scroll downward and swiping down more than one third of the
364 // bubble's height should close the bubble.
365 system_tray->ShowDefaultView(BUBBLE_CREATE_NEW);
366 gfx::Rect bounds =
367 system_tray->GetSystemBubble()->bubble_view()->GetLocalBounds();
368 float delta = bounds.height() / 2;
369 gfx::Point start(bounds.x() + 5, bounds.y() + 5);
370 SendGestureEvent(start, delta, 1, false, 0, true);
371 EXPECT_FALSE(system_tray->HasSystemBubble());
372
373 // Begins to scroll upward and swiping down more than one third of the
374 // bubble's height should also close the bubble.
375 system_tray->ShowDefaultView(BUBBLE_CREATE_NEW);
376 SendGestureEvent(start, delta, -1, false, 0, true);
377 EXPECT_FALSE(system_tray->HasSystemBubble());
378 }
379
323 // Verifies only the visible default views are recorded in the 380 // Verifies only the visible default views are recorded in the
324 // "Ash.SystemMenu.DefaultView.VisibleItems" histogram. 381 // "Ash.SystemMenu.DefaultView.VisibleItems" histogram.
325 TEST_F(SystemTrayTest, OnlyVisibleItemsRecorded) { 382 TEST_F(SystemTrayTest, OnlyVisibleItemsRecorded) {
326 SystemTray* tray = GetPrimarySystemTray(); 383 SystemTray* tray = GetPrimarySystemTray();
327 ASSERT_TRUE(tray->GetWidget()); 384 ASSERT_TRUE(tray->GetWidget());
328 385
329 TestSystemTrayItem* test_item = new TestSystemTrayItem(); 386 TestSystemTrayItem* test_item = new TestSystemTrayItem();
330 tray->AddTrayItem(base::WrapUnique(test_item)); 387 tray->AddTrayItem(base::WrapUnique(test_item));
331 388
332 base::HistogramTester histogram_tester; 389 base::HistogramTester histogram_tester;
(...skipping 515 matching lines...) Expand 10 before | Expand all | Expand 10 after
848 905
849 EXPECT_EQ(0, notification_tray->tray_bubble_height_for_test()); 906 EXPECT_EQ(0, notification_tray->tray_bubble_height_for_test());
850 } 907 }
851 908
852 TEST_F(SystemTrayTest, SeparatorThickness) { 909 TEST_F(SystemTrayTest, SeparatorThickness) {
853 EXPECT_EQ(kSeparatorWidth, views::Separator::kThickness); 910 EXPECT_EQ(kSeparatorWidth, views::Separator::kThickness);
854 } 911 }
855 912
856 } // namespace test 913 } // namespace test
857 } // namespace ash 914 } // namespace ash
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698