OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "chrome/browser/background/background_mode_manager.h" | 5 #include "chrome/browser/background/background_mode_manager.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include <memory> | 9 #include <memory> |
10 #include <string> | 10 #include <string> |
(...skipping 243 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
254 // Deleting our testing profile may have the side-effect of disabling | 254 // Deleting our testing profile may have the side-effect of disabling |
255 // background mode if it was enabled for that profile (explicitly note that | 255 // background mode if it was enabled for that profile (explicitly note that |
256 // here to satisfy StrictMock requirements. | 256 // here to satisfy StrictMock requirements. |
257 EXPECT_CALL(*manager_, EnableLaunchOnStartup(false)).Times(AtMost(1)); | 257 EXPECT_CALL(*manager_, EnableLaunchOnStartup(false)).Times(AtMost(1)); |
258 profile_manager_->DeleteAllTestingProfiles(); | 258 profile_manager_->DeleteAllTestingProfiles(); |
259 Mock::VerifyAndClearExpectations(manager_.get()); | 259 Mock::VerifyAndClearExpectations(manager_.get()); |
260 | 260 |
261 // We're getting ready to shutdown the message loop. Clear everything out! | 261 // We're getting ready to shutdown the message loop. Clear everything out! |
262 base::RunLoop().RunUntilIdle(); | 262 base::RunLoop().RunUntilIdle(); |
263 | 263 |
264 test_keep_alive_.reset(); | |
265 | |
266 // TestBackgroundModeManager has dependencies on the infrastructure. | 264 // TestBackgroundModeManager has dependencies on the infrastructure. |
267 // It should get cleared first. | 265 // It should get cleared first. |
268 manager_.reset(); | 266 manager_.reset(); |
269 | 267 |
| 268 // Now that the background manager is destroyed, the test KeepAlive can be |
| 269 // cleared without having |manager_| attempt to perform optimizations. |
| 270 test_keep_alive_.reset(); |
| 271 |
270 // The Profile Manager references the Browser Process. | 272 // The Profile Manager references the Browser Process. |
271 // The Browser Process references the Notification UI Manager. | 273 // The Browser Process references the Notification UI Manager. |
272 // The Notification UI Manager references the Message Center. | 274 // The Notification UI Manager references the Message Center. |
273 // As a result, we have to clear the browser process state here | 275 // As a result, we have to clear the browser process state here |
274 // before tearing down the Message Center. | 276 // before tearing down the Message Center. |
275 profile_manager_.reset(); | 277 profile_manager_.reset(); |
276 | 278 |
277 // Message Center shutdown must occur after the KeepAlive is released | 279 // Message Center shutdown must occur after the KeepAlive is released |
278 // because clearing it will end up referencing the message center. | 280 // because clearing it will end up referencing the message center. |
279 message_center::MessageCenter::Shutdown(); | 281 message_center::MessageCenter::Shutdown(); |
(...skipping 739 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1019 // When the background mode pref is enabled and there are pending triggers | 1021 // When the background mode pref is enabled and there are pending triggers |
1020 // they will be registered and the user will be notified. | 1022 // they will be registered and the user will be notified. |
1021 EXPECT_CALL(manager, EnableLaunchOnStartup(true)); | 1023 EXPECT_CALL(manager, EnableLaunchOnStartup(true)); |
1022 g_browser_process->local_state()->SetBoolean(prefs::kBackgroundModeEnabled, | 1024 g_browser_process->local_state()->SetBoolean(prefs::kBackgroundModeEnabled, |
1023 true); | 1025 true); |
1024 Mock::VerifyAndClearExpectations(&manager); | 1026 Mock::VerifyAndClearExpectations(&manager); |
1025 ASSERT_EQ(1, manager.GetBackgroundClientCountForProfile(profile_)); | 1027 ASSERT_EQ(1, manager.GetBackgroundClientCountForProfile(profile_)); |
1026 AssertBackgroundModeActive(manager); | 1028 AssertBackgroundModeActive(manager); |
1027 ASSERT_TRUE(manager.HasShownBalloon()); | 1029 ASSERT_TRUE(manager.HasShownBalloon()); |
1028 } | 1030 } |
OLD | NEW |