| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "chrome/browser/ui/views/message_center/web_notification_tray.h" | 5 #include "chrome/browser/ui/views/message_center/web_notification_tray.h" |
| 6 | 6 |
| 7 #include <set> | 7 #include <set> |
| 8 | 8 |
| 9 #include "ash/root_window_controller.h" | 9 #include "ash/root_window_controller.h" |
| 10 #include "ash/system/status_area_widget.h" | 10 #include "ash/system/status_area_widget.h" |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 59 private: | 59 private: |
| 60 virtual ~TestNotificationDelegate() {} | 60 virtual ~TestNotificationDelegate() {} |
| 61 | 61 |
| 62 std::string id_; | 62 std::string id_; |
| 63 }; | 63 }; |
| 64 | 64 |
| 65 void AddNotification(const std::string& delegate_id, | 65 void AddNotification(const std::string& delegate_id, |
| 66 const std::string& replace_id) { | 66 const std::string& replace_id) { |
| 67 ::Notification notification( | 67 ::Notification notification( |
| 68 GURL("chrome-extension://abbccedd"), | 68 GURL("chrome-extension://abbccedd"), |
| 69 GURL(), | |
| 70 base::ASCIIToUTF16("Test Web Notification"), | 69 base::ASCIIToUTF16("Test Web Notification"), |
| 71 base::ASCIIToUTF16("Notification message body."), | 70 base::ASCIIToUTF16("Notification message body."), |
| 72 blink::WebTextDirectionDefault, | 71 gfx::Image(), |
| 73 base::string16(), | 72 base::string16(), |
| 74 base::ASCIIToUTF16(replace_id), | 73 base::ASCIIToUTF16(replace_id), |
| 75 new TestNotificationDelegate(delegate_id)); | 74 new TestNotificationDelegate(delegate_id)); |
| 76 | 75 |
| 77 g_browser_process->notification_ui_manager()->Add( | 76 g_browser_process->notification_ui_manager()->Add(notification, |
| 78 notification, browser()->profile()); | 77 browser()->profile()); |
| 79 } | 78 } |
| 80 | 79 |
| 81 std::string FindNotificationIdByDelegateId(const std::string& delegate_id) { | 80 std::string FindNotificationIdByDelegateId(const std::string& delegate_id) { |
| 82 const ::Notification* notification = | 81 const ::Notification* notification = |
| 83 g_browser_process->notification_ui_manager()->FindById( | 82 g_browser_process->notification_ui_manager()->FindById( |
| 84 delegate_id, | 83 delegate_id, |
| 85 NotificationUIManager::GetProfileID(browser()->profile())); | 84 NotificationUIManager::GetProfileID(browser()->profile())); |
| 86 EXPECT_TRUE(notification); | 85 EXPECT_TRUE(notification); |
| 87 return notification->id(); | 86 return notification->id(); |
| 88 } | 87 } |
| 89 | 88 |
| 90 void UpdateNotification(const std::string& replace_id, | 89 void UpdateNotification(const std::string& replace_id, |
| 91 const std::string& new_id) { | 90 const std::string& new_id) { |
| 92 ::Notification notification(GURL("chrome-extension://abbccedd"), | 91 ::Notification notification(GURL("chrome-extension://abbccedd"), |
| 93 GURL(""), | |
| 94 base::ASCIIToUTF16("Updated Web Notification"), | 92 base::ASCIIToUTF16("Updated Web Notification"), |
| 95 base::ASCIIToUTF16("Updated message body."), | 93 base::ASCIIToUTF16("Updated message body."), |
| 96 blink::WebTextDirectionDefault, | 94 gfx::Image(), |
| 97 base::string16(), | 95 base::string16(), |
| 98 base::ASCIIToUTF16(replace_id), | 96 base::ASCIIToUTF16(replace_id), |
| 99 new TestNotificationDelegate(new_id)); | 97 new TestNotificationDelegate(new_id)); |
| 100 | 98 |
| 101 g_browser_process->notification_ui_manager()->Add( | 99 g_browser_process->notification_ui_manager()->Add(notification, |
| 102 notification, browser()->profile()); | 100 browser()->profile()); |
| 103 } | 101 } |
| 104 | 102 |
| 105 void RemoveNotification(const std::string& id) { | 103 void RemoveNotification(const std::string& id) { |
| 106 g_browser_process->notification_ui_manager()->CancelById( | 104 g_browser_process->notification_ui_manager()->CancelById( |
| 107 id, NotificationUIManager::GetProfileID(browser()->profile())); | 105 id, NotificationUIManager::GetProfileID(browser()->profile())); |
| 108 } | 106 } |
| 109 | 107 |
| 110 bool HasNotification(message_center::MessageCenter* message_center, | 108 bool HasNotification(message_center::MessageCenter* message_center, |
| 111 const std::string& id) { | 109 const std::string& id) { |
| 112 return message_center->FindVisibleNotificationById(id) != NULL; | 110 return message_center->FindVisibleNotificationById(id) != NULL; |
| (...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 258 base::RunLoop().RunUntilIdle(); | 256 base::RunLoop().RunUntilIdle(); |
| 259 EXPECT_TRUE(tray->status_icon_ == NULL); | 257 EXPECT_TRUE(tray->status_icon_ == NULL); |
| 260 AddNotification("test_id", "replace_id"); | 258 AddNotification("test_id", "replace_id"); |
| 261 base::RunLoop().RunUntilIdle(); | 259 base::RunLoop().RunUntilIdle(); |
| 262 EXPECT_TRUE(tray->status_icon_ != NULL); | 260 EXPECT_TRUE(tray->status_icon_ != NULL); |
| 263 RemoveNotification("test_id"); | 261 RemoveNotification("test_id"); |
| 264 base::RunLoop().RunUntilIdle(); | 262 base::RunLoop().RunUntilIdle(); |
| 265 EXPECT_TRUE(tray->status_icon_ == NULL); | 263 EXPECT_TRUE(tray->status_icon_ == NULL); |
| 266 } | 264 } |
| 267 } // namespace message_center | 265 } // namespace message_center |
| OLD | NEW |