OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/system/device_disabling_manager.h" | 5 #include "chrome/browser/chromeos/system/device_disabling_manager.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/bind_helpers.h" | 8 #include "base/bind_helpers.h" |
9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
10 #include "base/macros.h" | 10 #include "base/macros.h" |
11 #include "base/memory/ref_counted.h" | 11 #include "base/memory/ref_counted.h" |
12 #include "base/run_loop.h" | 12 #include "base/run_loop.h" |
13 #include "chrome/browser/browser_process_platform_part.h" | 13 #include "chrome/browser/browser_process_platform_part.h" |
14 #include "chrome/browser/chromeos/policy/browser_policy_connector_chromeos.h" | 14 #include "chrome/browser/chromeos/policy/browser_policy_connector_chromeos.h" |
15 #include "chrome/browser/chromeos/policy/device_cloud_policy_manager_chromeos.h" | 15 #include "chrome/browser/chromeos/policy/device_cloud_policy_manager_chromeos.h" |
16 #include "chrome/browser/chromeos/policy/device_policy_builder.h" | 16 #include "chrome/browser/chromeos/policy/device_policy_builder.h" |
17 #include "chrome/browser/chromeos/policy/server_backed_device_state.h" | 17 #include "chrome/browser/chromeos/policy/server_backed_device_state.h" |
18 #include "chrome/browser/chromeos/policy/stub_enterprise_install_attributes.h" | |
19 #include "chrome/browser/chromeos/settings/device_settings_service.h" | 18 #include "chrome/browser/chromeos/settings/device_settings_service.h" |
20 #include "chrome/browser/chromeos/settings/device_settings_test_helper.h" | 19 #include "chrome/browser/chromeos/settings/device_settings_test_helper.h" |
| 20 #include "chrome/browser/chromeos/settings/stub_install_attributes.h" |
21 #include "chrome/common/pref_names.h" | 21 #include "chrome/common/pref_names.h" |
22 #include "chrome/test/base/testing_browser_process.h" | 22 #include "chrome/test/base/testing_browser_process.h" |
23 #include "chromeos/chromeos_switches.h" | 23 #include "chromeos/chromeos_switches.h" |
24 #include "components/ownership/mock_owner_key_util.h" | 24 #include "components/ownership/mock_owner_key_util.h" |
25 #include "components/policy/core/common/cloud/cloud_policy_constants.h" | 25 #include "components/policy/core/common/cloud/cloud_policy_constants.h" |
26 #include "components/policy/proto/device_management_backend.pb.h" | 26 #include "components/policy/proto/device_management_backend.pb.h" |
27 #include "components/prefs/scoped_user_pref_update.h" | 27 #include "components/prefs/scoped_user_pref_update.h" |
28 #include "components/prefs/testing_pref_service.h" | 28 #include "components/prefs/testing_pref_service.h" |
29 #include "components/user_manager/fake_user_manager.h" | 29 #include "components/user_manager/fake_user_manager.h" |
30 #include "content/public/test/test_browser_thread_bundle.h" | 30 #include "content/public/test/test_browser_thread_bundle.h" |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
64 | 64 |
65 // DeviceDisablingManager::Delegate: | 65 // DeviceDisablingManager::Delegate: |
66 MOCK_METHOD0(RestartToLoginScreen, void()); | 66 MOCK_METHOD0(RestartToLoginScreen, void()); |
67 MOCK_METHOD0(ShowDeviceDisabledScreen, void()); | 67 MOCK_METHOD0(ShowDeviceDisabledScreen, void()); |
68 | 68 |
69 DeviceDisablingManager* GetDeviceDisablingManager() { | 69 DeviceDisablingManager* GetDeviceDisablingManager() { |
70 return device_disabling_manager_.get(); | 70 return device_disabling_manager_.get(); |
71 } | 71 } |
72 | 72 |
73 private: | 73 private: |
74 policy::ScopedStubEnterpriseInstallAttributes install_attributes_; | 74 chromeos::ScopedStubInstallAttributes install_attributes_; |
75 chromeos::ScopedTestDeviceSettingsService test_device_settings_service_; | 75 chromeos::ScopedTestDeviceSettingsService test_device_settings_service_; |
76 chromeos::ScopedTestCrosSettings test_cros_settings_; | 76 chromeos::ScopedTestCrosSettings test_cros_settings_; |
77 user_manager::FakeUserManager fake_user_manager_; | 77 user_manager::FakeUserManager fake_user_manager_; |
78 std::unique_ptr<DeviceDisablingManager> device_disabling_manager_; | 78 std::unique_ptr<DeviceDisablingManager> device_disabling_manager_; |
79 | 79 |
80 DISALLOW_COPY_AND_ASSIGN(DeviceDisablingManagerTestBase); | 80 DISALLOW_COPY_AND_ASSIGN(DeviceDisablingManagerTestBase); |
81 }; | 81 }; |
82 | 82 |
83 DeviceDisablingManagerTestBase::DeviceDisablingManagerTestBase() | 83 DeviceDisablingManagerTestBase::DeviceDisablingManagerTestBase() |
84 : install_attributes_("", "", "", policy::DEVICE_MODE_NOT_SET) { | 84 : install_attributes_("", "", "", policy::DEVICE_MODE_NOT_SET) { |
(...skipping 11 matching lines...) Expand all Loading... |
96 } | 96 } |
97 | 97 |
98 void DeviceDisablingManagerTestBase::DestroyDeviceDisablingManager() { | 98 void DeviceDisablingManagerTestBase::DestroyDeviceDisablingManager() { |
99 device_disabling_manager_.reset(); | 99 device_disabling_manager_.reset(); |
100 } | 100 } |
101 | 101 |
102 void DeviceDisablingManagerTestBase::UpdateInstallAttributes( | 102 void DeviceDisablingManagerTestBase::UpdateInstallAttributes( |
103 const std::string& enrollment_domain, | 103 const std::string& enrollment_domain, |
104 const std::string& registration_user, | 104 const std::string& registration_user, |
105 policy::DeviceMode device_mode) { | 105 policy::DeviceMode device_mode) { |
106 policy::StubEnterpriseInstallAttributes* install_attributes = | 106 chromeos::StubInstallAttributes* install_attributes = |
107 static_cast<policy::StubEnterpriseInstallAttributes*>( | 107 static_cast<chromeos::StubInstallAttributes*>( |
108 TestingBrowserProcess::GetGlobal()->platform_part()-> | 108 TestingBrowserProcess::GetGlobal() |
109 browser_policy_connector_chromeos()->GetInstallAttributes()); | 109 ->platform_part() |
| 110 ->browser_policy_connector_chromeos() |
| 111 ->GetInstallAttributes()); |
110 install_attributes->SetDomain(enrollment_domain); | 112 install_attributes->SetDomain(enrollment_domain); |
111 install_attributes->SetRegistrationUser(registration_user); | 113 install_attributes->SetRegistrationUser(registration_user); |
112 install_attributes->SetMode(device_mode); | 114 install_attributes->SetMode(device_mode); |
113 } | 115 } |
114 | 116 |
115 void DeviceDisablingManagerTestBase::LogIn() { | 117 void DeviceDisablingManagerTestBase::LogIn() { |
116 fake_user_manager_.AddUser(AccountId::FromUserEmail(kTestUser)); | 118 fake_user_manager_.AddUser(AccountId::FromUserEmail(kTestUser)); |
117 } | 119 } |
118 | 120 |
119 // Base class for tests that verify device disabling behavior during OOBE, when | 121 // Base class for tests that verify device disabling behavior during OOBE, when |
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
250 class DeviceDisablingManagerTest : public DeviceDisablingManagerTestBase, | 252 class DeviceDisablingManagerTest : public DeviceDisablingManagerTestBase, |
251 public DeviceDisablingManager::Observer { | 253 public DeviceDisablingManager::Observer { |
252 public: | 254 public: |
253 DeviceDisablingManagerTest(); | 255 DeviceDisablingManagerTest(); |
254 | 256 |
255 // DeviceDisablingManagerTestBase: | 257 // DeviceDisablingManagerTestBase: |
256 void TearDown() override; | 258 void TearDown() override; |
257 void CreateDeviceDisablingManager() override; | 259 void CreateDeviceDisablingManager() override; |
258 void DestroyDeviceDisablingManager() override; | 260 void DestroyDeviceDisablingManager() override; |
259 | 261 |
260 //DeviceDisablingManager::Observer: | 262 // DeviceDisablingManager::Observer: |
261 MOCK_METHOD1(OnDisabledMessageChanged, void(const std::string&)); | 263 MOCK_METHOD1(OnDisabledMessageChanged, void(const std::string&)); |
262 | 264 |
263 void SetUnowned(); | 265 void SetUnowned(); |
264 void SetEnterpriseOwned(); | 266 void SetEnterpriseOwned(); |
265 void SetConsumerOwned(); | 267 void SetConsumerOwned(); |
266 void MakeCrosSettingsTrusted(); | 268 void MakeCrosSettingsTrusted(); |
267 | 269 |
268 void SetDeviceDisabled(bool disabled); | 270 void SetDeviceDisabled(bool disabled); |
269 void SetDisabledMessage(const std::string& disabled_message); | 271 void SetDisabledMessage(const std::string& disabled_message); |
270 | 272 |
(...skipping 237 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
508 DeviceDisablingManager::HonorDeviceDisablingDuringNormalOperation()); | 510 DeviceDisablingManager::HonorDeviceDisablingDuringNormalOperation()); |
509 | 511 |
510 // Not enterprise owned, disabled by flag. | 512 // Not enterprise owned, disabled by flag. |
511 SetUnowned(); | 513 SetUnowned(); |
512 EXPECT_FALSE( | 514 EXPECT_FALSE( |
513 DeviceDisablingManager::HonorDeviceDisablingDuringNormalOperation()); | 515 DeviceDisablingManager::HonorDeviceDisablingDuringNormalOperation()); |
514 } | 516 } |
515 | 517 |
516 } // namespace system | 518 } // namespace system |
517 } // namespace chromeos | 519 } // namespace chromeos |
OLD | NEW |