Index: chrome/browser/chromeos/system/device_disabling_browsertest.cc |
diff --git a/chrome/browser/chromeos/system/device_disabling_browsertest.cc b/chrome/browser/chromeos/system/device_disabling_browsertest.cc |
new file mode 100644 |
index 0000000000000000000000000000000000000000..329efa26b44b39771fe34ae57ff3dad2f122d916 |
--- /dev/null |
+++ b/chrome/browser/chromeos/system/device_disabling_browsertest.cc |
@@ -0,0 +1,89 @@ |
+// Copyright 2014 The Chromium Authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+#include "base/command_line.h" |
+#include "base/memory/scoped_ptr.h" |
+#include "base/run_loop.h" |
+#include "chrome/browser/chromeos/login/wizard_controller.h" |
+#include "chrome/browser/chromeos/policy/device_policy_builder.h" |
+#include "chrome/browser/chromeos/policy/device_policy_cros_browser_test.h" |
+#include "chrome/browser/chromeos/settings/cros_settings.h" |
+#include "chrome/test/base/in_process_browser_test.h" |
+#include "chromeos/chromeos_switches.h" |
+#include "chromeos/dbus/dbus_thread_manager.h" |
+#include "chromeos/dbus/fake_session_manager_client.h" |
+#include "chromeos/settings/cros_settings_names.h" |
+#include "policy/proto/device_management_backend.pb.h" |
+ |
+namespace chromeos { |
+namespace system { |
+ |
+class DeviceDisablingTest : public InProcessBrowserTest { |
+ public: |
+ DeviceDisablingTest(); |
+ |
+ // InProcessBrowserTest: |
+ 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.
|
+ void SetUpCommandLine(CommandLine* command_line) override; |
+ |
+ 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.
|
+ void SimulatePolicyFetch(); |
+ |
+ private: |
+ FakeSessionManagerClient* fake_session_manager_client_; |
+ policy::DevicePolicyCrosTestHelper test_helper_; |
+ |
+ DISALLOW_COPY_AND_ASSIGN(DeviceDisablingTest); |
+}; |
+ |
+ |
+DeviceDisablingTest::DeviceDisablingTest() |
+ : fake_session_manager_client_(new FakeSessionManagerClient) { |
+} |
+ |
+void DeviceDisablingTest::SetUpInProcessBrowserTestFixture() { |
+ DBusThreadManager::GetSetterForTesting()->SetSessionManagerClient( |
+ scoped_ptr<SessionManagerClient>(fake_session_manager_client_)); |
+ |
+ test_helper_.InstallOwnerKey(); |
+ test_helper_.MarkAsEnterpriseOwned(); |
+} |
+ |
+void DeviceDisablingTest::SetUpCommandLine(CommandLine* command_line) { |
+ command_line->AppendSwitch(switches::kLoginManager); |
+ command_line->AppendSwitch(switches::kForceLoginManagerInTests); |
+} |
+ |
+policy::DevicePolicyBuilder* DeviceDisablingTest::GetDevicePolicy() { |
+ return test_helper_.device_policy(); |
+} |
+ |
+void DeviceDisablingTest::SimulatePolicyFetch() { |
+ GetDevicePolicy()->Build(); |
+ fake_session_manager_client_->set_device_policy(GetDevicePolicy()->GetBlob()); |
+ fake_session_manager_client_->OnPropertyChangeComplete(true); |
+} |
+ |
+IN_PROC_BROWSER_TEST_F(DeviceDisablingTest, DisableDuringNormalOperation) { |
+ // Mark the device as disabled and wait until cros settings update. |
+ base::RunLoop run_loop; |
+ scoped_ptr<CrosSettings::ObserverSubscription> observer = |
+ CrosSettings::Get()->AddSettingsObserver( |
+ kDeviceDisabled, |
+ run_loop.QuitClosure()); |
+ GetDevicePolicy()->policy_data().mutable_device_state()->set_device_mode( |
+ enterprise_management::DeviceState::DEVICE_MODE_DISABLED); |
+ SimulatePolicyFetch(); |
+ run_loop.Run(); |
+ |
+ // Verify that the device disabled screen is being shown. |
+ WizardController* wizard_controller = WizardController::default_controller(); |
+ ASSERT_TRUE(wizard_controller); |
+ 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
|
+ WizardController::kDeviceDisabledScreenName), |
+ WizardController::default_controller()->current_screen()); |
+} |
+ |
+} // namespace system |
+} // namespace chromeos |