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

Side by Side Diff: chrome/browser/download/download_history_unittest.cc

Issue 2703883003: Read and restore persisted slice info (Closed)
Patch Set: Created 3 years, 10 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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "chrome/browser/download/download_history.h" 5 #include "chrome/browser/download/download_history.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 #include <stdint.h> 8 #include <stdint.h>
9 #include <utility> 9 #include <utility>
10 #include <vector> 10 #include <vector>
11 11
12 #include "base/guid.h" 12 #include "base/guid.h"
13 #include "base/macros.h" 13 #include "base/macros.h"
14 #include "base/memory/ptr_util.h" 14 #include "base/memory/ptr_util.h"
15 #include "base/memory/weak_ptr.h" 15 #include "base/memory/weak_ptr.h"
16 #include "base/rand_util.h" 16 #include "base/rand_util.h"
17 #include "base/stl_util.h" 17 #include "base/stl_util.h"
18 #include "components/history/content/browser/download_constants_utils.h" 18 #include "components/history/content/browser/download_constants_utils.h"
19 #include "components/history/content/browser/download_database_helper.h"
19 #include "components/history/core/browser/download_constants.h" 20 #include "components/history/core/browser/download_constants.h"
20 #include "components/history/core/browser/download_row.h" 21 #include "components/history/core/browser/download_row.h"
21 #include "components/history/core/browser/history_service.h" 22 #include "components/history/core/browser/history_service.h"
22 #include "content/public/test/mock_download_item.h" 23 #include "content/public/test/mock_download_item.h"
23 #include "content/public/test/mock_download_manager.h" 24 #include "content/public/test/mock_download_manager.h"
24 #include "content/public/test/test_browser_thread.h" 25 #include "content/public/test/test_browser_thread.h"
25 #include "content/public/test/test_utils.h" 26 #include "content/public/test/test_utils.h"
26 #include "extensions/features/features.h" 27 #include "extensions/features/features.h"
27 #include "testing/gtest/include/gtest/gtest.h" 28 #include "testing/gtest/include/gtest/gtest.h"
28 29
(...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after
228 const history::DownloadRow& row = infos->at(index); 229 const history::DownloadRow& row = infos->at(index);
229 content::MockDownloadManager::CreateDownloadItemAdapter adapter( 230 content::MockDownloadManager::CreateDownloadItemAdapter adapter(
230 row.guid, history::ToContentDownloadId(row.id), row.current_path, 231 row.guid, history::ToContentDownloadId(row.id), row.current_path,
231 row.target_path, row.url_chain, row.referrer_url, row.site_url, 232 row.target_path, row.url_chain, row.referrer_url, row.site_url,
232 row.tab_url, row.tab_referrer_url, row.mime_type, 233 row.tab_url, row.tab_referrer_url, row.mime_type,
233 row.original_mime_type, row.start_time, row.end_time, row.etag, 234 row.original_mime_type, row.start_time, row.end_time, row.etag,
234 row.last_modified, row.received_bytes, row.total_bytes, std::string(), 235 row.last_modified, row.received_bytes, row.total_bytes, std::string(),
235 history::ToContentDownloadState(row.state), 236 history::ToContentDownloadState(row.state),
236 history::ToContentDownloadDangerType(row.danger_type), 237 history::ToContentDownloadDangerType(row.danger_type),
237 history::ToContentDownloadInterruptReason(row.interrupt_reason), 238 history::ToContentDownloadInterruptReason(row.interrupt_reason),
238 row.opened); 239 row.opened,
240 history::ToContentReceivedSlices(row.download_slice_info));
239 EXPECT_CALL(manager(), MockCreateDownloadItem(adapter)) 241 EXPECT_CALL(manager(), MockCreateDownloadItem(adapter))
240 .WillOnce(DoAll( 242 .WillOnce(DoAll(
241 InvokeWithoutArgs( 243 InvokeWithoutArgs(
242 this, &DownloadHistoryTest::CallOnDownloadCreatedInOrder), 244 this, &DownloadHistoryTest::CallOnDownloadCreatedInOrder),
243 Return(&item(index)))); 245 Return(&item(index))));
244 } 246 }
245 EXPECT_CALL(manager(), CheckForHistoryFilesRemoval()); 247 EXPECT_CALL(manager(), CheckForHistoryFilesRemoval());
246 history_ = new FakeHistoryAdapter(); 248 history_ = new FakeHistoryAdapter();
247 history_->ExpectWillQueryDownloads(std::move(infos)); 249 history_->ExpectWillQueryDownloads(std::move(infos));
248 EXPECT_CALL(*manager_.get(), GetAllDownloads(_)).WillRepeatedly(Return()); 250 EXPECT_CALL(*manager_.get(), GetAllDownloads(_)).WillRepeatedly(Return());
(...skipping 676 matching lines...) Expand 10 before | Expand all | Expand 10 after
925 FinishCreateDownload(); 927 FinishCreateDownload();
926 EXPECT_TRUE(DownloadHistory::IsPersisted(&item(0))); 928 EXPECT_TRUE(DownloadHistory::IsPersisted(&item(0)));
927 929
928 // ItemAdded should call OnDownloadUpdated, which should detect that the item 930 // ItemAdded should call OnDownloadUpdated, which should detect that the item
929 // changed while it was being added and call UpdateDownload immediately. 931 // changed while it was being added and call UpdateDownload immediately.
930 info.opened = true; 932 info.opened = true;
931 ExpectDownloadUpdated(info, false); 933 ExpectDownloadUpdated(info, false);
932 } 934 }
933 935
934 } // anonymous namespace 936 } // anonymous namespace
OLDNEW
« no previous file with comments | « chrome/browser/download/download_history.cc ('k') | chrome/browser/extensions/api/downloads/downloads_api_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698