| OLD | NEW |
| 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 Loading... |
| 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_), |
| 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 Loading... |
| 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 Loading... |
| 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 |
| OLD | NEW |