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

Unified Diff: chrome/browser/download/download_history_unittest.cc

Issue 1781983002: [Downloads] Introduce GUIDs for downloads. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/download/download_history_unittest.cc
diff --git a/chrome/browser/download/download_history_unittest.cc b/chrome/browser/download/download_history_unittest.cc
index 765588a8ddf463a4ef4114081c9c7ee5d8dc5a85..97236cedc193fdfccd5350a5420f19bad9ecfb67 100644
--- a/chrome/browser/download/download_history_unittest.cc
+++ b/chrome/browser/download/download_history_unittest.cc
@@ -9,6 +9,7 @@
#include <utility>
#include <vector>
+#include "base/guid.h"
#include "base/macros.h"
#include "base/memory/weak_ptr.h"
#include "base/rand_util.h"
@@ -37,33 +38,6 @@ using testing::_;
namespace {
-void CheckInfoEqual(const history::DownloadRow& left,
- const history::DownloadRow& right) {
- EXPECT_EQ(left.current_path.value(), right.current_path.value());
- EXPECT_EQ(left.target_path.value(), right.target_path.value());
- EXPECT_EQ(left.url_chain.size(), right.url_chain.size());
- for (unsigned int i = 0;
- i < left.url_chain.size() && i < right.url_chain.size();
- ++i) {
- EXPECT_EQ(left.url_chain[i].spec(), right.url_chain[i].spec());
- }
- EXPECT_EQ(left.referrer_url.spec(), right.referrer_url.spec());
- EXPECT_EQ(left.mime_type, right.mime_type);
- EXPECT_EQ(left.original_mime_type, right.original_mime_type);
- EXPECT_EQ(left.start_time.ToTimeT(), right.start_time.ToTimeT());
- EXPECT_EQ(left.end_time.ToTimeT(), right.end_time.ToTimeT());
- EXPECT_EQ(left.etag, right.etag);
- EXPECT_EQ(left.last_modified, right.last_modified);
- EXPECT_EQ(left.received_bytes, right.received_bytes);
- EXPECT_EQ(left.total_bytes, right.total_bytes);
- EXPECT_EQ(left.state, right.state);
- EXPECT_EQ(left.danger_type, right.danger_type);
- EXPECT_EQ(left.id, right.id);
- EXPECT_EQ(left.opened, right.opened);
- EXPECT_EQ(left.by_ext_id, right.by_ext_id);
- EXPECT_EQ(left.by_ext_name, right.by_ext_name);
-}
-
typedef DownloadHistory::IdSet IdSet;
typedef std::vector<history::DownloadRow> InfoVector;
typedef testing::StrictMock<content::MockDownloadItem> StrictMockDownloadItem;
@@ -146,27 +120,27 @@ class FakeHistoryAdapter : public DownloadHistory::HistoryAdapter {
const history::DownloadRow& info) {
DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
content::RunAllPendingInMessageLoop(content::BrowserThread::UI);
- CheckInfoEqual(info, create_download_info_);
+ EXPECT_EQ(info, create_download_info_);
create_download_info_ = history::DownloadRow();
}
void ExpectNoDownloadCreated() {
DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
content::RunAllPendingInMessageLoop(content::BrowserThread::UI);
- CheckInfoEqual(history::DownloadRow(), create_download_info_);
+ EXPECT_EQ(history::DownloadRow(), create_download_info_);
}
void ExpectDownloadUpdated(const history::DownloadRow& info) {
DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
content::RunAllPendingInMessageLoop(content::BrowserThread::UI);
- CheckInfoEqual(update_download_, info);
+ EXPECT_EQ(update_download_, info);
update_download_ = history::DownloadRow();
}
void ExpectNoDownloadUpdated() {
DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
content::RunAllPendingInMessageLoop(content::BrowserThread::UI);
- CheckInfoEqual(history::DownloadRow(), update_download_);
+ EXPECT_EQ(history::DownloadRow(), update_download_);
}
void ExpectNoDownloadsRemoved() {
@@ -236,19 +210,10 @@ class DownloadHistoryTest : public testing::Test {
for (size_t index = 0; index < infos->size(); ++index) {
const history::DownloadRow& row = infos->at(index);
content::MockDownloadManager::CreateDownloadItemAdapter adapter(
- history::ToContentDownloadId(row.id),
- row.current_path,
- row.target_path,
- row.url_chain,
- row.referrer_url,
- row.mime_type,
- row.original_mime_type,
- row.start_time,
- row.end_time,
- row.etag,
- row.last_modified,
- row.received_bytes,
- row.total_bytes,
+ row.guid, history::ToContentDownloadId(row.id), row.current_path,
+ row.target_path, row.url_chain, row.referrer_url, row.mime_type,
+ row.original_mime_type, row.start_time, row.end_time, row.etag,
+ row.last_modified, row.received_bytes, row.total_bytes,
history::ToContentDownloadState(row.state),
history::ToContentDownloadDangerType(row.danger_type),
history::ToContentDownloadInterruptReason(row.interrupt_reason),
@@ -351,8 +316,8 @@ class DownloadHistoryTest : public testing::Test {
GURL referrer(referrer_string);
std::vector<GURL> url_chain;
url_chain.push_back(url);
- InitItem(static_cast<uint32_t>(items_.size() + 1), base::FilePath(path),
- base::FilePath(path), url_chain, referrer,
+ InitItem(base::GenerateGUID(), static_cast<uint32_t>(items_.size() + 1),
+ base::FilePath(path), base::FilePath(path), url_chain, referrer,
"application/octet-stream", "application/octet-stream",
(base::Time::Now() - base::TimeDelta::FromMinutes(10)),
(base::Time::Now() - base::TimeDelta::FromMinutes(1)), "Etag",
@@ -362,7 +327,8 @@ class DownloadHistoryTest : public testing::Test {
std::string(), info);
}
- void InitItem(uint32_t id,
+ void InitItem(const std::string& guid,
+ uint32_t id,
const base::FilePath& current_path,
const base::FilePath& target_path,
const std::vector<GURL>& url_chain,
@@ -405,11 +371,13 @@ class DownloadHistoryTest : public testing::Test {
info->interrupt_reason =
history::ToHistoryDownloadInterruptReason(interrupt_reason);
info->id = history::ToHistoryDownloadId(id);
+ info->guid = guid;
info->opened = opened;
info->by_ext_id = by_extension_id;
info->by_ext_name = by_extension_name;
EXPECT_CALL(item(index), GetId()).WillRepeatedly(Return(id));
+ EXPECT_CALL(item(index), GetGuid()).WillRepeatedly(ReturnRefOfCopy(guid));
EXPECT_CALL(item(index), GetFullPath())
.WillRepeatedly(ReturnRefOfCopy(current_path));
EXPECT_CALL(item(index), GetTargetFilePath())

Powered by Google App Engine
This is Rietveld 408576698