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

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

Issue 1691543002: [Downloads] Enforce state transition integrity and state invariants. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 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 // Disable everything on windows only. http://crbug.com/306144 5 // Disable everything on windows only. http://crbug.com/306144
6 #ifndef OS_WIN 6 #ifndef OS_WIN
7 7
8 #include <stddef.h> 8 #include <stddef.h>
9 #include <stdint.h> 9 #include <stdint.h>
10 10
(...skipping 410 matching lines...) Expand 10 before | Expand all | Expand 10 after
421 base::Time current = base::Time::Now(); 421 base::Time current = base::Time::Now();
422 items->clear(); 422 items->clear();
423 GetOnRecordManager()->GetAllDownloads(items); 423 GetOnRecordManager()->GetAllDownloads(items);
424 CHECK_EQ(0, static_cast<int>(items->size())); 424 CHECK_EQ(0, static_cast<int>(items->size()));
425 std::vector<GURL> url_chain; 425 std::vector<GURL> url_chain;
426 url_chain.push_back(GURL()); 426 url_chain.push_back(GURL());
427 for (size_t i = 0; i < count; ++i) { 427 for (size_t i = 0; i < count; ++i) {
428 DownloadItem* item = GetOnRecordManager()->CreateDownloadItem( 428 DownloadItem* item = GetOnRecordManager()->CreateDownloadItem(
429 content::DownloadItem::kInvalidId + 1 + i, 429 content::DownloadItem::kInvalidId + 1 + i,
430 downloads_directory().Append(history_info[i].filename), 430 downloads_directory().Append(history_info[i].filename),
431 downloads_directory().Append(history_info[i].filename), 431 downloads_directory().Append(history_info[i].filename), url_chain,
432 url_chain, GURL(), // URL Chain, referrer 432 GURL(), // URL Chain, referrer
433 std::string(), std::string(), // mime_type, original_mime_type 433 std::string(), std::string(), // mime_type, original_mime_type
434 current, current, // start_time, end_time 434 current, current, // start_time, end_time
435 std::string(), std::string(), // etag, last_modified 435 std::string(), std::string(), // etag, last_modified
436 1, 1, // received_bytes, total_bytes 436 1, 1, // received_bytes, total_bytes
437 history_info[i].state, // state 437 history_info[i].state, // state
438 content::DOWNLOAD_DANGER_TYPE_NOT_DANGEROUS, 438 history_info[i].danger_type,
439 (history_info[i].state != content::DownloadItem::CANCELLED ? 439 (history_info[i].state != content::DownloadItem::CANCELLED
440 content::DOWNLOAD_INTERRUPT_REASON_NONE : 440 ? content::DOWNLOAD_INTERRUPT_REASON_NONE
441 content::DOWNLOAD_INTERRUPT_REASON_USER_CANCELED), 441 : content::DOWNLOAD_INTERRUPT_REASON_USER_CANCELED),
442 false); // opened 442 false); // opened
443 items->push_back(item); 443 items->push_back(item);
444 } 444 }
445 445
446 // Order by ID so that they are in the order that we created them. 446 // Order by ID so that they are in the order that we created them.
447 std::sort(items->begin(), items->end(), download_id_comparator); 447 std::sort(items->begin(), items->end(), download_id_comparator);
448 // Set the danger type if necessary.
449 for (size_t i = 0; i < count; ++i) {
450 if (history_info[i].danger_type !=
451 content::DOWNLOAD_DANGER_TYPE_NOT_DANGEROUS) {
452 EXPECT_EQ(content::DOWNLOAD_DANGER_TYPE_DANGEROUS_CONTENT,
453 history_info[i].danger_type);
454 items->at(i)->OnContentCheckCompleted(history_info[i].danger_type);
455 }
456 }
457 return true; 448 return true;
458 } 449 }
459 450
460 void CreateSlowTestDownloads( 451 void CreateSlowTestDownloads(
461 size_t count, DownloadManager::DownloadVector* items) { 452 size_t count, DownloadManager::DownloadVector* items) {
462 for (size_t i = 0; i < count; ++i) { 453 for (size_t i = 0; i < count; ++i) {
463 scoped_ptr<content::DownloadTestObserver> observer( 454 scoped_ptr<content::DownloadTestObserver> observer(
464 CreateInProgressDownloadObserver(1)); 455 CreateInProgressDownloadObserver(1));
465 GURL slow_download_url(net::URLRequestSlowDownloadJob::kUnknownSizeUrl); 456 GURL slow_download_url(net::URLRequestSlowDownloadJob::kUnknownSizeUrl);
466 ui_test_utils::NavigateToURL(current_browser(), slow_download_url); 457 ui_test_utils::NavigateToURL(current_browser(), slow_download_url);
(...skipping 3693 matching lines...) Expand 10 before | Expand all | Expand 10 after
4160 EXPECT_EQ(downloads::FILENAME_CONFLICT_ACTION_PROMPT, conflict_action); 4151 EXPECT_EQ(downloads::FILENAME_CONFLICT_ACTION_PROMPT, conflict_action);
4161 EXPECT_FALSE(warnings.empty()); 4152 EXPECT_FALSE(warnings.empty());
4162 EXPECT_EQ(Warning::kDownloadFilenameConflict, 4153 EXPECT_EQ(Warning::kDownloadFilenameConflict,
4163 warnings.begin()->warning_type()); 4154 warnings.begin()->warning_type());
4164 EXPECT_EQ("incumbent", warnings.begin()->extension_id()); 4155 EXPECT_EQ("incumbent", warnings.begin()->extension_id());
4165 } 4156 }
4166 4157
4167 } // namespace extensions 4158 } // namespace extensions
4168 4159
4169 #endif // http://crbug.com/306144 4160 #endif // http://crbug.com/306144
OLDNEW
« no previous file with comments | « no previous file | content/browser/download/download_item_impl.h » ('j') | content/browser/download/download_item_impl_unittest.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698