Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(114)

Side by Side Diff: chrome/browser/chromeos/policy/power_policy_browsertest.cc

Issue 2452983002: ChromeOS: This CL moves chromeos/login/user_names* to user_mananger. (Closed)
Patch Set: Remove unused include Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 <stdint.h> 5 #include <stdint.h>
6 6
7 #include <string> 7 #include <string>
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 23 matching lines...) Expand all
34 #include "chrome/browser/ui/browser.h" 34 #include "chrome/browser/ui/browser.h"
35 #include "chrome/test/base/testing_profile.h" 35 #include "chrome/test/base/testing_profile.h"
36 #include "chromeos/chromeos_paths.h" 36 #include "chromeos/chromeos_paths.h"
37 #include "chromeos/chromeos_switches.h" 37 #include "chromeos/chromeos_switches.h"
38 #include "chromeos/dbus/cryptohome_client.h" 38 #include "chromeos/dbus/cryptohome_client.h"
39 #include "chromeos/dbus/dbus_thread_manager.h" 39 #include "chromeos/dbus/dbus_thread_manager.h"
40 #include "chromeos/dbus/fake_power_manager_client.h" 40 #include "chromeos/dbus/fake_power_manager_client.h"
41 #include "chromeos/dbus/fake_session_manager_client.h" 41 #include "chromeos/dbus/fake_session_manager_client.h"
42 #include "chromeos/dbus/power_manager/policy.pb.h" 42 #include "chromeos/dbus/power_manager/policy.pb.h"
43 #include "chromeos/dbus/power_policy_controller.h" 43 #include "chromeos/dbus/power_policy_controller.h"
44 #include "chromeos/login/user_names.h"
45 #include "components/policy/core/common/cloud/cloud_policy_core.h" 44 #include "components/policy/core/common/cloud/cloud_policy_core.h"
46 #include "components/policy/core/common/cloud/cloud_policy_store.h" 45 #include "components/policy/core/common/cloud/cloud_policy_store.h"
47 #include "components/policy/core/common/cloud/policy_builder.h" 46 #include "components/policy/core/common/cloud/policy_builder.h"
48 #include "components/policy/core/common/external_data_fetcher.h" 47 #include "components/policy/core/common/external_data_fetcher.h"
49 #include "components/policy/core/common/mock_policy_service.h" 48 #include "components/policy/core/common/mock_policy_service.h"
50 #include "components/policy/core/common/policy_service.h" 49 #include "components/policy/core/common/policy_service.h"
51 #include "components/policy/proto/device_management_backend.pb.h" 50 #include "components/policy/proto/device_management_backend.pb.h"
52 #include "components/signin/core/account_id/account_id.h" 51 #include "components/signin/core/account_id/account_id.h"
52 #include "components/user_manager/user_names.h"
53 #include "content/public/browser/notification_details.h" 53 #include "content/public/browser/notification_details.h"
54 #include "content/public/browser/notification_service.h" 54 #include "content/public/browser/notification_service.h"
55 #include "content/public/browser/notification_source.h" 55 #include "content/public/browser/notification_source.h"
56 #include "content/public/test/test_utils.h" 56 #include "content/public/test/test_utils.h"
57 #include "extensions/browser/api/power/power_api.h" 57 #include "extensions/browser/api/power/power_api.h"
58 #include "extensions/common/api/power.h" 58 #include "extensions/common/api/power.h"
59 #include "testing/gmock/include/gmock/gmock.h" 59 #include "testing/gmock/include/gmock/gmock.h"
60 #include "testing/gtest/include/gtest/gtest.h" 60 #include "testing/gtest/include/gtest/gtest.h"
61 61
62 namespace em = enterprise_management; 62 namespace em = enterprise_management;
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after
192 InstallOwnerKey(); 192 InstallOwnerKey();
193 MarkAsEnterpriseOwned(); 193 MarkAsEnterpriseOwned();
194 } 194 }
195 195
196 void PowerPolicyBrowserTestBase::SetUpOnMainThread() { 196 void PowerPolicyBrowserTestBase::SetUpOnMainThread() {
197 DevicePolicyCrosBrowserTest::SetUpOnMainThread(); 197 DevicePolicyCrosBrowserTest::SetUpOnMainThread();
198 198
199 // Initialize user policy. 199 // Initialize user policy.
200 InstallUserKey(); 200 InstallUserKey();
201 user_policy_.policy_data().set_username( 201 user_policy_.policy_data().set_username(
202 chromeos::login::StubAccountId().GetUserEmail()); 202 user_manager::StubAccountId().GetUserEmail());
203 } 203 }
204 204
205 void PowerPolicyBrowserTestBase::InstallUserKey() { 205 void PowerPolicyBrowserTestBase::InstallUserKey() {
206 base::FilePath user_keys_dir; 206 base::FilePath user_keys_dir;
207 ASSERT_TRUE(PathService::Get(chromeos::DIR_USER_POLICY_KEYS, &user_keys_dir)); 207 ASSERT_TRUE(PathService::Get(chromeos::DIR_USER_POLICY_KEYS, &user_keys_dir));
208 std::string sanitized_username = 208 std::string sanitized_username =
209 chromeos::CryptohomeClient::GetStubSanitizedUsername( 209 chromeos::CryptohomeClient::GetStubSanitizedUsername(
210 cryptohome::Identification(chromeos::login::StubAccountId())); 210 cryptohome::Identification(user_manager::StubAccountId()));
211 base::FilePath user_key_file = 211 base::FilePath user_key_file =
212 user_keys_dir.AppendASCII(sanitized_username) 212 user_keys_dir.AppendASCII(sanitized_username)
213 .AppendASCII("policy.pub"); 213 .AppendASCII("policy.pub");
214 std::vector<uint8_t> user_key_bits; 214 std::vector<uint8_t> user_key_bits;
215 ASSERT_TRUE(user_policy_.GetSigningKey()->ExportPublicKey(&user_key_bits)); 215 ASSERT_TRUE(user_policy_.GetSigningKey()->ExportPublicKey(&user_key_bits));
216 ASSERT_TRUE(base::CreateDirectory(user_key_file.DirName())); 216 ASSERT_TRUE(base::CreateDirectory(user_key_file.DirName()));
217 ASSERT_EQ(base::WriteFile( 217 ASSERT_EQ(base::WriteFile(
218 user_key_file, 218 user_key_file,
219 reinterpret_cast<const char*>(user_key_bits.data()), 219 reinterpret_cast<const char*>(user_key_bits.data()),
220 user_key_bits.size()), 220 user_key_bits.size()),
(...skipping 293 matching lines...) Expand 10 before | Expand all | Expand 10 after
514 policy = baseline_policy; 514 policy = baseline_policy;
515 policy.set_ac_idle_action(power_manager_client_->policy().ac_idle_action()); 515 policy.set_ac_idle_action(power_manager_client_->policy().ac_idle_action());
516 policy.set_battery_idle_action( 516 policy.set_battery_idle_action(
517 power_manager_client_->policy().battery_idle_action()); 517 power_manager_client_->policy().battery_idle_action());
518 policy.set_reason(power_manager_client_->policy().reason()); 518 policy.set_reason(power_manager_client_->policy().reason());
519 EXPECT_EQ(GetDebugString(policy), 519 EXPECT_EQ(GetDebugString(policy),
520 GetDebugString(power_manager_client_->policy())); 520 GetDebugString(power_manager_client_->policy()));
521 } 521 }
522 522
523 } // namespace policy 523 } // namespace policy
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698