| 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/files/scoped_temp_dir.h" |    7 #include "base/files/scoped_temp_dir.h" | 
|    8 #include "base/logging.h" |    8 #include "base/logging.h" | 
|    9 #include "base/memory/scoped_ptr.h" |    9 #include "base/memory/scoped_ptr.h" | 
|   10 #include "base/message_loop.h" |   10 #include "base/message_loop.h" | 
| (...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  108         io_thread_(BrowserThread::IO, &loop_) {} |  108         io_thread_(BrowserThread::IO, &loop_) {} | 
|  109  |  109  | 
|  110   virtual ~CloudPolicySubsystemTestBase() {} |  110   virtual ~CloudPolicySubsystemTestBase() {} | 
|  111  |  111  | 
|  112  protected: |  112  protected: | 
|  113   void StopMessageLoop() { |  113   void StopMessageLoop() { | 
|  114     loop_.QuitNow(); |  114     loop_.QuitNow(); | 
|  115   } |  115   } | 
|  116  |  116  | 
|  117   virtual void SetUp() { |  117   virtual void SetUp() { | 
|  118     prefs_.reset(new TestingPrefService); |  118     prefs_.reset(new TestingPrefServiceSimple); | 
|  119     CloudPolicySubsystem::RegisterPrefs(prefs_.get()); |  119     CloudPolicySubsystem::RegisterPrefs(prefs_.get()); | 
|  120     ((TestingBrowserProcess*) g_browser_process)->SetLocalState(prefs_.get()); |  120     ((TestingBrowserProcess*) g_browser_process)->SetLocalState(prefs_.get()); | 
|  121  |  121  | 
|  122     logger_.reset(new EventLogger); |  122     logger_.reset(new EventLogger); | 
|  123     factory_.reset(new TestingPolicyURLFetcherFactory(logger_.get())); |  123     factory_.reset(new TestingPolicyURLFetcherFactory(logger_.get())); | 
|  124     ASSERT_TRUE(temp_user_data_dir_.CreateUniqueTempDir()); |  124     ASSERT_TRUE(temp_user_data_dir_.CreateUniqueTempDir()); | 
|  125     data_store_.reset(CloudPolicyDataStore::CreateForUserPolicies()); |  125     data_store_.reset(CloudPolicyDataStore::CreateForUserPolicies()); | 
|  126     cache_ = new UserPolicyCache( |  126     cache_ = new UserPolicyCache( | 
|  127         temp_user_data_dir_.path().AppendASCII("CloudPolicyControllerTest"), |  127         temp_user_data_dir_.path().AppendASCII("CloudPolicyControllerTest"), | 
|  128         false  /* wait_for_policy_fetch */); |  128         false  /* wait_for_policy_fetch */); | 
| (...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  248   base::ScopedTempDir temp_user_data_dir_; |  248   base::ScopedTempDir temp_user_data_dir_; | 
|  249  |  249  | 
|  250   MessageLoop loop_; |  250   MessageLoop loop_; | 
|  251   content::TestBrowserThread ui_thread_; |  251   content::TestBrowserThread ui_thread_; | 
|  252   content::TestBrowserThread file_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<PrefServiceSimple> prefs_; | 
|  259   CloudPolicyCacheBase* cache_; |  259   CloudPolicyCacheBase* cache_; | 
|  260  |  260  | 
|  261   scoped_ptr<TestingPolicyURLFetcherFactory> factory_; |  261   scoped_ptr<TestingPolicyURLFetcherFactory> factory_; | 
|  262  |  262  | 
|  263   DISALLOW_COPY_AND_ASSIGN(CloudPolicySubsystemTestBase); |  263   DISALLOW_COPY_AND_ASSIGN(CloudPolicySubsystemTestBase); | 
|  264 }; |  264 }; | 
|  265  |  265  | 
|  266 // A parameterized test case that simulates 100 failed registration attempts, |  266 // A parameterized test case that simulates 100 failed registration attempts, | 
|  267 // then a successful one, then 100 failed policy fetch attempts and then 100 |  267 // then a successful one, then 100 failed policy fetch attempts and then 100 | 
|  268 // successful policy fetches. The two parameters are the error codes for the |  268 // successful policy fetches. The two parameters are the error codes for the | 
| (...skipping 191 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 |