Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(382)

Side by Side Diff: webkit/media/buffered_data_source_unittest.cc

Issue 9699035: Reduce unnecessary network connections. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: acolwell CR responses. Created 8 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « webkit/media/buffered_data_source.cc ('k') | webkit/media/buffered_resource_loader.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/bind.h" 5 #include "base/bind.h"
6 #include "media/base/media_log.h" 6 #include "media/base/media_log.h"
7 #include "media/base/mock_callback.h" 7 #include "media/base/mock_callback.h"
8 #include "media/base/mock_data_source_host.h" 8 #include "media/base/mock_data_source_host.h"
9 #include "media/base/mock_filters.h" 9 #include "media/base/mock_filters.h"
10 #include "third_party/WebKit/Source/WebKit/chromium/public/WebView.h" 10 #include "third_party/WebKit/Source/WebKit/chromium/public/WebView.h"
(...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after
195 EXPECT_CALL(host_, SetTotalBytes(response_generator_.content_length())); 195 EXPECT_CALL(host_, SetTotalBytes(response_generator_.content_length()));
196 EXPECT_CALL(host_, SetBufferedBytes(0)); 196 EXPECT_CALL(host_, SetBufferedBytes(0));
197 Respond(response_generator_.Generate206(0)); 197 Respond(response_generator_.Generate206(0));
198 198
199 EXPECT_TRUE(data_source_->loading()); 199 EXPECT_TRUE(data_source_->loading());
200 Stop(); 200 Stop();
201 } 201 }
202 202
203 TEST_F(BufferedDataSourceTest, Range_NotFound) { 203 TEST_F(BufferedDataSourceTest, Range_NotFound) {
204 Initialize(media::PIPELINE_ERROR_NETWORK); 204 Initialize(media::PIPELINE_ERROR_NETWORK);
205
206 // It'll try again.
207 //
208 // TODO(scherkus): don't try again on errors http://crbug.com/105230
209 ExpectCreateResourceLoader();
210 Respond(response_generator_.Generate404());
211
212 // Now it's done and will fail.
213 Respond(response_generator_.Generate404()); 205 Respond(response_generator_.Generate404());
214 206
215 EXPECT_FALSE(data_source_->loading()); 207 EXPECT_FALSE(data_source_->loading());
216 Stop(); 208 Stop();
217 } 209 }
218 210
219 TEST_F(BufferedDataSourceTest, Range_NotSupported) { 211 TEST_F(BufferedDataSourceTest, Range_NotSupported) {
220 Initialize(media::PIPELINE_OK); 212 Initialize(media::PIPELINE_OK);
221
222 // It'll try again.
223 //
224 // TODO(scherkus): try to reuse existing connection http://crbug.com/104783
225 ExpectCreateResourceLoader();
226 Respond(response_generator_.Generate200());
227
228 // Now it'll succeed.
229 EXPECT_CALL(host_, SetTotalBytes(response_generator_.content_length())); 213 EXPECT_CALL(host_, SetTotalBytes(response_generator_.content_length()));
230 EXPECT_CALL(host_, SetBufferedBytes(0)); 214 EXPECT_CALL(host_, SetBufferedBytes(0));
231 Respond(response_generator_.Generate200()); 215 Respond(response_generator_.Generate200());
232 216
233 EXPECT_TRUE(data_source_->loading()); 217 EXPECT_TRUE(data_source_->loading());
234 EXPECT_TRUE(data_source_->IsStreaming()); 218 EXPECT_TRUE(data_source_->IsStreaming());
235 Stop(); 219 Stop();
236 } 220 }
237 221
238 TEST_F(BufferedDataSourceTest, Range_MissingContentRange) { 222 TEST_F(BufferedDataSourceTest, Range_MissingContentRange) {
239 Initialize(media::PIPELINE_ERROR_NETWORK); 223 Initialize(media::PIPELINE_ERROR_NETWORK);
240
241 // It'll try again.
242 //
243 // TODO(scherkus): don't try again on errors http://crbug.com/105230
244 ExpectCreateResourceLoader();
245 Respond(response_generator_.Generate206( 224 Respond(response_generator_.Generate206(
246 0, TestResponseGenerator::kNoContentRange)); 225 0, TestResponseGenerator::kNoContentRange));
247 226
248 // Now it's done and will fail.
249 Respond(response_generator_.Generate206(
250 0, TestResponseGenerator::kNoContentRange));
251
252 EXPECT_FALSE(data_source_->loading()); 227 EXPECT_FALSE(data_source_->loading());
253 Stop(); 228 Stop();
254 } 229 }
255 230
256 TEST_F(BufferedDataSourceTest, Range_MissingContentLength) { 231 TEST_F(BufferedDataSourceTest, Range_MissingContentLength) {
257 Initialize(media::PIPELINE_OK); 232 Initialize(media::PIPELINE_OK);
258 233
259 // It'll manage without a Content-Length response. 234 // It'll manage without a Content-Length response.
260 EXPECT_CALL(host_, SetTotalBytes(response_generator_.content_length())); 235 EXPECT_CALL(host_, SetTotalBytes(response_generator_.content_length()));
261 EXPECT_CALL(host_, SetBufferedBytes(0)); 236 EXPECT_CALL(host_, SetBufferedBytes(0));
262 Respond(response_generator_.Generate206( 237 Respond(response_generator_.Generate206(
263 0, TestResponseGenerator::kNoContentLength)); 238 0, TestResponseGenerator::kNoContentLength));
264 239
265 EXPECT_TRUE(data_source_->loading()); 240 EXPECT_TRUE(data_source_->loading());
266 Stop(); 241 Stop();
267 } 242 }
268 243
269 TEST_F(BufferedDataSourceTest, Range_WrongContentRange) { 244 TEST_F(BufferedDataSourceTest, Range_WrongContentRange) {
270 Initialize(media::PIPELINE_ERROR_NETWORK); 245 Initialize(media::PIPELINE_ERROR_NETWORK);
271 246
272 // It'll try again.
273 //
274 // TODO(scherkus): don't try again on errors http://crbug.com/105230
275 ExpectCreateResourceLoader();
276 Respond(response_generator_.Generate206(1337));
277
278 // Now it's done and will fail. 247 // Now it's done and will fail.
279 Respond(response_generator_.Generate206(1337)); 248 Respond(response_generator_.Generate206(1337));
280 249
281 EXPECT_FALSE(data_source_->loading()); 250 EXPECT_FALSE(data_source_->loading());
282 Stop(); 251 Stop();
283 } 252 }
284 253
285 // Test the case where the initial response from the server indicates that 254 // Test the case where the initial response from the server indicates that
286 // Range requests are supported, but a later request prove otherwise. 255 // Range requests are supported, but a later request prove otherwise.
287 TEST_F(BufferedDataSourceTest, Range_ServerLied) { 256 TEST_F(BufferedDataSourceTest, Range_ServerLied) {
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after
446 415
447 // During teardown we'll also report our final network status. 416 // During teardown we'll also report our final network status.
448 EXPECT_CALL(host_, SetNetworkActivity(false)); 417 EXPECT_CALL(host_, SetNetworkActivity(false));
449 EXPECT_CALL(host_, SetBufferedBytes(kDataSize)); 418 EXPECT_CALL(host_, SetBufferedBytes(kDataSize));
450 419
451 EXPECT_TRUE(data_source_->loading()); 420 EXPECT_TRUE(data_source_->loading());
452 Stop(); 421 Stop();
453 } 422 }
454 423
455 } // namespace webkit_media 424 } // namespace webkit_media
OLDNEW
« no previous file with comments | « webkit/media/buffered_data_source.cc ('k') | webkit/media/buffered_resource_loader.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698