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

Unified 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: Implement Touch Feedback on TrayBackgroundView Created 6 years, 4 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 side-by-side diff with in-line comments
Download patch
Index: ash/system/web_notification/web_notification_tray_unittest.cc
diff --git a/ash/system/web_notification/web_notification_tray_unittest.cc b/ash/system/web_notification/web_notification_tray_unittest.cc
index 7f17c3bb2f1980fc14b152de6541de4294707ae5..0944256cb8f111f4cd6aa39be41f433be95bbc57 100644
--- a/ash/system/web_notification/web_notification_tray_unittest.cc
+++ b/ash/system/web_notification/web_notification_tray_unittest.cc
@@ -6,6 +6,7 @@
#include <vector>
+#include "ash/ash_switches.h"
#include "ash/display/display_manager.h"
#include "ash/root_window_controller.h"
#include "ash/shelf/shelf_layout_manager.h"
@@ -18,13 +19,18 @@
#include "ash/test/ash_test_base.h"
#include "ash/test/status_area_widget_test_helper.h"
#include "ash/test/test_system_tray_delegate.h"
+#include "ash/wm/maximize_mode/maximize_mode_controller.h"
#include "ash/wm/window_state.h"
+#include "base/command_line.h"
#include "base/strings/stringprintf.h"
#include "base/strings/utf_string_conversions.h"
#include "ui/aura/client/aura_constants.h"
#include "ui/aura/window.h"
+#include "ui/events/event.h"
#include "ui/events/test/event_generator.h"
#include "ui/gfx/display.h"
+#include "ui/gfx/point.h"
+#include "ui/gfx/rect.h"
#include "ui/gfx/screen.h"
#include "ui/message_center/message_center_style.h"
#include "ui/message_center/message_center_tray.h"
@@ -90,6 +96,14 @@ class WebNotificationTrayTest : public test::AshTestBase {
WebNotificationTrayTest() {}
virtual ~WebNotificationTrayTest() {}
+#if defined(OS_CHROMEOS)
+ virtual void SetUp() OVERRIDE {
+ CommandLine::ForCurrentProcess()->AppendSwitch(
+ switches::kAshEnableTouchViewTouchFeedback);
+ test::AshTestBase::SetUp();
+ }
+#endif
+
virtual void TearDown() OVERRIDE {
GetMessageCenter()->RemoveAllNotifications(false);
test::AshTestBase::TearDown();
@@ -467,4 +481,114 @@ TEST_F(WebNotificationTrayTest, MAYBE_PopupAndSystemTrayMultiDisplay) {
EXPECT_EQ(bottom_second, GetPopupWorkAreaBottomForTray(GetSecondaryTray()));
}
+// TODO(jonross): Replace manually creating TouchEvent with
+// EventGenerator.PressTouch/ReleaseTouch. Currently they set a width on the
+// touch event causing the gesture recognizer to target a different view.
+#if defined(OS_CHROMEOS)
+#define MAYBE_NoTouchFeedback NoTouchFeedback
+#define MAYBE_MaximizeModeTouchFeedback MaximizeModeTouchFeedback
+#define MAYBE_TouchFeedbackCancellation TouchFeedbackCancellation
flackr 2014/08/29 15:34:10 Assuming we do want this CHROMEOS only I'd just pu
jonross 2014/08/29 17:20:21 Done.
+#else
+#define MAYBE_NoTouchFeedback DISABLED_NoTouchFeedback
+#define MAYBE_MaximizeModeTouchFeedback DISABLED_MaximizeModeTouchFeedback
+#define MAYBE_TouchFeedbackCancellation DISABLED_TouchFeedbackCancellation
+#endif
+// Tests that while there is no visual feedback for touch presses while in
+// normal mode.
+TEST_F(WebNotificationTrayTest, MAYBE_NoTouchFeedback) {
+ AddNotification("test_id");
+ RunAllPendingInMessageLoop();
+ WebNotificationTray* tray = GetTray();
+ EXPECT_TRUE(tray->visible());
+
+ ui::test::EventGenerator generator(Shell::GetPrimaryRootWindow());
+ const int touch_id = 0;
+ gfx::Point center_point = tray->GetBoundsInScreen().CenterPoint();
+
+ ui::TouchEvent press(ui::ET_TOUCH_PRESSED, center_point, touch_id,
+ generator.Now());
+ generator.Dispatch(&press);
+ RunAllPendingInMessageLoop();
+ EXPECT_FALSE(tray->draw_background_as_active());
+
+ ui::TouchEvent release(ui::ET_TOUCH_RELEASED, center_point, touch_id,
+ press.time_stamp()+base::TimeDelta::FromMilliseconds(50));
+ generator.Dispatch(&release);
+ RunAllPendingInMessageLoop();
+ EXPECT_TRUE(tray->draw_background_as_active());
+ EXPECT_TRUE(tray->IsMessageCenterBubbleVisible());
+
+ generator.GestureTapAt(center_point);
+ RunAllPendingInMessageLoop();
+ EXPECT_FALSE(tray->draw_background_as_active());
+}
+
+// Tests that while in MaximizeMode that there is visual feedback for touch
+// presses.
+TEST_F(WebNotificationTrayTest, MAYBE_MaximizeModeTouchFeedback) {
+ AddNotification("test_id");
+ RunAllPendingInMessageLoop();
+ WebNotificationTray* tray = GetTray();
+ EXPECT_TRUE(tray->visible());
+
+ Shell::GetInstance()->maximize_mode_controller()->
+ EnableMaximizeModeWindowManager(true);
+
+ ui::test::EventGenerator generator(Shell::GetPrimaryRootWindow());
+ const int touch_id = 0;
+ gfx::Point center_point = tray->GetBoundsInScreen().CenterPoint();
+
+ ui::TouchEvent press(ui::ET_TOUCH_PRESSED, center_point, touch_id,
+ generator.Now());
+ generator.Dispatch(&press);
+ RunAllPendingInMessageLoop();
+ EXPECT_TRUE(tray->draw_background_as_active());
+
+ ui::TouchEvent release(ui::ET_TOUCH_RELEASED, center_point, touch_id,
+ press.time_stamp()+base::TimeDelta::FromMilliseconds(50));
+ generator.Dispatch(&release);
+ RunAllPendingInMessageLoop();
+ EXPECT_TRUE(tray->draw_background_as_active());
+ EXPECT_TRUE(tray->IsMessageCenterBubbleVisible());
+
+ generator.GestureTapAt(center_point);
+ RunAllPendingInMessageLoop();
+ EXPECT_FALSE(tray->draw_background_as_active());
+ EXPECT_FALSE(tray->IsMessageCenterBubbleVisible());
+}
+
+// Tests that while touch presses trigger visual feedback, that subsequent non
+// tap gestures cancel the feedback without triggering the message center.
+TEST_F(WebNotificationTrayTest, MAYBE_TouchFeedbackCancellation) {
+ AddNotification("test_id");
+ RunAllPendingInMessageLoop();
+ WebNotificationTray* tray = GetTray();
+ EXPECT_TRUE(tray->visible());
+
+ Shell::GetInstance()->maximize_mode_controller()->
+ EnableMaximizeModeWindowManager(true);
+
+ ui::test::EventGenerator generator(Shell::GetPrimaryRootWindow());
+ const int touch_id = 0;
+ gfx::Rect bounds = tray->GetBoundsInScreen();
+ gfx::Point center_point = bounds.CenterPoint();
+
+ ui::TouchEvent press(ui::ET_TOUCH_PRESSED, center_point, touch_id,
+ generator.Now());
+ generator.Dispatch(&press);
+ RunAllPendingInMessageLoop();
+ EXPECT_TRUE(tray->draw_background_as_active());
+
+ gfx::Point out_of_bounds(bounds.x() - 1, center_point.y());
+ ui::TouchEvent move(ui::ET_TOUCH_MOVED, out_of_bounds, touch_id,
+ press.time_stamp()+base::TimeDelta::FromMilliseconds(50));
+ generator.Dispatch(&move);
+ ui::TouchEvent release(ui::ET_TOUCH_RELEASED, out_of_bounds, touch_id,
+ move.time_stamp()+base::TimeDelta::FromMilliseconds(50));
+ generator.Dispatch(&release);
+ RunAllPendingInMessageLoop();
+ EXPECT_FALSE(tray->draw_background_as_active());
+ EXPECT_FALSE(tray->IsMessageCenterBubbleVisible());
+}
+
} // namespace ash

Powered by Google App Engine
This is Rietveld 408576698