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

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

Issue 1989123003: Fix progress reporting for multibuffers to report progress for every byte we receive. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@2704
Patch Set: 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 921 matching lines...) Expand 10 before | Expand all | Expand 10 after
932 } 932 }
933 933
934 TEST_F(MultibufferDataSourceTest, Http_Read) { 934 TEST_F(MultibufferDataSourceTest, Http_Read) {
935 InitializeWith206Response(); 935 InitializeWith206Response();
936 936
937 EXPECT_CALL(*this, ReadCallback(kDataSize)); 937 EXPECT_CALL(*this, ReadCallback(kDataSize));
938 ReadAt(0, kDataSize * 2); 938 ReadAt(0, kDataSize * 2);
939 939
940 ReadAt(kDataSize, kDataSize); 940 ReadAt(kDataSize, kDataSize);
941 EXPECT_CALL(*this, ReadCallback(kDataSize)); 941 EXPECT_CALL(*this, ReadCallback(kDataSize));
942 EXPECT_CALL(host_,
943 AddBufferedByteRange(kDataSize, kDataSize + kDataSize / 2));
944 ReceiveData(kDataSize / 2);
942 EXPECT_CALL(host_, AddBufferedByteRange(0, kDataSize * 2)); 945 EXPECT_CALL(host_, AddBufferedByteRange(0, kDataSize * 2));
943 ReceiveData(kDataSize / 2); 946 ReceiveData(kDataSize / 2);
944 ReceiveData(kDataSize / 2);
945 947
946 EXPECT_TRUE(data_source_->downloading()); 948 EXPECT_TRUE(data_source_->downloading());
947 Stop(); 949 Stop();
948 } 950 }
949 951
950 TEST_F(MultibufferDataSourceTest, Http_ShareData) { 952 TEST_F(MultibufferDataSourceTest, Http_ShareData) {
951 InitializeWith206Response(); 953 InitializeWith206Response();
952 954
953 EXPECT_CALL(*this, ReadCallback(kDataSize)); 955 EXPECT_CALL(*this, ReadCallback(kDataSize));
954 ReadAt(0, kDataSize * 2); 956 ReadAt(0, kDataSize * 2);
955 957
956 ReadAt(kDataSize, kDataSize); 958 ReadAt(kDataSize, kDataSize);
957 EXPECT_CALL(*this, ReadCallback(kDataSize)); 959 EXPECT_CALL(*this, ReadCallback(kDataSize));
960 EXPECT_CALL(host_,
961 AddBufferedByteRange(kDataSize, kDataSize + kDataSize / 2));
962 ReceiveData(kDataSize / 2);
958 EXPECT_CALL(host_, AddBufferedByteRange(0, kDataSize * 2)); 963 EXPECT_CALL(host_, AddBufferedByteRange(0, kDataSize * 2));
959 ReceiveData(kDataSize / 2); 964 ReceiveData(kDataSize / 2);
960 ReceiveData(kDataSize / 2);
961 965
962 EXPECT_TRUE(data_source_->downloading()); 966 EXPECT_TRUE(data_source_->downloading());
963 967
964 StrictMock<MockBufferedDataSourceHost> host2; 968 StrictMock<MockBufferedDataSourceHost> host2;
965 MockMultibufferDataSource source2( 969 MockMultibufferDataSource source2(
966 GURL(kHttpUrl), message_loop_.task_runner(), url_index_, 970 GURL(kHttpUrl), message_loop_.task_runner(), url_index_,
967 view_->mainFrame()->toWebLocalFrame(), &host2); 971 view_->mainFrame()->toWebLocalFrame(), &host2);
968 source2.SetPreload(preload_); 972 source2.SetPreload(preload_);
969 973
970 EXPECT_CALL(*this, OnInitialize(true)); 974 EXPECT_CALL(*this, OnInitialize(true));
(...skipping 301 matching lines...) Expand 10 before | Expand all | Expand 10 after
1272 1276
1273 EXPECT_CALL(host_, SetTotalBytes(response_generator_->content_length())); 1277 EXPECT_CALL(host_, SetTotalBytes(response_generator_->content_length()));
1274 Respond(response_generator_->Generate206(0)); 1278 Respond(response_generator_->Generate206(0));
1275 EXPECT_CALL(host_, AddBufferedByteRange(0, kDataSize)); 1279 EXPECT_CALL(host_, AddBufferedByteRange(0, kDataSize));
1276 ReceiveData(kDataSize); 1280 ReceiveData(kDataSize);
1277 1281
1278 // Read a bit from the beginning. 1282 // Read a bit from the beginning.
1279 EXPECT_CALL(*this, ReadCallback(kDataSize)); 1283 EXPECT_CALL(*this, ReadCallback(kDataSize));
1280 ReadAt(0); 1284 ReadAt(0);
1281 1285
1286 EXPECT_CALL(host_, AddBufferedByteRange(kDataSize, kDataSize + 1));
1282 ReceiveData(1); 1287 ReceiveData(1);
1283 EXPECT_CALL(host_, AddBufferedByteRange(0, kDataSize * 3)); 1288 EXPECT_CALL(host_, AddBufferedByteRange(0, kDataSize * 3));
1284 FinishLoading(); 1289 FinishLoading();
1285 EXPECT_CALL(*this, ReadCallback(0)); 1290 EXPECT_CALL(*this, ReadCallback(0));
1286 1291
1287 ReadAt(kDataSize + 5, kDataSize * 2); 1292 ReadAt(kDataSize + 5, kDataSize * 2);
1288 Stop(); 1293 Stop();
1289 } 1294 }
1290 1295
1291 TEST_F(MultibufferDataSourceTest, Http_RetryThenRedirect) { 1296 TEST_F(MultibufferDataSourceTest, Http_RetryThenRedirect) {
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
1360 EXPECT_CALL(host_, AddBufferedByteRange(0, kDataSize * 2)); 1365 EXPECT_CALL(host_, AddBufferedByteRange(0, kDataSize * 2));
1361 FinishLoading(); 1366 FinishLoading();
1362 1367
1363 // Done loading, now we should know the length. 1368 // Done loading, now we should know the length.
1364 EXPECT_TRUE(data_source_->GetSize(&len)); 1369 EXPECT_TRUE(data_source_->GetSize(&len));
1365 EXPECT_EQ(kDataSize, len); 1370 EXPECT_EQ(kDataSize, len);
1366 Stop(); 1371 Stop();
1367 } 1372 }
1368 1373
1369 } // namespace media 1374 } // 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