| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/message_loop/message_loop.h" | 5 #include "base/message_loop/message_loop.h" |
| 6 #include "base/test/test_simple_task_runner.h" | 6 #include "base/test/test_simple_task_runner.h" |
| 7 #include "content/browser/streams/stream.h" | 7 #include "content/browser/streams/stream.h" |
| 8 #include "content/browser/streams/stream_registry.h" | 8 #include "content/browser/streams/stream_registry.h" |
| 9 #include "content/browser/streams/stream_url_request_job.h" | 9 #include "content/browser/streams/stream_url_request_job.h" |
| 10 #include "content/browser/streams/stream_write_observer.h" | 10 #include "content/browser/streams/stream_write_observer.h" |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 44 scoped_refptr<Stream> stream = registry_->GetStream(request->url()); | 44 scoped_refptr<Stream> stream = registry_->GetStream(request->url()); |
| 45 if (stream.get()) | 45 if (stream.get()) |
| 46 return new StreamURLRequestJob(request, network_delegate, stream); | 46 return new StreamURLRequestJob(request, network_delegate, stream); |
| 47 return NULL; | 47 return NULL; |
| 48 } | 48 } |
| 49 | 49 |
| 50 private: | 50 private: |
| 51 StreamRegistry* registry_; | 51 StreamRegistry* registry_; |
| 52 }; | 52 }; |
| 53 | 53 |
| 54 StreamURLRequestJobTest() : message_loop_(base::MessageLoop::TYPE_IO) {} | 54 StreamURLRequestJobTest() {} |
| 55 | 55 |
| 56 virtual void SetUp() { | 56 virtual void SetUp() { |
| 57 registry_.reset(new StreamRegistry()); | 57 registry_.reset(new StreamRegistry()); |
| 58 | 58 |
| 59 url_request_job_factory_.SetProtocolHandler( | 59 url_request_job_factory_.SetProtocolHandler( |
| 60 "blob", new MockProtocolHandler(registry_.get())); | 60 "blob", new MockProtocolHandler(registry_.get())); |
| 61 url_request_context_.set_job_factory(&url_request_job_factory_); | 61 url_request_context_.set_job_factory(&url_request_job_factory_); |
| 62 } | 62 } |
| 63 | 63 |
| 64 virtual void TearDown() { | 64 virtual void TearDown() { |
| (...skipping 21 matching lines...) Expand all Loading... |
| 86 | 86 |
| 87 // Verify response. | 87 // Verify response. |
| 88 EXPECT_TRUE(request_->status().is_success()); | 88 EXPECT_TRUE(request_->status().is_success()); |
| 89 ASSERT_TRUE(request_->response_headers()); | 89 ASSERT_TRUE(request_->response_headers()); |
| 90 EXPECT_EQ(expected_status_code, | 90 EXPECT_EQ(expected_status_code, |
| 91 request_->response_headers()->response_code()); | 91 request_->response_headers()->response_code()); |
| 92 EXPECT_EQ(expected_response, delegate.data_received()); | 92 EXPECT_EQ(expected_response, delegate.data_received()); |
| 93 } | 93 } |
| 94 | 94 |
| 95 protected: | 95 protected: |
| 96 base::MessageLoop message_loop_; | 96 base::MessageLoopForIO message_loop_; |
| 97 scoped_ptr<StreamRegistry> registry_; | 97 scoped_ptr<StreamRegistry> registry_; |
| 98 | 98 |
| 99 net::URLRequestContext url_request_context_; | 99 net::URLRequestContext url_request_context_; |
| 100 net::URLRequestJobFactoryImpl url_request_job_factory_; | 100 net::URLRequestJobFactoryImpl url_request_job_factory_; |
| 101 scoped_ptr<net::URLRequest> request_; | 101 scoped_ptr<net::URLRequest> request_; |
| 102 }; | 102 }; |
| 103 | 103 |
| 104 TEST_F(StreamURLRequestJobTest, TestGetSimpleDataRequest) { | 104 TEST_F(StreamURLRequestJobTest, TestGetSimpleDataRequest) { |
| 105 scoped_refptr<Stream> stream( | 105 scoped_refptr<Stream> stream( |
| 106 new Stream(registry_.get(), NULL, kStreamURL)); | 106 new Stream(registry_.get(), NULL, kStreamURL)); |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 171 stream->AddData(buffer, buffer->size()); | 171 stream->AddData(buffer, buffer->size()); |
| 172 stream->Finalize(); | 172 stream->Finalize(); |
| 173 | 173 |
| 174 net::HttpRequestHeaders extra_headers; | 174 net::HttpRequestHeaders extra_headers; |
| 175 extra_headers.SetHeader(net::HttpRequestHeaders::kRange, | 175 extra_headers.SetHeader(net::HttpRequestHeaders::kRange, |
| 176 net::HttpByteRange::Bounded(1, 3).GetHeaderValue()); | 176 net::HttpByteRange::Bounded(1, 3).GetHeaderValue()); |
| 177 TestRequest("GET", kStreamURL, extra_headers, 405, std::string()); | 177 TestRequest("GET", kStreamURL, extra_headers, 405, std::string()); |
| 178 } | 178 } |
| 179 | 179 |
| 180 } // namespace content | 180 } // namespace content |
| OLD | NEW |