Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2699)

Unified Diff: chrome/browser/chromeos/net/network_portal_detector_impl_unittest.cc

Issue 385553002: BackoffEntry is used to compute timeouts between consecutive captive portal checks. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 6 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/browser/chromeos/net/network_portal_detector_impl_unittest.cc
diff --git a/chrome/browser/chromeos/net/network_portal_detector_impl_unittest.cc b/chrome/browser/chromeos/net/network_portal_detector_impl_unittest.cc
index 2bf11a33352f3e627c0fdc68357cc1505cece1f8..7bf222f76167e0b9608459aabc4ec58937698b60 100644
--- a/chrome/browser/chromeos/net/network_portal_detector_impl_unittest.cc
+++ b/chrome/browser/chromeos/net/network_portal_detector_impl_unittest.cc
@@ -108,12 +108,16 @@ class NetworkPortalDetectorImplTest
ASSERT_EQ(response_code, state.response_code);
}
- void CheckRequestTimeoutAndCompleteAttempt(int expected_attempt_count,
- int expected_request_timeout_sec,
- int net_error,
- int status_code) {
+ void CheckRequestTimeoutAndCompleteAttempt(
+ uint64 expected_same_detection_result_count,
+ uint64 expected_no_response_result_count,
+ int expected_request_timeout_sec,
+ int net_error,
+ int status_code) {
ASSERT_TRUE(is_state_checking_for_portal());
- ASSERT_EQ(expected_attempt_count, attempt_count());
+ ASSERT_EQ(expected_same_detection_result_count,
+ same_detection_result_count());
+ ASSERT_EQ(expected_no_response_result_count, no_response_result_count());
ASSERT_EQ(base::TimeDelta::FromSeconds(expected_request_timeout_sec),
get_next_attempt_timeout());
CompleteURLFetch(net_error, status_code, NULL);
@@ -173,12 +177,16 @@ class NetworkPortalDetectorImplTest
return network_portal_detector()->next_attempt_delay_for_testing();
}
- int attempt_count() {
- return network_portal_detector()->attempt_count_for_testing();
+ uint64 same_detection_result_count() {
+ return network_portal_detector()->same_detection_result_count_for_testing();
}
- void set_attempt_count(int ac) {
- network_portal_detector()->set_attempt_count_for_testing(ac);
+ uint64 no_response_result_count() {
+ return network_portal_detector()->no_response_result_count_for_testing();
+ }
+
+ void set_no_response_result_count(uint64 count) {
+ network_portal_detector()->set_no_response_result_count_for_testing(count);
}
void set_delay_till_next_attempt(const base::TimeDelta& delta) {
@@ -282,7 +290,7 @@ TEST_F(NetworkPortalDetectorImplTest, NoPortal) {
CompleteURLFetch(net::OK, 204, NULL);
- ASSERT_TRUE(is_state_idle());
+ ASSERT_FALSE(is_state_idle());
CheckPortalState(
NetworkPortalDetector::CAPTIVE_PORTAL_STATUS_ONLINE, 204, kStubWireless1);
ASSERT_TRUE(
@@ -300,7 +308,7 @@ TEST_F(NetworkPortalDetectorImplTest, Portal) {
CompleteURLFetch(net::OK, 200, NULL);
- ASSERT_TRUE(is_state_idle());
+ ASSERT_FALSE(is_state_idle());
CheckPortalState(
NetworkPortalDetector::CAPTIVE_PORTAL_STATUS_PORTAL, 200, kStubWireless1);
@@ -310,7 +318,7 @@ TEST_F(NetworkPortalDetectorImplTest, Portal) {
CompleteURLFetch(net::OK, 301, NULL);
- ASSERT_TRUE(is_state_idle());
+ ASSERT_FALSE(is_state_idle());
CheckPortalState(
NetworkPortalDetector::CAPTIVE_PORTAL_STATUS_PORTAL, 301, kStubWireless2);
@@ -320,7 +328,7 @@ TEST_F(NetworkPortalDetectorImplTest, Portal) {
CompleteURLFetch(net::OK, 302, NULL);
- ASSERT_TRUE(is_state_idle());
+ ASSERT_FALSE(is_state_idle());
CheckPortalState(
NetworkPortalDetector::CAPTIVE_PORTAL_STATUS_PORTAL, 302, kStubEthernet);
@@ -357,7 +365,7 @@ TEST_F(NetworkPortalDetectorImplTest, Online2Offline) {
ASSERT_TRUE(is_state_checking_for_portal());
CompleteURLFetch(net::OK, 204, NULL);
- ASSERT_TRUE(is_state_idle());
+ ASSERT_FALSE(is_state_idle());
// Check that observer was notified about online state.
Mock::VerifyAndClearExpectations(&observer);
@@ -391,14 +399,14 @@ TEST_F(NetworkPortalDetectorImplTest, TwoNetworks) {
// WiFi is in portal state.
CompleteURLFetch(net::OK, 200, NULL);
- ASSERT_TRUE(is_state_idle());
+ ASSERT_FALSE(is_state_idle());
SetConnected(kStubEthernet);
ASSERT_TRUE(is_state_checking_for_portal());
// ethernet is in online state.
CompleteURLFetch(net::OK, 204, NULL);
- ASSERT_TRUE(is_state_idle());
+ ASSERT_FALSE(is_state_idle());
CheckPortalState(
NetworkPortalDetector::CAPTIVE_PORTAL_STATUS_ONLINE, 204, kStubEthernet);
CheckPortalState(
@@ -429,7 +437,7 @@ TEST_F(NetworkPortalDetectorImplTest, NetworkChanged) {
// ethernet is in online state.
CompleteURLFetch(net::OK, 204, NULL);
- ASSERT_TRUE(is_state_idle());
+ ASSERT_FALSE(is_state_idle());
CheckPortalState(
NetworkPortalDetector::CAPTIVE_PORTAL_STATUS_ONLINE, 204, kStubEthernet);
@@ -452,7 +460,7 @@ TEST_F(NetworkPortalDetectorImplTest, NetworkStateNotChanged) {
CompleteURLFetch(net::OK, 204, NULL);
- ASSERT_TRUE(is_state_idle());
+ ASSERT_FALSE(is_state_idle());
CheckPortalState(
NetworkPortalDetector::CAPTIVE_PORTAL_STATUS_ONLINE, 204, kStubWireless1);
@@ -474,7 +482,7 @@ TEST_F(NetworkPortalDetectorImplTest, NetworkStateChanged) {
CompleteURLFetch(net::OK, 200, NULL);
- ASSERT_TRUE(is_state_idle());
+ ASSERT_FALSE(is_state_idle());
CheckPortalState(
NetworkPortalDetector::CAPTIVE_PORTAL_STATUS_PORTAL, 200, kStubWireless1);
@@ -483,7 +491,7 @@ TEST_F(NetworkPortalDetectorImplTest, NetworkStateChanged) {
CompleteURLFetch(net::OK, 204, NULL);
- ASSERT_TRUE(is_state_idle());
+ ASSERT_FALSE(is_state_idle());
CheckPortalState(
NetworkPortalDetector::CAPTIVE_PORTAL_STATUS_ONLINE, 204, kStubWireless1);
@@ -492,7 +500,7 @@ TEST_F(NetworkPortalDetectorImplTest, NetworkStateChanged) {
CompleteURLFetch(net::OK, 200, NULL);
- ASSERT_TRUE(is_state_idle());
+ ASSERT_FALSE(is_state_idle());
CheckPortalState(
NetworkPortalDetector::CAPTIVE_PORTAL_STATUS_PORTAL, 200, kStubWireless1);
@@ -510,7 +518,8 @@ TEST_F(NetworkPortalDetectorImplTest, PortalDetectionTimeout) {
set_next_attempt_timeout(base::TimeDelta::FromSeconds(0));
ASSERT_TRUE(is_state_idle());
- ASSERT_EQ(0, attempt_count());
+ ASSERT_EQ(static_cast<uint64>(0), same_detection_result_count());
+ ASSERT_EQ(static_cast<uint64>(0), no_response_result_count());
SetConnected(kStubWireless1);
base::RunLoop().RunUntilIdle();
@@ -518,8 +527,7 @@ TEST_F(NetworkPortalDetectorImplTest, PortalDetectionTimeout) {
// First portal detection timeouts, next portal detection is
// scheduled.
ASSERT_TRUE(is_state_portal_detection_pending());
- ASSERT_EQ(1, attempt_count());
- ASSERT_EQ(base::TimeDelta::FromSeconds(3), next_attempt_delay());
+ ASSERT_EQ(static_cast<uint64>(1), no_response_result_count());
ASSERT_TRUE(MakeResultHistogramChecker()->Check());
}
@@ -530,7 +538,7 @@ TEST_F(NetworkPortalDetectorImplTest, PortalDetectionRetryAfter) {
const char* retry_after = "HTTP/1.1 503 OK\nRetry-After: 101\n\n";
ASSERT_TRUE(is_state_idle());
- ASSERT_EQ(0, attempt_count());
+ ASSERT_EQ(static_cast<uint64>(0), no_response_result_count());
SetConnected(kStubWireless1);
ASSERT_TRUE(is_state_checking_for_portal());
@@ -539,7 +547,7 @@ TEST_F(NetworkPortalDetectorImplTest, PortalDetectionRetryAfter) {
// First portal detection completed, next portal detection is
// scheduled after 101 seconds.
ASSERT_TRUE(is_state_portal_detection_pending());
- ASSERT_EQ(1, attempt_count());
+ ASSERT_EQ(static_cast<uint64>(1), no_response_result_count());
ASSERT_EQ(base::TimeDelta::FromSeconds(101), next_attempt_delay());
ASSERT_TRUE(MakeResultHistogramChecker()->Check());
@@ -551,7 +559,7 @@ TEST_F(NetworkPortalDetectorImplTest, PortalDetectorRetryAfterIsSmall) {
const char* retry_after = "HTTP/1.1 503 OK\nRetry-After: 1\n\n";
ASSERT_TRUE(is_state_idle());
- ASSERT_EQ(0, attempt_count());
+ ASSERT_EQ(static_cast<uint64>(0), no_response_result_count());
SetConnected(kStubWireless1);
CompleteURLFetch(net::OK, 503, retry_after);
@@ -560,8 +568,7 @@ TEST_F(NetworkPortalDetectorImplTest, PortalDetectorRetryAfterIsSmall) {
// scheduled after 3 seconds (due to minimum time between detection
// attemps).
ASSERT_TRUE(is_state_portal_detection_pending());
- ASSERT_EQ(1, attempt_count());
- ASSERT_EQ(base::TimeDelta::FromSeconds(3), next_attempt_delay());
+ ASSERT_EQ(static_cast<uint64>(1), no_response_result_count());
ASSERT_TRUE(MakeResultHistogramChecker()->Check());
}
@@ -573,21 +580,21 @@ TEST_F(NetworkPortalDetectorImplTest, FirstAttemptFailed) {
const char* retry_after = "HTTP/1.1 503 OK\nRetry-After: 0\n\n";
ASSERT_TRUE(is_state_idle());
- ASSERT_EQ(0, attempt_count());
+ ASSERT_EQ(static_cast<uint64>(0), no_response_result_count());
SetConnected(kStubWireless1);
CompleteURLFetch(net::OK, 503, retry_after);
ASSERT_TRUE(is_state_portal_detection_pending());
- ASSERT_EQ(1, attempt_count());
+ ASSERT_EQ(static_cast<uint64>(1), no_response_result_count());
ASSERT_EQ(base::TimeDelta::FromSeconds(0), next_attempt_delay());
// To run CaptivePortalDetector::DetectCaptivePortal().
base::RunLoop().RunUntilIdle();
CompleteURLFetch(net::OK, 204, NULL);
- ASSERT_TRUE(is_state_idle());
- ASSERT_EQ(2, attempt_count());
+ ASSERT_FALSE(is_state_idle());
+ ASSERT_EQ(static_cast<uint64>(0), no_response_result_count());
CheckPortalState(
NetworkPortalDetector::CAPTIVE_PORTAL_STATUS_ONLINE, 204, kStubWireless1);
@@ -604,13 +611,13 @@ TEST_F(NetworkPortalDetectorImplTest, AllAttemptsFailed) {
const char* retry_after = "HTTP/1.1 503 OK\nRetry-After: 0\n\n";
ASSERT_TRUE(is_state_idle());
- ASSERT_EQ(0, attempt_count());
+ ASSERT_EQ(static_cast<uint64>(0), no_response_result_count());
SetConnected(kStubWireless1);
CompleteURLFetch(net::OK, 503, retry_after);
ASSERT_TRUE(is_state_portal_detection_pending());
- ASSERT_EQ(1, attempt_count());
+ ASSERT_EQ(static_cast<uint64>(1), no_response_result_count());
ASSERT_EQ(base::TimeDelta::FromSeconds(0), next_attempt_delay());
// To run CaptivePortalDetector::DetectCaptivePortal().
@@ -618,15 +625,15 @@ TEST_F(NetworkPortalDetectorImplTest, AllAttemptsFailed) {
CompleteURLFetch(net::OK, 503, retry_after);
ASSERT_TRUE(is_state_portal_detection_pending());
- ASSERT_EQ(2, attempt_count());
+ ASSERT_EQ(static_cast<uint64>(2), no_response_result_count());
ASSERT_EQ(base::TimeDelta::FromSeconds(0), next_attempt_delay());
// To run CaptivePortalDetector::DetectCaptivePortal().
base::RunLoop().RunUntilIdle();
CompleteURLFetch(net::OK, 503, retry_after);
- ASSERT_TRUE(is_state_idle());
- ASSERT_EQ(3, attempt_count());
+ ASSERT_FALSE(is_state_idle());
+ ASSERT_EQ(static_cast<uint64>(3), no_response_result_count());
CheckPortalState(NetworkPortalDetector::CAPTIVE_PORTAL_STATUS_OFFLINE,
503,
kStubWireless1);
@@ -643,18 +650,18 @@ TEST_F(NetworkPortalDetectorImplTest, ProxyAuthRequired) {
SetConnected(kStubWireless1);
CompleteURLFetch(net::OK, 407, NULL);
- ASSERT_EQ(1, attempt_count());
+ ASSERT_EQ(static_cast<uint64>(1), no_response_result_count());
ASSERT_TRUE(is_state_portal_detection_pending());
base::RunLoop().RunUntilIdle();
CompleteURLFetch(net::OK, 407, NULL);
- ASSERT_EQ(2, attempt_count());
+ ASSERT_EQ(static_cast<uint64>(2), no_response_result_count());
ASSERT_TRUE(is_state_portal_detection_pending());
base::RunLoop().RunUntilIdle();
CompleteURLFetch(net::OK, 407, NULL);
- ASSERT_EQ(3, attempt_count());
- ASSERT_TRUE(is_state_idle());
+ ASSERT_EQ(static_cast<uint64>(3), no_response_result_count());
+ ASSERT_FALSE(is_state_idle());
CheckPortalState(
NetworkPortalDetector::CAPTIVE_PORTAL_STATUS_PROXY_AUTH_REQUIRED,
@@ -677,7 +684,7 @@ TEST_F(NetworkPortalDetectorImplTest, NoResponseButBehindPortal) {
CompleteURLFetch(
net::ERR_CONNECTION_CLOSED, net::URLFetcher::RESPONSE_CODE_INVALID, NULL);
- ASSERT_EQ(1, attempt_count());
+ ASSERT_EQ(static_cast<uint64>(1), no_response_result_count());
ASSERT_TRUE(is_state_portal_detection_pending());
// To run CaptivePortalDetector::DetectCaptivePortal().
@@ -685,7 +692,7 @@ TEST_F(NetworkPortalDetectorImplTest, NoResponseButBehindPortal) {
CompleteURLFetch(
net::ERR_CONNECTION_CLOSED, net::URLFetcher::RESPONSE_CODE_INVALID, NULL);
- ASSERT_EQ(2, attempt_count());
+ ASSERT_EQ(static_cast<uint64>(2), no_response_result_count());
ASSERT_TRUE(is_state_portal_detection_pending());
// To run CaptivePortalDetector::DetectCaptivePortal().
@@ -693,8 +700,8 @@ TEST_F(NetworkPortalDetectorImplTest, NoResponseButBehindPortal) {
CompleteURLFetch(
net::ERR_CONNECTION_CLOSED, net::URLFetcher::RESPONSE_CODE_INVALID, NULL);
- ASSERT_EQ(3, attempt_count());
- ASSERT_TRUE(is_state_idle());
+ ASSERT_EQ(static_cast<uint64>(3), no_response_result_count());
+ ASSERT_FALSE(is_state_idle());
CheckPortalState(NetworkPortalDetector::CAPTIVE_PORTAL_STATUS_PORTAL,
net::URLFetcher::RESPONSE_CODE_INVALID,
@@ -709,7 +716,7 @@ TEST_F(NetworkPortalDetectorImplTest, NoResponseButBehindPortal) {
TEST_F(NetworkPortalDetectorImplTest,
DisableErrorScreenStrategyWhilePendingRequest) {
ASSERT_TRUE(is_state_idle());
- set_attempt_count(3);
+ set_no_response_result_count(3);
enable_error_screen_strategy();
ASSERT_TRUE(is_state_portal_detection_pending());
disable_error_screen_strategy();
@@ -772,7 +779,7 @@ TEST_F(NetworkPortalDetectorImplTest, ErrorScreenStrategyForPortalNetwork) {
CompleteURLFetch(
net::ERR_CONNECTION_CLOSED, net::URLFetcher::RESPONSE_CODE_INVALID, NULL);
- ASSERT_EQ(1, attempt_count());
+ ASSERT_EQ(static_cast<uint64>(1), no_response_result_count());
ASSERT_TRUE(is_state_portal_detection_pending());
CheckPortalState(
NetworkPortalDetector::CAPTIVE_PORTAL_STATUS_UNKNOWN, -1, kStubWireless1);
@@ -782,7 +789,7 @@ TEST_F(NetworkPortalDetectorImplTest, ErrorScreenStrategyForPortalNetwork) {
CompleteURLFetch(
net::ERR_CONNECTION_CLOSED, net::URLFetcher::RESPONSE_CODE_INVALID, NULL);
- ASSERT_EQ(2, attempt_count());
+ ASSERT_EQ(static_cast<uint64>(2), no_response_result_count());
ASSERT_TRUE(is_state_portal_detection_pending());
CheckPortalState(
NetworkPortalDetector::CAPTIVE_PORTAL_STATUS_UNKNOWN, -1, kStubWireless1);
@@ -791,7 +798,7 @@ TEST_F(NetworkPortalDetectorImplTest, ErrorScreenStrategyForPortalNetwork) {
base::RunLoop().RunUntilIdle();
CompleteURLFetch(net::OK, 200, NULL);
- ASSERT_EQ(3, attempt_count());
+ ASSERT_EQ(static_cast<uint64>(0), no_response_result_count());
ASSERT_TRUE(is_state_portal_detection_pending());
CheckPortalState(
NetworkPortalDetector::CAPTIVE_PORTAL_STATUS_PORTAL, 200, kStubWireless1);
@@ -843,12 +850,10 @@ TEST_F(NetworkPortalDetectorImplTest, TestDetectionRestart) {
CheckPortalState(
NetworkPortalDetector::CAPTIVE_PORTAL_STATUS_ONLINE, 204, kStubWireless1);
- ASSERT_TRUE(is_state_idle());
+ ASSERT_FALSE(is_state_idle());
// First portal detection attempts determines PORTAL state.
- ASSERT_TRUE(start_detection_if_idle());
ASSERT_TRUE(is_state_portal_detection_pending());
- ASSERT_FALSE(start_detection_if_idle());
base::RunLoop().RunUntilIdle();
ASSERT_TRUE(is_state_checking_for_portal());
@@ -856,7 +861,7 @@ TEST_F(NetworkPortalDetectorImplTest, TestDetectionRestart) {
CheckPortalState(
NetworkPortalDetector::CAPTIVE_PORTAL_STATUS_PORTAL, 200, kStubWireless1);
- ASSERT_TRUE(is_state_idle());
+ ASSERT_FALSE(is_state_idle());
ASSERT_TRUE(
MakeResultHistogramChecker()
@@ -874,34 +879,44 @@ TEST_F(NetworkPortalDetectorImplTest, RequestTimeouts) {
// First portal detection attempt for cellular1 uses 5sec timeout.
CheckRequestTimeoutAndCompleteAttempt(
- 0, 5, net::ERR_CONNECTION_CLOSED, net::URLFetcher::RESPONSE_CODE_INVALID);
+ 0 /* expected_same_detection_result_count */,
+ 0 /* expected_no_response_result_count */,
+ 5 /* expected_request_timeout_sec */,
+ net::ERR_CONNECTION_CLOSED,
+ net::URLFetcher::RESPONSE_CODE_INVALID);
// Second portal detection attempt for cellular1 uses 10sec timeout.
ASSERT_TRUE(is_state_portal_detection_pending());
base::RunLoop().RunUntilIdle();
- CheckRequestTimeoutAndCompleteAttempt(1,
- 10,
- net::ERR_CONNECTION_CLOSED,
- net::URLFetcher::RESPONSE_CODE_INVALID);
+ CheckRequestTimeoutAndCompleteAttempt(
+ 1 /* expected_same_detection_result_count */,
+ 1 /* expected_no_response_result_count */,
+ 10 /* expected_request_timeout_sec */,
+ net::ERR_CONNECTION_CLOSED,
+ net::URLFetcher::RESPONSE_CODE_INVALID);
// Third portal detection attempt for cellular1 uses 15sec timeout.
ASSERT_TRUE(is_state_portal_detection_pending());
base::RunLoop().RunUntilIdle();
- CheckRequestTimeoutAndCompleteAttempt(2,
- 15,
- net::ERR_CONNECTION_CLOSED,
- net::URLFetcher::RESPONSE_CODE_INVALID);
+ CheckRequestTimeoutAndCompleteAttempt(
+ 2 /* expected_same_detection_result_count */,
+ 2 /* expected_no_response_result_count */,
+ 15 /* expected_request_timeout_sec */,
+ net::ERR_CONNECTION_CLOSED,
+ net::URLFetcher::RESPONSE_CODE_INVALID);
- ASSERT_TRUE(is_state_idle());
+ ASSERT_FALSE(is_state_idle());
- // Check that in lazy detection for cellular1 15sec timeout is used.
+ // Check that on the error screen 15sec timeout is used.
enable_error_screen_strategy();
ASSERT_TRUE(is_state_portal_detection_pending());
base::RunLoop().RunUntilIdle();
- CheckRequestTimeoutAndCompleteAttempt(0,
- 15,
- net::ERR_CONNECTION_CLOSED,
- net::URLFetcher::RESPONSE_CODE_INVALID);
+ CheckRequestTimeoutAndCompleteAttempt(
+ 0 /* expected_same_detection_result_count */,
+ 0 /* expected_no_response_result_count */,
+ 15 /* expected_request_timeout_sec */,
+ net::ERR_CONNECTION_CLOSED,
+ net::URLFetcher::RESPONSE_CODE_INVALID);
disable_error_screen_strategy();
ASSERT_TRUE(is_state_portal_detection_pending());
@@ -910,20 +925,34 @@ TEST_F(NetworkPortalDetectorImplTest, RequestTimeouts) {
// First portal detection attempt for wifi1 uses 5sec timeout.
CheckRequestTimeoutAndCompleteAttempt(
- 0, 5, net::ERR_CONNECTION_CLOSED, net::URLFetcher::RESPONSE_CODE_INVALID);
+ 0 /* expected_same_detection_result_count */,
+ 0 /* expected_no_response_result_count */,
+ 5 /* expected_request_timeout_sec */,
+ net::ERR_CONNECTION_CLOSED,
+ net::URLFetcher::RESPONSE_CODE_INVALID);
// Second portal detection attempt for wifi1 also uses 5sec timeout.
ASSERT_TRUE(is_state_portal_detection_pending());
base::RunLoop().RunUntilIdle();
- CheckRequestTimeoutAndCompleteAttempt(1, 10, net::OK, 204);
- ASSERT_TRUE(is_state_idle());
+ CheckRequestTimeoutAndCompleteAttempt(
+ 1 /* expected_same_detection_result_count */,
+ 1 /* expected_no_response_result_count */,
+ 10 /* expected_request_timeout_sec */,
+ net::OK,
+ 204);
+ ASSERT_FALSE(is_state_idle());
// Check that in error screen strategy detection for wifi1 15sec
// timeout is used.
enable_error_screen_strategy();
ASSERT_TRUE(is_state_portal_detection_pending());
base::RunLoop().RunUntilIdle();
- CheckRequestTimeoutAndCompleteAttempt(0, 15, net::OK, 204);
+ CheckRequestTimeoutAndCompleteAttempt(
+ 0 /* expected_same_detection_result_count */,
+ 0 /* expected_no_response_result_count */,
+ 15 /* expected_request_timeout_sec */,
+ net::OK,
+ 204);
disable_error_screen_strategy();
ASSERT_TRUE(is_state_portal_detection_pending());
@@ -934,39 +963,60 @@ TEST_F(NetworkPortalDetectorImplTest, RequestTimeouts) {
->Check());
}
-TEST_F(NetworkPortalDetectorImplTest, StartDetectionIfIdle) {
+TEST_F(NetworkPortalDetectorImplTest, RequestTimeouts2) {
ASSERT_TRUE(is_state_idle());
set_delay_till_next_attempt(base::TimeDelta());
SetConnected(kStubWireless1);
// First portal detection attempt for wifi1 uses 5sec timeout.
CheckRequestTimeoutAndCompleteAttempt(
- 0, 5, net::ERR_CONNECTION_CLOSED, net::URLFetcher::RESPONSE_CODE_INVALID);
+ 0 /* expected_same_detection_result_count */,
+ 0 /* expected_no_response_result_count */,
+ 5 /* expected_request_timeout_sec */,
+ net::ERR_CONNECTION_CLOSED,
+ net::URLFetcher::RESPONSE_CODE_INVALID);
ASSERT_TRUE(is_state_portal_detection_pending());
base::RunLoop().RunUntilIdle();
// Second portal detection attempt for wifi1 uses 10sec timeout.
- CheckRequestTimeoutAndCompleteAttempt(1,
- 10,
- net::ERR_CONNECTION_CLOSED,
- net::URLFetcher::RESPONSE_CODE_INVALID);
+ CheckRequestTimeoutAndCompleteAttempt(
+ 1 /* expected_same_detection_result_count */,
+ 1 /* expected_no_response_result_count */,
+ 10 /* expected_request_timeout_sec */,
+ net::ERR_CONNECTION_CLOSED,
+ net::URLFetcher::RESPONSE_CODE_INVALID);
ASSERT_TRUE(is_state_portal_detection_pending());
base::RunLoop().RunUntilIdle();
// Second portal detection attempt for wifi1 uses 15sec timeout.
- CheckRequestTimeoutAndCompleteAttempt(2,
- 15,
- net::ERR_CONNECTION_CLOSED,
- net::URLFetcher::RESPONSE_CODE_INVALID);
- ASSERT_TRUE(is_state_idle());
- start_detection_if_idle();
-
+ CheckRequestTimeoutAndCompleteAttempt(
+ 2 /* expected_same_detection_result_count */,
+ 2 /* expected_no_response_result_count */,
+ 15 /* expected_request_timeout_sec */,
+ net::ERR_CONNECTION_CLOSED,
+ net::URLFetcher::RESPONSE_CODE_INVALID);
+ ASSERT_FALSE(is_state_idle());
ASSERT_TRUE(is_state_portal_detection_pending());
- // First portal detection attempt for wifi1 uses 5sec timeout.
+ // Third portal detection attempt for wifi1 uses 20sec timeout.
base::RunLoop().RunUntilIdle();
- CheckRequestTimeoutAndCompleteAttempt(0, 5, net::OK, 204);
- ASSERT_TRUE(is_state_idle());
+ CheckRequestTimeoutAndCompleteAttempt(
+ 3 /* expected_same_detection_result_count */,
+ 3 /* expected_no_response_result_count */,
+ 20 /* expected_request_timeout_sec */,
+ net::OK,
+ 204);
+ ASSERT_FALSE(is_state_idle());
+
+ // Fourth portal detection attempt for wifi1 uses 5sec timeout.
+ base::RunLoop().RunUntilIdle();
+ CheckRequestTimeoutAndCompleteAttempt(
+ 1 /* expected_same_detection_result_count */,
+ 0 /* expected_no_response_result_count */,
+ 5 /* expected_request_timeout_sec */,
+ net::OK,
+ 204);
+ ASSERT_FALSE(is_state_idle());
ASSERT_TRUE(
MakeResultHistogramChecker()

Powered by Google App Engine
This is Rietveld 408576698