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

Unified Diff: ui/message_center/views/custom_notification_view_unittest.cc

Issue 2850153003: Revert of CrOS: Fix appearance of notification toasts when sliding out via gesture (Closed)
Patch Set: Created 3 years, 8 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
« no previous file with comments | « ui/message_center/BUILD.gn ('k') | ui/message_center/views/message_center_view_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/message_center/views/custom_notification_view_unittest.cc
diff --git a/ui/message_center/views/custom_notification_view_unittest.cc b/ui/message_center/views/custom_notification_view_unittest.cc
index 3f1a36709d517af2b17d11f432459c0cc2aeb404..4b9e13d5f785be20d029c54003fb384f93d90d39 100644
--- a/ui/message_center/views/custom_notification_view_unittest.cc
+++ b/ui/message_center/views/custom_notification_view_unittest.cc
@@ -29,6 +29,21 @@
const SkColor kBackgroundColor = SK_ColorGREEN;
+std::unique_ptr<ui::GestureEvent> GenerateGestureEvent(ui::EventType type) {
+ ui::GestureEventDetails detail(type);
+ std::unique_ptr<ui::GestureEvent> event(
+ new ui::GestureEvent(0, 0, 0, base::TimeTicks(), detail));
+ return event;
+}
+
+std::unique_ptr<ui::GestureEvent> GenerateGestureHorizontalScrollUpdateEvent(
+ int dx) {
+ ui::GestureEventDetails detail(ui::ET_GESTURE_SCROLL_UPDATE, dx, 0);
+ std::unique_ptr<ui::GestureEvent> event(
+ new ui::GestureEvent(0, 0, 0, base::TimeTicks(), detail));
+ return event;
+}
+
class TestCustomView : public views::View {
public:
TestCustomView() {
@@ -233,6 +248,10 @@
notification_view()->UpdateWithNotification(*notification());
}
+ float GetNotificationScrollAmount() const {
+ return notification_view_->GetTransform().To2dTranslation().x();
+ }
+
TestMessageCenterController* controller() { return &controller_; }
Notification* notification() { return notification_.get(); }
TestCustomView* custom_view() {
@@ -276,6 +295,53 @@
EXPECT_EQ(1, custom_view()->keyboard_event_count());
}
+TEST_F(CustomNotificationViewTest, SlideOut) {
+ UpdateNotificationViews();
+ std::string notification_id = notification()->id();
+
+ auto event_begin = GenerateGestureEvent(ui::ET_GESTURE_SCROLL_BEGIN);
+ auto event_scroll10 = GenerateGestureHorizontalScrollUpdateEvent(-10);
+ auto event_scroll500 = GenerateGestureHorizontalScrollUpdateEvent(-500);
+ auto event_end = GenerateGestureEvent(ui::ET_GESTURE_SCROLL_END);
+
+ notification_view()->OnGestureEvent(event_begin.get());
+ notification_view()->OnGestureEvent(event_scroll10.get());
+ EXPECT_FALSE(controller()->IsRemoved(notification_id));
+ EXPECT_EQ(-10.f, GetNotificationScrollAmount());
+ notification_view()->OnGestureEvent(event_end.get());
+ EXPECT_FALSE(controller()->IsRemoved(notification_id));
+ EXPECT_EQ(0.f, GetNotificationScrollAmount());
+
+ notification_view()->OnGestureEvent(event_begin.get());
+ notification_view()->OnGestureEvent(event_scroll500.get());
+ EXPECT_FALSE(controller()->IsRemoved(notification_id));
+ EXPECT_EQ(-500.f, GetNotificationScrollAmount());
+ notification_view()->OnGestureEvent(event_end.get());
+ EXPECT_TRUE(controller()->IsRemoved(notification_id));
+}
+
+// Pinning notification is ChromeOS only feature.
+#if defined(OS_CHROMEOS)
+
+TEST_F(CustomNotificationViewTest, SlideOutPinned) {
+ notification()->set_pinned(true);
+ UpdateNotificationViews();
+ std::string notification_id = notification()->id();
+
+ auto event_begin = GenerateGestureEvent(ui::ET_GESTURE_SCROLL_BEGIN);
+ auto event_scroll500 = GenerateGestureHorizontalScrollUpdateEvent(-500);
+ auto event_end = GenerateGestureEvent(ui::ET_GESTURE_SCROLL_END);
+
+ notification_view()->OnGestureEvent(event_begin.get());
+ notification_view()->OnGestureEvent(event_scroll500.get());
+ EXPECT_FALSE(controller()->IsRemoved(notification_id));
+ EXPECT_LT(-500.f, GetNotificationScrollAmount());
+ notification_view()->OnGestureEvent(event_end.get());
+ EXPECT_FALSE(controller()->IsRemoved(notification_id));
+}
+
+#endif // defined(OS_CHROMEOS)
+
TEST_F(CustomNotificationViewTest, PressBackspaceKey) {
std::string notification_id = notification()->id();
custom_view()->RequestFocus();
« no previous file with comments | « ui/message_center/BUILD.gn ('k') | ui/message_center/views/message_center_view_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698