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

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

Issue 1875033005: [Downloads/History] Add tab-url and tab-referrer-url to DownloadRow (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@guid-fix
Patch Set: Update expectations for DownloadUIController test. Created 4 years, 8 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>
(...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after
211 void CreateDownloadHistory(std::unique_ptr<InfoVector> infos) { 211 void CreateDownloadHistory(std::unique_ptr<InfoVector> infos) {
212 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); 212 DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
213 CHECK(infos.get()); 213 CHECK(infos.get());
214 EXPECT_CALL(manager(), AddObserver(_)).WillOnce(WithArg<0>(Invoke( 214 EXPECT_CALL(manager(), AddObserver(_)).WillOnce(WithArg<0>(Invoke(
215 this, &DownloadHistoryTest::SetManagerObserver))); 215 this, &DownloadHistoryTest::SetManagerObserver)));
216 EXPECT_CALL(manager(), RemoveObserver(_)); 216 EXPECT_CALL(manager(), RemoveObserver(_));
217 download_created_index_ = 0; 217 download_created_index_ = 0;
218 for (size_t index = 0; index < infos->size(); ++index) { 218 for (size_t index = 0; index < infos->size(); ++index) {
219 const history::DownloadRow& row = infos->at(index); 219 const history::DownloadRow& row = infos->at(index);
220 content::MockDownloadManager::CreateDownloadItemAdapter adapter( 220 content::MockDownloadManager::CreateDownloadItemAdapter adapter(
221 row.guid, 221 row.guid, history::ToContentDownloadId(row.id), row.current_path,
222 history::ToContentDownloadId(row.id), 222 row.target_path, row.url_chain, row.referrer_url, row.tab_url,
223 row.current_path, 223 row.tab_referrer_url, row.mime_type, row.original_mime_type,
224 row.target_path, 224 row.start_time, row.end_time, row.etag, row.last_modified,
225 row.url_chain, 225 row.received_bytes, row.total_bytes, std::string(),
226 row.referrer_url,
227 row.mime_type,
228 row.original_mime_type,
229 row.start_time,
230 row.end_time,
231 row.etag,
232 row.last_modified,
233 row.received_bytes,
234 row.total_bytes,
235 std::string(),
236 history::ToContentDownloadState(row.state), 226 history::ToContentDownloadState(row.state),
237 history::ToContentDownloadDangerType(row.danger_type), 227 history::ToContentDownloadDangerType(row.danger_type),
238 history::ToContentDownloadInterruptReason(row.interrupt_reason), 228 history::ToContentDownloadInterruptReason(row.interrupt_reason),
239 row.opened); 229 row.opened);
240 EXPECT_CALL(manager(), MockCreateDownloadItem(adapter)) 230 EXPECT_CALL(manager(), MockCreateDownloadItem(adapter))
241 .WillOnce(DoAll( 231 .WillOnce(DoAll(
242 InvokeWithoutArgs( 232 InvokeWithoutArgs(
243 this, &DownloadHistoryTest::CallOnDownloadCreatedInOrder), 233 this, &DownloadHistoryTest::CallOnDownloadCreatedInOrder),
244 Return(&item(index)))); 234 Return(&item(index))));
245 } 235 }
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
329 } 319 }
330 320
331 void InitBasicItem(const base::FilePath::CharType* path, 321 void InitBasicItem(const base::FilePath::CharType* path,
332 const char* url_string, 322 const char* url_string,
333 const char* referrer_string, 323 const char* referrer_string,
334 history::DownloadRow* info) { 324 history::DownloadRow* info) {
335 GURL url(url_string); 325 GURL url(url_string);
336 GURL referrer(referrer_string); 326 GURL referrer(referrer_string);
337 std::vector<GURL> url_chain; 327 std::vector<GURL> url_chain;
338 url_chain.push_back(url); 328 url_chain.push_back(url);
339 InitItem(base::GenerateGUID(), 329 InitItem(base::GenerateGUID(), static_cast<uint32_t>(items_.size() + 1),
340 static_cast<uint32_t>(items_.size() + 1), 330 base::FilePath(path), base::FilePath(path), url_chain, referrer,
341 base::FilePath(path), 331 GURL("http://example.com/tab-url"),
342 base::FilePath(path), 332 GURL("http://example.com/tab-referrer-url"),
343 url_chain, 333 "application/octet-stream", "application/octet-stream",
344 referrer,
345 "application/octet-stream",
346 "application/octet-stream",
347 (base::Time::Now() - base::TimeDelta::FromMinutes(10)), 334 (base::Time::Now() - base::TimeDelta::FromMinutes(10)),
348 (base::Time::Now() - base::TimeDelta::FromMinutes(1)), 335 (base::Time::Now() - base::TimeDelta::FromMinutes(1)), "Etag",
349 "Etag", 336 "abc", 100, 100, content::DownloadItem::COMPLETE,
350 "abc",
351 100,
352 100,
353 content::DownloadItem::COMPLETE,
354 content::DOWNLOAD_DANGER_TYPE_NOT_DANGEROUS, 337 content::DOWNLOAD_DANGER_TYPE_NOT_DANGEROUS,
355 content::DOWNLOAD_INTERRUPT_REASON_NONE, 338 content::DOWNLOAD_INTERRUPT_REASON_NONE, false, std::string(),
356 false, 339 std::string(), info);
357 std::string(),
358 std::string(),
359 info);
360 } 340 }
361 341
362 void InitItem(const std::string& guid, 342 void InitItem(const std::string& guid,
363 uint32_t id, 343 uint32_t id,
364 const base::FilePath& current_path, 344 const base::FilePath& current_path,
365 const base::FilePath& target_path, 345 const base::FilePath& target_path,
366 const std::vector<GURL>& url_chain, 346 const std::vector<GURL>& url_chain,
367 const GURL& referrer, 347 const GURL& referrer,
348 const GURL& tab_url,
349 const GURL& tab_referrer_url,
368 const std::string& mime_type, 350 const std::string& mime_type,
369 const std::string& original_mime_type, 351 const std::string& original_mime_type,
370 const base::Time& start_time, 352 const base::Time& start_time,
371 const base::Time& end_time, 353 const base::Time& end_time,
372 const std::string& etag, 354 const std::string& etag,
373 const std::string& last_modified, 355 const std::string& last_modified,
374 int64_t received_bytes, 356 int64_t received_bytes,
375 int64_t total_bytes, 357 int64_t total_bytes,
376 content::DownloadItem::DownloadState state, 358 content::DownloadItem::DownloadState state,
377 content::DownloadDangerType danger_type, 359 content::DownloadDangerType danger_type,
378 content::DownloadInterruptReason interrupt_reason, 360 content::DownloadInterruptReason interrupt_reason,
379 bool opened, 361 bool opened,
380 const std::string& by_extension_id, 362 const std::string& by_extension_id,
381 const std::string& by_extension_name, 363 const std::string& by_extension_name,
382 history::DownloadRow* info) { 364 history::DownloadRow* info) {
383 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); 365 DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
384 366
385 size_t index = items_.size(); 367 size_t index = items_.size();
386 StrictMockDownloadItem* mock_item = new StrictMockDownloadItem(); 368 StrictMockDownloadItem* mock_item = new StrictMockDownloadItem();
387 items_.push_back(mock_item); 369 items_.push_back(mock_item);
388 370
389 info->current_path = current_path; 371 info->current_path = current_path;
390 info->target_path = target_path; 372 info->target_path = target_path;
391 info->url_chain = url_chain; 373 info->url_chain = url_chain;
392 info->referrer_url = referrer; 374 info->referrer_url = referrer;
375 info->tab_url = tab_url;
376 info->tab_referrer_url = tab_referrer_url;
393 info->mime_type = mime_type; 377 info->mime_type = mime_type;
394 info->original_mime_type = original_mime_type; 378 info->original_mime_type = original_mime_type;
395 info->start_time = start_time; 379 info->start_time = start_time;
396 info->end_time = end_time; 380 info->end_time = end_time;
397 info->etag = etag; 381 info->etag = etag;
398 info->last_modified = last_modified; 382 info->last_modified = last_modified;
399 info->received_bytes = received_bytes; 383 info->received_bytes = received_bytes;
400 info->total_bytes = total_bytes; 384 info->total_bytes = total_bytes;
401 info->state = history::ToHistoryDownloadState(state); 385 info->state = history::ToHistoryDownloadState(state);
402 info->danger_type = history::ToHistoryDownloadDangerType(danger_type); 386 info->danger_type = history::ToHistoryDownloadDangerType(danger_type);
(...skipping 14 matching lines...) Expand all
417 DCHECK_LE(1u, url_chain.size()); 401 DCHECK_LE(1u, url_chain.size());
418 EXPECT_CALL(item(index), GetURL()) 402 EXPECT_CALL(item(index), GetURL())
419 .WillRepeatedly(ReturnRefOfCopy(url_chain[0])); 403 .WillRepeatedly(ReturnRefOfCopy(url_chain[0]));
420 EXPECT_CALL(item(index), GetUrlChain()) 404 EXPECT_CALL(item(index), GetUrlChain())
421 .WillRepeatedly(ReturnRefOfCopy(url_chain)); 405 .WillRepeatedly(ReturnRefOfCopy(url_chain));
422 EXPECT_CALL(item(index), GetMimeType()).WillRepeatedly(Return(mime_type)); 406 EXPECT_CALL(item(index), GetMimeType()).WillRepeatedly(Return(mime_type));
423 EXPECT_CALL(item(index), GetOriginalMimeType()).WillRepeatedly(Return( 407 EXPECT_CALL(item(index), GetOriginalMimeType()).WillRepeatedly(Return(
424 original_mime_type)); 408 original_mime_type));
425 EXPECT_CALL(item(index), GetReferrerUrl()) 409 EXPECT_CALL(item(index), GetReferrerUrl())
426 .WillRepeatedly(ReturnRefOfCopy(referrer)); 410 .WillRepeatedly(ReturnRefOfCopy(referrer));
411 EXPECT_CALL(item(index), GetTabUrl())
412 .WillRepeatedly(ReturnRefOfCopy(tab_url));
413 EXPECT_CALL(item(index), GetTabReferrerUrl())
414 .WillRepeatedly(ReturnRefOfCopy(tab_referrer_url));
427 EXPECT_CALL(item(index), GetStartTime()).WillRepeatedly(Return(start_time)); 415 EXPECT_CALL(item(index), GetStartTime()).WillRepeatedly(Return(start_time));
428 EXPECT_CALL(item(index), GetEndTime()).WillRepeatedly(Return(end_time)); 416 EXPECT_CALL(item(index), GetEndTime()).WillRepeatedly(Return(end_time));
429 EXPECT_CALL(item(index), GetETag()).WillRepeatedly(ReturnRefOfCopy(etag)); 417 EXPECT_CALL(item(index), GetETag()).WillRepeatedly(ReturnRefOfCopy(etag));
430 EXPECT_CALL(item(index), GetLastModifiedTime()) 418 EXPECT_CALL(item(index), GetLastModifiedTime())
431 .WillRepeatedly(ReturnRefOfCopy(last_modified)); 419 .WillRepeatedly(ReturnRefOfCopy(last_modified));
432 EXPECT_CALL(item(index), GetReceivedBytes()) 420 EXPECT_CALL(item(index), GetReceivedBytes())
433 .WillRepeatedly(Return(received_bytes)); 421 .WillRepeatedly(Return(received_bytes));
434 EXPECT_CALL(item(index), GetTotalBytes()) 422 EXPECT_CALL(item(index), GetTotalBytes())
435 .WillRepeatedly(Return(total_bytes)); 423 .WillRepeatedly(Return(total_bytes));
436 EXPECT_CALL(item(index), GetState()).WillRepeatedly(Return(state)); 424 EXPECT_CALL(item(index), GetState()).WillRepeatedly(Return(state));
(...skipping 466 matching lines...) Expand 10 before | Expand all | Expand 10 after
903 FinishCreateDownload(); 891 FinishCreateDownload();
904 EXPECT_TRUE(DownloadHistory::IsPersisted(&item(0))); 892 EXPECT_TRUE(DownloadHistory::IsPersisted(&item(0)));
905 893
906 // ItemAdded should call OnDownloadUpdated, which should detect that the item 894 // ItemAdded should call OnDownloadUpdated, which should detect that the item
907 // changed while it was being added and call UpdateDownload immediately. 895 // changed while it was being added and call UpdateDownload immediately.
908 info.opened = true; 896 info.opened = true;
909 ExpectDownloadUpdated(info); 897 ExpectDownloadUpdated(info);
910 } 898 }
911 899
912 } // anonymous namespace 900 } // anonymous namespace
OLDNEW
« no previous file with comments | « chrome/browser/download/download_history.cc ('k') | chrome/browser/download/download_ui_controller_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698