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

Side by Side Diff: chrome/browser/extensions/api/downloads/downloads_api_unittest.cc

Issue 11363222: Persist download interrupt reason, both target and current paths, and url_chain. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Added test requested by reviewers. Created 8 years, 1 month 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 | Annotate | Revision Log
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 <algorithm> 5 #include <algorithm>
6 6
7 #include "base/file_util.h" 7 #include "base/file_util.h"
8 #include "base/json/json_reader.h" 8 #include "base/json/json_reader.h"
9 #include "base/json/json_writer.h" 9 #include "base/json/json_writer.h"
10 #include "base/message_loop.h" 10 #include "base/message_loop.h"
(...skipping 341 matching lines...) Expand 10 before | Expand all | Expand 10 after
352 // array. |count| is the number of elements in |history_info|. On success, 352 // array. |count| is the number of elements in |history_info|. On success,
353 // |items| will contain |count| DownloadItems in the order that they were 353 // |items| will contain |count| DownloadItems in the order that they were
354 // specified in |history_info|. Returns true on success and false otherwise. 354 // specified in |history_info|. Returns true on success and false otherwise.
355 bool CreateHistoryDownloads(const HistoryDownloadInfo* history_info, 355 bool CreateHistoryDownloads(const HistoryDownloadInfo* history_info,
356 size_t count, 356 size_t count,
357 DownloadManager::DownloadVector* items) { 357 DownloadManager::DownloadVector* items) {
358 DownloadIdComparator download_id_comparator; 358 DownloadIdComparator download_id_comparator;
359 base::Time current = base::Time::Now(); 359 base::Time current = base::Time::Now();
360 std::vector<DownloadPersistentStoreInfo> entries; 360 std::vector<DownloadPersistentStoreInfo> entries;
361 entries.reserve(count); 361 entries.reserve(count);
362 std::vector<GURL> url_chain;
363 url_chain.push_back(GURL());
362 for (size_t i = 0; i < count; ++i) { 364 for (size_t i = 0; i < count; ++i) {
363 DownloadPersistentStoreInfo entry( 365 DownloadPersistentStoreInfo entry(
364 downloads_directory().Append(history_info[i].filename), 366 downloads_directory().Append(history_info[i].filename),
365 GURL(), GURL(), // URL, referrer 367 downloads_directory().Append(history_info[i].filename),
368 url_chain, GURL(), // URL Chain, referrer
366 current, current, // start_time, end_time 369 current, current, // start_time, end_time
367 1, 1, // received_bytes, total_bytes 370 1, 1, // received_bytes, total_bytes
368 history_info[i].state, // state 371 history_info[i].state, // state
372 content::DOWNLOAD_INTERRUPT_REASON_NONE,
369 i + 1, // db_handle 373 i + 1, // db_handle
370 false); // opened 374 false); // opened
371 entries.push_back(entry); 375 entries.push_back(entry);
372 } 376 }
373 GetOnRecordManager()->OnPersistentStoreQueryComplete(&entries); 377 GetOnRecordManager()->OnPersistentStoreQueryComplete(&entries);
374 GetOnRecordManager()->GetAllDownloads(items); 378 GetOnRecordManager()->GetAllDownloads(items);
375 EXPECT_EQ(count, items->size()); 379 EXPECT_EQ(count, items->size());
376 if (count != items->size()) 380 if (count != items->size())
377 return false; 381 return false;
378 382
(...skipping 1704 matching lines...) Expand 10 before | Expand all | Expand 10 after
2083 " \"state\": {" 2087 " \"state\": {"
2084 " \"previous\": \"in_progress\"," 2088 " \"previous\": \"in_progress\","
2085 " \"current\": \"complete\"}}]", 2089 " \"current\": \"complete\"}}]",
2086 result_id, 2090 result_id,
2087 GetFilename("on_record.txt.crdownload").c_str(), 2091 GetFilename("on_record.txt.crdownload").c_str(),
2088 GetFilename("on_record.txt").c_str()))); 2092 GetFilename("on_record.txt").c_str())));
2089 std::string disk_data; 2093 std::string disk_data;
2090 EXPECT_TRUE(file_util::ReadFileToString(item->GetFullPath(), &disk_data)); 2094 EXPECT_TRUE(file_util::ReadFileToString(item->GetFullPath(), &disk_data));
2091 EXPECT_STREQ(kPayloadData, disk_data.c_str()); 2095 EXPECT_STREQ(kPayloadData, disk_data.c_str());
2092 } 2096 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698