| 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 12 matching lines...) Expand all Loading... |
| 23 namespace { | 23 namespace { |
| 24 | 24 |
| 25 // Stub implementation of CaptivePortalWindowProxyDelegate, does | 25 // Stub implementation of CaptivePortalWindowProxyDelegate, does |
| 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 ~CaptivePortalWindowProxyStubDelegate() override {} |
| 34 } | |
| 35 | 34 |
| 36 virtual void OnPortalDetected() override { | 35 void OnPortalDetected() override { ++num_portal_notifications_; } |
| 37 ++num_portal_notifications_; | |
| 38 } | |
| 39 | 36 |
| 40 int num_portal_notifications() const { return num_portal_notifications_; } | 37 int num_portal_notifications() const { return num_portal_notifications_; } |
| 41 | 38 |
| 42 private: | 39 private: |
| 43 int num_portal_notifications_; | 40 int num_portal_notifications_; |
| 44 }; | 41 }; |
| 45 | 42 |
| 46 } // namespace | 43 } // namespace |
| 47 | 44 |
| 48 class CaptivePortalWindowTest : public InProcessBrowserTest { | 45 class CaptivePortalWindowTest : public InProcessBrowserTest { |
| (...skipping 18 matching lines...) Expand all Loading... |
| 67 captive_portal_window_proxy_->OnOriginalURLLoaded(); | 64 captive_portal_window_proxy_->OnOriginalURLLoaded(); |
| 68 } | 65 } |
| 69 | 66 |
| 70 void CheckState(bool is_shown, int num_portal_notifications) { | 67 void CheckState(bool is_shown, int num_portal_notifications) { |
| 71 bool actual_is_shown = (CaptivePortalWindowProxy::STATE_DISPLAYED == | 68 bool actual_is_shown = (CaptivePortalWindowProxy::STATE_DISPLAYED == |
| 72 captive_portal_window_proxy_->GetState()); | 69 captive_portal_window_proxy_->GetState()); |
| 73 ASSERT_EQ(is_shown, actual_is_shown); | 70 ASSERT_EQ(is_shown, actual_is_shown); |
| 74 ASSERT_EQ(num_portal_notifications, delegate_.num_portal_notifications()); | 71 ASSERT_EQ(num_portal_notifications, delegate_.num_portal_notifications()); |
| 75 } | 72 } |
| 76 | 73 |
| 77 virtual void SetUpCommandLine(base::CommandLine* command_line) override { | 74 void SetUpCommandLine(base::CommandLine* command_line) override { |
| 78 command_line->AppendSwitch(chromeos::switches::kForceLoginManagerInTests); | 75 command_line->AppendSwitch(chromeos::switches::kForceLoginManagerInTests); |
| 79 command_line->AppendSwitch(chromeos::switches::kLoginManager); | 76 command_line->AppendSwitch(chromeos::switches::kLoginManager); |
| 80 } | 77 } |
| 81 | 78 |
| 82 virtual void SetUpOnMainThread() override { | 79 void SetUpOnMainThread() override { |
| 83 host_ = LoginDisplayHostImpl::default_host(); | 80 host_ = LoginDisplayHostImpl::default_host(); |
| 84 CHECK(host_); | 81 CHECK(host_); |
| 85 content::WebContents* web_contents = | 82 content::WebContents* web_contents = |
| 86 LoginDisplayHostImpl::default_host()->GetWebUILoginView()-> | 83 LoginDisplayHostImpl::default_host()->GetWebUILoginView()-> |
| 87 GetWebContents(); | 84 GetWebContents(); |
| 88 captive_portal_window_proxy_.reset( | 85 captive_portal_window_proxy_.reset( |
| 89 new CaptivePortalWindowProxy(&delegate_, web_contents)); | 86 new CaptivePortalWindowProxy(&delegate_, web_contents)); |
| 90 } | 87 } |
| 91 | 88 |
| 92 virtual void TearDownOnMainThread() override { | 89 void TearDownOnMainThread() override { |
| 93 captive_portal_window_proxy_.reset(); | 90 captive_portal_window_proxy_.reset(); |
| 94 base::MessageLoopForUI::current()->DeleteSoon(FROM_HERE, host_); | 91 base::MessageLoopForUI::current()->DeleteSoon(FROM_HERE, host_); |
| 95 base::MessageLoopForUI::current()->RunUntilIdle(); | 92 base::MessageLoopForUI::current()->RunUntilIdle(); |
| 96 } | 93 } |
| 97 | 94 |
| 98 private: | 95 private: |
| 99 scoped_ptr<CaptivePortalWindowProxy> captive_portal_window_proxy_; | 96 scoped_ptr<CaptivePortalWindowProxy> captive_portal_window_proxy_; |
| 100 CaptivePortalWindowProxyStubDelegate delegate_; | 97 CaptivePortalWindowProxyStubDelegate delegate_; |
| 101 | 98 |
| 102 LoginDisplayHost* host_; | 99 LoginDisplayHost* host_; |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 170 CheckState(false, 2); | 167 CheckState(false, 2); |
| 171 | 168 |
| 172 OnOriginalURLLoaded(); | 169 OnOriginalURLLoaded(); |
| 173 CheckState(false, 2); | 170 CheckState(false, 2); |
| 174 } | 171 } |
| 175 | 172 |
| 176 class CaptivePortalWindowCtorDtorTest : public LoginManagerTest { | 173 class CaptivePortalWindowCtorDtorTest : public LoginManagerTest { |
| 177 public: | 174 public: |
| 178 CaptivePortalWindowCtorDtorTest() | 175 CaptivePortalWindowCtorDtorTest() |
| 179 : LoginManagerTest(false) {} | 176 : LoginManagerTest(false) {} |
| 180 virtual ~CaptivePortalWindowCtorDtorTest() {} | 177 ~CaptivePortalWindowCtorDtorTest() override {} |
| 181 | 178 |
| 182 virtual void SetUpInProcessBrowserTestFixture() override { | 179 void SetUpInProcessBrowserTestFixture() override { |
| 183 LoginManagerTest::SetUpInProcessBrowserTestFixture(); | 180 LoginManagerTest::SetUpInProcessBrowserTestFixture(); |
| 184 | 181 |
| 185 network_portal_detector_ = new NetworkPortalDetectorTestImpl(); | 182 network_portal_detector_ = new NetworkPortalDetectorTestImpl(); |
| 186 NetworkPortalDetector::InitializeForTesting(network_portal_detector_); | 183 NetworkPortalDetector::InitializeForTesting(network_portal_detector_); |
| 187 NetworkPortalDetector::CaptivePortalState portal_state; | 184 NetworkPortalDetector::CaptivePortalState portal_state; |
| 188 portal_state.status = NetworkPortalDetector::CAPTIVE_PORTAL_STATUS_PORTAL; | 185 portal_state.status = NetworkPortalDetector::CAPTIVE_PORTAL_STATUS_PORTAL; |
| 189 portal_state.response_code = 200; | 186 portal_state.response_code = 200; |
| 190 network_portal_detector_->SetDefaultNetworkForTesting( | 187 network_portal_detector_->SetDefaultNetworkForTesting( |
| 191 FakeShillManagerClient::kFakeEthernetNetworkGuid); | 188 FakeShillManagerClient::kFakeEthernetNetworkGuid); |
| 192 network_portal_detector_->SetDetectionResultsForTesting( | 189 network_portal_detector_->SetDetectionResultsForTesting( |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 227 | 224 |
| 228 ASSERT_EQ(PortalDetectorStrategy::STRATEGY_ID_LOGIN_SCREEN, strategy_id()); | 225 ASSERT_EQ(PortalDetectorStrategy::STRATEGY_ID_LOGIN_SCREEN, strategy_id()); |
| 229 network_portal_detector()->NotifyObserversForTesting(); | 226 network_portal_detector()->NotifyObserversForTesting(); |
| 230 OobeScreenWaiter(OobeDisplay::SCREEN_ERROR_MESSAGE).Wait(); | 227 OobeScreenWaiter(OobeDisplay::SCREEN_ERROR_MESSAGE).Wait(); |
| 231 ASSERT_EQ(PortalDetectorStrategy::STRATEGY_ID_ERROR_SCREEN, strategy_id()); | 228 ASSERT_EQ(PortalDetectorStrategy::STRATEGY_ID_ERROR_SCREEN, strategy_id()); |
| 232 | 229 |
| 233 actor->ShowCaptivePortal(); | 230 actor->ShowCaptivePortal(); |
| 234 } | 231 } |
| 235 | 232 |
| 236 } // namespace chromeos | 233 } // namespace chromeos |
| OLD | NEW |