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

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

Issue 16658015: Add device policies to control accessibility settings on the login screen (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fixed leaky tests. Created 7 years, 6 months 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 | Annotate | Revision Log
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 "chrome/browser/chromeos/policy/device_policy_cros_browser_test.h" 5 #include "chrome/browser/chromeos/policy/device_policy_cros_browser_test.h"
6 6
7 #include <string>
7 #include <vector> 8 #include <vector>
8 9
9 #include "base/file_util.h" 10 #include "base/file_util.h"
10 #include "base/files/file_path.h" 11 #include "base/files/file_path.h"
11 #include "base/files/scoped_temp_dir.h" 12 #include "base/files/scoped_temp_dir.h"
12 #include "base/path_service.h" 13 #include "base/path_service.h"
13 #include "base/stl_util.h" 14 #include "base/stl_util.h"
14 #include "chrome/browser/chromeos/policy/device_policy_builder.h" 15 #include "chrome/browser/chromeos/policy/device_policy_builder.h"
16 #include "chrome/browser/chromeos/policy/enterprise_install_attributes.h"
17 #include "chrome/browser/policy/proto/chromeos/install_attributes.pb.h"
15 #include "chromeos/chromeos_paths.h" 18 #include "chromeos/chromeos_paths.h"
16 #include "chromeos/dbus/mock_dbus_thread_manager_without_gmock.h" 19 #include "chromeos/dbus/mock_dbus_thread_manager_without_gmock.h"
17 #include "crypto/rsa_private_key.h" 20 #include "crypto/rsa_private_key.h"
18 #include "testing/gmock/include/gmock/gmock.h" 21 #include "testing/gmock/include/gmock/gmock.h"
19 #include "testing/gtest/include/gtest/gtest.h" 22 #include "testing/gtest/include/gtest/gtest.h"
20 23
21 using ::testing::_; 24 using ::testing::_;
22 using ::testing::AnyNumber; 25 using ::testing::AnyNumber;
23 using ::testing::Return; 26 using ::testing::Return;
24 27
25 namespace policy { 28 namespace policy {
26 29
30 // static
31 void DevicePolicyCrosBrowserTest::MarkAsEnterpriseOwned(
32 base::ScopedTempDir* temp_dir) {
33 cryptohome::SerializedInstallAttributes install_attrs_proto;
34 cryptohome::SerializedInstallAttributes::Attribute* attribute = NULL;
35
36 attribute = install_attrs_proto.add_attributes();
37 attribute->set_name(EnterpriseInstallAttributes::kAttrEnterpriseOwned);
38 attribute->set_value("true");
39
40 attribute = install_attrs_proto.add_attributes();
41 attribute->set_name(EnterpriseInstallAttributes::kAttrEnterpriseUser);
42 attribute->set_value(DevicePolicyBuilder::kFakeUsername);
43
44 base::FilePath install_attrs_file =
45 temp_dir->path().AppendASCII("install_attributes.pb");
46 const std::string install_attrs_blob(
47 install_attrs_proto.SerializeAsString());
48 ASSERT_EQ(static_cast<int>(install_attrs_blob.size()),
49 file_util::WriteFile(install_attrs_file,
50 install_attrs_blob.c_str(),
51 install_attrs_blob.size()));
52 ASSERT_TRUE(PathService::Override(chromeos::FILE_INSTALL_ATTRIBUTES,
53 install_attrs_file));
54 }
55
27 DevicePolicyCrosBrowserTest::DevicePolicyCrosBrowserTest() 56 DevicePolicyCrosBrowserTest::DevicePolicyCrosBrowserTest()
28 : mock_dbus_thread_manager_( 57 : mock_dbus_thread_manager_(
29 new chromeos::MockDBusThreadManagerWithoutGMock) { 58 new chromeos::MockDBusThreadManagerWithoutGMock) {
30 } 59 }
31 60
32 DevicePolicyCrosBrowserTest::~DevicePolicyCrosBrowserTest() { 61 DevicePolicyCrosBrowserTest::~DevicePolicyCrosBrowserTest() {
33 } 62 }
34 63
35 void DevicePolicyCrosBrowserTest::SetUpInProcessBrowserTestFixture() { 64 void DevicePolicyCrosBrowserTest::SetUpInProcessBrowserTestFixture() {
36 chromeos::DBusThreadManager::InitializeForTesting(mock_dbus_thread_manager_); 65 chromeos::DBusThreadManager::InitializeForTesting(mock_dbus_thread_manager_);
(...skipping 29 matching lines...) Expand all
66 session_manager_client()->set_device_policy(device_policy_.GetBlob()); 95 session_manager_client()->set_device_policy(device_policy_.GetBlob());
67 session_manager_client()->OnPropertyChangeComplete(true); 96 session_manager_client()->OnPropertyChangeComplete(true);
68 } 97 }
69 98
70 void DevicePolicyCrosBrowserTest::TearDownInProcessBrowserTestFixture() { 99 void DevicePolicyCrosBrowserTest::TearDownInProcessBrowserTestFixture() {
71 CrosInProcessBrowserTest::TearDownInProcessBrowserTestFixture(); 100 CrosInProcessBrowserTest::TearDownInProcessBrowserTestFixture();
72 chromeos::DBusThreadManager::Shutdown(); 101 chromeos::DBusThreadManager::Shutdown();
73 } 102 }
74 103
75 } // namespace policy 104 } // namespace policy
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698