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

Unified Diff: content/child/notifications/notification_data_conversions_unittest.cc

Issue 1267673003: Plumb Blink notification actions to button UI on desktop (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix size_t Created 5 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: content/child/notifications/notification_data_conversions_unittest.cc
diff --git a/content/child/notifications/notification_data_conversions_unittest.cc b/content/child/notifications/notification_data_conversions_unittest.cc
index c124e4f0e3e346ea2e9dd04d6fb278eff4ead57d..d71f74f79f3cf81e8cc86890aa9b00da1a295fc7 100644
--- a/content/child/notifications/notification_data_conversions_unittest.cc
+++ b/content/child/notifications/notification_data_conversions_unittest.cc
@@ -23,6 +23,10 @@ const char kNotificationTag[] = "my_tag";
const char kNotificationIconUrl[] = "https://example.com/icon.png";
const int kNotificationVibrationPattern[] = { 100, 200, 300 };
const unsigned char kNotificationData[] = { 0xdf, 0xff, 0x0, 0x0, 0xff, 0xdf };
+const char kAction1Name[] = "btn1";
+const char kAction1Title[] = "Button 1";
+const char kAction2Name[] = "btn2";
+const char kAction2Title[] = "Button 2";
TEST(NotificationDataConversionsTest, ToPlatformNotificationData) {
std::vector<int> vibration_pattern(
@@ -32,6 +36,13 @@ TEST(NotificationDataConversionsTest, ToPlatformNotificationData) {
std::vector<char> developer_data(
kNotificationData, kNotificationData + arraysize(kNotificationData));
+ blink::WebVector<blink::WebNotificationAction> web_actions(
+ static_cast<size_t>(2));
+ web_actions[0].action = blink::WebString::fromUTF8(kAction1Name);
+ web_actions[0].title = blink::WebString::fromUTF8(kAction1Title);
+ web_actions[1].action = blink::WebString::fromUTF8(kAction2Name);
+ web_actions[1].title = blink::WebString::fromUTF8(kAction2Title);
+
blink::WebNotificationData web_data(
blink::WebString::fromUTF8(kNotificationTitle),
blink::WebNotificationData::DirectionLeftToRight,
@@ -41,7 +52,8 @@ TEST(NotificationDataConversionsTest, ToPlatformNotificationData) {
blink::WebURL(GURL(kNotificationIconUrl)),
blink::WebVector<int>(vibration_pattern),
true /* silent */,
- blink::WebVector<char>(developer_data));
+ blink::WebVector<char>(developer_data),
+ web_actions);
PlatformNotificationData platform_data = ToPlatformNotificationData(web_data);
EXPECT_EQ(base::ASCIIToUTF16(kNotificationTitle), platform_data.title);
@@ -59,6 +71,11 @@ TEST(NotificationDataConversionsTest, ToPlatformNotificationData) {
ASSERT_EQ(developer_data.size(), platform_data.data.size());
for (size_t i = 0; i < developer_data.size(); ++i)
EXPECT_EQ(developer_data[i], platform_data.data[i]);
+ ASSERT_EQ(web_actions.size(), platform_data.actions.size());
+ EXPECT_EQ(kAction1Name, platform_data.actions[0].action);
+ EXPECT_EQ(base::ASCIIToUTF16(kAction1Title), platform_data.actions[0].title);
+ EXPECT_EQ(kAction2Name, platform_data.actions[1].action);
+ EXPECT_EQ(base::ASCIIToUTF16(kAction2Title), platform_data.actions[1].title);
}
TEST(NotificationDataConversionsTest,
@@ -96,6 +113,11 @@ TEST(NotificationDataConversionsTest, ToWebNotificationData) {
platform_data.vibration_pattern = vibration_pattern;
platform_data.silent = true;
platform_data.data = developer_data;
+ platform_data.actions.resize(2);
+ platform_data.actions[0].action = kAction1Name;
+ platform_data.actions[0].title = base::ASCIIToUTF16(kAction1Title);
+ platform_data.actions[1].action = kAction2Name;
+ platform_data.actions[1].title = base::ASCIIToUTF16(kAction2Title);
blink::WebNotificationData web_data = ToWebNotificationData(platform_data);
EXPECT_EQ(kNotificationTitle, web_data.title);
@@ -115,6 +137,12 @@ TEST(NotificationDataConversionsTest, ToWebNotificationData) {
ASSERT_EQ(developer_data.size(), web_data.data.size());
for (size_t i = 0; i < developer_data.size(); ++i)
EXPECT_EQ(developer_data[i], web_data.data[i]);
+
+ ASSERT_EQ(platform_data.actions.size(), web_data.actions.size());
+ EXPECT_EQ(kAction1Name, web_data.actions[0].action);
+ EXPECT_EQ(kAction1Title, web_data.actions[0].title);
+ EXPECT_EQ(kAction2Name, web_data.actions[1].action);
+ EXPECT_EQ(kAction2Title, web_data.actions[1].title);
}
TEST(NotificationDataConversionsTest, ToWebNotificationDataDirectionality) {
« no previous file with comments | « content/child/notifications/notification_data_conversions.cc ('k') | content/child/notifications/notification_manager.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698