OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 <deque> | 5 #include <deque> |
6 #include <string> | 6 #include <string> |
7 | 7 |
8 #include "base/bind.h" | 8 #include "base/bind.h" |
9 #include "base/callback.h" | 9 #include "base/callback.h" |
10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
70 MessageCenterChangeObserver() | 70 MessageCenterChangeObserver() |
71 : notification_received_(false) { | 71 : notification_received_(false) { |
72 message_center::MessageCenter::Get()->AddObserver(this); | 72 message_center::MessageCenter::Get()->AddObserver(this); |
73 } | 73 } |
74 | 74 |
75 virtual ~MessageCenterChangeObserver() { | 75 virtual ~MessageCenterChangeObserver() { |
76 message_center::MessageCenter::Get()->RemoveObserver(this); | 76 message_center::MessageCenter::Get()->RemoveObserver(this); |
77 } | 77 } |
78 | 78 |
79 // NotificationChangeObserver: | 79 // NotificationChangeObserver: |
80 virtual bool Wait() OVERRIDE { | 80 virtual bool Wait() override { |
81 if (notification_received_) | 81 if (notification_received_) |
82 return true; | 82 return true; |
83 | 83 |
84 message_loop_runner_ = new content::MessageLoopRunner; | 84 message_loop_runner_ = new content::MessageLoopRunner; |
85 message_loop_runner_->Run(); | 85 message_loop_runner_->Run(); |
86 return notification_received_; | 86 return notification_received_; |
87 } | 87 } |
88 | 88 |
89 // message_center::MessageCenterObserver: | 89 // message_center::MessageCenterObserver: |
90 virtual void OnNotificationAdded( | 90 virtual void OnNotificationAdded( |
91 const std::string& notification_id) OVERRIDE { | 91 const std::string& notification_id) override { |
92 OnMessageCenterChanged(); | 92 OnMessageCenterChanged(); |
93 } | 93 } |
94 | 94 |
95 virtual void OnNotificationRemoved(const std::string& notification_id, | 95 virtual void OnNotificationRemoved(const std::string& notification_id, |
96 bool by_user) OVERRIDE { | 96 bool by_user) override { |
97 OnMessageCenterChanged(); | 97 OnMessageCenterChanged(); |
98 } | 98 } |
99 | 99 |
100 virtual void OnNotificationUpdated( | 100 virtual void OnNotificationUpdated( |
101 const std::string& notification_id) OVERRIDE { | 101 const std::string& notification_id) override { |
102 OnMessageCenterChanged(); | 102 OnMessageCenterChanged(); |
103 } | 103 } |
104 | 104 |
105 void OnMessageCenterChanged() { | 105 void OnMessageCenterChanged() { |
106 notification_received_ = true; | 106 notification_received_ = true; |
107 if (message_loop_runner_.get()) | 107 if (message_loop_runner_.get()) |
108 message_loop_runner_->Quit(); | 108 message_loop_runner_->Quit(); |
109 } | 109 } |
110 | 110 |
111 bool notification_received_; | 111 bool notification_received_; |
(...skipping 720 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
832 (*notifications.rbegin())->id()); | 832 (*notifications.rbegin())->id()); |
833 | 833 |
834 ASSERT_EQ(0, GetNotificationPopupCount()); | 834 ASSERT_EQ(0, GetNotificationPopupCount()); |
835 | 835 |
836 result = CreateNotification( | 836 result = CreateNotification( |
837 browser(), true, "abc.png", "Title2", "Body2", "chat"); | 837 browser(), true, "abc.png", "Title2", "Body2", "chat"); |
838 EXPECT_NE("-1", result); | 838 EXPECT_NE("-1", result); |
839 | 839 |
840 ASSERT_EQ(1, GetNotificationPopupCount()); | 840 ASSERT_EQ(1, GetNotificationPopupCount()); |
841 } | 841 } |
OLD | NEW |