| OLD | NEW |
| 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/files/scoped_temp_dir.h" | 8 #include "base/files/scoped_temp_dir.h" |
| 9 #include "base/json/json_reader.h" | 9 #include "base/json/json_reader.h" |
| 10 #include "base/message_loop/message_loop.h" | 10 #include "base/message_loop/message_loop.h" |
| (...skipping 455 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 466 GetCurrentManager()->GetAllDownloads(items); | 466 GetCurrentManager()->GetAllDownloads(items); |
| 467 ASSERT_EQ(count, items->size()); | 467 ASSERT_EQ(count, items->size()); |
| 468 } | 468 } |
| 469 | 469 |
| 470 DownloadItem* CreateSlowTestDownload() { | 470 DownloadItem* CreateSlowTestDownload() { |
| 471 scoped_ptr<content::DownloadTestObserver> observer( | 471 scoped_ptr<content::DownloadTestObserver> observer( |
| 472 CreateInProgressDownloadObserver(1)); | 472 CreateInProgressDownloadObserver(1)); |
| 473 GURL slow_download_url(URLRequestSlowDownloadJob::kUnknownSizeUrl); | 473 GURL slow_download_url(URLRequestSlowDownloadJob::kUnknownSizeUrl); |
| 474 DownloadManager* manager = GetCurrentManager(); | 474 DownloadManager* manager = GetCurrentManager(); |
| 475 | 475 |
| 476 EXPECT_EQ(0, manager->NonMaliciousInProgressCount()); |
| 476 EXPECT_EQ(0, manager->InProgressCount()); | 477 EXPECT_EQ(0, manager->InProgressCount()); |
| 477 if (manager->InProgressCount() != 0) | 478 if (manager->InProgressCount() != 0) |
| 478 return NULL; | 479 return NULL; |
| 479 | 480 |
| 480 ui_test_utils::NavigateToURLWithDisposition( | 481 ui_test_utils::NavigateToURLWithDisposition( |
| 481 current_browser(), slow_download_url, CURRENT_TAB, | 482 current_browser(), slow_download_url, CURRENT_TAB, |
| 482 ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION); | 483 ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION); |
| 483 | 484 |
| 484 observer->WaitForFinished(); | 485 observer->WaitForFinished(); |
| 485 EXPECT_EQ(1u, observer->NumDownloadsSeenInState(DownloadItem::IN_PROGRESS)); | 486 EXPECT_EQ(1u, observer->NumDownloadsSeenInState(DownloadItem::IN_PROGRESS)); |
| (...skipping 2852 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3338 GoOnTheRecord(); | 3339 GoOnTheRecord(); |
| 3339 content::RenderProcessHost* host = AddFilenameDeterminer(); | 3340 content::RenderProcessHost* host = AddFilenameDeterminer(); |
| 3340 | 3341 |
| 3341 // Start a download. | 3342 // Start a download. |
| 3342 DownloadItem* item = NULL; | 3343 DownloadItem* item = NULL; |
| 3343 { | 3344 { |
| 3344 DownloadManager* manager = GetCurrentManager(); | 3345 DownloadManager* manager = GetCurrentManager(); |
| 3345 scoped_ptr<content::DownloadTestObserver> observer( | 3346 scoped_ptr<content::DownloadTestObserver> observer( |
| 3346 new JustInProgressDownloadObserver(manager, 1)); | 3347 new JustInProgressDownloadObserver(manager, 1)); |
| 3347 ASSERT_EQ(0, manager->InProgressCount()); | 3348 ASSERT_EQ(0, manager->InProgressCount()); |
| 3349 ASSERT_EQ(0, manager->NonMaliciousInProgressCount()); |
| 3348 // Tabs created just for a download are automatically closed, invalidating | 3350 // Tabs created just for a download are automatically closed, invalidating |
| 3349 // the download's WebContents. Downloads without WebContents cannot be | 3351 // the download's WebContents. Downloads without WebContents cannot be |
| 3350 // resumed. http://crbug.com/225901 | 3352 // resumed. http://crbug.com/225901 |
| 3351 ui_test_utils::NavigateToURLWithDisposition( | 3353 ui_test_utils::NavigateToURLWithDisposition( |
| 3352 current_browser(), | 3354 current_browser(), |
| 3353 GURL(URLRequestSlowDownloadJob::kUnknownSizeUrl), | 3355 GURL(URLRequestSlowDownloadJob::kUnknownSizeUrl), |
| 3354 CURRENT_TAB, | 3356 CURRENT_TAB, |
| 3355 ui_test_utils::BROWSER_TEST_NONE); | 3357 ui_test_utils::BROWSER_TEST_NONE); |
| 3356 observer->WaitForFinished(); | 3358 observer->WaitForFinished(); |
| 3357 EXPECT_EQ(1u, observer->NumDownloadsSeenInState(DownloadItem::IN_PROGRESS)); | 3359 EXPECT_EQ(1u, observer->NumDownloadsSeenInState(DownloadItem::IN_PROGRESS)); |
| (...skipping 248 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3606 &warnings); | 3608 &warnings); |
| 3607 EXPECT_EQ("suggester", winner_id); | 3609 EXPECT_EQ("suggester", winner_id); |
| 3608 EXPECT_EQ(FILE_PATH_LITERAL("b"), filename.value()); | 3610 EXPECT_EQ(FILE_PATH_LITERAL("b"), filename.value()); |
| 3609 EXPECT_EQ(api::FILENAME_CONFLICT_ACTION_PROMPT, conflict_action); | 3611 EXPECT_EQ(api::FILENAME_CONFLICT_ACTION_PROMPT, conflict_action); |
| 3610 EXPECT_FALSE(warnings.empty()); | 3612 EXPECT_FALSE(warnings.empty()); |
| 3611 EXPECT_EQ(extensions::ExtensionWarning::kDownloadFilenameConflict, | 3613 EXPECT_EQ(extensions::ExtensionWarning::kDownloadFilenameConflict, |
| 3612 warnings.begin()->warning_type()); | 3614 warnings.begin()->warning_type()); |
| 3613 EXPECT_EQ("incumbent", warnings.begin()->extension_id()); | 3615 EXPECT_EQ("incumbent", warnings.begin()->extension_id()); |
| 3614 } | 3616 } |
| 3615 #endif // Issue 306144 | 3617 #endif // Issue 306144 |
| OLD | NEW |