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