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

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

Issue 1796973004: Improve retry support for media network loading. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@2661
Patch Set: Created 4 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
« no previous file with comments | « media/blink/buffered_data_source.cc ('k') | media/blink/multibuffer_data_source_unittest.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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 <stdint.h> 5 #include <stdint.h>
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/macros.h" 8 #include "base/macros.h"
9 #include "base/message_loop/message_loop.h" 9 #include "base/message_loop/message_loop.h"
10 #include "base/run_loop.h" 10 #include "base/run_loop.h"
(...skipping 615 matching lines...) Expand 10 before | Expand all | Expand 10 after
626 EXPECT_TRUE(data_source_->loading()); 626 EXPECT_TRUE(data_source_->loading());
627 Stop(); 627 Stop();
628 } 628 }
629 629
630 TEST_F(BufferedDataSourceTest, Http_TooManyRetries) { 630 TEST_F(BufferedDataSourceTest, Http_TooManyRetries) {
631 InitializeWith206Response(); 631 InitializeWith206Response();
632 632
633 // Make sure there's a pending read -- we'll expect it to error. 633 // Make sure there's a pending read -- we'll expect it to error.
634 ReadAt(0); 634 ReadAt(0);
635 635
636 // It'll try three times. 636 for (int i = 0; i < BufferedDataSource::kLoaderRetries; i++) {
637 ExpectCreateResourceLoader(); 637 ExpectCreateResourceLoader();
638 FinishLoading(); 638 FinishLoading();
639 Respond(response_generator_->Generate206(0)); 639 Respond(response_generator_->Generate206(0));
640 640 }
641 ExpectCreateResourceLoader();
642 FinishLoading();
643 Respond(response_generator_->Generate206(0));
644
645 ExpectCreateResourceLoader();
646 FinishLoading();
647 Respond(response_generator_->Generate206(0));
648 641
649 // It'll error after this. 642 // It'll error after this.
650 EXPECT_CALL(*this, ReadCallback(media::DataSource::kReadError)); 643 EXPECT_CALL(*this, ReadCallback(media::DataSource::kReadError));
651 FinishLoading(); 644 FinishLoading();
652 645
653 EXPECT_FALSE(data_source_->loading()); 646 EXPECT_FALSE(data_source_->loading());
654 Stop(); 647 Stop();
655 } 648 }
656 649
657 TEST_F(BufferedDataSourceTest, File_TooManyRetries) { 650 TEST_F(BufferedDataSourceTest, File_TooManyRetries) {
658 InitializeWithFileResponse(); 651 InitializeWithFileResponse();
659 652
660 // Make sure there's a pending read -- we'll expect it to error. 653 // Make sure there's a pending read -- we'll expect it to error.
661 ReadAt(0); 654 ReadAt(0);
662 655
663 // It'll try three times. 656 for (int i = 0; i < BufferedDataSource::kLoaderRetries; i++) {
664 ExpectCreateResourceLoader(); 657 ExpectCreateResourceLoader();
665 FinishLoading(); 658 FinishLoading();
666 Respond(response_generator_->GenerateFileResponse(0)); 659 Respond(response_generator_->GenerateFileResponse(0));
667 660 }
668 ExpectCreateResourceLoader();
669 FinishLoading();
670 Respond(response_generator_->GenerateFileResponse(0));
671
672 ExpectCreateResourceLoader();
673 FinishLoading();
674 Respond(response_generator_->GenerateFileResponse(0));
675 661
676 // It'll error after this. 662 // It'll error after this.
677 EXPECT_CALL(*this, ReadCallback(media::DataSource::kReadError)); 663 EXPECT_CALL(*this, ReadCallback(media::DataSource::kReadError));
678 FinishLoading(); 664 FinishLoading();
679 665
680 EXPECT_FALSE(data_source_->loading()); 666 EXPECT_FALSE(data_source_->loading());
681 Stop(); 667 Stop();
682 } 668 }
683 669
684 TEST_F(BufferedDataSourceTest, File_InstanceSizeUnknown) { 670 TEST_F(BufferedDataSourceTest, File_InstanceSizeUnknown) {
(...skipping 335 matching lines...) Expand 10 before | Expand all | Expand 10 after
1020 // Read a bit from the beginning. 1006 // Read a bit from the beginning.
1021 ReadAt(0); 1007 ReadAt(0);
1022 EXPECT_CALL(*this, ReadCallback(kDataSize)); 1008 EXPECT_CALL(*this, ReadCallback(kDataSize));
1023 EXPECT_CALL(host_, AddBufferedByteRange(0, kDataSize - 1)); 1009 EXPECT_CALL(host_, AddBufferedByteRange(0, kDataSize - 1));
1024 ReceiveData(kDataSize); 1010 ReceiveData(kDataSize);
1025 1011
1026 EXPECT_FALSE(active_loader()); 1012 EXPECT_FALSE(active_loader());
1027 } 1013 }
1028 1014
1029 } // namespace media 1015 } // namespace media
OLDNEW
« no previous file with comments | « media/blink/buffered_data_source.cc ('k') | media/blink/multibuffer_data_source_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698