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

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

Issue 1971373002: Fix progress reporting for multibuffers to report progress for every byte we receive. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: comments addressed Created 4 years, 7 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/multibuffer.cc ('k') | media/blink/multibuffer_reader.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 <stddef.h> 5 #include <stddef.h>
6 #include <stdint.h> 6 #include <stdint.h>
7 7
8 #include "base/bind.h" 8 #include "base/bind.h"
9 #include "base/macros.h" 9 #include "base/macros.h"
10 #include "base/message_loop/message_loop.h" 10 #include "base/message_loop/message_loop.h"
(...skipping 955 matching lines...) Expand 10 before | Expand all | Expand 10 after
966 } 966 }
967 967
968 TEST_F(MultibufferDataSourceTest, Http_Read) { 968 TEST_F(MultibufferDataSourceTest, Http_Read) {
969 InitializeWith206Response(); 969 InitializeWith206Response();
970 970
971 EXPECT_CALL(*this, ReadCallback(kDataSize)); 971 EXPECT_CALL(*this, ReadCallback(kDataSize));
972 ReadAt(0, kDataSize * 2); 972 ReadAt(0, kDataSize * 2);
973 973
974 ReadAt(kDataSize, kDataSize); 974 ReadAt(kDataSize, kDataSize);
975 EXPECT_CALL(*this, ReadCallback(kDataSize)); 975 EXPECT_CALL(*this, ReadCallback(kDataSize));
976 EXPECT_CALL(host_,
977 AddBufferedByteRange(kDataSize, kDataSize + kDataSize / 2));
978 ReceiveData(kDataSize / 2);
976 EXPECT_CALL(host_, AddBufferedByteRange(0, kDataSize * 2)); 979 EXPECT_CALL(host_, AddBufferedByteRange(0, kDataSize * 2));
977 ReceiveData(kDataSize / 2); 980 ReceiveData(kDataSize / 2);
978 ReceiveData(kDataSize / 2);
979 981
980 EXPECT_TRUE(data_source_->downloading()); 982 EXPECT_TRUE(data_source_->downloading());
981 Stop(); 983 Stop();
982 } 984 }
983 985
984 TEST_F(MultibufferDataSourceTest, Http_ShareData) { 986 TEST_F(MultibufferDataSourceTest, Http_ShareData) {
985 InitializeWith206Response(); 987 InitializeWith206Response();
986 988
987 EXPECT_CALL(*this, ReadCallback(kDataSize)); 989 EXPECT_CALL(*this, ReadCallback(kDataSize));
988 ReadAt(0, kDataSize * 2); 990 ReadAt(0, kDataSize * 2);
989 991
990 ReadAt(kDataSize, kDataSize); 992 ReadAt(kDataSize, kDataSize);
991 EXPECT_CALL(*this, ReadCallback(kDataSize)); 993 EXPECT_CALL(*this, ReadCallback(kDataSize));
994 EXPECT_CALL(host_,
995 AddBufferedByteRange(kDataSize, kDataSize + kDataSize / 2));
996 ReceiveData(kDataSize / 2);
992 EXPECT_CALL(host_, AddBufferedByteRange(0, kDataSize * 2)); 997 EXPECT_CALL(host_, AddBufferedByteRange(0, kDataSize * 2));
993 ReceiveData(kDataSize / 2); 998 ReceiveData(kDataSize / 2);
994 ReceiveData(kDataSize / 2);
995 999
996 EXPECT_TRUE(data_source_->downloading()); 1000 EXPECT_TRUE(data_source_->downloading());
997 1001
998 StrictMock<MockBufferedDataSourceHost> host2; 1002 StrictMock<MockBufferedDataSourceHost> host2;
999 MockMultibufferDataSource source2( 1003 MockMultibufferDataSource source2(
1000 GURL(kHttpUrl), UrlData::CORS_UNSPECIFIED, message_loop_.task_runner(), 1004 GURL(kHttpUrl), UrlData::CORS_UNSPECIFIED, message_loop_.task_runner(),
1001 url_index_, view_->mainFrame()->toWebLocalFrame(), &host2); 1005 url_index_, view_->mainFrame()->toWebLocalFrame(), &host2);
1002 source2.SetPreload(preload_); 1006 source2.SetPreload(preload_);
1003 1007
1004 EXPECT_CALL(*this, OnInitialize(true)); 1008 EXPECT_CALL(*this, OnInitialize(true));
(...skipping 301 matching lines...) Expand 10 before | Expand all | Expand 10 after
1306 1310
1307 EXPECT_CALL(host_, SetTotalBytes(response_generator_->content_length())); 1311 EXPECT_CALL(host_, SetTotalBytes(response_generator_->content_length()));
1308 Respond(response_generator_->Generate206(0)); 1312 Respond(response_generator_->Generate206(0));
1309 EXPECT_CALL(host_, AddBufferedByteRange(0, kDataSize)); 1313 EXPECT_CALL(host_, AddBufferedByteRange(0, kDataSize));
1310 ReceiveData(kDataSize); 1314 ReceiveData(kDataSize);
1311 1315
1312 // Read a bit from the beginning. 1316 // Read a bit from the beginning.
1313 EXPECT_CALL(*this, ReadCallback(kDataSize)); 1317 EXPECT_CALL(*this, ReadCallback(kDataSize));
1314 ReadAt(0); 1318 ReadAt(0);
1315 1319
1320 EXPECT_CALL(host_, AddBufferedByteRange(kDataSize, kDataSize + 1));
1316 ReceiveData(1); 1321 ReceiveData(1);
1317 EXPECT_CALL(host_, AddBufferedByteRange(0, kDataSize * 3)); 1322 EXPECT_CALL(host_, AddBufferedByteRange(0, kDataSize * 3));
1318 FinishLoading(); 1323 FinishLoading();
1319 EXPECT_CALL(*this, ReadCallback(0)); 1324 EXPECT_CALL(*this, ReadCallback(0));
1320 1325
1321 ReadAt(kDataSize + 5, kDataSize * 2); 1326 ReadAt(kDataSize + 5, kDataSize * 2);
1322 Stop(); 1327 Stop();
1323 } 1328 }
1324 1329
1325 TEST_F(MultibufferDataSourceTest, Http_RetryThenRedirect) { 1330 TEST_F(MultibufferDataSourceTest, Http_RetryThenRedirect) {
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
1367 ReceiveData(kDataSize); 1372 ReceiveData(kDataSize);
1368 1373
1369 EXPECT_FALSE(data_source_->IsStreaming()); 1374 EXPECT_FALSE(data_source_->IsStreaming());
1370 1375
1371 FinishLoading(); 1376 FinishLoading();
1372 EXPECT_FALSE(loading()); 1377 EXPECT_FALSE(loading());
1373 Stop(); 1378 Stop();
1374 } 1379 }
1375 1380
1376 } // namespace media 1381 } // namespace media
OLDNEW
« no previous file with comments | « media/blink/multibuffer.cc ('k') | media/blink/multibuffer_reader.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698