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

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

Issue 193773003: Turn on and use the AppInfo data. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Turn on app info: Refactoring the image holders Created 6 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 | Annotate | Revision Log
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "chrome/browser/notifications/sync_notifier/synced_notification_app_inf o_service.h" 5 #include "chrome/browser/notifications/sync_notifier/synced_notification_app_inf o_service.h"
6 6
7 #include "chrome/browser/notifications/sync_notifier/sync_notifier_test_utils.h"
7 #include "chrome/browser/profiles/profile.h" 8 #include "chrome/browser/profiles/profile.h"
8 #include "chrome/test/base/testing_pref_service_syncable.h" 9 #include "chrome/test/base/testing_pref_service_syncable.h"
9 #include "chrome/test/base/testing_profile.h" 10 #include "chrome/test/base/testing_profile.h"
10 #include "content/public/test/test_browser_thread_bundle.h" 11 #include "content/public/test/test_browser_thread.h"
11 #include "sync/api/fake_sync_change_processor.h" 12 #include "sync/api/fake_sync_change_processor.h"
12 #include "sync/api/sync_change.h" 13 #include "sync/api/sync_change.h"
13 #include "sync/api/sync_change_processor.h" 14 #include "sync/api/sync_change_processor.h"
14 #include "sync/api/sync_error_factory.h" 15 #include "sync/api/sync_error_factory.h"
15 #include "sync/api/sync_error_factory_mock.h" 16 #include "sync/api/sync_error_factory_mock.h"
16 #include "sync/protocol/sync.pb.h" 17 #include "sync/protocol/sync.pb.h"
17 #include "testing/gtest/include/gtest/gtest.h" 18 #include "testing/gtest/include/gtest/gtest.h"
18 19
19 using sync_pb::EntitySpecifics; 20 using sync_pb::EntitySpecifics;
20 using syncer::SyncData; 21 using syncer::SyncData;
21 using syncer::SyncChange; 22 using syncer::SyncChange;
22 using syncer::SyncChangeList; 23 using syncer::SyncChangeList;
23 using syncer::SyncDataList; 24 using syncer::SyncDataList;
24 using syncer::SYNCED_NOTIFICATION_APP_INFO; 25 using syncer::SYNCED_NOTIFICATION_APP_INFO;
25 using notifier::SyncedNotificationAppInfo; 26 using notifier::SyncedNotificationAppInfo;
26 using notifier::SyncedNotificationAppInfoService; 27 using notifier::SyncedNotificationAppInfoService;
27 using sync_pb::SyncedNotificationAppInfoSpecifics; 28 using sync_pb::SyncedNotificationAppInfoSpecifics;
28 29
29 namespace {
30 const char kSendingService1Name[] = "TestService1";
31 const char kSendingService2Name[] = "TestService2";
32 const char kSendingService3Name[] = "TestService3";
33 const char kAppId1[] = "service1_appid1";
34 const char kAppId2[] = "service1_appid2";
35 const char kAppId3[] = "service1_appid3";
36 const char kAppId4[] = "service2_appid1";
37 const char kAppId5[] = "service2_appid2";
38 const char kTestIconUrl[] = "https://www.google.com/someicon.png";
39 } // namespace
40
41 namespace notifier { 30 namespace notifier {
42 31
43 // Extract app_info id from syncer::SyncData. 32 // Extract app_info id from syncer::SyncData.
44 std::string GetAppInfoId(const SyncData& sync_data) { 33 std::string GetAppInfoId(const SyncData& sync_data) {
45 SyncedNotificationAppInfoSpecifics specifics = 34 SyncedNotificationAppInfoSpecifics specifics =
46 sync_data.GetSpecifics().synced_notification_app_info(); 35 sync_data.GetSpecifics().synced_notification_app_info();
47 36
48 // TODO(petewil): It would be better if we had a designated unique identifier 37 // TODO(petewil): It would be better if we had a designated unique identifier
49 // instead of relying on the display name to be unique. 38 // instead of relying on the display name to be unique.
50 return specifics.synced_notification_app_info(0).settings_display_name(); 39 return specifics.synced_notification_app_info(0).settings_display_name();
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
107 96
108 // Overrides from testing::Test. 97 // Overrides from testing::Test.
109 virtual void SetUp() { profile_.reset(new TestingProfile()); } 98 virtual void SetUp() { profile_.reset(new TestingProfile()); }
110 99
111 // Introduce some sample test data into the system. 100 // Introduce some sample test data into the system.
112 void AddTestingAppInfosToList( 101 void AddTestingAppInfosToList(
113 SyncedNotificationAppInfoService* app_info_service) { 102 SyncedNotificationAppInfoService* app_info_service) {
114 // Create the app_info struct, setting the settings display name. 103 // Create the app_info struct, setting the settings display name.
115 104
116 // The sending_service_infos_ list will take ownership of this pointer. 105 // The sending_service_infos_ list will take ownership of this pointer.
117 SyncedNotificationAppInfo* test_item1 = 106 SyncedNotificationAppInfo* test_item1 = new SyncedNotificationAppInfo(
118 new SyncedNotificationAppInfo(kSendingService1Name); 107 NULL, kSendingService1Name, app_info_service);
119 108
120 // Add some App IDs. 109 // Add some App IDs.
121 test_item1->AddAppId(kAppId1); 110 test_item1->AddAppId(kAppId1);
122 test_item1->AddAppId(kAppId2); 111 test_item1->AddAppId(kAppId2);
123 112
124 // Set this icon GURL. 113 // Set this icon GURL.
125 test_item1->SetSettingsIcon(GURL(kTestIconUrl)); 114 test_item1->SetSettingsURLs(GURL(kTestIconUrl), GURL());
dewittj 2014/03/24 17:35:50 probably want to test with non-empty highres urls
Pete Williamson 2014/03/25 00:08:37 We do test that in ImageHolderTest.IsFetchingDoneT
126 115
127 // Add to the list. 116 // Add to the list.
128 app_info_service->sending_service_infos_.push_back(test_item1); 117 app_info_service->sending_service_infos_.push_back(test_item1);
129 118
130 // Add a second test item for another service. 119 // Add a second test item for another service.
131 SyncedNotificationAppInfo* test_item2 = 120 SyncedNotificationAppInfo* test_item2 = new SyncedNotificationAppInfo(
132 new SyncedNotificationAppInfo(kSendingService2Name); 121 NULL, kSendingService2Name, app_info_service);
133 122
134 // Add some App IDs. 123 // Add some App IDs.
135 test_item2->AddAppId(kAppId4); 124 test_item2->AddAppId(kAppId4);
136 test_item2->AddAppId(kAppId5); 125 test_item2->AddAppId(kAppId5);
137 126
138 // Set thi icon GURL. 127 // Set thi icon GURL.
139 test_item2->SetSettingsIcon(GURL(kTestIconUrl)); 128 test_item2->SetSettingsURLs(GURL(kTestIconUrl), GURL());
140 129
141 // Add to the list. 130 // Add to the list.
142 app_info_service->sending_service_infos_.push_back(test_item2); 131 app_info_service->sending_service_infos_.push_back(test_item2);
143 } 132 }
144 133
145 // Put some representative test data into the AppInfo protobuf. 134 // Put some representative test data into the AppInfo protobuf.
146 static void FillProtobufWithTestData1( 135 static void FillProtobufWithTestData1(
147 sync_pb::SyncedNotificationAppInfo& protobuf) { 136 sync_pb::SyncedNotificationAppInfo& protobuf) {
148 protobuf.add_app_id(std::string(kAppId1)); 137 protobuf.add_app_id(std::string(kAppId1));
149 protobuf.add_app_id(std::string(kAppId2)); 138 protobuf.add_app_id(std::string(kAppId2));
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
218 scoped_ptr<syncer::SyncChangeProcessor> PassProcessor() { 207 scoped_ptr<syncer::SyncChangeProcessor> PassProcessor() {
219 return sync_processor_delegate_.Pass(); 208 return sync_processor_delegate_.Pass();
220 } 209 }
221 210
222 protected: 211 protected:
223 scoped_ptr<TestingProfile> profile_; 212 scoped_ptr<TestingProfile> profile_;
224 213
225 private: 214 private:
226 scoped_ptr<syncer::SyncChangeProcessor> sync_processor_; 215 scoped_ptr<syncer::SyncChangeProcessor> sync_processor_;
227 scoped_ptr<syncer::SyncChangeProcessor> sync_processor_delegate_; 216 scoped_ptr<syncer::SyncChangeProcessor> sync_processor_delegate_;
228 content::TestBrowserThreadBundle thread_bundle_;
229 217
230 DISALLOW_COPY_AND_ASSIGN(SyncedNotificationAppInfoServiceTest); 218 DISALLOW_COPY_AND_ASSIGN(SyncedNotificationAppInfoServiceTest);
231 }; 219 };
232 220
233 // Null data case - we have no data, and sync has no data when we start up. 221 // Null data case - we have no data, and sync has no data when we start up.
234 TEST_F(SyncedNotificationAppInfoServiceTest, MergeDataAndStartSyncingTest) { 222 TEST_F(SyncedNotificationAppInfoServiceTest, MergeDataAndStartSyncingTest) {
235 SyncedNotificationAppInfoService app_info_service(profile_.get()); 223 SyncedNotificationAppInfoService app_info_service(profile_.get());
236 224
237 app_info_service.MergeDataAndStartSyncing( 225 app_info_service.MergeDataAndStartSyncing(
238 SYNCED_NOTIFICATION_APP_INFO, 226 SYNCED_NOTIFICATION_APP_INFO,
239 SyncDataList(), // Empty. 227 SyncDataList(), // Empty.
240 PassProcessor(), 228 PassProcessor(),
241 scoped_ptr<syncer::SyncErrorFactory>(new syncer::SyncErrorFactoryMock())); 229 scoped_ptr<syncer::SyncErrorFactory>(new syncer::SyncErrorFactoryMock()));
242 230
243 EXPECT_EQ(static_cast<size_t>(0), 231 EXPECT_EQ(static_cast<size_t>(0),
244 app_info_service.sending_service_infos_size()); 232 app_info_service.sending_service_infos_size());
245 } 233 }
246 234
247 // Process sync changes when there is no local data. 235 // Process sync changes when there is no local data.
248 TEST_F(SyncedNotificationAppInfoServiceTest, ProcessSyncChangesEmptyModel) { 236 TEST_F(SyncedNotificationAppInfoServiceTest, ProcessSyncChangesEmptyModel) {
249 // We initially have no data. 237 // We initially have no data.
250 SyncedNotificationAppInfoService app_info_service(profile_.get()); 238 SyncedNotificationAppInfoService app_info_service(profile_.get());
239 app_info_service.set_avoid_bitmap_fetching_for_test(true);
251 240
252 // Set up an ADD. 241 // Set up an ADD.
253 SyncChangeList changes; 242 SyncChangeList changes;
254 changes.push_back(CreateSyncChange(SyncChange::ACTION_ADD, 243 changes.push_back(CreateSyncChange(SyncChange::ACTION_ADD,
255 kSendingService1Name, 244 kSendingService1Name,
256 kTestIconUrl, 245 kTestIconUrl,
257 kAppId1, 246 kAppId1,
258 kAppId2)); 247 kAppId2));
259 248
260 // Process the changes we built. 249 // Process the changes we built.
261 app_info_service.ProcessSyncChanges(FROM_HERE, changes); 250 app_info_service.ProcessSyncChanges(FROM_HERE, changes);
262 251
263 // Verify sync change made it to the SyncedNotificationAppInfo list. 252 // Verify sync change made it to the SyncedNotificationAppInfo list.
264 SyncedNotificationAppInfo* app_info1 = 253 SyncedNotificationAppInfo* app_info1 =
265 app_info_service.FindSyncedNotificationAppInfoByName( 254 app_info_service.FindSyncedNotificationAppInfoByName(
266 kSendingService1Name); 255 kSendingService1Name);
267 EXPECT_NE(static_cast<SyncedNotificationAppInfo*>(NULL), app_info1); 256 EXPECT_NE(static_cast<SyncedNotificationAppInfo*>(NULL), app_info1);
268 EXPECT_TRUE(app_info1->HasAppId(kAppId1)); 257 EXPECT_TRUE(app_info1->HasAppId(kAppId1));
269 EXPECT_TRUE(app_info1->HasAppId(kAppId2)); 258 EXPECT_TRUE(app_info1->HasAppId(kAppId2));
270 EXPECT_FALSE(app_info1->HasAppId(kAppId3)); 259 EXPECT_FALSE(app_info1->HasAppId(kAppId3));
271 EXPECT_EQ(app_info1->settings_icon_url(), GURL(kTestIconUrl)); 260 EXPECT_EQ(app_info1->settings_icon_url(), GURL(kTestIconUrl));
272 } 261 }
273 262
274 // Process sync changes when there is local data. 263 // Process sync changes when there is local data.
275 TEST_F(SyncedNotificationAppInfoServiceTest, ProcessSyncChangesNonEmptyModel) { 264 TEST_F(SyncedNotificationAppInfoServiceTest, ProcessSyncChangesNonEmptyModel) {
276 SyncedNotificationAppInfoService app_info_service(profile_.get()); 265 SyncedNotificationAppInfoService app_info_service(profile_.get());
266 app_info_service.set_avoid_bitmap_fetching_for_test(true);
277 267
278 // Create some local fake data. We rely on the specific ids set up here. 268 // Create some local fake data. We rely on the specific ids set up here.
279 AddTestingAppInfosToList(&app_info_service); 269 AddTestingAppInfosToList(&app_info_service);
280 270
281 // Set up an UPDATE. 271 // Set up an UPDATE.
282 SyncChangeList changes; 272 SyncChangeList changes;
283 273
284 changes.push_back(CreateSyncChange(SyncChange::ACTION_UPDATE, 274 changes.push_back(CreateSyncChange(SyncChange::ACTION_UPDATE,
285 kSendingService1Name, 275 kSendingService1Name,
286 kTestIconUrl, 276 kTestIconUrl,
(...skipping 12 matching lines...) Expand all
299 EXPECT_FALSE(app_info1->HasAppId(kAppId2)); 289 EXPECT_FALSE(app_info1->HasAppId(kAppId2));
300 EXPECT_TRUE(app_info1->HasAppId(kAppId3)); 290 EXPECT_TRUE(app_info1->HasAppId(kAppId3));
301 EXPECT_EQ(app_info1->settings_icon_url(), GURL(kTestIconUrl)); 291 EXPECT_EQ(app_info1->settings_icon_url(), GURL(kTestIconUrl));
302 } 292 }
303 293
304 // Test ProcessIncomingAppInfoProtobuf with an add. 294 // Test ProcessIncomingAppInfoProtobuf with an add.
305 TEST_F(SyncedNotificationAppInfoServiceTest, 295 TEST_F(SyncedNotificationAppInfoServiceTest,
306 ProcessIncomingAppInfoProtobufAddTest) { 296 ProcessIncomingAppInfoProtobufAddTest) {
307 // Get an app info service object. 297 // Get an app info service object.
308 SyncedNotificationAppInfoService app_info_service(profile_.get()); 298 SyncedNotificationAppInfoService app_info_service(profile_.get());
299 app_info_service.set_avoid_bitmap_fetching_for_test(true);
309 300
310 // Get an app info protobuf. 301 // Get an app info protobuf.
311 sync_pb::SyncedNotificationAppInfo protobuf; 302 sync_pb::SyncedNotificationAppInfo protobuf;
312 FillProtobufWithTestData1(protobuf); 303 FillProtobufWithTestData1(protobuf);
313 304
314 // Call the function we are testing. 305 // Call the function we are testing.
315 app_info_service.ProcessIncomingAppInfoProtobuf(protobuf); 306 app_info_service.ProcessIncomingAppInfoProtobuf(protobuf);
316 307
317 // Ensure that we now have an app_info in our list, and it looks like we 308 // Ensure that we now have an app_info in our list, and it looks like we
318 // expect. 309 // expect.
319 notifier::SyncedNotificationAppInfo* found_app_info; 310 notifier::SyncedNotificationAppInfo* found_app_info;
320 found_app_info = app_info_service.FindSyncedNotificationAppInfoByName( 311 found_app_info = app_info_service.FindSyncedNotificationAppInfoByName(
321 kSendingService1Name); 312 kSendingService1Name);
322 EXPECT_NE(static_cast<notifier::SyncedNotificationAppInfo*>(NULL), 313 EXPECT_NE(static_cast<notifier::SyncedNotificationAppInfo*>(NULL),
323 found_app_info); 314 found_app_info);
324 EXPECT_TRUE(found_app_info->HasAppId(kAppId1)); 315 EXPECT_TRUE(found_app_info->HasAppId(kAppId1));
325 EXPECT_TRUE(found_app_info->HasAppId(kAppId2)); 316 EXPECT_TRUE(found_app_info->HasAppId(kAppId2));
326 } 317 }
327 318
328 // Test ProcessIncomingAppInfoProtobuf with an update 319 // Test ProcessIncomingAppInfoProtobuf with an update
329 TEST_F(SyncedNotificationAppInfoServiceTest, 320 TEST_F(SyncedNotificationAppInfoServiceTest,
330 ProcessIncomingAppInfoProtobufUpdateTest) { 321 ProcessIncomingAppInfoProtobufUpdateTest) {
331 // Get an app info service object. 322 // Get an app info service object.
332 SyncedNotificationAppInfoService app_info_service(profile_.get()); 323 SyncedNotificationAppInfoService app_info_service(profile_.get());
324 app_info_service.set_avoid_bitmap_fetching_for_test(true);
333 325
334 // Make an app info with the same display name as the first one in the test 326 // Make an app info with the same display name as the first one in the test
335 // data. 327 // data.
336 sync_pb::SyncedNotificationAppInfo protobuf1; 328 sync_pb::SyncedNotificationAppInfo protobuf1;
337 FillProtobufWithTestData1(protobuf1); 329 FillProtobufWithTestData1(protobuf1);
338 app_info_service.ProcessIncomingAppInfoProtobuf(protobuf1); 330 app_info_service.ProcessIncomingAppInfoProtobuf(protobuf1);
339 331
340 // Ensure that we now have an app_info in our list, and it looks like we 332 // Ensure that we now have an app_info in our list, and it looks like we
341 // expect. 333 // expect.
342 notifier::SyncedNotificationAppInfo* found_app_info1; 334 notifier::SyncedNotificationAppInfo* found_app_info1;
(...skipping 18 matching lines...) Expand all
361 kSendingService1Name); 353 kSendingService1Name);
362 EXPECT_NE(static_cast<notifier::SyncedNotificationAppInfo*>(NULL), 354 EXPECT_NE(static_cast<notifier::SyncedNotificationAppInfo*>(NULL),
363 found_app_info2); 355 found_app_info2);
364 EXPECT_FALSE(found_app_info2->HasAppId(kAppId1)); 356 EXPECT_FALSE(found_app_info2->HasAppId(kAppId1));
365 EXPECT_TRUE(found_app_info2->HasAppId(kAppId3)); 357 EXPECT_TRUE(found_app_info2->HasAppId(kAppId3));
366 } 358 }
367 359
368 // Test our function that creates a synced notification from a protobuf. 360 // Test our function that creates a synced notification from a protobuf.
369 TEST_F(SyncedNotificationAppInfoServiceTest, 361 TEST_F(SyncedNotificationAppInfoServiceTest,
370 CreateSyncedNotificationAppInfoFromProtobufTest) { 362 CreateSyncedNotificationAppInfoFromProtobufTest) {
363 SyncedNotificationAppInfoService app_info_service(profile_.get());
371 // Build a protobuf and fill it with data. 364 // Build a protobuf and fill it with data.
372 sync_pb::SyncedNotificationAppInfo protobuf; 365 sync_pb::SyncedNotificationAppInfo protobuf;
373 FillProtobufWithTestData1(protobuf); 366 FillProtobufWithTestData1(protobuf);
374 367
375 scoped_ptr<SyncedNotificationAppInfo> app_info; 368 scoped_ptr<SyncedNotificationAppInfo> app_info;
376 app_info = SyncedNotificationAppInfoService:: 369 app_info =
377 CreateSyncedNotificationAppInfoFromProtobuf(protobuf); 370 app_info_service.CreateSyncedNotificationAppInfoFromProtobuf(protobuf);
378 371
379 // Ensure the app info class has the fields we expect. 372 // Ensure the app info class has the fields we expect.
380 EXPECT_EQ(std::string(kSendingService1Name), 373 EXPECT_EQ(std::string(kSendingService1Name),
381 app_info->settings_display_name()); 374 app_info->settings_display_name());
382 EXPECT_TRUE(app_info->HasAppId(kAppId1)); 375 EXPECT_TRUE(app_info->HasAppId(kAppId1));
383 EXPECT_TRUE(app_info->HasAppId(kAppId2)); 376 EXPECT_TRUE(app_info->HasAppId(kAppId2));
384 EXPECT_EQ(GURL(std::string(kTestIconUrl)), app_info->settings_icon_url()); 377 EXPECT_EQ(GURL(std::string(kTestIconUrl)), app_info->settings_icon_url());
385 } 378 }
386 379
387 // Test our find function. 380 // Test our find by sending service name function.
388 TEST_F(SyncedNotificationAppInfoServiceTest, 381 TEST_F(SyncedNotificationAppInfoServiceTest,
389 FindSyncedNotificationAppInfoByNameTest) { 382 FindSyncedNotificationAppInfoByNameTest) {
390 SyncedNotificationAppInfoService app_info_service(profile_.get()); 383 SyncedNotificationAppInfoService app_info_service(profile_.get());
391 384
392 AddTestingAppInfosToList(&app_info_service); 385 AddTestingAppInfosToList(&app_info_service);
393 386
394 SyncedNotificationAppInfo* found; 387 SyncedNotificationAppInfo* found;
395 388
396 found = app_info_service.FindSyncedNotificationAppInfoByName( 389 found = app_info_service.FindSyncedNotificationAppInfoByName(
397 kSendingService1Name); 390 kSendingService1Name);
398 391
399 EXPECT_NE(static_cast<SyncedNotificationAppInfo*>(NULL), found); 392 EXPECT_NE(static_cast<SyncedNotificationAppInfo*>(NULL), found);
400 EXPECT_EQ(std::string(kSendingService1Name), found->settings_display_name()); 393 EXPECT_EQ(std::string(kSendingService1Name), found->settings_display_name());
401 394
402 found = app_info_service.FindSyncedNotificationAppInfoByName( 395 found = app_info_service.FindSyncedNotificationAppInfoByName(
403 kSendingService3Name); 396 kSendingService3Name);
404 EXPECT_EQ(NULL, found); 397 EXPECT_EQ(NULL, found);
405 } 398 }
406 399
400 // Test our find by AppId function.
401 TEST_F(SyncedNotificationAppInfoServiceTest,
402 FindSyncedNotificationAppInfoByAppIdTest) {
403 SyncedNotificationAppInfoService app_info_service(profile_.get());
404
405 AddTestingAppInfosToList(&app_info_service);
406
407 SyncedNotificationAppInfo* found;
408
409 found = app_info_service.FindSyncedNotificationAppInfoByAppId(kAppId1);
410
411 EXPECT_NE(static_cast<SyncedNotificationAppInfo*>(NULL), found);
412 EXPECT_EQ(std::string(kSendingService1Name), found->settings_display_name());
413
414 found = app_info_service.FindSyncedNotificationAppInfoByName(kAppId5);
415 EXPECT_EQ(NULL, found);
416 }
417
418 // Test our find sending service name by app id function.
419 TEST_F(SyncedNotificationAppInfoServiceTest,
420 FindSendingServiceNameFromAppIdTest) {
421 SyncedNotificationAppInfoService app_info_service(profile_.get());
422
423 AddTestingAppInfosToList(&app_info_service);
424
425 std::string found_name;
426
427 found_name = app_info_service.FindSendingServiceNameFromAppId(kAppId1);
428
429 EXPECT_EQ(std::string(kSendingService1Name), found_name);
430
431 found_name = app_info_service.FindSendingServiceNameFromAppId(kAppId6);
432 EXPECT_TRUE(found_name.empty());
433 }
434
407 // Test our delete function. 435 // Test our delete function.
408 TEST_F(SyncedNotificationAppInfoServiceTest, 436 TEST_F(SyncedNotificationAppInfoServiceTest,
409 FreeSyncedNotificationAppInfoByNameTest) { 437 FreeSyncedNotificationAppInfoByNameTest) {
410 SyncedNotificationAppInfoService app_info_service(profile_.get()); 438 SyncedNotificationAppInfoService app_info_service(profile_.get());
411 439
412 AddTestingAppInfosToList(&app_info_service); 440 AddTestingAppInfosToList(&app_info_service);
413 441
414 SyncedNotificationAppInfo* found; 442 SyncedNotificationAppInfo* found;
415 443
416 app_info_service.FreeSyncedNotificationAppInfoByName(kSendingService1Name); 444 app_info_service.FreeSyncedNotificationAppInfoByName(kSendingService1Name);
417 found = app_info_service.FindSyncedNotificationAppInfoByName( 445 found = app_info_service.FindSyncedNotificationAppInfoByName(
418 kSendingService1Name); 446 kSendingService1Name);
419 EXPECT_EQ(NULL, found); 447 EXPECT_EQ(NULL, found);
420 } 448 }
421 449
450 TEST_F(SyncedNotificationAppInfoServiceTest, GetAllSendingServiceNamesTest) {
451 SyncedNotificationAppInfoService app_info_service(profile_.get());
452
453 AddTestingAppInfosToList(&app_info_service);
454
455 std::vector<std::string> names;
456 names = app_info_service.GetAllSendingServiceNames();
457
458 EXPECT_EQ(static_cast<unsigned int>(2), names.size());
459 EXPECT_EQ(kSendingService1Name, names[0]);
460 EXPECT_EQ(kSendingService2Name, names[1]);
461 }
462
422 } // namespace notifier 463 } // namespace notifier
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698