Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(283)

Side by Side Diff: chrome/browser/chromeos/policy/cloud_external_data_policy_observer_unittest.cc

Issue 1412813003: This CL replaces user_manager::UserID with AccountId. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@468875--Chrome-OS-handles-deletion-of-Gmail-account-poorly--Create-AccountID-structure-part2--user_names
Patch Set: Fix Win GN build. Created 5 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 "chrome/browser/chromeos/policy/cloud_external_data_policy_observer.h" 5 #include "chrome/browser/chromeos/policy/cloud_external_data_policy_observer.h"
6 6
7 #include <utility> 7 #include <utility>
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/files/file_path.h" 10 #include "base/files/file_path.h"
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
116 void SetDeviceLocalAccountAvatarPolicy(const std::string& account_id, 116 void SetDeviceLocalAccountAvatarPolicy(const std::string& account_id,
117 const std::string& value); 117 const std::string& value);
118 118
119 void AddDeviceLocalAccount(const std::string& account_id); 119 void AddDeviceLocalAccount(const std::string& account_id);
120 void RemoveDeviceLocalAccount(const std::string& account_id); 120 void RemoveDeviceLocalAccount(const std::string& account_id);
121 121
122 DeviceLocalAccountPolicyBroker* GetBrokerForDeviceLocalAccountUser(); 122 DeviceLocalAccountPolicyBroker* GetBrokerForDeviceLocalAccountUser();
123 123
124 void RefreshDeviceLocalAccountPolicy(DeviceLocalAccountPolicyBroker* broker); 124 void RefreshDeviceLocalAccountPolicy(DeviceLocalAccountPolicyBroker* broker);
125 125
126 void LogInAsDeviceLocalAccount(const std::string& user_id); 126 void LogInAsDeviceLocalAccount(const AccountId& account_id);
127 127
128 void SetRegularUserAvatarPolicy(const std::string& value); 128 void SetRegularUserAvatarPolicy(const std::string& value);
129 129
130 void LogInAsRegularUser(); 130 void LogInAsRegularUser();
131 131
132 const std::string device_local_account_user_id_; 132 const std::string device_local_account_user_id_;
133 133
134 std::string avatar_policy_1_data_; 134 std::string avatar_policy_1_data_;
135 std::string avatar_policy_2_data_; 135 std::string avatar_policy_2_data_;
136 std::string avatar_policy_1_; 136 std::string avatar_policy_1_;
(...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after
313 device_local_account_user_id_); 313 device_local_account_user_id_);
314 } 314 }
315 315
316 void CloudExternalDataPolicyObserverTest::RefreshDeviceLocalAccountPolicy( 316 void CloudExternalDataPolicyObserverTest::RefreshDeviceLocalAccountPolicy(
317 DeviceLocalAccountPolicyBroker* broker) { 317 DeviceLocalAccountPolicyBroker* broker) {
318 broker->core()->store()->Load(); 318 broker->core()->store()->Load();
319 device_settings_test_helper_.Flush(); 319 device_settings_test_helper_.Flush();
320 } 320 }
321 321
322 void CloudExternalDataPolicyObserverTest::LogInAsDeviceLocalAccount( 322 void CloudExternalDataPolicyObserverTest::LogInAsDeviceLocalAccount(
323 const std::string& user_id) { 323 const AccountId& account_id) {
324 user_manager_->AddUser(user_id); 324 user_manager_->AddUser(account_id);
325 325
326 device_local_account_policy_provider_.reset( 326 device_local_account_policy_provider_.reset(
327 new DeviceLocalAccountPolicyProvider( 327 new DeviceLocalAccountPolicyProvider(
328 user_id, 328 account_id.GetUserEmail(), device_local_account_policy_service_.get(),
329 device_local_account_policy_service_.get(),
330 scoped_ptr<PolicyMap>())); 329 scoped_ptr<PolicyMap>()));
331 330
332 PolicyServiceImpl::Providers providers; 331 PolicyServiceImpl::Providers providers;
333 providers.push_back(device_local_account_policy_provider_.get()); 332 providers.push_back(device_local_account_policy_provider_.get());
334 TestingProfile::Builder builder; 333 TestingProfile::Builder builder;
335 builder.SetPolicyService( 334 builder.SetPolicyService(
336 scoped_ptr<PolicyService>(new PolicyServiceImpl(providers))); 335 scoped_ptr<PolicyService>(new PolicyServiceImpl(providers)));
337 builder.SetPath(chromeos::ProfileHelper::Get()->GetProfilePathByUserIdHash( 336 builder.SetPath(chromeos::ProfileHelper::Get()->GetProfilePathByUserIdHash(
338 chromeos::ProfileHelper::GetUserIdHashByUserIdForTesting(user_id))); 337 chromeos::ProfileHelper::GetUserIdHashByUserIdForTesting(
338 account_id.GetUserEmail())));
339 339
340 profile_ = builder.Build(); 340 profile_ = builder.Build();
341 profile_->set_profile_name(user_id); 341 profile_->set_profile_name(account_id.GetUserEmail());
342 342
343 content::NotificationService::current()->Notify( 343 content::NotificationService::current()->Notify(
344 chrome::NOTIFICATION_LOGIN_USER_PROFILE_PREPARED, 344 chrome::NOTIFICATION_LOGIN_USER_PROFILE_PREPARED,
345 content::NotificationService::AllSources(), 345 content::NotificationService::AllSources(),
346 content::Details<Profile>(profile_.get())); 346 content::Details<Profile>(profile_.get()));
347 } 347 }
348 348
349 void CloudExternalDataPolicyObserverTest::SetRegularUserAvatarPolicy( 349 void CloudExternalDataPolicyObserverTest::SetRegularUserAvatarPolicy(
350 const std::string& value) { 350 const std::string& value) {
351 PolicyMap policy_map; 351 PolicyMap policy_map;
352 if (!value.empty()) { 352 if (!value.empty()) {
353 policy_map.Set( 353 policy_map.Set(
354 key::kUserAvatarImage, 354 key::kUserAvatarImage,
355 POLICY_LEVEL_MANDATORY, 355 POLICY_LEVEL_MANDATORY,
356 POLICY_SCOPE_USER, 356 POLICY_SCOPE_USER,
357 POLICY_SOURCE_CLOUD, 357 POLICY_SOURCE_CLOUD,
358 new base::StringValue(value), 358 new base::StringValue(value),
359 external_data_manager_.CreateExternalDataFetcher( 359 external_data_manager_.CreateExternalDataFetcher(
360 key::kUserAvatarImage).release()); 360 key::kUserAvatarImage).release());
361 } 361 }
362 user_policy_provider_.UpdateChromePolicy(policy_map); 362 user_policy_provider_.UpdateChromePolicy(policy_map);
363 } 363 }
364 364
365 void CloudExternalDataPolicyObserverTest::LogInAsRegularUser() { 365 void CloudExternalDataPolicyObserverTest::LogInAsRegularUser() {
366 user_manager_->AddUser(kRegularUserID); 366 user_manager_->AddUser(AccountId::FromUserEmail(kRegularUserID));
367 367
368 PolicyServiceImpl::Providers providers; 368 PolicyServiceImpl::Providers providers;
369 providers.push_back(&user_policy_provider_); 369 providers.push_back(&user_policy_provider_);
370 TestingProfile::Builder builder; 370 TestingProfile::Builder builder;
371 builder.SetPolicyService( 371 builder.SetPolicyService(
372 scoped_ptr<PolicyService>(new PolicyServiceImpl(providers))); 372 scoped_ptr<PolicyService>(new PolicyServiceImpl(providers)));
373 builder.SetPath(chromeos::ProfileHelper::Get()->GetProfilePathByUserIdHash( 373 builder.SetPath(chromeos::ProfileHelper::Get()->GetProfilePathByUserIdHash(
374 chromeos::ProfileHelper::GetUserIdHashByUserIdForTesting( 374 chromeos::ProfileHelper::GetUserIdHashByUserIdForTesting(
375 kRegularUserID))); 375 kRegularUserID)));
376 376
(...skipping 277 matching lines...) Expand 10 before | Expand all | Expand 10 after
654 ExistingDeviceLocalAccountSetAfterLogin) { 654 ExistingDeviceLocalAccountSetAfterLogin) {
655 AddDeviceLocalAccount(kDeviceLocalAccount); 655 AddDeviceLocalAccount(kDeviceLocalAccount);
656 656
657 DeviceLocalAccountPolicyBroker* broker = GetBrokerForDeviceLocalAccountUser(); 657 DeviceLocalAccountPolicyBroker* broker = GetBrokerForDeviceLocalAccountUser();
658 ASSERT_TRUE(broker); 658 ASSERT_TRUE(broker);
659 broker->external_data_manager()->Connect(NULL); 659 broker->external_data_manager()->Connect(NULL);
660 base::RunLoop().RunUntilIdle(); 660 base::RunLoop().RunUntilIdle();
661 661
662 CreateObserver(); 662 CreateObserver();
663 663
664 LogInAsDeviceLocalAccount(kDeviceLocalAccount); 664 LogInAsDeviceLocalAccount(AccountId::FromUserEmail(kDeviceLocalAccount));
665 665
666 EXPECT_TRUE(set_calls_.empty()); 666 EXPECT_TRUE(set_calls_.empty());
667 EXPECT_TRUE(cleared_calls_.empty()); 667 EXPECT_TRUE(cleared_calls_.empty());
668 EXPECT_TRUE(fetched_calls_.empty()); 668 EXPECT_TRUE(fetched_calls_.empty());
669 ClearObservations(); 669 ClearObservations();
670 670
671 SetDeviceLocalAccountAvatarPolicy(kDeviceLocalAccount, avatar_policy_1_); 671 SetDeviceLocalAccountAvatarPolicy(kDeviceLocalAccount, avatar_policy_1_);
672 RefreshDeviceLocalAccountPolicy(broker); 672 RefreshDeviceLocalAccountPolicy(broker);
673 673
674 EXPECT_TRUE(cleared_calls_.empty()); 674 EXPECT_TRUE(cleared_calls_.empty());
(...skipping 275 matching lines...) Expand 10 before | Expand all | Expand 10 after
950 950
951 EXPECT_TRUE(set_calls_.empty()); 951 EXPECT_TRUE(set_calls_.empty());
952 EXPECT_TRUE(cleared_calls_.empty()); 952 EXPECT_TRUE(cleared_calls_.empty());
953 ASSERT_EQ(1u, fetched_calls_.size()); 953 ASSERT_EQ(1u, fetched_calls_.size());
954 EXPECT_EQ(kRegularUserID, fetched_calls_.front().first); 954 EXPECT_EQ(kRegularUserID, fetched_calls_.front().first);
955 EXPECT_EQ(avatar_policy_2_data_, fetched_calls_.front().second); 955 EXPECT_EQ(avatar_policy_2_data_, fetched_calls_.front().second);
956 ClearObservations(); 956 ClearObservations();
957 } 957 }
958 958
959 } // namespace policy 959 } // namespace policy
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698