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

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

Issue 9911029: Refactored the CloudPolicyProvider so that it becomes initialized once and stays initialized. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Using mock caches in the unittest Created 8 years, 8 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
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 <vector> 5 #include <vector>
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "base/memory/scoped_ptr.h" 8 #include "base/memory/scoped_ptr.h"
9 #include "base/message_loop.h" 9 #include "base/message_loop.h"
10 #include "base/scoped_temp_dir.h" 10 #include "base/scoped_temp_dir.h"
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
97 arg3->response_code = 200; 97 arg3->response_code = 200;
98 } 98 }
99 99
100 // Tests CloudPolicySubsystem by intercepting its network requests. 100 // Tests CloudPolicySubsystem by intercepting its network requests.
101 // The requests are intercepted by PolicyRequestInterceptor and they are 101 // The requests are intercepted by PolicyRequestInterceptor and they are
102 // logged by LoggingWorkScheduler for further examination. 102 // logged by LoggingWorkScheduler for further examination.
103 class CloudPolicySubsystemTestBase : public testing::Test { 103 class CloudPolicySubsystemTestBase : public testing::Test {
104 public: 104 public:
105 CloudPolicySubsystemTestBase() 105 CloudPolicySubsystemTestBase()
106 : ui_thread_(BrowserThread::UI, &loop_), 106 : ui_thread_(BrowserThread::UI, &loop_),
107 io_thread_(BrowserThread::IO, &loop_) { 107 file_thread_(BrowserThread::FILE, &loop_),
Mattias Nissler (ping if slow) 2012/03/30 11:46:35 why?
Joao da Silva 2012/03/30 16:36:58 Because otherwise the UserPolicyCache DCHECKs on L
108 } 108 io_thread_(BrowserThread::IO, &loop_) {}
109 109
110 virtual ~CloudPolicySubsystemTestBase() { 110 virtual ~CloudPolicySubsystemTestBase() {}
111 }
112 111
113 protected: 112 protected:
114 void StopMessageLoop() { 113 void StopMessageLoop() {
115 loop_.QuitNow(); 114 loop_.QuitNow();
116 } 115 }
117 116
118 virtual void SetUp() { 117 virtual void SetUp() {
119 prefs_.reset(new TestingPrefService); 118 prefs_.reset(new TestingPrefService);
120 CloudPolicySubsystem::RegisterPrefs(prefs_.get()); 119 CloudPolicySubsystem::RegisterPrefs(prefs_.get());
121 ((TestingBrowserProcess*) g_browser_process)->SetLocalState(prefs_.get()); 120 ((TestingBrowserProcess*) g_browser_process)->SetLocalState(prefs_.get());
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after
243 } 242 }
244 243
245 EXPECT_GE(count, 11) 244 EXPECT_GE(count, 11)
246 << "No enough requests were fired during the test run."; 245 << "No enough requests were fired during the test run.";
247 } 246 }
248 247
249 ScopedTempDir temp_user_data_dir_; 248 ScopedTempDir temp_user_data_dir_;
250 249
251 MessageLoop loop_; 250 MessageLoop loop_;
252 content::TestBrowserThread ui_thread_; 251 content::TestBrowserThread ui_thread_;
252 content::TestBrowserThread file_thread_;
253 content::TestBrowserThread io_thread_; 253 content::TestBrowserThread io_thread_;
254 254
255 scoped_ptr<EventLogger> logger_; 255 scoped_ptr<EventLogger> logger_;
256 scoped_ptr<CloudPolicyDataStore> data_store_; 256 scoped_ptr<CloudPolicyDataStore> data_store_;
257 scoped_ptr<CloudPolicySubsystem> cloud_policy_subsystem_; 257 scoped_ptr<CloudPolicySubsystem> cloud_policy_subsystem_;
258 scoped_ptr<PrefService> prefs_; 258 scoped_ptr<PrefService> prefs_;
259 CloudPolicyCacheBase* cache_; 259 CloudPolicyCacheBase* cache_;
260 260
261 scoped_ptr<TestingPolicyURLFetcherFactory> factory_; 261 scoped_ptr<TestingPolicyURLFetcherFactory> factory_;
262 262
(...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after
460 TEST_F(CloudPolicySubsystemSerialNumberRecoveryTest, SerialRequested) { 460 TEST_F(CloudPolicySubsystemSerialNumberRecoveryTest, SerialRequested) {
461 InSequence s; 461 InSequence s;
462 ExpectSuccessfulRegistration(); 462 ExpectSuccessfulRegistration();
463 ExpectPolicyRequest("", true, true); 463 ExpectPolicyRequest("", true, true);
464 ExpectPolicyRequest(kMachineId, false, false); 464 ExpectPolicyRequest(kMachineId, false, false);
465 ExpectPolicyRequest("", false, false); 465 ExpectPolicyRequest("", false, false);
466 ExecuteTest(); 466 ExecuteTest();
467 } 467 }
468 468
469 } // policy 469 } // policy
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698