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

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

Issue 816403003: Make callers of CommandLine use it via the base:: namespace. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix Created 5 years, 12 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 <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"
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after
142 #if !defined(OS_MACOSX) 142 #if !defined(OS_MACOSX)
143 143
144 IN_PROC_BROWSER_TEST_F(MessageCenterNotificationsTest, RetrieveBaseParts) { 144 IN_PROC_BROWSER_TEST_F(MessageCenterNotificationsTest, RetrieveBaseParts) {
145 EXPECT_TRUE(manager()); 145 EXPECT_TRUE(manager());
146 EXPECT_TRUE(message_center()); 146 EXPECT_TRUE(message_center());
147 } 147 }
148 148
149 IN_PROC_BROWSER_TEST_F(MessageCenterNotificationsTest, BasicAddCancel) { 149 IN_PROC_BROWSER_TEST_F(MessageCenterNotificationsTest, BasicAddCancel) {
150 #if defined(OS_WIN) && defined(USE_ASH) 150 #if defined(OS_WIN) && defined(USE_ASH)
151 // Disable this test in Metro+Ash for now (http://crbug.com/262796). 151 // Disable this test in Metro+Ash for now (http://crbug.com/262796).
152 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kAshBrowserTests)) 152 if (base::CommandLine::ForCurrentProcess()->HasSwitch(
153 switches::kAshBrowserTests))
153 return; 154 return;
154 #endif 155 #endif
155 156
156 // Someone may create system notifications like "you're in multi-profile 157 // Someone may create system notifications like "you're in multi-profile
157 // mode..." or something which may change the expectation. 158 // mode..." or something which may change the expectation.
158 // TODO(mukai): move this to SetUpOnMainThread() after fixing the side-effect 159 // TODO(mukai): move this to SetUpOnMainThread() after fixing the side-effect
159 // of canceling animation which prevents some Displayed() event. 160 // of canceling animation which prevents some Displayed() event.
160 manager()->CancelAll(); 161 manager()->CancelAll();
161 manager()->Add(CreateTestNotification("hey"), profile()); 162 manager()->Add(CreateTestNotification("hey"), profile());
162 EXPECT_EQ(1u, message_center()->NotificationCount()); 163 EXPECT_EQ(1u, message_center()->NotificationCount());
163 manager()->CancelById("hey", NotificationUIManager::GetProfileID(profile())); 164 manager()->CancelById("hey", NotificationUIManager::GetProfileID(profile()));
164 EXPECT_EQ(0u, message_center()->NotificationCount()); 165 EXPECT_EQ(0u, message_center()->NotificationCount());
165 } 166 }
166 167
167 IN_PROC_BROWSER_TEST_F(MessageCenterNotificationsTest, BasicDelegate) { 168 IN_PROC_BROWSER_TEST_F(MessageCenterNotificationsTest, BasicDelegate) {
168 #if defined(OS_WIN) && defined(USE_ASH) 169 #if defined(OS_WIN) && defined(USE_ASH)
169 // Disable this test in Metro+Ash for now (http://crbug.com/262796). 170 // Disable this test in Metro+Ash for now (http://crbug.com/262796).
170 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kAshBrowserTests)) 171 if (base::CommandLine::ForCurrentProcess()->HasSwitch(
172 switches::kAshBrowserTests))
171 return; 173 return;
172 #endif 174 #endif
173 175
174 TestDelegate* delegate; 176 TestDelegate* delegate;
175 manager()->Add(CreateTestNotification("hey", &delegate), profile()); 177 manager()->Add(CreateTestNotification("hey", &delegate), profile());
176 // Verify that delegate accumulated correct log of events. 178 // Verify that delegate accumulated correct log of events.
177 EXPECT_EQ("Display_", delegate->log()); 179 EXPECT_EQ("Display_", delegate->log());
178 manager()->CancelById("hey", NotificationUIManager::GetProfileID(profile())); 180 manager()->CancelById("hey", NotificationUIManager::GetProfileID(profile()));
179 // Verify that delegate accumulated correct log of events. 181 // Verify that delegate accumulated correct log of events.
180 EXPECT_EQ("Display_Close_programmatically_", delegate->log()); 182 EXPECT_EQ("Display_Close_programmatically_", delegate->log());
181 delegate->Release(); 183 delegate->Release();
182 } 184 }
183 185
184 IN_PROC_BROWSER_TEST_F(MessageCenterNotificationsTest, ButtonClickedDelegate) { 186 IN_PROC_BROWSER_TEST_F(MessageCenterNotificationsTest, ButtonClickedDelegate) {
185 #if defined(OS_WIN) && defined(USE_ASH) 187 #if defined(OS_WIN) && defined(USE_ASH)
186 // Disable this test in Metro+Ash for now (http://crbug.com/262796). 188 // Disable this test in Metro+Ash for now (http://crbug.com/262796).
187 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kAshBrowserTests)) 189 if (base::CommandLine::ForCurrentProcess()->HasSwitch(
190 switches::kAshBrowserTests))
188 return; 191 return;
189 #endif 192 #endif
190 193
191 TestDelegate* delegate; 194 TestDelegate* delegate;
192 manager()->Add(CreateTestNotification("n", &delegate), profile()); 195 manager()->Add(CreateTestNotification("n", &delegate), profile());
193 const std::string notification_id = 196 const std::string notification_id =
194 manager()->GetMessageCenterNotificationIdForTest("n", profile()); 197 manager()->GetMessageCenterNotificationIdForTest("n", profile());
195 message_center()->ClickOnNotificationButton(notification_id, 1); 198 message_center()->ClickOnNotificationButton(notification_id, 1);
196 // Verify that delegate accumulated correct log of events. 199 // Verify that delegate accumulated correct log of events.
197 EXPECT_EQ("Display_ButtonClick_1_", delegate->log()); 200 EXPECT_EQ("Display_ButtonClick_1_", delegate->log());
198 delegate->Release(); 201 delegate->Release();
199 } 202 }
200 203
201 IN_PROC_BROWSER_TEST_F(MessageCenterNotificationsTest, 204 IN_PROC_BROWSER_TEST_F(MessageCenterNotificationsTest,
202 UpdateExistingNotification) { 205 UpdateExistingNotification) {
203 #if defined(OS_WIN) && defined(USE_ASH) 206 #if defined(OS_WIN) && defined(USE_ASH)
204 // Disable this test in Metro+Ash for now (http://crbug.com/262796). 207 // Disable this test in Metro+Ash for now (http://crbug.com/262796).
205 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kAshBrowserTests)) 208 if (base::CommandLine::ForCurrentProcess()->HasSwitch(
209 switches::kAshBrowserTests))
206 return; 210 return;
207 #endif 211 #endif
208 212
209 TestDelegate* delegate; 213 TestDelegate* delegate;
210 manager()->Add(CreateTestNotification("n", &delegate), profile()); 214 manager()->Add(CreateTestNotification("n", &delegate), profile());
211 TestDelegate* delegate2; 215 TestDelegate* delegate2;
212 manager()->Add(CreateRichTestNotification("n", &delegate2), profile()); 216 manager()->Add(CreateRichTestNotification("n", &delegate2), profile());
213 217
214 manager()->CancelById("n", NotificationUIManager::GetProfileID(profile())); 218 manager()->CancelById("n", NotificationUIManager::GetProfileID(profile()));
215 EXPECT_EQ("Display_", delegate->log()); 219 EXPECT_EQ("Display_", delegate->log());
216 EXPECT_EQ("Close_programmatically_", delegate2->log()); 220 EXPECT_EQ("Close_programmatically_", delegate2->log());
217 221
218 delegate->Release(); 222 delegate->Release();
219 delegate2->Release(); 223 delegate2->Release();
220 } 224 }
221 225
222 IN_PROC_BROWSER_TEST_F(MessageCenterNotificationsTest, QueueWhenCenterVisible) { 226 IN_PROC_BROWSER_TEST_F(MessageCenterNotificationsTest, QueueWhenCenterVisible) {
223 #if defined(OS_WIN) && defined(USE_ASH) 227 #if defined(OS_WIN) && defined(USE_ASH)
224 // Disable this test in Metro+Ash for now (http://crbug.com/262796). 228 // Disable this test in Metro+Ash for now (http://crbug.com/262796).
225 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kAshBrowserTests)) 229 if (base::CommandLine::ForCurrentProcess()->HasSwitch(
230 switches::kAshBrowserTests))
226 return; 231 return;
227 #endif 232 #endif
228 233
229 TestAddObserver observer(message_center()); 234 TestAddObserver observer(message_center());
230 235
231 TestDelegate* delegate; 236 TestDelegate* delegate;
232 TestDelegate* delegate2; 237 TestDelegate* delegate2;
233 238
234 manager()->Add(CreateTestNotification("n", &delegate), profile()); 239 manager()->Add(CreateTestNotification("n", &delegate), profile());
235 const std::string id_n = 240 const std::string id_n =
(...skipping 16 matching lines...) Expand all
252 EXPECT_EQ(base::StringPrintf("add-%s", id_n2.c_str()), observer.log(id_n2)); 257 EXPECT_EQ(base::StringPrintf("add-%s", id_n2.c_str()), observer.log(id_n2));
253 258
254 delegate->Release(); 259 delegate->Release();
255 delegate2->Release(); 260 delegate2->Release();
256 } 261 }
257 262
258 IN_PROC_BROWSER_TEST_F(MessageCenterNotificationsTest, 263 IN_PROC_BROWSER_TEST_F(MessageCenterNotificationsTest,
259 UpdateNonProgressNotificationWhenCenterVisible) { 264 UpdateNonProgressNotificationWhenCenterVisible) {
260 #if defined(OS_WIN) && defined(USE_ASH) 265 #if defined(OS_WIN) && defined(USE_ASH)
261 // Disable this test in Metro+Ash for now (http://crbug.com/262796). 266 // Disable this test in Metro+Ash for now (http://crbug.com/262796).
262 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kAshBrowserTests)) 267 if (base::CommandLine::ForCurrentProcess()->HasSwitch(
268 switches::kAshBrowserTests))
263 return; 269 return;
264 #endif 270 #endif
265 271
266 TestAddObserver observer(message_center()); 272 TestAddObserver observer(message_center());
267 273
268 TestDelegate* delegate; 274 TestDelegate* delegate;
269 275
270 // Add a non-progress notification and update it while the message center 276 // Add a non-progress notification and update it while the message center
271 // is visible. 277 // is visible.
272 Notification notification = CreateTestNotification("n", &delegate); 278 Notification notification = CreateTestNotification("n", &delegate);
(...skipping 14 matching lines...) Expand all
287 observer.log(notification_id)); 293 observer.log(notification_id));
288 294
289 delegate->Release(); 295 delegate->Release();
290 } 296 }
291 297
292 IN_PROC_BROWSER_TEST_F( 298 IN_PROC_BROWSER_TEST_F(
293 MessageCenterNotificationsTest, 299 MessageCenterNotificationsTest,
294 UpdateNonProgressToProgressNotificationWhenCenterVisible) { 300 UpdateNonProgressToProgressNotificationWhenCenterVisible) {
295 #if defined(OS_WIN) && defined(USE_ASH) 301 #if defined(OS_WIN) && defined(USE_ASH)
296 // Disable this test in Metro+Ash for now (http://crbug.com/262796). 302 // Disable this test in Metro+Ash for now (http://crbug.com/262796).
297 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kAshBrowserTests)) 303 if (base::CommandLine::ForCurrentProcess()->HasSwitch(
304 switches::kAshBrowserTests))
298 return; 305 return;
299 #endif 306 #endif
300 307
301 TestAddObserver observer(message_center()); 308 TestAddObserver observer(message_center());
302 309
303 TestDelegate* delegate; 310 TestDelegate* delegate;
304 311
305 // Add a non-progress notification and change the type to progress while the 312 // Add a non-progress notification and change the type to progress while the
306 // message center is visible. 313 // message center is visible.
307 Notification notification = CreateTestNotification("n", &delegate); 314 Notification notification = CreateTestNotification("n", &delegate);
(...skipping 13 matching lines...) Expand all
321 EXPECT_EQ(base::StringPrintf("update-%s", notification_id.c_str()), 328 EXPECT_EQ(base::StringPrintf("update-%s", notification_id.c_str()),
322 observer.log(notification_id)); 329 observer.log(notification_id));
323 330
324 delegate->Release(); 331 delegate->Release();
325 } 332 }
326 333
327 IN_PROC_BROWSER_TEST_F(MessageCenterNotificationsTest, 334 IN_PROC_BROWSER_TEST_F(MessageCenterNotificationsTest,
328 UpdateProgressNotificationWhenCenterVisible) { 335 UpdateProgressNotificationWhenCenterVisible) {
329 #if defined(OS_WIN) && defined(USE_ASH) 336 #if defined(OS_WIN) && defined(USE_ASH)
330 // Disable this test in Metro+Ash for now (http://crbug.com/262796). 337 // Disable this test in Metro+Ash for now (http://crbug.com/262796).
331 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kAshBrowserTests)) 338 if (base::CommandLine::ForCurrentProcess()->HasSwitch(
339 switches::kAshBrowserTests))
332 return; 340 return;
333 #endif 341 #endif
334 342
335 TestAddObserver observer(message_center()); 343 TestAddObserver observer(message_center());
336 344
337 TestDelegate* delegate; 345 TestDelegate* delegate;
338 346
339 // Add a progress notification and update it while the message center 347 // Add a progress notification and update it while the message center
340 // is visible. 348 // is visible.
341 Notification notification = CreateTestNotification("n", &delegate); 349 Notification notification = CreateTestNotification("n", &delegate);
342 notification.set_type(message_center::NOTIFICATION_TYPE_PROGRESS); 350 notification.set_type(message_center::NOTIFICATION_TYPE_PROGRESS);
343 manager()->Add(notification, profile()); 351 manager()->Add(notification, profile());
344 const std::string notification_id = 352 const std::string notification_id =
345 manager()->GetMessageCenterNotificationIdForTest("n", profile()); 353 manager()->GetMessageCenterNotificationIdForTest("n", profile());
346 message_center()->ClickOnNotification(notification_id); 354 message_center()->ClickOnNotification(notification_id);
347 message_center()->SetVisibility(message_center::VISIBILITY_MESSAGE_CENTER); 355 message_center()->SetVisibility(message_center::VISIBILITY_MESSAGE_CENTER);
348 observer.reset_logs(); 356 observer.reset_logs();
349 notification.set_progress(50); 357 notification.set_progress(50);
350 manager()->Update(notification, profile()); 358 manager()->Update(notification, profile());
351 359
352 // Expect that the progress notification update is performed. 360 // Expect that the progress notification update is performed.
353 EXPECT_EQ(base::StringPrintf("update-%s", notification_id.c_str()), 361 EXPECT_EQ(base::StringPrintf("update-%s", notification_id.c_str()),
354 observer.log(notification_id)); 362 observer.log(notification_id));
355 363
356 delegate->Release(); 364 delegate->Release();
357 } 365 }
358 366
359 #endif // !defined(OS_MACOSX) 367 #endif // !defined(OS_MACOSX)
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698