| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 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/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/message_loop/message_loop.h" |
| 8 #include "base/prefs/scoped_user_pref_update.h" | 9 #include "base/prefs/scoped_user_pref_update.h" |
| 9 #include "base/strings/stringprintf.h" | 10 #include "base/strings/stringprintf.h" |
| 10 #include "base/strings/utf_string_conversions.h" | 11 #include "base/strings/utf_string_conversions.h" |
| 11 #include "base/threading/sequenced_worker_pool.h" | 12 #include "base/threading/sequenced_worker_pool.h" |
| 12 #include "chrome/browser/managed_mode/managed_user_sync_service.h" | 13 #include "chrome/browser/managed_mode/managed_user_sync_service.h" |
| 13 #include "chrome/browser/managed_mode/managed_user_sync_service_factory.h" | 14 #include "chrome/browser/managed_mode/managed_user_sync_service_factory.h" |
| 14 #include "chrome/common/pref_names.h" | 15 #include "chrome/common/pref_names.h" |
| 15 #include "chrome/test/base/testing_profile.h" | 16 #include "chrome/test/base/testing_profile.h" |
| 17 #include "sync/api/attachments/attachment_id.h" |
| 18 #include "sync/api/attachments/attachment_service_proxy_for_test.h" |
| 16 #include "sync/api/sync_change.h" | 19 #include "sync/api/sync_change.h" |
| 17 #include "sync/api/sync_error_factory_mock.h" | 20 #include "sync/api/sync_error_factory_mock.h" |
| 18 #include "sync/protocol/sync.pb.h" | 21 #include "sync/protocol/sync.pb.h" |
| 19 #include "testing/gtest/include/gtest/gtest.h" | 22 #include "testing/gtest/include/gtest/gtest.h" |
| 20 | 23 |
| 21 #if defined(OS_CHROMEOS) | 24 #if defined(OS_CHROMEOS) |
| 22 #include "chrome/browser/chromeos/login/default_user_images.h" | 25 #include "chrome/browser/chromeos/login/default_user_images.h" |
| 23 #endif | 26 #endif |
| 24 | 27 |
| 25 using sync_pb::ManagedUserSpecifics; | 28 using sync_pb::ManagedUserSpecifics; |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 91 scoped_ptr<SyncErrorFactory> CreateErrorFactory(); | 94 scoped_ptr<SyncErrorFactory> CreateErrorFactory(); |
| 92 SyncData CreateRemoteData(const std::string& id, | 95 SyncData CreateRemoteData(const std::string& id, |
| 93 const std::string& name, | 96 const std::string& name, |
| 94 const std::string& avatar); | 97 const std::string& avatar); |
| 95 | 98 |
| 96 PrefService* prefs() { return profile_.GetPrefs(); } | 99 PrefService* prefs() { return profile_.GetPrefs(); } |
| 97 ManagedUserSyncService* service() { return service_; } | 100 ManagedUserSyncService* service() { return service_; } |
| 98 MockChangeProcessor* change_processor() { return change_processor_; } | 101 MockChangeProcessor* change_processor() { return change_processor_; } |
| 99 | 102 |
| 100 private: | 103 private: |
| 104 base::MessageLoop message_loop; |
| 101 TestingProfile profile_; | 105 TestingProfile profile_; |
| 102 ManagedUserSyncService* service_; | 106 ManagedUserSyncService* service_; |
| 103 | 107 |
| 104 // Owned by the ManagedUserSyncService. | 108 // Owned by the ManagedUserSyncService. |
| 105 MockChangeProcessor* change_processor_; | 109 MockChangeProcessor* change_processor_; |
| 106 | 110 |
| 107 // A unique ID for creating "remote" Sync data. | 111 // A unique ID for creating "remote" Sync data. |
| 108 int64 sync_data_id_; | 112 int64 sync_data_id_; |
| 109 }; | 113 }; |
| 110 | 114 |
| (...skipping 21 matching lines...) Expand all Loading... |
| 132 const std::string& id, | 136 const std::string& id, |
| 133 const std::string& name, | 137 const std::string& name, |
| 134 const std::string& chrome_avatar) { | 138 const std::string& chrome_avatar) { |
| 135 ::sync_pb::EntitySpecifics specifics; | 139 ::sync_pb::EntitySpecifics specifics; |
| 136 specifics.mutable_managed_user()->set_id(id); | 140 specifics.mutable_managed_user()->set_id(id); |
| 137 specifics.mutable_managed_user()->set_name(name); | 141 specifics.mutable_managed_user()->set_name(name); |
| 138 specifics.mutable_managed_user()->set_acknowledged(true); | 142 specifics.mutable_managed_user()->set_acknowledged(true); |
| 139 if (!chrome_avatar.empty()) | 143 if (!chrome_avatar.empty()) |
| 140 specifics.mutable_managed_user()->set_chrome_avatar(chrome_avatar); | 144 specifics.mutable_managed_user()->set_chrome_avatar(chrome_avatar); |
| 141 | 145 |
| 142 return SyncData::CreateRemoteData(++sync_data_id_, specifics, base::Time()); | 146 return SyncData::CreateRemoteData( |
| 147 ++sync_data_id_, |
| 148 specifics, |
| 149 base::Time(), |
| 150 syncer::AttachmentIdList(), |
| 151 syncer::AttachmentServiceProxyForTest::Create()); |
| 143 } | 152 } |
| 144 | 153 |
| 145 TEST_F(ManagedUserSyncServiceTest, MergeEmpty) { | 154 TEST_F(ManagedUserSyncServiceTest, MergeEmpty) { |
| 146 SyncMergeResult result = | 155 SyncMergeResult result = |
| 147 service()->MergeDataAndStartSyncing(MANAGED_USERS, | 156 service()->MergeDataAndStartSyncing(MANAGED_USERS, |
| 148 SyncDataList(), | 157 SyncDataList(), |
| 149 CreateChangeProcessor(), | 158 CreateChangeProcessor(), |
| 150 CreateErrorFactory()); | 159 CreateErrorFactory()); |
| 151 EXPECT_FALSE(result.error().IsSet()); | 160 EXPECT_FALSE(result.error().IsSet()); |
| 152 EXPECT_EQ(0, result.num_items_added()); | 161 EXPECT_EQ(0, result.num_items_added()); |
| (...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 341 EXPECT_FALSE(ManagedUserSyncService::GetAvatarIndex("chrome-avatar-index:", | 350 EXPECT_FALSE(ManagedUserSyncService::GetAvatarIndex("chrome-avatar-index:", |
| 342 &avatar)); | 351 &avatar)); |
| 343 | 352 |
| 344 EXPECT_FALSE(ManagedUserSyncService::GetAvatarIndex("chrome-avatar-index:x", | 353 EXPECT_FALSE(ManagedUserSyncService::GetAvatarIndex("chrome-avatar-index:x", |
| 345 &avatar)); | 354 &avatar)); |
| 346 | 355 |
| 347 EXPECT_FALSE(ManagedUserSyncService::GetAvatarIndex("chromeos-avatar-index:5", | 356 EXPECT_FALSE(ManagedUserSyncService::GetAvatarIndex("chromeos-avatar-index:5", |
| 348 &avatar)); | 357 &avatar)); |
| 349 #endif | 358 #endif |
| 350 } | 359 } |
| OLD | NEW |