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

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

Issue 17127002: Correctly integrate StoragePartition into TestingProfile. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix InstantNTP test. Created 7 years, 5 months 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/memory/ref_counted.h" 5 #include "base/memory/ref_counted.h"
6 #include "base/memory/scoped_ptr.h" 6 #include "base/memory/scoped_ptr.h"
7 #include "base/message_loop/message_loop.h" 7 #include "base/message_loop/message_loop.h"
8 #include "base/prefs/pref_service.h" 8 #include "base/prefs/pref_service.h"
9 #include "base/run_loop.h" 9 #include "base/run_loop.h"
10 #include "base/time/time.h" 10 #include "base/time/time.h"
(...skipping 10 matching lines...) Expand all
21 #include "chrome/browser/signin/fake_signin_manager.h" 21 #include "chrome/browser/signin/fake_signin_manager.h"
22 #include "chrome/browser/signin/signin_manager.h" 22 #include "chrome/browser/signin/signin_manager.h"
23 #include "chrome/browser/signin/signin_manager_factory.h" 23 #include "chrome/browser/signin/signin_manager_factory.h"
24 #include "chrome/test/base/testing_browser_process.h" 24 #include "chrome/test/base/testing_browser_process.h"
25 #include "chrome/test/base/testing_pref_service_syncable.h" 25 #include "chrome/test/base/testing_pref_service_syncable.h"
26 #include "chrome/test/base/testing_profile.h" 26 #include "chrome/test/base/testing_profile.h"
27 #include "content/public/browser/browser_context.h" 27 #include "content/public/browser/browser_context.h"
28 #include "content/public/browser/notification_details.h" 28 #include "content/public/browser/notification_details.h"
29 #include "content/public/browser/notification_service.h" 29 #include "content/public/browser/notification_service.h"
30 #include "content/public/browser/notification_source.h" 30 #include "content/public/browser/notification_source.h"
31 #include "content/public/test/test_browser_thread.h" 31 #include "content/public/test/test_browser_thread_bundle.h"
32 #include "google_apis/gaia/gaia_constants.h" 32 #include "google_apis/gaia/gaia_constants.h"
33 #include "google_apis/gaia/google_service_auth_error.h" 33 #include "google_apis/gaia/google_service_auth_error.h"
34 #include "net/http/http_status_code.h" 34 #include "net/http/http_status_code.h"
35 #include "net/url_request/test_url_fetcher_factory.h" 35 #include "net/url_request/test_url_fetcher_factory.h"
36 #include "net/url_request/url_request_context_getter.h" 36 #include "net/url_request/url_request_context_getter.h"
37 #include "net/url_request/url_request_status.h" 37 #include "net/url_request/url_request_status.h"
38 #include "testing/gmock/include/gmock/gmock.h" 38 #include "testing/gmock/include/gmock/gmock.h"
39 #include "testing/gtest/include/gtest/gtest.h" 39 #include "testing/gtest/include/gtest/gtest.h"
40 40
41 #if defined(OS_ANDROID) 41 #if defined(OS_ANDROID)
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
133 133
134 private: 134 private:
135 FetchOAuth2TokenCallback pending_callback_; 135 FetchOAuth2TokenCallback pending_callback_;
136 }; 136 };
137 137
138 #endif 138 #endif
139 139
140 class UserPolicySigninServiceTest : public testing::Test { 140 class UserPolicySigninServiceTest : public testing::Test {
141 public: 141 public:
142 UserPolicySigninServiceTest() 142 UserPolicySigninServiceTest()
143 : loop_(base::MessageLoop::TYPE_IO), 143 : thread_bundle_(content::TestBrowserThreadBundle::IO_MAINLOOP),
144 ui_thread_(content::BrowserThread::UI, &loop_),
145 file_thread_(content::BrowserThread::FILE, &loop_),
146 io_thread_(content::BrowserThread::IO, &loop_),
147 register_completed_(false) {} 144 register_completed_(false) {}
148 145
149 MOCK_METHOD1(OnPolicyRefresh, void(bool)); 146 MOCK_METHOD1(OnPolicyRefresh, void(bool));
150 147
151 void OnRegisterCompleted(scoped_ptr<CloudPolicyClient> client) { 148 void OnRegisterCompleted(scoped_ptr<CloudPolicyClient> client) {
152 register_completed_ = true; 149 register_completed_ = true;
153 created_client_.swap(client); 150 created_client_.swap(client);
154 } 151 }
155 152
156 void RegisterPolicyClientWithCallback(UserPolicySigninService* service) { 153 void RegisterPolicyClientWithCallback(UserPolicySigninService* service) {
(...skipping 22 matching lines...) Expand all
179 local_state_.get(), system_request_context); 176 local_state_.get(), system_request_context);
180 177
181 // Create a testing profile with cloud-policy-on-signin enabled, and bring 178 // Create a testing profile with cloud-policy-on-signin enabled, and bring
182 // up a UserCloudPolicyManager with a MockUserCloudPolicyStore. 179 // up a UserCloudPolicyManager with a MockUserCloudPolicyStore.
183 scoped_ptr<TestingPrefServiceSyncable> prefs( 180 scoped_ptr<TestingPrefServiceSyncable> prefs(
184 new TestingPrefServiceSyncable()); 181 new TestingPrefServiceSyncable());
185 chrome::RegisterUserProfilePrefs(prefs->registry()); 182 chrome::RegisterUserProfilePrefs(prefs->registry());
186 TestingProfile::Builder builder; 183 TestingProfile::Builder builder;
187 builder.SetPrefService(scoped_ptr<PrefServiceSyncable>(prefs.Pass())); 184 builder.SetPrefService(scoped_ptr<PrefServiceSyncable>(prefs.Pass()));
188 profile_ = builder.Build().Pass(); 185 profile_ = builder.Build().Pass();
189 profile_->CreateRequestContext();
190 186
191 mock_store_ = new MockUserCloudPolicyStore(); 187 mock_store_ = new MockUserCloudPolicyStore();
192 EXPECT_CALL(*mock_store_, Load()).Times(AnyNumber()); 188 EXPECT_CALL(*mock_store_, Load()).Times(AnyNumber());
193 manager_.reset(new UserCloudPolicyManager( 189 manager_.reset(new UserCloudPolicyManager(
194 profile_.get(), scoped_ptr<UserCloudPolicyStore>(mock_store_))); 190 profile_.get(), scoped_ptr<UserCloudPolicyStore>(mock_store_)));
195 signin_manager_ = static_cast<SigninManagerFake*>( 191 signin_manager_ = static_cast<SigninManagerFake*>(
196 SigninManagerFactory::GetInstance()->SetTestingFactoryAndUse( 192 SigninManagerFactory::GetInstance()->SetTestingFactoryAndUse(
197 profile_.get(), SigninManagerFake::Build)); 193 profile_.get(), SigninManagerFake::Build));
198 194
199 #if defined(OS_ANDROID) 195 #if defined(OS_ANDROID)
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after
333 } 329 }
334 330
335 scoped_ptr<TestingProfile> profile_; 331 scoped_ptr<TestingProfile> profile_;
336 // Weak pointer to a MockUserCloudPolicyStore - lifetime is managed by the 332 // Weak pointer to a MockUserCloudPolicyStore - lifetime is managed by the
337 // UserCloudPolicyManager. 333 // UserCloudPolicyManager.
338 MockUserCloudPolicyStore* mock_store_; 334 MockUserCloudPolicyStore* mock_store_;
339 scoped_ptr<UserCloudPolicyManager> manager_; 335 scoped_ptr<UserCloudPolicyManager> manager_;
340 336
341 // BrowserPolicyConnector and UrlFetcherFactory want to initialize and free 337 // BrowserPolicyConnector and UrlFetcherFactory want to initialize and free
342 // various components asynchronously via tasks, so create fake threads here. 338 // various components asynchronously via tasks, so create fake threads here.
343 base::MessageLoop loop_; 339 content::TestBrowserThreadBundle thread_bundle_;
344 content::TestBrowserThread ui_thread_;
345 content::TestBrowserThread file_thread_;
346 content::TestBrowserThread io_thread_;
347 340
348 net::TestURLFetcherFactory url_factory_; 341 net::TestURLFetcherFactory url_factory_;
349 342
350 SigninManagerFake* signin_manager_; 343 SigninManagerFake* signin_manager_;
351 #if defined(OS_ANDROID) 344 #if defined(OS_ANDROID)
352 FakeProfileOAuth2TokenService* token_service_; // Not owned. 345 FakeProfileOAuth2TokenService* token_service_; // Not owned.
353 #endif 346 #endif
354 347
355 // Used in conjunction with OnRegisterCompleted() to test client registration 348 // Used in conjunction with OnRegisterCompleted() to test client registration
356 // callbacks. 349 // callbacks.
(...skipping 444 matching lines...) Expand 10 before | Expand all | Expand 10 after
801 base::RunLoop().RunUntilIdle(); 794 base::RunLoop().RunUntilIdle();
802 EXPECT_FALSE(manager_->IsClientRegistered()); 795 EXPECT_FALSE(manager_->IsClientRegistered());
803 #if !defined(OS_ANDROID) 796 #if !defined(OS_ANDROID)
804 EXPECT_FALSE(signin_manager_->IsSignoutProhibited()); 797 EXPECT_FALSE(signin_manager_->IsSignoutProhibited());
805 #endif 798 #endif
806 } 799 }
807 800
808 } // namespace 801 } // namespace
809 802
810 } // namespace policy 803 } // namespace policy
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698