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

Side by Side Diff: content/browser/notifications/notification_database_data_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 unified diff | Download patch
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 "base/strings/string_number_conversions.h"
5 #include "base/strings/utf_string_conversions.h" 6 #include "base/strings/utf_string_conversions.h"
6 #include "content/browser/notifications/notification_database_data.pb.h" 7 #include "content/browser/notifications/notification_database_data.pb.h"
7 #include "content/browser/notifications/notification_database_data_conversions.h " 8 #include "content/browser/notifications/notification_database_data_conversions.h "
9 #include "content/common/notification_constants.h"
8 #include "content/public/browser/notification_database_data.h" 10 #include "content/public/browser/notification_database_data.h"
9 #include "testing/gmock/include/gmock/gmock.h" 11 #include "testing/gmock/include/gmock/gmock.h"
10 #include "testing/gtest/include/gtest/gtest.h" 12 #include "testing/gtest/include/gtest/gtest.h"
11 13
12 namespace content { 14 namespace content {
13 15
14 const int64_t kNotificationId = 42; 16 const int64_t kNotificationId = 42;
15 const int64_t kServiceWorkerRegistrationId = 9001; 17 const int64_t kServiceWorkerRegistrationId = 9001;
16 18
17 const char kOrigin[] = "https://example.com/"; 19 const char kOrigin[] = "https://example.com/";
(...skipping 17 matching lines...) Expand all
35 notification_data.title = base::ASCIIToUTF16(kNotificationTitle); 37 notification_data.title = base::ASCIIToUTF16(kNotificationTitle);
36 notification_data.direction = 38 notification_data.direction =
37 PlatformNotificationData::NotificationDirectionRightToLeft; 39 PlatformNotificationData::NotificationDirectionRightToLeft;
38 notification_data.lang = kNotificationLang; 40 notification_data.lang = kNotificationLang;
39 notification_data.body = base::ASCIIToUTF16(kNotificationBody); 41 notification_data.body = base::ASCIIToUTF16(kNotificationBody);
40 notification_data.tag = kNotificationTag; 42 notification_data.tag = kNotificationTag;
41 notification_data.icon = GURL(kNotificationIconUrl); 43 notification_data.icon = GURL(kNotificationIconUrl);
42 notification_data.vibration_pattern = vibration_pattern; 44 notification_data.vibration_pattern = vibration_pattern;
43 notification_data.silent = true; 45 notification_data.silent = true;
44 notification_data.data = developer_data; 46 notification_data.data = developer_data;
47 for (size_t i = 0; i < kPlatformNotificationMaxActions; i++) {
48 PlatformNotificationAction notification_action;
49 notification_action.action = base::SizeTToString(i);
50 notification_action.title = base::SizeTToString16(i);
51 notification_data.actions.push_back(notification_action);
52 }
45 53
46 NotificationDatabaseData database_data; 54 NotificationDatabaseData database_data;
47 database_data.notification_id = kNotificationId; 55 database_data.notification_id = kNotificationId;
48 database_data.origin = GURL(kOrigin); 56 database_data.origin = GURL(kOrigin);
49 database_data.service_worker_registration_id = kServiceWorkerRegistrationId; 57 database_data.service_worker_registration_id = kServiceWorkerRegistrationId;
50 database_data.notification_data = notification_data; 58 database_data.notification_data = notification_data;
51 59
52 std::string serialized_data; 60 std::string serialized_data;
53 61
54 // Serialize the data in |notification_data| to the string |serialized_data|. 62 // Serialize the data in |notification_data| to the string |serialized_data|.
(...skipping 22 matching lines...) Expand all
77 EXPECT_EQ(notification_data.icon, copied_notification_data.icon); 85 EXPECT_EQ(notification_data.icon, copied_notification_data.icon);
78 86
79 EXPECT_THAT(copied_notification_data.vibration_pattern, 87 EXPECT_THAT(copied_notification_data.vibration_pattern,
80 testing::ElementsAreArray(kNotificationVibrationPattern)); 88 testing::ElementsAreArray(kNotificationVibrationPattern));
81 89
82 EXPECT_EQ(notification_data.silent, copied_notification_data.silent); 90 EXPECT_EQ(notification_data.silent, copied_notification_data.silent);
83 91
84 ASSERT_EQ(developer_data.size(), copied_notification_data.data.size()); 92 ASSERT_EQ(developer_data.size(), copied_notification_data.data.size());
85 for (size_t i = 0; i < developer_data.size(); ++i) 93 for (size_t i = 0; i < developer_data.size(); ++i)
86 EXPECT_EQ(developer_data[i], copied_notification_data.data[i]); 94 EXPECT_EQ(developer_data[i], copied_notification_data.data[i]);
95
96 ASSERT_EQ(notification_data.actions.size(),
97 copied_notification_data.actions.size());
98 for (size_t i = 0; i < notification_data.actions.size(); ++i) {
99 EXPECT_EQ(notification_data.actions[i].action,
100 copied_notification_data.actions[i].action);
101 EXPECT_EQ(notification_data.actions[i].title,
102 copied_notification_data.actions[i].title);
103 }
87 } 104 }
88 105
89 } // namespace content 106 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698