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/web_notification/web_notification_tray.h" | 5 #include "ash/system/web_notification/web_notification_tray.h" |
6 | 6 |
7 #include <vector> | 7 #include <vector> |
8 | 8 |
9 #include "ash/ash_switches.h" | |
9 #include "ash/display/display_manager.h" | 10 #include "ash/display/display_manager.h" |
10 #include "ash/root_window_controller.h" | 11 #include "ash/root_window_controller.h" |
11 #include "ash/shelf/shelf_layout_manager.h" | 12 #include "ash/shelf/shelf_layout_manager.h" |
12 #include "ash/shelf/shelf_widget.h" | 13 #include "ash/shelf/shelf_widget.h" |
13 #include "ash/shell.h" | 14 #include "ash/shell.h" |
14 #include "ash/system/status_area_widget.h" | 15 #include "ash/system/status_area_widget.h" |
15 #include "ash/system/tray/system_tray.h" | 16 #include "ash/system/tray/system_tray.h" |
16 #include "ash/system/tray/system_tray_item.h" | 17 #include "ash/system/tray/system_tray_item.h" |
17 #include "ash/system/web_notification/ash_popup_alignment_delegate.h" | 18 #include "ash/system/web_notification/ash_popup_alignment_delegate.h" |
18 #include "ash/test/ash_test_base.h" | 19 #include "ash/test/ash_test_base.h" |
19 #include "ash/test/status_area_widget_test_helper.h" | 20 #include "ash/test/status_area_widget_test_helper.h" |
20 #include "ash/test/test_system_tray_delegate.h" | 21 #include "ash/test/test_system_tray_delegate.h" |
21 #include "ash/wm/window_state.h" | 22 #include "ash/wm/window_state.h" |
23 #include "base/command_line.h" | |
22 #include "base/strings/stringprintf.h" | 24 #include "base/strings/stringprintf.h" |
23 #include "base/strings/utf_string_conversions.h" | 25 #include "base/strings/utf_string_conversions.h" |
24 #include "ui/aura/client/aura_constants.h" | 26 #include "ui/aura/client/aura_constants.h" |
25 #include "ui/aura/window.h" | 27 #include "ui/aura/window.h" |
28 #include "ui/events/event.h" | |
26 #include "ui/events/test/event_generator.h" | 29 #include "ui/events/test/event_generator.h" |
27 #include "ui/gfx/display.h" | 30 #include "ui/gfx/display.h" |
31 #include "ui/gfx/point.h" | |
32 #include "ui/gfx/rect.h" | |
28 #include "ui/gfx/screen.h" | 33 #include "ui/gfx/screen.h" |
29 #include "ui/message_center/message_center_style.h" | 34 #include "ui/message_center/message_center_style.h" |
30 #include "ui/message_center/message_center_tray.h" | 35 #include "ui/message_center/message_center_tray.h" |
31 #include "ui/message_center/notification_list.h" | 36 #include "ui/message_center/notification_list.h" |
32 #include "ui/message_center/notification_types.h" | 37 #include "ui/message_center/notification_types.h" |
33 #include "ui/message_center/views/message_center_bubble.h" | 38 #include "ui/message_center/views/message_center_bubble.h" |
34 #include "ui/message_center/views/message_popup_collection.h" | 39 #include "ui/message_center/views/message_popup_collection.h" |
35 #include "ui/views/controls/label.h" | 40 #include "ui/views/controls/label.h" |
36 #include "ui/views/layout/fill_layout.h" | 41 #include "ui/views/layout/fill_layout.h" |
37 #include "ui/views/view.h" | 42 #include "ui/views/view.h" |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
83 DISALLOW_COPY_AND_ASSIGN(TestItem); | 88 DISALLOW_COPY_AND_ASSIGN(TestItem); |
84 }; | 89 }; |
85 | 90 |
86 } // namespace | 91 } // namespace |
87 | 92 |
88 class WebNotificationTrayTest : public test::AshTestBase { | 93 class WebNotificationTrayTest : public test::AshTestBase { |
89 public: | 94 public: |
90 WebNotificationTrayTest() {} | 95 WebNotificationTrayTest() {} |
91 virtual ~WebNotificationTrayTest() {} | 96 virtual ~WebNotificationTrayTest() {} |
92 | 97 |
98 #if defined(OS_CHROMEOS) | |
99 virtual void SetUp() OVERRIDE { | |
100 CommandLine::ForCurrentProcess()->AppendSwitch( | |
101 switches::kAshEnableTouchViewTouchFeedback); | |
102 test::AshTestBase::SetUp(); | |
103 } | |
104 #endif | |
105 | |
93 virtual void TearDown() OVERRIDE { | 106 virtual void TearDown() OVERRIDE { |
94 GetMessageCenter()->RemoveAllNotifications(false); | 107 GetMessageCenter()->RemoveAllNotifications(false); |
95 test::AshTestBase::TearDown(); | 108 test::AshTestBase::TearDown(); |
96 } | 109 } |
97 | 110 |
98 protected: | 111 protected: |
99 void AddNotification(const std::string& id) { | 112 void AddNotification(const std::string& id) { |
100 scoped_ptr<message_center::Notification> notification; | 113 scoped_ptr<message_center::Notification> notification; |
101 notification.reset(new message_center::Notification( | 114 notification.reset(new message_center::Notification( |
102 message_center::NOTIFICATION_TYPE_SIMPLE, | 115 message_center::NOTIFICATION_TYPE_SIMPLE, |
(...skipping 357 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
460 int bottom = GetPopupWorkAreaBottom(); | 473 int bottom = GetPopupWorkAreaBottom(); |
461 int bottom_second = GetPopupWorkAreaBottomForTray(GetSecondaryTray()); | 474 int bottom_second = GetPopupWorkAreaBottomForTray(GetSecondaryTray()); |
462 | 475 |
463 // System tray is created on the primary display. The popups in the secondary | 476 // System tray is created on the primary display. The popups in the secondary |
464 // tray aren't affected. | 477 // tray aren't affected. |
465 GetSystemTray()->ShowDefaultView(BUBBLE_CREATE_NEW); | 478 GetSystemTray()->ShowDefaultView(BUBBLE_CREATE_NEW); |
466 EXPECT_GT(bottom, GetPopupWorkAreaBottom()); | 479 EXPECT_GT(bottom, GetPopupWorkAreaBottom()); |
467 EXPECT_EQ(bottom_second, GetPopupWorkAreaBottomForTray(GetSecondaryTray())); | 480 EXPECT_EQ(bottom_second, GetPopupWorkAreaBottomForTray(GetSecondaryTray())); |
468 } | 481 } |
469 | 482 |
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, MaximizeModeTouchFeedback) { | |
flackr
2014/09/03 13:42:07
Just TouchFeedback, the feature doesn't need to be
jonross
2014/09/03 15:48:21
Missed that. Done.
jonross
2014/09/03 15:48:21
Missed that.
| |
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)); | |
flackr
2014/09/03 13:42:07
nit: spaces around operator.
jonross
2014/09/03 15:48:21
Done.
| |
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 // Tests that while touch presses trigger visual feedback, that subsequent non | |
518 // tap gestures cancel the feedback without triggering the message center. | |
519 TEST_F(WebNotificationTrayTest, TouchFeedbackCancellation) { | |
520 AddNotification("test_id"); | |
521 RunAllPendingInMessageLoop(); | |
522 WebNotificationTray* tray = GetTray(); | |
523 EXPECT_TRUE(tray->visible()); | |
524 | |
525 ui::test::EventGenerator generator(Shell::GetPrimaryRootWindow()); | |
526 const int touch_id = 0; | |
527 gfx::Rect bounds = tray->GetBoundsInScreen(); | |
528 gfx::Point center_point = bounds.CenterPoint(); | |
529 | |
530 ui::TouchEvent press(ui::ET_TOUCH_PRESSED, center_point, touch_id, | |
531 generator.Now()); | |
532 generator.Dispatch(&press); | |
533 RunAllPendingInMessageLoop(); | |
534 EXPECT_TRUE(tray->draw_background_as_active()); | |
535 | |
536 gfx::Point out_of_bounds(bounds.x() - 1, center_point.y()); | |
537 ui::TouchEvent move(ui::ET_TOUCH_MOVED, out_of_bounds, touch_id, | |
538 press.time_stamp()+base::TimeDelta::FromMilliseconds(50)); | |
539 generator.Dispatch(&move); | |
flackr
2014/09/03 13:42:07
It should be inactive before the touch release rig
jonross
2014/09/03 15:48:21
Done.
| |
540 ui::TouchEvent release(ui::ET_TOUCH_RELEASED, out_of_bounds, touch_id, | |
541 move.time_stamp()+base::TimeDelta::FromMilliseconds(50)); | |
542 generator.Dispatch(&release); | |
543 RunAllPendingInMessageLoop(); | |
544 EXPECT_FALSE(tray->draw_background_as_active()); | |
545 EXPECT_FALSE(tray->IsMessageCenterBubbleVisible()); | |
546 } | |
547 | |
548 #endif // OS_CHROMEOS | |
549 | |
470 } // namespace ash | 550 } // namespace ash |
OLD | NEW |