OLD | NEW |
---|---|
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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 <algorithm> | 5 #include <algorithm> |
6 | 6 |
7 #include "base/format_macros.h" | |
7 #include "base/string_util.h" | 8 #include "base/string_util.h" |
8 #include "media/base/filters.h" | 9 #include "media/base/filters.h" |
9 #include "media/base/mock_filter_host.h" | 10 #include "media/base/mock_filter_host.h" |
10 #include "media/base/mock_filters.h" | 11 #include "media/base/mock_filters.h" |
11 #include "net/base/net_errors.h" | 12 #include "net/base/net_errors.h" |
12 #include "net/http/http_response_headers.h" | 13 #include "net/http/http_response_headers.h" |
13 #include "webkit/glue/media/buffered_data_source.h" | 14 #include "webkit/glue/media/buffered_data_source.h" |
14 #include "webkit/glue/media/mock_media_resource_loader_bridge_factory.h" | 15 #include "webkit/glue/media/mock_media_resource_loader_bridge_factory.h" |
15 #include "webkit/glue/mock_resource_loader_bridge.h" | 16 #include "webkit/glue/mock_resource_loader_bridge.h" |
16 | 17 |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
85 EXPECT_CALL(*bridge_, Start(loader_.get())); | 86 EXPECT_CALL(*bridge_, Start(loader_.get())); |
86 loader_->Start( | 87 loader_->Start( |
87 NewCallback(this, &BufferedResourceLoaderTest::StartCallback), | 88 NewCallback(this, &BufferedResourceLoaderTest::StartCallback), |
88 NewCallback(this, &BufferedResourceLoaderTest::NetworkCallback)); | 89 NewCallback(this, &BufferedResourceLoaderTest::NetworkCallback)); |
89 } | 90 } |
90 | 91 |
91 void FullResponse(int64 instance_size) { | 92 void FullResponse(int64 instance_size) { |
92 EXPECT_CALL(*this, StartCallback(net::OK)); | 93 EXPECT_CALL(*this, StartCallback(net::OK)); |
93 ResourceLoaderBridge::ResponseInfo info; | 94 ResourceLoaderBridge::ResponseInfo info; |
94 std::string header = StringPrintf("HTTP/1.1 200 OK\n" | 95 std::string header = StringPrintf("HTTP/1.1 200 OK\n" |
95 "Content-Length: %lld", instance_size); | 96 "Content-Length: %"PRId64, instance_size); |
Mark Mentovai
2009/11/18 20:55:27
spaces.
| |
96 replace(header.begin(), header.end(), '\n', '\0'); | 97 replace(header.begin(), header.end(), '\n', '\0'); |
97 info.headers = new net::HttpResponseHeaders(header); | 98 info.headers = new net::HttpResponseHeaders(header); |
98 info.content_length = instance_size; | 99 info.content_length = instance_size; |
99 loader_->OnReceivedResponse(info, false); | 100 loader_->OnReceivedResponse(info, false); |
100 EXPECT_EQ(instance_size, loader_->content_length()); | 101 EXPECT_EQ(instance_size, loader_->content_length()); |
101 EXPECT_EQ(instance_size, loader_->instance_size()); | 102 EXPECT_EQ(instance_size, loader_->instance_size()); |
102 EXPECT_FALSE(loader_->partial_response()); | 103 EXPECT_FALSE(loader_->partial_response()); |
103 } | 104 } |
104 | 105 |
105 void PartialResponse(int64 first_position, int64 last_position, | 106 void PartialResponse(int64 first_position, int64 last_position, |
106 int64 instance_size) { | 107 int64 instance_size) { |
107 EXPECT_CALL(*this, StartCallback(net::OK)); | 108 EXPECT_CALL(*this, StartCallback(net::OK)); |
108 int64 content_length = last_position - first_position + 1; | 109 int64 content_length = last_position - first_position + 1; |
109 ResourceLoaderBridge::ResponseInfo info; | 110 ResourceLoaderBridge::ResponseInfo info; |
110 std::string header = StringPrintf("HTTP/1.1 206 Partial Content\n" | 111 std::string header = StringPrintf("HTTP/1.1 206 Partial Content\n" |
111 "Content-Range: bytes %lld-%lld/%lld", | 112 "Content-Range: bytes " |
113 "%"PRId64"-%"PRId64"/%"PRId64, | |
Mark Mentovai
2009/11/18 20:55:27
spaces.
| |
112 first_position, | 114 first_position, |
113 last_position, | 115 last_position, |
114 instance_size); | 116 instance_size); |
115 replace(header.begin(), header.end(), '\n', '\0'); | 117 replace(header.begin(), header.end(), '\n', '\0'); |
116 info.headers = new net::HttpResponseHeaders(header); | 118 info.headers = new net::HttpResponseHeaders(header); |
117 info.content_length = content_length; | 119 info.content_length = content_length; |
118 loader_->OnReceivedResponse(info, false); | 120 loader_->OnReceivedResponse(info, false); |
119 EXPECT_EQ(content_length, loader_->content_length()); | 121 EXPECT_EQ(content_length, loader_->content_length()); |
120 EXPECT_EQ(instance_size, loader_->instance_size()); | 122 EXPECT_EQ(instance_size, loader_->instance_size()); |
121 EXPECT_TRUE(loader_->partial_response()); | 123 EXPECT_TRUE(loader_->partial_response()); |
(...skipping 654 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
776 StopDataSource(); | 778 StopDataSource(); |
777 } | 779 } |
778 | 780 |
779 TEST_F(BufferedDataSourceTest, FileHasLoadedState) { | 781 TEST_F(BufferedDataSourceTest, FileHasLoadedState) { |
780 InitializeDataSource(kFileUrl, net::OK, true, 1024, LOADED); | 782 InitializeDataSource(kFileUrl, net::OK, true, 1024, LOADED); |
781 ReadDataSourceTimesOut(20, 10); | 783 ReadDataSourceTimesOut(20, 10); |
782 StopDataSource(); | 784 StopDataSource(); |
783 } | 785 } |
784 | 786 |
785 } // namespace webkit_glue | 787 } // namespace webkit_glue |
OLD | NEW |