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
3 // found in the LICENSE file.
5 #include "base/command_line.h"
6 #include "base/message_loop/message_loop.h"
7 #include "base/path_service.h"
8 #include "base/run_loop.h"
9 #include "base/strings/utf_string_conversions.h"
10 #include "chrome/browser/chromeos/profiles/profile_helper.h"
11 #include "chrome/browser/download/chrome_download_manager_delegate.h"
12 #include "chrome/browser/download/download_prefs.h"
13 #include "chrome/browser/download/download_service.h"
14 #include "chrome/browser/download/download_service_factory.h"
15 #include "chrome/browser/profiles/profile.h"
16 #include "chrome/browser/signin/signin_manager_factory.h"
17 #include "chrome/browser/ui/browser.h"
18 #include "chrome/browser/ui/browser_commands.h"
19 #include "chrome/common/chrome_paths.h"
20 #include "chrome/common/chrome_switches.h"
21 #include "chrome/grit/chromium_strings.h"
22 #include "chrome/grit/generated_resources.h"
23 #include "chrome/test/base/in_process_browser_test.h"
24 #include "chrome/test/base/ui_test_utils.h"
25 #include "chromeos/chromeos_switches.h"
26 #include "components/signin/core/browser/signin_manager_base.h"
27 #include "content/public/browser/browser_context.h"
28 #include "content/public/browser/download_item.h"
29 #include "content/public/browser/download_manager.h"
30 #include "content/public/test/download_test_observer.h"
31 #include "grit/theme_resources.h"
32 #include "net/test/embedded_test_server/embedded_test_server.h"
33 #include "net/test/url_request/url_request_slow_download_job.h"
34 #include "ui/base/l10n/l10n_util.h"
35 #include "ui/message_center/message_center.h"
36 #include "ui/message_center/message_center_observer.h"
42 DUMMY_ACCOUNT_INDEX
= 0,
43 PRIMARY_ACCOUNT_INDEX
= 1,
44 SECONDARY_ACCOUNT_INDEX_START
= 2,
47 // Structure to describe an account info.
48 struct TestAccountInfo
{
49 const char* const email
;
50 const char* const gaia_id
;
51 const char* const hash
;
52 const char* const display_name
;
55 // Accounts for multi profile test.
56 static const TestAccountInfo kTestAccounts
[] = {
57 {"__dummy__@invalid.domain", "10000", "hashdummy", "Dummy Account"},
58 {"alice@invalid.domain", "10001", "hashalice", "Alice"},
59 {"bob@invalid.domain", "10002", "hashbobbo", "Bob"},
60 {"charlie@invalid.domain", "10003", "hashcharl", "Charlie"},
63 bool IsInNotifications(
64 const message_center::NotificationList::Notifications
& notifications
,
65 const std::string
& id
) {
66 for (const auto& notification
: notifications
) {
67 if (notification
->id() == id
)
73 // Base class observing notification events.
74 class MessageCenterChangeObserver
75 : public message_center::MessageCenterObserver
{
77 MessageCenterChangeObserver() {
78 message_center::MessageCenter::Get()->AddObserver(this);
81 ~MessageCenterChangeObserver() override
{
82 message_center::MessageCenter::Get()->RemoveObserver(this);
87 base::MessageLoop::ScopedNestableTaskAllower
allow(
88 base::MessageLoop::current());
97 base::RunLoop run_loop_
;
99 DISALLOW_COPY_AND_ASSIGN(MessageCenterChangeObserver
);
102 // Class observing of "ADD" notification events.
103 class NotificationAddObserver
: public MessageCenterChangeObserver
{
105 NotificationAddObserver() : count_(1) {}
106 explicit NotificationAddObserver(int count
) : count_(count
) {
107 MessageCenterChangeObserver();
109 ~NotificationAddObserver() override
{}
121 // message_center::MessageCenterObserver:
122 void OnNotificationAdded(const std::string
& notification_id
) override
{
125 notification_ids_
.push_back(notification_id
);
127 if (waiting_
&& count_
== 0)
131 const std::string
& notification_id() const { return notification_ids_
.at(0); }
132 const std::vector
<std::string
>& notification_ids() const {
133 return notification_ids_
;
137 std::vector
<std::string
> notification_ids_
;
138 bool waiting_
= false;
141 DISALLOW_COPY_AND_ASSIGN(NotificationAddObserver
);
144 // Class observing of "UPDATE" notification events.
145 class NotificationUpdateObserver
: public MessageCenterChangeObserver
{
147 NotificationUpdateObserver() {}
148 ~NotificationUpdateObserver() override
{}
151 if (!notification_id_
.empty())
152 return notification_id_
;
157 return notification_id_
;
160 void OnNotificationUpdated(const std::string
& notification_id
) override
{
161 if (notification_id_
.empty()) {
162 notification_id_
= notification_id
;
170 std::string notification_id_
;
171 bool waiting_
= false;
173 DISALLOW_COPY_AND_ASSIGN(NotificationUpdateObserver
);
176 // Class observing of "REMOVE" notification events.
177 class NotificationRemoveObserver
: public MessageCenterChangeObserver
{
179 NotificationRemoveObserver() {}
180 ~NotificationRemoveObserver() override
{}
183 if (!notification_id_
.empty())
184 return notification_id_
;
189 return notification_id_
;
192 // message_center::MessageCenterObserver:
193 void OnNotificationRemoved(
194 const std::string
& notification_id
, bool by_user
) override
{
195 if (notification_id_
.empty()) {
196 notification_id_
= notification_id
;
204 std::string notification_id_
;
205 bool waiting_
= false;
207 DISALLOW_COPY_AND_ASSIGN(NotificationRemoveObserver
);
210 class TestChromeDownloadManagerDelegate
: public ChromeDownloadManagerDelegate
{
212 explicit TestChromeDownloadManagerDelegate(Profile
* profile
)
213 : ChromeDownloadManagerDelegate(profile
), opened_(false) {}
214 ~TestChromeDownloadManagerDelegate() override
{}
216 // ChromeDownloadManagerDelegate override:
217 void OpenDownload(content::DownloadItem
* item
) override
{ opened_
= true; }
219 // Return if the download is opened.
220 bool opened() const { return opened_
; }
226 // Utility method to retrieve a message center.
227 message_center::MessageCenter
* GetMessageCenter() {
228 return message_center::MessageCenter::Get();
231 // Utility method to retrieve a notification object by id.
232 message_center::Notification
* GetNotification(const std::string
& id
) {
233 return GetMessageCenter()->FindVisibleNotificationById(id
);
236 } // anonnymous namespace
238 // Base class for tests
239 class DownloadNotificationTestBase
: public InProcessBrowserTest
{
241 ~DownloadNotificationTestBase() override
{}
243 void SetUpCommandLine(base::CommandLine
* command_line
) override
{
244 // TODO(yoshiki): Remove this after the download notification launches.
245 command_line
->AppendSwitchASCII(switches::kEnableDownloadNotification
,
249 void SetUp() override
{
250 base::FilePath test_data_dir
;
251 PathService::Get(chrome::DIR_TEST_DATA
, &test_data_dir
);
252 embedded_test_server()->ServeFilesFromDirectory(test_data_dir
);
254 ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady());
255 embedded_test_server()->StopThread();
256 InProcessBrowserTest::SetUp();
259 void SetUpOnMainThread() override
{
260 embedded_test_server()->RestartThreadAndListen();
262 content::BrowserThread::PostTask(
263 content::BrowserThread::IO
, FROM_HERE
,
264 base::Bind(&net::URLRequestSlowDownloadJob::AddUrlHandler
));
267 content::DownloadManager
* GetDownloadManager(Browser
* browser
) {
268 return content::BrowserContext::GetDownloadManager(browser
->profile());
272 //////////////////////////////////////////////////
273 // Test with a single profile
274 //////////////////////////////////////////////////
276 class DownloadNotificationTest
: public DownloadNotificationTestBase
{
278 ~DownloadNotificationTest() override
{}
280 void SetUpOnMainThread() override
{
281 Profile
* profile
= browser()->profile();
283 scoped_ptr
<TestChromeDownloadManagerDelegate
> test_delegate
;
284 test_delegate
.reset(new TestChromeDownloadManagerDelegate(profile
));
285 test_delegate
->GetDownloadIdReceiverCallback().Run(
286 content::DownloadItem::kInvalidId
+ 1);
287 DownloadServiceFactory::GetForBrowserContext(profile
)
288 ->SetDownloadManagerDelegateForTesting(test_delegate
.Pass());
290 DownloadNotificationTestBase::SetUpOnMainThread();
293 TestChromeDownloadManagerDelegate
* GetDownloadManagerDelegate() const {
294 return static_cast<TestChromeDownloadManagerDelegate
*>(
295 DownloadServiceFactory::GetForBrowserContext(browser()->profile())
296 ->GetDownloadManagerDelegate());
299 void PrepareIncognitoBrowser() {
300 incognito_browser_
= CreateIncognitoBrowser();
301 Profile
* incognito_profile
= incognito_browser_
->profile();
303 scoped_ptr
<TestChromeDownloadManagerDelegate
> incognito_test_delegate
;
304 incognito_test_delegate
.reset(
305 new TestChromeDownloadManagerDelegate(incognito_profile
));
306 DownloadServiceFactory::GetForBrowserContext(incognito_profile
)
307 ->SetDownloadManagerDelegateForTesting(incognito_test_delegate
.Pass());
310 TestChromeDownloadManagerDelegate
* GetIncognitoDownloadManagerDelegate()
312 Profile
* incognito_profile
= incognito_browser()->profile();
313 return static_cast<TestChromeDownloadManagerDelegate
*>(
314 DownloadServiceFactory::GetForBrowserContext(incognito_profile
)->
315 GetDownloadManagerDelegate());
318 void CreateDownload() {
319 return CreateDownloadForBrowserAndURL(
321 GURL(net::URLRequestSlowDownloadJob::kKnownSizeUrl
));
324 void CreateDownloadForBrowserAndURL(Browser
* browser
, GURL url
) {
325 // Starts a download.
326 NotificationAddObserver download_start_notification_observer
;
327 ui_test_utils::NavigateToURL(browser
, url
);
328 EXPECT_TRUE(download_start_notification_observer
.Wait());
330 // Confirms that a notification is created.
331 notification_id_
= download_start_notification_observer
.notification_id();
332 EXPECT_FALSE(notification_id_
.empty());
333 ASSERT_TRUE(notification());
335 // Confirms that there is only one notification.
336 message_center::NotificationList::Notifications
337 visible_notifications
= GetMessageCenter()->GetVisibleNotifications();
338 EXPECT_EQ(1u, visible_notifications
.size());
339 EXPECT_TRUE(IsInNotifications(visible_notifications
, notification_id_
));
341 // Confirms that a download is also started.
342 std::vector
<content::DownloadItem
*> downloads
;
343 GetDownloadManager(browser
)->GetAllDownloads(&downloads
);
344 EXPECT_EQ(1u, downloads
.size());
345 download_item_
= downloads
[0];
346 ASSERT_TRUE(download_item_
);
349 content::DownloadItem
* download_item() const { return download_item_
; }
350 std::string
notification_id() const { return notification_id_
; }
351 message_center::Notification
* notification() const {
352 return GetNotification(notification_id_
);
354 Browser
* incognito_browser() const { return incognito_browser_
; }
355 base::FilePath
GetDownloadPath() {
356 return DownloadPrefs::FromDownloadManager(GetDownloadManager(browser()))->
361 content::DownloadItem
* download_item_
= nullptr;
362 Browser
* incognito_browser_
= nullptr;
363 std::string notification_id_
;
366 IN_PROC_BROWSER_TEST_F(DownloadNotificationTest
, DownloadFile
) {
369 EXPECT_EQ(l10n_util::GetStringFUTF16(
370 IDS_DOWNLOAD_STATUS_IN_PROGRESS_TITLE
,
371 download_item()->GetFileNameToReportUser().LossyDisplayName()),
372 GetNotification(notification_id())->title());
373 EXPECT_EQ(message_center::NOTIFICATION_TYPE_PROGRESS
,
374 GetNotification(notification_id())->type());
376 NotificationUpdateObserver download_notification_update_observer
;
378 // Requests to complete the download.
379 ui_test_utils::NavigateToURL(
380 browser(), GURL(net::URLRequestSlowDownloadJob::kFinishDownloadUrl
));
382 // Waits for download completion.
383 while (download_item()->GetState() != content::DownloadItem::COMPLETE
) {
384 NotificationUpdateObserver download_change_notification_observer
;
385 download_change_notification_observer
.Wait();
388 // Waits for new notification.
389 download_notification_update_observer
.Wait();
392 EXPECT_EQ(l10n_util::GetStringFUTF16(
393 IDS_DOWNLOAD_STATUS_DOWNLOADED_TITLE
,
394 download_item()->GetFileNameToReportUser().LossyDisplayName()),
395 GetNotification(notification_id())->title());
396 EXPECT_EQ(message_center::NOTIFICATION_TYPE_BASE_FORMAT
,
397 GetNotification(notification_id())->type());
399 // Confirms that there is only one notification.
400 message_center::NotificationList::Notifications
401 visible_notifications
= GetMessageCenter()->GetVisibleNotifications();
402 EXPECT_EQ(1u, visible_notifications
.size());
403 EXPECT_TRUE(IsInNotifications(visible_notifications
, notification_id()));
405 // Opens the message center.
406 GetMessageCenter()->SetVisibility(message_center::VISIBILITY_MESSAGE_CENTER
);
408 // Try to open the downloaded item by clicking the notification.
409 EXPECT_FALSE(GetDownloadManagerDelegate()->opened());
410 GetMessageCenter()->ClickOnNotification(notification_id());
411 EXPECT_TRUE(GetDownloadManagerDelegate()->opened());
413 EXPECT_FALSE(GetNotification(notification_id()));
416 IN_PROC_BROWSER_TEST_F(DownloadNotificationTest
, DownloadDangerousFile
) {
417 GURL
download_url(embedded_test_server()->GetURL(
418 "/downloads/dangerous/dangerous.swf"));
420 content::DownloadTestObserverTerminal
download_terminal_observer(
421 GetDownloadManager(browser()),
423 content::DownloadTestObserver::ON_DANGEROUS_DOWNLOAD_IGNORE
);
425 CreateDownloadForBrowserAndURL(browser(), download_url
);
427 base::FilePath filename
= download_item()->GetFileNameToReportUser();
429 // Checks the download status.
430 EXPECT_EQ(content::DOWNLOAD_DANGER_TYPE_DANGEROUS_FILE
,
431 download_item()->GetDangerType());
432 EXPECT_TRUE(download_item()->IsDangerous());
434 // Opens the message center.
435 GetMessageCenter()->SetVisibility(message_center::VISIBILITY_MESSAGE_CENTER
);
437 NotificationRemoveObserver notification_close_observer
;
438 NotificationAddObserver notification_add_observer
;
440 // Cicks the "keep" button.
441 notification()->ButtonClick(1); // 2nd button: "Keep"
442 // Clicking makes the message center closed.
443 GetMessageCenter()->SetVisibility(message_center::VISIBILITY_TRANSIENT
);
445 // Confirms that the notification is closed and re-shown.
446 EXPECT_EQ(notification_id(), notification_close_observer
.Wait());
447 notification_add_observer
.Wait();
448 EXPECT_EQ(notification_id(), notification_add_observer
.notification_id());
449 EXPECT_EQ(1u, GetMessageCenter()->GetVisibleNotifications().size());
451 // Checks the download status.
452 EXPECT_EQ(content::DOWNLOAD_DANGER_TYPE_USER_VALIDATED
,
453 download_item()->GetDangerType());
454 EXPECT_FALSE(download_item()->IsDangerous());
456 // Wait for the download completion.
457 download_terminal_observer
.WaitForFinished();
459 // Checks the download status.
460 EXPECT_FALSE(download_item()->IsDangerous());
461 EXPECT_EQ(content::DownloadItem::COMPLETE
, download_item()->GetState());
463 // Checks the downloaded file.
464 EXPECT_TRUE(base::PathExists(GetDownloadPath().Append(filename
.BaseName())));
467 IN_PROC_BROWSER_TEST_F(DownloadNotificationTest
, DiscardDangerousFile
) {
468 GURL
download_url(embedded_test_server()->GetURL(
469 "/downloads/dangerous/dangerous.swf"));
471 content::DownloadTestObserverTerminal
download_terminal_observer(
472 GetDownloadManager(browser()),
474 content::DownloadTestObserver::ON_DANGEROUS_DOWNLOAD_IGNORE
);
476 CreateDownloadForBrowserAndURL(browser(), download_url
);
478 base::FilePath filename
= download_item()->GetFileNameToReportUser();
480 // Checks the download status.
481 EXPECT_EQ(content::DOWNLOAD_DANGER_TYPE_DANGEROUS_FILE
,
482 download_item()->GetDangerType());
483 EXPECT_TRUE(download_item()->IsDangerous());
485 // Opens the message center.
486 GetMessageCenter()->SetVisibility(message_center::VISIBILITY_MESSAGE_CENTER
);
488 NotificationRemoveObserver notification_close_observer
;
490 // Clicks the "Discard" button.
491 notification()->ButtonClick(0); // 1st button: "Discard"
492 // Clicking makes the message center closed.
493 GetMessageCenter()->SetVisibility(message_center::VISIBILITY_TRANSIENT
);
495 // Confirms that the notification is closed.
496 EXPECT_EQ(notification_id(), notification_close_observer
.Wait());
498 // Wait for the download completion.
499 download_terminal_observer
.WaitForFinished();
501 // Checks there is neither any download nor any notification.
502 EXPECT_EQ(0u, GetMessageCenter()->GetVisibleNotifications().size());
503 std::vector
<content::DownloadItem
*> downloads
;
504 GetDownloadManager(browser())->GetAllDownloads(&downloads
);
505 EXPECT_EQ(0u, downloads
.size());
507 // Checks the downloaded file doesn't exist.
508 EXPECT_FALSE(base::PathExists(GetDownloadPath().Append(filename
.BaseName())));
511 IN_PROC_BROWSER_TEST_F(DownloadNotificationTest
, DownloadImageFile
) {
512 GURL
download_url(embedded_test_server()->GetURL(
513 "/downloads/image-octet-stream.png"));
515 content::DownloadTestObserverTerminal
download_terminal_observer(
516 GetDownloadManager(browser()), 1u, /* wait_count */
517 content::DownloadTestObserver::ON_DANGEROUS_DOWNLOAD_IGNORE
);
519 CreateDownloadForBrowserAndURL(browser(), download_url
);
521 // Wait for the download completion.
522 download_terminal_observer
.WaitForFinished();
524 // Waits for download completion.
525 while (GetNotification(notification_id())->image().IsEmpty()) {
526 NotificationUpdateObserver download_change_notification_observer
;
527 download_change_notification_observer
.Wait();
531 IN_PROC_BROWSER_TEST_F(DownloadNotificationTest
,
532 CloseNotificationAfterDownload
) {
535 // Requests to complete the download.
536 ui_test_utils::NavigateToURL(
537 browser(), GURL(net::URLRequestSlowDownloadJob::kFinishDownloadUrl
));
539 // Waits for download completion.
540 while (download_item()->GetState() != content::DownloadItem::COMPLETE
) {
541 NotificationUpdateObserver download_change_notification_observer
;
542 download_change_notification_observer
.Wait();
545 // Opens the message center.
546 GetMessageCenter()->SetVisibility(message_center::VISIBILITY_MESSAGE_CENTER
);
548 // Closes the notification.
549 NotificationRemoveObserver notification_close_observer
;
550 GetMessageCenter()->RemoveNotification(notification_id(), true /* by_user */);
551 EXPECT_EQ(notification_id(), notification_close_observer
.Wait());
553 EXPECT_EQ(0u, GetMessageCenter()->GetVisibleNotifications().size());
555 // Confirms that a download is also started.
556 std::vector
<content::DownloadItem
*> downloads
;
557 GetDownloadManager(browser())->GetAllDownloads(&downloads
);
558 EXPECT_EQ(1u, downloads
.size());
559 EXPECT_EQ(content::DownloadItem::COMPLETE
, downloads
[0]->GetState());
562 IN_PROC_BROWSER_TEST_F(DownloadNotificationTest
,
563 CloseNotificationWhileDownloading
) {
566 // Closes the notification.
567 NotificationRemoveObserver notification_close_observer
;
568 GetMessageCenter()->RemoveNotification(notification_id(), true /* by_user */);
569 EXPECT_EQ(notification_id(), notification_close_observer
.Wait());
571 EXPECT_EQ(0u, GetMessageCenter()->GetVisibleNotifications().size());
573 // Confirms that a download is still in progress.
574 std::vector
<content::DownloadItem
*> downloads
;
575 content::DownloadManager
* download_manager
= GetDownloadManager(browser());
576 download_manager
->GetAllDownloads(&downloads
);
577 EXPECT_EQ(1u, downloads
.size());
578 EXPECT_EQ(content::DownloadItem::IN_PROGRESS
, downloads
[0]->GetState());
580 // Installs observers before requesting the completion.
581 NotificationAddObserver download_notification_add_observer
;
582 content::DownloadTestObserverTerminal
download_terminal_observer(
585 content::DownloadTestObserver::ON_DANGEROUS_DOWNLOAD_FAIL
);
587 // Requests to complete the download and wait for it.
588 ui_test_utils::NavigateToURL(
589 browser(), GURL(net::URLRequestSlowDownloadJob::kFinishDownloadUrl
));
590 download_terminal_observer
.WaitForFinished();
592 // Waits that new notification.
593 download_notification_add_observer
.Wait();
595 // Confirms that there is only one notification.
596 message_center::NotificationList::Notifications
597 visible_notifications
= GetMessageCenter()->GetVisibleNotifications();
598 EXPECT_EQ(1u, visible_notifications
.size());
599 EXPECT_TRUE(IsInNotifications(visible_notifications
, notification_id()));
602 IN_PROC_BROWSER_TEST_F(DownloadNotificationTest
, InterruptDownload
) {
605 // Installs observers before requesting.
606 NotificationUpdateObserver download_notification_update_observer
;
607 content::DownloadTestObserverTerminal
download_terminal_observer(
608 GetDownloadManager(browser()),
610 content::DownloadTestObserver::ON_DANGEROUS_DOWNLOAD_FAIL
);
612 // Requests to fail the download and wait for it.
613 ui_test_utils::NavigateToURL(
614 browser(), GURL(net::URLRequestSlowDownloadJob::kErrorDownloadUrl
));
615 download_terminal_observer
.WaitForFinished();
617 // Waits that new notification.
618 download_notification_update_observer
.Wait();
620 // Confirms that there is only one notification.
621 message_center::NotificationList::Notifications
622 visible_notifications
= GetMessageCenter()->GetVisibleNotifications();
623 EXPECT_EQ(1u, visible_notifications
.size());
624 EXPECT_TRUE(IsInNotifications(visible_notifications
, notification_id()));
627 EXPECT_EQ(l10n_util::GetStringFUTF16(
628 IDS_DOWNLOAD_STATUS_DOWNLOAD_FAILED_TITLE
,
629 download_item()->GetFileNameToReportUser().LossyDisplayName()),
630 GetNotification(notification_id())->title());
631 EXPECT_EQ(l10n_util::GetStringFUTF16(
632 IDS_DOWNLOAD_STATUS_INTERRUPTED
,
633 l10n_util::GetStringUTF16(
634 IDS_DOWNLOAD_INTERRUPTED_STATUS_NETWORK_ERROR
)),
635 GetNotification(notification_id())->message());
636 EXPECT_EQ(message_center::NOTIFICATION_TYPE_BASE_FORMAT
,
637 GetNotification(notification_id())->type());
640 IN_PROC_BROWSER_TEST_F(DownloadNotificationTest
,
641 InterruptDownloadAfterClosingNotification
) {
644 // Closes the notification.
645 NotificationRemoveObserver notification_close_observer
;
646 GetMessageCenter()->RemoveNotification(notification_id(), true /* by_user */);
647 EXPECT_EQ(notification_id(), notification_close_observer
.Wait());
649 EXPECT_EQ(0u, GetMessageCenter()->GetVisibleNotifications().size());
651 // Confirms that a download is still in progress.
652 std::vector
<content::DownloadItem
*> downloads
;
653 content::DownloadManager
* download_manager
= GetDownloadManager(browser());
654 download_manager
->GetAllDownloads(&downloads
);
655 EXPECT_EQ(1u, downloads
.size());
656 EXPECT_EQ(content::DownloadItem::IN_PROGRESS
, downloads
[0]->GetState());
658 // Installs observers before requesting the completion.
659 NotificationAddObserver download_notification_add_observer
;
660 content::DownloadTestObserverTerminal
download_terminal_observer(
663 content::DownloadTestObserver::ON_DANGEROUS_DOWNLOAD_FAIL
);
665 // Requests to fail the download and wait for it.
666 ui_test_utils::NavigateToURL(
667 browser(), GURL(net::URLRequestSlowDownloadJob::kErrorDownloadUrl
));
668 download_terminal_observer
.WaitForFinished();
670 // Waits that new notification.
671 download_notification_add_observer
.Wait();
673 // Confirms that there is only one notification.
674 message_center::NotificationList::Notifications
675 visible_notifications
= GetMessageCenter()->GetVisibleNotifications();
676 EXPECT_EQ(1u, visible_notifications
.size());
677 EXPECT_TRUE(IsInNotifications(visible_notifications
, notification_id()));
680 IN_PROC_BROWSER_TEST_F(DownloadNotificationTest
, DownloadRemoved
) {
683 NotificationRemoveObserver notification_close_observer
;
684 download_item()->Remove();
685 EXPECT_EQ(notification_id(), notification_close_observer
.Wait());
687 // Confirms that the notification is removed.
688 EXPECT_EQ(0u, GetMessageCenter()->GetVisibleNotifications().size());
690 // Confirms that the download item is removed.
691 std::vector
<content::DownloadItem
*> downloads
;
692 GetDownloadManager(browser())->GetAllDownloads(&downloads
);
693 EXPECT_EQ(0u, downloads
.size());
696 IN_PROC_BROWSER_TEST_F(DownloadNotificationTest
, DownloadMultipleFiles
) {
697 GURL
url1(net::URLRequestSlowDownloadJob::kUnknownSizeUrl
);
698 GURL
url2(net::URLRequestSlowDownloadJob::kKnownSizeUrl
);
700 // Starts the 1st download.
701 NotificationAddObserver download_start_notification_observer1
;
702 ui_test_utils::NavigateToURL(browser(), url1
);
703 EXPECT_TRUE(download_start_notification_observer1
.Wait());
704 std::string notification_id1
=
705 download_start_notification_observer1
.notification_id();
706 EXPECT_FALSE(notification_id1
.empty());
708 // Confirms that there is a download.
709 std::vector
<content::DownloadItem
*> downloads
;
710 GetDownloadManager(browser())->GetAllDownloads(&downloads
);
711 EXPECT_EQ(1u, downloads
.size());
712 content::DownloadItem
* download1or2
= downloads
[0];
714 // Starts the 2nd download and waits for 2 notifications (normal and
716 NotificationAddObserver
download_start_notification_observer2(2);
717 ui_test_utils::NavigateToURL(browser(), url2
);
718 EXPECT_TRUE(download_start_notification_observer2
.Wait());
720 // Confirms that there are 2 downloads.
722 GetDownloadManager(browser())->GetAllDownloads(&downloads
);
723 content::DownloadItem
* download1
= downloads
[0];
724 content::DownloadItem
* download2
= downloads
[1];
725 EXPECT_EQ(2u, downloads
.size());
726 EXPECT_NE(download1
, download2
);
727 EXPECT_TRUE(download1
== download1or2
|| download2
== download1or2
);
729 // Confirms that there is only one group notification.
730 message_center::NotificationList::Notifications
731 visible_notifications
= GetMessageCenter()->GetVisibleNotifications();
732 EXPECT_EQ(3u, visible_notifications
.size());
734 std::string notification_id2
;
735 std::string notification_id_group
;
736 for (auto notification
: visible_notifications
) {
737 if (notification
->id() == notification_id1
) {
739 } else if (notification
->type() ==
740 message_center::NOTIFICATION_TYPE_PROGRESS
) {
741 notification_id2
= (notification
->id());
742 } else if (notification
->type() ==
743 message_center::NOTIFICATION_TYPE_MULTIPLE
) {
744 notification_id_group
= (notification
->id());
747 EXPECT_TRUE(!notification_id2
.empty());
748 EXPECT_TRUE(!notification_id_group
.empty());
749 EXPECT_NE(notification_id2
, notification_id_group
);
751 // Confirms the types of download notifications are correct.
752 EXPECT_EQ(message_center::NOTIFICATION_TYPE_MULTIPLE
,
753 GetNotification(notification_id_group
)->type());
754 EXPECT_EQ(2u, GetNotification(notification_id_group
)->items().size());
755 EXPECT_EQ(2u, GetNotification(notification_id_group
)->items().size());
757 // Requests to complete the downloads.
758 ui_test_utils::NavigateToURL(
759 browser(), GURL(net::URLRequestSlowDownloadJob::kFinishDownloadUrl
));
761 // Waits for the completion of downloads.
762 while (download1
->GetState() != content::DownloadItem::COMPLETE
||
763 download2
->GetState() != content::DownloadItem::COMPLETE
) {
764 NotificationUpdateObserver download_change_notification_observer
;
765 download_change_notification_observer
.Wait();
768 visible_notifications
= GetMessageCenter()->GetVisibleNotifications();
769 EXPECT_EQ(3u, visible_notifications
.size());
770 EXPECT_TRUE(IsInNotifications(visible_notifications
,
771 notification_id_group
));
772 EXPECT_TRUE(IsInNotifications(visible_notifications
,
774 EXPECT_TRUE(IsInNotifications(visible_notifications
,
777 // Confirms the types of download notifications are correct.
778 EXPECT_EQ(message_center::NOTIFICATION_TYPE_BASE_FORMAT
,
779 GetNotification(notification_id1
)->type());
780 EXPECT_EQ(message_center::NOTIFICATION_TYPE_BASE_FORMAT
,
781 GetNotification(notification_id2
)->type());
782 EXPECT_EQ(message_center::NOTIFICATION_TYPE_MULTIPLE
,
783 GetNotification(notification_id_group
)->type());
784 EXPECT_EQ(2u, GetNotification(notification_id_group
)->items().size());
787 IN_PROC_BROWSER_TEST_F(DownloadNotificationTest
,
788 DownloadMultipleFilesOneByOne
) {
790 content::DownloadItem
* first_download_item
= download_item();
791 content::DownloadItem
* second_download_item
= nullptr;
792 std::string first_notification_id
= notification_id();
793 std::string second_notification_id
;
795 // Requests to complete the first download.
796 ui_test_utils::NavigateToURL(
797 browser(), GURL(net::URLRequestSlowDownloadJob::kFinishDownloadUrl
));
799 // Waits for completion of the first download.
800 while (first_download_item
->GetState() != content::DownloadItem::COMPLETE
) {
801 NotificationUpdateObserver download_change_notification_observer
;
802 download_change_notification_observer
.Wait();
804 EXPECT_EQ(content::DownloadItem::COMPLETE
, first_download_item
->GetState());
806 // Checks the message center.
807 EXPECT_EQ(1u, GetMessageCenter()->GetVisibleNotifications().size());
809 // Starts the second download.
810 GURL
url(net::URLRequestSlowDownloadJob::kKnownSizeUrl
);
811 NotificationAddObserver download_start_notification_observer
;
812 ui_test_utils::NavigateToURL(browser(), url
);
813 EXPECT_TRUE(download_start_notification_observer
.Wait());
815 // Confirms that the second notification is created.
816 second_notification_id
=
817 download_start_notification_observer
.notification_id();
818 EXPECT_FALSE(second_notification_id
.empty());
819 ASSERT_TRUE(GetNotification(second_notification_id
));
821 // Confirms that there are two notifications, including the second
823 message_center::NotificationList::Notifications
824 visible_notifications
= GetMessageCenter()->GetVisibleNotifications();
825 EXPECT_EQ(2u, visible_notifications
.size());
826 EXPECT_TRUE(IsInNotifications(visible_notifications
, first_notification_id
));
827 EXPECT_TRUE(IsInNotifications(visible_notifications
, second_notification_id
));
829 // Confirms that the second download is also started.
830 std::vector
<content::DownloadItem
*> downloads
;
831 GetDownloadManager(browser())->GetAllDownloads(&downloads
);
832 EXPECT_EQ(2u, downloads
.size());
833 EXPECT_TRUE(first_download_item
== downloads
[0] ||
834 first_download_item
== downloads
[1]);
835 // Stores the second download.
836 if (first_download_item
== downloads
[0])
837 second_download_item
= downloads
[1];
839 second_download_item
= downloads
[0];
841 EXPECT_EQ(content::DownloadItem::IN_PROGRESS
,
842 second_download_item
->GetState());
844 // Requests to complete the second download.
845 ui_test_utils::NavigateToURL(
846 browser(), GURL(net::URLRequestSlowDownloadJob::kFinishDownloadUrl
));
848 // Waits for completion of the second download.
849 while (second_download_item
->GetState() != content::DownloadItem::COMPLETE
) {
850 NotificationUpdateObserver download_change_notification_observer
;
851 download_change_notification_observer
.Wait();
854 // Opens the message center.
855 GetMessageCenter()->SetVisibility(message_center::VISIBILITY_MESSAGE_CENTER
);
856 // Checks the message center.
857 EXPECT_EQ(2u, GetMessageCenter()->GetVisibleNotifications().size());
860 IN_PROC_BROWSER_TEST_F(DownloadNotificationTest
, CancelDownload
) {
863 // Opens the message center.
864 GetMessageCenter()->SetVisibility(message_center::VISIBILITY_MESSAGE_CENTER
);
866 // Cancels the notification by clicking the "cancel' button.
867 NotificationRemoveObserver notification_close_observer
;
868 notification()->ButtonClick(1);
869 EXPECT_EQ(notification_id(), notification_close_observer
.Wait());
870 EXPECT_EQ(0u, GetMessageCenter()->GetVisibleNotifications().size());
872 // Confirms that a download is also cancelled.
873 std::vector
<content::DownloadItem
*> downloads
;
874 GetDownloadManager(browser())->GetAllDownloads(&downloads
);
875 EXPECT_EQ(1u, downloads
.size());
876 EXPECT_EQ(content::DownloadItem::CANCELLED
, downloads
[0]->GetState());
879 IN_PROC_BROWSER_TEST_F(DownloadNotificationTest
,
880 DownloadCancelledByUserExternally
) {
883 // Cancels the notification by clicking the "cancel' button.
884 NotificationRemoveObserver notification_close_observer
;
885 download_item()->Cancel(true /* by_user */);
886 EXPECT_EQ(notification_id(), notification_close_observer
.Wait());
887 EXPECT_EQ(0u, GetMessageCenter()->GetVisibleNotifications().size());
889 // Confirms that a download is also cancelled.
890 std::vector
<content::DownloadItem
*> downloads
;
891 GetDownloadManager(browser())->GetAllDownloads(&downloads
);
892 EXPECT_EQ(1u, downloads
.size());
893 EXPECT_EQ(content::DownloadItem::CANCELLED
, downloads
[0]->GetState());
896 IN_PROC_BROWSER_TEST_F(DownloadNotificationTest
,
897 DownloadCancelledExternally
) {
900 // Cancels the notification by clicking the "cancel' button.
901 NotificationRemoveObserver notification_close_observer
;
902 download_item()->Cancel(false /* by_user */);
903 EXPECT_EQ(notification_id(), notification_close_observer
.Wait());
904 EXPECT_EQ(0u, GetMessageCenter()->GetVisibleNotifications().size());
906 // Confirms that a download is also cancelled.
907 std::vector
<content::DownloadItem
*> downloads
;
908 GetDownloadManager(browser())->GetAllDownloads(&downloads
);
909 EXPECT_EQ(1u, downloads
.size());
910 EXPECT_EQ(content::DownloadItem::CANCELLED
, downloads
[0]->GetState());
913 IN_PROC_BROWSER_TEST_F(DownloadNotificationTest
, IncognitoDownloadFile
) {
914 PrepareIncognitoBrowser();
916 // Starts an incognito download.
917 CreateDownloadForBrowserAndURL(
919 GURL(net::URLRequestSlowDownloadJob::kKnownSizeUrl
));
921 EXPECT_EQ(l10n_util::GetStringFUTF16(
922 IDS_DOWNLOAD_STATUS_IN_PROGRESS_TITLE
,
923 download_item()->GetFileNameToReportUser().LossyDisplayName()),
924 GetNotification(notification_id())->title());
925 EXPECT_EQ(message_center::NOTIFICATION_TYPE_PROGRESS
,
926 GetNotification(notification_id())->type());
927 EXPECT_TRUE(download_item()->GetBrowserContext()->IsOffTheRecord());
929 // Requests to complete the download.
930 ui_test_utils::NavigateToURL(
932 GURL(net::URLRequestSlowDownloadJob::kFinishDownloadUrl
));
934 // Waits for download completion.
935 while (download_item()->GetState() != content::DownloadItem::COMPLETE
) {
936 NotificationUpdateObserver download_change_notification_observer
;
937 download_change_notification_observer
.Wait();
940 EXPECT_EQ(l10n_util::GetStringFUTF16(
941 IDS_DOWNLOAD_STATUS_DOWNLOADED_TITLE
,
942 download_item()->GetFileNameToReportUser().LossyDisplayName()),
943 GetNotification(notification_id())->title());
944 EXPECT_EQ(message_center::NOTIFICATION_TYPE_BASE_FORMAT
,
945 GetNotification(notification_id())->type());
947 // Opens the message center.
948 GetMessageCenter()->SetVisibility(message_center::VISIBILITY_MESSAGE_CENTER
);
950 // Try to open the downloaded item by clicking the notification.
951 EXPECT_FALSE(GetIncognitoDownloadManagerDelegate()->opened());
952 GetMessageCenter()->ClickOnNotification(notification_id());
953 EXPECT_TRUE(GetIncognitoDownloadManagerDelegate()->opened());
954 EXPECT_FALSE(GetDownloadManagerDelegate()->opened());
956 EXPECT_FALSE(GetNotification(notification_id()));
957 chrome::CloseWindow(incognito_browser());
960 IN_PROC_BROWSER_TEST_F(DownloadNotificationTest
,
961 SimultaneousIncognitoAndNormalDownloads
) {
962 PrepareIncognitoBrowser();
964 GURL
url_incognito(net::URLRequestSlowDownloadJob::kUnknownSizeUrl
);
965 GURL
url_normal(net::URLRequestSlowDownloadJob::kKnownSizeUrl
);
967 // Starts the incognito download.
968 NotificationAddObserver download_start_notification_observer1
;
969 ui_test_utils::NavigateToURL(incognito_browser(), url_incognito
);
970 EXPECT_TRUE(download_start_notification_observer1
.Wait());
971 std::string notification_id1
=
972 download_start_notification_observer1
.notification_id();
973 EXPECT_FALSE(notification_id1
.empty());
975 // Confirms that there is a download.
976 std::vector
<content::DownloadItem
*> downloads
;
977 GetDownloadManager(browser())->GetAllDownloads(&downloads
);
978 EXPECT_EQ(0u, downloads
.size());
980 GetDownloadManager(incognito_browser())->GetAllDownloads(&downloads
);
981 EXPECT_EQ(1u, downloads
.size());
982 content::DownloadItem
* download_incognito
= downloads
[0];
984 // Starts the normal download.
985 NotificationAddObserver download_start_notification_observer2
;
986 ui_test_utils::NavigateToURL(browser(), url_normal
);
987 EXPECT_TRUE(download_start_notification_observer2
.Wait());
988 std::string notification_id2
=
989 download_start_notification_observer2
.notification_id();
990 EXPECT_FALSE(notification_id2
.empty());
992 // Confirms that there are 2 downloads.
994 GetDownloadManager(browser())->GetAllDownloads(&downloads
);
995 content::DownloadItem
* download_normal
= downloads
[0];
996 EXPECT_EQ(1u, downloads
.size());
997 EXPECT_NE(download_normal
, download_incognito
);
999 GetDownloadManager(incognito_browser())->GetAllDownloads(&downloads
);
1000 EXPECT_EQ(1u, downloads
.size());
1001 EXPECT_EQ(download_incognito
, downloads
[0]);
1003 // Confirms the types of download notifications are correct.
1004 EXPECT_EQ(message_center::NOTIFICATION_TYPE_BASE_FORMAT
,
1005 GetNotification(notification_id1
)->type());
1006 EXPECT_EQ(message_center::NOTIFICATION_TYPE_PROGRESS
,
1007 GetNotification(notification_id2
)->type());
1009 EXPECT_TRUE(download_incognito
->GetBrowserContext()->IsOffTheRecord());
1010 EXPECT_FALSE(download_normal
->GetBrowserContext()->IsOffTheRecord());
1012 // Requests to complete the downloads.
1013 ui_test_utils::NavigateToURL(
1014 browser(), GURL(net::URLRequestSlowDownloadJob::kFinishDownloadUrl
));
1016 // Waits for the completion of downloads.
1017 while (download_normal
->GetState() != content::DownloadItem::COMPLETE
||
1018 download_incognito
->GetState() != content::DownloadItem::COMPLETE
) {
1019 NotificationUpdateObserver download_change_notification_observer
;
1020 download_change_notification_observer
.Wait();
1023 // Confirms the types of download notifications are correct.
1024 EXPECT_EQ(message_center::NOTIFICATION_TYPE_BASE_FORMAT
,
1025 GetNotification(notification_id1
)->type());
1026 EXPECT_EQ(message_center::NOTIFICATION_TYPE_BASE_FORMAT
,
1027 GetNotification(notification_id2
)->type());
1029 chrome::CloseWindow(incognito_browser());
1032 //////////////////////////////////////////////////
1033 // Test with multi profiles
1034 //////////////////////////////////////////////////
1036 class MultiProfileDownloadNotificationTest
1037 : public DownloadNotificationTestBase
{
1039 ~MultiProfileDownloadNotificationTest() override
{}
1041 void SetUpCommandLine(base::CommandLine
* command_line
) override
{
1042 DownloadNotificationTestBase::SetUpCommandLine(command_line
);
1044 // Logs in to a dummy profile.
1045 command_line
->AppendSwitchASCII(chromeos::switches::kLoginUser
,
1046 kTestAccounts
[DUMMY_ACCOUNT_INDEX
].email
);
1047 command_line
->AppendSwitchASCII(chromeos::switches::kLoginProfile
,
1048 kTestAccounts
[DUMMY_ACCOUNT_INDEX
].hash
);
1051 // Logs in to the primary profile.
1052 void SetUpOnMainThread() override
{
1053 const TestAccountInfo
& info
= kTestAccounts
[PRIMARY_ACCOUNT_INDEX
];
1055 AddUser(info
, true);
1056 DownloadNotificationTestBase::SetUpOnMainThread();
1059 // Loads all users to the current session and sets up necessary fields.
1060 // This is used for preparing all accounts in PRE_ test setup, and for testing
1061 // actual login behavior.
1062 void AddAllUsers() {
1063 for (size_t i
= 0; i
< arraysize(kTestAccounts
); ++i
)
1064 AddUser(kTestAccounts
[i
], i
>= SECONDARY_ACCOUNT_INDEX_START
);
1067 Profile
* GetProfileByIndex(int index
) {
1068 return chromeos::ProfileHelper::GetProfileByUserIdHash(
1069 kTestAccounts
[index
].hash
);
1072 // Adds a new user for testing to the current session.
1073 void AddUser(const TestAccountInfo
& info
, bool log_in
) {
1074 user_manager::UserManager
* const user_manager
=
1075 user_manager::UserManager::Get();
1077 user_manager
->UserLoggedIn(info
.email
, info
.hash
, false);
1078 user_manager
->SaveUserDisplayName(info
.email
,
1079 base::UTF8ToUTF16(info
.display_name
));
1080 SigninManagerFactory::GetForProfile(
1081 chromeos::ProfileHelper::GetProfileByUserIdHash(info
.hash
))
1082 ->SetAuthenticatedAccountInfo(info
.gaia_id
, info
.email
);
1086 IN_PROC_BROWSER_TEST_F(MultiProfileDownloadNotificationTest
,
1087 PRE_DownloadMultipleFiles
) {
1091 IN_PROC_BROWSER_TEST_F(MultiProfileDownloadNotificationTest
,
1092 DownloadMultipleFiles
) {
1095 GURL
url(net::URLRequestSlowDownloadJob::kUnknownSizeUrl
);
1097 Profile
* profile1
= GetProfileByIndex(1);
1098 Profile
* profile2
= GetProfileByIndex(2);
1099 Browser
* browser1
= CreateBrowser(profile1
);
1100 Browser
* browser2
= CreateBrowser(profile2
);
1101 EXPECT_NE(browser1
, browser2
);
1103 // First user starts a download.
1104 NotificationAddObserver download_start_notification_observer1
;
1105 ui_test_utils::NavigateToURL(browser1
, url
);
1106 download_start_notification_observer1
.Wait();
1108 // Confirms that the download is started.
1109 std::vector
<content::DownloadItem
*> downloads
;
1110 GetDownloadManager(browser1
)->GetAllDownloads(&downloads
);
1111 EXPECT_EQ(1u, downloads
.size());
1112 content::DownloadItem
* download1
= downloads
[0];
1114 // Confirms that a download notification is generated.
1115 std::string notification_id_user1
=
1116 download_start_notification_observer1
.notification_id();
1117 EXPECT_FALSE(notification_id_user1
.empty());
1119 // Second user starts a download.
1120 NotificationAddObserver download_start_notification_observer2
;
1121 ui_test_utils::NavigateToURL(browser2
, url
);
1122 download_start_notification_observer2
.Wait();
1123 std::string notification_id_user2_1
=
1124 download_start_notification_observer2
.notification_id();
1125 EXPECT_FALSE(notification_id_user2_1
.empty());
1127 // Confirms that the second user has only 1 download.
1129 GetDownloadManager(browser2
)->GetAllDownloads(&downloads
);
1130 ASSERT_EQ(1u, downloads
.size());
1132 // Second user starts another download.
1133 NotificationAddObserver
download_start_notification_observer3(2);
1134 ui_test_utils::NavigateToURL(browser2
, url
);
1135 download_start_notification_observer3
.Wait();
1136 std::string notification_id_user2_2
;
1137 std::string notification_id_user2_group
;
1139 auto added_notification_ids
=
1140 download_start_notification_observer3
.notification_ids();
1141 EXPECT_EQ(2u, added_notification_ids
.size());
1142 for (auto notification_id
: added_notification_ids
) {
1143 if (GetNotification(notification_id
)->type() ==
1144 message_center::NOTIFICATION_TYPE_MULTIPLE
) {
1145 notification_id_user2_group
= notification_id
;
1147 notification_id_user2_2
= notification_id
;
1151 EXPECT_FALSE(notification_id_user2_2
.empty());
1152 EXPECT_FALSE(notification_id_user2_group
.empty());
1154 // Confirms that the second user has 2 downloads.
1156 GetDownloadManager(browser2
)->GetAllDownloads(&downloads
);
1157 ASSERT_EQ(2u, downloads
.size());
1158 content::DownloadItem
* download2
= downloads
[0];
1159 content::DownloadItem
* download3
= downloads
[1];
1160 EXPECT_NE(download1
, download2
);
1161 EXPECT_NE(download1
, download3
);
1162 EXPECT_NE(download2
, download3
);
1164 // Confirms that the first user still has only 1 download.
1166 GetDownloadManager(browser1
)->GetAllDownloads(&downloads
);
1167 ASSERT_EQ(1u, downloads
.size());
1168 EXPECT_EQ(download1
, downloads
[0]);
1170 // Confirms the types of download notifications are correct.
1171 // Normal notification for user1.
1172 EXPECT_EQ(message_center::NOTIFICATION_TYPE_BASE_FORMAT
,
1173 GetNotification(notification_id_user1
)->type());
1174 // Group notification for user2.
1175 EXPECT_EQ(message_center::NOTIFICATION_TYPE_MULTIPLE
,
1176 GetNotification(notification_id_user2_group
)->type());
1178 GetNotification(notification_id_user2_group
)->items().size());
1179 // Normal notification for user2.
1180 EXPECT_EQ(message_center::NOTIFICATION_TYPE_BASE_FORMAT
,
1181 GetNotification(notification_id_user2_1
)->type());
1182 EXPECT_EQ(message_center::NOTIFICATION_TYPE_BASE_FORMAT
,
1183 GetNotification(notification_id_user2_2
)->type());
1185 // Requests to complete the downloads.
1186 ui_test_utils::NavigateToURL(
1187 browser(), GURL(net::URLRequestSlowDownloadJob::kFinishDownloadUrl
));
1189 // Waits for the completion of downloads.
1190 while (download1
->GetState() != content::DownloadItem::COMPLETE
||
1191 download2
->GetState() != content::DownloadItem::COMPLETE
||
1192 download3
->GetState() != content::DownloadItem::COMPLETE
) {
1193 NotificationUpdateObserver download_change_notification_observer
;
1194 download_change_notification_observer
.Wait();
1197 // Confirms the types of download notifications are correct.
1198 EXPECT_EQ(message_center::NOTIFICATION_TYPE_BASE_FORMAT
,
1199 GetNotification(notification_id_user1
)->type());
1200 EXPECT_EQ(message_center::NOTIFICATION_TYPE_BASE_FORMAT
,
1201 GetNotification(notification_id_user2_1
)->type());
1202 // There is still a group notification.
1203 EXPECT_EQ(message_center::NOTIFICATION_TYPE_MULTIPLE
,
1204 GetNotification(notification_id_user2_group
)->type());
1206 GetNotification(notification_id_user2_group
)->items().size());
1207 // Normal notifications for user2.
1208 EXPECT_EQ(message_center::NOTIFICATION_TYPE_BASE_FORMAT
,
1209 GetNotification(notification_id_user2_1
)->type());
1210 EXPECT_EQ(message_center::NOTIFICATION_TYPE_BASE_FORMAT
,
1211 GetNotification(notification_id_user2_2
)->type());