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/path_service.h" | 7 #include "base/path_service.h" |
8 #include "base/run_loop.h" | 8 #include "base/run_loop.h" |
9 #include "base/strings/utf_string_conversions.h" | 9 #include "base/strings/utf_string_conversions.h" |
10 #include "chrome/browser/chromeos/profiles/profile_helper.h" | 10 #include "chrome/browser/chromeos/profiles/profile_helper.h" |
(...skipping 492 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
503 // Checks there is neither any download nor any notification. | 503 // Checks there is neither any download nor any notification. |
504 EXPECT_EQ(0u, GetMessageCenter()->GetVisibleNotifications().size()); | 504 EXPECT_EQ(0u, GetMessageCenter()->GetVisibleNotifications().size()); |
505 std::vector<content::DownloadItem*> downloads; | 505 std::vector<content::DownloadItem*> downloads; |
506 GetDownloadManager(browser())->GetAllDownloads(&downloads); | 506 GetDownloadManager(browser())->GetAllDownloads(&downloads); |
507 EXPECT_EQ(0u, downloads.size()); | 507 EXPECT_EQ(0u, downloads.size()); |
508 | 508 |
509 // Checks the downloaded file doesn't exist. | 509 // Checks the downloaded file doesn't exist. |
510 EXPECT_FALSE(base::PathExists(GetDownloadPath().Append(filename.BaseName()))); | 510 EXPECT_FALSE(base::PathExists(GetDownloadPath().Append(filename.BaseName()))); |
511 } | 511 } |
512 | 512 |
| 513 IN_PROC_BROWSER_TEST_F(DownloadNotificationTest, DownloadImageFile) { |
| 514 GURL download_url(embedded_test_server()->GetURL( |
| 515 "/downloads/image-octet-stream.png")); |
| 516 |
| 517 content::DownloadTestObserverTerminal download_terminal_observer( |
| 518 GetDownloadManager(browser()), 1u, /* wait_count */ |
| 519 content::DownloadTestObserver::ON_DANGEROUS_DOWNLOAD_IGNORE); |
| 520 |
| 521 CreateDownloadForBrowserAndURL(browser(), download_url); |
| 522 |
| 523 // Wait for the download completion. |
| 524 download_terminal_observer.WaitForFinished(); |
| 525 |
| 526 // Waits for download completion. |
| 527 while (GetNotification(notification_id())->image().IsEmpty()) { |
| 528 NotificationUpdateObserver download_change_notification_observer; |
| 529 download_change_notification_observer.Wait(); |
| 530 } |
| 531 } |
| 532 |
513 IN_PROC_BROWSER_TEST_F(DownloadNotificationTest, | 533 IN_PROC_BROWSER_TEST_F(DownloadNotificationTest, |
514 CloseNotificationAfterDownload) { | 534 CloseNotificationAfterDownload) { |
515 CreateDownload(); | 535 CreateDownload(); |
516 | 536 |
517 // Requests to complete the download. | 537 // Requests to complete the download. |
518 ui_test_utils::NavigateToURL( | 538 ui_test_utils::NavigateToURL( |
519 browser(), GURL(net::URLRequestSlowDownloadJob::kFinishDownloadUrl)); | 539 browser(), GURL(net::URLRequestSlowDownloadJob::kFinishDownloadUrl)); |
520 | 540 |
521 // Waits for download completion. | 541 // Waits for download completion. |
522 while (download_item()->GetState() != content::DownloadItem::COMPLETE) { | 542 while (download_item()->GetState() != content::DownloadItem::COMPLETE) { |
(...skipping 591 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1114 EXPECT_EQ(message_center::NOTIFICATION_TYPE_MULTIPLE, | 1134 EXPECT_EQ(message_center::NOTIFICATION_TYPE_MULTIPLE, |
1115 GetNotification(notification_id_user2_group)->type()); | 1135 GetNotification(notification_id_user2_group)->type()); |
1116 EXPECT_EQ(2u, | 1136 EXPECT_EQ(2u, |
1117 GetNotification(notification_id_user2_group)->items().size()); | 1137 GetNotification(notification_id_user2_group)->items().size()); |
1118 // Normal notifications for user2. | 1138 // Normal notifications for user2. |
1119 EXPECT_EQ(message_center::NOTIFICATION_TYPE_BASE_FORMAT, | 1139 EXPECT_EQ(message_center::NOTIFICATION_TYPE_BASE_FORMAT, |
1120 GetNotification(notification_id_user2_1)->type()); | 1140 GetNotification(notification_id_user2_1)->type()); |
1121 EXPECT_EQ(message_center::NOTIFICATION_TYPE_BASE_FORMAT, | 1141 EXPECT_EQ(message_center::NOTIFICATION_TYPE_BASE_FORMAT, |
1122 GetNotification(notification_id_user2_2)->type()); | 1142 GetNotification(notification_id_user2_2)->type()); |
1123 } | 1143 } |
OLD | NEW |