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

Side by Side Diff: chrome/browser/chromeos/net/network_portal_notification_controller_unittest.cc

Issue 324583002: The 1st patch to disambiguate message center notifications (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: . Created 6 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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "base/command_line.h" 5 #include "base/command_line.h"
6 #include "chrome/browser/chromeos/net/network_portal_notification_controller.h" 6 #include "chrome/browser/chromeos/net/network_portal_notification_controller.h"
7 #include "chromeos/chromeos_switches.h" 7 #include "chromeos/chromeos_switches.h"
8 #include "chromeos/network/network_state.h" 8 #include "chromeos/network/network_state.h"
9 #include "testing/gtest/include/gtest/gtest.h" 9 #include "testing/gtest/include/gtest/gtest.h"
10 #include "ui/message_center/message_center.h" 10 #include "ui/message_center/message_center.h"
11 #include "ui/message_center/message_center_observer.h" 11 #include "ui/message_center/message_center_observer.h"
12 12
13 using message_center::MessageCenter; 13 using message_center::MessageCenter;
14 14
15 namespace chromeos { 15 namespace chromeos {
16 16
17 namespace { 17 namespace {
18 18
19 const char* kNotificationId = 19 const char* kNotificationId =
20 NetworkPortalNotificationController::kNotificationId; 20 NetworkPortalNotificationController::kNotificationId;
21 21
22 bool HasNotification() { 22 bool HasNotification() {
23 return MessageCenter::Get()->HasNotification(kNotificationId); 23 MessageCenter* message_center = MessageCenter::Get();
24 return message_center->FindVisibleNotificationById(kNotificationId);
24 } 25 }
25 26
26 class NotificationObserver : public message_center::MessageCenterObserver { 27 class NotificationObserver : public message_center::MessageCenterObserver {
27 public: 28 public:
28 NotificationObserver() : add_count_(0), remove_count_(0), update_count_(0) {} 29 NotificationObserver() : add_count_(0), remove_count_(0), update_count_(0) {}
29 30
30 // Overridden from message_center::MessageCenterObserver: 31 // Overridden from message_center::MessageCenterObserver:
31 virtual void OnNotificationAdded( 32 virtual void OnNotificationAdded(
32 const std::string& notification_id) OVERRIDE { 33 const std::string& notification_id) OVERRIDE {
33 if (notification_id == kNotificationId) 34 if (notification_id == kNotificationId)
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after
190 // Network was switched (by shill or by user) to wifi1. Notification 191 // Network was switched (by shill or by user) to wifi1. Notification
191 // should be displayed. 192 // should be displayed.
192 OnPortalDetectionCompleted(&wifi1, portal_state); 193 OnPortalDetectionCompleted(&wifi1, portal_state);
193 ASSERT_TRUE(HasNotification()); 194 ASSERT_TRUE(HasNotification());
194 EXPECT_EQ(2u, observer().add_count()); 195 EXPECT_EQ(2u, observer().add_count());
195 EXPECT_EQ(1u, observer().remove_count()); 196 EXPECT_EQ(1u, observer().remove_count());
196 EXPECT_EQ(1u, observer().update_count()); 197 EXPECT_EQ(1u, observer().update_count());
197 } 198 }
198 199
199 } // namespace chromeos 200 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698