| 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 <memory> | 5 #include <memory> |
| 6 #include <string> | 6 #include <string> |
| 7 | 7 |
| 8 #include "base/bind.h" | 8 #include "base/bind.h" |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "base/macros.h" | 10 #include "base/macros.h" |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 52 public: | 52 public: |
| 53 DeviceDisablingTest(); | 53 DeviceDisablingTest(); |
| 54 | 54 |
| 55 // Sets up a device state blob that indicates the device is disabled, triggers | 55 // Sets up a device state blob that indicates the device is disabled, triggers |
| 56 // a policy plus device state fetch and waits for it to succeed. | 56 // a policy plus device state fetch and waits for it to succeed. |
| 57 void MarkDisabledAndWaitForPolicyFetch(); | 57 void MarkDisabledAndWaitForPolicyFetch(); |
| 58 | 58 |
| 59 std::string GetCurrentScreenName(content::WebContents* web_contents); | 59 std::string GetCurrentScreenName(content::WebContents* web_contents); |
| 60 | 60 |
| 61 protected: | 61 protected: |
| 62 base::RunLoop network_state_change_wait_run_loop_; | 62 std::unique_ptr<base::RunLoop> network_state_change_wait_run_loop_; |
| 63 | 63 |
| 64 private: | 64 private: |
| 65 // OobeBaseTest: | 65 // OobeBaseTest: |
| 66 void SetUpInProcessBrowserTestFixture() override; | 66 void SetUpInProcessBrowserTestFixture() override; |
| 67 void SetUpOnMainThread() override; | 67 void SetUpOnMainThread() override; |
| 68 | 68 |
| 69 // NetworkStateInformer::NetworkStateInformerObserver: | 69 // NetworkStateInformer::NetworkStateInformerObserver: |
| 70 void UpdateState(NetworkError::ErrorReason reason) override; | 70 void UpdateState(NetworkError::ErrorReason reason) override; |
| 71 | 71 |
| 72 FakeSessionManagerClient* fake_session_manager_client_; | 72 FakeSessionManagerClient* fake_session_manager_client_; |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 114 OobeBaseTest::SetUpInProcessBrowserTestFixture(); | 114 OobeBaseTest::SetUpInProcessBrowserTestFixture(); |
| 115 | 115 |
| 116 DBusThreadManager::GetSetterForTesting()->SetSessionManagerClient( | 116 DBusThreadManager::GetSetterForTesting()->SetSessionManagerClient( |
| 117 std::unique_ptr<SessionManagerClient>(fake_session_manager_client_)); | 117 std::unique_ptr<SessionManagerClient>(fake_session_manager_client_)); |
| 118 | 118 |
| 119 test_helper_.InstallOwnerKey(); | 119 test_helper_.InstallOwnerKey(); |
| 120 test_helper_.MarkAsEnterpriseOwned(); | 120 test_helper_.MarkAsEnterpriseOwned(); |
| 121 } | 121 } |
| 122 | 122 |
| 123 void DeviceDisablingTest::SetUpOnMainThread() { | 123 void DeviceDisablingTest::SetUpOnMainThread() { |
| 124 network_state_change_wait_run_loop_.reset(new base::RunLoop); |
| 125 |
| 124 OobeBaseTest::SetUpOnMainThread(); | 126 OobeBaseTest::SetUpOnMainThread(); |
| 125 | 127 |
| 126 // Set up fake networks. | 128 // Set up fake networks. |
| 127 DBusThreadManager::Get()->GetShillManagerClient()->GetTestInterface()-> | 129 DBusThreadManager::Get()->GetShillManagerClient()->GetTestInterface()-> |
| 128 SetupDefaultEnvironment(); | 130 SetupDefaultEnvironment(); |
| 129 } | 131 } |
| 130 | 132 |
| 131 void DeviceDisablingTest::UpdateState(NetworkError::ErrorReason reason) { | 133 void DeviceDisablingTest::UpdateState(NetworkError::ErrorReason reason) { |
| 132 network_state_change_wait_run_loop_.Quit(); | 134 network_state_change_wait_run_loop_->Quit(); |
| 133 } | 135 } |
| 134 | 136 |
| 135 IN_PROC_BROWSER_TEST_F(DeviceDisablingTest, DisableDuringNormalOperation) { | 137 IN_PROC_BROWSER_TEST_F(DeviceDisablingTest, DisableDuringNormalOperation) { |
| 136 // Mark the device as disabled and wait until cros settings update. | 138 // Mark the device as disabled and wait until cros settings update. |
| 137 MarkDisabledAndWaitForPolicyFetch(); | 139 MarkDisabledAndWaitForPolicyFetch(); |
| 138 | 140 |
| 139 // Verify that the device disabled screen is being shown. | 141 // Verify that the device disabled screen is being shown. |
| 140 WizardController* const wizard_controller = | 142 WizardController* const wizard_controller = |
| 141 WizardController::default_controller(); | 143 WizardController::default_controller(); |
| 142 ASSERT_TRUE(wizard_controller); | 144 ASSERT_TRUE(wizard_controller); |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 199 ASSERT_TRUE(oobe_ui); | 201 ASSERT_TRUE(oobe_ui); |
| 200 const scoped_refptr<NetworkStateInformer> network_state_informer = | 202 const scoped_refptr<NetworkStateInformer> network_state_informer = |
| 201 oobe_ui->network_state_informer_for_test(); | 203 oobe_ui->network_state_informer_for_test(); |
| 202 ASSERT_TRUE(network_state_informer); | 204 ASSERT_TRUE(network_state_informer); |
| 203 network_state_informer->AddObserver(this); | 205 network_state_informer->AddObserver(this); |
| 204 SigninScreenHandler* const signin_screen_handler = | 206 SigninScreenHandler* const signin_screen_handler = |
| 205 oobe_ui->signin_screen_handler_for_test(); | 207 oobe_ui->signin_screen_handler_for_test(); |
| 206 ASSERT_TRUE(signin_screen_handler); | 208 ASSERT_TRUE(signin_screen_handler); |
| 207 signin_screen_handler->ZeroOfflineTimeoutForTesting(); | 209 signin_screen_handler->ZeroOfflineTimeoutForTesting(); |
| 208 SimulateNetworkOffline(); | 210 SimulateNetworkOffline(); |
| 209 network_state_change_wait_run_loop_.Run(); | 211 network_state_change_wait_run_loop_->Run(); |
| 210 network_state_informer->RemoveObserver(this); | 212 network_state_informer->RemoveObserver(this); |
| 211 base::RunLoop().RunUntilIdle(); | 213 base::RunLoop().RunUntilIdle(); |
| 212 | 214 |
| 213 // Verify that the offline error screen was not shown and the device disabled | 215 // Verify that the offline error screen was not shown and the device disabled |
| 214 // screen is still being shown instead. | 216 // screen is still being shown instead. |
| 215 EXPECT_EQ(GetOobeScreenName(OobeScreen::SCREEN_DEVICE_DISABLED), | 217 EXPECT_EQ(GetOobeScreenName(OobeScreen::SCREEN_DEVICE_DISABLED), |
| 216 GetCurrentScreenName(web_contents)); | 218 GetCurrentScreenName(web_contents)); |
| 217 } | 219 } |
| 218 | 220 |
| 219 } // namespace system | 221 } // namespace system |
| 220 } // namespace chromeos | 222 } // namespace chromeos |
| OLD | NEW |