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 #import "ui/message_center/cocoa/popup_collection.h" | 5 #import "ui/message_center/cocoa/popup_collection.h" |
6 | 6 |
7 #include "base/mac/scoped_nsobject.h" | 7 #include "base/mac/scoped_nsobject.h" |
8 #include "base/memory/scoped_ptr.h" | 8 #include "base/memory/scoped_ptr.h" |
9 #include "base/message_loop/message_loop.h" | 9 #include "base/message_loop/message_loop.h" |
10 #include "base/run_loop.h" | 10 #include "base/run_loop.h" |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
42 | 42 |
43 ~PopupCollectionTest() override { message_center::MessageCenter::Shutdown(); } | 43 ~PopupCollectionTest() override { message_center::MessageCenter::Shutdown(); } |
44 | 44 |
45 message_center::NotifierId DummyNotifierId() { | 45 message_center::NotifierId DummyNotifierId() { |
46 return message_center::NotifierId(); | 46 return message_center::NotifierId(); |
47 } | 47 } |
48 | 48 |
49 void AddThreeNotifications() { | 49 void AddThreeNotifications() { |
50 scoped_ptr<message_center::Notification> notification; | 50 scoped_ptr<message_center::Notification> notification; |
51 notification.reset(new message_center::Notification( | 51 notification.reset(new message_center::Notification( |
52 message_center::NOTIFICATION_TYPE_SIMPLE, | 52 message_center::NOTIFICATION_TYPE_SIMPLE, "1", ASCIIToUTF16("One"), |
53 "1", | |
54 ASCIIToUTF16("One"), | |
55 ASCIIToUTF16("This is the first notification to" | 53 ASCIIToUTF16("This is the first notification to" |
56 " be displayed"), | 54 " be displayed"), |
57 gfx::Image(), | 55 gfx::Image(), base::string16(), GURL(), DummyNotifierId(), |
58 base::string16(), | 56 message_center::RichNotificationData(), NULL)); |
59 DummyNotifierId(), | |
60 message_center::RichNotificationData(), | |
61 NULL)); | |
62 center_->AddNotification(notification.Pass()); | 57 center_->AddNotification(notification.Pass()); |
63 | 58 |
64 notification.reset(new message_center::Notification( | 59 notification.reset(new message_center::Notification( |
65 message_center::NOTIFICATION_TYPE_SIMPLE, | 60 message_center::NOTIFICATION_TYPE_SIMPLE, "2", ASCIIToUTF16("Two"), |
66 "2", | 61 ASCIIToUTF16("This is the second notification."), gfx::Image(), |
67 ASCIIToUTF16("Two"), | 62 base::string16(), GURL(), DummyNotifierId(), |
68 ASCIIToUTF16("This is the second notification."), | 63 message_center::RichNotificationData(), NULL)); |
69 gfx::Image(), | |
70 base::string16(), | |
71 DummyNotifierId(), | |
72 message_center::RichNotificationData(), | |
73 NULL)); | |
74 center_->AddNotification(notification.Pass()); | 64 center_->AddNotification(notification.Pass()); |
75 | 65 |
76 notification.reset(new message_center::Notification( | 66 notification.reset(new message_center::Notification( |
77 message_center::NOTIFICATION_TYPE_SIMPLE, | 67 message_center::NOTIFICATION_TYPE_SIMPLE, "3", ASCIIToUTF16("Three"), |
78 "3", | |
79 ASCIIToUTF16("Three"), | |
80 ASCIIToUTF16("This is the third notification " | 68 ASCIIToUTF16("This is the third notification " |
81 "that has a much longer body " | 69 "that has a much longer body " |
82 "than the other notifications. It " | 70 "than the other notifications. It " |
83 "may not fit on the screen if we " | 71 "may not fit on the screen if we " |
84 "set the screen size too small or " | 72 "set the screen size too small or " |
85 "if the notification is way too big"), | 73 "if the notification is way too big"), |
86 gfx::Image(), | 74 gfx::Image(), base::string16(), GURL(), DummyNotifierId(), |
87 base::string16(), | 75 message_center::RichNotificationData(), NULL)); |
88 DummyNotifierId(), | |
89 message_center::RichNotificationData(), | |
90 NULL)); | |
91 center_->AddNotification(notification.Pass()); | 76 center_->AddNotification(notification.Pass()); |
92 WaitForAnimationEnded(); | 77 WaitForAnimationEnded(); |
93 } | 78 } |
94 | 79 |
95 bool CheckSpacingBetween(MCPopupController* upper, MCPopupController* lower) { | 80 bool CheckSpacingBetween(MCPopupController* upper, MCPopupController* lower) { |
96 CGFloat minY = NSMinY([[upper window] frame]); | 81 CGFloat minY = NSMinY([[upper window] frame]); |
97 CGFloat maxY = NSMaxY([[lower window] frame]); | 82 CGFloat maxY = NSMaxY([[lower window] frame]); |
98 CGFloat delta = minY - maxY; | 83 CGFloat delta = minY - maxY; |
99 EXPECT_EQ(message_center::kMarginBetweenItems, delta); | 84 EXPECT_EQ(message_center::kMarginBetweenItems, delta); |
100 return delta == message_center::kMarginBetweenItems; | 85 return delta == message_center::kMarginBetweenItems; |
(...skipping 26 matching lines...) Expand all Loading... |
127 TEST_F(PopupCollectionTest, AttemptFourOneOffscreen) { | 112 TEST_F(PopupCollectionTest, AttemptFourOneOffscreen) { |
128 [collection_ setScreenFrame:NSMakeRect(0, 0, 800, 300)]; | 113 [collection_ setScreenFrame:NSMakeRect(0, 0, 800, 300)]; |
129 | 114 |
130 EXPECT_EQ(0u, [[collection_ popups] count]); | 115 EXPECT_EQ(0u, [[collection_ popups] count]); |
131 AddThreeNotifications(); | 116 AddThreeNotifications(); |
132 EXPECT_EQ(2u, [[collection_ popups] count]); // "3" does not fit on screen. | 117 EXPECT_EQ(2u, [[collection_ popups] count]); // "3" does not fit on screen. |
133 | 118 |
134 scoped_ptr<message_center::Notification> notification; | 119 scoped_ptr<message_center::Notification> notification; |
135 | 120 |
136 notification.reset(new message_center::Notification( | 121 notification.reset(new message_center::Notification( |
137 message_center::NOTIFICATION_TYPE_SIMPLE, | 122 message_center::NOTIFICATION_TYPE_SIMPLE, "4", ASCIIToUTF16("Four"), |
138 "4", | 123 ASCIIToUTF16("This is the fourth notification."), gfx::Image(), |
139 ASCIIToUTF16("Four"), | 124 base::string16(), GURL(), DummyNotifierId(), |
140 ASCIIToUTF16("This is the fourth notification."), | 125 message_center::RichNotificationData(), NULL)); |
141 gfx::Image(), | |
142 base::string16(), | |
143 DummyNotifierId(), | |
144 message_center::RichNotificationData(), | |
145 NULL)); | |
146 center_->AddNotification(notification.Pass()); | 126 center_->AddNotification(notification.Pass()); |
147 WaitForAnimationEnded(); | 127 WaitForAnimationEnded(); |
148 | 128 |
149 // Remove "1" and "3" should fit on screen. | 129 // Remove "1" and "3" should fit on screen. |
150 center_->RemoveNotification("1", true); | 130 center_->RemoveNotification("1", true); |
151 WaitForAnimationEnded(); | 131 WaitForAnimationEnded(); |
152 ASSERT_EQ(2u, [[collection_ popups] count]); | 132 ASSERT_EQ(2u, [[collection_ popups] count]); |
153 | 133 |
154 EXPECT_EQ("2", [[[collection_ popups] objectAtIndex:0] notificationID]); | 134 EXPECT_EQ("2", [[[collection_ popups] objectAtIndex:0] notificationID]); |
155 EXPECT_EQ("3", [[[collection_ popups] objectAtIndex:1] notificationID]); | 135 EXPECT_EQ("3", [[[collection_ popups] objectAtIndex:1] notificationID]); |
(...skipping 20 matching lines...) Expand all Loading... |
176 EXPECT_TRUE(CheckSpacingBetween([popups objectAtIndex:0], | 156 EXPECT_TRUE(CheckSpacingBetween([popups objectAtIndex:0], |
177 [popups objectAtIndex:1])); | 157 [popups objectAtIndex:1])); |
178 EXPECT_TRUE(CheckSpacingBetween([popups objectAtIndex:1], | 158 EXPECT_TRUE(CheckSpacingBetween([popups objectAtIndex:1], |
179 [popups objectAtIndex:2])); | 159 [popups objectAtIndex:2])); |
180 | 160 |
181 // Set priority so that kMaxVisiblePopupNotifications does not hide it. | 161 // Set priority so that kMaxVisiblePopupNotifications does not hide it. |
182 message_center::RichNotificationData optional; | 162 message_center::RichNotificationData optional; |
183 optional.priority = message_center::HIGH_PRIORITY; | 163 optional.priority = message_center::HIGH_PRIORITY; |
184 scoped_ptr<message_center::Notification> notification; | 164 scoped_ptr<message_center::Notification> notification; |
185 notification.reset(new message_center::Notification( | 165 notification.reset(new message_center::Notification( |
186 message_center::NOTIFICATION_TYPE_SIMPLE, | 166 message_center::NOTIFICATION_TYPE_SIMPLE, "4", ASCIIToUTF16("Four"), |
187 "4", | 167 ASCIIToUTF16("This is the fourth notification."), gfx::Image(), |
188 ASCIIToUTF16("Four"), | 168 base::string16(), GURL(), DummyNotifierId(), optional, NULL)); |
189 ASCIIToUTF16("This is the fourth notification."), | |
190 gfx::Image(), | |
191 base::string16(), | |
192 DummyNotifierId(), | |
193 optional, | |
194 NULL)); | |
195 center_->AddNotification(notification.Pass()); | 169 center_->AddNotification(notification.Pass()); |
196 WaitForAnimationEnded(); | 170 WaitForAnimationEnded(); |
197 EXPECT_TRUE(CheckSpacingBetween([popups objectAtIndex:2], | 171 EXPECT_TRUE(CheckSpacingBetween([popups objectAtIndex:2], |
198 [popups objectAtIndex:3])); | 172 [popups objectAtIndex:3])); |
199 | 173 |
200 // Remove "2". | 174 // Remove "2". |
201 center_->RemoveNotification("2", true); | 175 center_->RemoveNotification("2", true); |
202 WaitForAnimationEnded(); | 176 WaitForAnimationEnded(); |
203 EXPECT_TRUE(CheckSpacingBetween([popups objectAtIndex:0], | 177 EXPECT_TRUE(CheckSpacingBetween([popups objectAtIndex:0], |
204 [popups objectAtIndex:1])); | 178 [popups objectAtIndex:1])); |
205 EXPECT_TRUE(CheckSpacingBetween([popups objectAtIndex:1], | 179 EXPECT_TRUE(CheckSpacingBetween([popups objectAtIndex:1], |
206 [popups objectAtIndex:2])); | 180 [popups objectAtIndex:2])); |
207 | 181 |
208 // Remove "1". | 182 // Remove "1". |
209 center_->RemoveNotification("2", true); | 183 center_->RemoveNotification("2", true); |
210 WaitForAnimationEnded(); | 184 WaitForAnimationEnded(); |
211 EXPECT_EQ(message_center::kMarginBetweenItems, | 185 EXPECT_EQ(message_center::kMarginBetweenItems, |
212 kScreenSize - NSMaxY([[[popups objectAtIndex:0] window] frame])); | 186 kScreenSize - NSMaxY([[[popups objectAtIndex:0] window] frame])); |
213 EXPECT_TRUE(CheckSpacingBetween([popups objectAtIndex:0], | 187 EXPECT_TRUE(CheckSpacingBetween([popups objectAtIndex:0], |
214 [popups objectAtIndex:1])); | 188 [popups objectAtIndex:1])); |
215 } | 189 } |
216 | 190 |
217 TEST_F(PopupCollectionTest, TinyScreen) { | 191 TEST_F(PopupCollectionTest, TinyScreen) { |
218 [collection_ setScreenFrame:NSMakeRect(0, 0, 800, 100)]; | 192 [collection_ setScreenFrame:NSMakeRect(0, 0, 800, 100)]; |
219 | 193 |
220 EXPECT_EQ(0u, [[collection_ popups] count]); | 194 EXPECT_EQ(0u, [[collection_ popups] count]); |
221 scoped_ptr<message_center::Notification> notification; | 195 scoped_ptr<message_center::Notification> notification; |
222 notification.reset(new message_center::Notification( | 196 notification.reset(new message_center::Notification( |
223 message_center::NOTIFICATION_TYPE_SIMPLE, | 197 message_center::NOTIFICATION_TYPE_SIMPLE, "1", ASCIIToUTF16("One"), |
224 "1", | |
225 ASCIIToUTF16("One"), | |
226 ASCIIToUTF16("This is the first notification to" | 198 ASCIIToUTF16("This is the first notification to" |
227 " be displayed"), | 199 " be displayed"), |
228 gfx::Image(), | 200 gfx::Image(), base::string16(), GURL(), DummyNotifierId(), |
229 base::string16(), | 201 message_center::RichNotificationData(), NULL)); |
230 DummyNotifierId(), | |
231 message_center::RichNotificationData(), | |
232 NULL)); | |
233 center_->AddNotification(notification.Pass()); | 202 center_->AddNotification(notification.Pass()); |
234 WaitForAnimationEnded(); | 203 WaitForAnimationEnded(); |
235 EXPECT_EQ(1u, [[collection_ popups] count]); | 204 EXPECT_EQ(1u, [[collection_ popups] count]); |
236 | 205 |
237 // Now give the notification a longer message so that it no longer fits. | 206 // Now give the notification a longer message so that it no longer fits. |
238 notification.reset(new message_center::Notification( | 207 notification.reset(new message_center::Notification( |
239 message_center::NOTIFICATION_TYPE_SIMPLE, | 208 message_center::NOTIFICATION_TYPE_SIMPLE, "1", ASCIIToUTF16("One"), |
240 "1", | |
241 ASCIIToUTF16("One"), | |
242 ASCIIToUTF16("This is now a very very very very " | 209 ASCIIToUTF16("This is now a very very very very " |
243 "very very very very very very very " | 210 "very very very very very very very " |
244 "very very very very very very very " | 211 "very very very very very very very " |
245 "very very very very very very very " | 212 "very very very very very very very " |
246 "very very very very very very very " | 213 "very very very very very very very " |
247 "very very very very very very very " | 214 "very very very very very very very " |
248 "very very very very very very very " | 215 "very very very very very very very " |
249 "long notification."), | 216 "long notification."), |
250 gfx::Image(), | 217 gfx::Image(), base::string16(), GURL(), DummyNotifierId(), |
251 base::string16(), | 218 message_center::RichNotificationData(), NULL)); |
252 DummyNotifierId(), | |
253 message_center::RichNotificationData(), | |
254 NULL)); | |
255 center_->UpdateNotification("1", notification.Pass()); | 219 center_->UpdateNotification("1", notification.Pass()); |
256 WaitForAnimationEnded(); | 220 WaitForAnimationEnded(); |
257 EXPECT_EQ(0u, [[collection_ popups] count]); | 221 EXPECT_EQ(0u, [[collection_ popups] count]); |
258 } | 222 } |
259 | 223 |
260 TEST_F(PopupCollectionTest, UpdateIconAndBody) { | 224 TEST_F(PopupCollectionTest, UpdateIconAndBody) { |
261 AddThreeNotifications(); | 225 AddThreeNotifications(); |
262 NSArray* popups = [collection_ popups]; | 226 NSArray* popups = [collection_ popups]; |
263 | 227 |
264 EXPECT_EQ(3u, [popups count]); | 228 EXPECT_EQ(3u, [popups count]); |
(...skipping 11 matching lines...) Expand all Loading... |
276 EXPECT_TRUE(CheckSpacingBetween([popups objectAtIndex:0], | 240 EXPECT_TRUE(CheckSpacingBetween([popups objectAtIndex:0], |
277 [popups objectAtIndex:1])); | 241 [popups objectAtIndex:1])); |
278 EXPECT_TRUE(CheckSpacingBetween([popups objectAtIndex:1], | 242 EXPECT_TRUE(CheckSpacingBetween([popups objectAtIndex:1], |
279 [popups objectAtIndex:2])); | 243 [popups objectAtIndex:2])); |
280 | 244 |
281 // Replace "1". | 245 // Replace "1". |
282 controller = [[popups objectAtIndex:0] notificationController]; | 246 controller = [[popups objectAtIndex:0] notificationController]; |
283 NSRect old_frame = [[controller view] frame]; | 247 NSRect old_frame = [[controller view] frame]; |
284 scoped_ptr<message_center::Notification> notification; | 248 scoped_ptr<message_center::Notification> notification; |
285 notification.reset(new message_center::Notification( | 249 notification.reset(new message_center::Notification( |
286 message_center::NOTIFICATION_TYPE_SIMPLE, | 250 message_center::NOTIFICATION_TYPE_SIMPLE, "1", |
287 "1", | |
288 ASCIIToUTF16("One is going to get a much longer " | 251 ASCIIToUTF16("One is going to get a much longer " |
289 "title than it previously had."), | 252 "title than it previously had."), |
290 ASCIIToUTF16("This is the first notification to " | 253 ASCIIToUTF16("This is the first notification to " |
291 "be displayed, but it will also be " | 254 "be displayed, but it will also be " |
292 "updated to have a significantly " | 255 "updated to have a significantly " |
293 "longer body"), | 256 "longer body"), |
294 gfx::Image(), | 257 gfx::Image(), base::string16(), GURL(), DummyNotifierId(), |
295 base::string16(), | 258 message_center::RichNotificationData(), NULL)); |
296 DummyNotifierId(), | |
297 message_center::RichNotificationData(), | |
298 NULL)); | |
299 center_->AddNotification(notification.Pass()); | 259 center_->AddNotification(notification.Pass()); |
300 WaitForAnimationEnded(); | 260 WaitForAnimationEnded(); |
301 EXPECT_GT(NSHeight([[controller view] frame]), NSHeight(old_frame)); | 261 EXPECT_GT(NSHeight([[controller view] frame]), NSHeight(old_frame)); |
302 | 262 |
303 // Test updated spacing. | 263 // Test updated spacing. |
304 EXPECT_EQ(3u, [popups count]); | 264 EXPECT_EQ(3u, [popups count]); |
305 EXPECT_TRUE(CheckSpacingBetween([popups objectAtIndex:0], | 265 EXPECT_TRUE(CheckSpacingBetween([popups objectAtIndex:0], |
306 [popups objectAtIndex:1])); | 266 [popups objectAtIndex:1])); |
307 EXPECT_TRUE(CheckSpacingBetween([popups objectAtIndex:1], | 267 EXPECT_TRUE(CheckSpacingBetween([popups objectAtIndex:1], |
308 [popups objectAtIndex:2])); | 268 [popups objectAtIndex:2])); |
309 EXPECT_EQ("1", [[popups objectAtIndex:0] notificationID]); | 269 EXPECT_EQ("1", [[popups objectAtIndex:0] notificationID]); |
310 EXPECT_EQ("2", [[popups objectAtIndex:1] notificationID]); | 270 EXPECT_EQ("2", [[popups objectAtIndex:1] notificationID]); |
311 EXPECT_EQ("3", [[popups objectAtIndex:2] notificationID]); | 271 EXPECT_EQ("3", [[popups objectAtIndex:2] notificationID]); |
312 } | 272 } |
313 | 273 |
314 TEST_F(PopupCollectionTest, UpdatePriority) { | 274 TEST_F(PopupCollectionTest, UpdatePriority) { |
315 scoped_ptr<message_center::Notification> notification; | 275 scoped_ptr<message_center::Notification> notification; |
316 notification.reset(new message_center::Notification( | 276 notification.reset(new message_center::Notification( |
317 message_center::NOTIFICATION_TYPE_SIMPLE, | 277 message_center::NOTIFICATION_TYPE_SIMPLE, "1", ASCIIToUTF16("One"), |
318 "1", | 278 ASCIIToUTF16("This notification should not yet toast."), gfx::Image(), |
319 ASCIIToUTF16("One"), | 279 base::string16(), GURL(), DummyNotifierId(), |
320 ASCIIToUTF16("This notification should not yet toast."), | 280 message_center::RichNotificationData(), NULL)); |
321 gfx::Image(), | |
322 base::string16(), | |
323 DummyNotifierId(), | |
324 message_center::RichNotificationData(), | |
325 NULL)); | |
326 notification->set_priority(-1); | 281 notification->set_priority(-1); |
327 | 282 |
328 center_->AddNotification(notification.Pass()); | 283 center_->AddNotification(notification.Pass()); |
329 WaitForAnimationEnded(); | 284 WaitForAnimationEnded(); |
330 NSArray* popups = [collection_ popups]; | 285 NSArray* popups = [collection_ popups]; |
331 EXPECT_EQ(0u, [popups count]); | 286 EXPECT_EQ(0u, [popups count]); |
332 | 287 |
333 // Raise priority -1 to 1. Notification should display. | 288 // Raise priority -1 to 1. Notification should display. |
334 notification.reset(new message_center::Notification( | 289 notification.reset(new message_center::Notification( |
335 message_center::NOTIFICATION_TYPE_SIMPLE, | 290 message_center::NOTIFICATION_TYPE_SIMPLE, "1", ASCIIToUTF16("One"), |
336 "1", | 291 ASCIIToUTF16("This notification should now toast"), gfx::Image(), |
337 ASCIIToUTF16("One"), | 292 base::string16(), GURL(), DummyNotifierId(), |
338 ASCIIToUTF16("This notification should now toast"), | 293 message_center::RichNotificationData(), NULL)); |
339 gfx::Image(), | |
340 base::string16(), | |
341 DummyNotifierId(), | |
342 message_center::RichNotificationData(), | |
343 NULL)); | |
344 notification->set_priority(1); | 294 notification->set_priority(1); |
345 | 295 |
346 center_->UpdateNotification("1", notification.Pass()); | 296 center_->UpdateNotification("1", notification.Pass()); |
347 WaitForAnimationEnded(); | 297 WaitForAnimationEnded(); |
348 EXPECT_EQ(1u, [popups count]); | 298 EXPECT_EQ(1u, [popups count]); |
349 } | 299 } |
350 | 300 |
351 TEST_F(PopupCollectionTest, CloseCollectionBeforeNewPopupAnimationEnds) { | 301 TEST_F(PopupCollectionTest, CloseCollectionBeforeNewPopupAnimationEnds) { |
352 // Add a notification and don't wait for the animation to finish. | 302 // Add a notification and don't wait for the animation to finish. |
353 scoped_ptr<message_center::Notification> notification; | 303 scoped_ptr<message_center::Notification> notification; |
354 notification.reset(new message_center::Notification( | 304 notification.reset(new message_center::Notification( |
355 message_center::NOTIFICATION_TYPE_SIMPLE, | 305 message_center::NOTIFICATION_TYPE_SIMPLE, "1", ASCIIToUTF16("One"), |
356 "1", | |
357 ASCIIToUTF16("One"), | |
358 ASCIIToUTF16("This is the first notification to" | 306 ASCIIToUTF16("This is the first notification to" |
359 " be displayed"), | 307 " be displayed"), |
360 gfx::Image(), | 308 gfx::Image(), base::string16(), GURL(), DummyNotifierId(), |
361 base::string16(), | 309 message_center::RichNotificationData(), NULL)); |
362 DummyNotifierId(), | |
363 message_center::RichNotificationData(), | |
364 NULL)); | |
365 center_->AddNotification(notification.Pass()); | 310 center_->AddNotification(notification.Pass()); |
366 | 311 |
367 // Release the popup collection before the animation ends. No crash should | 312 // Release the popup collection before the animation ends. No crash should |
368 // be expected. | 313 // be expected. |
369 collection_.reset(); | 314 collection_.reset(); |
370 } | 315 } |
371 | 316 |
372 TEST_F(PopupCollectionTest, CloseCollectionBeforeClosePopupAnimationEnds) { | 317 TEST_F(PopupCollectionTest, CloseCollectionBeforeClosePopupAnimationEnds) { |
373 AddThreeNotifications(); | 318 AddThreeNotifications(); |
374 | 319 |
375 // Remove a notification and don't wait for the animation to finish. | 320 // Remove a notification and don't wait for the animation to finish. |
376 center_->RemoveNotification("1", true); | 321 center_->RemoveNotification("1", true); |
377 | 322 |
378 // Release the popup collection before the animation ends. No crash should | 323 // Release the popup collection before the animation ends. No crash should |
379 // be expected. | 324 // be expected. |
380 collection_.reset(); | 325 collection_.reset(); |
381 } | 326 } |
382 | 327 |
383 TEST_F(PopupCollectionTest, CloseCollectionBeforeUpdatePopupAnimationEnds) { | 328 TEST_F(PopupCollectionTest, CloseCollectionBeforeUpdatePopupAnimationEnds) { |
384 AddThreeNotifications(); | 329 AddThreeNotifications(); |
385 | 330 |
386 // Update a notification and don't wait for the animation to finish. | 331 // Update a notification and don't wait for the animation to finish. |
387 scoped_ptr<message_center::Notification> notification; | 332 scoped_ptr<message_center::Notification> notification; |
388 notification.reset(new message_center::Notification( | 333 notification.reset(new message_center::Notification( |
389 message_center::NOTIFICATION_TYPE_SIMPLE, | 334 message_center::NOTIFICATION_TYPE_SIMPLE, "1", ASCIIToUTF16("One"), |
390 "1", | 335 ASCIIToUTF16("New message."), gfx::Image(), base::string16(), GURL(), |
391 ASCIIToUTF16("One"), | 336 DummyNotifierId(), message_center::RichNotificationData(), NULL)); |
392 ASCIIToUTF16("New message."), | |
393 gfx::Image(), | |
394 base::string16(), | |
395 DummyNotifierId(), | |
396 message_center::RichNotificationData(), | |
397 NULL)); | |
398 center_->UpdateNotification("1", notification.Pass()); | 337 center_->UpdateNotification("1", notification.Pass()); |
399 | 338 |
400 // Release the popup collection before the animation ends. No crash should | 339 // Release the popup collection before the animation ends. No crash should |
401 // be expected. | 340 // be expected. |
402 collection_.reset(); | 341 collection_.reset(); |
403 } | 342 } |
404 | 343 |
405 } // namespace message_center | 344 } // namespace message_center |
OLD | NEW |