| 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/memory/scoped_ptr.h" |
| 6 #include "base/run_loop.h" | 6 #include "base/run_loop.h" |
| 7 #include "base/strings/stringprintf.h" | 7 #include "base/strings/stringprintf.h" |
| 8 #include "net/base/request_priority.h" | 8 #include "net/base/request_priority.h" |
| 9 #include "net/url_request/url_request_job.h" | 9 #include "net/url_request/url_request_job.h" |
| 10 #include "net/url_request/url_request_job_factory.h" | 10 #include "net/url_request/url_request_job_factory.h" |
| 11 #include "net/url_request/url_request_job_factory_impl.h" | 11 #include "net/url_request/url_request_job_factory_impl.h" |
| 12 #include "net/url_request/url_request_simple_job.h" | 12 #include "net/url_request/url_request_simple_job.h" |
| 13 #include "net/url_request/url_request_test_util.h" | 13 #include "net/url_request/url_request_test_util.h" |
| 14 #include "testing/gtest/include/gtest/gtest.h" | 14 #include "testing/gtest/include/gtest/gtest.h" |
| 15 | 15 |
| 16 namespace net { | 16 namespace net { |
| 17 | 17 |
| 18 namespace { | 18 namespace { |
| 19 | 19 |
| 20 const char kTestData[] = "Huge data array"; | 20 const char kTestData[] = "Huge data array"; |
| 21 const int kRangeFirstPosition = 5; | 21 const int kRangeFirstPosition = 5; |
| 22 const int kRangeLastPosition = 8; | 22 const int kRangeLastPosition = 8; |
| 23 COMPILE_ASSERT(kRangeFirstPosition > 0 && | 23 static_assert(kRangeFirstPosition > 0 && |
| 24 kRangeFirstPosition < kRangeLastPosition && | 24 kRangeFirstPosition < kRangeLastPosition && |
| 25 kRangeLastPosition < static_cast<int>(arraysize(kTestData) - 1), | 25 kRangeLastPosition < |
| 26 invalid_range); | 26 static_cast<int>(arraysize(kTestData) - 1), |
| 27 "invalid range"); |
| 27 | 28 |
| 28 class MockSimpleJob : public URLRequestSimpleJob { | 29 class MockSimpleJob : public URLRequestSimpleJob { |
| 29 public: | 30 public: |
| 30 MockSimpleJob(URLRequest* request, NetworkDelegate* network_delegate) | 31 MockSimpleJob(URLRequest* request, NetworkDelegate* network_delegate) |
| 31 : URLRequestSimpleJob(request, network_delegate) { | 32 : URLRequestSimpleJob(request, network_delegate) { |
| 32 } | 33 } |
| 33 | 34 |
| 34 protected: | 35 protected: |
| 35 int GetData(std::string* mime_type, | 36 int GetData(std::string* mime_type, |
| 36 std::string* charset, | 37 std::string* charset, |
| (...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 133 "bytes=%d-%d", kRangeLastPosition, kRangeFirstPosition); | 134 "bytes=%d-%d", kRangeLastPosition, kRangeFirstPosition); |
| 134 headers.SetHeader(HttpRequestHeaders::kRange, range); | 135 headers.SetHeader(HttpRequestHeaders::kRange, range); |
| 135 | 136 |
| 136 StartRequest(&headers); | 137 StartRequest(&headers); |
| 137 | 138 |
| 138 ASSERT_TRUE(request_->status().is_success()); | 139 ASSERT_TRUE(request_->status().is_success()); |
| 139 EXPECT_EQ(kTestData, delegate_.data_received()); | 140 EXPECT_EQ(kTestData, delegate_.data_received()); |
| 140 } | 141 } |
| 141 | 142 |
| 142 } // namespace net | 143 } // namespace net |
| OLD | NEW |