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 210 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
221 class BackgroundModeManagerWithExtensionsTest : public testing::Test { | 221 class BackgroundModeManagerWithExtensionsTest : public testing::Test { |
222 public: | 222 public: |
223 BackgroundModeManagerWithExtensionsTest() {} | 223 BackgroundModeManagerWithExtensionsTest() {} |
224 ~BackgroundModeManagerWithExtensionsTest() override {} | 224 ~BackgroundModeManagerWithExtensionsTest() override {} |
225 | 225 |
226 void SetUp() override { | 226 void SetUp() override { |
227 command_line_.reset(new base::CommandLine(base::CommandLine::NO_PROGRAM)); | 227 command_line_.reset(new base::CommandLine(base::CommandLine::NO_PROGRAM)); |
228 profile_manager_ = CreateTestingProfileManager(); | 228 profile_manager_ = CreateTestingProfileManager(); |
229 profile_ = profile_manager_->CreateTestingProfile("p1"); | 229 profile_ = profile_manager_->CreateTestingProfile("p1"); |
230 | 230 |
231 // Aura clears notifications from the message center at shutdown. | |
232 message_center::MessageCenter::Initialize(); | |
233 | |
234 test_keep_alive_.reset( | 231 test_keep_alive_.reset( |
235 new ScopedKeepAlive(KeepAliveOrigin::BACKGROUND_MODE_MANAGER, | 232 new ScopedKeepAlive(KeepAliveOrigin::BACKGROUND_MODE_MANAGER, |
236 KeepAliveRestartOption::DISABLED)); | 233 KeepAliveRestartOption::DISABLED)); |
237 | 234 |
238 // Create our test BackgroundModeManager. | 235 // Create our test BackgroundModeManager. |
239 manager_.reset(new TestBackgroundModeManager( | 236 manager_.reset(new TestBackgroundModeManager( |
240 *command_line_, profile_manager_->profile_attributes_storage())); | 237 *command_line_, profile_manager_->profile_attributes_storage())); |
241 manager_->RegisterProfile(profile_); | 238 manager_->RegisterProfile(profile_); |
242 } | 239 } |
243 | 240 |
(...skipping 25 matching lines...) Expand all Loading... |
269 // cleared without having |manager_| attempt to perform optimizations. | 266 // cleared without having |manager_| attempt to perform optimizations. |
270 test_keep_alive_.reset(); | 267 test_keep_alive_.reset(); |
271 | 268 |
272 // The Profile Manager references the Browser Process. | 269 // The Profile Manager references the Browser Process. |
273 // The Browser Process references the Notification UI Manager. | 270 // The Browser Process references the Notification UI Manager. |
274 // The Notification UI Manager references the Message Center. | 271 // The Notification UI Manager references the Message Center. |
275 // As a result, we have to clear the browser process state here | 272 // As a result, we have to clear the browser process state here |
276 // before tearing down the Message Center. | 273 // before tearing down the Message Center. |
277 profile_manager_.reset(); | 274 profile_manager_.reset(); |
278 | 275 |
279 // Message Center shutdown must occur after the KeepAlive is released | |
280 // because clearing it will end up referencing the message center. | |
281 message_center::MessageCenter::Shutdown(); | |
282 | |
283 // Clear the shutdown flag to isolate the remaining effect of this test. | 276 // Clear the shutdown flag to isolate the remaining effect of this test. |
284 browser_shutdown::SetTryingToQuit(false); | 277 browser_shutdown::SetTryingToQuit(false); |
285 } | 278 } |
286 | 279 |
287 protected: | 280 protected: |
288 scoped_refptr<extensions::Extension> CreateExtension( | 281 scoped_refptr<extensions::Extension> CreateExtension( |
289 extensions::Manifest::Location location, | 282 extensions::Manifest::Location location, |
290 const std::string& data, | 283 const std::string& data, |
291 const std::string& id) { | 284 const std::string& id) { |
292 std::unique_ptr<base::DictionaryValue> parsed_manifest( | 285 std::unique_ptr<base::DictionaryValue> parsed_manifest( |
(...skipping 728 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1021 // When the background mode pref is enabled and there are pending triggers | 1014 // When the background mode pref is enabled and there are pending triggers |
1022 // they will be registered and the user will be notified. | 1015 // they will be registered and the user will be notified. |
1023 EXPECT_CALL(manager, EnableLaunchOnStartup(true)); | 1016 EXPECT_CALL(manager, EnableLaunchOnStartup(true)); |
1024 g_browser_process->local_state()->SetBoolean(prefs::kBackgroundModeEnabled, | 1017 g_browser_process->local_state()->SetBoolean(prefs::kBackgroundModeEnabled, |
1025 true); | 1018 true); |
1026 Mock::VerifyAndClearExpectations(&manager); | 1019 Mock::VerifyAndClearExpectations(&manager); |
1027 ASSERT_EQ(1, manager.GetBackgroundClientCountForProfile(profile_)); | 1020 ASSERT_EQ(1, manager.GetBackgroundClientCountForProfile(profile_)); |
1028 AssertBackgroundModeActive(manager); | 1021 AssertBackgroundModeActive(manager); |
1029 ASSERT_TRUE(manager.HasShownBalloon()); | 1022 ASSERT_TRUE(manager.HasShownBalloon()); |
1030 } | 1023 } |
OLD | NEW |