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

Unified Diff: content/browser/notifications/notification_database_data_unittest.cc

Issue 1855443002: Implement receiving side of web notification inline replies (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 9 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: content/browser/notifications/notification_database_data_unittest.cc
diff --git a/content/browser/notifications/notification_database_data_unittest.cc b/content/browser/notifications/notification_database_data_unittest.cc
index a07a5f5a36cae4abbadc006382ca6a7cc61509a5..fdfd8ba61e34096d3d9e83ee16a3d54362980503 100644
--- a/content/browser/notifications/notification_database_data_unittest.cc
+++ b/content/browser/notifications/notification_database_data_unittest.cc
@@ -21,6 +21,8 @@ namespace content {
const int64_t kNotificationId = 42;
const int64_t kServiceWorkerRegistrationId = 9001;
+const PlatformNotificationActionType kNotificationActionType =
+ PLATFORM_NOTIFICATION_ACTION_TYPE_TEXT;
const char kOrigin[] = "https://example.com/";
const char kNotificationTitle[] = "My Notification";
const char kNotificationLang[] = "nl";
@@ -58,9 +60,11 @@ TEST(NotificationDatabaseDataTest, SerializeAndDeserializeData) {
notification_data.data = developer_data;
for (size_t i = 0; i < kPlatformNotificationMaxActions; i++) {
PlatformNotificationAction notification_action;
+ notification_action.type = kNotificationActionType;
notification_action.action = base::SizeTToString(i);
notification_action.title = base::SizeTToString16(i);
notification_action.icon = GURL(kNotificationActionIconUrl);
+ notification_action.placeholder = base::SizeTToString16(i);
notification_data.actions.push_back(notification_action);
}
@@ -114,12 +118,16 @@ TEST(NotificationDatabaseDataTest, SerializeAndDeserializeData) {
ASSERT_EQ(notification_data.actions.size(),
copied_notification_data.actions.size());
for (size_t i = 0; i < notification_data.actions.size(); ++i) {
+ EXPECT_EQ(notification_data.actions[i].type,
+ copied_notification_data.actions[i].type);
EXPECT_EQ(notification_data.actions[i].action,
copied_notification_data.actions[i].action);
EXPECT_EQ(notification_data.actions[i].title,
copied_notification_data.actions[i].title);
EXPECT_EQ(notification_data.actions[i].icon,
copied_notification_data.actions[i].icon);
+ EXPECT_EQ(notification_data.actions[i].placeholder,
+ copied_notification_data.actions[i].placeholder);
}
}
@@ -148,4 +156,30 @@ TEST(NotificationDatabaseDataTest, SerializeAndDeserializeDirections) {
}
}
+TEST(NotificationDatabaseDataTest, SerializeAndDeserializeActionTypes) {
+ PlatformNotificationActionType action_types[] = {
+ PLATFORM_NOTIFICATION_ACTION_TYPE_BUTTON,
+ PLATFORM_NOTIFICATION_ACTION_TYPE_TEXT};
+
+ for (PlatformNotificationActionType action_type : action_types) {
+ PlatformNotificationData notification_data;
+
+ PlatformNotificationAction action;
+ action.type = action_type;
+ notification_data.actions.push_back(action);
+
+ NotificationDatabaseData database_data;
+ database_data.notification_data = notification_data;
+
+ std::string serialized_data;
+ ASSERT_TRUE(
+ SerializeNotificationDatabaseData(database_data, &serialized_data));
+
+ NotificationDatabaseData copied_data;
+ ASSERT_TRUE(
+ DeserializeNotificationDatabaseData(serialized_data, &copied_data));
+
+ EXPECT_EQ(action_type, copied_data.notification_data.actions[0].type);
+ }
+}
} // namespace content

Powered by Google App Engine
This is Rietveld 408576698