Chromium Code Reviews| 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 #include <vector> | 6 #include <vector> |
| 7 | 7 |
| 8 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/callback.h" | 10 #include "base/callback.h" |
| (...skipping 25 matching lines...) Expand all Loading... | |
| 36 #include "chrome/browser/policy/profile_policy_connector.h" | 36 #include "chrome/browser/policy/profile_policy_connector.h" |
| 37 #include "chrome/browser/policy/profile_policy_connector_factory.h" | 37 #include "chrome/browser/policy/profile_policy_connector_factory.h" |
| 38 #include "chrome/browser/policy/proto/chromeos/chrome_device_policy.pb.h" | 38 #include "chrome/browser/policy/proto/chromeos/chrome_device_policy.pb.h" |
| 39 #include "chrome/browser/policy/proto/cloud/device_management_backend.pb.h" | 39 #include "chrome/browser/policy/proto/cloud/device_management_backend.pb.h" |
| 40 #include "chrome/browser/profiles/profile.h" | 40 #include "chrome/browser/profiles/profile.h" |
| 41 #include "chrome/browser/profiles/profile_manager.h" | 41 #include "chrome/browser/profiles/profile_manager.h" |
| 42 #include "chrome/common/extensions/api/power.h" | 42 #include "chrome/common/extensions/api/power.h" |
| 43 #include "chrome/test/base/testing_profile.h" | 43 #include "chrome/test/base/testing_profile.h" |
| 44 #include "chromeos/chromeos_paths.h" | 44 #include "chromeos/chromeos_paths.h" |
| 45 #include "chromeos/chromeos_switches.h" | 45 #include "chromeos/chromeos_switches.h" |
| 46 #include "chromeos/dbus/cryptohome_client.h" | |
| 46 #include "chromeos/dbus/fake_power_manager_client.h" | 47 #include "chromeos/dbus/fake_power_manager_client.h" |
| 47 #include "chromeos/dbus/fake_session_manager_client.h" | 48 #include "chromeos/dbus/fake_session_manager_client.h" |
| 48 #include "chromeos/dbus/mock_dbus_thread_manager_without_gmock.h" | 49 #include "chromeos/dbus/mock_dbus_thread_manager_without_gmock.h" |
| 49 #include "chromeos/dbus/power_manager/policy.pb.h" | 50 #include "chromeos/dbus/power_manager/policy.pb.h" |
| 50 #include "chromeos/dbus/power_policy_controller.h" | 51 #include "chromeos/dbus/power_policy_controller.h" |
| 51 #include "content/public/browser/notification_details.h" | 52 #include "content/public/browser/notification_details.h" |
| 52 #include "content/public/browser/notification_service.h" | 53 #include "content/public/browser/notification_service.h" |
| 53 #include "content/public/browser/notification_source.h" | 54 #include "content/public/browser/notification_source.h" |
| 54 #include "content/public/test/test_utils.h" | 55 #include "content/public/test/test_utils.h" |
| 55 #include "crypto/rsa_private_key.h" | 56 #include "crypto/rsa_private_key.h" |
| (...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 164 DevicePolicyCrosBrowserTest::SetUpOnMainThread(); | 165 DevicePolicyCrosBrowserTest::SetUpOnMainThread(); |
| 165 | 166 |
| 166 // Initialize user policy. | 167 // Initialize user policy. |
| 167 InstallUserKey(); | 168 InstallUserKey(); |
| 168 user_policy_.policy_data().set_username(chromeos::UserManager::kStubUser); | 169 user_policy_.policy_data().set_username(chromeos::UserManager::kStubUser); |
| 169 } | 170 } |
| 170 | 171 |
| 171 void PowerPolicyBrowserTestBase::InstallUserKey() { | 172 void PowerPolicyBrowserTestBase::InstallUserKey() { |
| 172 base::FilePath user_keys_dir; | 173 base::FilePath user_keys_dir; |
| 173 ASSERT_TRUE(PathService::Get(chromeos::DIR_USER_POLICY_KEYS, &user_keys_dir)); | 174 ASSERT_TRUE(PathService::Get(chromeos::DIR_USER_POLICY_KEYS, &user_keys_dir)); |
| 175 std::string sanitized_username = | |
| 176 chromeos::CryptohomeClient::GetStubSanitizedUsername( | |
| 177 chromeos::UserManager::kStubUser); | |
|
satorux1
2013/09/27 02:31:02
This change was needed as the new FakeCryptohomeCl
| |
| 174 base::FilePath user_key_file = | 178 base::FilePath user_key_file = |
| 175 user_keys_dir.AppendASCII(chromeos::UserManager::kStubUser) | 179 user_keys_dir.AppendASCII(sanitized_username) |
| 176 .AppendASCII("policy.pub"); | 180 .AppendASCII("policy.pub"); |
| 177 std::vector<uint8> user_key_bits; | 181 std::vector<uint8> user_key_bits; |
| 178 ASSERT_TRUE(user_policy_.GetSigningKey()->ExportPublicKey(&user_key_bits)); | 182 ASSERT_TRUE(user_policy_.GetSigningKey()->ExportPublicKey(&user_key_bits)); |
| 179 ASSERT_TRUE(file_util::CreateDirectory(user_key_file.DirName())); | 183 ASSERT_TRUE(file_util::CreateDirectory(user_key_file.DirName())); |
| 180 ASSERT_EQ(file_util::WriteFile( | 184 ASSERT_EQ(file_util::WriteFile( |
| 181 user_key_file, | 185 user_key_file, |
| 182 reinterpret_cast<const char*>(user_key_bits.data()), | 186 reinterpret_cast<const char*>(user_key_bits.data()), |
| 183 user_key_bits.size()), | 187 user_key_bits.size()), |
| 184 static_cast<int>(user_key_bits.size())); | 188 static_cast<int>(user_key_bits.size())); |
| 185 } | 189 } |
| (...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 416 policy.set_ac_idle_action( | 420 policy.set_ac_idle_action( |
| 417 power_manager_client_->get_policy().ac_idle_action()); | 421 power_manager_client_->get_policy().ac_idle_action()); |
| 418 policy.set_battery_idle_action( | 422 policy.set_battery_idle_action( |
| 419 power_manager_client_->get_policy().battery_idle_action()); | 423 power_manager_client_->get_policy().battery_idle_action()); |
| 420 policy.set_reason(power_manager_client_->get_policy().reason()); | 424 policy.set_reason(power_manager_client_->get_policy().reason()); |
| 421 EXPECT_EQ(GetDebugString(policy), | 425 EXPECT_EQ(GetDebugString(policy), |
| 422 GetDebugString(power_manager_client_->get_policy())); | 426 GetDebugString(power_manager_client_->get_policy())); |
| 423 } | 427 } |
| 424 | 428 |
| 425 } // namespace policy | 429 } // namespace policy |
| OLD | NEW |