| 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 "base/bind.h" | 5 #include "base/bind.h" |
| 6 #include "base/message_loop/message_loop.h" | 6 #include "base/message_loop/message_loop.h" |
| 7 #include "base/prefs/scoped_user_pref_update.h" | 7 #include "base/prefs/scoped_user_pref_update.h" |
| 8 #include "base/run_loop.h" | 8 #include "base/run_loop.h" |
| 9 #include "base/strings/utf_string_conversions.h" | 9 #include "base/strings/utf_string_conversions.h" |
| 10 #include "base/threading/sequenced_worker_pool.h" | 10 #include "base/threading/sequenced_worker_pool.h" |
| 11 #include "chrome/browser/managed_mode/managed_user_refresh_token_fetcher.h" | 11 #include "chrome/browser/managed_mode/managed_user_refresh_token_fetcher.h" |
| 12 #include "chrome/browser/managed_mode/managed_user_registration_utility.h" | 12 #include "chrome/browser/managed_mode/managed_user_registration_utility.h" |
| 13 #include "chrome/browser/managed_mode/managed_user_shared_settings_service.h" | 13 #include "chrome/browser/managed_mode/managed_user_shared_settings_service.h" |
| 14 #include "chrome/browser/managed_mode/managed_user_shared_settings_service_facto
ry.h" | 14 #include "chrome/browser/managed_mode/managed_user_shared_settings_service_facto
ry.h" |
| 15 #include "chrome/browser/managed_mode/managed_user_sync_service.h" | 15 #include "chrome/browser/managed_mode/managed_user_sync_service.h" |
| 16 #include "chrome/browser/managed_mode/managed_user_sync_service_factory.h" | 16 #include "chrome/browser/managed_mode/managed_user_sync_service_factory.h" |
| 17 #include "chrome/common/pref_names.h" | 17 #include "chrome/common/pref_names.h" |
| 18 #include "chrome/test/base/testing_pref_service_syncable.h" | 18 #include "chrome/test/base/testing_pref_service_syncable.h" |
| 19 #include "chrome/test/base/testing_profile.h" | 19 #include "chrome/test/base/testing_profile.h" |
| 20 #include "content/public/browser/browser_thread.h" | 20 #include "content/public/browser/browser_thread.h" |
| 21 #include "google_apis/gaia/google_service_auth_error.h" | 21 #include "google_apis/gaia/google_service_auth_error.h" |
| 22 #include "sync/api/attachments/attachment_id.h" |
| 23 #include "sync/api/attachments/attachment_service_proxy_for_test.h" |
| 22 #include "sync/api/sync_change.h" | 24 #include "sync/api/sync_change.h" |
| 23 #include "sync/api/sync_error_factory_mock.h" | 25 #include "sync/api/sync_error_factory_mock.h" |
| 24 #include "sync/protocol/sync.pb.h" | 26 #include "sync/protocol/sync.pb.h" |
| 25 #include "testing/gtest/include/gtest/gtest.h" | 27 #include "testing/gtest/include/gtest/gtest.h" |
| 26 | 28 |
| 27 using sync_pb::ManagedUserSpecifics; | 29 using sync_pb::ManagedUserSpecifics; |
| 28 using syncer::MANAGED_USERS; | 30 using syncer::MANAGED_USERS; |
| 29 using syncer::SyncChange; | 31 using syncer::SyncChange; |
| 30 using syncer::SyncChangeList; | 32 using syncer::SyncChangeList; |
| 31 using syncer::SyncChangeProcessor; | 33 using syncer::SyncChangeProcessor; |
| (...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 211 void ManagedUserRegistrationUtilityTest::Acknowledge() { | 213 void ManagedUserRegistrationUtilityTest::Acknowledge() { |
| 212 SyncChangeList new_changes; | 214 SyncChangeList new_changes; |
| 213 const SyncChangeList& changes = change_processor()->changes(); | 215 const SyncChangeList& changes = change_processor()->changes(); |
| 214 for (SyncChangeList::const_iterator it = changes.begin(); it != changes.end(); | 216 for (SyncChangeList::const_iterator it = changes.begin(); it != changes.end(); |
| 215 ++it) { | 217 ++it) { |
| 216 EXPECT_EQ(SyncChange::ACTION_ADD, it->change_type()); | 218 EXPECT_EQ(SyncChange::ACTION_ADD, it->change_type()); |
| 217 ::sync_pb::EntitySpecifics specifics = it->sync_data().GetSpecifics(); | 219 ::sync_pb::EntitySpecifics specifics = it->sync_data().GetSpecifics(); |
| 218 EXPECT_FALSE(specifics.managed_user().acknowledged()); | 220 EXPECT_FALSE(specifics.managed_user().acknowledged()); |
| 219 specifics.mutable_managed_user()->set_acknowledged(true); | 221 specifics.mutable_managed_user()->set_acknowledged(true); |
| 220 new_changes.push_back( | 222 new_changes.push_back( |
| 221 SyncChange(FROM_HERE, SyncChange::ACTION_UPDATE, | 223 SyncChange(FROM_HERE, |
| 222 SyncData::CreateRemoteData(++sync_data_id_, | 224 SyncChange::ACTION_UPDATE, |
| 223 specifics, | 225 SyncData::CreateRemoteData( |
| 224 base::Time()))); | 226 ++sync_data_id_, |
| 227 specifics, |
| 228 base::Time(), |
| 229 syncer::AttachmentIdList(), |
| 230 syncer::AttachmentServiceProxyForTest::Create()))); |
| 225 } | 231 } |
| 226 service()->ProcessSyncChanges(FROM_HERE, new_changes); | 232 service()->ProcessSyncChanges(FROM_HERE, new_changes); |
| 227 | 233 |
| 228 run_loop_.Run(); | 234 run_loop_.Run(); |
| 229 } | 235 } |
| 230 | 236 |
| 231 void ManagedUserRegistrationUtilityTest::OnManagedUserRegistered( | 237 void ManagedUserRegistrationUtilityTest::OnManagedUserRegistered( |
| 232 const GoogleServiceAuthError& error, | 238 const GoogleServiceAuthError& error, |
| 233 const std::string& token) { | 239 const std::string& token) { |
| 234 received_callback_ = true; | 240 received_callback_ = true; |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 285 ManagedUserRegistrationUtility::GenerateNewManagedUserId(), | 291 ManagedUserRegistrationUtility::GenerateNewManagedUserId(), |
| 286 ManagedUserRegistrationInfo(base::ASCIIToUTF16("Mike"), 17), | 292 ManagedUserRegistrationInfo(base::ASCIIToUTF16("Mike"), 17), |
| 287 GetRegistrationCallback()); | 293 GetRegistrationCallback()); |
| 288 EXPECT_EQ(1u, prefs()->GetDictionary(prefs::kManagedUsers)->size()); | 294 EXPECT_EQ(1u, prefs()->GetDictionary(prefs::kManagedUsers)->size()); |
| 289 service()->StopSyncing(MANAGED_USERS); | 295 service()->StopSyncing(MANAGED_USERS); |
| 290 EXPECT_EQ(0u, prefs()->GetDictionary(prefs::kManagedUsers)->size()); | 296 EXPECT_EQ(0u, prefs()->GetDictionary(prefs::kManagedUsers)->size()); |
| 291 EXPECT_TRUE(received_callback()); | 297 EXPECT_TRUE(received_callback()); |
| 292 EXPECT_EQ(GoogleServiceAuthError::REQUEST_CANCELED, error().state()); | 298 EXPECT_EQ(GoogleServiceAuthError::REQUEST_CANCELED, error().state()); |
| 293 EXPECT_EQ(std::string(), token()); | 299 EXPECT_EQ(std::string(), token()); |
| 294 } | 300 } |
| OLD | NEW |