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

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

Powered by Google App Engine
This is Rietveld 408576698