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

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

Issue 1815893002: Merge M50: "Disable "pause-and-buffer" on Android, cancel suspended players." (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.h » ('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 981 matching lines...) Expand 10 before | Expand all | Expand 10 after
992 992
993 TEST_F(BufferedDataSourceTest, ExternalResource_Response206_CancelAfterDefer) { 993 TEST_F(BufferedDataSourceTest, ExternalResource_Response206_CancelAfterDefer) {
994 set_preload(BufferedDataSource::METADATA); 994 set_preload(BufferedDataSource::METADATA);
995 InitializeWith206Response(); 995 InitializeWith206Response();
996 996
997 EXPECT_EQ(BufferedDataSource::METADATA, preload()); 997 EXPECT_EQ(BufferedDataSource::METADATA, preload());
998 EXPECT_FALSE(is_local_source()); 998 EXPECT_FALSE(is_local_source());
999 EXPECT_TRUE(loader()->range_supported()); 999 EXPECT_TRUE(loader()->range_supported());
1000 EXPECT_EQ(BufferedResourceLoader::kReadThenDefer, defer_strategy()); 1000 EXPECT_EQ(BufferedResourceLoader::kReadThenDefer, defer_strategy());
1001 1001
1002 data_source_->OnBufferingHaveEnough(); 1002 data_source_->OnBufferingHaveEnough(false);
1003 1003
1004 ASSERT_TRUE(active_loader()); 1004 ASSERT_TRUE(active_loader());
1005 1005
1006 // Read a bit from the beginning. 1006 // Read a bit from the beginning.
1007 ReadAt(0); 1007 ReadAt(0);
1008 EXPECT_CALL(*this, ReadCallback(kDataSize)); 1008 EXPECT_CALL(*this, ReadCallback(kDataSize));
1009 EXPECT_CALL(host_, AddBufferedByteRange(0, kDataSize - 1)); 1009 EXPECT_CALL(host_, AddBufferedByteRange(0, kDataSize - 1));
1010 ReceiveData(kDataSize); 1010 ReceiveData(kDataSize);
1011 1011
1012 EXPECT_FALSE(active_loader()); 1012 EXPECT_FALSE(active_loader());
1013 } 1013 }
1014 1014
1015 TEST_F(BufferedDataSourceTest, ExternalResource_Response206_CancelAfterPlay) {
1016 set_preload(BufferedDataSource::METADATA);
1017 InitializeWith206Response();
1018
1019 EXPECT_EQ(BufferedDataSource::METADATA, preload());
1020 EXPECT_FALSE(is_local_source());
1021 EXPECT_TRUE(loader()->range_supported());
1022 EXPECT_EQ(BufferedResourceLoader::kReadThenDefer, defer_strategy());
1023
1024 // Marking the media as playing should prevent deferral. It also switches the
1025 // data source into kCapacityDefer.
1026 data_source_->MediaIsPlaying();
1027 data_source_->OnBufferingHaveEnough(false);
1028 EXPECT_EQ(BufferedResourceLoader::kCapacityDefer, defer_strategy());
1029 ASSERT_TRUE(active_loader());
1030
1031 // Read a bit from the beginning and ensure deferral hasn't happened yet.
1032 ReadAt(0);
1033 EXPECT_CALL(*this, ReadCallback(kDataSize));
1034 EXPECT_CALL(host_, AddBufferedByteRange(0, kDataSize - 1));
1035 ReceiveData(kDataSize);
1036 ASSERT_TRUE(active_loader());
1037 ASSERT_FALSE(active_loader()->deferred());
1038 data_source_->OnBufferingHaveEnough(true);
1039
1040 // Deliver data until capacity is reached and verify deferral.
1041 int bytes_received = 0;
1042 EXPECT_CALL(host_, AddBufferedByteRange(_, _)).Times(testing::AtLeast(1));
1043 while (active_loader() && !active_loader()->deferred()) {
1044 ReceiveData(kDataSize);
1045 bytes_received += kDataSize;
1046 }
1047 EXPECT_GT(bytes_received, 0);
1048 EXPECT_LT(bytes_received + kDataSize, kFileSize);
1049 EXPECT_FALSE(active_loader());
1050 }
1051
1015 } // namespace media 1052 } // namespace media
OLDNEW
« no previous file with comments | « media/blink/buffered_data_source.cc ('k') | media/blink/multibuffer_data_source.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698