OLD | NEW |
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 "ui/message_center/message_center_tray.h" | 5 #include "ui/message_center/message_center_tray.h" |
6 | 6 |
7 #include "base/utf_string_conversions.h" | 7 #include "base/utf_string_conversions.h" |
8 #include "testing/gtest/include/gtest/gtest.h" | 8 #include "testing/gtest/include/gtest/gtest.h" |
9 #include "ui/message_center/message_center.h" | 9 #include "ui/message_center/message_center.h" |
10 #include "ui/message_center/notification_types.h" | 10 #include "ui/message_center/notification_types.h" |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
95 | 95 |
96 TEST_F(MessageCenterTrayTest, BasicPopup) { | 96 TEST_F(MessageCenterTrayTest, BasicPopup) { |
97 ASSERT_FALSE(message_center_tray_->popups_visible()); | 97 ASSERT_FALSE(message_center_tray_->popups_visible()); |
98 ASSERT_FALSE(message_center_tray_->message_center_visible()); | 98 ASSERT_FALSE(message_center_tray_->message_center_visible()); |
99 | 99 |
100 message_center_tray_->ShowPopupBubble(); | 100 message_center_tray_->ShowPopupBubble(); |
101 | 101 |
102 ASSERT_FALSE(message_center_tray_->popups_visible()); | 102 ASSERT_FALSE(message_center_tray_->popups_visible()); |
103 ASSERT_FALSE(message_center_tray_->message_center_visible()); | 103 ASSERT_FALSE(message_center_tray_->message_center_visible()); |
104 | 104 |
105 message_center_->AddNotification( | 105 message_center_->AddNotification(message_center::NOTIFICATION_TYPE_SIMPLE, |
106 message_center::NOTIFICATION_TYPE_SIMPLE, | 106 "BasicPopup", |
107 "BasicPopup", | 107 ASCIIToUTF16("Test Web Notification"), |
108 ASCIIToUTF16("Test Web Notification"), | 108 ASCIIToUTF16("Notification message body."), |
109 ASCIIToUTF16("Notification message body."), | 109 ASCIIToUTF16("www.test.org"), |
110 ASCIIToUTF16("www.test.org"), | 110 "" /* extension id */, |
111 "" /* extension id */, | 111 NULL /* optional_fields */, |
112 NULL /* optional_fields */); | 112 NULL /* delegate */); |
113 | 113 |
114 ASSERT_TRUE(message_center_tray_->popups_visible()); | 114 ASSERT_TRUE(message_center_tray_->popups_visible()); |
115 ASSERT_FALSE(message_center_tray_->message_center_visible()); | 115 ASSERT_FALSE(message_center_tray_->message_center_visible()); |
116 | 116 |
117 message_center_tray_->HidePopupBubble(); | 117 message_center_tray_->HidePopupBubble(); |
118 | 118 |
119 ASSERT_FALSE(message_center_tray_->popups_visible()); | 119 ASSERT_FALSE(message_center_tray_->popups_visible()); |
120 ASSERT_FALSE(message_center_tray_->message_center_visible()); | 120 ASSERT_FALSE(message_center_tray_->message_center_visible()); |
121 } | 121 } |
122 | 122 |
123 TEST_F(MessageCenterTrayTest, MessageCenterClosesPopups) { | 123 TEST_F(MessageCenterTrayTest, MessageCenterClosesPopups) { |
124 ASSERT_FALSE(message_center_tray_->popups_visible()); | 124 ASSERT_FALSE(message_center_tray_->popups_visible()); |
125 ASSERT_FALSE(message_center_tray_->message_center_visible()); | 125 ASSERT_FALSE(message_center_tray_->message_center_visible()); |
126 | 126 |
127 message_center_->AddNotification( | 127 message_center_->AddNotification(message_center::NOTIFICATION_TYPE_SIMPLE, |
128 message_center::NOTIFICATION_TYPE_SIMPLE, | 128 "MessageCenterClosesPopups", |
129 "MessageCenterClosesPopups", | 129 ASCIIToUTF16("Test Web Notification"), |
130 ASCIIToUTF16("Test Web Notification"), | 130 ASCIIToUTF16("Notification message body."), |
131 ASCIIToUTF16("Notification message body."), | 131 ASCIIToUTF16("www.test.org"), |
132 ASCIIToUTF16("www.test.org"), | 132 "" /* extension id */, |
133 "" /* extension id */, | 133 NULL /* optional_fields */, |
134 NULL /* optional_fields */); | 134 NULL /* delegate */); |
135 | 135 |
136 ASSERT_TRUE(message_center_tray_->popups_visible()); | 136 ASSERT_TRUE(message_center_tray_->popups_visible()); |
137 ASSERT_FALSE(message_center_tray_->message_center_visible()); | 137 ASSERT_FALSE(message_center_tray_->message_center_visible()); |
138 | 138 |
139 bool shown = message_center_tray_->ShowMessageCenterBubble(); | 139 bool shown = message_center_tray_->ShowMessageCenterBubble(); |
140 EXPECT_TRUE(shown); | 140 EXPECT_TRUE(shown); |
141 | 141 |
142 ASSERT_FALSE(message_center_tray_->popups_visible()); | 142 ASSERT_FALSE(message_center_tray_->popups_visible()); |
143 ASSERT_TRUE(message_center_tray_->message_center_visible()); | 143 ASSERT_TRUE(message_center_tray_->message_center_visible()); |
144 | 144 |
145 message_center_->AddNotification( | 145 message_center_->AddNotification(message_center::NOTIFICATION_TYPE_SIMPLE, |
146 message_center::NOTIFICATION_TYPE_SIMPLE, | 146 "MessageCenterClosesPopups2", |
147 "MessageCenterClosesPopups2", | 147 ASCIIToUTF16("Test Web Notification"), |
148 ASCIIToUTF16("Test Web Notification"), | 148 ASCIIToUTF16("Notification message body."), |
149 ASCIIToUTF16("Notification message body."), | 149 ASCIIToUTF16("www.test.org"), |
150 ASCIIToUTF16("www.test.org"), | 150 "" /* extension id */, |
151 "" /* extension id */, | 151 NULL /* optional_fields */, |
152 NULL /* optional_fields */); | 152 NULL /* delegate */); |
153 | 153 |
154 message_center_tray_->ShowPopupBubble(); | 154 message_center_tray_->ShowPopupBubble(); |
155 | 155 |
156 ASSERT_FALSE(message_center_tray_->popups_visible()); | 156 ASSERT_FALSE(message_center_tray_->popups_visible()); |
157 ASSERT_TRUE(message_center_tray_->message_center_visible()); | 157 ASSERT_TRUE(message_center_tray_->message_center_visible()); |
158 | 158 |
159 message_center_tray_->HideMessageCenterBubble(); | 159 message_center_tray_->HideMessageCenterBubble(); |
160 | 160 |
161 ASSERT_FALSE(message_center_tray_->popups_visible()); | 161 ASSERT_FALSE(message_center_tray_->popups_visible()); |
162 ASSERT_FALSE(message_center_tray_->message_center_visible()); | 162 ASSERT_FALSE(message_center_tray_->message_center_visible()); |
163 } | 163 } |
164 | 164 |
165 TEST_F(MessageCenterTrayTest, ShowBubbleFails) { | 165 TEST_F(MessageCenterTrayTest, ShowBubbleFails) { |
166 // Now the delegate will signal that it was unable to show a bubble. | 166 // Now the delegate will signal that it was unable to show a bubble. |
167 delegate_->show_popups_success_ = false; | 167 delegate_->show_popups_success_ = false; |
168 delegate_->show_message_center_success_ = false; | 168 delegate_->show_message_center_success_ = false; |
169 | 169 |
170 ASSERT_FALSE(message_center_tray_->popups_visible()); | 170 ASSERT_FALSE(message_center_tray_->popups_visible()); |
171 ASSERT_FALSE(message_center_tray_->message_center_visible()); | 171 ASSERT_FALSE(message_center_tray_->message_center_visible()); |
172 | 172 |
173 message_center_->AddNotification( | 173 message_center_->AddNotification(message_center::NOTIFICATION_TYPE_SIMPLE, |
174 message_center::NOTIFICATION_TYPE_SIMPLE, | 174 "ShowBubbleFails", |
175 "ShowBubbleFails", | 175 ASCIIToUTF16("Test Web Notification"), |
176 ASCIIToUTF16("Test Web Notification"), | 176 ASCIIToUTF16("Notification message body."), |
177 ASCIIToUTF16("Notification message body."), | 177 ASCIIToUTF16("www.test.org"), |
178 ASCIIToUTF16("www.test.org"), | 178 "" /* extension id */, |
179 "" /* extension id */, | 179 NULL /* optional_fields */, |
180 NULL /* optional_fields */); | 180 NULL /* delegate */); |
181 | 181 |
182 message_center_tray_->ShowPopupBubble(); | 182 message_center_tray_->ShowPopupBubble(); |
183 | 183 |
184 ASSERT_FALSE(message_center_tray_->popups_visible()); | 184 ASSERT_FALSE(message_center_tray_->popups_visible()); |
185 ASSERT_FALSE(message_center_tray_->message_center_visible()); | 185 ASSERT_FALSE(message_center_tray_->message_center_visible()); |
186 | 186 |
187 bool shown = message_center_tray_->ShowMessageCenterBubble(); | 187 bool shown = message_center_tray_->ShowMessageCenterBubble(); |
188 EXPECT_FALSE(shown); | 188 EXPECT_FALSE(shown); |
189 | 189 |
190 ASSERT_FALSE(message_center_tray_->popups_visible()); | 190 ASSERT_FALSE(message_center_tray_->popups_visible()); |
191 ASSERT_FALSE(message_center_tray_->message_center_visible()); | 191 ASSERT_FALSE(message_center_tray_->message_center_visible()); |
192 | 192 |
193 message_center_tray_->HideMessageCenterBubble(); | 193 message_center_tray_->HideMessageCenterBubble(); |
194 | 194 |
195 ASSERT_FALSE(message_center_tray_->popups_visible()); | 195 ASSERT_FALSE(message_center_tray_->popups_visible()); |
196 ASSERT_FALSE(message_center_tray_->message_center_visible()); | 196 ASSERT_FALSE(message_center_tray_->message_center_visible()); |
197 | 197 |
198 message_center_tray_->ToggleMessageCenterBubble(); | 198 message_center_tray_->ToggleMessageCenterBubble(); |
199 | 199 |
200 ASSERT_FALSE(message_center_tray_->popups_visible()); | 200 ASSERT_FALSE(message_center_tray_->popups_visible()); |
201 ASSERT_FALSE(message_center_tray_->message_center_visible()); | 201 ASSERT_FALSE(message_center_tray_->message_center_visible()); |
202 | 202 |
203 message_center_tray_->HidePopupBubble(); | 203 message_center_tray_->HidePopupBubble(); |
204 | 204 |
205 ASSERT_FALSE(message_center_tray_->popups_visible()); | 205 ASSERT_FALSE(message_center_tray_->popups_visible()); |
206 ASSERT_FALSE(message_center_tray_->message_center_visible()); | 206 ASSERT_FALSE(message_center_tray_->message_center_visible()); |
207 } | 207 } |
208 | 208 |
209 } // namespace message_center | 209 } // namespace message_center |
OLD | NEW |