| OLD | NEW |
| 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/supervised_user/legacy/supervised_user_registration_uti
lity.h" | 5 #include "chrome/browser/supervised_user/legacy/supervised_user_registration_uti
lity.h" |
| 6 | 6 |
| 7 #include <stdint.h> | 7 #include <stdint.h> |
| 8 #include <utility> |
| 8 | 9 |
| 9 #include "base/bind.h" | 10 #include "base/bind.h" |
| 10 #include "base/message_loop/message_loop.h" | 11 #include "base/message_loop/message_loop.h" |
| 11 #include "base/prefs/scoped_user_pref_update.h" | 12 #include "base/prefs/scoped_user_pref_update.h" |
| 12 #include "base/run_loop.h" | 13 #include "base/run_loop.h" |
| 13 #include "base/strings/utf_string_conversions.h" | 14 #include "base/strings/utf_string_conversions.h" |
| 14 #include "base/threading/sequenced_worker_pool.h" | 15 #include "base/threading/sequenced_worker_pool.h" |
| 15 #include "chrome/browser/supervised_user/legacy/supervised_user_refresh_token_fe
tcher.h" | 16 #include "chrome/browser/supervised_user/legacy/supervised_user_refresh_token_fe
tcher.h" |
| 16 #include "chrome/browser/supervised_user/legacy/supervised_user_shared_settings_
service.h" | 17 #include "chrome/browser/supervised_user/legacy/supervised_user_shared_settings_
service.h" |
| 17 #include "chrome/browser/supervised_user/legacy/supervised_user_shared_settings_
service_factory.h" | 18 #include "chrome/browser/supervised_user/legacy/supervised_user_shared_settings_
service_factory.h" |
| (...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 198 weak_ptr_factory_.GetWeakPtr()); | 199 weak_ptr_factory_.GetWeakPtr()); |
| 199 } | 200 } |
| 200 | 201 |
| 201 SupervisedUserRegistrationUtility* | 202 SupervisedUserRegistrationUtility* |
| 202 SupervisedUserRegistrationUtilityTest::GetRegistrationUtility() { | 203 SupervisedUserRegistrationUtilityTest::GetRegistrationUtility() { |
| 203 if (registration_utility_.get()) | 204 if (registration_utility_.get()) |
| 204 return registration_utility_.get(); | 205 return registration_utility_.get(); |
| 205 | 206 |
| 206 scoped_ptr<SupervisedUserRefreshTokenFetcher> token_fetcher( | 207 scoped_ptr<SupervisedUserRefreshTokenFetcher> token_fetcher( |
| 207 new MockSupervisedUserRefreshTokenFetcher); | 208 new MockSupervisedUserRefreshTokenFetcher); |
| 208 registration_utility_.reset( | 209 registration_utility_.reset(SupervisedUserRegistrationUtility::CreateImpl( |
| 209 SupervisedUserRegistrationUtility::CreateImpl(prefs(), | 210 prefs(), std::move(token_fetcher), service(), shared_settings_service())); |
| 210 token_fetcher.Pass(), | |
| 211 service(), | |
| 212 shared_settings_service())); | |
| 213 return registration_utility_.get(); | 211 return registration_utility_.get(); |
| 214 } | 212 } |
| 215 | 213 |
| 216 void SupervisedUserRegistrationUtilityTest::Acknowledge() { | 214 void SupervisedUserRegistrationUtilityTest::Acknowledge() { |
| 217 SyncChangeList new_changes; | 215 SyncChangeList new_changes; |
| 218 for (const SyncChange& sync_change : change_processor()->changes()) { | 216 for (const SyncChange& sync_change : change_processor()->changes()) { |
| 219 EXPECT_EQ(SyncChange::ACTION_ADD, sync_change.change_type()); | 217 EXPECT_EQ(SyncChange::ACTION_ADD, sync_change.change_type()); |
| 220 ::sync_pb::EntitySpecifics specifics = | 218 ::sync_pb::EntitySpecifics specifics = |
| 221 sync_change.sync_data().GetSpecifics(); | 219 sync_change.sync_data().GetSpecifics(); |
| 222 EXPECT_FALSE(specifics.managed_user().acknowledged()); | 220 EXPECT_FALSE(specifics.managed_user().acknowledged()); |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 294 SupervisedUserRegistrationUtility::GenerateNewSupervisedUserId(), | 292 SupervisedUserRegistrationUtility::GenerateNewSupervisedUserId(), |
| 295 SupervisedUserRegistrationInfo(base::ASCIIToUTF16("Mike"), 17), | 293 SupervisedUserRegistrationInfo(base::ASCIIToUTF16("Mike"), 17), |
| 296 GetRegistrationCallback()); | 294 GetRegistrationCallback()); |
| 297 EXPECT_EQ(1u, prefs()->GetDictionary(prefs::kSupervisedUsers)->size()); | 295 EXPECT_EQ(1u, prefs()->GetDictionary(prefs::kSupervisedUsers)->size()); |
| 298 service()->StopSyncing(SUPERVISED_USERS); | 296 service()->StopSyncing(SUPERVISED_USERS); |
| 299 EXPECT_EQ(0u, prefs()->GetDictionary(prefs::kSupervisedUsers)->size()); | 297 EXPECT_EQ(0u, prefs()->GetDictionary(prefs::kSupervisedUsers)->size()); |
| 300 EXPECT_TRUE(received_callback()); | 298 EXPECT_TRUE(received_callback()); |
| 301 EXPECT_EQ(GoogleServiceAuthError::REQUEST_CANCELED, error().state()); | 299 EXPECT_EQ(GoogleServiceAuthError::REQUEST_CANCELED, error().state()); |
| 302 EXPECT_EQ(std::string(), token()); | 300 EXPECT_EQ(std::string(), token()); |
| 303 } | 301 } |
| OLD | NEW |