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 "base/command_line.h" | 5 #include "base/command_line.h" |
6 #include "base/memory/scoped_ptr.h" | 6 #include "base/memory/scoped_ptr.h" |
7 #include "base/run_loop.h" | 7 #include "base/run_loop.h" |
8 #include "chrome/browser/chromeos/login/wizard_controller.h" | 8 #include "chrome/browser/chromeos/login/wizard_controller.h" |
9 #include "chrome/browser/chromeos/policy/device_policy_builder.h" | 9 #include "chrome/browser/chromeos/policy/device_policy_builder.h" |
10 #include "chrome/browser/chromeos/policy/device_policy_cros_browser_test.h" | 10 #include "chrome/browser/chromeos/policy/device_policy_cros_browser_test.h" |
(...skipping 15 matching lines...) Expand all Loading... |
26 // Device policy is updated in two steps: | 26 // Device policy is updated in two steps: |
27 // - First, set up the policy builder that GetDevicePolicyBuilder() returns. | 27 // - First, set up the policy builder that GetDevicePolicyBuilder() returns. |
28 // - Second, call SimulatePolicyFetch() to build and flush the resulting | 28 // - Second, call SimulatePolicyFetch() to build and flush the resulting |
29 // policy blob to the browser. | 29 // policy blob to the browser. |
30 policy::DevicePolicyBuilder* GetDevicePolicyBuilder(); | 30 policy::DevicePolicyBuilder* GetDevicePolicyBuilder(); |
31 void SimulatePolicyFetch(); | 31 void SimulatePolicyFetch(); |
32 | 32 |
33 private: | 33 private: |
34 // InProcessBrowserTest: | 34 // InProcessBrowserTest: |
35 void SetUpInProcessBrowserTestFixture() override; | 35 void SetUpInProcessBrowserTestFixture() override; |
36 void SetUpCommandLine(CommandLine* command_line) override; | 36 void SetUpCommandLine(base::CommandLine* command_line) override; |
37 | 37 |
38 FakeSessionManagerClient* fake_session_manager_client_; | 38 FakeSessionManagerClient* fake_session_manager_client_; |
39 policy::DevicePolicyCrosTestHelper test_helper_; | 39 policy::DevicePolicyCrosTestHelper test_helper_; |
40 | 40 |
41 DISALLOW_COPY_AND_ASSIGN(DeviceDisablingTest); | 41 DISALLOW_COPY_AND_ASSIGN(DeviceDisablingTest); |
42 }; | 42 }; |
43 | 43 |
44 | 44 |
45 DeviceDisablingTest::DeviceDisablingTest() | 45 DeviceDisablingTest::DeviceDisablingTest() |
46 : fake_session_manager_client_(new FakeSessionManagerClient) { | 46 : fake_session_manager_client_(new FakeSessionManagerClient) { |
(...skipping 11 matching lines...) Expand all Loading... |
58 } | 58 } |
59 | 59 |
60 void DeviceDisablingTest::SetUpInProcessBrowserTestFixture() { | 60 void DeviceDisablingTest::SetUpInProcessBrowserTestFixture() { |
61 DBusThreadManager::GetSetterForTesting()->SetSessionManagerClient( | 61 DBusThreadManager::GetSetterForTesting()->SetSessionManagerClient( |
62 scoped_ptr<SessionManagerClient>(fake_session_manager_client_)); | 62 scoped_ptr<SessionManagerClient>(fake_session_manager_client_)); |
63 | 63 |
64 test_helper_.InstallOwnerKey(); | 64 test_helper_.InstallOwnerKey(); |
65 test_helper_.MarkAsEnterpriseOwned(); | 65 test_helper_.MarkAsEnterpriseOwned(); |
66 } | 66 } |
67 | 67 |
68 void DeviceDisablingTest::SetUpCommandLine(CommandLine* command_line) { | 68 void DeviceDisablingTest::SetUpCommandLine(base::CommandLine* command_line) { |
69 command_line->AppendSwitch(switches::kLoginManager); | 69 command_line->AppendSwitch(switches::kLoginManager); |
70 command_line->AppendSwitch(switches::kForceLoginManagerInTests); | 70 command_line->AppendSwitch(switches::kForceLoginManagerInTests); |
71 } | 71 } |
72 | 72 |
73 IN_PROC_BROWSER_TEST_F(DeviceDisablingTest, DisableDuringNormalOperation) { | 73 IN_PROC_BROWSER_TEST_F(DeviceDisablingTest, DisableDuringNormalOperation) { |
74 // Mark the device as disabled and wait until cros settings update. | 74 // Mark the device as disabled and wait until cros settings update. |
75 base::RunLoop run_loop; | 75 base::RunLoop run_loop; |
76 scoped_ptr<CrosSettings::ObserverSubscription> observer = | 76 scoped_ptr<CrosSettings::ObserverSubscription> observer = |
77 CrosSettings::Get()->AddSettingsObserver( | 77 CrosSettings::Get()->AddSettingsObserver( |
78 kDeviceDisabled, | 78 kDeviceDisabled, |
79 run_loop.QuitClosure()); | 79 run_loop.QuitClosure()); |
80 GetDevicePolicyBuilder()->policy_data().mutable_device_state()-> | 80 GetDevicePolicyBuilder()->policy_data().mutable_device_state()-> |
81 set_device_mode(enterprise_management::DeviceState::DEVICE_MODE_DISABLED); | 81 set_device_mode(enterprise_management::DeviceState::DEVICE_MODE_DISABLED); |
82 SimulatePolicyFetch(); | 82 SimulatePolicyFetch(); |
83 run_loop.Run(); | 83 run_loop.Run(); |
84 | 84 |
85 // Verify that the device disabled screen is being shown. | 85 // Verify that the device disabled screen is being shown. |
86 WizardController* wizard_controller = WizardController::default_controller(); | 86 WizardController* wizard_controller = WizardController::default_controller(); |
87 ASSERT_TRUE(wizard_controller); | 87 ASSERT_TRUE(wizard_controller); |
88 EXPECT_EQ(wizard_controller->GetScreen( | 88 EXPECT_EQ(wizard_controller->GetScreen( |
89 WizardController::kDeviceDisabledScreenName), | 89 WizardController::kDeviceDisabledScreenName), |
90 wizard_controller->current_screen()); | 90 wizard_controller->current_screen()); |
91 } | 91 } |
92 | 92 |
93 } // namespace system | 93 } // namespace system |
94 } // namespace chromeos | 94 } // namespace chromeos |
OLD | NEW |