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

Side by Side Diff: content/browser/download/parallel_download_utils_unittest.cc

Issue 2737033002: Update the received slices vector when stream is written to disk (Closed)
Patch Set: Created 3 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
OLDNEW
1 // Copyright 2017 The Chromium Authors. All rights reserved. 1 // Copyright 2017 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 "content/browser/download/parallel_download_utils.h" 5 #include "content/browser/download/parallel_download_utils.h"
6 6
7 #include "content/public/browser/download_save_info.h" 7 #include "content/public/browser/download_save_info.h"
8 #include "testing/gtest/include/gtest/gtest.h" 8 #include "testing/gtest/include/gtest/gtest.h"
9 9
10 namespace content { 10 namespace content {
(...skipping 21 matching lines...) Expand all
32 EXPECT_EQ(1500, slice.offset); 32 EXPECT_EQ(1500, slice.offset);
33 EXPECT_EQ(DownloadSaveInfo::kLengthFullContent, slice.received_bytes); 33 EXPECT_EQ(DownloadSaveInfo::kLengthFullContent, slice.received_bytes);
34 34
35 // Create a new gap at the beginning. 35 // Create a new gap at the beginning.
36 slices.erase(slices.begin()); 36 slices.erase(slices.begin());
37 slice = FindNextSliceToDownload(slices); 37 slice = FindNextSliceToDownload(slices);
38 EXPECT_EQ(0, slice.offset); 38 EXPECT_EQ(0, slice.offset);
39 EXPECT_EQ(500, slice.received_bytes); 39 EXPECT_EQ(500, slice.received_bytes);
40 } 40 }
41 41
42 TEST(ParallelDownloadUtilsTest, AddReceivedSliceToSortedArray) {
43 std::vector<DownloadItem::ReceivedSlice> slices;
44 DownloadItem::ReceivedSlice slice1(500, 500);
45 EXPECT_EQ(0, AddReceivedSliceToSortedArray(slice1, slices));
46 EXPECT_EQ(1u, slices.size());
47 EXPECT_EQ(slice1, slices[0]);
48
49 DownloadItem::ReceivedSlice slice2(1000, 400);
50 EXPECT_EQ(1, AddReceivedSliceToSortedArray(slice2, slices));
51 EXPECT_EQ(2u, slices.size());
52 EXPECT_EQ(slice1, slices[0]);
53 EXPECT_EQ(slice2, slices[1]);
54
55 DownloadItem::ReceivedSlice slice3(0, 50);
56 EXPECT_EQ(0, AddReceivedSliceToSortedArray(slice3, slices));
57 EXPECT_EQ(3u, slices.size());
58 EXPECT_EQ(slice3, slices[0]);
59 EXPECT_EQ(slice1, slices[1]);
60 EXPECT_EQ(slice2, slices[2]);
xingliu 2017/03/07 22:18:13 nit%: Can we add another case here that inserts so
qinmin 2017/03/08 18:46:33 Done.
61 }
62
42 } // namespace content 63 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698