| Index: chrome/browser/notifications/sync_notifier/synced_notification_app_info_service_unittest.cc
|
| diff --git a/chrome/browser/notifications/sync_notifier/synced_notification_app_info_service_unittest.cc b/chrome/browser/notifications/sync_notifier/synced_notification_app_info_service_unittest.cc
|
| index ef9658e424cfb0fd15176a1a31f39a53493dcaa9..64771c0878c29a590937993b14285f230c132893 100644
|
| --- a/chrome/browser/notifications/sync_notifier/synced_notification_app_info_service_unittest.cc
|
| +++ b/chrome/browser/notifications/sync_notifier/synced_notification_app_info_service_unittest.cc
|
| @@ -4,10 +4,11 @@
|
|
|
| #include "chrome/browser/notifications/sync_notifier/synced_notification_app_info_service.h"
|
|
|
| +#include "chrome/browser/notifications/sync_notifier/sync_notifier_test_utils.h"
|
| #include "chrome/browser/profiles/profile.h"
|
| #include "chrome/test/base/testing_pref_service_syncable.h"
|
| #include "chrome/test/base/testing_profile.h"
|
| -#include "content/public/test/test_browser_thread_bundle.h"
|
| +#include "content/public/test/test_browser_thread.h"
|
| #include "sync/api/fake_sync_change_processor.h"
|
| #include "sync/api/sync_change.h"
|
| #include "sync/api/sync_change_processor.h"
|
| @@ -26,18 +27,6 @@ using notifier::SyncedNotificationAppInfo;
|
| using notifier::SyncedNotificationAppInfoService;
|
| using sync_pb::SyncedNotificationAppInfoSpecifics;
|
|
|
| -namespace {
|
| -const char kSendingService1Name[] = "TestService1";
|
| -const char kSendingService2Name[] = "TestService2";
|
| -const char kSendingService3Name[] = "TestService3";
|
| -const char kAppId1[] = "service1_appid1";
|
| -const char kAppId2[] = "service1_appid2";
|
| -const char kAppId3[] = "service1_appid3";
|
| -const char kAppId4[] = "service2_appid1";
|
| -const char kAppId5[] = "service2_appid2";
|
| -const char kTestIconUrl[] = "https://www.google.com/someicon.png";
|
| -} // namespace
|
| -
|
| namespace notifier {
|
|
|
| // Extract app_info id from syncer::SyncData.
|
| @@ -114,8 +103,8 @@ class SyncedNotificationAppInfoServiceTest : public testing::Test {
|
| // Create the app_info struct, setting the settings display name.
|
|
|
| // The sending_service_infos_ list will take ownership of this pointer.
|
| - SyncedNotificationAppInfo* test_item1 =
|
| - new SyncedNotificationAppInfo(kSendingService1Name);
|
| + SyncedNotificationAppInfo* test_item1 = new SyncedNotificationAppInfo(
|
| + NULL, kSendingService1Name, app_info_service);
|
|
|
| // Add some App IDs.
|
| test_item1->AddAppId(kAppId1);
|
| @@ -128,8 +117,8 @@ class SyncedNotificationAppInfoServiceTest : public testing::Test {
|
| app_info_service->sending_service_infos_.push_back(test_item1);
|
|
|
| // Add a second test item for another service.
|
| - SyncedNotificationAppInfo* test_item2 =
|
| - new SyncedNotificationAppInfo(kSendingService2Name);
|
| + SyncedNotificationAppInfo* test_item2 = new SyncedNotificationAppInfo(
|
| + NULL, kSendingService2Name, app_info_service);
|
|
|
| // Add some App IDs.
|
| test_item2->AddAppId(kAppId4);
|
| @@ -225,7 +214,6 @@ class SyncedNotificationAppInfoServiceTest : public testing::Test {
|
| private:
|
| scoped_ptr<syncer::SyncChangeProcessor> sync_processor_;
|
| scoped_ptr<syncer::SyncChangeProcessor> sync_processor_delegate_;
|
| - content::TestBrowserThreadBundle thread_bundle_;
|
|
|
| DISALLOW_COPY_AND_ASSIGN(SyncedNotificationAppInfoServiceTest);
|
| };
|
| @@ -248,6 +236,7 @@ TEST_F(SyncedNotificationAppInfoServiceTest, MergeDataAndStartSyncingTest) {
|
| TEST_F(SyncedNotificationAppInfoServiceTest, ProcessSyncChangesEmptyModel) {
|
| // We initially have no data.
|
| SyncedNotificationAppInfoService app_info_service(profile_.get());
|
| + app_info_service.set_avoid_bitmap_fetching_for_test(true);
|
|
|
| // Set up an ADD.
|
| SyncChangeList changes;
|
| @@ -274,6 +263,7 @@ TEST_F(SyncedNotificationAppInfoServiceTest, ProcessSyncChangesEmptyModel) {
|
| // Process sync changes when there is local data.
|
| TEST_F(SyncedNotificationAppInfoServiceTest, ProcessSyncChangesNonEmptyModel) {
|
| SyncedNotificationAppInfoService app_info_service(profile_.get());
|
| + app_info_service.set_avoid_bitmap_fetching_for_test(true);
|
|
|
| // Create some local fake data. We rely on the specific ids set up here.
|
| AddTestingAppInfosToList(&app_info_service);
|
| @@ -306,6 +296,7 @@ TEST_F(SyncedNotificationAppInfoServiceTest,
|
| ProcessIncomingAppInfoProtobufAddTest) {
|
| // Get an app info service object.
|
| SyncedNotificationAppInfoService app_info_service(profile_.get());
|
| + app_info_service.set_avoid_bitmap_fetching_for_test(true);
|
|
|
| // Get an app info protobuf.
|
| sync_pb::SyncedNotificationAppInfo protobuf;
|
| @@ -330,6 +321,7 @@ TEST_F(SyncedNotificationAppInfoServiceTest,
|
| ProcessIncomingAppInfoProtobufUpdateTest) {
|
| // Get an app info service object.
|
| SyncedNotificationAppInfoService app_info_service(profile_.get());
|
| + app_info_service.set_avoid_bitmap_fetching_for_test(true);
|
|
|
| // Make an app info with the same display name as the first one in the test
|
| // data.
|
| @@ -368,13 +360,14 @@ TEST_F(SyncedNotificationAppInfoServiceTest,
|
| // Test our function that creates a synced notification from a protobuf.
|
| TEST_F(SyncedNotificationAppInfoServiceTest,
|
| CreateSyncedNotificationAppInfoFromProtobufTest) {
|
| + SyncedNotificationAppInfoService app_info_service(profile_.get());
|
| // Build a protobuf and fill it with data.
|
| sync_pb::SyncedNotificationAppInfo protobuf;
|
| FillProtobufWithTestData1(protobuf);
|
|
|
| scoped_ptr<SyncedNotificationAppInfo> app_info;
|
| - app_info = SyncedNotificationAppInfoService::
|
| - CreateSyncedNotificationAppInfoFromProtobuf(protobuf);
|
| + app_info =
|
| + app_info_service.CreateSyncedNotificationAppInfoFromProtobuf(protobuf);
|
|
|
| // Ensure the app info class has the fields we expect.
|
| EXPECT_EQ(std::string(kSendingService1Name),
|
| @@ -384,7 +377,7 @@ TEST_F(SyncedNotificationAppInfoServiceTest,
|
| EXPECT_EQ(GURL(std::string(kTestIconUrl)), app_info->settings_icon_url());
|
| }
|
|
|
| -// Test our find function.
|
| +// Test our find by sending service name function.
|
| TEST_F(SyncedNotificationAppInfoServiceTest,
|
| FindSyncedNotificationAppInfoByNameTest) {
|
| SyncedNotificationAppInfoService app_info_service(profile_.get());
|
| @@ -404,6 +397,41 @@ TEST_F(SyncedNotificationAppInfoServiceTest,
|
| EXPECT_EQ(NULL, found);
|
| }
|
|
|
| +// Test our find by AppId function.
|
| +TEST_F(SyncedNotificationAppInfoServiceTest,
|
| + FindSyncedNotificationAppInfoByAppIdTest) {
|
| + SyncedNotificationAppInfoService app_info_service(profile_.get());
|
| +
|
| + AddTestingAppInfosToList(&app_info_service);
|
| +
|
| + SyncedNotificationAppInfo* found;
|
| +
|
| + found = app_info_service.FindSyncedNotificationAppInfoByAppId(kAppId1);
|
| +
|
| + EXPECT_NE(static_cast<SyncedNotificationAppInfo*>(NULL), found);
|
| + EXPECT_EQ(std::string(kSendingService1Name), found->settings_display_name());
|
| +
|
| + found = app_info_service.FindSyncedNotificationAppInfoByName(kAppId5);
|
| + EXPECT_EQ(NULL, found);
|
| +}
|
| +
|
| +// Test our find sending service name by app id function.
|
| +TEST_F(SyncedNotificationAppInfoServiceTest,
|
| + FindSendingServiceNameFromAppIdTest) {
|
| + SyncedNotificationAppInfoService app_info_service(profile_.get());
|
| +
|
| + AddTestingAppInfosToList(&app_info_service);
|
| +
|
| + std::string found_name;
|
| +
|
| + found_name = app_info_service.FindSendingServiceNameFromAppId(kAppId1);
|
| +
|
| + EXPECT_EQ(std::string(kSendingService1Name), found_name);
|
| +
|
| + found_name = app_info_service.FindSendingServiceNameFromAppId(kAppId6);
|
| + EXPECT_TRUE(found_name.empty());
|
| +}
|
| +
|
| // Test our delete function.
|
| TEST_F(SyncedNotificationAppInfoServiceTest,
|
| FreeSyncedNotificationAppInfoByNameTest) {
|
| @@ -419,4 +447,17 @@ TEST_F(SyncedNotificationAppInfoServiceTest,
|
| EXPECT_EQ(NULL, found);
|
| }
|
|
|
| +TEST_F(SyncedNotificationAppInfoServiceTest, GetAllSendingServiceNamesTest) {
|
| + SyncedNotificationAppInfoService app_info_service(profile_.get());
|
| +
|
| + AddTestingAppInfosToList(&app_info_service);
|
| +
|
| + std::vector<std::string> names;
|
| + names = app_info_service.GetAllSendingServiceNames();
|
| +
|
| + EXPECT_EQ(static_cast<unsigned int>(2), names.size());
|
| + EXPECT_EQ(kSendingService1Name, names[0]);
|
| + EXPECT_EQ(kSendingService2Name, names[1]);
|
| +}
|
| +
|
| } // namespace notifier
|
|
|