OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/compiler_specific.h" | 6 #include "base/compiler_specific.h" |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "base/memory/scoped_ptr.h" | 8 #include "base/memory/scoped_ptr.h" |
9 #include "chrome/browser/chromeos/login/captive_portal_window_proxy.h" | 9 #include "chrome/browser/chromeos/login/captive_portal_window_proxy.h" |
10 #include "chrome/browser/chromeos/login/login_display_host_impl.h" | 10 #include "chrome/browser/chromeos/login/login_display_host_impl.h" |
| 11 #include "chrome/browser/chromeos/login/login_manager_test.h" |
| 12 #include "chrome/browser/chromeos/login/startup_utils.h" |
| 13 #include "chrome/browser/chromeos/login/test/oobe_screen_waiter.h" |
11 #include "chrome/browser/chromeos/login/webui_login_view.h" | 14 #include "chrome/browser/chromeos/login/webui_login_view.h" |
| 15 #include "chrome/browser/chromeos/net/network_portal_detector.h" |
| 16 #include "chrome/browser/chromeos/net/network_portal_detector_test_impl.h" |
12 #include "chrome/test/base/in_process_browser_test.h" | 17 #include "chrome/test/base/in_process_browser_test.h" |
13 #include "chromeos/chromeos_switches.h" | 18 #include "chromeos/chromeos_switches.h" |
14 | 19 |
15 namespace chromeos { | 20 namespace chromeos { |
16 | 21 |
17 namespace { | 22 namespace { |
18 | 23 |
| 24 const char kStubEthernetServicePath[] = "eth1"; |
| 25 |
19 // Stub implementation of CaptivePortalWindowProxyDelegate, does | 26 // Stub implementation of CaptivePortalWindowProxyDelegate, does |
20 // nothing and used to instantiate CaptivePortalWindowProxy. | 27 // nothing and used to instantiate CaptivePortalWindowProxy. |
21 class CaptivePortalWindowProxyStubDelegate | 28 class CaptivePortalWindowProxyStubDelegate |
22 : public CaptivePortalWindowProxyDelegate { | 29 : public CaptivePortalWindowProxyDelegate { |
23 public: | 30 public: |
24 CaptivePortalWindowProxyStubDelegate(): num_portal_notifications_(0) { | 31 CaptivePortalWindowProxyStubDelegate(): num_portal_notifications_(0) { |
25 } | 32 } |
26 | 33 |
27 virtual ~CaptivePortalWindowProxyStubDelegate() { | 34 virtual ~CaptivePortalWindowProxyStubDelegate() { |
28 } | 35 } |
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
160 OnRedirected(); | 167 OnRedirected(); |
161 CheckState(true, 2); | 168 CheckState(true, 2); |
162 | 169 |
163 Close(); | 170 Close(); |
164 CheckState(false, 2); | 171 CheckState(false, 2); |
165 | 172 |
166 OnOriginalURLLoaded(); | 173 OnOriginalURLLoaded(); |
167 CheckState(false, 2); | 174 CheckState(false, 2); |
168 } | 175 } |
169 | 176 |
| 177 class CaptivePortalWindowCtorDtorTest : public LoginManagerTest { |
| 178 public: |
| 179 CaptivePortalWindowCtorDtorTest() |
| 180 : LoginManagerTest(false) {} |
| 181 virtual ~CaptivePortalWindowCtorDtorTest() {} |
| 182 |
| 183 virtual void SetUpInProcessBrowserTestFixture() OVERRIDE { |
| 184 LoginManagerTest::SetUpInProcessBrowserTestFixture(); |
| 185 |
| 186 network_portal_detector_ = new NetworkPortalDetectorTestImpl(); |
| 187 NetworkPortalDetector::InitializeForTesting(network_portal_detector_); |
| 188 NetworkPortalDetector::CaptivePortalState portal_state; |
| 189 portal_state.status = NetworkPortalDetector::CAPTIVE_PORTAL_STATUS_PORTAL; |
| 190 portal_state.response_code = 200; |
| 191 network_portal_detector_->SetDefaultNetworkPathForTesting( |
| 192 kStubEthernetServicePath); |
| 193 network_portal_detector_->SetDetectionResultsForTesting( |
| 194 kStubEthernetServicePath, portal_state); |
| 195 } |
| 196 |
| 197 protected: |
| 198 NetworkPortalDetectorTestImpl* network_portal_detector() { |
| 199 return network_portal_detector_; |
| 200 } |
| 201 |
| 202 private: |
| 203 NetworkPortalDetectorTestImpl* network_portal_detector_; |
| 204 |
| 205 DISALLOW_COPY_AND_ASSIGN(CaptivePortalWindowCtorDtorTest); |
| 206 }; |
| 207 |
| 208 IN_PROC_BROWSER_TEST_F(CaptivePortalWindowCtorDtorTest, PRE_OpenPortalDialog) { |
| 209 StartupUtils::MarkOobeCompleted(); |
| 210 } |
| 211 |
| 212 IN_PROC_BROWSER_TEST_F(CaptivePortalWindowCtorDtorTest, OpenPortalDialog) { |
| 213 network_portal_detector()->NotifyObserversForTesting(); |
| 214 OobeScreenWaiter(OobeDisplay::SCREEN_ERROR_MESSAGE).Wait(); |
| 215 LoginDisplayHostImpl* host = |
| 216 static_cast<LoginDisplayHostImpl*>(LoginDisplayHostImpl::default_host()); |
| 217 |
| 218 ASSERT_TRUE(host); |
| 219 OobeUI* oobe = host->GetOobeUI(); |
| 220 ASSERT_TRUE(oobe); |
| 221 ErrorScreenActor* actor = oobe->GetErrorScreenActor(); |
| 222 ASSERT_TRUE(actor); |
| 223 actor->ShowCaptivePortal(); |
| 224 } |
| 225 |
170 } // namespace chromeos | 226 } // namespace chromeos |
OLD | NEW |