OLD | NEW |
---|---|
(Empty) | |
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 | |
3 // found in the LICENSE file. | |
4 | |
5 #include "base/command_line.h" | |
6 #include "base/memory/scoped_ptr.h" | |
7 #include "base/run_loop.h" | |
8 #include "chrome/browser/chromeos/login/wizard_controller.h" | |
9 #include "chrome/browser/chromeos/policy/device_policy_builder.h" | |
10 #include "chrome/browser/chromeos/policy/device_policy_cros_browser_test.h" | |
11 #include "chrome/browser/chromeos/settings/cros_settings.h" | |
12 #include "chrome/test/base/in_process_browser_test.h" | |
13 #include "chromeos/chromeos_switches.h" | |
14 #include "chromeos/dbus/dbus_thread_manager.h" | |
15 #include "chromeos/dbus/fake_session_manager_client.h" | |
16 #include "chromeos/settings/cros_settings_names.h" | |
17 #include "policy/proto/device_management_backend.pb.h" | |
18 | |
19 namespace chromeos { | |
20 namespace system { | |
21 | |
22 class DeviceDisablingTest : public InProcessBrowserTest { | |
23 public: | |
24 DeviceDisablingTest(); | |
25 | |
26 // InProcessBrowserTest: | |
27 void SetUpInProcessBrowserTestFixture() override; | |
achuithb
2014/11/07 00:15:17
You can make these derived methods private since t
bartfab (slow)
2014/11/07 10:11:36
Done.
| |
28 void SetUpCommandLine(CommandLine* command_line) override; | |
29 | |
30 policy::DevicePolicyBuilder* GetDevicePolicy(); | |
achuithb
2014/11/07 00:15:17
You should add function comments as per style guid
bartfab (slow)
2014/11/07 10:11:36
Done.
| |
31 void SimulatePolicyFetch(); | |
32 | |
33 private: | |
34 FakeSessionManagerClient* fake_session_manager_client_; | |
35 policy::DevicePolicyCrosTestHelper test_helper_; | |
36 | |
37 DISALLOW_COPY_AND_ASSIGN(DeviceDisablingTest); | |
38 }; | |
39 | |
40 | |
41 DeviceDisablingTest::DeviceDisablingTest() | |
42 : fake_session_manager_client_(new FakeSessionManagerClient) { | |
43 } | |
44 | |
45 void DeviceDisablingTest::SetUpInProcessBrowserTestFixture() { | |
46 DBusThreadManager::GetSetterForTesting()->SetSessionManagerClient( | |
47 scoped_ptr<SessionManagerClient>(fake_session_manager_client_)); | |
48 | |
49 test_helper_.InstallOwnerKey(); | |
50 test_helper_.MarkAsEnterpriseOwned(); | |
51 } | |
52 | |
53 void DeviceDisablingTest::SetUpCommandLine(CommandLine* command_line) { | |
54 command_line->AppendSwitch(switches::kLoginManager); | |
55 command_line->AppendSwitch(switches::kForceLoginManagerInTests); | |
56 } | |
57 | |
58 policy::DevicePolicyBuilder* DeviceDisablingTest::GetDevicePolicy() { | |
59 return test_helper_.device_policy(); | |
60 } | |
61 | |
62 void DeviceDisablingTest::SimulatePolicyFetch() { | |
63 GetDevicePolicy()->Build(); | |
64 fake_session_manager_client_->set_device_policy(GetDevicePolicy()->GetBlob()); | |
65 fake_session_manager_client_->OnPropertyChangeComplete(true); | |
66 } | |
67 | |
68 IN_PROC_BROWSER_TEST_F(DeviceDisablingTest, DisableDuringNormalOperation) { | |
69 // Mark the device as disabled and wait until cros settings update. | |
70 base::RunLoop run_loop; | |
71 scoped_ptr<CrosSettings::ObserverSubscription> observer = | |
72 CrosSettings::Get()->AddSettingsObserver( | |
73 kDeviceDisabled, | |
74 run_loop.QuitClosure()); | |
75 GetDevicePolicy()->policy_data().mutable_device_state()->set_device_mode( | |
76 enterprise_management::DeviceState::DEVICE_MODE_DISABLED); | |
77 SimulatePolicyFetch(); | |
78 run_loop.Run(); | |
79 | |
80 // Verify that the device disabled screen is being shown. | |
81 WizardController* wizard_controller = WizardController::default_controller(); | |
82 ASSERT_TRUE(wizard_controller); | |
83 EXPECT_EQ(WizardController::default_controller()->GetScreen( | |
achuithb
2014/11/07 00:15:17
I was expecting use of the local var wizard_contro
bartfab (slow)
2014/11/07 10:11:36
Oops. Kind of pointless to set up a local variable
| |
84 WizardController::kDeviceDisabledScreenName), | |
85 WizardController::default_controller()->current_screen()); | |
86 } | |
87 | |
88 } // namespace system | |
89 } // namespace chromeos | |
OLD | NEW |