| 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 "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/login_manager_test.h" | 9 #include "chrome/browser/chromeos/login/login_manager_test.h" |
| 10 #include "chrome/browser/chromeos/login/startup_utils.h" | 10 #include "chrome/browser/chromeos/login/startup_utils.h" |
| (...skipping 15 matching lines...) Expand all Loading... |
| 26 // nothing and used to instantiate CaptivePortalWindowProxy. | 26 // nothing and used to instantiate CaptivePortalWindowProxy. |
| 27 class CaptivePortalWindowProxyStubDelegate | 27 class CaptivePortalWindowProxyStubDelegate |
| 28 : public CaptivePortalWindowProxyDelegate { | 28 : public CaptivePortalWindowProxyDelegate { |
| 29 public: | 29 public: |
| 30 CaptivePortalWindowProxyStubDelegate(): num_portal_notifications_(0) { | 30 CaptivePortalWindowProxyStubDelegate(): num_portal_notifications_(0) { |
| 31 } | 31 } |
| 32 | 32 |
| 33 virtual ~CaptivePortalWindowProxyStubDelegate() { | 33 virtual ~CaptivePortalWindowProxyStubDelegate() { |
| 34 } | 34 } |
| 35 | 35 |
| 36 virtual void OnPortalDetected() OVERRIDE { | 36 virtual void OnPortalDetected() override { |
| 37 ++num_portal_notifications_; | 37 ++num_portal_notifications_; |
| 38 } | 38 } |
| 39 | 39 |
| 40 int num_portal_notifications() const { return num_portal_notifications_; } | 40 int num_portal_notifications() const { return num_portal_notifications_; } |
| 41 | 41 |
| 42 private: | 42 private: |
| 43 int num_portal_notifications_; | 43 int num_portal_notifications_; |
| 44 }; | 44 }; |
| 45 | 45 |
| 46 } // namespace | 46 } // namespace |
| (...skipping 20 matching lines...) Expand all Loading... |
| 67 captive_portal_window_proxy_->OnOriginalURLLoaded(); | 67 captive_portal_window_proxy_->OnOriginalURLLoaded(); |
| 68 } | 68 } |
| 69 | 69 |
| 70 void CheckState(bool is_shown, int num_portal_notifications) { | 70 void CheckState(bool is_shown, int num_portal_notifications) { |
| 71 bool actual_is_shown = (CaptivePortalWindowProxy::STATE_DISPLAYED == | 71 bool actual_is_shown = (CaptivePortalWindowProxy::STATE_DISPLAYED == |
| 72 captive_portal_window_proxy_->GetState()); | 72 captive_portal_window_proxy_->GetState()); |
| 73 ASSERT_EQ(is_shown, actual_is_shown); | 73 ASSERT_EQ(is_shown, actual_is_shown); |
| 74 ASSERT_EQ(num_portal_notifications, delegate_.num_portal_notifications()); | 74 ASSERT_EQ(num_portal_notifications, delegate_.num_portal_notifications()); |
| 75 } | 75 } |
| 76 | 76 |
| 77 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE { | 77 virtual void SetUpCommandLine(CommandLine* command_line) override { |
| 78 command_line->AppendSwitch(chromeos::switches::kForceLoginManagerInTests); | 78 command_line->AppendSwitch(chromeos::switches::kForceLoginManagerInTests); |
| 79 command_line->AppendSwitch(chromeos::switches::kLoginManager); | 79 command_line->AppendSwitch(chromeos::switches::kLoginManager); |
| 80 } | 80 } |
| 81 | 81 |
| 82 virtual void SetUpOnMainThread() OVERRIDE { | 82 virtual void SetUpOnMainThread() override { |
| 83 host_ = LoginDisplayHostImpl::default_host(); | 83 host_ = LoginDisplayHostImpl::default_host(); |
| 84 CHECK(host_); | 84 CHECK(host_); |
| 85 content::WebContents* web_contents = | 85 content::WebContents* web_contents = |
| 86 LoginDisplayHostImpl::default_host()->GetWebUILoginView()-> | 86 LoginDisplayHostImpl::default_host()->GetWebUILoginView()-> |
| 87 GetWebContents(); | 87 GetWebContents(); |
| 88 captive_portal_window_proxy_.reset( | 88 captive_portal_window_proxy_.reset( |
| 89 new CaptivePortalWindowProxy(&delegate_, web_contents)); | 89 new CaptivePortalWindowProxy(&delegate_, web_contents)); |
| 90 } | 90 } |
| 91 | 91 |
| 92 virtual void TearDownOnMainThread() OVERRIDE { | 92 virtual void TearDownOnMainThread() override { |
| 93 captive_portal_window_proxy_.reset(); | 93 captive_portal_window_proxy_.reset(); |
| 94 base::MessageLoopForUI::current()->DeleteSoon(FROM_HERE, host_); | 94 base::MessageLoopForUI::current()->DeleteSoon(FROM_HERE, host_); |
| 95 base::MessageLoopForUI::current()->RunUntilIdle(); | 95 base::MessageLoopForUI::current()->RunUntilIdle(); |
| 96 } | 96 } |
| 97 | 97 |
| 98 private: | 98 private: |
| 99 scoped_ptr<CaptivePortalWindowProxy> captive_portal_window_proxy_; | 99 scoped_ptr<CaptivePortalWindowProxy> captive_portal_window_proxy_; |
| 100 CaptivePortalWindowProxyStubDelegate delegate_; | 100 CaptivePortalWindowProxyStubDelegate delegate_; |
| 101 | 101 |
| 102 LoginDisplayHost* host_; | 102 LoginDisplayHost* host_; |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 172 OnOriginalURLLoaded(); | 172 OnOriginalURLLoaded(); |
| 173 CheckState(false, 2); | 173 CheckState(false, 2); |
| 174 } | 174 } |
| 175 | 175 |
| 176 class CaptivePortalWindowCtorDtorTest : public LoginManagerTest { | 176 class CaptivePortalWindowCtorDtorTest : public LoginManagerTest { |
| 177 public: | 177 public: |
| 178 CaptivePortalWindowCtorDtorTest() | 178 CaptivePortalWindowCtorDtorTest() |
| 179 : LoginManagerTest(false) {} | 179 : LoginManagerTest(false) {} |
| 180 virtual ~CaptivePortalWindowCtorDtorTest() {} | 180 virtual ~CaptivePortalWindowCtorDtorTest() {} |
| 181 | 181 |
| 182 virtual void SetUpInProcessBrowserTestFixture() OVERRIDE { | 182 virtual void SetUpInProcessBrowserTestFixture() override { |
| 183 LoginManagerTest::SetUpInProcessBrowserTestFixture(); | 183 LoginManagerTest::SetUpInProcessBrowserTestFixture(); |
| 184 | 184 |
| 185 network_portal_detector_ = new NetworkPortalDetectorTestImpl(); | 185 network_portal_detector_ = new NetworkPortalDetectorTestImpl(); |
| 186 NetworkPortalDetector::InitializeForTesting(network_portal_detector_); | 186 NetworkPortalDetector::InitializeForTesting(network_portal_detector_); |
| 187 NetworkPortalDetector::CaptivePortalState portal_state; | 187 NetworkPortalDetector::CaptivePortalState portal_state; |
| 188 portal_state.status = NetworkPortalDetector::CAPTIVE_PORTAL_STATUS_PORTAL; | 188 portal_state.status = NetworkPortalDetector::CAPTIVE_PORTAL_STATUS_PORTAL; |
| 189 portal_state.response_code = 200; | 189 portal_state.response_code = 200; |
| 190 network_portal_detector_->SetDefaultNetworkForTesting( | 190 network_portal_detector_->SetDefaultNetworkForTesting( |
| 191 FakeShillManagerClient::kFakeEthernetNetworkGuid); | 191 FakeShillManagerClient::kFakeEthernetNetworkGuid); |
| 192 network_portal_detector_->SetDetectionResultsForTesting( | 192 network_portal_detector_->SetDetectionResultsForTesting( |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 227 | 227 |
| 228 ASSERT_EQ(PortalDetectorStrategy::STRATEGY_ID_LOGIN_SCREEN, strategy_id()); | 228 ASSERT_EQ(PortalDetectorStrategy::STRATEGY_ID_LOGIN_SCREEN, strategy_id()); |
| 229 network_portal_detector()->NotifyObserversForTesting(); | 229 network_portal_detector()->NotifyObserversForTesting(); |
| 230 OobeScreenWaiter(OobeDisplay::SCREEN_ERROR_MESSAGE).Wait(); | 230 OobeScreenWaiter(OobeDisplay::SCREEN_ERROR_MESSAGE).Wait(); |
| 231 ASSERT_EQ(PortalDetectorStrategy::STRATEGY_ID_ERROR_SCREEN, strategy_id()); | 231 ASSERT_EQ(PortalDetectorStrategy::STRATEGY_ID_ERROR_SCREEN, strategy_id()); |
| 232 | 232 |
| 233 actor->ShowCaptivePortal(); | 233 actor->ShowCaptivePortal(); |
| 234 } | 234 } |
| 235 | 235 |
| 236 } // namespace chromeos | 236 } // namespace chromeos |
| OLD | NEW |