| 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/user_cloud_policy_store.h" | 5 #include "chrome/browser/policy/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" |
| 11 #include "chrome/browser/policy/mock_cloud_policy_store.h" |
| 11 #include "chrome/browser/policy/policy_builder.h" | 12 #include "chrome/browser/policy/policy_builder.h" |
| 12 #include "chrome/browser/signin/signin_manager.h" | 13 #include "chrome/browser/signin/signin_manager.h" |
| 13 #include "chrome/browser/signin/signin_manager_factory.h" | 14 #include "chrome/browser/signin/signin_manager_factory.h" |
| 14 #include "chrome/browser/signin/signin_manager_fake.h" | 15 #include "chrome/browser/signin/signin_manager_fake.h" |
| 15 #include "chrome/test/base/testing_profile.h" | 16 #include "chrome/test/base/testing_profile.h" |
| 16 #include "content/public/test/test_browser_thread.h" | 17 #include "content/public/test/test_browser_thread.h" |
| 17 #include "policy/policy_constants.h" | 18 #include "policy/policy_constants.h" |
| 18 #include "testing/gmock/include/gmock/gmock.h" | 19 #include "testing/gmock/include/gmock/gmock.h" |
| 19 #include "testing/gtest/include/gtest/gtest.h" | 20 #include "testing/gtest/include/gtest/gtest.h" |
| 20 | 21 |
| 21 using testing::AllOf; | 22 using testing::AllOf; |
| 22 using testing::Eq; | 23 using testing::Eq; |
| 23 using testing::Property; | 24 using testing::Property; |
| 24 | 25 |
| 25 namespace policy { | 26 namespace policy { |
| 26 | 27 |
| 27 namespace { | 28 namespace { |
| 28 | 29 |
| 29 void RunUntilIdle() { | 30 void RunUntilIdle() { |
| 30 base::RunLoop run_loop; | 31 base::RunLoop run_loop; |
| 31 run_loop.RunUntilIdle(); | 32 run_loop.RunUntilIdle(); |
| 32 } | 33 } |
| 33 | 34 |
| 34 class MockCloudPolicyStoreObserver : public CloudPolicyStore::Observer { | |
| 35 public: | |
| 36 MockCloudPolicyStoreObserver() {} | |
| 37 virtual ~MockCloudPolicyStoreObserver() {} | |
| 38 | |
| 39 MOCK_METHOD1(OnStoreLoaded, void(CloudPolicyStore* store)); | |
| 40 MOCK_METHOD1(OnStoreError, void(CloudPolicyStore* store)); | |
| 41 | |
| 42 private: | |
| 43 DISALLOW_COPY_AND_ASSIGN(MockCloudPolicyStoreObserver); | |
| 44 }; | |
| 45 | |
| 46 class UserCloudPolicyStoreTest : public testing::Test { | 35 class UserCloudPolicyStoreTest : public testing::Test { |
| 47 public: | 36 public: |
| 48 UserCloudPolicyStoreTest() | 37 UserCloudPolicyStoreTest() |
| 49 : loop_(MessageLoop::TYPE_UI), | 38 : loop_(MessageLoop::TYPE_UI), |
| 50 ui_thread_(content::BrowserThread::UI, &loop_), | 39 ui_thread_(content::BrowserThread::UI, &loop_), |
| 51 file_thread_(content::BrowserThread::FILE, &loop_), | 40 file_thread_(content::BrowserThread::FILE, &loop_), |
| 52 profile_(new TestingProfile()) {} | 41 profile_(new TestingProfile()) {} |
| 53 | 42 |
| 54 virtual void SetUp() OVERRIDE { | 43 virtual void SetUp() OVERRIDE { |
| 55 ASSERT_TRUE(tmp_dir_.CreateUniqueTempDir()); | 44 ASSERT_TRUE(tmp_dir_.CreateUniqueTempDir()); |
| (...skipping 263 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 319 store2->Load(); | 308 store2->Load(); |
| 320 RunUntilIdle(); | 309 RunUntilIdle(); |
| 321 | 310 |
| 322 ASSERT_FALSE(store2->policy()); | 311 ASSERT_FALSE(store2->policy()); |
| 323 store2->RemoveObserver(&observer_); | 312 store2->RemoveObserver(&observer_); |
| 324 } | 313 } |
| 325 | 314 |
| 326 } // namespace | 315 } // namespace |
| 327 | 316 |
| 328 } // namespace policy | 317 } // namespace policy |
| OLD | NEW |