| 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_chromeos.h" | 5 #include "chrome/browser/policy/user_cloud_policy_store_chromeos.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/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
| 10 #include "base/message_loop.h" | 10 #include "base/message_loop.h" |
| 11 #include "chrome/browser/policy/cloud_policy_constants.h" | 11 #include "chrome/browser/policy/cloud_policy_constants.h" |
| 12 #include "chrome/browser/policy/mock_cloud_policy_store.h" | 12 #include "chrome/browser/policy/mock_cloud_policy_store.h" |
| 13 #include "chrome/browser/policy/policy_builder.h" | 13 #include "chrome/browser/policy/policy_builder.h" |
| 14 #include "chrome/browser/policy/proto/cloud_policy.pb.h" | 14 #include "chrome/browser/policy/proto/cloud_policy.pb.h" |
| 15 #include "chrome/browser/policy/proto/device_management_local.pb.h" | 15 #include "chrome/browser/policy/proto/device_management_local.pb.h" |
| 16 #include "chromeos/dbus/mock_cryptohome_client.h" |
| 16 #include "chromeos/dbus/mock_session_manager_client.h" | 17 #include "chromeos/dbus/mock_session_manager_client.h" |
| 17 #include "content/public/test/test_browser_thread.h" | 18 #include "content/public/test/test_browser_thread.h" |
| 18 #include "policy/policy_constants.h" | 19 #include "policy/policy_constants.h" |
| 19 #include "testing/gmock/include/gmock/gmock.h" | 20 #include "testing/gmock/include/gmock/gmock.h" |
| 20 #include "testing/gtest/include/gtest/gtest.h" | 21 #include "testing/gtest/include/gtest/gtest.h" |
| 21 | 22 |
| 22 namespace em = enterprise_management; | 23 namespace em = enterprise_management; |
| 23 | 24 |
| 24 using testing::AllOf; | 25 using testing::AllOf; |
| 25 using testing::Eq; | 26 using testing::Eq; |
| (...skipping 11 matching lines...) Expand all Loading... |
| 37 | 38 |
| 38 class UserCloudPolicyStoreChromeOSTest : public testing::Test { | 39 class UserCloudPolicyStoreChromeOSTest : public testing::Test { |
| 39 protected: | 40 protected: |
| 40 UserCloudPolicyStoreChromeOSTest() | 41 UserCloudPolicyStoreChromeOSTest() |
| 41 : loop_(MessageLoop::TYPE_UI), | 42 : loop_(MessageLoop::TYPE_UI), |
| 42 ui_thread_(content::BrowserThread::UI, &loop_), | 43 ui_thread_(content::BrowserThread::UI, &loop_), |
| 43 file_thread_(content::BrowserThread::FILE, &loop_) {} | 44 file_thread_(content::BrowserThread::FILE, &loop_) {} |
| 44 | 45 |
| 45 virtual void SetUp() OVERRIDE { | 46 virtual void SetUp() OVERRIDE { |
| 46 ASSERT_TRUE(tmp_dir_.CreateUniqueTempDir()); | 47 ASSERT_TRUE(tmp_dir_.CreateUniqueTempDir()); |
| 47 store_.reset(new UserCloudPolicyStoreChromeOS(&session_manager_client_, | 48 store_.reset(new UserCloudPolicyStoreChromeOS(&cryptohome_client_, |
| 49 &session_manager_client_, |
| 48 PolicyBuilder::kFakeUsername, | 50 PolicyBuilder::kFakeUsername, |
| 49 token_file(), | 51 token_file(), |
| 50 policy_file())); | 52 policy_file())); |
| 51 store_->AddObserver(&observer_); | 53 store_->AddObserver(&observer_); |
| 52 | 54 |
| 53 policy_.payload().mutable_showhomebutton()->set_value(true); | 55 policy_.payload().mutable_showhomebutton()->set_value(true); |
| 54 policy_.Build(); | 56 policy_.Build(); |
| 55 } | 57 } |
| 56 | 58 |
| 57 virtual void TearDown() OVERRIDE { | 59 virtual void TearDown() OVERRIDE { |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 96 | 98 |
| 97 FilePath token_file() { | 99 FilePath token_file() { |
| 98 return tmp_dir_.path().AppendASCII("token"); | 100 return tmp_dir_.path().AppendASCII("token"); |
| 99 } | 101 } |
| 100 | 102 |
| 101 FilePath policy_file() { | 103 FilePath policy_file() { |
| 102 return tmp_dir_.path().AppendASCII("policy"); | 104 return tmp_dir_.path().AppendASCII("policy"); |
| 103 } | 105 } |
| 104 | 106 |
| 105 MessageLoop loop_; | 107 MessageLoop loop_; |
| 108 chromeos::MockCryptohomeClient cryptohome_client_; |
| 106 chromeos::MockSessionManagerClient session_manager_client_; | 109 chromeos::MockSessionManagerClient session_manager_client_; |
| 107 UserPolicyBuilder policy_; | 110 UserPolicyBuilder policy_; |
| 108 MockCloudPolicyStoreObserver observer_; | 111 MockCloudPolicyStoreObserver observer_; |
| 109 scoped_ptr<UserCloudPolicyStoreChromeOS> store_; | 112 scoped_ptr<UserCloudPolicyStoreChromeOS> store_; |
| 110 | 113 |
| 111 private: | 114 private: |
| 112 content::TestBrowserThread ui_thread_; | 115 content::TestBrowserThread ui_thread_; |
| 113 content::TestBrowserThread file_thread_; | 116 content::TestBrowserThread file_thread_; |
| 114 base::ScopedTempDir tmp_dir_; | 117 base::ScopedTempDir tmp_dir_; |
| 115 | 118 |
| (...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 310 ASSERT_TRUE(store_->policy()); | 313 ASSERT_TRUE(store_->policy()); |
| 311 EXPECT_EQ(expected_policy_data.SerializeAsString(), | 314 EXPECT_EQ(expected_policy_data.SerializeAsString(), |
| 312 store_->policy()->SerializeAsString()); | 315 store_->policy()->SerializeAsString()); |
| 313 EXPECT_TRUE(store_->policy_map().empty()); | 316 EXPECT_TRUE(store_->policy_map().empty()); |
| 314 EXPECT_EQ(CloudPolicyStore::STATUS_OK, store_->status()); | 317 EXPECT_EQ(CloudPolicyStore::STATUS_OK, store_->status()); |
| 315 }; | 318 }; |
| 316 | 319 |
| 317 } // namespace | 320 } // namespace |
| 318 | 321 |
| 319 } // namespace policy | 322 } // namespace policy |
| OLD | NEW |