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 "chrome/browser/policy/cloud/user_cloud_policy_store.h" | 5 #include "chrome/browser/policy/cloud/user_cloud_policy_store.h" |
6 | 6 |
7 #include "base/file_util.h" | 7 #include "base/file_util.h" |
8 #include "base/files/scoped_temp_dir.h" | 8 #include "base/files/scoped_temp_dir.h" |
9 #include "base/message_loop.h" | 9 #include "base/message_loop.h" |
10 #include "base/prefs/pref_service.h" | 10 #include "base/prefs/pref_service.h" |
(...skipping 19 matching lines...) Expand all Loading... |
30 namespace { | 30 namespace { |
31 | 31 |
32 void RunUntilIdle() { | 32 void RunUntilIdle() { |
33 base::RunLoop run_loop; | 33 base::RunLoop run_loop; |
34 run_loop.RunUntilIdle(); | 34 run_loop.RunUntilIdle(); |
35 } | 35 } |
36 | 36 |
37 class UserCloudPolicyStoreTest : public testing::Test { | 37 class UserCloudPolicyStoreTest : public testing::Test { |
38 public: | 38 public: |
39 UserCloudPolicyStoreTest() | 39 UserCloudPolicyStoreTest() |
40 : loop_(MessageLoop::TYPE_UI), | 40 : loop_(base::MessageLoop::TYPE_UI), |
41 ui_thread_(content::BrowserThread::UI, &loop_), | 41 ui_thread_(content::BrowserThread::UI, &loop_), |
42 file_thread_(content::BrowserThread::FILE, &loop_), | 42 file_thread_(content::BrowserThread::FILE, &loop_), |
43 profile_(new TestingProfile()) {} | 43 profile_(new TestingProfile()) {} |
44 | 44 |
45 virtual void SetUp() OVERRIDE { | 45 virtual void SetUp() OVERRIDE { |
46 ASSERT_TRUE(tmp_dir_.CreateUniqueTempDir()); | 46 ASSERT_TRUE(tmp_dir_.CreateUniqueTempDir()); |
47 SigninManager* signin = static_cast<SigninManager*>( | 47 SigninManager* signin = static_cast<SigninManager*>( |
48 SigninManagerFactory::GetInstance()->SetTestingFactoryAndUse( | 48 SigninManagerFactory::GetInstance()->SetTestingFactoryAndUse( |
49 profile_.get(), FakeSigninManager::Build)); | 49 profile_.get(), FakeSigninManager::Build)); |
50 profile_->GetPrefs()->SetString(prefs::kGoogleServicesUsername, | 50 profile_->GetPrefs()->SetString(prefs::kGoogleServicesUsername, |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
86 Eq(error))))); | 86 Eq(error))))); |
87 } | 87 } |
88 | 88 |
89 UserPolicyBuilder policy_; | 89 UserPolicyBuilder policy_; |
90 MockCloudPolicyStoreObserver observer_; | 90 MockCloudPolicyStoreObserver observer_; |
91 scoped_ptr<UserCloudPolicyStore> store_; | 91 scoped_ptr<UserCloudPolicyStore> store_; |
92 | 92 |
93 // CloudPolicyValidator() requires a FILE thread so declare one here. Both | 93 // CloudPolicyValidator() requires a FILE thread so declare one here. Both |
94 // |ui_thread_| and |file_thread_| share the same MessageLoop |loop_| so | 94 // |ui_thread_| and |file_thread_| share the same MessageLoop |loop_| so |
95 // callers can use RunLoop to manage both virtual threads. | 95 // callers can use RunLoop to manage both virtual threads. |
96 MessageLoop loop_; | 96 base::MessageLoop loop_; |
97 content::TestBrowserThread ui_thread_; | 97 content::TestBrowserThread ui_thread_; |
98 content::TestBrowserThread file_thread_; | 98 content::TestBrowserThread file_thread_; |
99 | 99 |
100 scoped_ptr<TestingProfile> profile_; | 100 scoped_ptr<TestingProfile> profile_; |
101 base::ScopedTempDir tmp_dir_; | 101 base::ScopedTempDir tmp_dir_; |
102 | 102 |
103 DISALLOW_COPY_AND_ASSIGN(UserCloudPolicyStoreTest); | 103 DISALLOW_COPY_AND_ASSIGN(UserCloudPolicyStoreTest); |
104 }; | 104 }; |
105 | 105 |
106 TEST_F(UserCloudPolicyStoreTest, LoadWithNoFile) { | 106 TEST_F(UserCloudPolicyStoreTest, LoadWithNoFile) { |
(...skipping 235 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
342 store4->Load(); | 342 store4->Load(); |
343 RunUntilIdle(); | 343 RunUntilIdle(); |
344 | 344 |
345 ASSERT_FALSE(store4->policy()); | 345 ASSERT_FALSE(store4->policy()); |
346 store4->RemoveObserver(&observer_); | 346 store4->RemoveObserver(&observer_); |
347 } | 347 } |
348 | 348 |
349 } // namespace | 349 } // namespace |
350 | 350 |
351 } // namespace policy | 351 } // namespace policy |
OLD | NEW |