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/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
9 #include "base/message_loop.h" | 10 #include "base/message_loop.h" |
10 #include "base/scoped_temp_dir.h" | |
11 #include "chrome/browser/chromeos/login/mock_user_manager.h" | 11 #include "chrome/browser/chromeos/login/mock_user_manager.h" |
12 #include "chrome/browser/policy/cloud_policy_constants.h" | 12 #include "chrome/browser/policy/cloud_policy_constants.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_session_manager_client.h" | 16 #include "chromeos/dbus/mock_session_manager_client.h" |
17 #include "content/public/test/test_browser_thread.h" | 17 #include "content/public/test/test_browser_thread.h" |
18 #include "policy/policy_constants.h" | 18 #include "policy/policy_constants.h" |
19 #include "testing/gmock/include/gmock/gmock.h" | 19 #include "testing/gmock/include/gmock/gmock.h" |
20 #include "testing/gtest/include/gtest/gtest.h" | 20 #include "testing/gtest/include/gtest/gtest.h" |
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
117 | 117 |
118 MessageLoop loop_; | 118 MessageLoop loop_; |
119 chromeos::MockSessionManagerClient session_manager_client_; | 119 chromeos::MockSessionManagerClient session_manager_client_; |
120 UserPolicyBuilder policy_; | 120 UserPolicyBuilder policy_; |
121 MockCloudPolicyStoreObserver observer_; | 121 MockCloudPolicyStoreObserver observer_; |
122 scoped_ptr<UserCloudPolicyStoreChromeOS> store_; | 122 scoped_ptr<UserCloudPolicyStoreChromeOS> store_; |
123 | 123 |
124 private: | 124 private: |
125 content::TestBrowserThread ui_thread_; | 125 content::TestBrowserThread ui_thread_; |
126 content::TestBrowserThread file_thread_; | 126 content::TestBrowserThread file_thread_; |
127 ScopedTempDir tmp_dir_; | 127 base::ScopedTempDir tmp_dir_; |
128 chromeos::ScopedMockUserManagerEnabler user_manager_; | 128 chromeos::ScopedMockUserManagerEnabler user_manager_; |
129 | 129 |
130 DISALLOW_COPY_AND_ASSIGN(UserCloudPolicyStoreChromeOSTest); | 130 DISALLOW_COPY_AND_ASSIGN(UserCloudPolicyStoreChromeOSTest); |
131 }; | 131 }; |
132 | 132 |
133 TEST_F(UserCloudPolicyStoreChromeOSTest, Store) { | 133 TEST_F(UserCloudPolicyStoreChromeOSTest, Store) { |
134 // Store policy. | 134 // Store policy. |
135 chromeos::SessionManagerClient::StorePolicyCallback store_callback; | 135 chromeos::SessionManagerClient::StorePolicyCallback store_callback; |
136 EXPECT_CALL(session_manager_client_, StoreUserPolicy(policy_.GetBlob(), _)) | 136 EXPECT_CALL(session_manager_client_, StoreUserPolicy(policy_.GetBlob(), _)) |
137 .WillOnce(SaveArg<1>(&store_callback)); | 137 .WillOnce(SaveArg<1>(&store_callback)); |
(...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
317 ASSERT_TRUE(store_->policy()); | 317 ASSERT_TRUE(store_->policy()); |
318 EXPECT_EQ(expected_policy_data.SerializeAsString(), | 318 EXPECT_EQ(expected_policy_data.SerializeAsString(), |
319 store_->policy()->SerializeAsString()); | 319 store_->policy()->SerializeAsString()); |
320 EXPECT_TRUE(store_->policy_map().empty()); | 320 EXPECT_TRUE(store_->policy_map().empty()); |
321 EXPECT_EQ(CloudPolicyStore::STATUS_OK, store_->status()); | 321 EXPECT_EQ(CloudPolicyStore::STATUS_OK, store_->status()); |
322 }; | 322 }; |
323 | 323 |
324 } // namespace | 324 } // namespace |
325 | 325 |
326 } // namespace policy | 326 } // namespace policy |
OLD | NEW |