| Index: net/url_request/url_request_unittest.cc
|
| ===================================================================
|
| --- net/url_request/url_request_unittest.cc (revision 23443)
|
| +++ net/url_request/url_request_unittest.cc (working copy)
|
| @@ -1361,16 +1361,6 @@
|
| }
|
|
|
| // Custom URLRequestJobs for use with interceptor tests
|
| -class RestartTestJob : public URLRequestTestJob {
|
| - public:
|
| - explicit RestartTestJob(URLRequest* request)
|
| - : URLRequestTestJob(request, true) {}
|
| - protected:
|
| - virtual void StartAsync() {
|
| - this->NotifyRestartRequired();
|
| - }
|
| -};
|
| -
|
| class CancelTestJob : public URLRequestTestJob {
|
| public:
|
| explicit CancelTestJob(URLRequest* request)
|
| @@ -1381,29 +1371,15 @@
|
| }
|
| };
|
|
|
| -class CancelThenRestartTestJob : public URLRequestTestJob {
|
| - public:
|
| - explicit CancelThenRestartTestJob(URLRequest* request)
|
| - : URLRequestTestJob(request, true) {
|
| - }
|
| - protected:
|
| - virtual void StartAsync() {
|
| - request_->Cancel();
|
| - this->NotifyRestartRequired();
|
| - }
|
| -};
|
| -
|
| // An Interceptor for use with interceptor tests
|
| class TestInterceptor : URLRequest::Interceptor {
|
| public:
|
| TestInterceptor()
|
| - : intercept_main_request_(false), restart_main_request_(false),
|
| - cancel_main_request_(false), cancel_then_restart_main_request_(false),
|
| + : intercept_main_request_(false), cancel_main_request_(false),
|
| simulate_main_network_error_(false),
|
| intercept_redirect_(false), cancel_redirect_request_(false),
|
| intercept_final_response_(false), cancel_final_request_(false),
|
| - did_intercept_main_(false), did_restart_main_(false),
|
| - did_cancel_main_(false), did_cancel_then_restart_main_(false),
|
| + did_intercept_main_(false), did_cancel_main_(false),
|
| did_simulate_error_main_(false),
|
| did_intercept_redirect_(false), did_cancel_redirect_(false),
|
| did_intercept_final_(false), did_cancel_final_(false) {
|
| @@ -1415,21 +1391,11 @@
|
| }
|
|
|
| virtual URLRequestJob* MaybeIntercept(URLRequest* request) {
|
| - if (restart_main_request_) {
|
| - restart_main_request_ = false;
|
| - did_restart_main_ = true;
|
| - return new RestartTestJob(request);
|
| - }
|
| if (cancel_main_request_) {
|
| cancel_main_request_ = false;
|
| did_cancel_main_ = true;
|
| return new CancelTestJob(request);
|
| }
|
| - if (cancel_then_restart_main_request_) {
|
| - cancel_then_restart_main_request_ = false;
|
| - did_cancel_then_restart_main_ = true;
|
| - return new CancelThenRestartTestJob(request);
|
| - }
|
| if (simulate_main_network_error_) {
|
| simulate_main_network_error_ = false;
|
| did_simulate_error_main_ = true;
|
| @@ -1485,9 +1451,7 @@
|
| std::string main_data_;
|
|
|
| // Other actions we take at MaybeIntercept time
|
| - bool restart_main_request_;
|
| bool cancel_main_request_;
|
| - bool cancel_then_restart_main_request_;
|
| bool simulate_main_network_error_;
|
|
|
| // Whether to intercept redirects, and if so the response to return.
|
| @@ -1508,9 +1472,7 @@
|
|
|
| // If we did something or not
|
| bool did_intercept_main_;
|
| - bool did_restart_main_;
|
| bool did_cancel_main_;
|
| - bool did_cancel_then_restart_main_;
|
| bool did_simulate_error_main_;
|
| bool did_intercept_redirect_;
|
| bool did_cancel_redirect_;
|
| @@ -1671,35 +1633,6 @@
|
| EXPECT_EQ(0, d.received_redirect_count());
|
| }
|
|
|
| -TEST_F(URLRequestTest, InterceptRestartRequired) {
|
| - TestInterceptor interceptor;
|
| -
|
| - // restart the main request
|
| - interceptor.restart_main_request_ = true;
|
| -
|
| - // then intercept the new main request and respond with an OK response
|
| - interceptor.intercept_main_request_ = true;
|
| - interceptor.main_headers_ = TestInterceptor::ok_headers();
|
| - interceptor.main_data_ = TestInterceptor::ok_data();
|
| -
|
| - TestDelegate d;
|
| - TestURLRequest req(GURL("http://test_intercept/foo"), &d);
|
| - req.set_method("GET");
|
| - req.Start();
|
| - MessageLoop::current()->Run();
|
| -
|
| - // Check the interceptor got called as expected
|
| - EXPECT_TRUE(interceptor.did_restart_main_);
|
| - EXPECT_TRUE(interceptor.did_intercept_main_);
|
| -
|
| - // Check we received one good response
|
| - EXPECT_TRUE(req.status().is_success());
|
| - EXPECT_EQ(200, req.response_headers()->response_code());
|
| - EXPECT_EQ(TestInterceptor::ok_data(), d.data_received());
|
| - EXPECT_EQ(1, d.response_started_count());
|
| - EXPECT_EQ(0, d.received_redirect_count());
|
| -}
|
| -
|
| TEST_F(URLRequestTest, InterceptRespectsCancelMain) {
|
| TestInterceptor interceptor;
|
|
|
| @@ -1782,32 +1715,6 @@
|
| EXPECT_EQ(URLRequestStatus::CANCELED, req.status().status());
|
| }
|
|
|
| -TEST_F(URLRequestTest, InterceptRespectsCancelInRestart) {
|
| - TestInterceptor interceptor;
|
| -
|
| - // intercept the main request and cancel then restart from within that job
|
| - interceptor.cancel_then_restart_main_request_ = true;
|
| -
|
| - // setup to intercept final response and override it with an OK response
|
| - interceptor.intercept_final_response_ = true;
|
| - interceptor.final_headers_ = TestInterceptor::ok_headers();
|
| - interceptor.final_data_ = TestInterceptor::ok_data();
|
| -
|
| - TestDelegate d;
|
| - TestURLRequest req(GURL("http://test_intercept/foo"), &d);
|
| - req.set_method("GET");
|
| - req.Start();
|
| - MessageLoop::current()->Run();
|
| -
|
| - // Check the interceptor got called as expected
|
| - EXPECT_TRUE(interceptor.did_cancel_then_restart_main_);
|
| - EXPECT_FALSE(interceptor.did_intercept_final_);
|
| -
|
| - // Check we see a canceled request
|
| - EXPECT_FALSE(req.status().is_success());
|
| - EXPECT_EQ(URLRequestStatus::CANCELED, req.status().status());
|
| -}
|
| -
|
| TEST_F(URLRequestTest, FTPGetTestAnonymous) {
|
| scoped_refptr<FTPTestServer> server = FTPTestServer::CreateServer(L"");
|
| ASSERT_TRUE(NULL != server.get());
|
|
|