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

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

Issue 23636010: Notifications: Add cross-platform UMA: ShowMessageCenter, ShowSettings. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Added the hash to chromeactions.txt Created 7 years, 3 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 | Annotate | Revision Log
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/message_loop/message_loop.h" 8 #include "base/message_loop/message_loop.h"
9 #include "base/strings/string_number_conversions.h" 9 #include "base/strings/string_number_conversions.h"
10 #include "base/strings/string_util.h" 10 #include "base/strings/string_util.h"
11 #include "base/strings/utf_string_conversions.h" 11 #include "base/strings/utf_string_conversions.h"
12 #include "chrome/browser/browser_process.h" 12 #include "chrome/browser/browser_process.h"
13 #include "chrome/browser/chrome_notification_types.h" 13 #include "chrome/browser/chrome_notification_types.h"
14 #include "chrome/browser/notifications/message_center_notification_manager.h" 14 #include "chrome/browser/notifications/message_center_notification_manager.h"
15 #include "chrome/browser/notifications/notification.h" 15 #include "chrome/browser/notifications/notification.h"
16 #include "chrome/browser/notifications/notification_ui_manager.h" 16 #include "chrome/browser/notifications/notification_ui_manager.h"
17 #include "chrome/browser/profiles/profile.h" 17 #include "chrome/browser/profiles/profile.h"
18 #include "chrome/browser/ui/browser.h" 18 #include "chrome/browser/ui/browser.h"
19 #include "chrome/test/base/in_process_browser_test.h" 19 #include "chrome/test/base/in_process_browser_test.h"
20 #include "chrome/test/base/test_switches.h" 20 #include "chrome/test/base/test_switches.h"
21 #include "content/public/browser/notification_details.h" 21 #include "content/public/browser/notification_details.h"
22 #include "content/public/browser/notification_observer.h" 22 #include "content/public/browser/notification_observer.h"
23 #include "content/public/browser/notification_source.h" 23 #include "content/public/browser/notification_source.h"
24 #include "ui/message_center/message_center.h" 24 #include "ui/message_center/message_center.h"
25 #include "ui/message_center/message_center_switches.h" 25 #include "ui/message_center/message_center_switches.h"
26 #include "ui/message_center/message_center_types.h"
26 #include "ui/message_center/message_center_util.h" 27 #include "ui/message_center/message_center_util.h"
27 28
28 class TestAddObserver : public message_center::MessageCenterObserver { 29 class TestAddObserver : public message_center::MessageCenterObserver {
29 public: 30 public:
30 explicit TestAddObserver(message_center::MessageCenter* message_center) 31 explicit TestAddObserver(message_center::MessageCenter* message_center)
31 : message_center_(message_center) { 32 : message_center_(message_center) {
32 message_center_->AddObserver(this); 33 message_center_->AddObserver(this);
33 } 34 }
34 35
35 virtual ~TestAddObserver() { message_center_->RemoveObserver(this); } 36 virtual ~TestAddObserver() { message_center_->RemoveObserver(this); }
(...skipping 240 matching lines...) Expand 10 before | Expand all | Expand 10 after
276 return; 277 return;
277 #endif 278 #endif
278 279
279 EXPECT_TRUE(NotificationUIManager::DelegatesToMessageCenter()); 280 EXPECT_TRUE(NotificationUIManager::DelegatesToMessageCenter());
280 TestAddObserver observer(message_center()); 281 TestAddObserver observer(message_center());
281 282
282 TestDelegate* delegate; 283 TestDelegate* delegate;
283 TestDelegate* delegate2; 284 TestDelegate* delegate2;
284 285
285 manager()->Add(CreateTestNotification("n", &delegate), profile()); 286 manager()->Add(CreateTestNotification("n", &delegate), profile());
286 message_center()->SetMessageCenterVisible(true); 287 message_center()->SetVisibility(message_center::VISIBILITY_MESSAGE_CENTER);
287 manager()->Add(CreateTestNotification("n2", &delegate2), profile()); 288 manager()->Add(CreateTestNotification("n2", &delegate2), profile());
288 289
289 EXPECT_EQ("add-n", observer.log()); 290 EXPECT_EQ("add-n", observer.log());
290 291
291 message_center()->SetMessageCenterVisible(false); 292 message_center()->SetVisibility(message_center::VISIBILITY_TRANSIENT);
292 293
293 EXPECT_EQ("add-n_add-n2", observer.log()); 294 EXPECT_EQ("add-n_add-n2", observer.log());
294 295
295 delegate->Release(); 296 delegate->Release();
296 delegate2->Release(); 297 delegate2->Release();
297 } 298 }
298 299
299 // MessaceCenter-specific test. 300 // MessaceCenter-specific test.
300 #if defined(RUN_MESSAGE_CENTER_TESTS) 301 #if defined(RUN_MESSAGE_CENTER_TESTS)
301 #define MAYBE_UpdateNonProgressNotificationWhenCenterVisible \ 302 #define MAYBE_UpdateNonProgressNotificationWhenCenterVisible \
(...skipping 14 matching lines...) Expand all
316 EXPECT_TRUE(NotificationUIManager::DelegatesToMessageCenter()); 317 EXPECT_TRUE(NotificationUIManager::DelegatesToMessageCenter());
317 TestAddObserver observer(message_center()); 318 TestAddObserver observer(message_center());
318 319
319 TestDelegate* delegate; 320 TestDelegate* delegate;
320 321
321 // Add a non-progress notification and update it while the message center 322 // Add a non-progress notification and update it while the message center
322 // is visible. 323 // is visible.
323 Notification notification = CreateTestNotification("n", &delegate); 324 Notification notification = CreateTestNotification("n", &delegate);
324 manager()->Add(notification, profile()); 325 manager()->Add(notification, profile());
325 message_center()->ClickOnNotification("n"); 326 message_center()->ClickOnNotification("n");
326 message_center()->SetMessageCenterVisible(true); 327 message_center()->SetVisibility(message_center::VISIBILITY_MESSAGE_CENTER);
327 observer.reset_log(); 328 observer.reset_log();
328 notification.set_title(ASCIIToUTF16("title2")); 329 notification.set_title(ASCIIToUTF16("title2"));
329 manager()->Update(notification, profile()); 330 manager()->Update(notification, profile());
330 331
331 // Expect that the notification update is not done. 332 // Expect that the notification update is not done.
332 EXPECT_EQ("", observer.log()); 333 EXPECT_EQ("", observer.log());
333 334
334 delegate->Release(); 335 delegate->Release();
335 } 336 }
336 337
(...skipping 18 matching lines...) Expand all
355 EXPECT_TRUE(NotificationUIManager::DelegatesToMessageCenter()); 356 EXPECT_TRUE(NotificationUIManager::DelegatesToMessageCenter());
356 TestAddObserver observer(message_center()); 357 TestAddObserver observer(message_center());
357 358
358 TestDelegate* delegate; 359 TestDelegate* delegate;
359 360
360 // Add a non-progress notification and change the type to progress while the 361 // Add a non-progress notification and change the type to progress while the
361 // message center is visible. 362 // message center is visible.
362 Notification notification = CreateTestNotification("n", &delegate); 363 Notification notification = CreateTestNotification("n", &delegate);
363 manager()->Add(notification, profile()); 364 manager()->Add(notification, profile());
364 message_center()->ClickOnNotification("n"); 365 message_center()->ClickOnNotification("n");
365 message_center()->SetMessageCenterVisible(true); 366 message_center()->SetVisibility(message_center::VISIBILITY_MESSAGE_CENTER);
366 observer.reset_log(); 367 observer.reset_log();
367 notification.set_type(message_center::NOTIFICATION_TYPE_PROGRESS); 368 notification.set_type(message_center::NOTIFICATION_TYPE_PROGRESS);
368 manager()->Update(notification, profile()); 369 manager()->Update(notification, profile());
369 370
370 // Expect that the notification update is not done. 371 // Expect that the notification update is not done.
371 EXPECT_EQ("", observer.log()); 372 EXPECT_EQ("", observer.log());
372 373
373 delegate->Release(); 374 delegate->Release();
374 } 375 }
375 376
(...skipping 18 matching lines...) Expand all
394 TestAddObserver observer(message_center()); 395 TestAddObserver observer(message_center());
395 396
396 TestDelegate* delegate; 397 TestDelegate* delegate;
397 398
398 // Add a progress notification and update it while the message center 399 // Add a progress notification and update it while the message center
399 // is visible. 400 // is visible.
400 Notification notification = CreateTestNotification("n", &delegate); 401 Notification notification = CreateTestNotification("n", &delegate);
401 notification.set_type(message_center::NOTIFICATION_TYPE_PROGRESS); 402 notification.set_type(message_center::NOTIFICATION_TYPE_PROGRESS);
402 manager()->Add(notification, profile()); 403 manager()->Add(notification, profile());
403 message_center()->ClickOnNotification("n"); 404 message_center()->ClickOnNotification("n");
404 message_center()->SetMessageCenterVisible(true); 405 message_center()->SetVisibility(message_center::VISIBILITY_MESSAGE_CENTER);
405 observer.reset_log(); 406 observer.reset_log();
406 notification.set_progress(50); 407 notification.set_progress(50);
407 manager()->Update(notification, profile()); 408 manager()->Update(notification, profile());
408 409
409 // Expect that the progress notification update is performed. 410 // Expect that the progress notification update is performed.
410 EXPECT_EQ("update-n", observer.log()); 411 EXPECT_EQ("update-n", observer.log());
411 412
412 delegate->Release(); 413 delegate->Release();
413 } 414 }
414 415
(...skipping 16 matching lines...) Expand all
431 // Cast so that Observe() is public. 432 // Cast so that Observe() is public.
432 content::NotificationObserver* observer = 433 content::NotificationObserver* observer =
433 static_cast<content::NotificationObserver*>(manager()); 434 static_cast<content::NotificationObserver*>(manager());
434 observer->Observe(chrome::NOTIFICATION_FULLSCREEN_CHANGED, 435 observer->Observe(chrome::NOTIFICATION_FULLSCREEN_CHANGED,
435 content::Source<Profile>(profile()), 436 content::Source<Profile>(profile()),
436 content::Details<bool>(&is_fullscreen)); 437 content::Details<bool>(&is_fullscreen));
437 EXPECT_FALSE(message_center()->HasPopupNotifications()); 438 EXPECT_FALSE(message_center()->HasPopupNotifications());
438 } 439 }
439 440
440 #endif // !defined(OS_MACOSX) 441 #endif // !defined(OS_MACOSX)
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698