| 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 <deque> | 5 #include <deque> |
| 6 #include <string> | 6 #include <string> |
| 7 | 7 |
| 8 #include "base/bind.h" | 8 #include "base/bind.h" |
| 9 #include "base/callback.h" | 9 #include "base/callback.h" |
| 10 #include "base/compiler_specific.h" | 10 #include "base/compiler_specific.h" |
| (...skipping 30 matching lines...) Expand all Loading... |
| 41 #include "content/public/test/test_utils.h" | 41 #include "content/public/test/test_utils.h" |
| 42 #include "googleurl/src/gurl.h" | 42 #include "googleurl/src/gurl.h" |
| 43 #include "net/base/net_util.h" | 43 #include "net/base/net_util.h" |
| 44 #include "net/test/test_server.h" | 44 #include "net/test/test_server.h" |
| 45 #include "testing/gtest/include/gtest/gtest.h" | 45 #include "testing/gtest/include/gtest/gtest.h" |
| 46 #include "ui/base/window_open_disposition.h" | 46 #include "ui/base/window_open_disposition.h" |
| 47 | 47 |
| 48 #if defined(ENABLE_MESSAGE_CENTER) | 48 #if defined(ENABLE_MESSAGE_CENTER) |
| 49 #include "ui/message_center/message_center.h" | 49 #include "ui/message_center/message_center.h" |
| 50 #endif | 50 #endif |
| 51 |
| 52 // Mac implementation of message_center is incomplete. The code builds, but |
| 53 // the tests do not pass <http://crbug.com/179904>. |
| 54 #if defined(ENABLE_MESSAGE_CENTER) && !defined(OS_MACOSX) |
| 55 #define ENABLE_MESSAGE_CENTER_TESTING 1 |
| 56 #else |
| 57 #define ENABLE_MESSAGE_CENTER_TESTING 0 |
| 58 #endif |
| 59 |
| 51 namespace { | 60 namespace { |
| 52 | 61 |
| 53 const char kExpectedIconUrl[] = "files/notifications/no_such_file.png"; | 62 const char kExpectedIconUrl[] = "files/notifications/no_such_file.png"; |
| 54 | 63 |
| 55 enum InfobarAction { | 64 enum InfobarAction { |
| 56 DISMISS = 0, | 65 DISMISS = 0, |
| 57 ALLOW, | 66 ALLOW, |
| 58 DENY, | 67 DENY, |
| 59 }; | 68 }; |
| 60 | 69 |
| 61 #if defined(ENABLE_MESSAGE_CENTER) | 70 #if ENABLE_MESSAGE_CENTER_TESTING |
| 62 class MessageCenterChangeObserver | 71 class MessageCenterChangeObserver |
| 63 : public message_center::MessageCenter::Observer { | 72 : public message_center::MessageCenter::Observer { |
| 64 public: | 73 public: |
| 65 MessageCenterChangeObserver() | 74 MessageCenterChangeObserver() |
| 66 : notification_received_(false) { | 75 : notification_received_(false) { |
| 67 message_center::MessageCenter::Get()->AddObserver(this); | 76 message_center::MessageCenter::Get()->AddObserver(this); |
| 68 } | 77 } |
| 69 | 78 |
| 70 ~MessageCenterChangeObserver() { | 79 ~MessageCenterChangeObserver() { |
| 71 message_center::MessageCenter::Get()->RemoveObserver(this); | 80 message_center::MessageCenter::Get()->RemoveObserver(this); |
| (...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 181 NotificationsTest() {} | 190 NotificationsTest() {} |
| 182 | 191 |
| 183 protected: | 192 protected: |
| 184 // Overriden from InProcessBrowserTest: | 193 // Overriden from InProcessBrowserTest: |
| 185 virtual void SetUpInProcessBrowserTestFixture() OVERRIDE; | 194 virtual void SetUpInProcessBrowserTestFixture() OVERRIDE; |
| 186 | 195 |
| 187 int GetNotificationCount(); | 196 int GetNotificationCount(); |
| 188 | 197 |
| 189 void CloseBrowserWindow(Browser* browser); | 198 void CloseBrowserWindow(Browser* browser); |
| 190 void CrashTab(Browser* browser, int index); | 199 void CrashTab(Browser* browser, int index); |
| 191 #if !defined(ENABLE_MESSAGE_CENTER) | 200 #if !ENABLE_MESSAGE_CENTER_TESTING |
| 192 const std::deque<Balloon*>& GetActiveBalloons(); | 201 const std::deque<Balloon*>& GetActiveBalloons(); |
| 193 void CrashNotification(Balloon* balloon); | 202 void CrashNotification(Balloon* balloon); |
| 194 bool CloseNotificationAndWait(const Notification& notification); | 203 bool CloseNotificationAndWait(const Notification& notification); |
| 195 #endif | 204 #endif |
| 196 | 205 |
| 197 void SetDefaultPermissionSetting(ContentSetting setting); | 206 void SetDefaultPermissionSetting(ContentSetting setting); |
| 198 void DenyOrigin(const GURL& origin); | 207 void DenyOrigin(const GURL& origin); |
| 199 void AllowOrigin(const GURL& origin); | 208 void AllowOrigin(const GURL& origin); |
| 200 void AllowAllOrigins(); | 209 void AllowAllOrigins(); |
| 201 | 210 |
| (...skipping 28 matching lines...) Expand all Loading... |
| 230 void NotificationsTest::SetUpInProcessBrowserTestFixture() { | 239 void NotificationsTest::SetUpInProcessBrowserTestFixture() { |
| 231 InProcessBrowserTest::SetUpInProcessBrowserTestFixture(); | 240 InProcessBrowserTest::SetUpInProcessBrowserTestFixture(); |
| 232 | 241 |
| 233 ASSERT_TRUE(test_server()->Start()); | 242 ASSERT_TRUE(test_server()->Start()); |
| 234 empty_page_url_ = test_server()->GetURL("files/empty.html"); | 243 empty_page_url_ = test_server()->GetURL("files/empty.html"); |
| 235 test_page_url_ = test_server()->GetURL( | 244 test_page_url_ = test_server()->GetURL( |
| 236 "files/notifications/notification_tester.html"); | 245 "files/notifications/notification_tester.html"); |
| 237 } | 246 } |
| 238 | 247 |
| 239 int NotificationsTest::GetNotificationCount() { | 248 int NotificationsTest::GetNotificationCount() { |
| 240 #if defined(ENABLE_MESSAGE_CENTER) | 249 #if ENABLE_MESSAGE_CENTER_TESTING |
| 241 return message_center::MessageCenter::Get()->NotificationCount(); | 250 return message_center::MessageCenter::Get()->NotificationCount(); |
| 242 #else | 251 #else |
| 243 return BalloonNotificationUIManager::GetInstanceForTesting()-> | 252 return BalloonNotificationUIManager::GetInstanceForTesting()-> |
| 244 balloon_collection()->GetActiveBalloons().size(); | 253 balloon_collection()->GetActiveBalloons().size(); |
| 245 #endif // defined(ENABLE_MESSAGE_CENTER) | 254 #endif // ENABLE_MESSAGE_CENTER_TESTING |
| 246 } | 255 } |
| 247 | 256 |
| 248 void NotificationsTest::CloseBrowserWindow(Browser* browser) { | 257 void NotificationsTest::CloseBrowserWindow(Browser* browser) { |
| 249 content::WindowedNotificationObserver observer( | 258 content::WindowedNotificationObserver observer( |
| 250 chrome::NOTIFICATION_BROWSER_CLOSED, | 259 chrome::NOTIFICATION_BROWSER_CLOSED, |
| 251 content::Source<Browser>(browser)); | 260 content::Source<Browser>(browser)); |
| 252 browser->window()->Close(); | 261 browser->window()->Close(); |
| 253 observer.Wait(); | 262 observer.Wait(); |
| 254 } | 263 } |
| 255 | 264 |
| 256 void NotificationsTest::CrashTab(Browser* browser, int index) { | 265 void NotificationsTest::CrashTab(Browser* browser, int index) { |
| 257 content::CrashTab(browser->tab_strip_model()->GetWebContentsAt(index)); | 266 content::CrashTab(browser->tab_strip_model()->GetWebContentsAt(index)); |
| 258 } | 267 } |
| 259 | 268 |
| 260 #if !defined(ENABLE_MESSAGE_CENTER) | 269 #if !ENABLE_MESSAGE_CENTER_TESTING |
| 261 | 270 |
| 262 const std::deque<Balloon*>& NotificationsTest::GetActiveBalloons() { | 271 const std::deque<Balloon*>& NotificationsTest::GetActiveBalloons() { |
| 263 return BalloonNotificationUIManager::GetInstanceForTesting()-> | 272 return BalloonNotificationUIManager::GetInstanceForTesting()-> |
| 264 balloon_collection()->GetActiveBalloons(); | 273 balloon_collection()->GetActiveBalloons(); |
| 265 } | 274 } |
| 266 | 275 |
| 267 void NotificationsTest::CrashNotification(Balloon* balloon) { | 276 void NotificationsTest::CrashNotification(Balloon* balloon) { |
| 268 content::CrashTab(balloon->balloon_view()->GetHost()->web_contents()); | 277 content::CrashTab(balloon->balloon_view()->GetHost()->web_contents()); |
| 269 } | 278 } |
| 270 | 279 |
| 271 bool NotificationsTest::CloseNotificationAndWait( | 280 bool NotificationsTest::CloseNotificationAndWait( |
| 272 const Notification& notification) { | 281 const Notification& notification) { |
| 273 NotificationChangeObserver observer; | 282 NotificationChangeObserver observer; |
| 274 bool success = g_browser_process->notification_ui_manager()-> | 283 bool success = g_browser_process->notification_ui_manager()-> |
| 275 CancelById(notification.notification_id()); | 284 CancelById(notification.notification_id()); |
| 276 if (success) | 285 if (success) |
| 277 return observer.Wait(); | 286 return observer.Wait(); |
| 278 return false; | 287 return false; |
| 279 } | 288 } |
| 280 | 289 |
| 281 #endif // !defined(ENABLE_MESSAGE_CENTER) | 290 #endif // !ENABLE_MESSAGE_CENTER_TESTING |
| 282 | 291 |
| 283 void NotificationsTest::SetDefaultPermissionSetting(ContentSetting setting) { | 292 void NotificationsTest::SetDefaultPermissionSetting(ContentSetting setting) { |
| 284 DesktopNotificationService* service = GetDesktopNotificationService(); | 293 DesktopNotificationService* service = GetDesktopNotificationService(); |
| 285 service->SetDefaultContentSetting(setting); | 294 service->SetDefaultContentSetting(setting); |
| 286 } | 295 } |
| 287 | 296 |
| 288 void NotificationsTest::DenyOrigin(const GURL& origin) { | 297 void NotificationsTest::DenyOrigin(const GURL& origin) { |
| 289 DropOriginPreference(origin); | 298 DropOriginPreference(origin); |
| 290 GetDesktopNotificationService()->DenyPermission(origin); | 299 GetDesktopNotificationService()->DenyPermission(origin); |
| 291 } | 300 } |
| (...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 493 IN_PROC_BROWSER_TEST_F(NotificationsTest, TestCreateSimpleNotification) { | 502 IN_PROC_BROWSER_TEST_F(NotificationsTest, TestCreateSimpleNotification) { |
| 494 // Creates a simple notification. | 503 // Creates a simple notification. |
| 495 AllowAllOrigins(); | 504 AllowAllOrigins(); |
| 496 ui_test_utils::NavigateToURL(browser(), test_page_url_); | 505 ui_test_utils::NavigateToURL(browser(), test_page_url_); |
| 497 | 506 |
| 498 std::string result = CreateSimpleNotification(browser(), true); | 507 std::string result = CreateSimpleNotification(browser(), true); |
| 499 EXPECT_NE("-1", result); | 508 EXPECT_NE("-1", result); |
| 500 | 509 |
| 501 GURL EXPECTED_ICON_URL = test_server()->GetURL(kExpectedIconUrl); | 510 GURL EXPECTED_ICON_URL = test_server()->GetURL(kExpectedIconUrl); |
| 502 ASSERT_EQ(1, GetNotificationCount()); | 511 ASSERT_EQ(1, GetNotificationCount()); |
| 503 #if defined(ENABLE_MESSAGE_CENTER) | 512 #if ENABLE_MESSAGE_CENTER_TESTING |
| 504 message_center::NotificationList* notification_list = | 513 message_center::NotificationList* notification_list = |
| 505 message_center::MessageCenter::Get()->notification_list(); | 514 message_center::MessageCenter::Get()->notification_list(); |
| 506 message_center::NotificationList::Notifications notifications = | 515 message_center::NotificationList::Notifications notifications = |
| 507 notification_list->GetNotifications(); | 516 notification_list->GetNotifications(); |
| 508 EXPECT_EQ(ASCIIToUTF16("My Title"), (*notifications.rbegin())->title()); | 517 EXPECT_EQ(ASCIIToUTF16("My Title"), (*notifications.rbegin())->title()); |
| 509 EXPECT_EQ(ASCIIToUTF16("My Body"), (*notifications.rbegin())->message()); | 518 EXPECT_EQ(ASCIIToUTF16("My Body"), (*notifications.rbegin())->message()); |
| 510 #else | 519 #else |
| 511 const std::deque<Balloon*>& balloons = GetActiveBalloons(); | 520 const std::deque<Balloon*>& balloons = GetActiveBalloons(); |
| 512 ASSERT_EQ(1U, balloons.size()); | 521 ASSERT_EQ(1U, balloons.size()); |
| 513 Balloon* balloon = balloons[0]; | 522 Balloon* balloon = balloons[0]; |
| 514 const Notification& notification = balloon->notification(); | 523 const Notification& notification = balloon->notification(); |
| 515 EXPECT_EQ(EXPECTED_ICON_URL, notification.icon_url()); | 524 EXPECT_EQ(EXPECTED_ICON_URL, notification.icon_url()); |
| 516 EXPECT_EQ(ASCIIToUTF16("My Title"), notification.title()); | 525 EXPECT_EQ(ASCIIToUTF16("My Title"), notification.title()); |
| 517 EXPECT_EQ(ASCIIToUTF16("My Body"), notification.body()); | 526 EXPECT_EQ(ASCIIToUTF16("My Body"), notification.body()); |
| 518 #endif | 527 #endif |
| 519 } | 528 } |
| 520 | 529 |
| 521 IN_PROC_BROWSER_TEST_F(NotificationsTest, TestCloseNotification) { | 530 IN_PROC_BROWSER_TEST_F(NotificationsTest, TestCloseNotification) { |
| 522 // Creates a notification and closes it. | 531 // Creates a notification and closes it. |
| 523 AllowAllOrigins(); | 532 AllowAllOrigins(); |
| 524 ui_test_utils::NavigateToURL(browser(), test_page_url_); | 533 ui_test_utils::NavigateToURL(browser(), test_page_url_); |
| 525 | 534 |
| 526 std::string result = CreateSimpleNotification(browser(), true); | 535 std::string result = CreateSimpleNotification(browser(), true); |
| 527 EXPECT_NE("-1", result); | 536 EXPECT_NE("-1", result); |
| 528 ASSERT_EQ(1, GetNotificationCount()); | 537 ASSERT_EQ(1, GetNotificationCount()); |
| 529 | 538 |
| 530 #if defined(ENABLE_MESSAGE_CENTER) | 539 #if ENABLE_MESSAGE_CENTER_TESTING |
| 531 message_center::NotificationList* notification_list = | 540 message_center::NotificationList* notification_list = |
| 532 message_center::MessageCenter::Get()->notification_list(); | 541 message_center::MessageCenter::Get()->notification_list(); |
| 533 message_center::NotificationList::Notifications notifications = | 542 message_center::NotificationList::Notifications notifications = |
| 534 notification_list->GetNotifications(); | 543 notification_list->GetNotifications(); |
| 535 message_center::MessageCenter::Get()->SendRemoveNotification( | 544 message_center::MessageCenter::Get()->SendRemoveNotification( |
| 536 (*notifications.rbegin())->id(), | 545 (*notifications.rbegin())->id(), |
| 537 true); // by_user | 546 true); // by_user |
| 538 #else | 547 #else |
| 539 const std::deque<Balloon*>& balloons = GetActiveBalloons(); | 548 const std::deque<Balloon*>& balloons = GetActiveBalloons(); |
| 540 EXPECT_TRUE(CloseNotificationAndWait(balloons[0]->notification())); | 549 EXPECT_TRUE(CloseNotificationAndWait(balloons[0]->notification())); |
| 541 #endif // ENABLE_MESSAGE_CENTER | 550 #endif // ENABLE_MESSAGE_CENTER_TESTING |
| 542 | 551 |
| 543 ASSERT_EQ(0, GetNotificationCount()); | 552 ASSERT_EQ(0, GetNotificationCount()); |
| 544 } | 553 } |
| 545 | 554 |
| 546 IN_PROC_BROWSER_TEST_F(NotificationsTest, TestCancelNotification) { | 555 IN_PROC_BROWSER_TEST_F(NotificationsTest, TestCancelNotification) { |
| 547 // Creates a notification and cancels it in the origin page. | 556 // Creates a notification and cancels it in the origin page. |
| 548 AllowAllOrigins(); | 557 AllowAllOrigins(); |
| 549 ui_test_utils::NavigateToURL(browser(), test_page_url_); | 558 ui_test_utils::NavigateToURL(browser(), test_page_url_); |
| 550 | 559 |
| 551 std::string note_id = CreateSimpleNotification(browser(), true); | 560 std::string note_id = CreateSimpleNotification(browser(), true); |
| (...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 682 ui_test_utils::NavigateToURL(browser(), test_page_url_); | 691 ui_test_utils::NavigateToURL(browser(), test_page_url_); |
| 683 CreateSimpleNotification(browser(), true); | 692 CreateSimpleNotification(browser(), true); |
| 684 ASSERT_EQ(1, GetNotificationCount()); | 693 ASSERT_EQ(1, GetNotificationCount()); |
| 685 | 694 |
| 686 DenyOrigin(test_page_url_.GetOrigin()); | 695 DenyOrigin(test_page_url_.GetOrigin()); |
| 687 ContentSettingsForOneType settings; | 696 ContentSettingsForOneType settings; |
| 688 GetPrefsByContentSetting(CONTENT_SETTING_BLOCK, &settings); | 697 GetPrefsByContentSetting(CONTENT_SETTING_BLOCK, &settings); |
| 689 ASSERT_TRUE(CheckOriginInSetting(settings, test_page_url_.GetOrigin())); | 698 ASSERT_TRUE(CheckOriginInSetting(settings, test_page_url_.GetOrigin())); |
| 690 | 699 |
| 691 EXPECT_EQ(1, GetNotificationCount()); | 700 EXPECT_EQ(1, GetNotificationCount()); |
| 692 #if defined(ENABLE_MESSAGE_CENTER) | 701 #if ENABLE_MESSAGE_CENTER_TESTING |
| 693 message_center::NotificationList* notification_list = | 702 message_center::NotificationList* notification_list = |
| 694 message_center::MessageCenter::Get()->notification_list(); | 703 message_center::MessageCenter::Get()->notification_list(); |
| 695 message_center::NotificationList::Notifications notifications = | 704 message_center::NotificationList::Notifications notifications = |
| 696 notification_list->GetNotifications(); | 705 notification_list->GetNotifications(); |
| 697 message_center::MessageCenter::Get()->SendRemoveNotification( | 706 message_center::MessageCenter::Get()->SendRemoveNotification( |
| 698 (*notifications.rbegin())->id(), | 707 (*notifications.rbegin())->id(), |
| 699 true); // by_user | 708 true); // by_user |
| 700 #else | 709 #else |
| 701 const std::deque<Balloon*>& balloons = GetActiveBalloons(); | 710 const std::deque<Balloon*>& balloons = GetActiveBalloons(); |
| 702 ASSERT_TRUE(CloseNotificationAndWait(balloons[0]->notification())); | 711 ASSERT_TRUE(CloseNotificationAndWait(balloons[0]->notification())); |
| 703 #endif // ENABLE_MESSAGE_CENTER | 712 #endif // ENABLE_MESSAGE_CENTER_TESTING |
| 704 ASSERT_EQ(0, GetNotificationCount()); | 713 ASSERT_EQ(0, GetNotificationCount()); |
| 705 } | 714 } |
| 706 | 715 |
| 707 // Crashes on Linux/Win. See http://crbug.com/160657. | 716 // Crashes on Linux/Win. See http://crbug.com/160657. |
| 708 IN_PROC_BROWSER_TEST_F( | 717 IN_PROC_BROWSER_TEST_F( |
| 709 NotificationsTest, | 718 NotificationsTest, |
| 710 DISABLED_TestOriginPrefsNotSavedInIncognito) { | 719 DISABLED_TestOriginPrefsNotSavedInIncognito) { |
| 711 // Verify that allow/deny origin preferences are not saved in incognito. | 720 // Verify that allow/deny origin preferences are not saved in incognito. |
| 712 Browser* incognito = CreateIncognitoBrowser(); | 721 Browser* incognito = CreateIncognitoBrowser(); |
| 713 ui_test_utils::NavigateToURL(incognito, test_page_url_); | 722 ui_test_utils::NavigateToURL(incognito, test_page_url_); |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 756 empty_page_url_, | 765 empty_page_url_, |
| 757 NEW_BACKGROUND_TAB, | 766 NEW_BACKGROUND_TAB, |
| 758 ui_test_utils::BROWSER_TEST_WAIT_FOR_TAB); | 767 ui_test_utils::BROWSER_TEST_WAIT_FOR_TAB); |
| 759 browser()->tab_strip_model()->ActivateTabAt(0, true); | 768 browser()->tab_strip_model()->ActivateTabAt(0, true); |
| 760 ui_test_utils::NavigateToURL(browser(), test_page_url_); | 769 ui_test_utils::NavigateToURL(browser(), test_page_url_); |
| 761 ASSERT_TRUE(RequestPermissionAndWait(browser())); | 770 ASSERT_TRUE(RequestPermissionAndWait(browser())); |
| 762 CrashTab(browser(), 0); | 771 CrashTab(browser(), 0); |
| 763 } | 772 } |
| 764 | 773 |
| 765 // Notifications don't have their own process with the message center. | 774 // Notifications don't have their own process with the message center. |
| 766 #if !defined(ENABLE_MESSAGE_CENTER) | 775 #if !ENABLE_MESSAGE_CENTER_TESTING |
| 767 IN_PROC_BROWSER_TEST_F(NotificationsTest, TestKillNotificationProcess) { | 776 IN_PROC_BROWSER_TEST_F(NotificationsTest, TestKillNotificationProcess) { |
| 768 // Test killing a notification doesn't crash Chrome. | 777 // Test killing a notification doesn't crash Chrome. |
| 769 AllowAllOrigins(); | 778 AllowAllOrigins(); |
| 770 ui_test_utils::NavigateToURL(browser(), test_page_url_); | 779 ui_test_utils::NavigateToURL(browser(), test_page_url_); |
| 771 CreateSimpleNotification(browser(), true); | 780 CreateSimpleNotification(browser(), true); |
| 772 ASSERT_EQ(1, GetNotificationCount()); | 781 ASSERT_EQ(1, GetNotificationCount()); |
| 773 | 782 |
| 774 const std::deque<Balloon*>& balloons = GetActiveBalloons(); | 783 const std::deque<Balloon*>& balloons = GetActiveBalloons(); |
| 775 ASSERT_EQ(1U, balloons.size()); | 784 ASSERT_EQ(1U, balloons.size()); |
| 776 CrashNotification(balloons[0]); | 785 CrashNotification(balloons[0]); |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 852 std::string result = CreateNotification( | 861 std::string result = CreateNotification( |
| 853 browser(), true, "abc.png", "Title1", "Body1", "chat"); | 862 browser(), true, "abc.png", "Title1", "Body1", "chat"); |
| 854 EXPECT_NE("-1", result); | 863 EXPECT_NE("-1", result); |
| 855 | 864 |
| 856 ASSERT_EQ(1, GetNotificationCount()); | 865 ASSERT_EQ(1, GetNotificationCount()); |
| 857 | 866 |
| 858 result = CreateNotification( | 867 result = CreateNotification( |
| 859 browser(), false, "no_such_file.png", "Title2", "Body2", "chat"); | 868 browser(), false, "no_such_file.png", "Title2", "Body2", "chat"); |
| 860 EXPECT_NE("-1", result); | 869 EXPECT_NE("-1", result); |
| 861 | 870 |
| 862 #if defined(ENABLE_MESSAGE_CENTER) | 871 #if ENABLE_MESSAGE_CENTER_TESTING |
| 863 ASSERT_EQ(1U, GetNotificationCount()); | 872 ASSERT_EQ(1, GetNotificationCount()); |
| 864 message_center::NotificationList* notification_list = | 873 message_center::NotificationList* notification_list = |
| 865 message_center::MessageCenter::Get()->notification_list(); | 874 message_center::MessageCenter::Get()->notification_list(); |
| 866 message_center::NotificationList::Notifications notifications = | 875 message_center::NotificationList::Notifications notifications = |
| 867 notification_list->GetNotifications(); | 876 notification_list->GetNotifications(); |
| 868 EXPECT_EQ(ASCIIToUTF16("Title2"), (*notifications.rbegin())->title()); | 877 EXPECT_EQ(ASCIIToUTF16("Title2"), (*notifications.rbegin())->title()); |
| 869 EXPECT_EQ(ASCIIToUTF16("Body2"), (*notifications.rbegin())->message()); | 878 EXPECT_EQ(ASCIIToUTF16("Body2"), (*notifications.rbegin())->message()); |
| 870 #else | 879 #else |
| 871 const std::deque<Balloon*>& balloons = GetActiveBalloons(); | 880 const std::deque<Balloon*>& balloons = GetActiveBalloons(); |
| 872 ASSERT_EQ(1U, balloons.size()); | 881 ASSERT_EQ(1U, balloons.size()); |
| 873 Balloon* balloon = balloons[0]; | 882 Balloon* balloon = balloons[0]; |
| 874 const Notification& notification = balloon->notification(); | 883 const Notification& notification = balloon->notification(); |
| 875 GURL EXPECTED_ICON_URL = test_server()->GetURL(kExpectedIconUrl); | 884 GURL EXPECTED_ICON_URL = test_server()->GetURL(kExpectedIconUrl); |
| 876 EXPECT_EQ(EXPECTED_ICON_URL, notification.icon_url()); | 885 EXPECT_EQ(EXPECTED_ICON_URL, notification.icon_url()); |
| 877 EXPECT_EQ(ASCIIToUTF16("Title2"), notification.title()); | 886 EXPECT_EQ(ASCIIToUTF16("Title2"), notification.title()); |
| 878 EXPECT_EQ(ASCIIToUTF16("Body2"), notification.body()); | 887 EXPECT_EQ(ASCIIToUTF16("Body2"), notification.body()); |
| 879 #endif | 888 #endif |
| 880 } | 889 } |
| 881 | 890 |
| 882 #endif // !defined(OS_CHROMEOS) | 891 #endif // !defined(OS_CHROMEOS) |
| OLD | NEW |