X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=src%2Fchrome%2Fbrowser%2Fui%2Fviews%2Fmessage_center%2Fweb_notification_tray_browsertest.cc;h=5e8ea3b55b562a20699645cc1e5d43d023205d34;hb=1afa4dd80ef85af7c90efaea6959db1d92330844;hp=9d2a4fd9589060dc77053d1693a62dff616bb756;hpb=90762837333c13ccf56f2ad88e4481fc71e8d281;p=platform%2Fframework%2Fweb%2Fcrosswalk.git diff --git a/src/chrome/browser/ui/views/message_center/web_notification_tray_browsertest.cc b/src/chrome/browser/ui/views/message_center/web_notification_tray_browsertest.cc index 9d2a4fd..5e8ea3b 100644 --- a/src/chrome/browser/ui/views/message_center/web_notification_tray_browsertest.cc +++ b/src/chrome/browser/ui/views/message_center/web_notification_tray_browsertest.cc @@ -37,9 +37,9 @@ namespace { class WebNotificationTrayTest : public InProcessBrowserTest { public: WebNotificationTrayTest() {} - virtual ~WebNotificationTrayTest() {} + ~WebNotificationTrayTest() override {} - virtual void TearDownOnMainThread() OVERRIDE { + void TearDownOnMainThread() override { message_center::MessageCenter::Get()->RemoveAllNotifications(false); } @@ -47,53 +47,55 @@ class WebNotificationTrayTest : public InProcessBrowserTest { class TestNotificationDelegate : public ::NotificationDelegate { public: explicit TestNotificationDelegate(std::string id) : id_(id) {} - virtual void Display() OVERRIDE {} - virtual void Error() OVERRIDE {} - virtual void Close(bool by_user) OVERRIDE {} - virtual void Click() OVERRIDE {} - virtual std::string id() const OVERRIDE { return id_; } - virtual content::WebContents* GetWebContents() const OVERRIDE { - return NULL; - } + std::string id() const override { return id_; } private: - virtual ~TestNotificationDelegate() {} + ~TestNotificationDelegate() override {} std::string id_; }; - void AddNotification(const std::string& id, const std::string& replace_id) { - ::Notification notification(GURL("chrome-extension://abbccedd"), - GURL(), - base::ASCIIToUTF16("Test Web Notification"), - base::ASCIIToUTF16( - "Notification message body."), - blink::WebTextDirectionDefault, - base::string16(), - base::ASCIIToUTF16(replace_id), - new TestNotificationDelegate(id)); + void AddNotification(const std::string& delegate_id, + const std::string& replace_id) { + ::Notification notification( + GURL("chrome-extension://abbccedd"), + base::ASCIIToUTF16("Test Web Notification"), + base::ASCIIToUTF16("Notification message body."), + gfx::Image(), + base::string16(), + base::ASCIIToUTF16(replace_id), + new TestNotificationDelegate(delegate_id)); + + g_browser_process->notification_ui_manager()->Add(notification, + browser()->profile()); + } - g_browser_process->notification_ui_manager()->Add( - notification, browser()->profile()); + std::string FindNotificationIdByDelegateId(const std::string& delegate_id) { + const ::Notification* notification = + g_browser_process->notification_ui_manager()->FindById( + delegate_id, + NotificationUIManager::GetProfileID(browser()->profile())); + EXPECT_TRUE(notification); + return notification->id(); } void UpdateNotification(const std::string& replace_id, const std::string& new_id) { ::Notification notification(GURL("chrome-extension://abbccedd"), - GURL(""), base::ASCIIToUTF16("Updated Web Notification"), base::ASCIIToUTF16("Updated message body."), - blink::WebTextDirectionDefault, + gfx::Image(), base::string16(), base::ASCIIToUTF16(replace_id), new TestNotificationDelegate(new_id)); - g_browser_process->notification_ui_manager()->Add( - notification, browser()->profile()); + g_browser_process->notification_ui_manager()->Add(notification, + browser()->profile()); } void RemoveNotification(const std::string& id) { - g_browser_process->notification_ui_manager()->CancelById(id); + g_browser_process->notification_ui_manager()->CancelById( + id, NotificationUIManager::GetProfileID(browser()->profile())); } bool HasNotification(message_center::MessageCenter* message_center, @@ -116,12 +118,14 @@ IN_PROC_BROWSER_TEST_F(WebNotificationTrayTest, WebNotifications) { // Add a notification. AddNotification("test_id1", "replace_id1"); EXPECT_EQ(1u, message_center->NotificationCount()); - EXPECT_TRUE(HasNotification(message_center, "test_id1")); + EXPECT_TRUE(HasNotification(message_center, + FindNotificationIdByDelegateId("test_id1"))); EXPECT_FALSE(HasNotification(message_center, "test_id2")); AddNotification("test_id2", "replace_id2"); AddNotification("test_id2", "replace_id2"); EXPECT_EQ(2u, message_center->NotificationCount()); - EXPECT_TRUE(HasNotification(message_center, "test_id1")); + EXPECT_TRUE(HasNotification(message_center, + FindNotificationIdByDelegateId("test_id1"))); // Ensure that updating a notification does not affect the count. UpdateNotification("replace_id2", "test_id3");