| 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/chromeos/settings/signed_settings_helper.h" | 5 #include "chrome/browser/chromeos/settings/signed_settings_helper.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/message_loop.h" | 8 #include "base/message_loop.h" |
| 9 #include "chrome/browser/chromeos/cros/cros_library.h" | 9 #include "chrome/browser/chromeos/cros/cros_library.h" |
| 10 #include "chrome/browser/chromeos/settings/cros_settings_names.h" | 10 #include "chrome/browser/chromeos/settings/cros_settings_names.h" |
| 11 #include "chrome/browser/chromeos/settings/mock_owner_key_utils.h" | 11 #include "chrome/browser/chromeos/settings/mock_owner_key_utils.h" |
| 12 #include "chrome/browser/chromeos/settings/mock_ownership_service.h" | 12 #include "chrome/browser/chromeos/settings/mock_ownership_service.h" |
| 13 #include "chrome/browser/chromeos/settings/owner_manager.h" | 13 #include "chrome/browser/chromeos/settings/owner_manager.h" |
| 14 #include "chrome/browser/chromeos/settings/signed_settings.h" | 14 #include "chrome/browser/chromeos/settings/signed_settings.h" |
| 15 #include "chrome/browser/policy/proto/chrome_device_policy.pb.h" | 15 #include "chrome/browser/policy/proto/chrome_device_policy.pb.h" |
| 16 #include "chrome/browser/policy/proto/device_management_backend.pb.h" | 16 #include "chrome/browser/policy/proto/device_management_backend.pb.h" |
| 17 #include "chromeos/dbus/dbus_thread_manager.h" | 17 #include "chromeos/dbus/dbus_thread_manager.h" |
| 18 #include "chromeos/dbus/mock_dbus_thread_manager.h" | 18 #include "chromeos/dbus/mock_dbus_thread_manager.h" |
| 19 #include "chromeos/dbus/mock_session_manager_client.h" | 19 #include "chromeos/dbus/mock_session_manager_client.h" |
| 20 #include "content/public/test/test_browser_thread.h" | 20 #include "content/public/test/test_browser_thread.h" |
| 21 #include "testing/gmock/include/gmock/gmock.h" | 21 #include "testing/gmock/include/gmock/gmock.h" |
| 22 #include "testing/gtest/include/gtest/gtest.h" | 22 #include "testing/gtest/include/gtest/gtest.h" |
| 23 | 23 |
| 24 using ::testing::_; | 24 using ::testing::_; |
| 25 using ::testing::A; | 25 using ::testing::A; |
| 26 using ::testing::InSequence; | 26 using ::testing::InSequence; |
| 27 using ::testing::Invoke; | 27 using ::testing::Invoke; |
| 28 using ::testing::Return; |
| 28 using ::testing::WithArg; | 29 using ::testing::WithArg; |
| 29 | 30 |
| 30 namespace em = enterprise_management; | 31 namespace em = enterprise_management; |
| 31 namespace chromeos { | 32 namespace chromeos { |
| 32 | 33 |
| 33 ACTION_P(Retrieve, policy_blob) { arg0.Run(policy_blob); } | 34 ACTION_P(Retrieve, policy_blob) { arg0.Run(policy_blob); } |
| 34 ACTION_P(Store, success) { arg1.Run(success); } | 35 ACTION_P(Store, success) { arg1.Run(success); } |
| 35 | 36 |
| 36 class SignedSettingsHelperTest : public testing::Test, | 37 class SignedSettingsHelperTest : public testing::Test, |
| 37 public SignedSettingsHelper::TestDelegate { | 38 public SignedSettingsHelper::TestDelegate { |
| 38 public: | 39 public: |
| 39 SignedSettingsHelperTest() | 40 SignedSettingsHelperTest() |
| 40 : message_loop_(MessageLoop::TYPE_UI), | 41 : message_loop_(MessageLoop::TYPE_UI), |
| 41 ui_thread_(content::BrowserThread::UI, &message_loop_), | 42 ui_thread_(content::BrowserThread::UI, &message_loop_), |
| 42 file_thread_(content::BrowserThread::FILE, &message_loop_), | 43 file_thread_(content::BrowserThread::FILE, &message_loop_), |
| 43 pending_ops_(0), | 44 pending_ops_(0), |
| 44 mock_dbus_thread_manager_(new MockDBusThreadManager) { | 45 mock_dbus_thread_manager_(new MockDBusThreadManager) { |
| 45 } | 46 } |
| 46 | 47 |
| 47 virtual void SetUp() { | 48 virtual void SetUp() { |
| 48 SignedSettingsHelper::Get()->set_test_delegate(this); | 49 SignedSettingsHelper::Get()->set_test_delegate(this); |
| 50 EXPECT_CALL(*mock_dbus_thread_manager_, GetSystemBus()) |
| 51 .WillRepeatedly(Return(reinterpret_cast<dbus::Bus*>(NULL))); |
| 49 DBusThreadManager::InitializeForTesting(mock_dbus_thread_manager_); | 52 DBusThreadManager::InitializeForTesting(mock_dbus_thread_manager_); |
| 50 | 53 |
| 51 fake_policy_data_ = BuildPolicyData(); | 54 fake_policy_data_ = BuildPolicyData(); |
| 52 std::string data_serialized = fake_policy_data_.SerializeAsString(); | 55 std::string data_serialized = fake_policy_data_.SerializeAsString(); |
| 53 std::string serialized_policy_; | 56 std::string serialized_policy_; |
| 54 fake_policy_ = BuildProto(data_serialized, | 57 fake_policy_ = BuildProto(data_serialized, |
| 55 std::string("false"), | 58 std::string("false"), |
| 56 &serialized_policy_); | 59 &serialized_policy_); |
| 57 | 60 |
| 58 MockSessionManagerClient* client = | 61 MockSessionManagerClient* client = |
| (...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 200 base::Unretained(&cb))); | 203 base::Unretained(&cb))); |
| 201 SignedSettingsHelper::Get()->StartRetrievePolicyOp( | 204 SignedSettingsHelper::Get()->StartRetrievePolicyOp( |
| 202 base::Bind(&MockSignedSettingsCallbacks::OnRetrievePolicyCompleted, | 205 base::Bind(&MockSignedSettingsCallbacks::OnRetrievePolicyCompleted, |
| 203 base::Unretained(&cb))); | 206 base::Unretained(&cb))); |
| 204 | 207 |
| 205 message_loop_.RunAllPending(); | 208 message_loop_.RunAllPending(); |
| 206 ASSERT_EQ(0, pending_ops_); | 209 ASSERT_EQ(0, pending_ops_); |
| 207 } | 210 } |
| 208 | 211 |
| 209 } // namespace chromeos | 212 } // namespace chromeos |
| OLD | NEW |