| 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 "base/prefs/pref_service.h" | 7 #include "base/prefs/pref_service.h" |
| 8 #include "chrome/browser/browser_process.h" | 8 #include "chrome/browser/browser_process.h" |
| 9 #include "chrome/browser/chromeos/login/screens/mock_base_screen_delegate.h" | 9 #include "chrome/browser/chromeos/login/screens/mock_base_screen_delegate.h" |
| 10 #include "chrome/browser/chromeos/login/screens/mock_error_screen.h" | 10 #include "chrome/browser/chromeos/login/screens/mock_error_screen.h" |
| (...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 233 EXPECT_CALL(*mock_base_screen_delegate_, | 233 EXPECT_CALL(*mock_base_screen_delegate_, |
| 234 OnExit(_, BaseScreenDelegate::UPDATE_NOUPDATE, _)).Times(1); | 234 OnExit(_, BaseScreenDelegate::UPDATE_NOUPDATE, _)).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 = NetworkPortalDetector::CAPTIVE_PORTAL_STATUS_PORTAL; |
| 240 portal_state.response_code = 200; | 240 portal_state.response_code = 200; |
| 241 SetDetectionResults(kStubEthernetGuid, portal_state); | 241 SetDetectionResults(kStubEthernetGuid, portal_state); |
| 242 | 242 |
| 243 // Update screen will show error message about portal state because | 243 // Update screen will delay error message about portal state because |
| 244 // ethernet is behind captive portal. | 244 // ethernet is behind captive portal. |
| 245 EXPECT_CALL(*mock_error_screen_, | 245 EXPECT_CALL(*mock_error_screen_, |
| 246 MockSetUIState(NetworkError::UI_STATE_UPDATE)).Times(1); | 246 MockSetUIState(NetworkError::UI_STATE_UPDATE)).Times(1); |
| 247 EXPECT_CALL(*mock_error_screen_, | 247 EXPECT_CALL(*mock_error_screen_, |
| 248 MockSetErrorState(NetworkError::ERROR_STATE_PORTAL, | 248 MockSetErrorState(NetworkError::ERROR_STATE_PORTAL, |
| 249 std::string())).Times(1); | 249 std::string())).Times(1); |
| 250 EXPECT_CALL(*mock_error_screen_, MockFixCaptivePortal()).Times(1); | 250 EXPECT_CALL(*mock_error_screen_, MockFixCaptivePortal()).Times(1); |
| 251 EXPECT_CALL(*mock_base_screen_delegate_, ShowErrorScreen()).Times(1); | 251 EXPECT_CALL(*mock_base_screen_delegate_, ShowErrorScreen()).Times(1); |
| 252 | 252 |
| 253 update_screen_->StartNetworkCheck(); | 253 update_screen_->StartNetworkCheck(); |
| 254 | 254 |
| 255 // Force timer expiration. |
| 256 { |
| 257 base::Closure timed_callback = |
| 258 update_screen_->GetErrorMessageTimerForTesting().user_task(); |
| 259 ASSERT_FALSE(timed_callback.is_null()); |
| 260 update_screen_->GetErrorMessageTimerForTesting().Reset(); |
| 261 timed_callback.Run(); |
| 262 } |
| 263 |
| 255 NetworkPortalDetector::CaptivePortalState online_state; | 264 NetworkPortalDetector::CaptivePortalState online_state; |
| 256 online_state.status = NetworkPortalDetector::CAPTIVE_PORTAL_STATUS_ONLINE; | 265 online_state.status = NetworkPortalDetector::CAPTIVE_PORTAL_STATUS_ONLINE; |
| 257 online_state.response_code = 204; | 266 online_state.response_code = 204; |
| 258 SetDetectionResults(kStubEthernetGuid, online_state); | 267 SetDetectionResults(kStubEthernetGuid, online_state); |
| 259 | 268 |
| 260 // Second notification from portal detector will be about online state, | 269 // Second notification from portal detector will be about online state, |
| 261 // so update screen will hide error message and proceed to update. | 270 // so update screen will hide error message and proceed to update. |
| 262 EXPECT_CALL(*mock_base_screen_delegate_, HideErrorScreen(update_screen_)) | 271 EXPECT_CALL(*mock_base_screen_delegate_, HideErrorScreen(update_screen_)) |
| 263 .Times(1); | 272 .Times(1); |
| 264 fake_update_engine_client_->set_update_check_result( | 273 fake_update_engine_client_->set_update_check_result( |
| (...skipping 10 matching lines...) Expand all Loading... |
| 275 EXPECT_CALL(*mock_base_screen_delegate_, | 284 EXPECT_CALL(*mock_base_screen_delegate_, |
| 276 OnExit(_, BaseScreenDelegate::UPDATE_NOUPDATE, _)).Times(1); | 285 OnExit(_, BaseScreenDelegate::UPDATE_NOUPDATE, _)).Times(1); |
| 277 update_screen_->CancelUpdate(); | 286 update_screen_->CancelUpdate(); |
| 278 | 287 |
| 279 // Change ethernet state to portal. | 288 // Change ethernet state to portal. |
| 280 NetworkPortalDetector::CaptivePortalState portal_state; | 289 NetworkPortalDetector::CaptivePortalState portal_state; |
| 281 portal_state.status = NetworkPortalDetector::CAPTIVE_PORTAL_STATUS_PORTAL; | 290 portal_state.status = NetworkPortalDetector::CAPTIVE_PORTAL_STATUS_PORTAL; |
| 282 portal_state.response_code = 200; | 291 portal_state.response_code = 200; |
| 283 SetDetectionResults(kStubEthernetGuid, portal_state); | 292 SetDetectionResults(kStubEthernetGuid, portal_state); |
| 284 | 293 |
| 285 // Update screen will show error message about portal state because | 294 // Update screen will delay error message about portal state because |
| 286 // ethernet is behind captive portal. | 295 // ethernet is behind captive portal. |
| 287 EXPECT_CALL(*mock_error_screen_, | 296 EXPECT_CALL(*mock_error_screen_, |
| 288 MockSetUIState(NetworkError::UI_STATE_UPDATE)).Times(1); | 297 MockSetUIState(NetworkError::UI_STATE_UPDATE)).Times(1); |
| 289 EXPECT_CALL(*mock_error_screen_, | 298 EXPECT_CALL(*mock_error_screen_, |
| 290 MockSetErrorState(NetworkError::ERROR_STATE_PORTAL, | 299 MockSetErrorState(NetworkError::ERROR_STATE_PORTAL, |
| 291 std::string())).Times(1); | 300 std::string())).Times(1); |
| 292 EXPECT_CALL(*mock_error_screen_, MockFixCaptivePortal()).Times(1); | 301 EXPECT_CALL(*mock_error_screen_, MockFixCaptivePortal()).Times(1); |
| 293 EXPECT_CALL(*mock_base_screen_delegate_, ShowErrorScreen()).Times(1); | 302 EXPECT_CALL(*mock_base_screen_delegate_, ShowErrorScreen()).Times(1); |
| 294 | 303 |
| 295 update_screen_->StartNetworkCheck(); | 304 update_screen_->StartNetworkCheck(); |
| 296 | 305 |
| 306 // Force timer expiration. |
| 307 { |
| 308 base::Closure timed_callback = |
| 309 update_screen_->GetErrorMessageTimerForTesting().user_task(); |
| 310 ASSERT_FALSE(timed_callback.is_null()); |
| 311 update_screen_->GetErrorMessageTimerForTesting().Reset(); |
| 312 timed_callback.Run(); |
| 313 } |
| 314 |
| 297 // Change active network to the wifi behind proxy. | 315 // Change active network to the wifi behind proxy. |
| 298 NetworkPortalDetector::CaptivePortalState proxy_state; | 316 NetworkPortalDetector::CaptivePortalState proxy_state; |
| 299 proxy_state.status = | 317 proxy_state.status = |
| 300 NetworkPortalDetector::CAPTIVE_PORTAL_STATUS_PROXY_AUTH_REQUIRED; | 318 NetworkPortalDetector::CAPTIVE_PORTAL_STATUS_PROXY_AUTH_REQUIRED; |
| 301 proxy_state.response_code = -1; | 319 proxy_state.response_code = -1; |
| 302 SetDefaultNetwork(kStubWifiGuid); | 320 SetDefaultNetwork(kStubWifiGuid); |
| 303 SetDetectionResults(kStubWifiGuid, proxy_state); | 321 SetDetectionResults(kStubWifiGuid, proxy_state); |
| 304 | 322 |
| 305 // Update screen will show message about proxy error because wifie | 323 // Update screen will show message about proxy error because wifie |
| 306 // network requires proxy authentication. | 324 // network requires proxy authentication. |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 342 EXPECT_CALL(*mock_base_screen_delegate_, | 360 EXPECT_CALL(*mock_base_screen_delegate_, |
| 343 OnExit(_, BaseScreenDelegate::UPDATE_NOUPDATE, _)).Times(1); | 361 OnExit(_, BaseScreenDelegate::UPDATE_NOUPDATE, _)).Times(1); |
| 344 update_screen_->CancelUpdate(); | 362 update_screen_->CancelUpdate(); |
| 345 | 363 |
| 346 // Change ethernet state to portal. | 364 // Change ethernet state to portal. |
| 347 NetworkPortalDetector::CaptivePortalState portal_state; | 365 NetworkPortalDetector::CaptivePortalState portal_state; |
| 348 portal_state.status = NetworkPortalDetector::CAPTIVE_PORTAL_STATUS_PORTAL; | 366 portal_state.status = NetworkPortalDetector::CAPTIVE_PORTAL_STATUS_PORTAL; |
| 349 portal_state.response_code = 200; | 367 portal_state.response_code = 200; |
| 350 SetDetectionResults(kStubEthernetGuid, portal_state); | 368 SetDetectionResults(kStubEthernetGuid, portal_state); |
| 351 | 369 |
| 352 // Update screen will show error message about portal state because | 370 // Update screen will delay error message about portal state because |
| 353 // ethernet is behind captive portal. | 371 // ethernet is behind captive portal. |
| 354 EXPECT_CALL(*mock_error_screen_, | 372 EXPECT_CALL(*mock_error_screen_, |
| 355 MockSetUIState(NetworkError::UI_STATE_UPDATE)).Times(1); | 373 MockSetUIState(NetworkError::UI_STATE_UPDATE)).Times(1); |
| 356 EXPECT_CALL(*mock_error_screen_, | 374 EXPECT_CALL(*mock_error_screen_, |
| 357 MockSetErrorState(NetworkError::ERROR_STATE_PORTAL, | 375 MockSetErrorState(NetworkError::ERROR_STATE_PORTAL, |
| 358 std::string())).Times(1); | 376 std::string())).Times(1); |
| 359 EXPECT_CALL(*mock_error_screen_, MockFixCaptivePortal()).Times(1); | 377 EXPECT_CALL(*mock_error_screen_, MockFixCaptivePortal()).Times(1); |
| 360 EXPECT_CALL(*mock_base_screen_delegate_, ShowErrorScreen()).Times(1); | 378 EXPECT_CALL(*mock_base_screen_delegate_, ShowErrorScreen()).Times(1); |
| 361 | 379 |
| 362 update_screen_->StartNetworkCheck(); | 380 update_screen_->StartNetworkCheck(); |
| 363 | 381 |
| 382 // Force timer expiration. |
| 383 { |
| 384 base::Closure timed_callback = |
| 385 update_screen_->GetErrorMessageTimerForTesting().user_task(); |
| 386 ASSERT_FALSE(timed_callback.is_null()); |
| 387 update_screen_->GetErrorMessageTimerForTesting().Reset(); |
| 388 timed_callback.Run(); |
| 389 } |
| 390 |
| 364 // User re-selects the same network manually. In this case, hide | 391 // User re-selects the same network manually. In this case, hide |
| 365 // offline message and skip network check. Since ethernet is still | 392 // offline message and skip network check. Since ethernet is still |
| 366 // behind portal, update engine fails to update. | 393 // behind portal, update engine fails to update. |
| 367 EXPECT_CALL(*mock_base_screen_delegate_, HideErrorScreen(update_screen_)) | 394 EXPECT_CALL(*mock_base_screen_delegate_, HideErrorScreen(update_screen_)) |
| 368 .Times(1); | 395 .Times(1); |
| 369 fake_update_engine_client_->set_update_check_result( | 396 fake_update_engine_client_->set_update_check_result( |
| 370 chromeos::UpdateEngineClient::UPDATE_RESULT_FAILED); | 397 chromeos::UpdateEngineClient::UPDATE_RESULT_FAILED); |
| 371 EXPECT_CALL(*mock_base_screen_delegate_, | 398 EXPECT_CALL(*mock_base_screen_delegate_, |
| 372 OnExit(_, BaseScreenDelegate::UPDATE_ERROR_CHECKING_FOR_UPDATE, | 399 OnExit(_, BaseScreenDelegate::UPDATE_ERROR_CHECKING_FOR_UPDATE, |
| 373 _)).Times(1); | 400 _)).Times(1); |
| 374 | 401 |
| 375 update_screen_->OnConnectToNetworkRequested(); | 402 update_screen_->OnConnectToNetworkRequested(); |
| 376 base::MessageLoop::current()->RunUntilIdle(); | 403 base::MessageLoop::current()->RunUntilIdle(); |
| 377 } | 404 } |
| 378 | 405 |
| 379 } // namespace chromeos | 406 } // namespace chromeos |
| OLD | NEW |