| OLD | NEW |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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 <string> | 5 #include <string> |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
| 9 #include "base/file_util.h" | 9 #include "base/file_util.h" |
| 10 #include "base/files/file_path.h" | 10 #include "base/files/file_path.h" |
| (...skipping 17 matching lines...) Expand all Loading... |
| 28 #include "chrome/common/chrome_switches.h" | 28 #include "chrome/common/chrome_switches.h" |
| 29 #include "chrome/common/extensions/extension.h" | 29 #include "chrome/common/extensions/extension.h" |
| 30 #include "policy/proto/cloud_policy.pb.h" | 30 #include "policy/proto/cloud_policy.pb.h" |
| 31 #include "testing/gmock/include/gmock/gmock.h" | 31 #include "testing/gmock/include/gmock/gmock.h" |
| 32 #include "testing/gtest/include/gtest/gtest.h" | 32 #include "testing/gtest/include/gtest/gtest.h" |
| 33 | 33 |
| 34 #if defined(OS_CHROMEOS) | 34 #if defined(OS_CHROMEOS) |
| 35 #include "chrome/browser/chromeos/login/user_manager.h" | 35 #include "chrome/browser/chromeos/login/user_manager.h" |
| 36 #include "chrome/browser/chromeos/policy/user_cloud_policy_manager_chromeos.h" | 36 #include "chrome/browser/chromeos/policy/user_cloud_policy_manager_chromeos.h" |
| 37 #include "chrome/common/chrome_paths.h" | 37 #include "chrome/common/chrome_paths.h" |
| 38 #include "chromeos/chromeos_paths.h" |
| 38 #include "chromeos/chromeos_switches.h" | 39 #include "chromeos/chromeos_switches.h" |
| 39 #include "chromeos/dbus/mock_cryptohome_client.h" | 40 #include "chromeos/dbus/mock_cryptohome_client.h" |
| 40 #include "chromeos/dbus/mock_dbus_thread_manager.h" | 41 #include "chromeos/dbus/mock_dbus_thread_manager.h" |
| 41 #include "chromeos/dbus/mock_session_manager_client.h" | 42 #include "chromeos/dbus/mock_session_manager_client.h" |
| 42 #include "chromeos/dbus/mock_update_engine_client.h" | 43 #include "chromeos/dbus/mock_update_engine_client.h" |
| 43 #else | 44 #else |
| 44 #include "chrome/browser/policy/cloud/user_cloud_policy_manager.h" | 45 #include "chrome/browser/policy/cloud/user_cloud_policy_manager.h" |
| 45 #include "chrome/browser/policy/cloud/user_cloud_policy_manager_factory.h" | 46 #include "chrome/browser/policy/cloud/user_cloud_policy_manager_factory.h" |
| 46 #include "chrome/browser/signin/signin_manager.h" | 47 #include "chrome/browser/signin/signin_manager.h" |
| 47 #include "chrome/browser/signin/signin_manager_factory.h" | 48 #include "chrome/browser/signin/signin_manager_factory.h" |
| (...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 153 std::string url = test_server_.GetServiceURL().spec(); | 154 std::string url = test_server_.GetServiceURL().spec(); |
| 154 CommandLine* command_line = CommandLine::ForCurrentProcess(); | 155 CommandLine* command_line = CommandLine::ForCurrentProcess(); |
| 155 command_line->AppendSwitchASCII(switches::kDeviceManagementUrl, url); | 156 command_line->AppendSwitchASCII(switches::kDeviceManagementUrl, url); |
| 156 command_line->AppendSwitch(switches::kEnableComponentCloudPolicy); | 157 command_line->AppendSwitch(switches::kEnableComponentCloudPolicy); |
| 157 | 158 |
| 158 #if defined(OS_CHROMEOS) | 159 #if defined(OS_CHROMEOS) |
| 159 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir()); | 160 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir()); |
| 160 base::FilePath user_key_path = | 161 base::FilePath user_key_path = |
| 161 temp_dir_.path().AppendASCII(kSanitizedUsername) | 162 temp_dir_.path().AppendASCII(kSanitizedUsername) |
| 162 .AppendASCII("policy.pub"); | 163 .AppendASCII("policy.pub"); |
| 163 PathService::Override(chrome::DIR_USER_POLICY_KEYS, temp_dir_.path()); | 164 ASSERT_TRUE(PathService::Override(chromeos::DIR_USER_POLICY_KEYS, |
| 165 temp_dir_.path())); |
| 164 | 166 |
| 165 mock_dbus_thread_manager_ = new chromeos::MockDBusThreadManager(); | 167 mock_dbus_thread_manager_ = new chromeos::MockDBusThreadManager(); |
| 166 chromeos::DBusThreadManager::InitializeForTesting( | 168 chromeos::DBusThreadManager::InitializeForTesting( |
| 167 mock_dbus_thread_manager_); | 169 mock_dbus_thread_manager_); |
| 168 EXPECT_CALL(*mock_dbus_thread_manager_->mock_cryptohome_client(), | 170 EXPECT_CALL(*mock_dbus_thread_manager_->mock_cryptohome_client(), |
| 169 GetSanitizedUsername(_, _)) | 171 GetSanitizedUsername(_, _)) |
| 170 .WillRepeatedly(GetSanitizedUsername()); | 172 .WillRepeatedly(GetSanitizedUsername()); |
| 171 EXPECT_CALL(*mock_dbus_thread_manager_->mock_session_manager_client(), | 173 EXPECT_CALL(*mock_dbus_thread_manager_->mock_session_manager_client(), |
| 172 StoreUserPolicy(_, _)) | 174 StoreUserPolicy(_, _)) |
| 173 .WillRepeatedly(StoreUserPolicy(&session_manager_user_policy_, | 175 .WillRepeatedly(StoreUserPolicy(&session_manager_user_policy_, |
| (...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 317 ASSERT_EQ(kTestExtension2, extension2->id()); | 319 ASSERT_EQ(kTestExtension2, extension2->id()); |
| 318 | 320 |
| 319 // This extension only sends the 'policy' signal once it receives the policy, | 321 // This extension only sends the 'policy' signal once it receives the policy, |
| 320 // and after verifying it has the expected value. Otherwise it sends 'fail'. | 322 // and after verifying it has the expected value. Otherwise it sends 'fail'. |
| 321 EXPECT_TRUE(result_listener.WaitUntilSatisfied()); | 323 EXPECT_TRUE(result_listener.WaitUntilSatisfied()); |
| 322 } | 324 } |
| 323 | 325 |
| 324 #endif // OS_CHROMEOS | 326 #endif // OS_CHROMEOS |
| 325 | 327 |
| 326 } // namespace policy | 328 } // namespace policy |
| OLD | NEW |