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

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

Issue 269002: Report stalled event correctly for <video> (Closed)
Patch Set: comments Created 11 years, 2 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
OLDNEW
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/string_util.h" 7 #include "base/string_util.h"
8 #include "media/base/filters.h" 8 #include "media/base/filters.h"
9 #include "media/base/mock_filter_host.h" 9 #include "media/base/mock_filter_host.h"
10 #include "media/base/mock_filters.h" 10 #include "media/base/mock_filters.h"
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
75 first_position_, last_position_); 75 first_position_, last_position_);
76 EXPECT_EQ(gurl_.spec(), loader_->GetURLForDebugging()); 76 EXPECT_EQ(gurl_.spec(), loader_->GetURLForDebugging());
77 } 77 }
78 78
79 void Start() { 79 void Start() {
80 InSequence s; 80 InSequence s;
81 EXPECT_CALL(bridge_factory_, 81 EXPECT_CALL(bridge_factory_,
82 CreateBridge(gurl_, _, first_position_, last_position_)) 82 CreateBridge(gurl_, _, first_position_, last_position_))
83 .WillOnce(Return(bridge_.get())); 83 .WillOnce(Return(bridge_.get()));
84 EXPECT_CALL(*bridge_, Start(loader_.get())); 84 EXPECT_CALL(*bridge_, Start(loader_.get()));
85 loader_->Start(NewCallback(this, 85 loader_->Start(
86 &BufferedResourceLoaderTest::StartCallback)); 86 NewCallback(this, &BufferedResourceLoaderTest::StartCallback),
87 NewCallback(this, &BufferedResourceLoaderTest::NetworkCallback));
87 } 88 }
88 89
89 void FullResponse(int64 instance_size) { 90 void FullResponse(int64 instance_size) {
90 EXPECT_CALL(*this, StartCallback(net::OK)); 91 EXPECT_CALL(*this, StartCallback(net::OK));
91 ResourceLoaderBridge::ResponseInfo info; 92 ResourceLoaderBridge::ResponseInfo info;
92 std::string header = StringPrintf("HTTP/1.1 200 OK\n" 93 std::string header = StringPrintf("HTTP/1.1 200 OK\n"
93 "Content-Length: %lld", instance_size); 94 "Content-Length: %lld", instance_size);
94 replace(header.begin(), header.end(), '\n', '\0'); 95 replace(header.begin(), header.end(), '\n', '\0');
95 info.headers = new net::HttpResponseHeaders(header); 96 info.headers = new net::HttpResponseHeaders(header);
96 info.content_length = instance_size; 97 info.content_length = instance_size;
(...skipping 30 matching lines...) Expand all
127 .WillOnce(Invoke(this, &BufferedResourceLoaderTest::ReleaseBridge)); 128 .WillOnce(Invoke(this, &BufferedResourceLoaderTest::ReleaseBridge));
128 loader_->Stop(); 129 loader_->Stop();
129 } 130 }
130 131
131 void ReleaseBridge() { 132 void ReleaseBridge() {
132 bridge_.release(); 133 bridge_.release();
133 } 134 }
134 135
135 // Helper method to write to |loader_| from |data_|. 136 // Helper method to write to |loader_| from |data_|.
136 void WriteLoader(int position, int size) { 137 void WriteLoader(int position, int size) {
138 EXPECT_CALL(*this, NetworkCallback());
137 loader_->OnReceivedData(reinterpret_cast<char*>(data_ + position), size); 139 loader_->OnReceivedData(reinterpret_cast<char*>(data_ + position), size);
138 } 140 }
139 141
140 // Helper method to read from |loader_|. 142 // Helper method to read from |loader_|.
141 void ReadLoader(int64 position, int size, uint8* buffer) { 143 void ReadLoader(int64 position, int size, uint8* buffer) {
142 loader_->Read(position, size, buffer, 144 loader_->Read(position, size, buffer,
143 NewCallback(this, &BufferedResourceLoaderTest::ReadCallback)); 145 NewCallback(this, &BufferedResourceLoaderTest::ReadCallback));
144 } 146 }
145 147
146 // Verifis that data in buffer[0...size] is equal to data_[pos...pos+size]. 148 // Verifis that data in buffer[0...size] is equal to data_[pos...pos+size].
147 void VerifyBuffer(uint8* buffer, int pos, int size) { 149 void VerifyBuffer(uint8* buffer, int pos, int size) {
148 EXPECT_EQ(0, memcmp(buffer, data_ + pos, size)); 150 EXPECT_EQ(0, memcmp(buffer, data_ + pos, size));
149 } 151 }
150 152
151 MOCK_METHOD1(StartCallback, void(int error)); 153 MOCK_METHOD1(StartCallback, void(int error));
152 MOCK_METHOD1(ReadCallback, void(int error)); 154 MOCK_METHOD1(ReadCallback, void(int error));
155 MOCK_METHOD0(NetworkCallback, void());
153 156
154 protected: 157 protected:
155 GURL gurl_; 158 GURL gurl_;
156 int64 first_position_; 159 int64 first_position_;
157 int64 last_position_; 160 int64 last_position_;
158 161
159 scoped_refptr<BufferedResourceLoader> loader_; 162 scoped_refptr<BufferedResourceLoader> loader_;
160 StrictMock<MockMediaResourceLoaderBridgeFactory> bridge_factory_; 163 StrictMock<MockMediaResourceLoaderBridgeFactory> bridge_factory_;
161 scoped_ptr<StrictMock<MockResourceLoaderBridge> > bridge_; 164 scoped_ptr<StrictMock<MockResourceLoaderBridge> > bridge_;
162 165
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
275 // Read backward within buffer. 278 // Read backward within buffer.
276 EXPECT_CALL(*this, ReadCallback(10)); 279 EXPECT_CALL(*this, ReadCallback(10));
277 ReadLoader(10, 10, buffer); 280 ReadLoader(10, 10, buffer);
278 VerifyBuffer(buffer, 10, 10); 281 VerifyBuffer(buffer, 10, 10);
279 282
280 // Read backward outside buffer. 283 // Read backward outside buffer.
281 EXPECT_CALL(*this, ReadCallback(net::ERR_CACHE_MISS)); 284 EXPECT_CALL(*this, ReadCallback(net::ERR_CACHE_MISS));
282 ReadLoader(9, 10, buffer); 285 ReadLoader(9, 10, buffer);
283 286
284 // Response has completed. 287 // Response has completed.
288 EXPECT_CALL(*this, NetworkCallback());
285 EXPECT_CALL(*bridge_, OnDestroy()) 289 EXPECT_CALL(*bridge_, OnDestroy())
286 .WillOnce(Invoke(this, &BufferedResourceLoaderTest::ReleaseBridge)); 290 .WillOnce(Invoke(this, &BufferedResourceLoaderTest::ReleaseBridge));
287 URLRequestStatus status; 291 URLRequestStatus status;
288 status.set_status(URLRequestStatus::SUCCESS); 292 status.set_status(URLRequestStatus::SUCCESS);
289 loader_->OnCompletedRequest(status, ""); 293 loader_->OnCompletedRequest(status, "");
290 294
291 // Try to read 10 from position 25 will just return with 5 bytes. 295 // Try to read 10 from position 25 will just return with 5 bytes.
292 EXPECT_CALL(*this, ReadCallback(5)); 296 EXPECT_CALL(*this, ReadCallback(5));
293 ReadLoader(25, 10, buffer); 297 ReadLoader(25, 10, buffer);
294 VerifyBuffer(buffer, 25, 5); 298 VerifyBuffer(buffer, 25, 5);
(...skipping 25 matching lines...) Expand all
320 324
321 // Writing to loader will fulfill the read request. 325 // Writing to loader will fulfill the read request.
322 EXPECT_CALL(*this, ReadCallback(10)); 326 EXPECT_CALL(*this, ReadCallback(10));
323 WriteLoader(10, 20); 327 WriteLoader(10, 20);
324 VerifyBuffer(buffer, 10, 10); 328 VerifyBuffer(buffer, 10, 10);
325 329
326 // The following call cannot be fulfilled now. 330 // The following call cannot be fulfilled now.
327 ReadLoader(25, 10, buffer); 331 ReadLoader(25, 10, buffer);
328 332
329 EXPECT_CALL(*this, ReadCallback(5)); 333 EXPECT_CALL(*this, ReadCallback(5));
334 EXPECT_CALL(*this, NetworkCallback());
330 EXPECT_CALL(*bridge_, OnDestroy()) 335 EXPECT_CALL(*bridge_, OnDestroy())
331 .WillOnce(Invoke(this, &BufferedResourceLoaderTest::ReleaseBridge)); 336 .WillOnce(Invoke(this, &BufferedResourceLoaderTest::ReleaseBridge));
332 URLRequestStatus status; 337 URLRequestStatus status;
333 status.set_status(URLRequestStatus::SUCCESS); 338 status.set_status(URLRequestStatus::SUCCESS);
334 loader_->OnCompletedRequest(status, ""); 339 loader_->OnCompletedRequest(status, "");
335 } 340 }
336 341
337 TEST_F(BufferedResourceLoaderTest, RequestFailedWhenRead) { 342 TEST_F(BufferedResourceLoaderTest, RequestFailedWhenRead) {
338 Initialize(kHttpUrl, 10, 29); 343 Initialize(kHttpUrl, 10, 29);
339 Start(); 344 Start();
340 PartialResponse(10, 29, 30); 345 PartialResponse(10, 29, 30);
341 346
342 uint8 buffer[10]; 347 uint8 buffer[10];
343 InSequence s; 348 InSequence s;
344 349
345 ReadLoader(10, 10, buffer); 350 ReadLoader(10, 10, buffer);
346 EXPECT_CALL(*this, ReadCallback(net::ERR_FAILED)); 351 EXPECT_CALL(*this, ReadCallback(net::ERR_FAILED));
352 EXPECT_CALL(*this, NetworkCallback());
347 EXPECT_CALL(*bridge_, OnDestroy()) 353 EXPECT_CALL(*bridge_, OnDestroy())
348 .WillOnce(Invoke(this, &BufferedResourceLoaderTest::ReleaseBridge)); 354 .WillOnce(Invoke(this, &BufferedResourceLoaderTest::ReleaseBridge));
349 URLRequestStatus status; 355 URLRequestStatus status;
350 status.set_status(URLRequestStatus::FAILED); 356 status.set_status(URLRequestStatus::FAILED);
351 loader_->OnCompletedRequest(status, ""); 357 loader_->OnCompletedRequest(status, "");
352 } 358 }
353 359
354 // TODO(hclam): add unit test for defer loading. 360 // TODO(hclam): add unit test for defer loading.
355 361
356 class MockBufferedResourceLoader : public BufferedResourceLoader { 362 class MockBufferedResourceLoader : public BufferedResourceLoader {
357 public: 363 public:
358 MockBufferedResourceLoader() : BufferedResourceLoader() { 364 MockBufferedResourceLoader() : BufferedResourceLoader() {
359 } 365 }
360 366
361 MOCK_METHOD1(Start, void(net::CompletionCallback* read_callback)); 367 MOCK_METHOD2(Start, void(net::CompletionCallback* read_callback,
368 NetworkEventCallback* network_callback));
362 MOCK_METHOD0(Stop, void()); 369 MOCK_METHOD0(Stop, void());
363 MOCK_METHOD4(Read, void(int64 position, int read_size, uint8* buffer, 370 MOCK_METHOD4(Read, void(int64 position, int read_size, uint8* buffer,
364 net::CompletionCallback* callback)); 371 net::CompletionCallback* callback));
365 MOCK_METHOD0(content_length, int64()); 372 MOCK_METHOD0(content_length, int64());
366 MOCK_METHOD0(instance_size, int64()); 373 MOCK_METHOD0(instance_size, int64());
367 MOCK_METHOD0(partial_response, bool()); 374 MOCK_METHOD0(partial_response, bool());
375 MOCK_METHOD0(network_activity, bool());
376 MOCK_METHOD0(GetBufferedFirstBytePosition, int64());
377 MOCK_METHOD0(GetBufferedLastBytePosition, int64());
368 378
369 private: 379 private:
370 DISALLOW_COPY_AND_ASSIGN(MockBufferedResourceLoader); 380 DISALLOW_COPY_AND_ASSIGN(MockBufferedResourceLoader);
371 }; 381 };
372 382
373 // A mock BufferedDataSource to inject mock BufferedResourceLoader through 383 // A mock BufferedDataSource to inject mock BufferedResourceLoader through
374 // CreateLoader() method. 384 // CreateResourceLoader() method.
375 class MockBufferedDataSource : public BufferedDataSource { 385 class MockBufferedDataSource : public BufferedDataSource {
376 public: 386 public:
377 // Static methods for creating this class. 387 // Static methods for creating this class.
378 static media::FilterFactory* CreateFactory( 388 static media::FilterFactory* CreateFactory(
379 MessageLoop* message_loop, 389 MessageLoop* message_loop,
380 MediaResourceLoaderBridgeFactory* bridge_factory) { 390 MediaResourceLoaderBridgeFactory* bridge_factory) {
381 return new media::FilterFactoryImpl2< 391 return new media::FilterFactoryImpl2<
382 MockBufferedDataSource, 392 MockBufferedDataSource,
383 MessageLoop*, 393 MessageLoop*,
384 MediaResourceLoaderBridgeFactory*>(message_loop, 394 MediaResourceLoaderBridgeFactory*>(message_loop,
385 bridge_factory); 395 bridge_factory);
386 } 396 }
387 397
388 virtual base::TimeDelta GetTimeoutMilliseconds() { 398 virtual base::TimeDelta GetTimeoutMilliseconds() {
389 // It is 100 ms because we don't want the test to run too long. 399 // It is 100 ms because we don't want the test to run too long.
390 return base::TimeDelta::FromMilliseconds(100); 400 return base::TimeDelta::FromMilliseconds(100);
391 } 401 }
392 402
393 MOCK_METHOD2(CreateLoader, BufferedResourceLoader*(int64 first_position, 403 MOCK_METHOD2(CreateResourceLoader, BufferedResourceLoader*(
394 int64 last_position)); 404 int64 first_position, int64 last_position));
395 405
396 protected: 406 protected:
397 MockBufferedDataSource( 407 MockBufferedDataSource(
398 MessageLoop* message_loop, 408 MessageLoop* message_loop, MediaResourceLoaderBridgeFactory* factory)
399 MediaResourceLoaderBridgeFactory* factory)
400 : BufferedDataSource(message_loop, factory) { 409 : BufferedDataSource(message_loop, factory) {
401 } 410 }
402 411
403 private: 412 private:
404 friend class media::FilterFactoryImpl2< 413 friend class media::FilterFactoryImpl2<
405 MockBufferedDataSource, 414 MockBufferedDataSource,
406 MessageLoop*, 415 MessageLoop*,
407 MediaResourceLoaderBridgeFactory*>; 416 MediaResourceLoaderBridgeFactory*>;
408 417
409 DISALLOW_COPY_AND_ASSIGN(MockBufferedDataSource); 418 DISALLOW_COPY_AND_ASSIGN(MockBufferedDataSource);
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
452 461
453 // There is no need to provide a message loop to data source. 462 // There is no need to provide a message loop to data source.
454 data_source_->set_host(&host_); 463 data_source_->set_host(&host_);
455 464
456 // Creates the mock loader to be injected. 465 // Creates the mock loader to be injected.
457 loader_ = new StrictMock<MockBufferedResourceLoader>(); 466 loader_ = new StrictMock<MockBufferedResourceLoader>();
458 467
459 bool loaded = networkState == LOADED; 468 bool loaded = networkState == LOADED;
460 { 469 {
461 InSequence s; 470 InSequence s;
462 EXPECT_CALL(*data_source_, CreateLoader(_, _)) 471 EXPECT_CALL(*data_source_, CreateResourceLoader(_, _))
463 .WillOnce(Return(loader_.get())); 472 .WillOnce(Return(loader_.get()));
464 473
465 // The initial response loader will be started. 474 // The initial response loader will be started.
466 EXPECT_CALL(*loader_, Start(NotNull())) 475 EXPECT_CALL(*loader_, Start(NotNull(), NotNull()))
467 .WillOnce( 476 .WillOnce(
468 DoAll(Assign(&error_, error), 477 DoAll(Assign(&error_, error),
469 Invoke(this, 478 Invoke(this,
470 &BufferedDataSourceTest::InvokeStartCallback))); 479 &BufferedDataSourceTest::InvokeStartCallback)));
471 } 480 }
472 481
473 StrictMock<media::MockFilterCallback> callback; 482 StrictMock<media::MockFilterCallback> callback;
483 EXPECT_CALL(*loader_, instance_size())
484 .WillRepeatedly(Return(instance_size));
485 EXPECT_CALL(*loader_, partial_response())
486 .WillRepeatedly(Return(partial_response));
474 if (error == net::OK) { 487 if (error == net::OK) {
475 // Expected loaded or not. 488 // Expected loaded or not.
476 EXPECT_CALL(host_, SetLoaded(loaded)); 489 EXPECT_CALL(host_, SetLoaded(loaded));
477 EXPECT_CALL(*loader_, instance_size())
478 .WillRepeatedly(Return(instance_size));
479 EXPECT_CALL(*loader_, partial_response())
480 .WillRepeatedly(Return(partial_response));
481 490
482 // TODO(hclam): The condition for streaming needs to be adjusted. 491 // TODO(hclam): The condition for streaming needs to be adjusted.
483 if (instance_size != -1 && (loaded || partial_response)) { 492 if (instance_size != -1 && (loaded || partial_response)) {
484 EXPECT_CALL(host_, SetTotalBytes(instance_size)); 493 EXPECT_CALL(host_, SetTotalBytes(instance_size));
485 EXPECT_CALL(host_, SetBufferedBytes(instance_size)); 494 if (loaded)
495 EXPECT_CALL(host_, SetBufferedBytes(instance_size));
496 else
497 EXPECT_CALL(host_, SetBufferedBytes(0));
486 } else { 498 } else {
487 EXPECT_CALL(host_, SetStreaming(true)); 499 EXPECT_CALL(host_, SetStreaming(true));
488 } 500 }
489 501
490 EXPECT_CALL(callback, OnFilterCallback()); 502 EXPECT_CALL(callback, OnFilterCallback());
491 EXPECT_CALL(callback, OnCallbackDestroyed()); 503 EXPECT_CALL(callback, OnCallbackDestroyed());
492 } else { 504 } else {
493 EXPECT_CALL(host_, SetError(media::PIPELINE_ERROR_NETWORK)); 505 EXPECT_CALL(host_, SetError(media::PIPELINE_ERROR_NETWORK));
494 EXPECT_CALL(*loader_, Stop()); 506 EXPECT_CALL(*loader_, Stop());
495 EXPECT_CALL(callback, OnFilterCallback()); 507 EXPECT_CALL(callback, OnFilterCallback());
(...skipping 23 matching lines...) Expand all
519 } 531 }
520 532
521 data_source_->Stop(); 533 data_source_->Stop();
522 message_loop_->RunAllPending(); 534 message_loop_->RunAllPending();
523 } 535 }
524 536
525 void ReleaseBridgeFactory() { 537 void ReleaseBridgeFactory() {
526 bridge_factory_.release(); 538 bridge_factory_.release();
527 } 539 }
528 540
529 void InvokeStartCallback(net::CompletionCallback* callback) { 541 void InvokeStartCallback(
542 net::CompletionCallback* callback,
543 BufferedResourceLoader::NetworkEventCallback* network_callback) {
530 callback->RunWithParams(Tuple1<int>(error_)); 544 callback->RunWithParams(Tuple1<int>(error_));
531 delete callback; 545 delete callback;
546 // TODO(hclam): Save this callback.
547 delete network_callback;
532 } 548 }
533 549
534 void InvokeReadCallback(int64 position, int size, uint8* buffer, 550 void InvokeReadCallback(int64 position, int size, uint8* buffer,
535 net::CompletionCallback* callback) { 551 net::CompletionCallback* callback) {
536 if (error_ > 0) 552 if (error_ > 0)
537 memcpy(buffer, data_ + static_cast<int>(position), error_); 553 memcpy(buffer, data_ + static_cast<int>(position), error_);
538 callback->RunWithParams(Tuple1<int>(error_)); 554 callback->RunWithParams(Tuple1<int>(error_));
539 delete callback; 555 delete callback;
540 } 556 }
541 557
(...skipping 29 matching lines...) Expand all
571 EXPECT_CALL(*loader_, Read(position, size, NotNull(), NotNull())) 587 EXPECT_CALL(*loader_, Read(position, size, NotNull(), NotNull()))
572 .WillOnce(DoAll(Assign(&error_, net::ERR_CACHE_MISS), 588 .WillOnce(DoAll(Assign(&error_, net::ERR_CACHE_MISS),
573 Invoke(this, 589 Invoke(this,
574 &BufferedDataSourceTest::InvokeReadCallback))); 590 &BufferedDataSourceTest::InvokeReadCallback)));
575 EXPECT_CALL(*loader_, Stop()); 591 EXPECT_CALL(*loader_, Stop());
576 } 592 }
577 593
578 // 2. Then the current loader will be stop and destroyed. 594 // 2. Then the current loader will be stop and destroyed.
579 StrictMock<MockBufferedResourceLoader> *new_loader = 595 StrictMock<MockBufferedResourceLoader> *new_loader =
580 new StrictMock<MockBufferedResourceLoader>(); 596 new StrictMock<MockBufferedResourceLoader>();
581 EXPECT_CALL(*data_source_, CreateLoader(position, -1)) 597 EXPECT_CALL(*data_source_, CreateResourceLoader(position, -1))
582 .WillOnce(Return(new_loader)); 598 .WillOnce(Return(new_loader));
583 599
584 // 3. Then the new loader will be started. 600 // 3. Then the new loader will be started.
585 EXPECT_CALL(*new_loader, Start(NotNull())) 601 EXPECT_CALL(*new_loader, Start(NotNull(), NotNull()))
586 .WillOnce(DoAll(Assign(&error_, net::OK), 602 .WillOnce(DoAll(Assign(&error_, net::OK),
587 Invoke(this, 603 Invoke(this,
588 &BufferedDataSourceTest::InvokeStartCallback))); 604 &BufferedDataSourceTest::InvokeStartCallback)));
589 EXPECT_CALL(*new_loader, partial_response()) 605 EXPECT_CALL(*new_loader, partial_response())
590 .WillRepeatedly(Return(loader_->partial_response())); 606 .WillRepeatedly(Return(loader_->partial_response()));
591 607
592 // 4. Then again a read request is made to the new loader. 608 // 4. Then again a read request is made to the new loader.
593 EXPECT_CALL(*new_loader, Read(position, size, NotNull(), NotNull())) 609 EXPECT_CALL(*new_loader, Read(position, size, NotNull(), NotNull()))
594 .WillOnce(DoAll(Assign(&error_, size), 610 .WillOnce(DoAll(Assign(&error_, size),
595 Invoke(this, 611 Invoke(this,
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
635 { 651 {
636 InSequence s; 652 InSequence s;
637 EXPECT_CALL(*loader_, Read(position, size, NotNull(), NotNull())) 653 EXPECT_CALL(*loader_, Read(position, size, NotNull(), NotNull()))
638 .WillOnce(DeleteArg<3>()); 654 .WillOnce(DeleteArg<3>());
639 EXPECT_CALL(*loader_, Stop()); 655 EXPECT_CALL(*loader_, Stop());
640 } 656 }
641 657
642 // 2. Then the current loader will be stop and destroyed. 658 // 2. Then the current loader will be stop and destroyed.
643 StrictMock<MockBufferedResourceLoader> *new_loader = 659 StrictMock<MockBufferedResourceLoader> *new_loader =
644 new StrictMock<MockBufferedResourceLoader>(); 660 new StrictMock<MockBufferedResourceLoader>();
645 EXPECT_CALL(*data_source_, CreateLoader(position, -1)) 661 EXPECT_CALL(*data_source_, CreateResourceLoader(position, -1))
646 .WillOnce(Return(new_loader)); 662 .WillOnce(Return(new_loader));
647 663
648 // 3. Then the new loader will be started and respond to queries about 664 // 3. Then the new loader will be started and respond to queries about
649 // whether this is a partial response using the value of the previous 665 // whether this is a partial response using the value of the previous
650 // loader. 666 // loader.
651 EXPECT_CALL(*new_loader, Start(NotNull())) 667 EXPECT_CALL(*new_loader, Start(NotNull(), NotNull()))
652 .WillOnce(DoAll(Assign(&error_, net::OK), 668 .WillOnce(DoAll(Assign(&error_, net::OK),
653 Invoke(this, 669 Invoke(this,
654 &BufferedDataSourceTest::InvokeStartCallback))); 670 &BufferedDataSourceTest::InvokeStartCallback)));
655 EXPECT_CALL(*new_loader, partial_response()) 671 EXPECT_CALL(*new_loader, partial_response())
656 .WillRepeatedly(Return(loader_->partial_response())); 672 .WillRepeatedly(Return(loader_->partial_response()));
657 673
658 // 4. Then again a read request is made to the new loader. 674 // 4. Then again a read request is made to the new loader.
659 EXPECT_CALL(*new_loader, Read(position, size, NotNull(), NotNull())) 675 EXPECT_CALL(*new_loader, Read(position, size, NotNull(), NotNull()))
660 .WillOnce(DoAll(Assign(&error_, size), 676 .WillOnce(DoAll(Assign(&error_, size),
661 Invoke(this, 677 Invoke(this,
(...skipping 15 matching lines...) Expand all
677 EXPECT_EQ(0, memcmp(buffer_, data_ + static_cast<int>(position), size)); 693 EXPECT_EQ(0, memcmp(buffer_, data_ + static_cast<int>(position), size));
678 694
679 loader_ = new_loader; 695 loader_ = new_loader;
680 } 696 }
681 697
682 MOCK_METHOD1(ReadCallback, void(size_t size)); 698 MOCK_METHOD1(ReadCallback, void(size_t size));
683 699
684 scoped_ptr<StrictMock<MockMediaResourceLoaderBridgeFactory> > 700 scoped_ptr<StrictMock<MockMediaResourceLoaderBridgeFactory> >
685 bridge_factory_; 701 bridge_factory_;
686 scoped_refptr<StrictMock<MockBufferedResourceLoader> > loader_; 702 scoped_refptr<StrictMock<MockBufferedResourceLoader> > loader_;
687 scoped_refptr<MockBufferedDataSource > data_source_; 703 scoped_refptr<MockBufferedDataSource> data_source_;
688 scoped_refptr<media::FilterFactory> factory_; 704 scoped_refptr<media::FilterFactory> factory_;
689 705
690 StrictMock<media::MockFilterHost> host_; 706 StrictMock<media::MockFilterHost> host_;
691 GURL gurl_; 707 GURL gurl_;
692 scoped_ptr<MessageLoop> message_loop_; 708 scoped_ptr<MessageLoop> message_loop_;
693 709
694 int error_; 710 int error_;
695 uint8 buffer_[1024]; 711 uint8 buffer_[1024];
696 uint8 data_[1024]; 712 uint8 data_[1024];
697 713
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
757 StopDataSource(); 773 StopDataSource();
758 } 774 }
759 775
760 TEST_F(BufferedDataSourceTest, FileHasLoadedState) { 776 TEST_F(BufferedDataSourceTest, FileHasLoadedState) {
761 InitializeDataSource(kFileUrl, net::OK, true, 1024, LOADED); 777 InitializeDataSource(kFileUrl, net::OK, true, 1024, LOADED);
762 ReadDataSourceTimesOut(20, 10); 778 ReadDataSourceTimesOut(20, 10);
763 StopDataSource(); 779 StopDataSource();
764 } 780 }
765 781
766 } // namespace webkit_glue 782 } // namespace webkit_glue
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698