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

Side by Side Diff: chrome/browser/notifications/sync_notifier/synced_notification_unittest.cc

Issue 12717010: Widen Data Pipes and newer protobufs (Closed) Base URL: http://git.chromium.org/chromium/src.git@newProtobufs
Patch Set: Synced Notifications newer protobufs - add priority enum adapter. Created 7 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 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 <string> 5 #include <string>
6 6
7 #include "base/memory/scoped_ptr.h" 7 #include "base/memory/scoped_ptr.h"
8 #include "chrome/browser/notifications/sync_notifier/synced_notification.h" 8 #include "chrome/browser/notifications/sync_notifier/synced_notification.h"
9 #include "sync/api/sync_data.h" 9 #include "sync/api/sync_data.h"
10 #include "sync/protocol/sync.pb.h" 10 #include "sync/protocol/sync.pb.h"
11 #include "sync/protocol/synced_notification_specifics.pb.h" 11 #include "sync/protocol/synced_notification_specifics.pb.h"
12 #include "testing/gtest/include/gtest/gtest.h" 12 #include "testing/gtest/include/gtest/gtest.h"
13 #include "ui/message_center/notification_types.h"
13 14
14 using syncer::SyncData; 15 using syncer::SyncData;
15 using notifier::SyncedNotification; 16 using notifier::SyncedNotification;
16 using sync_pb::EntitySpecifics; 17 using sync_pb::EntitySpecifics;
17 using sync_pb::SyncedNotificationSpecifics; 18 using sync_pb::SyncedNotificationSpecifics;
18 19
19 namespace { 20 namespace {
20 21
21 const int64 kFakeCreationTime = 42; 22 const int64 kFakeCreationTime = 42;
23 const int kProtobufPriority = static_cast<int>(
24 sync_pb::CoalescedSyncedNotification_Priority_LOW);
25 const int kNotificationPriority = static_cast<int>(
26 message_center::LOW_PRIORITY);
22 27
23 const char kTitle1[] = "New appointment at 2:15"; 28 const char kTitle1[] = "New appointment at 2:15";
24 const char kTitle2[] = "Email from Mark: Upcoming Ski trip"; 29 const char kTitle2[] = "Email from Mark: Upcoming Ski trip";
25 const char kTitle3[] = "Weather alert - light rain tonight."; 30 const char kTitle3[] = "Weather alert - light rain tonight.";
26 const char kAppId1[] = "fboilmbenheemaomgaeehigklolhkhnf"; 31 const char kAppId1[] = "fboilmbenheemaomgaeehigklolhkhnf";
27 const char kAppId2[] = "fbcmoldooppoahjhfflnmljoanccekpf"; 32 const char kAppId2[] = "fbcmoldooppoahjhfflnmljoanccekpf";
28 const char kKey1[] = "foo"; 33 const char kKey1[] = "foo";
29 const char kKey2[] = "bar"; 34 const char kKey2[] = "bar";
30 const char kText1[] = "Space Needle, 12:00 pm"; 35 const char kText1[] = "Space Needle, 12:00 pm";
31 const char kText2[] = "Stevens Pass is our first choice."; 36 const char kText2[] = "Stevens Pass is our first choice.";
32 const char kText3[] = "More rain expected in the Seattle area tonight."; 37 const char kText3[] = "More rain expected in the Seattle area tonight.";
33 const char kIconUrl1[] = "http://www.google.com/icon1.jpg"; 38 const char kIconUrl1[] = "http://www.google.com/icon1.jpg";
34 const char kIconUrl2[] = "http://www.google.com/icon2.jpg"; 39 const char kIconUrl2[] = "http://www.google.com/icon2.jpg";
35 const char kIconUrl3[] = "http://www.google.com/icon3.jpg"; 40 const char kIconUrl3[] = "http://www.google.com/icon3.jpg";
36 const char kImageUrl1[] = "http://www.google.com/image1.jpg"; 41 const char kImageUrl1[] = "http://www.google.com/image1.jpg";
37 const char kImageUrl2[] = "http://www.google.com/image2.jpg"; 42 const char kImageUrl2[] = "http://www.google.com/image2.jpg";
38 const char kImageUrl3[] = "http://www.google.com/image3.jpg"; 43 const char kImageUrl3[] = "http://www.google.com/image3.jpg";
44 const char kDefaultDestinationTitle[] = "Open web page";
45 const char kDefaultDestinationIconUrl[] = "http://www.google.com/image4.jpg";
46 const char kDefaultDestinationUrl[] = "http://www.google.com";
47 const char kButtonOneTitle[] = "Read";
48 const char kButtonOneIconUrl[] = "http://www.google.com/image5.jpg";
49 const char kButtonOneUrl[] = "http://www.google.com/do-something1";
50 const char kButtonTwoTitle[] = "Reply";
51 const char kButtonTwoIconUrl[] = "http://www.google.com/image6.jpg";
52 const char kButtonTwoUrl[] = "http://www.google.com/do-something2";
53 const char kContainedTitle1[] = "Today's Picnic moved";
54 const char kContainedTitle2[] = "Group Run Today";
55 const char kContainedTitle3[] = "Starcraft Tonight";
56 const char kContainedMessage1[] = "Due to rain, we will be inside the cafe.";
57 const char kContainedMessage2[] = "Meet at noon in the Gym.";
58 const char kContainedMessage3[] = "Let's play starcraft tonight on the LAN.";
59
39 const sync_pb::CoalescedSyncedNotification_ReadState kRead = 60 const sync_pb::CoalescedSyncedNotification_ReadState kRead =
40 sync_pb::CoalescedSyncedNotification_ReadState_READ; 61 sync_pb::CoalescedSyncedNotification_ReadState_READ;
41 const sync_pb::CoalescedSyncedNotification_ReadState kUnread = 62 const sync_pb::CoalescedSyncedNotification_ReadState kUnread =
42 sync_pb::CoalescedSyncedNotification_ReadState_UNREAD; 63 sync_pb::CoalescedSyncedNotification_ReadState_UNREAD;
43 const sync_pb::CoalescedSyncedNotification_ReadState kDismissed = 64 const sync_pb::CoalescedSyncedNotification_ReadState kDismissed =
44 sync_pb::CoalescedSyncedNotification_ReadState_DISMISSED; 65 sync_pb::CoalescedSyncedNotification_ReadState_DISMISSED;
45 } // namespace 66 } // namespace
46 67
47 class SyncedNotificationTest : public testing::Test { 68 class SyncedNotificationTest : public testing::Test {
48 public: 69 public:
49 SyncedNotificationTest() {} 70 SyncedNotificationTest() {}
50 ~SyncedNotificationTest() {} 71 ~SyncedNotificationTest() {}
51 72
52 // Methods from testing::Test. 73 // Methods from testing::Test.
53 74
54 virtual void SetUp() OVERRIDE { 75 virtual void SetUp() OVERRIDE {
55 sync_data1_ = CreateSyncData(kTitle1, kText1, kIconUrl1, kImageUrl1, 76 sync_data1_ = CreateSyncData(kTitle1, kText1, kIconUrl1, kImageUrl1,
56 kAppId1, kKey1, kUnread); 77 kAppId1, kKey1, kUnread);
57 sync_data2_ = CreateSyncData(kTitle2, kText2, kIconUrl2, kImageUrl1, 78 sync_data2_ = CreateSyncData(kTitle2, kText2, kIconUrl2, kImageUrl2,
58 kAppId2, kKey2, kUnread); 79 kAppId2, kKey2, kUnread);
59 // Notification 3 will have the same ID as notification1, but different 80 // Notification 3 will have the same ID as notification1, but different
60 // data inside. 81 // data inside.
61 sync_data3_ = CreateSyncData(kTitle3, kText3, kIconUrl3, kImageUrl1, 82 sync_data3_ = CreateSyncData(kTitle3, kText3, kIconUrl3, kImageUrl3,
62 kAppId1, kKey1, kUnread); 83 kAppId1, kKey1, kUnread);
63 // Notification 4 will be the same as 1, but the read state will be 'read'. 84 // Notification 4 will be the same as 1, but the read state will be 'read'.
64 sync_data4_ = CreateSyncData(kTitle1, kText1, kIconUrl1, kImageUrl1, 85 sync_data4_ = CreateSyncData(kTitle1, kText1, kIconUrl1, kImageUrl1,
65 kAppId1, kKey1, kDismissed); 86 kAppId1, kKey1, kDismissed);
66 87
67 notification1_.reset(new SyncedNotification(sync_data1_)); 88 notification1_.reset(new SyncedNotification(sync_data1_));
68 notification2_.reset(new SyncedNotification(sync_data2_)); 89 notification2_.reset(new SyncedNotification(sync_data2_));
69 notification3_.reset(new SyncedNotification(sync_data3_)); 90 notification3_.reset(new SyncedNotification(sync_data3_));
70 notification4_.reset(new SyncedNotification(sync_data4_)); 91 notification4_.reset(new SyncedNotification(sync_data4_));
71 } 92 }
(...skipping 29 matching lines...) Expand all
101 SyncedNotificationSpecifics* specifics = 122 SyncedNotificationSpecifics* specifics =
102 entity_specifics.mutable_synced_notification(); 123 entity_specifics.mutable_synced_notification();
103 124
104 specifics->mutable_coalesced_notification()-> 125 specifics->mutable_coalesced_notification()->
105 set_app_id(app_id); 126 set_app_id(app_id);
106 127
107 specifics->mutable_coalesced_notification()-> 128 specifics->mutable_coalesced_notification()->
108 set_key(key); 129 set_key(key);
109 130
110 specifics->mutable_coalesced_notification()-> 131 specifics->mutable_coalesced_notification()->
132 set_priority(static_cast<sync_pb::CoalescedSyncedNotification_Priority>(
133 kProtobufPriority));
134
135 // Set the title.
136 specifics->mutable_coalesced_notification()->
111 mutable_render_info()-> 137 mutable_render_info()->
112 mutable_expanded_info()-> 138 mutable_expanded_info()->
113 mutable_simple_expanded_layout()-> 139 mutable_simple_expanded_layout()->
114 set_title(title); 140 set_title(title);
115 141
142 // Set the text.
116 specifics->mutable_coalesced_notification()-> 143 specifics->mutable_coalesced_notification()->
117 mutable_render_info()-> 144 mutable_render_info()->
118 mutable_expanded_info()-> 145 mutable_expanded_info()->
119 mutable_simple_expanded_layout()-> 146 mutable_simple_expanded_layout()->
120 set_text(text); 147 set_text(text);
121 148
149 // Add the collapsed info and set the app_icon_url on it.
122 specifics->mutable_coalesced_notification()-> 150 specifics->mutable_coalesced_notification()->
123 mutable_render_info()-> 151 mutable_render_info()->
124 mutable_expanded_info()-> 152 mutable_expanded_info()->
125 add_collapsed_info(); 153 add_collapsed_info();
126 specifics->mutable_coalesced_notification()-> 154 specifics->mutable_coalesced_notification()->
127 mutable_render_info()-> 155 mutable_render_info()->
128 mutable_expanded_info()-> 156 mutable_expanded_info()->
129 mutable_collapsed_info(0)-> 157 mutable_collapsed_info(0)->
130 mutable_simple_collapsed_layout()-> 158 mutable_simple_collapsed_layout()->
131 mutable_app_icon()-> 159 mutable_app_icon()->
132 set_url(app_icon_url); 160 set_url(app_icon_url);
133 161
162 // Add the media object and set the image url on it.
134 specifics->mutable_coalesced_notification()-> 163 specifics->mutable_coalesced_notification()->
135 mutable_render_info()-> 164 mutable_render_info()->
136 mutable_expanded_info()-> 165 mutable_expanded_info()->
137 mutable_simple_expanded_layout()-> 166 mutable_simple_expanded_layout()->
138 add_media(); 167 add_media();
139 specifics->mutable_coalesced_notification()-> 168 specifics->mutable_coalesced_notification()->
140 mutable_render_info()-> 169 mutable_render_info()->
141 mutable_expanded_info()-> 170 mutable_expanded_info()->
142 mutable_simple_expanded_layout()-> 171 mutable_simple_expanded_layout()->
143 mutable_media(0)-> 172 mutable_media(0)->
144 mutable_image()-> 173 mutable_image()->
145 set_url(image_url); 174 set_url(image_url);
146 175
147 specifics->mutable_coalesced_notification()-> 176 specifics->mutable_coalesced_notification()->
148 set_creation_time_msec(kFakeCreationTime); 177 set_creation_time_msec(kFakeCreationTime);
149 178
150 specifics->mutable_coalesced_notification()-> 179 specifics->mutable_coalesced_notification()->
151 add_notification();
152
153 specifics->mutable_coalesced_notification()->
154 set_read_state(read_state); 180 set_read_state(read_state);
155 181
156 // TODO(petewil): Improve ctor to pass in an image and type so this test can 182 // Contained notification one.
157 // pass on actual data. 183 // We re-use the collapsed info we added for the app_icon_url,
184 // so no need to create another one here.
185 specifics->mutable_coalesced_notification()->
186 mutable_render_info()->
187 mutable_expanded_info()->
188 mutable_collapsed_info(0)->
189 mutable_simple_collapsed_layout()->
190 set_heading(kContainedTitle1);
191 specifics->mutable_coalesced_notification()->
192 mutable_render_info()->
193 mutable_expanded_info()->
194 mutable_collapsed_info(0)->
195 mutable_simple_collapsed_layout()->
196 set_description(kContainedMessage1);
197
198 // Contained notification two.
199 specifics->mutable_coalesced_notification()->
200 mutable_render_info()->
201 mutable_expanded_info()->
202 add_collapsed_info();
203 specifics->mutable_coalesced_notification()->
204 mutable_render_info()->
205 mutable_expanded_info()->
206 mutable_collapsed_info(1)->
207 mutable_simple_collapsed_layout()->
208 set_heading(kContainedTitle2);
209 specifics->mutable_coalesced_notification()->
210 mutable_render_info()->
211 mutable_expanded_info()->
212 mutable_collapsed_info(1)->
213 mutable_simple_collapsed_layout()->
214 set_description(kContainedMessage2);
215
216 // Contained notification three.
217 specifics->mutable_coalesced_notification()->
218 mutable_render_info()->
219 mutable_expanded_info()->
220 add_collapsed_info();
221 specifics->mutable_coalesced_notification()->
222 mutable_render_info()->
223 mutable_expanded_info()->
224 mutable_collapsed_info(2)->
225 mutable_simple_collapsed_layout()->
226 set_heading(kContainedTitle3);
227 specifics->mutable_coalesced_notification()->
228 mutable_render_info()->
229 mutable_expanded_info()->
230 mutable_collapsed_info(2)->
231 mutable_simple_collapsed_layout()->
232 set_description(kContainedMessage3);
233
234 // Default Destination.
235 specifics->mutable_coalesced_notification()->
236 mutable_render_info()->
237 mutable_collapsed_info()->
238 mutable_default_destination()->
239 set_text(kDefaultDestinationTitle);
240 specifics->mutable_coalesced_notification()->
241 mutable_render_info()->
242 mutable_collapsed_info()->
243 mutable_default_destination()->
244 mutable_icon()->
245 set_url(kDefaultDestinationIconUrl);
246 specifics->mutable_coalesced_notification()->
247 mutable_render_info()->
248 mutable_collapsed_info()->
249 mutable_default_destination()->
250 mutable_icon()->
251 set_alt_text(kDefaultDestinationTitle);
252 specifics->mutable_coalesced_notification()->
253 mutable_render_info()->
254 mutable_collapsed_info()->
255 mutable_default_destination()->
256 set_url(kDefaultDestinationUrl);
257
258 // Buttons are represented as targets.
259
260 // Button One.
261 specifics->mutable_coalesced_notification()->
262 mutable_render_info()->
263 mutable_collapsed_info()->
264 add_target();
265 specifics->mutable_coalesced_notification()->
266 mutable_render_info()->
267 mutable_collapsed_info()->
268 mutable_target(0)->
269 mutable_action()->
270 set_text(kButtonOneTitle);
271 specifics->mutable_coalesced_notification()->
272 mutable_render_info()->
273 mutable_collapsed_info()->
274 mutable_target(0)->
275 mutable_action()->
276 mutable_icon()->
277 set_url(kButtonOneIconUrl);
278 specifics->mutable_coalesced_notification()->
279 mutable_render_info()->
280 mutable_collapsed_info()->
281 mutable_target(0)->
282 mutable_action()->
283 mutable_icon()->
284 set_alt_text(kButtonOneTitle);
285 specifics->mutable_coalesced_notification()->
286 mutable_render_info()->
287 mutable_collapsed_info()->
288 mutable_target(0)->
289 mutable_action()->
290 set_url(kButtonOneUrl);
291
292 // Button Two.
293 specifics->mutable_coalesced_notification()->
294 mutable_render_info()->
295 mutable_collapsed_info()->
296 add_target();
297 specifics->mutable_coalesced_notification()->
298 mutable_render_info()->
299 mutable_collapsed_info()->
300 mutable_target(1)->
301 mutable_action()->
302 set_text(kButtonTwoTitle);
303 specifics->mutable_coalesced_notification()->
304 mutable_render_info()->
305 mutable_collapsed_info()->
306 mutable_target(1)->
307 mutable_action()->
308 mutable_icon()->
309 set_url(kButtonTwoIconUrl);
310 specifics->mutable_coalesced_notification()->
311 mutable_render_info()->
312 mutable_collapsed_info()->
313 mutable_target(1)->
314 mutable_action()->
315 mutable_icon()->
316 set_alt_text(kButtonTwoTitle);
317 specifics->mutable_coalesced_notification()->
318 mutable_render_info()->
319 mutable_collapsed_info()->
320 mutable_target(1)->
321 mutable_action()->
322 set_url(kButtonTwoUrl);
323
158 SyncData sync_data = SyncData::CreateLocalData( 324 SyncData sync_data = SyncData::CreateLocalData(
159 "syncer::SYNCED_NOTIFICATIONS", 325 "syncer::SYNCED_NOTIFICATIONS",
160 "SyncedNotificationTest", 326 "SyncedNotificationTest",
161 entity_specifics); 327 entity_specifics);
162 328
163 return sync_data; 329 return sync_data;
164 } 330 }
165 331
166 private: 332 private:
167 DISALLOW_COPY_AND_ASSIGN(SyncedNotificationTest); 333 DISALLOW_COPY_AND_ASSIGN(SyncedNotificationTest);
168 }; 334 };
169 335
170 // test simple accessors 336 // test simple accessors
171 337
172 TEST_F(SyncedNotificationTest, GetAppIdTest) { 338 TEST_F(SyncedNotificationTest, GetAppIdTest) {
173 std::string found_app_id = notification1_->app_id(); 339 std::string found_app_id = notification1_->GetAppId();
174 std::string expected_app_id(kAppId1); 340 std::string expected_app_id(kAppId1);
175 341
176 EXPECT_EQ(found_app_id, expected_app_id); 342 EXPECT_EQ(found_app_id, expected_app_id);
177 } 343 }
178 344
179 TEST_F(SyncedNotificationTest, GetKeyTest) { 345 TEST_F(SyncedNotificationTest, GetKeyTest) {
180 std::string found_key = notification1_->key(); 346 std::string found_key = notification1_->GetKey();
181 std::string expected_key(kKey1); 347 std::string expected_key(kKey1);
182 348
183 EXPECT_EQ(expected_key, found_key); 349 EXPECT_EQ(expected_key, found_key);
184 } 350 }
185 351
186 TEST_F(SyncedNotificationTest, GetTitleTest) { 352 TEST_F(SyncedNotificationTest, GetTitleTest) {
187 std::string found_title = notification1_->title(); 353 std::string found_title = notification1_->GetTitle();
188 std::string expected_title(kTitle1); 354 std::string expected_title(kTitle1);
189 355
190 EXPECT_EQ(expected_title, found_title); 356 EXPECT_EQ(expected_title, found_title);
191 } 357 }
192 358
193 TEST_F(SyncedNotificationTest, GetIconURLTest) { 359 TEST_F(SyncedNotificationTest, GetIconURLTest) {
194 std::string found_icon_url = notification1_->app_icon_url().spec(); 360 std::string found_icon_url = notification1_->GetAppIconUrl().spec();
195 std::string expected_icon_url(kIconUrl1); 361 std::string expected_icon_url(kIconUrl1);
196 362
197 EXPECT_EQ(expected_icon_url, found_icon_url); 363 EXPECT_EQ(expected_icon_url, found_icon_url);
198 } 364 }
199 365
200 TEST_F(SyncedNotificationTest, GetReadStateTest) { 366 TEST_F(SyncedNotificationTest, GetReadStateTest) {
201 SyncedNotification::ReadState found_state1 = 367 SyncedNotification::ReadState found_state1 =
202 notification1_->read_state(); 368 notification1_->GetReadState();
203 SyncedNotification::ReadState expected_state1(SyncedNotification::kUnread); 369 SyncedNotification::ReadState expected_state1(SyncedNotification::kUnread);
204 370
205 EXPECT_EQ(expected_state1, found_state1); 371 EXPECT_EQ(expected_state1, found_state1);
206 372
207 SyncedNotification::ReadState found_state2 = 373 SyncedNotification::ReadState found_state2 =
208 notification4_->read_state(); 374 notification4_->GetReadState();
209 SyncedNotification::ReadState expected_state2(SyncedNotification::kDismissed); 375 SyncedNotification::ReadState expected_state2(SyncedNotification::kDismissed);
210 376
211 EXPECT_EQ(expected_state2, found_state2); 377 EXPECT_EQ(expected_state2, found_state2);
212 } 378 }
213 379
214 // TODO(petewil): Improve ctor to pass in an image and type so this test can 380 // TODO(petewil): Improve ctor to pass in an image and type so this test can
215 // pass on actual data. 381 // pass on actual data.
216 TEST_F(SyncedNotificationTest, GetImageURLTest) { 382 TEST_F(SyncedNotificationTest, GetImageURLTest) {
217 std::string found_image_url = notification1_->image_url().spec(); 383 std::string found_image_url = notification1_->GetImageUrl().spec();
218 std::string expected_image_url = kImageUrl1; 384 std::string expected_image_url = kImageUrl1;
219 385
220 EXPECT_EQ(expected_image_url, found_image_url); 386 EXPECT_EQ(expected_image_url, found_image_url);
221 } 387 }
222 388
223 // TODO(petewil): test with a multi-line body 389 // TODO(petewil): test with a multi-line body
224 TEST_F(SyncedNotificationTest, GetTextTest) { 390 TEST_F(SyncedNotificationTest, GetTextTest) {
225 std::string found_text = notification1_->text(); 391 std::string found_text = notification1_->GetText();
226 std::string expected_text(kText1); 392 std::string expected_text(kText1);
227 393
228 EXPECT_EQ(expected_text, found_text); 394 EXPECT_EQ(expected_text, found_text);
229 } 395 }
230 396
231 TEST_F(SyncedNotificationTest, GetNotificationIdTest) { 397 TEST_F(SyncedNotificationTest, GetCreationTimeTest) {
232 std::string found_id = notification1_->notification_id(); 398 uint64 found_time = notification1_->GetCreationTime();
233 std::string expected_id(kKey1); 399 EXPECT_EQ(kFakeCreationTime, found_time);
234
235 EXPECT_EQ(expected_id, found_id);
236 } 400 }
237 401
238 // test that the ID match function works as we expect 402 TEST_F(SyncedNotificationTest, GetPriorityTest) {
239 TEST_F(SyncedNotificationTest, IdMatchesTest) { 403 double found_priority = notification1_->GetPriority();
240 EXPECT_TRUE(notification1_->IdMatches(*notification1_)); 404 EXPECT_EQ(static_cast<double>(kNotificationPriority), found_priority);
241 EXPECT_TRUE(notification2_->IdMatches(*notification2_)); 405 }
242 EXPECT_FALSE(notification1_->IdMatches(*notification2_)); 406
243 EXPECT_TRUE(notification1_->IdMatches(*notification3_)); 407 TEST_F(SyncedNotificationTest, GetButtonCountTest) {
244 EXPECT_TRUE(notification1_->IdMatches(*notification4_)); 408 int found_button_count = notification1_->GetButtonCount();
409 EXPECT_EQ(2, found_button_count);
410 }
411
412 TEST_F(SyncedNotificationTest, GetNotificationCountTest) {
413 int found_notification_count = notification1_->GetNotificationCount();
414 EXPECT_EQ(3, found_notification_count);
415 }
416
417 TEST_F(SyncedNotificationTest, GetDefaultDestinationDataTest) {
418 std::string default_destination_title =
419 notification1_->GetDefaultDestinationTitle();
420 std::string default_destination_icon_url =
421 notification1_->GetDefaultDestinationIconUrl();
422 std::string default_destination_url =
423 notification1_->GetDefaultDestinationUrl();
424 EXPECT_EQ(std::string(kDefaultDestinationTitle), default_destination_title);
425 EXPECT_EQ(std::string(kDefaultDestinationIconUrl),
426 default_destination_icon_url);
427 EXPECT_EQ(std::string(kDefaultDestinationUrl), default_destination_url);
428 }
429
430 TEST_F(SyncedNotificationTest, GetButtonDataTest) {
431 std::string button_one_title = notification1_->GetButtonOneTitle();
432 std::string button_one_icon_url = notification1_->GetButtonOneIconUrl();
433 std::string button_one_url = notification1_->GetButtonOneUrl();
434 std::string button_two_title = notification1_->GetButtonTwoTitle();
435 std::string button_two_icon_url = notification1_->GetButtonTwoIconUrl();
436 std::string button_two_url = notification1_->GetButtonTwoUrl();
437 EXPECT_EQ(std::string(kButtonOneTitle), button_one_title);
438 EXPECT_EQ(std::string(kButtonOneIconUrl), button_one_icon_url);
439 EXPECT_EQ(std::string(kButtonOneUrl), button_one_url);
440 EXPECT_EQ(std::string(kButtonTwoTitle), button_two_title);
441 EXPECT_EQ(std::string(kButtonTwoIconUrl), button_two_icon_url);
442 EXPECT_EQ(std::string(kButtonTwoUrl), button_two_url);
443 }
444
445 TEST_F(SyncedNotificationTest, ContainedNotificationTest) {
446 std::string notification_title1 =
447 notification1_->GetContainedNotificationTitle(0);
448 std::string notification_title2 =
449 notification1_->GetContainedNotificationTitle(1);
450 std::string notification_title3 =
451 notification1_->GetContainedNotificationTitle(2);
452 std::string notification_message1 =
453 notification1_->GetContainedNotificationMessage(0);
454 std::string notification_message2 =
455 notification1_->GetContainedNotificationMessage(1);
456 std::string notification_message3 =
457 notification1_->GetContainedNotificationMessage(2);
458
459 EXPECT_EQ(std::string(kContainedTitle1), notification_title1);
460 EXPECT_EQ(std::string(kContainedTitle2), notification_title2);
461 EXPECT_EQ(std::string(kContainedTitle3), notification_title3);
462 EXPECT_EQ(std::string(kContainedMessage1), notification_message1);
463 EXPECT_EQ(std::string(kContainedMessage2), notification_message2);
464 EXPECT_EQ(std::string(kContainedMessage3), notification_message3);
245 } 465 }
246 466
247 // test that EqualsIgnoringReadState works as we expect 467 // test that EqualsIgnoringReadState works as we expect
248 TEST_F(SyncedNotificationTest, EqualsIgnoringReadStateTest) { 468 TEST_F(SyncedNotificationTest, EqualsIgnoringReadStateTest) {
249 EXPECT_TRUE(notification1_->EqualsIgnoringReadState(*notification1_)); 469 EXPECT_TRUE(notification1_->EqualsIgnoringReadState(*notification1_));
250 EXPECT_TRUE(notification2_->EqualsIgnoringReadState(*notification2_)); 470 EXPECT_TRUE(notification2_->EqualsIgnoringReadState(*notification2_));
251 EXPECT_FALSE(notification1_->EqualsIgnoringReadState(*notification2_)); 471 EXPECT_FALSE(notification1_->EqualsIgnoringReadState(*notification2_));
252 EXPECT_FALSE(notification1_->EqualsIgnoringReadState(*notification3_)); 472 EXPECT_FALSE(notification1_->EqualsIgnoringReadState(*notification3_));
253 EXPECT_TRUE(notification1_->EqualsIgnoringReadState(*notification4_)); 473 EXPECT_TRUE(notification1_->EqualsIgnoringReadState(*notification4_));
254 } 474 }
255 475
256 TEST_F(SyncedNotificationTest, UpdateTest) { 476 TEST_F(SyncedNotificationTest, UpdateTest) {
257 scoped_ptr<SyncedNotification> notification5; 477 scoped_ptr<SyncedNotification> notification5;
258 notification5.reset(new SyncedNotification(sync_data1_)); 478 notification5.reset(new SyncedNotification(sync_data1_));
259 479
260 // update with the sync data from notification2, and ensure they are equal. 480 // update with the sync data from notification2, and ensure they are equal.
261 notification5->Update(sync_data2_); 481 notification5->Update(sync_data2_);
262 EXPECT_TRUE(notification5->EqualsIgnoringReadState(*notification2_)); 482 EXPECT_TRUE(notification5->EqualsIgnoringReadState(*notification2_));
263 EXPECT_EQ(notification5->read_state(), notification2_->read_state()); 483 EXPECT_EQ(notification5->GetReadState(), notification2_->GetReadState());
264 EXPECT_FALSE(notification5->EqualsIgnoringReadState(*notification1_)); 484 EXPECT_FALSE(notification5->EqualsIgnoringReadState(*notification1_));
265 } 485 }
266 486
267 // Add a test for set_local_changes and has_local_changes together 487 // Add a test for a notification being read and or deleted.
268 // Add a test for a notification being read and or deleted
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698