Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 25 matching lines...) Expand all Loading... | |
| 56 DISALLOW_COPY_AND_ASSIGN(ModalWidgetDelegate); | 57 DISALLOW_COPY_AND_ASSIGN(ModalWidgetDelegate); |
| 57 }; | 58 }; |
| 58 | 59 |
| 59 } // namespace | 60 } // namespace |
| 60 | 61 |
| 61 class SystemTrayTest : public AshTestBase { | 62 class SystemTrayTest : public AshTestBase { |
| 62 public: | 63 public: |
| 63 SystemTrayTest() {} | 64 SystemTrayTest() {} |
| 64 ~SystemTrayTest() override {} | 65 ~SystemTrayTest() override {} |
| 65 | 66 |
| 66 // Swiping on the system tray and ends with finger released. | 67 // Swiping on the system tray and ends with finger released. Note, |start| is |
| 68 // based on the system tray or system tray bubble's coordinate space. | |
| 67 void SendGestureEvent(gfx::Point& start, | 69 void SendGestureEvent(gfx::Point& start, |
| 68 float delta, | 70 float delta, |
| 69 bool is_fling, | 71 bool is_fling, |
| 70 float velocity_y) { | 72 float velocity_y) { |
| 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, timestamp); |
| 74 | 76 |
| 75 ui::GestureEventDetails details = | 77 ui::GestureEventDetails details = |
| 76 is_fling | 78 is_fling |
| 77 ? ui::GestureEventDetails(ui::ET_SCROLL_FLING_START, 0, velocity_y) | 79 ? ui::GestureEventDetails(ui::ET_SCROLL_FLING_START, 0, velocity_y) |
| 78 : ui::GestureEventDetails(ui::ET_GESTURE_SCROLL_END); | 80 : ui::GestureEventDetails(ui::ET_GESTURE_SCROLL_END); |
| 79 ui::GestureEvent event = ui::GestureEvent(start.x(), start.y() + delta, | 81 ui::GestureEvent event = ui::GestureEvent(start.x(), start.y() + delta, |
| 80 ui::EF_NONE, timestamp, details); | 82 ui::EF_NONE, timestamp, details); |
| 81 system_tray->OnGestureEvent(&event); | 83 ui::Event::DispatcherApi dispatch_helper(&event); |
|
msw
2017/07/14 02:00:46
Can you extract a helper function for the three si
minch1
2017/07/14 19:45:17
Done.
| |
| 84 if (is_on_bubble_) { | |
| 85 dispatch_helper.set_target(system_tray->GetSystemBubble()->bubble_view()); | |
| 86 system_tray->GetSystemBubble()->bubble_view()->OnGestureEvent(&event); | |
| 87 } else { | |
| 88 dispatch_helper.set_target(system_tray); | |
| 89 system_tray->OnGestureEvent(&event); | |
| 90 } | |
| 82 } | 91 } |
| 83 | 92 |
| 84 // Swiping on the system tray without releasing the finger. | 93 // Swiping on the system tray without releasing the finger. |
| 85 void SendScrollStartAndUpdate(gfx::Point& start, | 94 void SendScrollStartAndUpdate(gfx::Point& start, |
| 86 float delta, | 95 float delta, |
| 87 base::TimeTicks& timestamp) { | 96 base::TimeTicks& timestamp) { |
| 88 SystemTray* system_tray = GetPrimarySystemTray(); | 97 SystemTray* system_tray = GetPrimarySystemTray(); |
| 89 ui::GestureEventDetails begin_details(ui::ET_GESTURE_SCROLL_BEGIN); | 98 ui::GestureEventDetails begin_details(ui::ET_GESTURE_SCROLL_BEGIN, 0, |
| 99 scroll_y_hint_); | |
| 90 ui::GestureEvent begin_event = ui::GestureEvent( | 100 ui::GestureEvent begin_event = ui::GestureEvent( |
| 91 start.x(), start.y(), ui::EF_NONE, timestamp, begin_details); | 101 start.x(), start.y(), ui::EF_NONE, timestamp, begin_details); |
| 92 system_tray->OnGestureEvent(&begin_event); | 102 |
| 103 ui::Event::DispatcherApi begin_dispatch_helper(&begin_event); | |
| 104 if (is_on_bubble_) { | |
| 105 begin_dispatch_helper.set_target( | |
| 106 system_tray->GetSystemBubble()->bubble_view()); | |
| 107 system_tray->GetSystemBubble()->bubble_view()->OnGestureEvent( | |
| 108 &begin_event); | |
| 109 } else { | |
| 110 begin_dispatch_helper.set_target(system_tray); | |
| 111 system_tray->OnGestureEvent(&begin_event); | |
| 112 } | |
| 93 | 113 |
| 94 ui::GestureEventDetails update_details(ui::ET_GESTURE_SCROLL_UPDATE, 0, | 114 ui::GestureEventDetails update_details(ui::ET_GESTURE_SCROLL_UPDATE, 0, |
| 95 delta); | 115 delta); |
| 96 timestamp += base::TimeDelta::FromMilliseconds(100); | 116 timestamp += base::TimeDelta::FromMilliseconds(100); |
| 97 ui::GestureEvent update_event = ui::GestureEvent( | 117 ui::GestureEvent update_event = ui::GestureEvent( |
| 98 start.x(), start.y() + delta, ui::EF_NONE, timestamp, update_details); | 118 start.x(), start.y() + delta, ui::EF_NONE, timestamp, update_details); |
| 99 system_tray->OnGestureEvent(&update_event); | 119 |
| 120 ui::Event::DispatcherApi update_dispatch_helper(&update_event); | |
| 121 if (is_on_bubble_) { | |
| 122 update_dispatch_helper.set_target( | |
| 123 system_tray->GetSystemBubble()->bubble_view()); | |
| 124 system_tray->GetSystemBubble()->bubble_view()->OnGestureEvent( | |
| 125 &update_event); | |
| 126 } else { | |
| 127 update_dispatch_helper.set_target(system_tray); | |
| 128 system_tray->OnGestureEvent(&update_event); | |
| 129 } | |
| 100 } | 130 } |
| 101 | 131 |
| 102 // Open the default system tray bubble to get the height of the bubble and | 132 // Open the default system tray bubble to get the height of the bubble and |
| 103 // then close it. | 133 // then close it. |
| 104 float GetSystemBubbleHeight() { | 134 float GetSystemBubbleHeight() { |
| 105 SystemTray* system_tray = GetPrimarySystemTray(); | 135 SystemTray* system_tray = GetPrimarySystemTray(); |
| 106 system_tray->ShowDefaultView(BUBBLE_CREATE_NEW); | 136 system_tray->ShowDefaultView(BUBBLE_CREATE_NEW); |
| 107 gfx::Rect bounds = GetSystemBubbleBoundsInScreen(); | 137 gfx::Rect bounds = GetSystemBubbleBoundsInScreen(); |
| 108 system_tray->CloseSystemBubble(); | 138 system_tray->CloseSystemBubble(); |
| 109 return bounds.height(); | 139 return bounds.height(); |
| 110 } | 140 } |
| 111 | 141 |
| 112 gfx::Rect GetSystemBubbleBoundsInScreen() { | 142 gfx::Rect GetSystemBubbleBoundsInScreen() { |
| 113 return GetPrimarySystemTray() | 143 return GetPrimarySystemTray() |
| 114 ->GetSystemBubble() | 144 ->GetSystemBubble() |
| 115 ->bubble_view() | 145 ->bubble_view() |
| 116 ->GetWidget() | 146 ->GetWidget() |
| 117 ->GetWindowBoundsInScreen(); | 147 ->GetWindowBoundsInScreen(); |
| 118 } | 148 } |
| 119 | 149 |
| 150 void set_scroll_y_hint(float scroll_y_hint) { | |
| 151 scroll_y_hint_ = scroll_y_hint; | |
| 152 } | |
| 153 | |
| 154 void set_is_on_bubble(bool is_on_bubble) { is_on_bubble_ = is_on_bubble; } | |
| 155 | |
| 120 private: | 156 private: |
| 157 // Distance that caused the scroll to start, which can be used to indicate the | |
| 158 // scroll direction. | |
| 159 float scroll_y_hint_ = -1.f; | |
|
msw
2017/07/14 02:00:45
I think these two members might be better off as a
minch1
2017/07/14 19:45:17
Personally, I prefer to make them as the arguments
| |
| 160 | |
| 161 // True if the dragging is triggered on the system tray bubble, otherwise | |
| 162 // false. | |
|
msw
2017/07/14 02:00:45
nit: s/false/the dragging is triggered on the tray
minch1
2017/07/14 19:45:17
Done.
| |
| 163 bool is_on_bubble_ = false; | |
|
msw
2017/07/14 02:00:45
nit: maybe rename this to something like |target_b
minch1
2017/07/14 19:45:17
Done.
| |
| 164 | |
| 121 DISALLOW_COPY_AND_ASSIGN(SystemTrayTest); | 165 DISALLOW_COPY_AND_ASSIGN(SystemTrayTest); |
| 122 }; | 166 }; |
| 123 | 167 |
| 124 // Swiping on the overlap area of shelf and system tray bubble during the | 168 // Swiping on the overlap area of shelf and system tray bubble during the |
| 125 // animation should close the bubble. | 169 // animation should close the bubble. |
| 126 TEST_F(SystemTrayTest, SwipingOnShelfDuringAnimation) { | 170 TEST_F(SystemTrayTest, SwipingOnShelfDuringAnimation) { |
| 127 Shelf* shelf = GetPrimaryShelf(); | 171 Shelf* shelf = GetPrimaryShelf(); |
| 128 SystemTray* system_tray = GetPrimarySystemTray(); | 172 SystemTray* system_tray = GetPrimarySystemTray(); |
| 129 gfx::Point start = system_tray->GetLocalBounds().CenterPoint(); | 173 gfx::Point start = system_tray->GetLocalBounds().CenterPoint(); |
| 130 shelf->SetAlignment(SHELF_ALIGNMENT_BOTTOM); | 174 shelf->SetAlignment(SHELF_ALIGNMENT_BOTTOM); |
| (...skipping 26 matching lines...) Expand all Loading... | |
| 157 | 201 |
| 158 // Dragging the shelf during up animation should close the bubble. | 202 // Dragging the shelf during up animation should close the bubble. |
| 159 if (current_bounds.y() != original_bounds.y()) { | 203 if (current_bounds.y() != original_bounds.y()) { |
| 160 generator.GestureScrollSequence(point_on_shelf_start, point_on_shelf_end, | 204 generator.GestureScrollSequence(point_on_shelf_start, point_on_shelf_end, |
| 161 base::TimeDelta::FromMilliseconds(100), 5); | 205 base::TimeDelta::FromMilliseconds(100), 5); |
| 162 EXPECT_FALSE(system_tray->HasSystemBubble()); | 206 EXPECT_FALSE(system_tray->HasSystemBubble()); |
| 163 } | 207 } |
| 164 | 208 |
| 165 // Fling down on the shelf with a velocity that exceeds |kFlingVelocity|. | 209 // Fling down on the shelf with a velocity that exceeds |kFlingVelocity|. |
| 166 EXPECT_FALSE(system_tray->HasSystemBubble()); | 210 EXPECT_FALSE(system_tray->HasSystemBubble()); |
| 167 SendGestureEvent(start, delta, true, SystemTray::kFlingVelocity + 1); | 211 SendGestureEvent(start, delta, true, TrayDragController::kFlingVelocity + 1); |
| 168 current_bounds = GetSystemBubbleBoundsInScreen(); | 212 current_bounds = GetSystemBubbleBoundsInScreen(); |
| 169 EXPECT_TRUE(system_tray->HasSystemBubble()); | 213 EXPECT_TRUE(system_tray->HasSystemBubble()); |
| 170 | 214 |
| 171 // Dragging the shelf during down animation should close the bubble. | 215 // Dragging the shelf during down animation should close the bubble. |
| 172 if (current_bounds.y() != original_bounds.y()) { | 216 if (current_bounds.y() != original_bounds.y()) { |
| 173 generator.GestureScrollSequence(point_on_shelf_start, point_on_shelf_end, | 217 generator.GestureScrollSequence(point_on_shelf_start, point_on_shelf_end, |
| 174 base::TimeDelta::FromMilliseconds(100), 5); | 218 base::TimeDelta::FromMilliseconds(100), 5); |
| 175 EXPECT_FALSE(system_tray->HasSystemBubble()); | 219 EXPECT_FALSE(system_tray->HasSystemBubble()); |
| 176 } | 220 } |
| 177 } | 221 } |
| 178 | 222 |
| 179 // Swiping on the system tray ends with fling event. | 223 // Swiping on the system tray ends with fling event. |
| 180 TEST_F(SystemTrayTest, FlingOnSystemTray) { | 224 TEST_F(SystemTrayTest, FlingOnSystemTray) { |
| 181 Shelf* shelf = GetPrimaryShelf(); | 225 Shelf* shelf = GetPrimaryShelf(); |
| 182 SystemTray* system_tray = GetPrimarySystemTray(); | 226 SystemTray* system_tray = GetPrimarySystemTray(); |
| 183 gfx::Point start = system_tray->GetBoundsInScreen().CenterPoint(); | 227 gfx::Point start = system_tray->GetLocalBounds().CenterPoint(); |
| 184 shelf->SetAlignment(SHELF_ALIGNMENT_BOTTOM); | 228 shelf->SetAlignment(SHELF_ALIGNMENT_BOTTOM); |
| 185 Shell::Get()->maximize_mode_controller()->EnableMaximizeModeWindowManager( | 229 Shell::Get()->maximize_mode_controller()->EnableMaximizeModeWindowManager( |
| 186 true); | 230 true); |
| 187 | 231 |
| 188 // Fling up on the system tray should show the bubble if the |velocity_y| is | 232 // 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 | 233 // larger than |kFlingVelocity| and the dragging amount is larger than one |
| 190 // third of the height of the bubble. | 234 // third of the height of the bubble. |
| 191 float delta = -GetSystemBubbleHeight(); | 235 float delta = -GetSystemBubbleHeight(); |
| 192 SendGestureEvent(start, delta, true, -(SystemTray::kFlingVelocity + 1)); | 236 SendGestureEvent(start, delta, true, |
| 237 -(TrayDragController::kFlingVelocity + 1)); | |
| 193 EXPECT_TRUE(system_tray->HasSystemBubble()); | 238 EXPECT_TRUE(system_tray->HasSystemBubble()); |
| 194 system_tray->CloseSystemBubble(); | 239 system_tray->CloseSystemBubble(); |
| 195 | 240 |
| 196 // Fling up on the system tray should show the bubble if the |velocity_y| is | 241 // 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 | 242 // larger than |kFlingVelocity| even the dragging amount is less than one |
| 198 // third of the height of the bubble. | 243 // third of the height of the bubble. |
| 199 delta /= 4; | 244 delta /= 4; |
| 200 SendGestureEvent(start, delta, true, -(SystemTray::kFlingVelocity + 1)); | 245 SendGestureEvent(start, delta, true, |
| 246 -(TrayDragController::kFlingVelocity + 1)); | |
| 201 EXPECT_TRUE(system_tray->HasSystemBubble()); | 247 EXPECT_TRUE(system_tray->HasSystemBubble()); |
| 202 system_tray->CloseSystemBubble(); | 248 system_tray->CloseSystemBubble(); |
| 203 | 249 |
| 204 // Fling up on the system tray should show the bubble if the |velocity_y| is | 250 // 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 | 251 // less than |kFlingVelocity| but the dragging amount if larger than one third |
| 206 // of the height of the bubble. | 252 // of the height of the bubble. |
| 207 delta = -GetSystemBubbleHeight(); | 253 delta = -GetSystemBubbleHeight(); |
| 208 SendGestureEvent(start, delta, true, -(SystemTray::kFlingVelocity - 1)); | 254 SendGestureEvent(start, delta, true, |
| 255 -(TrayDragController::kFlingVelocity - 1)); | |
| 209 EXPECT_TRUE(system_tray->HasSystemBubble()); | 256 EXPECT_TRUE(system_tray->HasSystemBubble()); |
| 210 system_tray->CloseSystemBubble(); | 257 system_tray->CloseSystemBubble(); |
| 211 | 258 |
| 212 // Fling up on the system tray should close the bubble if the |velocity_y| | 259 // 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 | 260 // is less than |kFlingVelocity| and the dragging amount is less than one |
| 214 // third of the height of the bubble. | 261 // third of the height of the bubble. |
| 215 delta /= 4; | 262 delta /= 4; |
| 216 SendGestureEvent(start, delta, true, -(SystemTray::kFlingVelocity - 1)); | 263 SendGestureEvent(start, delta, true, |
| 264 -(TrayDragController::kFlingVelocity - 1)); | |
| 217 EXPECT_FALSE(system_tray->HasSystemBubble()); | 265 EXPECT_FALSE(system_tray->HasSystemBubble()); |
| 218 | 266 |
| 219 // Fling down on the system tray should close the bubble if the |velocity_y| | 267 // Fling down on the system tray should close the bubble if the |velocity_y| |
| 220 // is larger than kFLingVelocity. | 268 // is larger than kFLingVelocity. |
| 221 SendGestureEvent(start, delta, true, SystemTray::kFlingVelocity + 1); | 269 SendGestureEvent(start, delta, true, TrayDragController::kFlingVelocity + 1); |
| 222 EXPECT_FALSE(system_tray->HasSystemBubble()); | 270 EXPECT_FALSE(system_tray->HasSystemBubble()); |
| 223 | 271 |
| 224 // Fling down on the system tray should close the bubble if the |velocity_y| | 272 // 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 | 273 // is larger than |kFlingVelocity| even the dragging amount is larger than one |
| 226 // third of the height of the bubble. | 274 // third of the height of the bubble. |
| 227 delta = -GetSystemBubbleHeight(); | 275 delta = -GetSystemBubbleHeight(); |
| 228 SendGestureEvent(start, delta, true, SystemTray::kFlingVelocity + 1); | 276 SendGestureEvent(start, delta, true, TrayDragController::kFlingVelocity + 1); |
| 229 EXPECT_FALSE(system_tray->HasSystemBubble()); | 277 EXPECT_FALSE(system_tray->HasSystemBubble()); |
| 230 | 278 |
| 231 // Fling down on the system tray should open the bubble if the |velocity_y| is | 279 // 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 | 280 // less than |kFlingVelocity| but the dragging amount exceed one third of the |
| 233 // height of the bubble. | 281 // height of the bubble. |
| 234 SendGestureEvent(start, delta, true, SystemTray::kFlingVelocity - 1); | 282 SendGestureEvent(start, delta, true, TrayDragController::kFlingVelocity - 1); |
| 235 EXPECT_TRUE(system_tray->HasSystemBubble()); | 283 EXPECT_TRUE(system_tray->HasSystemBubble()); |
| 236 system_tray->CloseSystemBubble(); | 284 system_tray->CloseSystemBubble(); |
| 237 | 285 |
| 238 // Fling down on the system tray should close the bubble if the |velocity_y| | 286 // 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 | 287 // is less than |kFlingVelocity| and the dragging amount is less than one |
| 240 // third of the height of the bubble. | 288 // third of the height of the bubble. |
| 241 delta /= 4; | 289 delta /= 4; |
| 242 SendGestureEvent(start, delta, true, SystemTray::kFlingVelocity - 1); | 290 SendGestureEvent(start, delta, true, TrayDragController::kFlingVelocity - 1); |
| 243 EXPECT_FALSE(system_tray->HasSystemBubble()); | 291 EXPECT_FALSE(system_tray->HasSystemBubble()); |
| 244 } | 292 } |
| 245 | 293 |
| 246 // Touch outside the system tray bubble during swiping should close the bubble. | 294 // Touch outside the system tray bubble during swiping should close the bubble. |
| 247 TEST_F(SystemTrayTest, TapOutsideCloseBubble) { | 295 TEST_F(SystemTrayTest, TapOutsideCloseBubble) { |
| 248 Shelf* shelf = GetPrimaryShelf(); | 296 Shelf* shelf = GetPrimaryShelf(); |
| 249 SystemTray* system_tray = GetPrimarySystemTray(); | 297 SystemTray* system_tray = GetPrimarySystemTray(); |
| 250 gfx::Point start = system_tray->GetLocalBounds().CenterPoint(); | 298 gfx::Point start = system_tray->GetLocalBounds().CenterPoint(); |
| 251 shelf->SetAlignment(SHELF_ALIGNMENT_BOTTOM); | 299 shelf->SetAlignment(SHELF_ALIGNMENT_BOTTOM); |
| 252 | 300 |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 306 shelf->SetAlignment(SHELF_ALIGNMENT_LEFT); | 354 shelf->SetAlignment(SHELF_ALIGNMENT_LEFT); |
| 307 SendGestureEvent(start, delta, false, 0); | 355 SendGestureEvent(start, delta, false, 0); |
| 308 EXPECT_FALSE(system_tray->HasSystemBubble()); | 356 EXPECT_FALSE(system_tray->HasSystemBubble()); |
| 309 | 357 |
| 310 // Swiping up on system tray should not show the system tray bubble if the | 358 // Swiping up on system tray should not show the system tray bubble if the |
| 311 // shelf is right alignment. | 359 // shelf is right alignment. |
| 312 shelf->SetAlignment(SHELF_ALIGNMENT_RIGHT); | 360 shelf->SetAlignment(SHELF_ALIGNMENT_RIGHT); |
| 313 SendGestureEvent(start, delta, false, 0); | 361 SendGestureEvent(start, delta, false, 0); |
| 314 EXPECT_FALSE(system_tray->HasSystemBubble()); | 362 EXPECT_FALSE(system_tray->HasSystemBubble()); |
| 315 | 363 |
| 316 // Swiping down on the shelf should not show the system tray bubble. | 364 // Beginning to scroll downward on the shelf should not show the system tray |
| 365 // bubble. | |
|
msw
2017/07/14 02:00:46
nit: "bubble, even if the drag then moves upwards.
minch1
2017/07/14 19:45:17
Done.
| |
| 317 shelf->SetAlignment(SHELF_ALIGNMENT_BOTTOM); | 366 shelf->SetAlignment(SHELF_ALIGNMENT_BOTTOM); |
| 318 delta = -delta; | 367 set_scroll_y_hint(1.0); |
| 319 SendGestureEvent(start, delta, false, 0); | 368 SendGestureEvent(start, delta, false, 0); |
| 320 EXPECT_FALSE(system_tray->HasSystemBubble()); | 369 EXPECT_FALSE(system_tray->HasSystemBubble()); |
| 321 } | 370 } |
| 322 | 371 |
| 372 // Swiping on opened system tray bubble. | |
| 373 TEST_F(SystemTrayTest, SwipingOnSystemTrayBubble) { | |
| 374 Shelf* shelf = GetPrimaryShelf(); | |
| 375 SystemTray* system_tray = GetPrimarySystemTray(); | |
| 376 shelf->SetAlignment(SHELF_ALIGNMENT_BOTTOM); | |
| 377 set_is_on_bubble(true); | |
| 378 | |
| 379 // Beginning to scroll downward and then swiping down more than one third of | |
| 380 // the bubble's height should close the bubble. | |
|
msw
2017/07/14 02:00:45
Thanks for adding the comment about maximize mode
minch1
2017/07/14 19:45:17
Done.
| |
| 381 Shell::Get()->maximize_mode_controller()->EnableMaximizeModeWindowManager( | |
| 382 true); | |
| 383 system_tray->ShowDefaultView(BUBBLE_CREATE_NEW); | |
| 384 gfx::Rect bounds = | |
| 385 system_tray->GetSystemBubble()->bubble_view()->GetLocalBounds(); | |
| 386 float delta = bounds.height() / 2; | |
| 387 gfx::Point start(bounds.x() + 5, bounds.y() + 5); | |
| 388 set_scroll_y_hint(1.0); | |
| 389 SendGestureEvent(start, delta, false, 0); | |
| 390 EXPECT_FALSE(system_tray->HasSystemBubble()); | |
| 391 | |
| 392 // Beginning to scroll upward and then swiping down more than one third of the | |
| 393 // bubble's height should also close the bubble. | |
| 394 system_tray->ShowDefaultView(BUBBLE_CREATE_NEW); | |
| 395 set_scroll_y_hint(-1.0); | |
| 396 SendGestureEvent(start, delta, false, 0); | |
| 397 EXPECT_FALSE(system_tray->HasSystemBubble()); | |
| 398 | |
| 399 // Swiping on the bubble has no effect if it is not in maximize mode. | |
| 400 Shell::Get()->maximize_mode_controller()->EnableMaximizeModeWindowManager( | |
| 401 false); | |
| 402 system_tray->ShowDefaultView(BUBBLE_CREATE_NEW); | |
| 403 set_scroll_y_hint(-1.0); | |
| 404 SendGestureEvent(start, delta, false, 0); | |
| 405 EXPECT_TRUE(system_tray->HasSystemBubble()); | |
| 406 } | |
| 407 | |
| 323 // Verifies only the visible default views are recorded in the | 408 // Verifies only the visible default views are recorded in the |
| 324 // "Ash.SystemMenu.DefaultView.VisibleItems" histogram. | 409 // "Ash.SystemMenu.DefaultView.VisibleItems" histogram. |
| 325 TEST_F(SystemTrayTest, OnlyVisibleItemsRecorded) { | 410 TEST_F(SystemTrayTest, OnlyVisibleItemsRecorded) { |
| 326 SystemTray* tray = GetPrimarySystemTray(); | 411 SystemTray* tray = GetPrimarySystemTray(); |
| 327 ASSERT_TRUE(tray->GetWidget()); | 412 ASSERT_TRUE(tray->GetWidget()); |
| 328 | 413 |
| 329 TestSystemTrayItem* test_item = new TestSystemTrayItem(); | 414 TestSystemTrayItem* test_item = new TestSystemTrayItem(); |
| 330 tray->AddTrayItem(base::WrapUnique(test_item)); | 415 tray->AddTrayItem(base::WrapUnique(test_item)); |
| 331 | 416 |
| 332 base::HistogramTester histogram_tester; | 417 base::HistogramTester histogram_tester; |
| (...skipping 515 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 848 | 933 |
| 849 EXPECT_EQ(0, notification_tray->tray_bubble_height_for_test()); | 934 EXPECT_EQ(0, notification_tray->tray_bubble_height_for_test()); |
| 850 } | 935 } |
| 851 | 936 |
| 852 TEST_F(SystemTrayTest, SeparatorThickness) { | 937 TEST_F(SystemTrayTest, SeparatorThickness) { |
| 853 EXPECT_EQ(kSeparatorWidth, views::Separator::kThickness); | 938 EXPECT_EQ(kSeparatorWidth, views::Separator::kThickness); |
| 854 } | 939 } |
| 855 | 940 |
| 856 } // namespace test | 941 } // namespace test |
| 857 } // namespace ash | 942 } // namespace ash |
| OLD | NEW |