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 "testing/gtest/include/gtest/gtest.h" | 5 #include "testing/gtest/include/gtest/gtest.h" |
6 | 6 |
7 #include "base/compiler_specific.h" | 7 #include "base/compiler_specific.h" |
8 #include "base/logging.h" | 8 #include "base/logging.h" |
9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
10 #include "base/message_loop.h" | 10 #include "base/message_loop.h" |
(...skipping 394 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
405 | 405 |
406 CompleteURLFetch(net::OK, 503, retry_after); | 406 CompleteURLFetch(net::OK, 503, retry_after); |
407 ASSERT_TRUE(is_state_idle()); | 407 ASSERT_TRUE(is_state_idle()); |
408 ASSERT_EQ(3, attempt_count()); | 408 ASSERT_EQ(3, attempt_count()); |
409 CheckPortalState(NetworkPortalDetector::CAPTIVE_PORTAL_STATUS_OFFLINE, 503, | 409 CheckPortalState(NetworkPortalDetector::CAPTIVE_PORTAL_STATUS_OFFLINE, 503, |
410 wifi1_network()); | 410 wifi1_network()); |
411 } | 411 } |
412 | 412 |
413 TEST_F(NetworkPortalDetectorTest, ProxyAuthRequired) { | 413 TEST_F(NetworkPortalDetectorTest, ProxyAuthRequired) { |
414 ASSERT_TRUE(is_state_idle()); | 414 ASSERT_TRUE(is_state_idle()); |
| 415 set_min_time_between_attempts(base::TimeDelta()); |
415 | 416 |
416 SetConnected(wifi1_network()); | 417 SetConnected(wifi1_network()); |
417 CompleteURLFetch(net::OK, 407, NULL); | 418 CompleteURLFetch(net::OK, 407, NULL); |
| 419 ASSERT_EQ(1, attempt_count()); |
| 420 ASSERT_TRUE(is_state_portal_detection_pending()); |
| 421 CheckPortalState(NetworkPortalDetector::CAPTIVE_PORTAL_STATUS_UNKNOWN, -1, |
| 422 wifi1_network()); |
418 | 423 |
| 424 // To run CaptivePortalDetector::DetectCaptivePortal(). |
| 425 MessageLoop::current()->RunUntilIdle(); |
| 426 |
| 427 CompleteURLFetch(net::OK, 407, NULL); |
| 428 ASSERT_EQ(2, attempt_count()); |
| 429 ASSERT_TRUE(is_state_portal_detection_pending()); |
| 430 CheckPortalState(NetworkPortalDetector::CAPTIVE_PORTAL_STATUS_UNKNOWN, -1, |
| 431 wifi1_network()); |
| 432 |
| 433 // To run CaptivePortalDetector::DetectCaptivePortal(). |
| 434 MessageLoop::current()->RunUntilIdle(); |
| 435 |
| 436 CompleteURLFetch(net::OK, 407, NULL); |
| 437 ASSERT_EQ(3, attempt_count()); |
419 ASSERT_TRUE(is_state_idle()); | 438 ASSERT_TRUE(is_state_idle()); |
420 CheckPortalState( | 439 CheckPortalState( |
421 NetworkPortalDetector::CAPTIVE_PORTAL_STATUS_PROXY_AUTH_REQUIRED, 407, | 440 NetworkPortalDetector::CAPTIVE_PORTAL_STATUS_PROXY_AUTH_REQUIRED, 407, |
422 wifi1_network()); | 441 wifi1_network()); |
423 } | 442 } |
424 | 443 |
425 TEST_F(NetworkPortalDetectorTest, NoResponseButBehindPortal) { | 444 TEST_F(NetworkPortalDetectorTest, NoResponseButBehindPortal) { |
426 ASSERT_TRUE(is_state_idle()); | 445 ASSERT_TRUE(is_state_idle()); |
427 set_min_time_between_attempts(base::TimeDelta()); | 446 set_min_time_between_attempts(base::TimeDelta()); |
428 | 447 |
(...skipping 23 matching lines...) Expand all Loading... |
452 NULL); | 471 NULL); |
453 ASSERT_EQ(3, attempt_count()); | 472 ASSERT_EQ(3, attempt_count()); |
454 ASSERT_TRUE(is_state_idle()); | 473 ASSERT_TRUE(is_state_idle()); |
455 | 474 |
456 CheckPortalState(NetworkPortalDetector::CAPTIVE_PORTAL_STATUS_PORTAL, | 475 CheckPortalState(NetworkPortalDetector::CAPTIVE_PORTAL_STATUS_PORTAL, |
457 net::URLFetcher::RESPONSE_CODE_INVALID, | 476 net::URLFetcher::RESPONSE_CODE_INVALID, |
458 wifi1_network()); | 477 wifi1_network()); |
459 } | 478 } |
460 | 479 |
461 } // namespace chromeos | 480 } // namespace chromeos |
OLD | NEW |