Update To 11.40.268.0
[platform/framework/web/crosswalk.git] / src / ash / system / web_notification / web_notification_tray_unittest.cc
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
3 // found in the LICENSE file.
4
5 #include "ash/system/web_notification/web_notification_tray.h"
6
7 #include <vector>
8
9 #include "ash/display/display_manager.h"
10 #include "ash/root_window_controller.h"
11 #include "ash/shelf/shelf_layout_manager.h"
12 #include "ash/shelf/shelf_widget.h"
13 #include "ash/shell.h"
14 #include "ash/system/status_area_widget.h"
15 #include "ash/system/tray/system_tray.h"
16 #include "ash/system/tray/system_tray_item.h"
17 #include "ash/system/web_notification/ash_popup_alignment_delegate.h"
18 #include "ash/test/ash_test_base.h"
19 #include "ash/test/status_area_widget_test_helper.h"
20 #include "ash/test/test_system_tray_delegate.h"
21 #include "ash/wm/window_state.h"
22 #include "base/command_line.h"
23 #include "base/strings/stringprintf.h"
24 #include "base/strings/utf_string_conversions.h"
25 #include "ui/aura/client/aura_constants.h"
26 #include "ui/aura/window.h"
27 #include "ui/base/ui_base_switches.h"
28 #include "ui/events/event.h"
29 #include "ui/events/test/event_generator.h"
30 #include "ui/gfx/display.h"
31 #include "ui/gfx/point.h"
32 #include "ui/gfx/rect.h"
33 #include "ui/gfx/screen.h"
34 #include "ui/message_center/message_center_style.h"
35 #include "ui/message_center/message_center_tray.h"
36 #include "ui/message_center/notification_list.h"
37 #include "ui/message_center/notification_types.h"
38 #include "ui/message_center/views/message_center_bubble.h"
39 #include "ui/message_center/views/message_popup_collection.h"
40 #include "ui/views/controls/label.h"
41 #include "ui/views/layout/fill_layout.h"
42 #include "ui/views/view.h"
43 #include "ui/views/widget/widget.h"
44
45 namespace ash {
46
47 namespace {
48
49 WebNotificationTray* GetTray() {
50   return StatusAreaWidgetTestHelper::GetStatusAreaWidget()->
51       web_notification_tray();
52 }
53
54 WebNotificationTray* GetSecondaryTray() {
55   StatusAreaWidget* status_area_widget =
56       StatusAreaWidgetTestHelper::GetSecondaryStatusAreaWidget();
57   if (status_area_widget)
58     return status_area_widget->web_notification_tray();
59   return NULL;
60 }
61
62 message_center::MessageCenter* GetMessageCenter() {
63   return GetTray()->message_center();
64 }
65
66 SystemTray* GetSystemTray() {
67   return StatusAreaWidgetTestHelper::GetStatusAreaWidget()->system_tray();
68 }
69
70 // Trivial item implementation for testing PopupAndSystemTray test case.
71 class TestItem : public SystemTrayItem {
72  public:
73   TestItem() : SystemTrayItem(GetSystemTray()) {}
74
75   views::View* CreateDefaultView(user::LoginStatus status) override {
76     views::View* default_view = new views::View;
77     default_view->SetLayoutManager(new views::FillLayout);
78     default_view->AddChildView(new views::Label(base::UTF8ToUTF16("Default")));
79     return default_view;
80   }
81
82   views::View* CreateNotificationView(user::LoginStatus status) override {
83     return new views::View;
84   }
85
86  private:
87   DISALLOW_COPY_AND_ASSIGN(TestItem);
88 };
89
90 }  // namespace
91
92 class WebNotificationTrayTest : public test::AshTestBase {
93  public:
94   WebNotificationTrayTest() {}
95   ~WebNotificationTrayTest() override {}
96
97   void SetUp() override {
98     base::CommandLine::ForCurrentProcess()->AppendSwitch(
99         switches::kEnableTouchFeedback);
100     test::AshTestBase::SetUp();
101   }
102
103   void TearDown() override {
104     GetMessageCenter()->RemoveAllNotifications(false);
105     test::AshTestBase::TearDown();
106   }
107
108  protected:
109   void AddNotification(const std::string& id) {
110     scoped_ptr<message_center::Notification> notification;
111     notification.reset(new message_center::Notification(
112         message_center::NOTIFICATION_TYPE_SIMPLE,
113         id,
114         base::ASCIIToUTF16("Test Web Notification"),
115         base::ASCIIToUTF16("Notification message body."),
116         gfx::Image(),
117         base::ASCIIToUTF16("www.test.org"),
118         message_center::NotifierId(),
119         message_center::RichNotificationData(),
120         NULL /* delegate */));
121     GetMessageCenter()->AddNotification(notification.Pass());
122   }
123
124   void UpdateNotification(const std::string& old_id,
125                           const std::string& new_id) {
126     scoped_ptr<message_center::Notification> notification;
127     notification.reset(new message_center::Notification(
128         message_center::NOTIFICATION_TYPE_SIMPLE,
129         new_id,
130         base::ASCIIToUTF16("Updated Web Notification"),
131         base::ASCIIToUTF16("Updated message body."),
132         gfx::Image(),
133         base::ASCIIToUTF16("www.test.org"),
134         message_center::NotifierId(),
135         message_center::RichNotificationData(),
136         NULL /* delegate */));
137     GetMessageCenter()->UpdateNotification(old_id, notification.Pass());
138   }
139
140   void RemoveNotification(const std::string& id) {
141     GetMessageCenter()->RemoveNotification(id, false);
142   }
143
144   views::Widget* GetWidget() {
145     return GetTray()->GetWidget();
146   }
147
148   int GetPopupWorkAreaBottom() {
149     return GetPopupWorkAreaBottomForTray(GetTray());
150   }
151
152   int GetPopupWorkAreaBottomForTray(WebNotificationTray* tray) {
153     return tray->popup_alignment_delegate_->GetWorkAreaBottom();
154   }
155
156   bool IsPopupVisible() {
157     return GetTray()->IsPopupVisible();
158   }
159
160  private:
161   DISALLOW_COPY_AND_ASSIGN(WebNotificationTrayTest);
162 };
163
164 TEST_F(WebNotificationTrayTest, WebNotifications) {
165   // TODO(mukai): move this test case to ui/message_center.
166   ASSERT_TRUE(GetWidget());
167
168   // Add a notification.
169   AddNotification("test_id1");
170   EXPECT_EQ(1u, GetMessageCenter()->NotificationCount());
171   EXPECT_TRUE(GetMessageCenter()->FindVisibleNotificationById("test_id1"));
172   AddNotification("test_id2");
173   AddNotification("test_id2");
174   EXPECT_EQ(2u, GetMessageCenter()->NotificationCount());
175   EXPECT_TRUE(GetMessageCenter()->FindVisibleNotificationById("test_id2"));
176
177   // Ensure that updating a notification does not affect the count.
178   UpdateNotification("test_id2", "test_id3");
179   UpdateNotification("test_id3", "test_id3");
180   EXPECT_EQ(2u, GetMessageCenter()->NotificationCount());
181   EXPECT_FALSE(GetMessageCenter()->FindVisibleNotificationById("test_id2"));
182
183   // Ensure that Removing the first notification removes it from the tray.
184   RemoveNotification("test_id1");
185   EXPECT_FALSE(GetMessageCenter()->FindVisibleNotificationById("test_id1"));
186   EXPECT_EQ(1u, GetMessageCenter()->NotificationCount());
187
188   // Remove the remianing notification.
189   RemoveNotification("test_id3");
190   EXPECT_EQ(0u, GetMessageCenter()->NotificationCount());
191   EXPECT_FALSE(GetMessageCenter()->FindVisibleNotificationById("test_id3"));
192 }
193
194 TEST_F(WebNotificationTrayTest, WebNotificationPopupBubble) {
195   // TODO(mukai): move this test case to ui/message_center.
196   ASSERT_TRUE(GetWidget());
197
198   // Adding a notification should show the popup bubble.
199   AddNotification("test_id1");
200   EXPECT_TRUE(GetTray()->IsPopupVisible());
201
202   // Updating a notification should not hide the popup bubble.
203   AddNotification("test_id2");
204   UpdateNotification("test_id2", "test_id3");
205   EXPECT_TRUE(GetTray()->IsPopupVisible());
206
207   // Removing the first notification should not hide the popup bubble.
208   RemoveNotification("test_id1");
209   EXPECT_TRUE(GetTray()->IsPopupVisible());
210
211   // Removing the visible notification should hide the popup bubble.
212   RemoveNotification("test_id3");
213   EXPECT_FALSE(GetTray()->IsPopupVisible());
214
215   // Now test that we can show multiple popups and then show the message center.
216   AddNotification("test_id4");
217   AddNotification("test_id5");
218   EXPECT_TRUE(GetTray()->IsPopupVisible());
219
220   GetTray()->message_center_tray_->ShowMessageCenterBubble();
221   GetTray()->message_center_tray_->HideMessageCenterBubble();
222
223   EXPECT_FALSE(GetTray()->IsPopupVisible());
224 }
225
226 using message_center::NotificationList;
227
228
229 // Flakily fails. http://crbug.com/229791
230 TEST_F(WebNotificationTrayTest, DISABLED_ManyMessageCenterNotifications) {
231   // Add the max visible notifications +1, ensure the correct visible number.
232   size_t notifications_to_add =
233       message_center::kMaxVisibleMessageCenterNotifications + 1;
234   for (size_t i = 0; i < notifications_to_add; ++i) {
235     std::string id = base::StringPrintf("test_id%d", static_cast<int>(i));
236     AddNotification(id);
237   }
238   bool shown = GetTray()->message_center_tray_->ShowMessageCenterBubble();
239   EXPECT_TRUE(shown);
240   RunAllPendingInMessageLoop();
241   EXPECT_TRUE(GetTray()->message_center_bubble() != NULL);
242   EXPECT_EQ(notifications_to_add,
243             GetMessageCenter()->NotificationCount());
244   EXPECT_EQ(message_center::kMaxVisibleMessageCenterNotifications,
245             GetTray()->GetMessageCenterBubbleForTest()->
246                 NumMessageViewsForTest());
247 }
248
249 // Flakily times out. http://crbug.com/229792
250 TEST_F(WebNotificationTrayTest, DISABLED_ManyPopupNotifications) {
251   // Add the max visible popup notifications +1, ensure the correct num visible.
252   size_t notifications_to_add =
253       message_center::kMaxVisiblePopupNotifications + 1;
254   for (size_t i = 0; i < notifications_to_add; ++i) {
255     std::string id = base::StringPrintf("test_id%d", static_cast<int>(i));
256     AddNotification(id);
257   }
258   GetTray()->ShowPopups();
259   EXPECT_TRUE(GetTray()->IsPopupVisible());
260   EXPECT_EQ(notifications_to_add,
261             GetMessageCenter()->NotificationCount());
262   NotificationList::PopupNotifications popups =
263       GetMessageCenter()->GetPopupNotifications();
264   EXPECT_EQ(message_center::kMaxVisiblePopupNotifications, popups.size());
265 }
266
267 #if defined(OS_CHROMEOS)
268 // Display notification is ChromeOS only.
269 #define MAYBE_PopupShownOnBothDisplays PopupShownOnBothDisplays
270 #define MAYBE_PopupAndSystemTrayMultiDisplay PopupAndSystemTrayMultiDisplay
271 #else
272 #define MAYBE_PopupShownOnBothDisplays DISABLED_PopupShownOnBothDisplays
273 #define MAYBE_PopupAndSystemTrayMultiDisplay \
274   DISABLED_PopupAndSystemTrayMultiDisplay
275 #endif
276
277 // Verifies if the notification appears on both displays when extended mode.
278 TEST_F(WebNotificationTrayTest, MAYBE_PopupShownOnBothDisplays) {
279   if (!SupportsMultipleDisplays())
280     return;
281
282   // Enables to appear the notification for display changes.
283   test::TestSystemTrayDelegate* tray_delegate =
284       static_cast<test::TestSystemTrayDelegate*>(
285           Shell::GetInstance()->system_tray_delegate());
286   tray_delegate->set_should_show_display_notification(true);
287
288   UpdateDisplay("400x400,200x200");
289   // UpdateDisplay() creates the display notifications, so popup is visible.
290   EXPECT_TRUE(GetTray()->IsPopupVisible());
291   WebNotificationTray* secondary_tray = GetSecondaryTray();
292   ASSERT_TRUE(secondary_tray);
293   EXPECT_TRUE(secondary_tray->IsPopupVisible());
294
295   // Transition to mirroring and then back to extended display, which recreates
296   // root window controller and shelf with having notifications. This code
297   // verifies it doesn't cause crash and popups are still visible. See
298   // http://crbug.com/263664
299   DisplayManager* display_manager = Shell::GetInstance()->display_manager();
300
301   display_manager->SetSecondDisplayMode(DisplayManager::MIRRORING);
302   UpdateDisplay("400x400,200x200");
303   EXPECT_TRUE(GetTray()->IsPopupVisible());
304   EXPECT_FALSE(GetSecondaryTray());
305
306   display_manager->SetSecondDisplayMode(DisplayManager::EXTENDED);
307   UpdateDisplay("400x400,200x200");
308   EXPECT_TRUE(GetTray()->IsPopupVisible());
309   secondary_tray = GetSecondaryTray();
310   ASSERT_TRUE(secondary_tray);
311   EXPECT_TRUE(secondary_tray->IsPopupVisible());
312 }
313
314 #if defined(OS_CHROMEOS)
315 // PopupAndSystemTray may fail in platforms other than ChromeOS because the
316 // RootWindow's bound can be bigger than gfx::Display's work area so that
317 // openingsystem tray doesn't affect at all the work area of popups.
318 #define MAYBE_PopupAndSystemTray PopupAndSystemTray
319 #define MAYBE_PopupAndAutoHideShelf PopupAndAutoHideShelf
320 #define MAYBE_PopupAndFullscreen PopupAndFullscreen
321 #else
322 #define MAYBE_PopupAndSystemTray DISABLED_PopupAndSystemTray
323 #define MAYBE_PopupAndAutoHideShelf DISABLED_PopupAndAutoHideShelf
324 #define MAYBE_PopupAndFullscreen DISABLED_PopupAndFullscreen
325 #endif
326
327 TEST_F(WebNotificationTrayTest, MAYBE_PopupAndSystemTray) {
328   TestItem* test_item = new TestItem;
329   GetSystemTray()->AddTrayItem(test_item);
330
331   AddNotification("test_id");
332   EXPECT_TRUE(GetTray()->IsPopupVisible());
333   int bottom = GetPopupWorkAreaBottom();
334
335   // System tray is created, the popup's work area should be narrowed but still
336   // visible.
337   GetSystemTray()->ShowDefaultView(BUBBLE_CREATE_NEW);
338   EXPECT_TRUE(GetTray()->IsPopupVisible());
339   int bottom_with_tray = GetPopupWorkAreaBottom();
340   EXPECT_GT(bottom, bottom_with_tray);
341
342   // System tray notification is also created, the popup's work area is narrowed
343   // even more, but still visible.
344   GetSystemTray()->ShowNotificationView(test_item);
345   EXPECT_TRUE(GetTray()->IsPopupVisible());
346   int bottom_with_tray_notification = GetPopupWorkAreaBottom();
347   EXPECT_GT(bottom, bottom_with_tray_notification);
348   EXPECT_GT(bottom_with_tray, bottom_with_tray_notification);
349
350   // Close system tray, only system tray notifications.
351   GetSystemTray()->ClickedOutsideBubble();
352   EXPECT_TRUE(GetTray()->IsPopupVisible());
353   int bottom_with_notification = GetPopupWorkAreaBottom();
354   EXPECT_GT(bottom, bottom_with_notification);
355   EXPECT_LT(bottom_with_tray_notification, bottom_with_notification);
356
357   // Close the system tray notifications.
358   GetSystemTray()->HideNotificationView(test_item);
359   EXPECT_TRUE(GetTray()->IsPopupVisible());
360   EXPECT_EQ(bottom, GetPopupWorkAreaBottom());
361 }
362
363 TEST_F(WebNotificationTrayTest, MAYBE_PopupAndAutoHideShelf) {
364   AddNotification("test_id");
365   EXPECT_TRUE(GetTray()->IsPopupVisible());
366   int bottom = GetPopupWorkAreaBottom();
367
368   // Shelf's auto-hide state won't be HIDDEN unless window exists.
369   scoped_ptr<aura::Window> window(
370       CreateTestWindowInShellWithBounds(gfx::Rect(1, 2, 3, 4)));
371   ShelfLayoutManager* shelf =
372       Shell::GetPrimaryRootWindowController()->GetShelfLayoutManager();
373   shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS);
374
375   EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, shelf->auto_hide_state());
376   int bottom_auto_hidden = GetPopupWorkAreaBottom();
377   EXPECT_LT(bottom, bottom_auto_hidden);
378
379   // Close the window, which shows the shelf.
380   window.reset();
381   EXPECT_EQ(SHELF_AUTO_HIDE_SHOWN, shelf->auto_hide_state());
382   int bottom_auto_shown = GetPopupWorkAreaBottom();
383   EXPECT_EQ(bottom, bottom_auto_shown);
384
385   // Create the system tray during auto-hide.
386   window.reset(CreateTestWindowInShellWithBounds(gfx::Rect(1, 2, 3, 4)));
387   TestItem* test_item = new TestItem;
388   GetSystemTray()->AddTrayItem(test_item);
389   GetSystemTray()->ShowDefaultView(BUBBLE_CREATE_NEW);
390
391   EXPECT_EQ(SHELF_AUTO_HIDE_SHOWN, shelf->auto_hide_state());
392   EXPECT_TRUE(GetTray()->IsPopupVisible());
393   int bottom_with_tray = GetPopupWorkAreaBottom();
394   EXPECT_GT(bottom_auto_shown, bottom_with_tray);
395
396   // Create tray notification.
397   GetSystemTray()->ShowNotificationView(test_item);
398   EXPECT_EQ(SHELF_AUTO_HIDE_SHOWN, shelf->auto_hide_state());
399   int bottom_with_tray_notification = GetPopupWorkAreaBottom();
400   EXPECT_GT(bottom_with_tray, bottom_with_tray_notification);
401
402   // Close the system tray.
403   GetSystemTray()->ClickedOutsideBubble();
404   shelf->UpdateAutoHideState();
405   RunAllPendingInMessageLoop();
406   EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, shelf->auto_hide_state());
407   int bottom_hidden_with_tray_notification = GetPopupWorkAreaBottom();
408   EXPECT_LT(bottom_with_tray_notification,
409             bottom_hidden_with_tray_notification);
410   EXPECT_GT(bottom_auto_hidden, bottom_hidden_with_tray_notification);
411
412   // Close the window again, which shows the shelf.
413   window.reset();
414   EXPECT_EQ(SHELF_AUTO_HIDE_SHOWN, shelf->auto_hide_state());
415   int bottom_shown_with_tray_notification = GetPopupWorkAreaBottom();
416   EXPECT_GT(bottom_hidden_with_tray_notification,
417             bottom_shown_with_tray_notification);
418   EXPECT_GT(bottom_auto_shown, bottom_shown_with_tray_notification);
419 }
420
421 TEST_F(WebNotificationTrayTest, MAYBE_PopupAndFullscreen) {
422   AddNotification("test_id");
423   EXPECT_TRUE(IsPopupVisible());
424   int bottom = GetPopupWorkAreaBottom();
425
426   // Checks the work area for normal auto-hidden state.
427   scoped_ptr<aura::Window> window(
428       CreateTestWindowInShellWithBounds(gfx::Rect(1, 2, 3, 4)));
429   ShelfLayoutManager* shelf =
430       Shell::GetPrimaryRootWindowController()->GetShelfLayoutManager();
431   shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS);
432   EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, shelf->auto_hide_state());
433   int bottom_auto_hidden = GetPopupWorkAreaBottom();
434   shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_NEVER);
435
436   // Put |window| into fullscreen without forcing the shelf to hide. Currently,
437   // this is used by immersive fullscreen and forces the shelf to be auto
438   // hidden.
439   wm::GetWindowState(window.get())->set_hide_shelf_when_fullscreen(false);
440   window->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_FULLSCREEN);
441   RunAllPendingInMessageLoop();
442
443   // The work area for auto-hidden status of fullscreen is a bit larger
444   // since it doesn't even have the 3-pixel width.
445   EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, shelf->auto_hide_state());
446   int bottom_fullscreen_hidden = GetPopupWorkAreaBottom();
447   EXPECT_EQ(bottom_auto_hidden, bottom_fullscreen_hidden);
448
449   // Move the mouse cursor at the bottom, which shows the shelf.
450   ui::test::EventGenerator generator(Shell::GetPrimaryRootWindow());
451   gfx::Point bottom_right =
452       Shell::GetScreen()->GetPrimaryDisplay().bounds().bottom_right();
453   bottom_right.Offset(-1, -1);
454   generator.MoveMouseTo(bottom_right);
455   shelf->UpdateAutoHideStateNow();
456   EXPECT_EQ(SHELF_AUTO_HIDE_SHOWN, shelf->auto_hide_state());
457   EXPECT_EQ(bottom, GetPopupWorkAreaBottom());
458
459   generator.MoveMouseTo(
460       Shell::GetScreen()->GetPrimaryDisplay().bounds().CenterPoint());
461   shelf->UpdateAutoHideStateNow();
462   EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, shelf->auto_hide_state());
463   EXPECT_EQ(bottom_auto_hidden, GetPopupWorkAreaBottom());
464 }
465
466 TEST_F(WebNotificationTrayTest, MAYBE_PopupAndSystemTrayMultiDisplay) {
467   UpdateDisplay("800x600,600x400");
468
469   AddNotification("test_id");
470   int bottom = GetPopupWorkAreaBottom();
471   int bottom_second = GetPopupWorkAreaBottomForTray(GetSecondaryTray());
472
473   // System tray is created on the primary display. The popups in the secondary
474   // tray aren't affected.
475   GetSystemTray()->ShowDefaultView(BUBBLE_CREATE_NEW);
476   EXPECT_GT(bottom, GetPopupWorkAreaBottom());
477   EXPECT_EQ(bottom_second, GetPopupWorkAreaBottomForTray(GetSecondaryTray()));
478 }
479
480 // TODO(jonross): This test is failing on ASAN bots, fix the failure and
481 // re-enable. (crbug.com/411881)
482 // TODO(jonross): Replace manually creating TouchEvent with
483 // EventGenerator.PressTouch/ReleaseTouch. Currently they set a width on the
484 // touch event causing the gesture recognizer to target a different view.
485 #if defined(OS_CHROMEOS)
486 // Tests that there is visual feedback for touch presses.
487 TEST_F(WebNotificationTrayTest, DISABLED_TouchFeedback) {
488   AddNotification("test_id");
489   RunAllPendingInMessageLoop();
490   WebNotificationTray* tray = GetTray();
491   EXPECT_TRUE(tray->visible());
492
493   ui::test::EventGenerator generator(Shell::GetPrimaryRootWindow());
494   const int touch_id = 0;
495   gfx::Point center_point = tray->GetBoundsInScreen().CenterPoint();
496
497   ui::TouchEvent press(ui::ET_TOUCH_PRESSED, center_point, touch_id,
498                        generator.Now());
499   generator.Dispatch(&press);
500   RunAllPendingInMessageLoop();
501   EXPECT_TRUE(tray->draw_background_as_active());
502
503   ui::TouchEvent release(ui::ET_TOUCH_RELEASED, center_point, touch_id,
504       press.time_stamp() + base::TimeDelta::FromMilliseconds(50));
505   generator.Dispatch(&release);
506   RunAllPendingInMessageLoop();
507   EXPECT_TRUE(tray->draw_background_as_active());
508   EXPECT_TRUE(tray->IsMessageCenterBubbleVisible());
509
510   generator.GestureTapAt(center_point);
511   RunAllPendingInMessageLoop();
512   EXPECT_FALSE(tray->draw_background_as_active());
513   EXPECT_FALSE(tray->IsMessageCenterBubbleVisible());
514 }
515
516 // TODO(jonross): This test is failing on ASAN bots, fix the failure and
517 // re-enable. (crbug.com/411881)
518 // Tests that while touch presses trigger visual feedback, that subsequent non
519 // tap gestures cancel the feedback without triggering the message center.
520 TEST_F(WebNotificationTrayTest, DISABLED_TouchFeedbackCancellation) {
521   AddNotification("test_id");
522   RunAllPendingInMessageLoop();
523   WebNotificationTray* tray = GetTray();
524   EXPECT_TRUE(tray->visible());
525
526   ui::test::EventGenerator generator(Shell::GetPrimaryRootWindow());
527   const int touch_id = 0;
528   gfx::Rect bounds = tray->GetBoundsInScreen();
529   gfx::Point center_point = bounds.CenterPoint();
530
531   ui::TouchEvent press(ui::ET_TOUCH_PRESSED, center_point, touch_id,
532                        generator.Now());
533   generator.Dispatch(&press);
534   RunAllPendingInMessageLoop();
535   EXPECT_TRUE(tray->draw_background_as_active());
536
537   gfx::Point out_of_bounds(bounds.x() - 1, center_point.y());
538   ui::TouchEvent move(ui::ET_TOUCH_MOVED, out_of_bounds, touch_id,
539                       press.time_stamp()+base::TimeDelta::FromMilliseconds(50));
540   generator.Dispatch(&move);
541   RunAllPendingInMessageLoop();
542   EXPECT_FALSE(tray->draw_background_as_active());
543
544   ui::TouchEvent release(ui::ET_TOUCH_RELEASED, out_of_bounds, touch_id,
545       move.time_stamp()+base::TimeDelta::FromMilliseconds(50));
546   generator.Dispatch(&release);
547   RunAllPendingInMessageLoop();
548   EXPECT_FALSE(tray->draw_background_as_active());
549   EXPECT_FALSE(tray->IsMessageCenterBubbleVisible());
550 }
551
552 #endif  // OS_CHROMEOS
553
554 }  // namespace ash