| OLD | NEW |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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 <map> | 5 #include <map> |
| 6 #include <string> | 6 #include <string> |
| 7 | 7 |
| 8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
| 9 #include "base/message_loop/message_loop.h" | 9 #include "base/message_loop/message_loop.h" |
| 10 #include "base/strings/string_number_conversions.h" | 10 #include "base/strings/string_number_conversions.h" |
| 11 #include "base/strings/string_util.h" | 11 #include "base/strings/string_util.h" |
| 12 #include "base/strings/stringprintf.h" | 12 #include "base/strings/stringprintf.h" |
| 13 #include "base/strings/utf_string_conversions.h" | 13 #include "base/strings/utf_string_conversions.h" |
| 14 #include "chrome/browser/browser_process.h" | 14 #include "chrome/browser/browser_process.h" |
| 15 #include "chrome/browser/notifications/message_center_notification_manager.h" | 15 #include "chrome/browser/notifications/message_center_notification_manager.h" |
| 16 #include "chrome/browser/notifications/notification.h" | 16 #include "chrome/browser/notifications/notification.h" |
| 17 #include "chrome/browser/notifications/notification_ui_manager.h" | 17 #include "chrome/browser/notifications/notification_ui_manager.h" |
| 18 #include "chrome/browser/profiles/profile.h" | 18 #include "chrome/browser/profiles/profile.h" |
| 19 #include "chrome/browser/ui/browser.h" | 19 #include "chrome/browser/ui/browser.h" |
| 20 #include "chrome/test/base/in_process_browser_test.h" | 20 #include "chrome/test/base/in_process_browser_test.h" |
| 21 #include "chrome/test/base/test_switches.h" | 21 #include "chrome/test/base/test_switches.h" |
| 22 #include "ui/message_center/message_center.h" | 22 #include "ui/message_center/message_center.h" |
| 23 #include "ui/message_center/message_center_types.h" | 23 #include "ui/message_center/message_center_types.h" |
| 24 #include "ui/message_center/notification_types.h" |
| 25 #include "ui/message_center/notifier_settings.h" |
| 24 | 26 |
| 25 class TestAddObserver : public message_center::MessageCenterObserver { | 27 class TestAddObserver : public message_center::MessageCenterObserver { |
| 26 public: | 28 public: |
| 27 explicit TestAddObserver(message_center::MessageCenter* message_center) | 29 explicit TestAddObserver(message_center::MessageCenter* message_center) |
| 28 : message_center_(message_center) { | 30 : message_center_(message_center) { |
| 29 message_center_->AddObserver(this); | 31 message_center_->AddObserver(this); |
| 30 } | 32 } |
| 31 | 33 |
| 32 ~TestAddObserver() override { message_center_->RemoveObserver(this); } | 34 ~TestAddObserver() override { message_center_->RemoveObserver(this); } |
| 33 | 35 |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 95 }; | 97 }; |
| 96 | 98 |
| 97 Notification CreateTestNotification(const std::string& delegate_id, | 99 Notification CreateTestNotification(const std::string& delegate_id, |
| 98 TestDelegate** delegate = NULL) { | 100 TestDelegate** delegate = NULL) { |
| 99 TestDelegate* new_delegate = new TestDelegate(delegate_id); | 101 TestDelegate* new_delegate = new TestDelegate(delegate_id); |
| 100 if (delegate) { | 102 if (delegate) { |
| 101 *delegate = new_delegate; | 103 *delegate = new_delegate; |
| 102 new_delegate->AddRef(); | 104 new_delegate->AddRef(); |
| 103 } | 105 } |
| 104 | 106 |
| 105 return Notification(GURL("chrome-test://testing/"), | 107 return Notification(message_center::NOTIFICATION_TYPE_SIMPLE, |
| 106 base::ASCIIToUTF16("title"), | 108 base::ASCIIToUTF16("title"), |
| 107 base::ASCIIToUTF16("message"), | 109 base::ASCIIToUTF16("message"), |
| 108 gfx::Image(), | 110 gfx::Image(), |
| 111 message_center::NotifierId(), |
| 109 base::UTF8ToUTF16("chrome-test://testing/"), | 112 base::UTF8ToUTF16("chrome-test://testing/"), |
| 113 GURL("chrome-test://testing/"), |
| 110 "REPLACE-ME", | 114 "REPLACE-ME", |
| 115 message_center::RichNotificationData(), |
| 111 new_delegate); | 116 new_delegate); |
| 112 } | 117 } |
| 113 | 118 |
| 114 Notification CreateRichTestNotification(const std::string& id, | 119 Notification CreateRichTestNotification(const std::string& id, |
| 115 TestDelegate** delegate = NULL) { | 120 TestDelegate** delegate = NULL) { |
| 116 TestDelegate* new_delegate = new TestDelegate(id); | 121 TestDelegate* new_delegate = new TestDelegate(id); |
| 117 if (delegate) { | 122 if (delegate) { |
| 118 *delegate = new_delegate; | 123 *delegate = new_delegate; |
| 119 new_delegate->AddRef(); | 124 new_delegate->AddRef(); |
| 120 } | 125 } |
| (...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 326 manager()->Update(notification, profile()); | 331 manager()->Update(notification, profile()); |
| 327 | 332 |
| 328 // Expect that the progress notification update is performed. | 333 // Expect that the progress notification update is performed. |
| 329 EXPECT_EQ(base::StringPrintf("update-%s", notification_id.c_str()), | 334 EXPECT_EQ(base::StringPrintf("update-%s", notification_id.c_str()), |
| 330 observer.log(notification_id)); | 335 observer.log(notification_id)); |
| 331 | 336 |
| 332 delegate->Release(); | 337 delegate->Release(); |
| 333 } | 338 } |
| 334 | 339 |
| 335 #endif // defined(OS_CHROMEOS) | 340 #endif // defined(OS_CHROMEOS) |
| OLD | NEW |