| 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/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/mock_cloud_policy_store.h" |
| 13 #include "chrome/browser/policy/policy_builder.h" | 14 #include "chrome/browser/policy/policy_builder.h" |
| 14 #include "chrome/browser/policy/proto/cloud_policy.pb.h" | 15 #include "chrome/browser/policy/proto/cloud_policy.pb.h" |
| 15 #include "chrome/browser/policy/proto/device_management_local.pb.h" | 16 #include "chrome/browser/policy/proto/device_management_local.pb.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; |
| 26 using testing::Property; | 27 using testing::Property; |
| 27 using testing::Return; | 28 using testing::Return; |
| 28 using testing::SaveArg; | 29 using testing::SaveArg; |
| 29 using testing::_; | 30 using testing::_; |
| 30 | 31 |
| 31 namespace policy { | 32 namespace policy { |
| 32 | 33 |
| 33 namespace { | 34 namespace { |
| 34 | 35 |
| 35 const char kLegacyDeviceId[] = "legacy-device-id"; | 36 const char kLegacyDeviceId[] = "legacy-device-id"; |
| 36 const char kLegacyToken[] = "legacy-token"; | 37 const char kLegacyToken[] = "legacy-token"; |
| 37 | 38 |
| 38 class MockCloudPolicyStoreObserver : public CloudPolicyStore::Observer { | |
| 39 public: | |
| 40 MockCloudPolicyStoreObserver() {} | |
| 41 virtual ~MockCloudPolicyStoreObserver() {} | |
| 42 | |
| 43 MOCK_METHOD1(OnStoreLoaded, void(CloudPolicyStore* store)); | |
| 44 MOCK_METHOD1(OnStoreError, void(CloudPolicyStore* store)); | |
| 45 | |
| 46 private: | |
| 47 DISALLOW_COPY_AND_ASSIGN(MockCloudPolicyStoreObserver); | |
| 48 }; | |
| 49 | |
| 50 class UserCloudPolicyStoreChromeOSTest : public testing::Test { | 39 class UserCloudPolicyStoreChromeOSTest : public testing::Test { |
| 51 protected: | 40 protected: |
| 52 UserCloudPolicyStoreChromeOSTest() | 41 UserCloudPolicyStoreChromeOSTest() |
| 53 : loop_(MessageLoop::TYPE_UI), | 42 : loop_(MessageLoop::TYPE_UI), |
| 54 ui_thread_(content::BrowserThread::UI, &loop_), | 43 ui_thread_(content::BrowserThread::UI, &loop_), |
| 55 file_thread_(content::BrowserThread::FILE, &loop_) {} | 44 file_thread_(content::BrowserThread::FILE, &loop_) {} |
| 56 | 45 |
| 57 virtual void SetUp() OVERRIDE { | 46 virtual void SetUp() OVERRIDE { |
| 58 ASSERT_TRUE(tmp_dir_.CreateUniqueTempDir()); | 47 ASSERT_TRUE(tmp_dir_.CreateUniqueTempDir()); |
| 59 EXPECT_CALL(*user_manager_.user_manager(), IsUserLoggedIn()) | 48 EXPECT_CALL(*user_manager_.user_manager(), IsUserLoggedIn()) |
| (...skipping 257 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 317 ASSERT_TRUE(store_->policy()); | 306 ASSERT_TRUE(store_->policy()); |
| 318 EXPECT_EQ(expected_policy_data.SerializeAsString(), | 307 EXPECT_EQ(expected_policy_data.SerializeAsString(), |
| 319 store_->policy()->SerializeAsString()); | 308 store_->policy()->SerializeAsString()); |
| 320 EXPECT_TRUE(store_->policy_map().empty()); | 309 EXPECT_TRUE(store_->policy_map().empty()); |
| 321 EXPECT_EQ(CloudPolicyStore::STATUS_OK, store_->status()); | 310 EXPECT_EQ(CloudPolicyStore::STATUS_OK, store_->status()); |
| 322 }; | 311 }; |
| 323 | 312 |
| 324 } // namespace | 313 } // namespace |
| 325 | 314 |
| 326 } // namespace policy | 315 } // namespace policy |
| OLD | NEW |