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

Side by Side Diff: chrome/browser/policy/user_policy_signin_service_unittest.cc

Issue 11570009: Split PrefService into PrefService, PrefServiceSimple and PrefServiceSyncable. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Merge to head again, previous had unrelated broken win_rel test. Created 8 years 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/command_line.h" 5 #include "base/command_line.h"
6 #include "base/message_loop.h" 6 #include "base/message_loop.h"
7 #include "base/run_loop.h" 7 #include "base/run_loop.h"
8 #include "chrome/browser/policy/browser_policy_connector.h" 8 #include "chrome/browser/policy/browser_policy_connector.h"
9 #include "chrome/browser/policy/mock_device_management_service.h" 9 #include "chrome/browser/policy/mock_device_management_service.h"
10 #include "chrome/browser/policy/mock_user_cloud_policy_store.h" 10 #include "chrome/browser/policy/mock_user_cloud_policy_store.h"
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
68 MOCK_METHOD1(OnPolicyRefresh, void(bool)); 68 MOCK_METHOD1(OnPolicyRefresh, void(bool));
69 69
70 virtual void SetUp() OVERRIDE { 70 virtual void SetUp() OVERRIDE {
71 device_management_service_ = new MockDeviceManagementService(); 71 device_management_service_ = new MockDeviceManagementService();
72 g_browser_process->browser_policy_connector()-> 72 g_browser_process->browser_policy_connector()->
73 SetDeviceManagementServiceForTesting( 73 SetDeviceManagementServiceForTesting(
74 scoped_ptr<DeviceManagementService>(device_management_service_)); 74 scoped_ptr<DeviceManagementService>(device_management_service_));
75 75
76 g_browser_process->browser_policy_connector()->Init(); 76 g_browser_process->browser_policy_connector()->Init();
77 77
78 local_state_.reset(new TestingPrefService); 78 local_state_.reset(new TestingPrefServiceSimple);
79 chrome::RegisterLocalState(local_state_.get()); 79 chrome::RegisterLocalState(local_state_.get());
80 static_cast<TestingBrowserProcess*>(g_browser_process)->SetLocalState( 80 static_cast<TestingBrowserProcess*>(g_browser_process)->SetLocalState(
81 local_state_.get()); 81 local_state_.get());
82 82
83 // Create a testing profile with cloud-policy-on-signin enabled, and bring 83 // Create a testing profile with cloud-policy-on-signin enabled, and bring
84 // up a UserCloudPolicyManager with a MockUserCloudPolicyStore. 84 // up a UserCloudPolicyManager with a MockUserCloudPolicyStore.
85 scoped_ptr<TestingPrefService> prefs(new TestingPrefService()); 85 scoped_ptr<TestingPrefServiceSyncable> prefs(
86 new TestingPrefServiceSyncable());
86 Profile::RegisterUserPrefs(prefs.get()); 87 Profile::RegisterUserPrefs(prefs.get());
87 chrome::RegisterUserPrefs(prefs.get()); 88 chrome::RegisterUserPrefs(prefs.get());
88 prefs->SetUserPref(prefs::kLoadCloudPolicyOnSignin, 89 prefs->SetUserPref(prefs::kLoadCloudPolicyOnSignin,
89 Value::CreateBooleanValue(true)); 90 Value::CreateBooleanValue(true));
90 TestingProfile::Builder builder; 91 TestingProfile::Builder builder;
91 builder.SetPrefService(scoped_ptr<PrefService>(prefs.Pass())); 92 builder.SetPrefService(scoped_ptr<PrefServiceSyncable>(prefs.Pass()));
92 profile_ = builder.Build().Pass(); 93 profile_ = builder.Build().Pass();
93 profile_->CreateRequestContext(); 94 profile_->CreateRequestContext();
94 95
95 mock_store_ = new MockUserCloudPolicyStore(); 96 mock_store_ = new MockUserCloudPolicyStore();
96 EXPECT_CALL(*mock_store_, Load()).Times(AnyNumber()); 97 EXPECT_CALL(*mock_store_, Load()).Times(AnyNumber());
97 manager_.reset(new UserCloudPolicyManager( 98 manager_.reset(new UserCloudPolicyManager(
98 profile_.get(), scoped_ptr<UserCloudPolicyStore>(mock_store_))); 99 profile_.get(), scoped_ptr<UserCloudPolicyStore>(mock_store_)));
99 SigninManagerFactory::GetInstance()->SetTestingFactory( 100 SigninManagerFactory::GetInstance()->SetTestingFactory(
100 profile_.get(), FakeSigninManager::Build); 101 profile_.get(), FakeSigninManager::Build);
101 102
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after
224 content::TestBrowserThread ui_thread_; 225 content::TestBrowserThread ui_thread_;
225 content::TestBrowserThread file_thread_; 226 content::TestBrowserThread file_thread_;
226 content::TestBrowserThread io_thread_; 227 content::TestBrowserThread io_thread_;
227 228
228 net::TestURLFetcherFactory url_factory_; 229 net::TestURLFetcherFactory url_factory_;
229 230
230 // Weak ptr to the MockDeviceManagementService (object is owned by the 231 // Weak ptr to the MockDeviceManagementService (object is owned by the
231 // BrowserPolicyConnector). 232 // BrowserPolicyConnector).
232 MockDeviceManagementService* device_management_service_; 233 MockDeviceManagementService* device_management_service_;
233 234
234 scoped_ptr<TestingPrefService> local_state_; 235 scoped_ptr<TestingPrefServiceSimple> local_state_;
235 }; 236 };
236 237
237 TEST_F(UserPolicySigninServiceTest, InitWhileSignedOut) { 238 TEST_F(UserPolicySigninServiceTest, InitWhileSignedOut) {
238 EXPECT_CALL(*mock_store_, Clear()); 239 EXPECT_CALL(*mock_store_, Clear());
239 // Make sure user is not signed in. 240 // Make sure user is not signed in.
240 ASSERT_TRUE(SigninManagerFactory::GetForProfile(profile_.get())-> 241 ASSERT_TRUE(SigninManagerFactory::GetForProfile(profile_.get())->
241 GetAuthenticatedUsername().empty()); 242 GetAuthenticatedUsername().empty());
242 243
243 // Let the SigninService know that the profile has been created. 244 // Let the SigninService know that the profile has been created.
244 content::NotificationService::current()->Notify( 245 content::NotificationService::current()->Notify(
(...skipping 364 matching lines...) Expand 10 before | Expand all | Expand 10 after
609 SigninManagerFactory::GetForProfile(profile_.get())->SignOut(); 610 SigninManagerFactory::GetForProfile(profile_.get())->SignOut();
610 ASSERT_FALSE(manager_->core()->service()); 611 ASSERT_FALSE(manager_->core()->service());
611 612
612 // Now sign in again. 613 // Now sign in again.
613 TestSuccessfulSignin(); 614 TestSuccessfulSignin();
614 } 615 }
615 616
616 } // namespace 617 } // namespace
617 618
618 } // namespace policy 619 } // namespace policy
OLDNEW
« no previous file with comments | « chrome/browser/policy/user_policy_signin_service_factory.cc ('k') | chrome/browser/prefs/browser_prefs.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698