OLD | NEW |
---|---|
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 " |
8 #include "content/public/browser/notification_database_data.h" | 9 #include "content/public/browser/notification_database_data.h" |
9 #include "testing/gmock/include/gmock/gmock.h" | 10 #include "testing/gmock/include/gmock/gmock.h" |
10 #include "testing/gtest/include/gtest/gtest.h" | 11 #include "testing/gtest/include/gtest/gtest.h" |
11 | 12 |
12 namespace content { | 13 namespace content { |
13 | 14 |
14 const int64_t kNotificationId = 42; | 15 const int64_t kNotificationId = 42; |
(...skipping 20 matching lines...) Expand all Loading... | |
35 notification_data.title = base::ASCIIToUTF16(kNotificationTitle); | 36 notification_data.title = base::ASCIIToUTF16(kNotificationTitle); |
36 notification_data.direction = | 37 notification_data.direction = |
37 PlatformNotificationData::NotificationDirectionRightToLeft; | 38 PlatformNotificationData::NotificationDirectionRightToLeft; |
38 notification_data.lang = kNotificationLang; | 39 notification_data.lang = kNotificationLang; |
39 notification_data.body = base::ASCIIToUTF16(kNotificationBody); | 40 notification_data.body = base::ASCIIToUTF16(kNotificationBody); |
40 notification_data.tag = kNotificationTag; | 41 notification_data.tag = kNotificationTag; |
41 notification_data.icon = GURL(kNotificationIconUrl); | 42 notification_data.icon = GURL(kNotificationIconUrl); |
42 notification_data.vibration_pattern = vibration_pattern; | 43 notification_data.vibration_pattern = vibration_pattern; |
43 notification_data.silent = true; | 44 notification_data.silent = true; |
44 notification_data.data = developer_data; | 45 notification_data.data = developer_data; |
46 for (int i = 0; i < 2; i++) { | |
Peter Beverloo
2015/07/31 19:17:51
nit: might as well use the constant (in case we ev
johnme
2015/07/31 19:38:24
Done.
| |
47 PlatformNotificationAction notification_action; | |
48 notification_action.action = IntToString(i); | |
Peter Beverloo
2015/07/31 19:17:51
base::
johnme
2015/07/31 19:38:24
Done.
| |
49 notification_action.title = IntToString16(i); | |
Peter Beverloo
2015/07/31 19:17:51
dito
johnme
2015/07/31 19:38:24
Done.
| |
50 notification_data.actions.push_back(notification_action); | |
51 } | |
45 | 52 |
46 NotificationDatabaseData database_data; | 53 NotificationDatabaseData database_data; |
47 database_data.notification_id = kNotificationId; | 54 database_data.notification_id = kNotificationId; |
48 database_data.origin = GURL(kOrigin); | 55 database_data.origin = GURL(kOrigin); |
49 database_data.service_worker_registration_id = kServiceWorkerRegistrationId; | 56 database_data.service_worker_registration_id = kServiceWorkerRegistrationId; |
50 database_data.notification_data = notification_data; | 57 database_data.notification_data = notification_data; |
51 | 58 |
52 std::string serialized_data; | 59 std::string serialized_data; |
53 | 60 |
54 // Serialize the data in |notification_data| to the string |serialized_data|. | 61 // Serialize the data in |notification_data| to the string |serialized_data|. |
(...skipping 22 matching lines...) Expand all Loading... | |
77 EXPECT_EQ(notification_data.icon, copied_notification_data.icon); | 84 EXPECT_EQ(notification_data.icon, copied_notification_data.icon); |
78 | 85 |
79 EXPECT_THAT(copied_notification_data.vibration_pattern, | 86 EXPECT_THAT(copied_notification_data.vibration_pattern, |
80 testing::ElementsAreArray(kNotificationVibrationPattern)); | 87 testing::ElementsAreArray(kNotificationVibrationPattern)); |
81 | 88 |
82 EXPECT_EQ(notification_data.silent, copied_notification_data.silent); | 89 EXPECT_EQ(notification_data.silent, copied_notification_data.silent); |
83 | 90 |
84 ASSERT_EQ(developer_data.size(), copied_notification_data.data.size()); | 91 ASSERT_EQ(developer_data.size(), copied_notification_data.data.size()); |
85 for (size_t i = 0; i < developer_data.size(); ++i) | 92 for (size_t i = 0; i < developer_data.size(); ++i) |
86 EXPECT_EQ(developer_data[i], copied_notification_data.data[i]); | 93 EXPECT_EQ(developer_data[i], copied_notification_data.data[i]); |
94 | |
95 ASSERT_EQ(notification_data.actions.size(), | |
96 copied_notification_data.actions.size()); | |
97 for (size_t i = 0; i < notification_data.actions.size(); ++i) { | |
98 EXPECT_EQ(notification_data.actions[i].action, | |
99 copied_notification_data.actions[i].action); | |
100 EXPECT_EQ(notification_data.actions[i].title, | |
101 copied_notification_data.actions[i].title); | |
102 } | |
87 } | 103 } |
88 | 104 |
89 } // namespace content | 105 } // namespace content |
OLD | NEW |