| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/memory/scoped_ptr.h" | 6 #include "base/memory/scoped_ptr.h" |
| 7 #include "chrome/browser/chromeos/login/screens/mock_error_screen.h" | 7 #include "chrome/browser/chromeos/login/screens/mock_error_screen.h" |
| 8 #include "chrome/browser/chromeos/login/screens/mock_screen_observer.h" | 8 #include "chrome/browser/chromeos/login/screens/mock_screen_observer.h" |
| 9 #include "chrome/browser/chromeos/login/screens/update_screen.h" | 9 #include "chrome/browser/chromeos/login/screens/update_screen.h" |
| 10 #include "chrome/browser/chromeos/login/wizard_controller.h" | 10 #include "chrome/browser/chromeos/login/wizard_controller.h" |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 51 | 51 |
| 52 DBusThreadManager::SetInstanceForTesting(fake_dbus_thread_manager); | 52 DBusThreadManager::SetInstanceForTesting(fake_dbus_thread_manager); |
| 53 WizardInProcessBrowserTest::SetUpInProcessBrowserTestFixture(); | 53 WizardInProcessBrowserTest::SetUpInProcessBrowserTestFixture(); |
| 54 | 54 |
| 55 // Setup network portal detector to return online state for both | 55 // Setup network portal detector to return online state for both |
| 56 // ethernet and wifi networks. Ethernet is an active network by | 56 // ethernet and wifi networks. Ethernet is an active network by |
| 57 // default. | 57 // default. |
| 58 network_portal_detector_ = new NetworkPortalDetectorTestImpl(); | 58 network_portal_detector_ = new NetworkPortalDetectorTestImpl(); |
| 59 NetworkPortalDetector::InitializeForTesting(network_portal_detector_); | 59 NetworkPortalDetector::InitializeForTesting(network_portal_detector_); |
| 60 NetworkPortalDetector::CaptivePortalState online_state; | 60 NetworkPortalDetector::CaptivePortalState online_state; |
| 61 online_state.status = NetworkPortalDetector::CAPTIVE_PORTAL_STATUS_ONLINE; | 61 online_state.status = captive_portal::CAPTIVE_PORTAL_STATUS_ONLINE; |
| 62 online_state.response_code = 204; | 62 online_state.response_code = 204; |
| 63 SetDefaultNetworkPath(kStubEthernetServicePath); | 63 SetDefaultNetworkPath(kStubEthernetServicePath); |
| 64 SetDetectionResults(kStubEthernetServicePath, online_state); | 64 SetDetectionResults(kStubEthernetServicePath, online_state); |
| 65 SetDetectionResults(kStubWifiServicePath, online_state); | 65 SetDetectionResults(kStubWifiServicePath, online_state); |
| 66 } | 66 } |
| 67 | 67 |
| 68 virtual void SetUpOnMainThread() OVERRIDE { | 68 virtual void SetUpOnMainThread() OVERRIDE { |
| 69 WizardInProcessBrowserTest::SetUpOnMainThread(); | 69 WizardInProcessBrowserTest::SetUpOnMainThread(); |
| 70 | 70 |
| 71 mock_screen_observer_.reset(new MockScreenObserver()); | 71 mock_screen_observer_.reset(new MockScreenObserver()); |
| (...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 229 } | 229 } |
| 230 | 230 |
| 231 IN_PROC_BROWSER_TEST_F(UpdateScreenTest, TestTemproraryOfflineNetwork) { | 231 IN_PROC_BROWSER_TEST_F(UpdateScreenTest, TestTemproraryOfflineNetwork) { |
| 232 EXPECT_CALL(*mock_screen_observer_, | 232 EXPECT_CALL(*mock_screen_observer_, |
| 233 OnExit(ScreenObserver::UPDATE_NOUPDATE)) | 233 OnExit(ScreenObserver::UPDATE_NOUPDATE)) |
| 234 .Times(1); | 234 .Times(1); |
| 235 update_screen_->CancelUpdate(); | 235 update_screen_->CancelUpdate(); |
| 236 | 236 |
| 237 // Change ethernet state to portal. | 237 // Change ethernet state to portal. |
| 238 NetworkPortalDetector::CaptivePortalState portal_state; | 238 NetworkPortalDetector::CaptivePortalState portal_state; |
| 239 portal_state.status = NetworkPortalDetector::CAPTIVE_PORTAL_STATUS_PORTAL; | 239 portal_state.status = captive_portal::CAPTIVE_PORTAL_STATUS_PORTAL; |
| 240 portal_state.response_code = 200; | 240 portal_state.response_code = 200; |
| 241 SetDetectionResults(kStubEthernetServicePath, portal_state); | 241 SetDetectionResults(kStubEthernetServicePath, portal_state); |
| 242 | 242 |
| 243 // Update screen will show error message about portal state because | 243 // Update screen will show error message about portal state because |
| 244 // ethernet is behind captive portal. | 244 // ethernet is behind captive portal. |
| 245 EXPECT_CALL(*mock_error_screen_actor_, | 245 EXPECT_CALL(*mock_error_screen_actor_, |
| 246 SetUIState(ErrorScreen::UI_STATE_UPDATE)) | 246 SetUIState(ErrorScreen::UI_STATE_UPDATE)) |
| 247 .Times(1); | 247 .Times(1); |
| 248 EXPECT_CALL(*mock_error_screen_actor_, | 248 EXPECT_CALL(*mock_error_screen_actor_, |
| 249 SetErrorState(ErrorScreen::ERROR_STATE_PORTAL, std::string())) | 249 SetErrorState(ErrorScreen::ERROR_STATE_PORTAL, std::string())) |
| 250 .Times(1); | 250 .Times(1); |
| 251 EXPECT_CALL(*mock_error_screen_actor_, FixCaptivePortal()) | 251 EXPECT_CALL(*mock_error_screen_actor_, FixCaptivePortal()) |
| 252 .Times(1); | 252 .Times(1); |
| 253 EXPECT_CALL(*mock_screen_observer_, ShowErrorScreen()) | 253 EXPECT_CALL(*mock_screen_observer_, ShowErrorScreen()) |
| 254 .Times(1); | 254 .Times(1); |
| 255 | 255 |
| 256 update_screen_->StartNetworkCheck(); | 256 update_screen_->StartNetworkCheck(); |
| 257 | 257 |
| 258 NetworkPortalDetector::CaptivePortalState online_state; | 258 NetworkPortalDetector::CaptivePortalState online_state; |
| 259 online_state.status = NetworkPortalDetector::CAPTIVE_PORTAL_STATUS_ONLINE; | 259 online_state.status = captive_portal::CAPTIVE_PORTAL_STATUS_ONLINE; |
| 260 online_state.response_code = 204; | 260 online_state.response_code = 204; |
| 261 SetDetectionResults(kStubEthernetServicePath, online_state); | 261 SetDetectionResults(kStubEthernetServicePath, online_state); |
| 262 | 262 |
| 263 // Second notification from portal detector will be about online state, | 263 // Second notification from portal detector will be about online state, |
| 264 // so update screen will hide error message and proceed to update. | 264 // so update screen will hide error message and proceed to update. |
| 265 EXPECT_CALL(*mock_screen_observer_, HideErrorScreen(update_screen_)) | 265 EXPECT_CALL(*mock_screen_observer_, HideErrorScreen(update_screen_)) |
| 266 .Times(1); | 266 .Times(1); |
| 267 fake_update_engine_client_->set_update_check_result( | 267 fake_update_engine_client_->set_update_check_result( |
| 268 chromeos::UpdateEngineClient::UPDATE_RESULT_FAILED); | 268 chromeos::UpdateEngineClient::UPDATE_RESULT_FAILED); |
| 269 | 269 |
| 270 EXPECT_CALL(*mock_screen_observer_, | 270 EXPECT_CALL(*mock_screen_observer_, |
| 271 OnExit(ScreenObserver::UPDATE_ERROR_CHECKING_FOR_UPDATE)) | 271 OnExit(ScreenObserver::UPDATE_ERROR_CHECKING_FOR_UPDATE)) |
| 272 .Times(1); | 272 .Times(1); |
| 273 | 273 |
| 274 NotifyPortalDetectionCompleted(); | 274 NotifyPortalDetectionCompleted(); |
| 275 } | 275 } |
| 276 | 276 |
| 277 IN_PROC_BROWSER_TEST_F(UpdateScreenTest, TestTwoOfflineNetworks) { | 277 IN_PROC_BROWSER_TEST_F(UpdateScreenTest, TestTwoOfflineNetworks) { |
| 278 EXPECT_CALL(*mock_screen_observer_, | 278 EXPECT_CALL(*mock_screen_observer_, |
| 279 OnExit(ScreenObserver::UPDATE_NOUPDATE)) | 279 OnExit(ScreenObserver::UPDATE_NOUPDATE)) |
| 280 .Times(1); | 280 .Times(1); |
| 281 update_screen_->CancelUpdate(); | 281 update_screen_->CancelUpdate(); |
| 282 | 282 |
| 283 // Change ethernet state to portal. | 283 // Change ethernet state to portal. |
| 284 NetworkPortalDetector::CaptivePortalState portal_state; | 284 NetworkPortalDetector::CaptivePortalState portal_state; |
| 285 portal_state.status = NetworkPortalDetector::CAPTIVE_PORTAL_STATUS_PORTAL; | 285 portal_state.status = captive_portal::CAPTIVE_PORTAL_STATUS_PORTAL; |
| 286 portal_state.response_code = 200; | 286 portal_state.response_code = 200; |
| 287 SetDetectionResults(kStubEthernetServicePath, portal_state); | 287 SetDetectionResults(kStubEthernetServicePath, portal_state); |
| 288 | 288 |
| 289 // Update screen will show error message about portal state because | 289 // Update screen will show error message about portal state because |
| 290 // ethernet is behind captive portal. | 290 // ethernet is behind captive portal. |
| 291 EXPECT_CALL(*mock_error_screen_actor_, | 291 EXPECT_CALL(*mock_error_screen_actor_, |
| 292 SetUIState(ErrorScreen::UI_STATE_UPDATE)) | 292 SetUIState(ErrorScreen::UI_STATE_UPDATE)) |
| 293 .Times(1); | 293 .Times(1); |
| 294 EXPECT_CALL(*mock_error_screen_actor_, | 294 EXPECT_CALL(*mock_error_screen_actor_, |
| 295 SetErrorState(ErrorScreen::ERROR_STATE_PORTAL, std::string())) | 295 SetErrorState(ErrorScreen::ERROR_STATE_PORTAL, std::string())) |
| 296 .Times(1); | 296 .Times(1); |
| 297 EXPECT_CALL(*mock_error_screen_actor_, FixCaptivePortal()) | 297 EXPECT_CALL(*mock_error_screen_actor_, FixCaptivePortal()) |
| 298 .Times(1); | 298 .Times(1); |
| 299 EXPECT_CALL(*mock_screen_observer_, ShowErrorScreen()) | 299 EXPECT_CALL(*mock_screen_observer_, ShowErrorScreen()) |
| 300 .Times(1); | 300 .Times(1); |
| 301 | 301 |
| 302 update_screen_->StartNetworkCheck(); | 302 update_screen_->StartNetworkCheck(); |
| 303 | 303 |
| 304 // Change active network to the wifi behind proxy. | 304 // Change active network to the wifi behind proxy. |
| 305 NetworkPortalDetector::CaptivePortalState proxy_state; | 305 NetworkPortalDetector::CaptivePortalState proxy_state; |
| 306 proxy_state.status = | 306 proxy_state.status = |
| 307 NetworkPortalDetector::CAPTIVE_PORTAL_STATUS_PROXY_AUTH_REQUIRED; | 307 captive_portal::CAPTIVE_PORTAL_STATUS_PROXY_AUTH_REQUIRED; |
| 308 proxy_state.response_code = -1; | 308 proxy_state.response_code = -1; |
| 309 SetDefaultNetworkPath(kStubWifiServicePath); | 309 SetDefaultNetworkPath(kStubWifiServicePath); |
| 310 SetDetectionResults(kStubWifiServicePath, proxy_state); | 310 SetDetectionResults(kStubWifiServicePath, proxy_state); |
| 311 | 311 |
| 312 // Update screen will show message about proxy error because wifie | 312 // Update screen will show message about proxy error because wifie |
| 313 // network requires proxy authentication. | 313 // network requires proxy authentication. |
| 314 EXPECT_CALL(*mock_error_screen_actor_, | 314 EXPECT_CALL(*mock_error_screen_actor_, |
| 315 SetErrorState(ErrorScreen::ERROR_STATE_PROXY, std::string())) | 315 SetErrorState(ErrorScreen::ERROR_STATE_PROXY, std::string())) |
| 316 .Times(1); | 316 .Times(1); |
| 317 | 317 |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 354 } | 354 } |
| 355 | 355 |
| 356 IN_PROC_BROWSER_TEST_F(UpdateScreenTest, TestAPReselection) { | 356 IN_PROC_BROWSER_TEST_F(UpdateScreenTest, TestAPReselection) { |
| 357 EXPECT_CALL(*mock_screen_observer_, | 357 EXPECT_CALL(*mock_screen_observer_, |
| 358 OnExit(ScreenObserver::UPDATE_NOUPDATE)) | 358 OnExit(ScreenObserver::UPDATE_NOUPDATE)) |
| 359 .Times(1); | 359 .Times(1); |
| 360 update_screen_->CancelUpdate(); | 360 update_screen_->CancelUpdate(); |
| 361 | 361 |
| 362 // Change ethernet state to portal. | 362 // Change ethernet state to portal. |
| 363 NetworkPortalDetector::CaptivePortalState portal_state; | 363 NetworkPortalDetector::CaptivePortalState portal_state; |
| 364 portal_state.status = NetworkPortalDetector::CAPTIVE_PORTAL_STATUS_PORTAL; | 364 portal_state.status = captive_portal::CAPTIVE_PORTAL_STATUS_PORTAL; |
| 365 portal_state.response_code = 200; | 365 portal_state.response_code = 200; |
| 366 SetDetectionResults(kStubEthernetServicePath, portal_state); | 366 SetDetectionResults(kStubEthernetServicePath, portal_state); |
| 367 | 367 |
| 368 // Update screen will show error message about portal state because | 368 // Update screen will show error message about portal state because |
| 369 // ethernet is behind captive portal. | 369 // ethernet is behind captive portal. |
| 370 EXPECT_CALL(*mock_error_screen_actor_, | 370 EXPECT_CALL(*mock_error_screen_actor_, |
| 371 SetUIState(ErrorScreen::UI_STATE_UPDATE)) | 371 SetUIState(ErrorScreen::UI_STATE_UPDATE)) |
| 372 .Times(1); | 372 .Times(1); |
| 373 EXPECT_CALL(*mock_error_screen_actor_, | 373 EXPECT_CALL(*mock_error_screen_actor_, |
| 374 SetErrorState(ErrorScreen::ERROR_STATE_PORTAL, std::string())) | 374 SetErrorState(ErrorScreen::ERROR_STATE_PORTAL, std::string())) |
| (...skipping 14 matching lines...) Expand all Loading... |
| 389 chromeos::UpdateEngineClient::UPDATE_RESULT_FAILED); | 389 chromeos::UpdateEngineClient::UPDATE_RESULT_FAILED); |
| 390 EXPECT_CALL(*mock_screen_observer_, | 390 EXPECT_CALL(*mock_screen_observer_, |
| 391 OnExit(ScreenObserver::UPDATE_ERROR_CHECKING_FOR_UPDATE)) | 391 OnExit(ScreenObserver::UPDATE_ERROR_CHECKING_FOR_UPDATE)) |
| 392 .Times(1); | 392 .Times(1); |
| 393 | 393 |
| 394 update_screen_->OnConnectToNetworkRequested(kStubEthernetServicePath); | 394 update_screen_->OnConnectToNetworkRequested(kStubEthernetServicePath); |
| 395 base::MessageLoop::current()->RunUntilIdle(); | 395 base::MessageLoop::current()->RunUntilIdle(); |
| 396 } | 396 } |
| 397 | 397 |
| 398 } // namespace chromeos | 398 } // namespace chromeos |
| OLD | NEW |