Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(13)

Side by Side Diff: ash/system/web_notification/web_notification_tray_unittest.cc

Issue 515573002: Use active state on touch start for tray icons (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Update test histogram Created 6 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « ash/system/tray/tray_background_view.cc ('k') | chrome/app/generated_resources.grd » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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 virtual void SetUp() OVERRIDE {
99 CommandLine::ForCurrentProcess()->AppendSwitch(
100 switches::kAshEnableTouchViewTouchFeedback);
101 test::AshTestBase::SetUp();
102 }
103
93 virtual void TearDown() OVERRIDE { 104 virtual void TearDown() OVERRIDE {
94 GetMessageCenter()->RemoveAllNotifications(false); 105 GetMessageCenter()->RemoveAllNotifications(false);
95 test::AshTestBase::TearDown(); 106 test::AshTestBase::TearDown();
96 } 107 }
97 108
98 protected: 109 protected:
99 void AddNotification(const std::string& id) { 110 void AddNotification(const std::string& id) {
100 scoped_ptr<message_center::Notification> notification; 111 scoped_ptr<message_center::Notification> notification;
101 notification.reset(new message_center::Notification( 112 notification.reset(new message_center::Notification(
102 message_center::NOTIFICATION_TYPE_SIMPLE, 113 message_center::NOTIFICATION_TYPE_SIMPLE,
(...skipping 357 matching lines...) Expand 10 before | Expand all | Expand 10 after
460 int bottom = GetPopupWorkAreaBottom(); 471 int bottom = GetPopupWorkAreaBottom();
461 int bottom_second = GetPopupWorkAreaBottomForTray(GetSecondaryTray()); 472 int bottom_second = GetPopupWorkAreaBottomForTray(GetSecondaryTray());
462 473
463 // System tray is created on the primary display. The popups in the secondary 474 // System tray is created on the primary display. The popups in the secondary
464 // tray aren't affected. 475 // tray aren't affected.
465 GetSystemTray()->ShowDefaultView(BUBBLE_CREATE_NEW); 476 GetSystemTray()->ShowDefaultView(BUBBLE_CREATE_NEW);
466 EXPECT_GT(bottom, GetPopupWorkAreaBottom()); 477 EXPECT_GT(bottom, GetPopupWorkAreaBottom());
467 EXPECT_EQ(bottom_second, GetPopupWorkAreaBottomForTray(GetSecondaryTray())); 478 EXPECT_EQ(bottom_second, GetPopupWorkAreaBottomForTray(GetSecondaryTray()));
468 } 479 }
469 480
481 // TODO(jonross): Replace manually creating TouchEvent with
482 // EventGenerator.PressTouch/ReleaseTouch. Currently they set a width on the
483 // touch event causing the gesture recognizer to target a different view.
484 #if defined(OS_CHROMEOS)
485 // Tests that there is visual feedback for touch presses.
486 TEST_F(WebNotificationTrayTest, TouchFeedback) {
487 AddNotification("test_id");
488 RunAllPendingInMessageLoop();
489 WebNotificationTray* tray = GetTray();
490 EXPECT_TRUE(tray->visible());
491
492 ui::test::EventGenerator generator(Shell::GetPrimaryRootWindow());
493 const int touch_id = 0;
494 gfx::Point center_point = tray->GetBoundsInScreen().CenterPoint();
495
496 ui::TouchEvent press(ui::ET_TOUCH_PRESSED, center_point, touch_id,
497 generator.Now());
498 generator.Dispatch(&press);
499 RunAllPendingInMessageLoop();
500 EXPECT_TRUE(tray->draw_background_as_active());
501
502 ui::TouchEvent release(ui::ET_TOUCH_RELEASED, center_point, touch_id,
503 press.time_stamp() + base::TimeDelta::FromMilliseconds(50));
504 generator.Dispatch(&release);
505 RunAllPendingInMessageLoop();
506 EXPECT_TRUE(tray->draw_background_as_active());
507 EXPECT_TRUE(tray->IsMessageCenterBubbleVisible());
508
509 generator.GestureTapAt(center_point);
510 RunAllPendingInMessageLoop();
511 EXPECT_FALSE(tray->draw_background_as_active());
512 EXPECT_FALSE(tray->IsMessageCenterBubbleVisible());
513 }
514
515 // Tests that while touch presses trigger visual feedback, that subsequent non
516 // tap gestures cancel the feedback without triggering the message center.
517 TEST_F(WebNotificationTrayTest, TouchFeedbackCancellation) {
518 AddNotification("test_id");
519 RunAllPendingInMessageLoop();
520 WebNotificationTray* tray = GetTray();
521 EXPECT_TRUE(tray->visible());
522
523 ui::test::EventGenerator generator(Shell::GetPrimaryRootWindow());
524 const int touch_id = 0;
525 gfx::Rect bounds = tray->GetBoundsInScreen();
526 gfx::Point center_point = bounds.CenterPoint();
527
528 ui::TouchEvent press(ui::ET_TOUCH_PRESSED, center_point, touch_id,
529 generator.Now());
530 generator.Dispatch(&press);
531 RunAllPendingInMessageLoop();
532 EXPECT_TRUE(tray->draw_background_as_active());
533
534 gfx::Point out_of_bounds(bounds.x() - 1, center_point.y());
535 ui::TouchEvent move(ui::ET_TOUCH_MOVED, out_of_bounds, touch_id,
536 press.time_stamp()+base::TimeDelta::FromMilliseconds(50));
537 generator.Dispatch(&move);
538 RunAllPendingInMessageLoop();
539 EXPECT_FALSE(tray->draw_background_as_active());
540
541 ui::TouchEvent release(ui::ET_TOUCH_RELEASED, out_of_bounds, touch_id,
542 move.time_stamp()+base::TimeDelta::FromMilliseconds(50));
543 generator.Dispatch(&release);
544 RunAllPendingInMessageLoop();
545 EXPECT_FALSE(tray->draw_background_as_active());
546 EXPECT_FALSE(tray->IsMessageCenterBubbleVisible());
547 }
548
549 #endif // OS_CHROMEOS
550
470 } // namespace ash 551 } // namespace ash
OLDNEW
« no previous file with comments | « ash/system/tray/tray_background_view.cc ('k') | chrome/app/generated_resources.grd » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698