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

Unified Diff: chrome/browser/captive_portal/captive_portal_service_unittest.cc

Issue 11419070: Added detection timeouts and usage of Retry-After HTTP header. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix. Created 8 years, 1 month 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/captive_portal/captive_portal_service_unittest.cc
diff --git a/chrome/browser/captive_portal/captive_portal_service_unittest.cc b/chrome/browser/captive_portal/captive_portal_service_unittest.cc
index 11a5921a70b0a5b1d9c84ed67920f4750ac2cd5c..5febd622a24164e5d74b027a6841888431647525 100644
--- a/chrome/browser/captive_portal/captive_portal_service_unittest.cc
+++ b/chrome/browser/captive_portal/captive_portal_service_unittest.cc
@@ -21,8 +21,6 @@
#include "content/public/browser/notification_registrar.h"
#include "content/public/browser/notification_source.h"
#include "net/base/net_errors.h"
-#include "net/http/http_response_headers.h"
-#include "net/url_request/test_url_fetcher_factory.h"
#include "testing/gtest/include/gtest/gtest.h"
namespace captive_portal {
@@ -163,7 +161,6 @@ class CaptivePortalServiceTest : public testing::Test,
ASSERT_EQ(base::TimeDelta(), GetTimeUntilNextRequest());
CaptivePortalObserver observer(profile(), service());
- net::TestURLFetcherFactory factory;
service()->DetectCaptivePortal();
EXPECT_EQ(CaptivePortalService::STATE_TIMER_RUNNING, service()->state());
@@ -176,23 +173,7 @@ class CaptivePortalServiceTest : public testing::Test,
ASSERT_TRUE(FetchingURL());
EXPECT_FALSE(TimerRunning());
- net::TestURLFetcher* fetcher = factory.GetFetcherByID(0);
- if (net_error != net::OK) {
- EXPECT_FALSE(response_headers);
- fetcher->set_status(net::URLRequestStatus(net::URLRequestStatus::FAILED,
- net_error));
- } else {
- fetcher->set_response_code(status_code);
- if (response_headers) {
- scoped_refptr<net::HttpResponseHeaders> headers(
- CreateResponseHeaders(response_headers));
- // Sanity check.
- EXPECT_EQ(status_code, headers->response_code());
- fetcher->set_response_headers(headers);
- }
- }
-
- OnURLFetchComplete(fetcher);
+ CompleteURLFetch(net_error, status_code, response_headers);
EXPECT_FALSE(FetchingURL());
EXPECT_FALSE(TimerRunning());
@@ -389,7 +370,6 @@ TEST_F(CaptivePortalServiceTest, CaptivePortalPrefDisabledWhileRunning) {
CaptivePortalObserver observer(profile(), service());
// Needed to create the URLFetcher, even if it never returns any results.
- net::TestURLFetcherFactory factory;
service()->DetectCaptivePortal();
MessageLoop::current()->RunUntilIdle();
@@ -416,9 +396,6 @@ TEST_F(CaptivePortalServiceTest, CaptivePortalPrefDisabledWhilePending) {
Initialize(CaptivePortalService::SKIP_OS_CHECK_FOR_TESTING);
set_initial_backoff_no_portal(base::TimeDelta::FromDays(1));
- // Needed to create the URLFetcher, even if it never returns any results.
- net::TestURLFetcherFactory factory;
-
CaptivePortalObserver observer(profile(), service());
service()->DetectCaptivePortal();
EXPECT_FALSE(FetchingURL());
@@ -451,8 +428,6 @@ TEST_F(CaptivePortalServiceTest, CaptivePortalPrefEnabledWhilePending) {
EXPECT_FALSE(FetchingURL());
EXPECT_TRUE(TimerRunning());
- net::TestURLFetcherFactory factory;
-
EnableCaptivePortalDetectionPreference(true);
EXPECT_FALSE(FetchingURL());
EXPECT_TRUE(TimerRunning());
@@ -461,9 +436,7 @@ TEST_F(CaptivePortalServiceTest, CaptivePortalPrefEnabledWhilePending) {
ASSERT_TRUE(FetchingURL());
EXPECT_FALSE(TimerRunning());
- net::TestURLFetcher* fetcher = factory.GetFetcherByID(0);
- fetcher->set_response_code(200);
- OnURLFetchComplete(fetcher);
+ CompleteURLFetch(net::OK, 200, NULL);
EXPECT_FALSE(FetchingURL());
EXPECT_FALSE(TimerRunning());
« no previous file with comments | « chrome/browser/captive_portal/captive_portal_service.cc ('k') | chrome/browser/captive_portal/testing_utils.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698