| 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/supervised_user/supervised_user_refresh_token_fetcher.h
" |
| 12 #include "chrome/browser/managed_mode/managed_user_registration_utility.h" | 12 #include "chrome/browser/supervised_user/supervised_user_registration_utility.h" |
| 13 #include "chrome/browser/managed_mode/managed_user_shared_settings_service.h" | 13 #include "chrome/browser/supervised_user/supervised_user_shared_settings_service
.h" |
| 14 #include "chrome/browser/managed_mode/managed_user_shared_settings_service_facto
ry.h" | 14 #include "chrome/browser/supervised_user/supervised_user_shared_settings_service
_factory.h" |
| 15 #include "chrome/browser/managed_mode/managed_user_sync_service.h" | 15 #include "chrome/browser/supervised_user/supervised_user_sync_service.h" |
| 16 #include "chrome/browser/managed_mode/managed_user_sync_service_factory.h" | 16 #include "chrome/browser/supervised_user/supervised_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" | 22 #include "sync/api/attachments/attachment_id.h" |
| 23 #include "sync/api/attachments/attachment_service_proxy_for_test.h" | 23 #include "sync/api/attachments/attachment_service_proxy_for_test.h" |
| 24 #include "sync/api/sync_change.h" | 24 #include "sync/api/sync_change.h" |
| 25 #include "sync/api/sync_error_factory_mock.h" | 25 #include "sync/api/sync_error_factory_mock.h" |
| 26 #include "sync/protocol/sync.pb.h" | 26 #include "sync/protocol/sync.pb.h" |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 62 SyncChangeList change_list_; | 62 SyncChangeList change_list_; |
| 63 }; | 63 }; |
| 64 | 64 |
| 65 SyncError MockChangeProcessor::ProcessSyncChanges( | 65 SyncError MockChangeProcessor::ProcessSyncChanges( |
| 66 const tracked_objects::Location& from_here, | 66 const tracked_objects::Location& from_here, |
| 67 const SyncChangeList& change_list) { | 67 const SyncChangeList& change_list) { |
| 68 change_list_ = change_list; | 68 change_list_ = change_list; |
| 69 return SyncError(); | 69 return SyncError(); |
| 70 } | 70 } |
| 71 | 71 |
| 72 class MockManagedUserRefreshTokenFetcher | 72 class MockSupervisedUserRefreshTokenFetcher |
| 73 : public ManagedUserRefreshTokenFetcher { | 73 : public SupervisedUserRefreshTokenFetcher { |
| 74 public: | 74 public: |
| 75 MockManagedUserRefreshTokenFetcher() {} | 75 MockSupervisedUserRefreshTokenFetcher() {} |
| 76 virtual ~MockManagedUserRefreshTokenFetcher() {} | 76 virtual ~MockSupervisedUserRefreshTokenFetcher() {} |
| 77 | 77 |
| 78 // ManagedUserRefreshTokenFetcher implementation: | 78 // SupervisedUserRefreshTokenFetcher implementation: |
| 79 virtual void Start(const std::string& managed_user_id, | 79 virtual void Start(const std::string& supervised_user_id, |
| 80 const std::string& device_name, | 80 const std::string& device_name, |
| 81 const TokenCallback& callback) OVERRIDE { | 81 const TokenCallback& callback) OVERRIDE { |
| 82 GoogleServiceAuthError error(GoogleServiceAuthError::NONE); | 82 GoogleServiceAuthError error(GoogleServiceAuthError::NONE); |
| 83 callback.Run(error, kSupervisedUserToken); | 83 callback.Run(error, kSupervisedUserToken); |
| 84 } | 84 } |
| 85 }; | 85 }; |
| 86 | 86 |
| 87 } // namespace | 87 } // namespace |
| 88 | 88 |
| 89 class ManagedUserRegistrationUtilityTest : public ::testing::Test { | 89 class SupervisedUserRegistrationUtilityTest : public ::testing::Test { |
| 90 public: | 90 public: |
| 91 ManagedUserRegistrationUtilityTest(); | 91 SupervisedUserRegistrationUtilityTest(); |
| 92 virtual ~ManagedUserRegistrationUtilityTest(); | 92 virtual ~SupervisedUserRegistrationUtilityTest(); |
| 93 | 93 |
| 94 virtual void TearDown() OVERRIDE; | 94 virtual void TearDown() OVERRIDE; |
| 95 | 95 |
| 96 protected: | 96 protected: |
| 97 scoped_ptr<SyncChangeProcessor> CreateChangeProcessor(); | 97 scoped_ptr<SyncChangeProcessor> CreateChangeProcessor(); |
| 98 scoped_ptr<SyncErrorFactory> CreateErrorFactory(); | 98 scoped_ptr<SyncErrorFactory> CreateErrorFactory(); |
| 99 SyncData CreateRemoteData(const std::string& id, const std::string& name); | 99 SyncData CreateRemoteData(const std::string& id, const std::string& name); |
| 100 | 100 |
| 101 SyncMergeResult StartInitialSync(); | 101 SyncMergeResult StartInitialSync(); |
| 102 | 102 |
| 103 ManagedUserRegistrationUtility::RegistrationCallback | 103 SupervisedUserRegistrationUtility::RegistrationCallback |
| 104 GetRegistrationCallback(); | 104 GetRegistrationCallback(); |
| 105 | 105 |
| 106 ManagedUserRegistrationUtility* GetRegistrationUtility(); | 106 SupervisedUserRegistrationUtility* GetRegistrationUtility(); |
| 107 | 107 |
| 108 void Acknowledge(); | 108 void Acknowledge(); |
| 109 | 109 |
| 110 PrefService* prefs() { return profile_.GetTestingPrefService(); } | 110 PrefService* prefs() { return profile_.GetTestingPrefService(); } |
| 111 ManagedUserSyncService* service() { return service_; } | 111 SupervisedUserSyncService* service() { return service_; } |
| 112 ManagedUserSharedSettingsService* shared_settings_service() { | 112 SupervisedUserSharedSettingsService* shared_settings_service() { |
| 113 return shared_settings_service_; | 113 return shared_settings_service_; |
| 114 } | 114 } |
| 115 MockChangeProcessor* change_processor() { return change_processor_; } | 115 MockChangeProcessor* change_processor() { return change_processor_; } |
| 116 | 116 |
| 117 bool received_callback() const { return received_callback_; } | 117 bool received_callback() const { return received_callback_; } |
| 118 const GoogleServiceAuthError& error() const { return error_; } | 118 const GoogleServiceAuthError& error() const { return error_; } |
| 119 const std::string& token() const { return token_; } | 119 const std::string& token() const { return token_; } |
| 120 | 120 |
| 121 private: | 121 private: |
| 122 void OnManagedUserRegistered(const GoogleServiceAuthError& error, | 122 void OnSupervisedUserRegistered(const GoogleServiceAuthError& error, |
| 123 const std::string& token); | 123 const std::string& token); |
| 124 | 124 |
| 125 base::MessageLoop message_loop_; | 125 base::MessageLoop message_loop_; |
| 126 base::RunLoop run_loop_; | 126 base::RunLoop run_loop_; |
| 127 TestingProfile profile_; | 127 TestingProfile profile_; |
| 128 ManagedUserSyncService* service_; | 128 SupervisedUserSyncService* service_; |
| 129 ManagedUserSharedSettingsService* shared_settings_service_; | 129 SupervisedUserSharedSettingsService* shared_settings_service_; |
| 130 scoped_ptr<ManagedUserRegistrationUtility> registration_utility_; | 130 scoped_ptr<SupervisedUserRegistrationUtility> registration_utility_; |
| 131 | 131 |
| 132 // Owned by the ManagedUserSyncService. | 132 // Owned by the SupervisedUserSyncService. |
| 133 MockChangeProcessor* change_processor_; | 133 MockChangeProcessor* change_processor_; |
| 134 | 134 |
| 135 // A unique ID for creating "remote" Sync data. | 135 // A unique ID for creating "remote" Sync data. |
| 136 int64 sync_data_id_; | 136 int64 sync_data_id_; |
| 137 | 137 |
| 138 // Whether OnManagedUserRegistered has been called. | 138 // Whether OnSupervisedUserRegistered has been called. |
| 139 bool received_callback_; | 139 bool received_callback_; |
| 140 | 140 |
| 141 // Hold the registration result (either an error, or a token). | 141 // Hold the registration result (either an error, or a token). |
| 142 GoogleServiceAuthError error_; | 142 GoogleServiceAuthError error_; |
| 143 std::string token_; | 143 std::string token_; |
| 144 | 144 |
| 145 base::WeakPtrFactory<ManagedUserRegistrationUtilityTest> weak_ptr_factory_; | 145 base::WeakPtrFactory<SupervisedUserRegistrationUtilityTest> weak_ptr_factory_; |
| 146 }; | 146 }; |
| 147 | 147 |
| 148 ManagedUserRegistrationUtilityTest::ManagedUserRegistrationUtilityTest() | 148 SupervisedUserRegistrationUtilityTest::SupervisedUserRegistrationUtilityTest() |
| 149 : change_processor_(NULL), | 149 : change_processor_(NULL), |
| 150 sync_data_id_(0), | 150 sync_data_id_(0), |
| 151 received_callback_(false), | 151 received_callback_(false), |
| 152 error_(GoogleServiceAuthError::NUM_STATES), | 152 error_(GoogleServiceAuthError::NUM_STATES), |
| 153 weak_ptr_factory_(this) { | 153 weak_ptr_factory_(this) { |
| 154 service_ = ManagedUserSyncServiceFactory::GetForProfile(&profile_); | 154 service_ = SupervisedUserSyncServiceFactory::GetForProfile(&profile_); |
| 155 shared_settings_service_ = | 155 shared_settings_service_ = |
| 156 ManagedUserSharedSettingsServiceFactory::GetForBrowserContext(&profile_); | 156 SupervisedUserSharedSettingsServiceFactory::GetForBrowserContext( |
| 157 &profile_); |
| 157 } | 158 } |
| 158 | 159 |
| 159 ManagedUserRegistrationUtilityTest::~ManagedUserRegistrationUtilityTest() { | 160 SupervisedUserRegistrationUtilityTest:: |
| 161 ~SupervisedUserRegistrationUtilityTest() { |
| 160 EXPECT_FALSE(weak_ptr_factory_.HasWeakPtrs()); | 162 EXPECT_FALSE(weak_ptr_factory_.HasWeakPtrs()); |
| 161 } | 163 } |
| 162 | 164 |
| 163 void ManagedUserRegistrationUtilityTest::TearDown() { | 165 void SupervisedUserRegistrationUtilityTest::TearDown() { |
| 164 content::BrowserThread::GetBlockingPool()->FlushForTesting(); | 166 content::BrowserThread::GetBlockingPool()->FlushForTesting(); |
| 165 base::RunLoop().RunUntilIdle(); | 167 base::RunLoop().RunUntilIdle(); |
| 166 } | 168 } |
| 167 | 169 |
| 168 scoped_ptr<SyncChangeProcessor> | 170 scoped_ptr<SyncChangeProcessor> |
| 169 ManagedUserRegistrationUtilityTest::CreateChangeProcessor() { | 171 SupervisedUserRegistrationUtilityTest::CreateChangeProcessor() { |
| 170 EXPECT_FALSE(change_processor_); | 172 EXPECT_FALSE(change_processor_); |
| 171 change_processor_ = new MockChangeProcessor(); | 173 change_processor_ = new MockChangeProcessor(); |
| 172 return scoped_ptr<SyncChangeProcessor>(change_processor_); | 174 return scoped_ptr<SyncChangeProcessor>(change_processor_); |
| 173 } | 175 } |
| 174 | 176 |
| 175 scoped_ptr<SyncErrorFactory> | 177 scoped_ptr<SyncErrorFactory> |
| 176 ManagedUserRegistrationUtilityTest::CreateErrorFactory() { | 178 SupervisedUserRegistrationUtilityTest::CreateErrorFactory() { |
| 177 return scoped_ptr<SyncErrorFactory>(new syncer::SyncErrorFactoryMock()); | 179 return scoped_ptr<SyncErrorFactory>(new syncer::SyncErrorFactoryMock()); |
| 178 } | 180 } |
| 179 | 181 |
| 180 SyncMergeResult ManagedUserRegistrationUtilityTest::StartInitialSync() { | 182 SyncMergeResult SupervisedUserRegistrationUtilityTest::StartInitialSync() { |
| 181 SyncDataList initial_sync_data; | 183 SyncDataList initial_sync_data; |
| 182 SyncMergeResult result = | 184 SyncMergeResult result = |
| 183 service()->MergeDataAndStartSyncing(SUPERVISED_USERS, | 185 service()->MergeDataAndStartSyncing(SUPERVISED_USERS, |
| 184 initial_sync_data, | 186 initial_sync_data, |
| 185 CreateChangeProcessor(), | 187 CreateChangeProcessor(), |
| 186 CreateErrorFactory()); | 188 CreateErrorFactory()); |
| 187 EXPECT_FALSE(result.error().IsSet()); | 189 EXPECT_FALSE(result.error().IsSet()); |
| 188 return result; | 190 return result; |
| 189 } | 191 } |
| 190 | 192 |
| 191 ManagedUserRegistrationUtility::RegistrationCallback | 193 SupervisedUserRegistrationUtility::RegistrationCallback |
| 192 ManagedUserRegistrationUtilityTest::GetRegistrationCallback() { | 194 SupervisedUserRegistrationUtilityTest::GetRegistrationCallback() { |
| 193 return base::Bind( | 195 return base::Bind( |
| 194 &ManagedUserRegistrationUtilityTest::OnManagedUserRegistered, | 196 &SupervisedUserRegistrationUtilityTest::OnSupervisedUserRegistered, |
| 195 weak_ptr_factory_.GetWeakPtr()); | 197 weak_ptr_factory_.GetWeakPtr()); |
| 196 } | 198 } |
| 197 | 199 |
| 198 ManagedUserRegistrationUtility* | 200 SupervisedUserRegistrationUtility* |
| 199 ManagedUserRegistrationUtilityTest::GetRegistrationUtility() { | 201 SupervisedUserRegistrationUtilityTest::GetRegistrationUtility() { |
| 200 if (registration_utility_.get()) | 202 if (registration_utility_.get()) |
| 201 return registration_utility_.get(); | 203 return registration_utility_.get(); |
| 202 | 204 |
| 203 scoped_ptr<ManagedUserRefreshTokenFetcher> token_fetcher( | 205 scoped_ptr<SupervisedUserRefreshTokenFetcher> token_fetcher( |
| 204 new MockManagedUserRefreshTokenFetcher); | 206 new MockSupervisedUserRefreshTokenFetcher); |
| 205 registration_utility_.reset( | 207 registration_utility_.reset( |
| 206 ManagedUserRegistrationUtility::CreateImpl(prefs(), | 208 SupervisedUserRegistrationUtility::CreateImpl(prefs(), |
| 207 token_fetcher.Pass(), | 209 token_fetcher.Pass(), |
| 208 service(), | 210 service(), |
| 209 shared_settings_service())); | 211 shared_settings_service())); |
| 210 return registration_utility_.get(); | 212 return registration_utility_.get(); |
| 211 } | 213 } |
| 212 | 214 |
| 213 void ManagedUserRegistrationUtilityTest::Acknowledge() { | 215 void SupervisedUserRegistrationUtilityTest::Acknowledge() { |
| 214 SyncChangeList new_changes; | 216 SyncChangeList new_changes; |
| 215 const SyncChangeList& changes = change_processor()->changes(); | 217 const SyncChangeList& changes = change_processor()->changes(); |
| 216 for (SyncChangeList::const_iterator it = changes.begin(); it != changes.end(); | 218 for (SyncChangeList::const_iterator it = changes.begin(); it != changes.end(); |
| 217 ++it) { | 219 ++it) { |
| 218 EXPECT_EQ(SyncChange::ACTION_ADD, it->change_type()); | 220 EXPECT_EQ(SyncChange::ACTION_ADD, it->change_type()); |
| 219 ::sync_pb::EntitySpecifics specifics = it->sync_data().GetSpecifics(); | 221 ::sync_pb::EntitySpecifics specifics = it->sync_data().GetSpecifics(); |
| 220 EXPECT_FALSE(specifics.managed_user().acknowledged()); | 222 EXPECT_FALSE(specifics.managed_user().acknowledged()); |
| 221 specifics.mutable_managed_user()->set_acknowledged(true); | 223 specifics.mutable_managed_user()->set_acknowledged(true); |
| 222 new_changes.push_back( | 224 new_changes.push_back( |
| 223 SyncChange(FROM_HERE, | 225 SyncChange(FROM_HERE, |
| 224 SyncChange::ACTION_UPDATE, | 226 SyncChange::ACTION_UPDATE, |
| 225 SyncData::CreateRemoteData( | 227 SyncData::CreateRemoteData( |
| 226 ++sync_data_id_, | 228 ++sync_data_id_, |
| 227 specifics, | 229 specifics, |
| 228 base::Time(), | 230 base::Time(), |
| 229 syncer::AttachmentIdList(), | 231 syncer::AttachmentIdList(), |
| 230 syncer::AttachmentServiceProxyForTest::Create()))); | 232 syncer::AttachmentServiceProxyForTest::Create()))); |
| 231 } | 233 } |
| 232 service()->ProcessSyncChanges(FROM_HERE, new_changes); | 234 service()->ProcessSyncChanges(FROM_HERE, new_changes); |
| 233 | 235 |
| 234 run_loop_.Run(); | 236 run_loop_.Run(); |
| 235 } | 237 } |
| 236 | 238 |
| 237 void ManagedUserRegistrationUtilityTest::OnManagedUserRegistered( | 239 void SupervisedUserRegistrationUtilityTest::OnSupervisedUserRegistered( |
| 238 const GoogleServiceAuthError& error, | 240 const GoogleServiceAuthError& error, |
| 239 const std::string& token) { | 241 const std::string& token) { |
| 240 received_callback_ = true; | 242 received_callback_ = true; |
| 241 error_ = error; | 243 error_ = error; |
| 242 token_ = token; | 244 token_ = token; |
| 243 run_loop_.Quit(); | 245 run_loop_.Quit(); |
| 244 } | 246 } |
| 245 | 247 |
| 246 TEST_F(ManagedUserRegistrationUtilityTest, Register) { | 248 TEST_F(SupervisedUserRegistrationUtilityTest, Register) { |
| 247 StartInitialSync(); | 249 StartInitialSync(); |
| 248 GetRegistrationUtility()->Register( | 250 GetRegistrationUtility()->Register( |
| 249 ManagedUserRegistrationUtility::GenerateNewManagedUserId(), | 251 SupervisedUserRegistrationUtility::GenerateNewSupervisedUserId(), |
| 250 ManagedUserRegistrationInfo(base::ASCIIToUTF16("Dug"), 0), | 252 SupervisedUserRegistrationInfo(base::ASCIIToUTF16("Dug"), 0), |
| 251 GetRegistrationCallback()); | 253 GetRegistrationCallback()); |
| 252 EXPECT_EQ(1u, prefs()->GetDictionary(prefs::kSupervisedUsers)->size()); | 254 EXPECT_EQ(1u, prefs()->GetDictionary(prefs::kSupervisedUsers)->size()); |
| 253 Acknowledge(); | 255 Acknowledge(); |
| 254 | 256 |
| 255 EXPECT_TRUE(received_callback()); | 257 EXPECT_TRUE(received_callback()); |
| 256 EXPECT_EQ(GoogleServiceAuthError::NONE, error().state()); | 258 EXPECT_EQ(GoogleServiceAuthError::NONE, error().state()); |
| 257 EXPECT_FALSE(token().empty()); | 259 EXPECT_FALSE(token().empty()); |
| 258 } | 260 } |
| 259 | 261 |
| 260 TEST_F(ManagedUserRegistrationUtilityTest, RegisterBeforeInitialSync) { | 262 TEST_F(SupervisedUserRegistrationUtilityTest, RegisterBeforeInitialSync) { |
| 261 GetRegistrationUtility()->Register( | 263 GetRegistrationUtility()->Register( |
| 262 ManagedUserRegistrationUtility::GenerateNewManagedUserId(), | 264 SupervisedUserRegistrationUtility::GenerateNewSupervisedUserId(), |
| 263 ManagedUserRegistrationInfo(base::ASCIIToUTF16("Nemo"), 5), | 265 SupervisedUserRegistrationInfo(base::ASCIIToUTF16("Nemo"), 5), |
| 264 GetRegistrationCallback()); | 266 GetRegistrationCallback()); |
| 265 EXPECT_EQ(1u, prefs()->GetDictionary(prefs::kSupervisedUsers)->size()); | 267 EXPECT_EQ(1u, prefs()->GetDictionary(prefs::kSupervisedUsers)->size()); |
| 266 StartInitialSync(); | 268 StartInitialSync(); |
| 267 Acknowledge(); | 269 Acknowledge(); |
| 268 | 270 |
| 269 EXPECT_TRUE(received_callback()); | 271 EXPECT_TRUE(received_callback()); |
| 270 EXPECT_EQ(GoogleServiceAuthError::NONE, error().state()); | 272 EXPECT_EQ(GoogleServiceAuthError::NONE, error().state()); |
| 271 EXPECT_FALSE(token().empty()); | 273 EXPECT_FALSE(token().empty()); |
| 272 } | 274 } |
| 273 | 275 |
| 274 TEST_F(ManagedUserRegistrationUtilityTest, SyncServiceShutdownBeforeRegFinish) { | 276 TEST_F(SupervisedUserRegistrationUtilityTest, |
| 277 SyncServiceShutdownBeforeRegFinish) { |
| 275 StartInitialSync(); | 278 StartInitialSync(); |
| 276 GetRegistrationUtility()->Register( | 279 GetRegistrationUtility()->Register( |
| 277 ManagedUserRegistrationUtility::GenerateNewManagedUserId(), | 280 SupervisedUserRegistrationUtility::GenerateNewSupervisedUserId(), |
| 278 ManagedUserRegistrationInfo(base::ASCIIToUTF16("Remy"), 12), | 281 SupervisedUserRegistrationInfo(base::ASCIIToUTF16("Remy"), 12), |
| 279 GetRegistrationCallback()); | 282 GetRegistrationCallback()); |
| 280 EXPECT_EQ(1u, prefs()->GetDictionary(prefs::kSupervisedUsers)->size()); | 283 EXPECT_EQ(1u, prefs()->GetDictionary(prefs::kSupervisedUsers)->size()); |
| 281 service()->Shutdown(); | 284 service()->Shutdown(); |
| 282 EXPECT_EQ(0u, prefs()->GetDictionary(prefs::kSupervisedUsers)->size()); | 285 EXPECT_EQ(0u, prefs()->GetDictionary(prefs::kSupervisedUsers)->size()); |
| 283 EXPECT_TRUE(received_callback()); | 286 EXPECT_TRUE(received_callback()); |
| 284 EXPECT_EQ(GoogleServiceAuthError::REQUEST_CANCELED, error().state()); | 287 EXPECT_EQ(GoogleServiceAuthError::REQUEST_CANCELED, error().state()); |
| 285 EXPECT_EQ(std::string(), token()); | 288 EXPECT_EQ(std::string(), token()); |
| 286 } | 289 } |
| 287 | 290 |
| 288 TEST_F(ManagedUserRegistrationUtilityTest, StopSyncingBeforeRegFinish) { | 291 TEST_F(SupervisedUserRegistrationUtilityTest, StopSyncingBeforeRegFinish) { |
| 289 StartInitialSync(); | 292 StartInitialSync(); |
| 290 GetRegistrationUtility()->Register( | 293 GetRegistrationUtility()->Register( |
| 291 ManagedUserRegistrationUtility::GenerateNewManagedUserId(), | 294 SupervisedUserRegistrationUtility::GenerateNewSupervisedUserId(), |
| 292 ManagedUserRegistrationInfo(base::ASCIIToUTF16("Mike"), 17), | 295 SupervisedUserRegistrationInfo(base::ASCIIToUTF16("Mike"), 17), |
| 293 GetRegistrationCallback()); | 296 GetRegistrationCallback()); |
| 294 EXPECT_EQ(1u, prefs()->GetDictionary(prefs::kSupervisedUsers)->size()); | 297 EXPECT_EQ(1u, prefs()->GetDictionary(prefs::kSupervisedUsers)->size()); |
| 295 service()->StopSyncing(SUPERVISED_USERS); | 298 service()->StopSyncing(SUPERVISED_USERS); |
| 296 EXPECT_EQ(0u, prefs()->GetDictionary(prefs::kSupervisedUsers)->size()); | 299 EXPECT_EQ(0u, prefs()->GetDictionary(prefs::kSupervisedUsers)->size()); |
| 297 EXPECT_TRUE(received_callback()); | 300 EXPECT_TRUE(received_callback()); |
| 298 EXPECT_EQ(GoogleServiceAuthError::REQUEST_CANCELED, error().state()); | 301 EXPECT_EQ(GoogleServiceAuthError::REQUEST_CANCELED, error().state()); |
| 299 EXPECT_EQ(std::string(), token()); | 302 EXPECT_EQ(std::string(), token()); |
| 300 } | 303 } |
| OLD | NEW |