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 <string> | 5 #include <string> |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/logging.h" | 8 #include "base/logging.h" |
9 #include "base/macros.h" | 9 #include "base/macros.h" |
10 #include "base/memory/ref_counted.h" | 10 #include "base/memory/ref_counted.h" |
(...skipping 30 matching lines...) Expand all Loading... |
41 | 41 |
42 namespace { | 42 namespace { |
43 | 43 |
44 void ErrorCallbackFunction(const std::string& error_name, | 44 void ErrorCallbackFunction(const std::string& error_name, |
45 const std::string& error_message) { | 45 const std::string& error_message) { |
46 LOG(ERROR) << "Shill Error: " << error_name << " : " << error_message; | 46 LOG(ERROR) << "Shill Error: " << error_name << " : " << error_message; |
47 } | 47 } |
48 | 48 |
49 } // namespace | 49 } // namespace |
50 | 50 |
| 51 // Boolean parameter is used to run this test for webview (true) and for |
| 52 // iframe (false) GAIA sign in. |
51 class DeviceDisablingTest | 53 class DeviceDisablingTest |
52 : public OobeBaseTest, | 54 : public OobeBaseTest, |
53 public NetworkStateInformer::NetworkStateInformerObserver { | 55 public NetworkStateInformer::NetworkStateInformerObserver, |
| 56 public testing::WithParamInterface<bool> { |
54 public: | 57 public: |
55 DeviceDisablingTest(); | 58 DeviceDisablingTest(); |
56 | 59 |
57 // Sets up a device state blob that indicates the device is disabled, triggers | 60 // Sets up a device state blob that indicates the device is disabled, triggers |
58 // a policy plus device state fetch and waits for it to succeed. | 61 // a policy plus device state fetch and waits for it to succeed. |
59 void MarkDisabledAndWaitForPolicyFetch(); | 62 void MarkDisabledAndWaitForPolicyFetch(); |
60 | 63 |
61 std::string GetCurrentScreenName(content::WebContents* web_contents); | 64 std::string GetCurrentScreenName(content::WebContents* web_contents); |
62 | 65 |
63 protected: | 66 protected: |
64 base::RunLoop network_state_change_wait_run_loop_; | 67 base::RunLoop network_state_change_wait_run_loop_; |
65 | 68 |
66 private: | 69 private: |
67 // OobeBaseTest: | 70 // OobeBaseTest: |
68 void SetUpInProcessBrowserTestFixture() override; | 71 void SetUpInProcessBrowserTestFixture() override; |
69 void SetUpOnMainThread() override; | 72 void SetUpOnMainThread() override; |
70 | 73 |
71 // NetworkStateInformer::NetworkStateInformerObserver: | 74 // NetworkStateInformer::NetworkStateInformerObserver: |
72 void UpdateState(NetworkError::ErrorReason reason) override; | 75 void UpdateState(NetworkError::ErrorReason reason) override; |
73 | 76 |
74 FakeSessionManagerClient* fake_session_manager_client_; | 77 FakeSessionManagerClient* fake_session_manager_client_; |
75 policy::DevicePolicyCrosTestHelper test_helper_; | 78 policy::DevicePolicyCrosTestHelper test_helper_; |
76 | 79 |
77 DISALLOW_COPY_AND_ASSIGN(DeviceDisablingTest); | 80 DISALLOW_COPY_AND_ASSIGN(DeviceDisablingTest); |
78 }; | 81 }; |
79 | 82 |
80 | 83 |
81 DeviceDisablingTest::DeviceDisablingTest() | 84 DeviceDisablingTest::DeviceDisablingTest() |
82 : fake_session_manager_client_(new FakeSessionManagerClient) { | 85 : fake_session_manager_client_(new FakeSessionManagerClient) { |
| 86 set_use_webview(GetParam()); |
83 } | 87 } |
84 | 88 |
85 void DeviceDisablingTest::MarkDisabledAndWaitForPolicyFetch() { | 89 void DeviceDisablingTest::MarkDisabledAndWaitForPolicyFetch() { |
86 base::RunLoop run_loop; | 90 base::RunLoop run_loop; |
87 // Set up an |observer| that will wait for the disabled setting to change. | 91 // Set up an |observer| that will wait for the disabled setting to change. |
88 scoped_ptr<CrosSettings::ObserverSubscription> observer = | 92 scoped_ptr<CrosSettings::ObserverSubscription> observer = |
89 CrosSettings::Get()->AddSettingsObserver( | 93 CrosSettings::Get()->AddSettingsObserver( |
90 kDeviceDisabled, | 94 kDeviceDisabled, |
91 run_loop.QuitClosure()); | 95 run_loop.QuitClosure()); |
92 // Prepare a policy fetch response that indicates the device is disabled. | 96 // Prepare a policy fetch response that indicates the device is disabled. |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
128 | 132 |
129 // Set up fake networks. | 133 // Set up fake networks. |
130 DBusThreadManager::Get()->GetShillManagerClient()->GetTestInterface()-> | 134 DBusThreadManager::Get()->GetShillManagerClient()->GetTestInterface()-> |
131 SetupDefaultEnvironment(); | 135 SetupDefaultEnvironment(); |
132 } | 136 } |
133 | 137 |
134 void DeviceDisablingTest::UpdateState(NetworkError::ErrorReason reason) { | 138 void DeviceDisablingTest::UpdateState(NetworkError::ErrorReason reason) { |
135 network_state_change_wait_run_loop_.Quit(); | 139 network_state_change_wait_run_loop_.Quit(); |
136 } | 140 } |
137 | 141 |
138 | 142 IN_PROC_BROWSER_TEST_P(DeviceDisablingTest, DisableDuringNormalOperation) { |
139 IN_PROC_BROWSER_TEST_F(DeviceDisablingTest, DisableDuringNormalOperation) { | |
140 // Mark the device as disabled and wait until cros settings update. | 143 // Mark the device as disabled and wait until cros settings update. |
141 MarkDisabledAndWaitForPolicyFetch(); | 144 MarkDisabledAndWaitForPolicyFetch(); |
142 | 145 |
143 // Verify that the device disabled screen is being shown. | 146 // Verify that the device disabled screen is being shown. |
144 WizardController* const wizard_controller = | 147 WizardController* const wizard_controller = |
145 WizardController::default_controller(); | 148 WizardController::default_controller(); |
146 ASSERT_TRUE(wizard_controller); | 149 ASSERT_TRUE(wizard_controller); |
147 EXPECT_EQ(wizard_controller->GetScreen( | 150 EXPECT_EQ(wizard_controller->GetScreen( |
148 WizardController::kDeviceDisabledScreenName), | 151 WizardController::kDeviceDisabledScreenName), |
149 wizard_controller->current_screen()); | 152 wizard_controller->current_screen()); |
150 } | 153 } |
151 | 154 |
152 // Verifies that device disabling works when the ephemeral users policy is | 155 // Verifies that device disabling works when the ephemeral users policy is |
153 // enabled. This case warrants its own test because the UI behaves somewhat | 156 // enabled. This case warrants its own test because the UI behaves somewhat |
154 // differently when the policy is set: A background job runs on startup that | 157 // differently when the policy is set: A background job runs on startup that |
155 // causes the UI to try and show the login screen after some delay. It must | 158 // causes the UI to try and show the login screen after some delay. It must |
156 // be ensured that the login screen does not show and does not clobber the | 159 // be ensured that the login screen does not show and does not clobber the |
157 // disabled screen. | 160 // disabled screen. |
158 IN_PROC_BROWSER_TEST_F(DeviceDisablingTest, DisableWithEphemeralUsers) { | 161 IN_PROC_BROWSER_TEST_P(DeviceDisablingTest, DisableWithEphemeralUsers) { |
159 // Connect to the fake Ethernet network. This ensures that Chrome OS will not | 162 // Connect to the fake Ethernet network. This ensures that Chrome OS will not |
160 // try to show the offline error screen. | 163 // try to show the offline error screen. |
161 base::RunLoop connect_run_loop; | 164 base::RunLoop connect_run_loop; |
162 DBusThreadManager::Get()->GetShillServiceClient()->Connect( | 165 DBusThreadManager::Get()->GetShillServiceClient()->Connect( |
163 dbus::ObjectPath("/service/eth1"), | 166 dbus::ObjectPath("/service/eth1"), |
164 connect_run_loop.QuitClosure(), | 167 connect_run_loop.QuitClosure(), |
165 base::Bind(&ErrorCallbackFunction)); | 168 base::Bind(&ErrorCallbackFunction)); |
166 connect_run_loop.Run(); | 169 connect_run_loop.Run(); |
167 | 170 |
168 // Skip to the login screen. | 171 // Skip to the login screen. |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
212 SimulateNetworkOffline(); | 215 SimulateNetworkOffline(); |
213 network_state_change_wait_run_loop_.Run(); | 216 network_state_change_wait_run_loop_.Run(); |
214 network_state_informer->RemoveObserver(this); | 217 network_state_informer->RemoveObserver(this); |
215 base::RunLoop().RunUntilIdle(); | 218 base::RunLoop().RunUntilIdle(); |
216 | 219 |
217 // Verify that the offline error screen was not shown and the device disabled | 220 // Verify that the offline error screen was not shown and the device disabled |
218 // screen is still being shown instead. | 221 // screen is still being shown instead. |
219 EXPECT_EQ(OobeUI::kScreenDeviceDisabled, GetCurrentScreenName(web_contents)); | 222 EXPECT_EQ(OobeUI::kScreenDeviceDisabled, GetCurrentScreenName(web_contents)); |
220 } | 223 } |
221 | 224 |
| 225 INSTANTIATE_TEST_CASE_P(DeviceDisablingSuite, |
| 226 DeviceDisablingTest, |
| 227 testing::Bool()); |
| 228 |
222 } // namespace system | 229 } // namespace system |
223 } // namespace chromeos | 230 } // namespace chromeos |
OLD | NEW |