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 <map> | 5 #include <map> |
6 #include <string> | 6 #include <string> |
7 | 7 |
8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
9 #include "base/macros.h" | 9 #include "base/macros.h" |
10 #include "base/message_loop/message_loop.h" | 10 #include "base/message_loop/message_loop.h" |
11 #include "base/run_loop.h" | |
11 #include "base/strings/string_number_conversions.h" | 12 #include "base/strings/string_number_conversions.h" |
12 #include "base/strings/string_util.h" | 13 #include "base/strings/string_util.h" |
13 #include "base/strings/stringprintf.h" | 14 #include "base/strings/stringprintf.h" |
14 #include "base/strings/utf_string_conversions.h" | 15 #include "base/strings/utf_string_conversions.h" |
15 #include "build/build_config.h" | 16 #include "build/build_config.h" |
16 #include "chrome/browser/browser_process.h" | 17 #include "chrome/browser/browser_process.h" |
17 #include "chrome/browser/lifetime/keep_alive_registry.h" | 18 #include "chrome/browser/lifetime/keep_alive_registry.h" |
18 #include "chrome/browser/lifetime/keep_alive_types.h" | 19 #include "chrome/browser/lifetime/keep_alive_types.h" |
19 #include "chrome/browser/notifications/message_center_notification_manager.h" | 20 #include "chrome/browser/notifications/message_center_notification_manager.h" |
20 #include "chrome/browser/notifications/notification.h" | 21 #include "chrome/browser/notifications/notification.h" |
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
194 delegate->Release(); | 195 delegate->Release(); |
195 delegate2->Release(); | 196 delegate2->Release(); |
196 } | 197 } |
197 | 198 |
198 IN_PROC_BROWSER_TEST_F(MessageCenterNotificationsTest, VerifyKeepAlives) { | 199 IN_PROC_BROWSER_TEST_F(MessageCenterNotificationsTest, VerifyKeepAlives) { |
199 EXPECT_FALSE(KeepAliveRegistry::GetInstance()->IsOriginRegistered( | 200 EXPECT_FALSE(KeepAliveRegistry::GetInstance()->IsOriginRegistered( |
200 KeepAliveOrigin::NOTIFICATION)); | 201 KeepAliveOrigin::NOTIFICATION)); |
201 | 202 |
202 TestDelegate* delegate; | 203 TestDelegate* delegate; |
203 manager()->Add(CreateTestNotification("a", &delegate), profile()); | 204 manager()->Add(CreateTestNotification("a", &delegate), profile()); |
205 { | |
206 base::RunLoop loop; | |
207 loop.RunUntilIdle(); | |
208 } | |
stevenjb
2017/04/07 20:16:23
nit: These could but put in a helper method, e.g.
oshima
2017/04/07 20:23:01
Done.
| |
204 EXPECT_TRUE(KeepAliveRegistry::GetInstance()->IsOriginRegistered( | 209 EXPECT_TRUE(KeepAliveRegistry::GetInstance()->IsOriginRegistered( |
205 KeepAliveOrigin::NOTIFICATION)); | 210 KeepAliveOrigin::NOTIFICATION)); |
206 | 211 |
207 TestDelegate* delegate2; | 212 TestDelegate* delegate2; |
208 manager()->Add(CreateRichTestNotification("b", &delegate2), profile()); | 213 manager()->Add(CreateRichTestNotification("b", &delegate2), profile()); |
214 { | |
215 base::RunLoop loop; | |
216 loop.RunUntilIdle(); | |
217 } | |
209 EXPECT_TRUE(KeepAliveRegistry::GetInstance()->IsOriginRegistered( | 218 EXPECT_TRUE(KeepAliveRegistry::GetInstance()->IsOriginRegistered( |
210 KeepAliveOrigin::NOTIFICATION)); | 219 KeepAliveOrigin::NOTIFICATION)); |
211 | 220 |
212 manager()->CancelById("a", NotificationUIManager::GetProfileID(profile())); | 221 manager()->CancelById("a", NotificationUIManager::GetProfileID(profile())); |
222 { | |
223 base::RunLoop loop; | |
224 loop.RunUntilIdle(); | |
225 } | |
213 EXPECT_TRUE(KeepAliveRegistry::GetInstance()->IsOriginRegistered( | 226 EXPECT_TRUE(KeepAliveRegistry::GetInstance()->IsOriginRegistered( |
214 KeepAliveOrigin::NOTIFICATION)); | 227 KeepAliveOrigin::NOTIFICATION)); |
215 | 228 |
216 manager()->CancelById("b", NotificationUIManager::GetProfileID(profile())); | 229 manager()->CancelById("b", NotificationUIManager::GetProfileID(profile())); |
230 { | |
231 base::RunLoop loop; | |
232 loop.RunUntilIdle(); | |
233 } | |
217 EXPECT_FALSE(KeepAliveRegistry::GetInstance()->IsOriginRegistered( | 234 EXPECT_FALSE(KeepAliveRegistry::GetInstance()->IsOriginRegistered( |
218 KeepAliveOrigin::NOTIFICATION)); | 235 KeepAliveOrigin::NOTIFICATION)); |
219 | 236 |
220 delegate->Release(); | 237 delegate->Release(); |
221 delegate2->Release(); | 238 delegate2->Release(); |
222 } | 239 } |
223 | 240 |
224 // Notification center is only used on ChromeOS. | 241 // Notification center is only used on ChromeOS. |
225 #if defined(OS_CHROMEOS) | 242 #if defined(OS_CHROMEOS) |
226 | 243 |
(...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
433 EXPECT_EQ("", observer.log(notification_id)); | 450 EXPECT_EQ("", observer.log(notification_id)); |
434 | 451 |
435 message_center()->SetVisibility(message_center::VISIBILITY_TRANSIENT); | 452 message_center()->SetVisibility(message_center::VISIBILITY_TRANSIENT); |
436 EXPECT_EQ(base::StringPrintf("update-%s", notification_id.c_str()), | 453 EXPECT_EQ(base::StringPrintf("update-%s", notification_id.c_str()), |
437 observer.log(notification_id)); | 454 observer.log(notification_id)); |
438 | 455 |
439 delegate->Release(); | 456 delegate->Release(); |
440 } | 457 } |
441 | 458 |
442 #endif // defined(OS_CHROMEOS) | 459 #endif // defined(OS_CHROMEOS) |
OLD | NEW |