| 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/run_loop.h" | 10 #include "base/run_loop.h" |
| (...skipping 17 matching lines...) Expand all Loading... |
| 28 namespace { | 28 namespace { |
| 29 | 29 |
| 30 void RunUntilIdle() { | 30 void RunUntilIdle() { |
| 31 base::RunLoop run_loop; | 31 base::RunLoop run_loop; |
| 32 run_loop.RunUntilIdle(); | 32 run_loop.RunUntilIdle(); |
| 33 } | 33 } |
| 34 | 34 |
| 35 class UserCloudPolicyStoreTest : public testing::Test { | 35 class UserCloudPolicyStoreTest : public testing::Test { |
| 36 public: | 36 public: |
| 37 UserCloudPolicyStoreTest() | 37 UserCloudPolicyStoreTest() |
| 38 : loop_(MessageLoop::TYPE_UI), | 38 : loop_(base::MessageLoop::TYPE_UI), |
| 39 ui_thread_(content::BrowserThread::UI, &loop_), | 39 ui_thread_(content::BrowserThread::UI, &loop_), |
| 40 file_thread_(content::BrowserThread::FILE, &loop_), | 40 file_thread_(content::BrowserThread::FILE, &loop_), |
| 41 profile_(new TestingProfile()) {} | 41 profile_(new TestingProfile()) {} |
| 42 | 42 |
| 43 virtual void SetUp() OVERRIDE { | 43 virtual void SetUp() OVERRIDE { |
| 44 ASSERT_TRUE(tmp_dir_.CreateUniqueTempDir()); | 44 ASSERT_TRUE(tmp_dir_.CreateUniqueTempDir()); |
| 45 SigninManager* signin = static_cast<SigninManager*>( | 45 SigninManager* signin = static_cast<SigninManager*>( |
| 46 SigninManagerFactory::GetInstance()->SetTestingFactoryAndUse( | 46 SigninManagerFactory::GetInstance()->SetTestingFactoryAndUse( |
| 47 profile_.get(), FakeSigninManager::Build)); | 47 profile_.get(), FakeSigninManager::Build)); |
| 48 signin->SetAuthenticatedUsername(PolicyBuilder::kFakeUsername); | 48 signin->SetAuthenticatedUsername(PolicyBuilder::kFakeUsername); |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 82 Eq(error))))); | 82 Eq(error))))); |
| 83 } | 83 } |
| 84 | 84 |
| 85 UserPolicyBuilder policy_; | 85 UserPolicyBuilder policy_; |
| 86 MockCloudPolicyStoreObserver observer_; | 86 MockCloudPolicyStoreObserver observer_; |
| 87 scoped_ptr<UserCloudPolicyStore> store_; | 87 scoped_ptr<UserCloudPolicyStore> store_; |
| 88 | 88 |
| 89 // CloudPolicyValidator() requires a FILE thread so declare one here. Both | 89 // CloudPolicyValidator() requires a FILE thread so declare one here. Both |
| 90 // |ui_thread_| and |file_thread_| share the same MessageLoop |loop_| so | 90 // |ui_thread_| and |file_thread_| share the same MessageLoop |loop_| so |
| 91 // callers can use RunLoop to manage both virtual threads. | 91 // callers can use RunLoop to manage both virtual threads. |
| 92 MessageLoop loop_; | 92 base::MessageLoop loop_; |
| 93 content::TestBrowserThread ui_thread_; | 93 content::TestBrowserThread ui_thread_; |
| 94 content::TestBrowserThread file_thread_; | 94 content::TestBrowserThread file_thread_; |
| 95 | 95 |
| 96 scoped_ptr<TestingProfile> profile_; | 96 scoped_ptr<TestingProfile> profile_; |
| 97 base::ScopedTempDir tmp_dir_; | 97 base::ScopedTempDir tmp_dir_; |
| 98 | 98 |
| 99 DISALLOW_COPY_AND_ASSIGN(UserCloudPolicyStoreTest); | 99 DISALLOW_COPY_AND_ASSIGN(UserCloudPolicyStoreTest); |
| 100 }; | 100 }; |
| 101 | 101 |
| 102 TEST_F(UserCloudPolicyStoreTest, LoadWithNoFile) { | 102 TEST_F(UserCloudPolicyStoreTest, LoadWithNoFile) { |
| (...skipping 235 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 338 store4->Load(); | 338 store4->Load(); |
| 339 RunUntilIdle(); | 339 RunUntilIdle(); |
| 340 | 340 |
| 341 ASSERT_FALSE(store4->policy()); | 341 ASSERT_FALSE(store4->policy()); |
| 342 store4->RemoveObserver(&observer_); | 342 store4->RemoveObserver(&observer_); |
| 343 } | 343 } |
| 344 | 344 |
| 345 } // namespace | 345 } // namespace |
| 346 | 346 |
| 347 } // namespace policy | 347 } // namespace policy |
| OLD | NEW |