| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/memory/scoped_ptr.h" |
| 5 #include "base/run_loop.h" | 6 #include "base/run_loop.h" |
| 6 #include "base/strings/stringprintf.h" | 7 #include "base/strings/stringprintf.h" |
| 7 #include "net/base/request_priority.h" | 8 #include "net/base/request_priority.h" |
| 8 #include "net/url_request/url_request_job.h" | 9 #include "net/url_request/url_request_job.h" |
| 9 #include "net/url_request/url_request_job_factory.h" | 10 #include "net/url_request/url_request_job_factory.h" |
| 10 #include "net/url_request/url_request_job_factory_impl.h" | 11 #include "net/url_request/url_request_job_factory_impl.h" |
| 11 #include "net/url_request/url_request_simple_job.h" | 12 #include "net/url_request/url_request_simple_job.h" |
| 12 #include "net/url_request/url_request_test_util.h" | 13 #include "net/url_request/url_request_test_util.h" |
| 13 #include "testing/gtest/include/gtest/gtest.h" | 14 #include "testing/gtest/include/gtest/gtest.h" |
| 14 | 15 |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 59 } | 60 } |
| 60 }; | 61 }; |
| 61 | 62 |
| 62 class URLRequestSimpleJobTest : public ::testing::Test { | 63 class URLRequestSimpleJobTest : public ::testing::Test { |
| 63 public: | 64 public: |
| 64 URLRequestSimpleJobTest() : context_(true) { | 65 URLRequestSimpleJobTest() : context_(true) { |
| 65 job_factory_.SetProtocolHandler("data", new SimpleJobProtocolHandler()); | 66 job_factory_.SetProtocolHandler("data", new SimpleJobProtocolHandler()); |
| 66 context_.set_job_factory(&job_factory_); | 67 context_.set_job_factory(&job_factory_); |
| 67 context_.Init(); | 68 context_.Init(); |
| 68 | 69 |
| 69 request_.reset(new URLRequest( | 70 request_ = context_.CreateRequest( |
| 70 GURL("data:test"), DEFAULT_PRIORITY, &delegate_, &context_)); | 71 GURL("data:test"), DEFAULT_PRIORITY, &delegate_, NULL); |
| 71 } | 72 } |
| 72 | 73 |
| 73 void StartRequest(const HttpRequestHeaders* headers) { | 74 void StartRequest(const HttpRequestHeaders* headers) { |
| 74 if (headers) | 75 if (headers) |
| 75 request_->SetExtraRequestHeaders(*headers); | 76 request_->SetExtraRequestHeaders(*headers); |
| 76 request_->Start(); | 77 request_->Start(); |
| 77 | 78 |
| 78 EXPECT_TRUE(request_->is_pending()); | 79 EXPECT_TRUE(request_->is_pending()); |
| 79 base::RunLoop().Run(); | 80 base::RunLoop().Run(); |
| 80 EXPECT_FALSE(request_->is_pending()); | 81 EXPECT_FALSE(request_->is_pending()); |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 132 "bytes=%d-%d", kRangeLastPosition, kRangeFirstPosition); | 133 "bytes=%d-%d", kRangeLastPosition, kRangeFirstPosition); |
| 133 headers.SetHeader(HttpRequestHeaders::kRange, range); | 134 headers.SetHeader(HttpRequestHeaders::kRange, range); |
| 134 | 135 |
| 135 StartRequest(&headers); | 136 StartRequest(&headers); |
| 136 | 137 |
| 137 ASSERT_TRUE(request_->status().is_success()); | 138 ASSERT_TRUE(request_->status().is_success()); |
| 138 EXPECT_EQ(kTestData, delegate_.data_received()); | 139 EXPECT_EQ(kTestData, delegate_.data_received()); |
| 139 } | 140 } |
| 140 | 141 |
| 141 } // namespace net | 142 } // namespace net |
| OLD | NEW |