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/common/system/web_notification/web_notification_tray.h" | 5 #include "ash/common/system/web_notification/web_notification_tray.h" |
6 | 6 |
7 #include <utility> | 7 #include <utility> |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "ash/common/material_design/material_design_controller.h" | |
11 #include "ash/common/shelf/shelf_layout_manager.h" | 10 #include "ash/common/shelf/shelf_layout_manager.h" |
12 #include "ash/common/shelf/wm_shelf.h" | 11 #include "ash/common/shelf/wm_shelf.h" |
13 #include "ash/common/system/status_area_widget.h" | 12 #include "ash/common/system/status_area_widget.h" |
14 #include "ash/common/system/tray/system_tray.h" | 13 #include "ash/common/system/tray/system_tray.h" |
15 #include "ash/common/system/tray/system_tray_item.h" | 14 #include "ash/common/system/tray/system_tray_item.h" |
16 #include "ash/common/system/web_notification/ash_popup_alignment_delegate.h" | 15 #include "ash/common/system/web_notification/ash_popup_alignment_delegate.h" |
17 #include "ash/common/test/test_system_tray_delegate.h" | 16 #include "ash/common/test/test_system_tray_delegate.h" |
18 #include "ash/common/wm/window_state.h" | 17 #include "ash/common/wm/window_state.h" |
19 #include "ash/common/wm_lookup.h" | 18 #include "ash/common/wm_lookup.h" |
20 #include "ash/common/wm_window.h" | 19 #include "ash/common/wm_window.h" |
21 #include "ash/public/cpp/shell_window_ids.h" | 20 #include "ash/public/cpp/shell_window_ids.h" |
22 #include "ash/shell.h" | 21 #include "ash/shell.h" |
23 #include "ash/system/chromeos/screen_layout_observer.h" | 22 #include "ash/system/chromeos/screen_layout_observer.h" |
24 #include "ash/test/ash_md_test_base.h" | 23 #include "ash/test/ash_test_base.h" |
25 #include "ash/test/status_area_widget_test_helper.h" | 24 #include "ash/test/status_area_widget_test_helper.h" |
26 #include "base/memory/ptr_util.h" | 25 #include "base/memory/ptr_util.h" |
27 #include "base/strings/stringprintf.h" | 26 #include "base/strings/stringprintf.h" |
28 #include "base/strings/utf_string_conversions.h" | 27 #include "base/strings/utf_string_conversions.h" |
29 #include "ui/display/display.h" | 28 #include "ui/display/display.h" |
30 #include "ui/display/manager/display_manager.h" | 29 #include "ui/display/manager/display_manager.h" |
31 #include "ui/display/screen.h" | 30 #include "ui/display/screen.h" |
32 #include "ui/events/test/event_generator.h" | 31 #include "ui/events/test/event_generator.h" |
33 #include "ui/gfx/geometry/point.h" | 32 #include "ui/gfx/geometry/point.h" |
34 #include "ui/gfx/geometry/rect.h" | 33 #include "ui/gfx/geometry/rect.h" |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
84 return new views::View; | 83 return new views::View; |
85 } | 84 } |
86 | 85 |
87 private: | 86 private: |
88 DISALLOW_COPY_AND_ASSIGN(TestItem); | 87 DISALLOW_COPY_AND_ASSIGN(TestItem); |
89 }; | 88 }; |
90 | 89 |
91 } // namespace | 90 } // namespace |
92 | 91 |
93 // TODO(jamescook): Move this to //ash/common. http://crbug.com/620955 | 92 // TODO(jamescook): Move this to //ash/common. http://crbug.com/620955 |
94 class WebNotificationTrayTest : public test::AshMDTestBase { | 93 class WebNotificationTrayTest : public test::AshTestBase { |
95 public: | 94 public: |
96 WebNotificationTrayTest() {} | 95 WebNotificationTrayTest() {} |
97 ~WebNotificationTrayTest() override {} | 96 ~WebNotificationTrayTest() override {} |
98 | 97 |
99 void TearDown() override { | 98 void TearDown() override { |
100 GetMessageCenter()->RemoveAllNotifications( | 99 GetMessageCenter()->RemoveAllNotifications( |
101 false /* by_user */, message_center::MessageCenter::RemoveType::ALL); | 100 false /* by_user */, message_center::MessageCenter::RemoveType::ALL); |
102 test::AshMDTestBase::TearDown(); | 101 test::AshTestBase::TearDown(); |
103 } | 102 } |
104 | 103 |
105 protected: | 104 protected: |
106 void AddNotification(const std::string& id) { | 105 void AddNotification(const std::string& id) { |
107 std::unique_ptr<message_center::Notification> notification; | 106 std::unique_ptr<message_center::Notification> notification; |
108 notification.reset(new message_center::Notification( | 107 notification.reset(new message_center::Notification( |
109 message_center::NOTIFICATION_TYPE_SIMPLE, id, | 108 message_center::NOTIFICATION_TYPE_SIMPLE, id, |
110 base::ASCIIToUTF16("Test Web Notification"), | 109 base::ASCIIToUTF16("Test Web Notification"), |
111 base::ASCIIToUTF16("Notification message body."), gfx::Image(), | 110 base::ASCIIToUTF16("Notification message body."), gfx::Image(), |
112 base::ASCIIToUTF16("www.test.org"), GURL(), | 111 base::ASCIIToUTF16("www.test.org"), GURL(), |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
150 } | 149 } |
151 | 150 |
152 static void UpdateAutoHideStateNow() { | 151 static void UpdateAutoHideStateNow() { |
153 GetPrimaryShelf()->shelf_layout_manager()->UpdateAutoHideStateNow(); | 152 GetPrimaryShelf()->shelf_layout_manager()->UpdateAutoHideStateNow(); |
154 } | 153 } |
155 | 154 |
156 private: | 155 private: |
157 DISALLOW_COPY_AND_ASSIGN(WebNotificationTrayTest); | 156 DISALLOW_COPY_AND_ASSIGN(WebNotificationTrayTest); |
158 }; | 157 }; |
159 | 158 |
160 INSTANTIATE_TEST_CASE_P( | 159 TEST_F(WebNotificationTrayTest, WebNotifications) { |
161 /* prefix intentionally left blank due to only one parameterization */, | |
162 WebNotificationTrayTest, | |
163 testing::Values(MaterialDesignController::NON_MATERIAL, | |
164 MaterialDesignController::MATERIAL_NORMAL, | |
165 MaterialDesignController::MATERIAL_EXPERIMENTAL)); | |
166 | |
167 TEST_P(WebNotificationTrayTest, WebNotifications) { | |
168 // TODO(mukai): move this test case to ui/message_center. | 160 // TODO(mukai): move this test case to ui/message_center. |
169 ASSERT_TRUE(GetWidget()); | 161 ASSERT_TRUE(GetWidget()); |
170 | 162 |
171 // Add a notification. | 163 // Add a notification. |
172 AddNotification("test_id1"); | 164 AddNotification("test_id1"); |
173 EXPECT_EQ(1u, GetMessageCenter()->NotificationCount()); | 165 EXPECT_EQ(1u, GetMessageCenter()->NotificationCount()); |
174 EXPECT_TRUE(GetMessageCenter()->FindVisibleNotificationById("test_id1")); | 166 EXPECT_TRUE(GetMessageCenter()->FindVisibleNotificationById("test_id1")); |
175 AddNotification("test_id2"); | 167 AddNotification("test_id2"); |
176 AddNotification("test_id2"); | 168 AddNotification("test_id2"); |
177 EXPECT_EQ(2u, GetMessageCenter()->NotificationCount()); | 169 EXPECT_EQ(2u, GetMessageCenter()->NotificationCount()); |
178 EXPECT_TRUE(GetMessageCenter()->FindVisibleNotificationById("test_id2")); | 170 EXPECT_TRUE(GetMessageCenter()->FindVisibleNotificationById("test_id2")); |
179 | 171 |
180 // Ensure that updating a notification does not affect the count. | 172 // Ensure that updating a notification does not affect the count. |
181 UpdateNotification("test_id2", "test_id3"); | 173 UpdateNotification("test_id2", "test_id3"); |
182 UpdateNotification("test_id3", "test_id3"); | 174 UpdateNotification("test_id3", "test_id3"); |
183 EXPECT_EQ(2u, GetMessageCenter()->NotificationCount()); | 175 EXPECT_EQ(2u, GetMessageCenter()->NotificationCount()); |
184 EXPECT_FALSE(GetMessageCenter()->FindVisibleNotificationById("test_id2")); | 176 EXPECT_FALSE(GetMessageCenter()->FindVisibleNotificationById("test_id2")); |
185 | 177 |
186 // Ensure that Removing the first notification removes it from the tray. | 178 // Ensure that Removing the first notification removes it from the tray. |
187 RemoveNotification("test_id1"); | 179 RemoveNotification("test_id1"); |
188 EXPECT_FALSE(GetMessageCenter()->FindVisibleNotificationById("test_id1")); | 180 EXPECT_FALSE(GetMessageCenter()->FindVisibleNotificationById("test_id1")); |
189 EXPECT_EQ(1u, GetMessageCenter()->NotificationCount()); | 181 EXPECT_EQ(1u, GetMessageCenter()->NotificationCount()); |
190 | 182 |
191 // Remove the remianing notification. | 183 // Remove the remianing notification. |
192 RemoveNotification("test_id3"); | 184 RemoveNotification("test_id3"); |
193 EXPECT_EQ(0u, GetMessageCenter()->NotificationCount()); | 185 EXPECT_EQ(0u, GetMessageCenter()->NotificationCount()); |
194 EXPECT_FALSE(GetMessageCenter()->FindVisibleNotificationById("test_id3")); | 186 EXPECT_FALSE(GetMessageCenter()->FindVisibleNotificationById("test_id3")); |
195 } | 187 } |
196 | 188 |
197 TEST_P(WebNotificationTrayTest, WebNotificationPopupBubble) { | 189 TEST_F(WebNotificationTrayTest, WebNotificationPopupBubble) { |
198 // TODO(mukai): move this test case to ui/message_center. | 190 // TODO(mukai): move this test case to ui/message_center. |
199 ASSERT_TRUE(GetWidget()); | 191 ASSERT_TRUE(GetWidget()); |
200 | 192 |
201 // Adding a notification should show the popup bubble. | 193 // Adding a notification should show the popup bubble. |
202 AddNotification("test_id1"); | 194 AddNotification("test_id1"); |
203 EXPECT_TRUE(GetTray()->IsPopupVisible()); | 195 EXPECT_TRUE(GetTray()->IsPopupVisible()); |
204 | 196 |
205 // Updating a notification should not hide the popup bubble. | 197 // Updating a notification should not hide the popup bubble. |
206 AddNotification("test_id2"); | 198 AddNotification("test_id2"); |
207 UpdateNotification("test_id2", "test_id3"); | 199 UpdateNotification("test_id2", "test_id3"); |
(...skipping 14 matching lines...) Expand all Loading... |
222 | 214 |
223 GetTray()->message_center_tray_->ShowMessageCenterBubble(); | 215 GetTray()->message_center_tray_->ShowMessageCenterBubble(); |
224 GetTray()->message_center_tray_->HideMessageCenterBubble(); | 216 GetTray()->message_center_tray_->HideMessageCenterBubble(); |
225 | 217 |
226 EXPECT_FALSE(GetTray()->IsPopupVisible()); | 218 EXPECT_FALSE(GetTray()->IsPopupVisible()); |
227 } | 219 } |
228 | 220 |
229 using message_center::NotificationList; | 221 using message_center::NotificationList; |
230 | 222 |
231 // Flakily fails. http://crbug.com/229791 | 223 // Flakily fails. http://crbug.com/229791 |
232 TEST_P(WebNotificationTrayTest, DISABLED_ManyMessageCenterNotifications) { | 224 TEST_F(WebNotificationTrayTest, DISABLED_ManyMessageCenterNotifications) { |
233 // Add the max visible notifications +1, ensure the correct visible number. | 225 // Add the max visible notifications +1, ensure the correct visible number. |
234 size_t notifications_to_add = | 226 size_t notifications_to_add = |
235 message_center::kMaxVisibleMessageCenterNotifications + 1; | 227 message_center::kMaxVisibleMessageCenterNotifications + 1; |
236 for (size_t i = 0; i < notifications_to_add; ++i) { | 228 for (size_t i = 0; i < notifications_to_add; ++i) { |
237 std::string id = base::StringPrintf("test_id%d", static_cast<int>(i)); | 229 std::string id = base::StringPrintf("test_id%d", static_cast<int>(i)); |
238 AddNotification(id); | 230 AddNotification(id); |
239 } | 231 } |
240 bool shown = GetTray()->message_center_tray_->ShowMessageCenterBubble(); | 232 bool shown = GetTray()->message_center_tray_->ShowMessageCenterBubble(); |
241 EXPECT_TRUE(shown); | 233 EXPECT_TRUE(shown); |
242 RunAllPendingInMessageLoop(); | 234 RunAllPendingInMessageLoop(); |
243 EXPECT_TRUE(GetTray()->message_center_bubble() != NULL); | 235 EXPECT_TRUE(GetTray()->message_center_bubble() != NULL); |
244 EXPECT_EQ(notifications_to_add, GetMessageCenter()->NotificationCount()); | 236 EXPECT_EQ(notifications_to_add, GetMessageCenter()->NotificationCount()); |
245 EXPECT_EQ( | 237 EXPECT_EQ( |
246 message_center::kMaxVisibleMessageCenterNotifications, | 238 message_center::kMaxVisibleMessageCenterNotifications, |
247 GetTray()->GetMessageCenterBubbleForTest()->NumMessageViewsForTest()); | 239 GetTray()->GetMessageCenterBubbleForTest()->NumMessageViewsForTest()); |
248 } | 240 } |
249 | 241 |
250 // Flakily times out. http://crbug.com/229792 | 242 // Flakily times out. http://crbug.com/229792 |
251 TEST_P(WebNotificationTrayTest, DISABLED_ManyPopupNotifications) { | 243 TEST_F(WebNotificationTrayTest, DISABLED_ManyPopupNotifications) { |
252 // Add the max visible popup notifications +1, ensure the correct num visible. | 244 // Add the max visible popup notifications +1, ensure the correct num visible. |
253 size_t notifications_to_add = | 245 size_t notifications_to_add = |
254 message_center::kMaxVisiblePopupNotifications + 1; | 246 message_center::kMaxVisiblePopupNotifications + 1; |
255 for (size_t i = 0; i < notifications_to_add; ++i) { | 247 for (size_t i = 0; i < notifications_to_add; ++i) { |
256 std::string id = base::StringPrintf("test_id%d", static_cast<int>(i)); | 248 std::string id = base::StringPrintf("test_id%d", static_cast<int>(i)); |
257 AddNotification(id); | 249 AddNotification(id); |
258 } | 250 } |
259 GetTray()->ShowPopups(); | 251 GetTray()->ShowPopups(); |
260 EXPECT_TRUE(GetTray()->IsPopupVisible()); | 252 EXPECT_TRUE(GetTray()->IsPopupVisible()); |
261 EXPECT_EQ(notifications_to_add, GetMessageCenter()->NotificationCount()); | 253 EXPECT_EQ(notifications_to_add, GetMessageCenter()->NotificationCount()); |
262 NotificationList::PopupNotifications popups = | 254 NotificationList::PopupNotifications popups = |
263 GetMessageCenter()->GetPopupNotifications(); | 255 GetMessageCenter()->GetPopupNotifications(); |
264 EXPECT_EQ(message_center::kMaxVisiblePopupNotifications, popups.size()); | 256 EXPECT_EQ(message_center::kMaxVisiblePopupNotifications, popups.size()); |
265 } | 257 } |
266 | 258 |
267 // Verifies if the notification appears on both displays when extended mode. | 259 // Verifies if the notification appears on both displays when extended mode. |
268 TEST_P(WebNotificationTrayTest, PopupShownOnBothDisplays) { | 260 TEST_F(WebNotificationTrayTest, PopupShownOnBothDisplays) { |
269 Shell::GetInstance() | 261 Shell::GetInstance() |
270 ->screen_layout_observer() | 262 ->screen_layout_observer() |
271 ->set_show_notifications_for_testing(true); | 263 ->set_show_notifications_for_testing(true); |
272 UpdateDisplay("400x400,200x200"); | 264 UpdateDisplay("400x400,200x200"); |
273 // UpdateDisplay() creates the display notifications, so popup is visible. | 265 // UpdateDisplay() creates the display notifications, so popup is visible. |
274 EXPECT_TRUE(GetTray()->IsPopupVisible()); | 266 EXPECT_TRUE(GetTray()->IsPopupVisible()); |
275 WebNotificationTray* secondary_tray = GetSecondaryTray(); | 267 WebNotificationTray* secondary_tray = GetSecondaryTray(); |
276 ASSERT_TRUE(secondary_tray); | 268 ASSERT_TRUE(secondary_tray); |
277 EXPECT_TRUE(secondary_tray->IsPopupVisible()); | 269 EXPECT_TRUE(secondary_tray->IsPopupVisible()); |
278 | 270 |
(...skipping 11 matching lines...) Expand all Loading... |
290 UpdateDisplay("400x400,200x200"); | 282 UpdateDisplay("400x400,200x200"); |
291 EXPECT_TRUE(GetTray()->IsPopupVisible()); | 283 EXPECT_TRUE(GetTray()->IsPopupVisible()); |
292 secondary_tray = GetSecondaryTray(); | 284 secondary_tray = GetSecondaryTray(); |
293 ASSERT_TRUE(secondary_tray); | 285 ASSERT_TRUE(secondary_tray); |
294 EXPECT_TRUE(secondary_tray->IsPopupVisible()); | 286 EXPECT_TRUE(secondary_tray->IsPopupVisible()); |
295 } | 287 } |
296 | 288 |
297 // PopupAndSystemTray may fail in platforms other than ChromeOS because the | 289 // PopupAndSystemTray may fail in platforms other than ChromeOS because the |
298 // RootWindow's bound can be bigger than display::Display's work area so that | 290 // RootWindow's bound can be bigger than display::Display's work area so that |
299 // openingsystem tray doesn't affect at all the work area of popups. | 291 // openingsystem tray doesn't affect at all the work area of popups. |
300 TEST_P(WebNotificationTrayTest, PopupAndSystemTray) { | 292 TEST_F(WebNotificationTrayTest, PopupAndSystemTray) { |
301 TestItem* test_item = new TestItem; | 293 TestItem* test_item = new TestItem; |
302 GetSystemTray()->AddTrayItem(base::WrapUnique(test_item)); | 294 GetSystemTray()->AddTrayItem(base::WrapUnique(test_item)); |
303 | 295 |
304 AddNotification("test_id"); | 296 AddNotification("test_id"); |
305 EXPECT_TRUE(GetTray()->IsPopupVisible()); | 297 EXPECT_TRUE(GetTray()->IsPopupVisible()); |
306 int bottom = GetPopupWorkAreaBottom(); | 298 int bottom = GetPopupWorkAreaBottom(); |
307 | 299 |
308 // System tray is created, the popup's work area should be narrowed but still | 300 // System tray is created, the popup's work area should be narrowed but still |
309 // visible. | 301 // visible. |
310 GetSystemTray()->ShowDefaultView(BUBBLE_CREATE_NEW); | 302 GetSystemTray()->ShowDefaultView(BUBBLE_CREATE_NEW); |
(...skipping 15 matching lines...) Expand all Loading... |
326 int bottom_with_notification = GetPopupWorkAreaBottom(); | 318 int bottom_with_notification = GetPopupWorkAreaBottom(); |
327 EXPECT_GT(bottom, bottom_with_notification); | 319 EXPECT_GT(bottom, bottom_with_notification); |
328 EXPECT_LT(bottom_with_tray_notification, bottom_with_notification); | 320 EXPECT_LT(bottom_with_tray_notification, bottom_with_notification); |
329 | 321 |
330 // Close the system tray notifications. | 322 // Close the system tray notifications. |
331 GetSystemTray()->HideNotificationView(test_item); | 323 GetSystemTray()->HideNotificationView(test_item); |
332 EXPECT_TRUE(GetTray()->IsPopupVisible()); | 324 EXPECT_TRUE(GetTray()->IsPopupVisible()); |
333 EXPECT_EQ(bottom, GetPopupWorkAreaBottom()); | 325 EXPECT_EQ(bottom, GetPopupWorkAreaBottom()); |
334 } | 326 } |
335 | 327 |
336 TEST_P(WebNotificationTrayTest, PopupAndAutoHideShelf) { | 328 TEST_F(WebNotificationTrayTest, PopupAndAutoHideShelf) { |
337 AddNotification("test_id"); | 329 AddNotification("test_id"); |
338 EXPECT_TRUE(GetTray()->IsPopupVisible()); | 330 EXPECT_TRUE(GetTray()->IsPopupVisible()); |
339 int bottom = GetPopupWorkAreaBottom(); | 331 int bottom = GetPopupWorkAreaBottom(); |
340 | 332 |
341 // Shelf's auto-hide state won't be HIDDEN unless window exists. | 333 // Shelf's auto-hide state won't be HIDDEN unless window exists. |
342 std::unique_ptr<views::Widget> widget(CreateTestWidget()); | 334 std::unique_ptr<views::Widget> widget(CreateTestWidget()); |
343 WmShelf* shelf = GetPrimaryShelf(); | 335 WmShelf* shelf = GetPrimaryShelf(); |
344 shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS); | 336 shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS); |
345 | 337 |
346 EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, shelf->GetAutoHideState()); | 338 EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, shelf->GetAutoHideState()); |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
383 | 375 |
384 // Close the window again, which shows the shelf. | 376 // Close the window again, which shows the shelf. |
385 widget.reset(); | 377 widget.reset(); |
386 EXPECT_EQ(SHELF_AUTO_HIDE_SHOWN, shelf->GetAutoHideState()); | 378 EXPECT_EQ(SHELF_AUTO_HIDE_SHOWN, shelf->GetAutoHideState()); |
387 int bottom_shown_with_tray_notification = GetPopupWorkAreaBottom(); | 379 int bottom_shown_with_tray_notification = GetPopupWorkAreaBottom(); |
388 EXPECT_GT(bottom_hidden_with_tray_notification, | 380 EXPECT_GT(bottom_hidden_with_tray_notification, |
389 bottom_shown_with_tray_notification); | 381 bottom_shown_with_tray_notification); |
390 EXPECT_GT(bottom_auto_shown, bottom_shown_with_tray_notification); | 382 EXPECT_GT(bottom_auto_shown, bottom_shown_with_tray_notification); |
391 } | 383 } |
392 | 384 |
393 TEST_P(WebNotificationTrayTest, PopupAndFullscreen) { | 385 TEST_F(WebNotificationTrayTest, PopupAndFullscreen) { |
394 AddNotification("test_id"); | 386 AddNotification("test_id"); |
395 EXPECT_TRUE(IsPopupVisible()); | 387 EXPECT_TRUE(IsPopupVisible()); |
396 int bottom = GetPopupWorkAreaBottom(); | 388 int bottom = GetPopupWorkAreaBottom(); |
397 | 389 |
398 // Checks the work area for normal auto-hidden state. | 390 // Checks the work area for normal auto-hidden state. |
399 std::unique_ptr<views::Widget> widget(CreateTestWidget()); | 391 std::unique_ptr<views::Widget> widget(CreateTestWidget()); |
400 WmShelf* shelf = GetPrimaryShelf(); | 392 WmShelf* shelf = GetPrimaryShelf(); |
401 shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS); | 393 shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS); |
402 EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, shelf->GetAutoHideState()); | 394 EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, shelf->GetAutoHideState()); |
403 int bottom_auto_hidden = GetPopupWorkAreaBottom(); | 395 int bottom_auto_hidden = GetPopupWorkAreaBottom(); |
(...skipping 25 matching lines...) Expand all Loading... |
429 EXPECT_EQ(SHELF_AUTO_HIDE_SHOWN, shelf->GetAutoHideState()); | 421 EXPECT_EQ(SHELF_AUTO_HIDE_SHOWN, shelf->GetAutoHideState()); |
430 EXPECT_EQ(bottom, GetPopupWorkAreaBottom()); | 422 EXPECT_EQ(bottom, GetPopupWorkAreaBottom()); |
431 | 423 |
432 generator.MoveMouseTo( | 424 generator.MoveMouseTo( |
433 display::Screen::GetScreen()->GetPrimaryDisplay().bounds().CenterPoint()); | 425 display::Screen::GetScreen()->GetPrimaryDisplay().bounds().CenterPoint()); |
434 shelf->UpdateVisibilityState(); | 426 shelf->UpdateVisibilityState(); |
435 EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, shelf->GetAutoHideState()); | 427 EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, shelf->GetAutoHideState()); |
436 EXPECT_EQ(bottom_auto_hidden, GetPopupWorkAreaBottom()); | 428 EXPECT_EQ(bottom_auto_hidden, GetPopupWorkAreaBottom()); |
437 } | 429 } |
438 | 430 |
439 TEST_P(WebNotificationTrayTest, PopupAndSystemTrayMultiDisplay) { | 431 TEST_F(WebNotificationTrayTest, PopupAndSystemTrayMultiDisplay) { |
440 UpdateDisplay("800x600,600x400"); | 432 UpdateDisplay("800x600,600x400"); |
441 | 433 |
442 AddNotification("test_id"); | 434 AddNotification("test_id"); |
443 int bottom = GetPopupWorkAreaBottom(); | 435 int bottom = GetPopupWorkAreaBottom(); |
444 int bottom_second = GetPopupWorkAreaBottomForTray(GetSecondaryTray()); | 436 int bottom_second = GetPopupWorkAreaBottomForTray(GetSecondaryTray()); |
445 | 437 |
446 // System tray is created on the primary display. The popups in the secondary | 438 // System tray is created on the primary display. The popups in the secondary |
447 // tray aren't affected. | 439 // tray aren't affected. |
448 GetSystemTray()->ShowDefaultView(BUBBLE_CREATE_NEW); | 440 GetSystemTray()->ShowDefaultView(BUBBLE_CREATE_NEW); |
449 EXPECT_GT(bottom, GetPopupWorkAreaBottom()); | 441 EXPECT_GT(bottom, GetPopupWorkAreaBottom()); |
450 EXPECT_EQ(bottom_second, GetPopupWorkAreaBottomForTray(GetSecondaryTray())); | 442 EXPECT_EQ(bottom_second, GetPopupWorkAreaBottomForTray(GetSecondaryTray())); |
451 } | 443 } |
452 | 444 |
453 // Tests that there is visual feedback for touch presses. | |
454 TEST_P(WebNotificationTrayTest, TouchFeedback) { | |
455 // Touch feedback is not available in material mode. | |
456 if (MaterialDesignController::IsShelfMaterial()) | |
457 return; | |
458 | |
459 AddNotification("test_id"); | |
460 RunAllPendingInMessageLoop(); | |
461 WebNotificationTray* tray = GetTray(); | |
462 EXPECT_TRUE(tray->visible()); | |
463 | |
464 ui::test::EventGenerator& generator = GetEventGenerator(); | |
465 gfx::Point center_point = tray->GetBoundsInScreen().CenterPoint(); | |
466 generator.set_current_location(center_point); | |
467 | |
468 generator.PressTouch(); | |
469 EXPECT_TRUE(tray->is_active()); | |
470 | |
471 generator.ReleaseTouch(); | |
472 EXPECT_TRUE(tray->is_active()); | |
473 EXPECT_TRUE(tray->IsMessageCenterBubbleVisible()); | |
474 | |
475 generator.GestureTapAt(center_point); | |
476 EXPECT_FALSE(tray->is_active()); | |
477 EXPECT_FALSE(tray->IsMessageCenterBubbleVisible()); | |
478 } | |
479 | |
480 // Tests that while touch presses trigger visual feedback, that subsequent non | |
481 // tap gestures cancel the feedback without triggering the message center. | |
482 TEST_P(WebNotificationTrayTest, TouchFeedbackCancellation) { | |
483 // Touch feedback is not available in material mode. | |
484 if (MaterialDesignController::IsShelfMaterial()) | |
485 return; | |
486 | |
487 AddNotification("test_id"); | |
488 RunAllPendingInMessageLoop(); | |
489 WebNotificationTray* tray = GetTray(); | |
490 EXPECT_TRUE(tray->visible()); | |
491 | |
492 ui::test::EventGenerator& generator = GetEventGenerator(); | |
493 gfx::Rect bounds = tray->GetBoundsInScreen(); | |
494 gfx::Point center_point = bounds.CenterPoint(); | |
495 generator.set_current_location(center_point); | |
496 | |
497 generator.PressTouch(); | |
498 EXPECT_TRUE(tray->is_active()); | |
499 | |
500 gfx::Point out_of_bounds(bounds.x() - 1, center_point.y()); | |
501 generator.MoveTouch(out_of_bounds); | |
502 EXPECT_FALSE(tray->is_active()); | |
503 | |
504 generator.ReleaseTouch(); | |
505 EXPECT_FALSE(tray->is_active()); | |
506 EXPECT_FALSE(tray->IsMessageCenterBubbleVisible()); | |
507 } | |
508 | |
509 } // namespace ash | 445 } // namespace ash |
OLD | NEW |