Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 "base/command_line.h" | 5 #include "base/command_line.h" |
| 6 #include "base/message_loop/message_loop.h" | 6 #include "base/message_loop/message_loop.h" |
| 7 #include "base/run_loop.h" | 7 #include "base/run_loop.h" |
| 8 #include "base/strings/utf_string_conversions.h" | 8 #include "base/strings/utf_string_conversions.h" |
| 9 #include "chrome/browser/chromeos/profiles/profile_helper.h" | 9 #include "chrome/browser/chromeos/profiles/profile_helper.h" |
| 10 #include "chrome/browser/download/chrome_download_manager_delegate.h" | 10 #include "chrome/browser/download/chrome_download_manager_delegate.h" |
| (...skipping 483 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 494 // Checks there is neither any download nor any notification. | 494 // Checks there is neither any download nor any notification. |
| 495 EXPECT_EQ(0u, GetMessageCenter()->GetVisibleNotifications().size()); | 495 EXPECT_EQ(0u, GetMessageCenter()->GetVisibleNotifications().size()); |
| 496 std::vector<content::DownloadItem*> downloads; | 496 std::vector<content::DownloadItem*> downloads; |
| 497 GetDownloadManager(browser())->GetAllDownloads(&downloads); | 497 GetDownloadManager(browser())->GetAllDownloads(&downloads); |
| 498 EXPECT_EQ(0u, downloads.size()); | 498 EXPECT_EQ(0u, downloads.size()); |
| 499 | 499 |
| 500 // Checks the downloaded file doesn't exist. | 500 // Checks the downloaded file doesn't exist. |
| 501 EXPECT_FALSE(base::PathExists(GetDownloadPath().Append(filename.BaseName()))); | 501 EXPECT_FALSE(base::PathExists(GetDownloadPath().Append(filename.BaseName()))); |
| 502 } | 502 } |
| 503 | 503 |
| 504 IN_PROC_BROWSER_TEST_F(DownloadNotificationTest, DownloadImageFile) { | |
| 505 ASSERT_TRUE(test_server()->Start()); | |
|
asanka
2015/06/17 14:35:30
Didn't you migrate this test suite to use embedded
yoshiki
2015/06/18 10:48:04
Done.
| |
| 506 GURL download_url( | |
| 507 test_server()->GetURL("files/downloads/image-octet-stream.png")); | |
| 508 | |
| 509 content::DownloadTestObserverTerminal download_terminal_observer( | |
| 510 GetDownloadManager(browser()), | |
| 511 1u, /* wait_count */ | |
| 512 content::DownloadTestObserver::ON_DANGEROUS_DOWNLOAD_IGNORE); | |
| 513 | |
| 514 CreateDownloadForBrowserAndURL(browser(), download_url); | |
| 515 | |
| 516 // Wait for the download completion. | |
| 517 download_terminal_observer.WaitForFinished(); | |
| 518 | |
| 519 // Waits for download completion. | |
| 520 while (GetNotification(notification_id())->image().IsEmpty()) { | |
| 521 NotificationUpdateObserver download_change_notification_observer; | |
| 522 download_change_notification_observer.Wait(); | |
| 523 } | |
| 524 } | |
| 525 | |
| 504 IN_PROC_BROWSER_TEST_F(DownloadNotificationTest, | 526 IN_PROC_BROWSER_TEST_F(DownloadNotificationTest, |
| 505 CloseNotificationAfterDownload) { | 527 CloseNotificationAfterDownload) { |
| 506 CreateDownload(); | 528 CreateDownload(); |
| 507 | 529 |
| 508 // Requests to complete the download. | 530 // Requests to complete the download. |
| 509 ui_test_utils::NavigateToURL( | 531 ui_test_utils::NavigateToURL( |
| 510 browser(), GURL(net::URLRequestSlowDownloadJob::kFinishDownloadUrl)); | 532 browser(), GURL(net::URLRequestSlowDownloadJob::kFinishDownloadUrl)); |
| 511 | 533 |
| 512 // Waits for download completion. | 534 // Waits for download completion. |
| 513 while (download_item()->GetState() != content::DownloadItem::COMPLETE) { | 535 while (download_item()->GetState() != content::DownloadItem::COMPLETE) { |
| (...skipping 530 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1044 } | 1066 } |
| 1045 | 1067 |
| 1046 // Confirms the types of download notifications are correct. | 1068 // Confirms the types of download notifications are correct. |
| 1047 EXPECT_EQ(message_center::NOTIFICATION_TYPE_BASE_FORMAT, | 1069 EXPECT_EQ(message_center::NOTIFICATION_TYPE_BASE_FORMAT, |
| 1048 GetNotification(notification_id1)->type()); | 1070 GetNotification(notification_id1)->type()); |
| 1049 EXPECT_EQ(message_center::NOTIFICATION_TYPE_BASE_FORMAT, | 1071 EXPECT_EQ(message_center::NOTIFICATION_TYPE_BASE_FORMAT, |
| 1050 GetNotification(notification_id2)->type()); | 1072 GetNotification(notification_id2)->type()); |
| 1051 EXPECT_EQ(message_center::NOTIFICATION_TYPE_BASE_FORMAT, | 1073 EXPECT_EQ(message_center::NOTIFICATION_TYPE_BASE_FORMAT, |
| 1052 GetNotification(notification_id3)->type()); | 1074 GetNotification(notification_id3)->type()); |
| 1053 } | 1075 } |
| OLD | NEW |