Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(263)

Side by Side Diff: chrome/browser/notifications/message_center_notifications_browsertest.cc

Issue 14631005: Enable users of NotificationUIManager to specify binary images. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase for relanding. Created 7 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 <string> 5 #include <string>
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/string_util.h" 8 #include "base/string_util.h"
9 #include "base/strings/string_number_conversions.h" 9 #include "base/strings/string_number_conversions.h"
10 #include "base/utf_string_conversions.h" 10 #include "base/utf_string_conversions.h"
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
72 }; 72 };
73 73
74 Notification CreateTestNotification(const std::string& id, 74 Notification CreateTestNotification(const std::string& id,
75 TestDelegate** delegate = NULL) { 75 TestDelegate** delegate = NULL) {
76 TestDelegate* new_delegate = new TestDelegate(id); 76 TestDelegate* new_delegate = new TestDelegate(id);
77 if (delegate) { 77 if (delegate) {
78 *delegate = new_delegate; 78 *delegate = new_delegate;
79 new_delegate->AddRef(); 79 new_delegate->AddRef();
80 } 80 }
81 81
82 return Notification(GURL(), 82 return Notification(GURL("chrome-test://testing/"),
83 GURL(), 83 GURL(),
84 ASCIIToUTF16("title"), 84 ASCIIToUTF16("title"),
85 ASCIIToUTF16("message"), 85 ASCIIToUTF16("message"),
86 WebKit::WebTextDirectionDefault, 86 WebKit::WebTextDirectionDefault,
87 EmptyString16(), 87 UTF8ToUTF16("chrome-test://testing/"),
88 EmptyString16(), 88 UTF8ToUTF16("REPLACE-ME"),
89 new_delegate);
90 }
91
92 Notification CreateRichTestNotification(const std::string& id,
93 TestDelegate** delegate = NULL) {
94 TestDelegate* new_delegate = new TestDelegate(id);
95 if (delegate) {
96 *delegate = new_delegate;
97 new_delegate->AddRef();
98 }
99
100 message_center::RichNotificationData data;
101
102 return Notification(message_center::NOTIFICATION_TYPE_BASE_FORMAT,
103 GURL("chrome-test://testing/"),
104 ASCIIToUTF16("title"),
105 ASCIIToUTF16("message"),
106 gfx::Image(),
107 WebKit::WebTextDirectionDefault,
108 UTF8ToUTF16("chrome-test://testing/"),
109 UTF8ToUTF16("REPLACE-ME"),
110 data,
89 new_delegate); 111 new_delegate);
90 } 112 }
91 }; 113 };
92 114
93 // TODO(rsesek): Implement Message Center on Mac and get these tests passing 115 // TODO(rsesek): Implement Message Center on Mac and get these tests passing
94 // for real. http://crbug.com/179904 116 // for real. http://crbug.com/179904
95 #if !defined(OS_MACOSX) 117 #if !defined(OS_MACOSX)
96 118
97 IN_PROC_BROWSER_TEST_F(MessageCenterNotificationsTest, RetrieveBaseParts) { 119 IN_PROC_BROWSER_TEST_F(MessageCenterNotificationsTest, RetrieveBaseParts) {
98 // Make sure comamnd-line switch has an effect. 120 // Make sure comamnd-line switch has an effect.
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
147 MAYBE_ButtonClickedDelegate) { 169 MAYBE_ButtonClickedDelegate) {
148 EXPECT_TRUE(NotificationUIManager::DelegatesToMessageCenter()); 170 EXPECT_TRUE(NotificationUIManager::DelegatesToMessageCenter());
149 TestDelegate* delegate; 171 TestDelegate* delegate;
150 manager()->Add(CreateTestNotification("n", &delegate), profile()); 172 manager()->Add(CreateTestNotification("n", &delegate), profile());
151 message_center()->ClickOnNotificationButton("n", 1); 173 message_center()->ClickOnNotificationButton("n", 1);
152 // Verify that delegate accumulated correct log of events. 174 // Verify that delegate accumulated correct log of events.
153 EXPECT_EQ("Display_ButtonClick_1_", delegate->log()); 175 EXPECT_EQ("Display_ButtonClick_1_", delegate->log());
154 delegate->Release(); 176 delegate->Release();
155 } 177 }
156 178
179 // MessaceCenter-specific test.
180 #if defined(RUN_MESSAGE_CENTER_TESTS)
181 #define MAYBE_UpdateExistingNotification UpdateExistingNotification
182 #else
183 #define MAYBE_UpdateExistingNotification DISABLED_UpdateExistingNotification
184 #endif
185
186 IN_PROC_BROWSER_TEST_F(MessageCenterNotificationsTest,
187 MAYBE_UpdateExistingNotification) {
188 EXPECT_TRUE(NotificationUIManager::DelegatesToMessageCenter());
189 TestDelegate* delegate;
190 manager()->Add(CreateTestNotification("n", &delegate), profile());
191 TestDelegate* delegate2;
192 manager()->Add(CreateRichTestNotification("n", &delegate2), profile());
193
194 manager()->CancelById("n");
195 EXPECT_EQ("Display_Close_programmatically_", delegate->log());
196 EXPECT_EQ("Close_programmatically_", delegate2->log());
197
198 delegate->Release();
199 delegate2->Release();
200 }
201
157 #endif // !defined(OS_MACOSX) 202 #endif // !defined(OS_MACOSX)
OLDNEW
« no previous file with comments | « chrome/browser/notifications/message_center_notification_manager.cc ('k') | chrome/browser/notifications/notification.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698