Chromium Code Reviews| Index: chrome/browser/background/background_mode_manager_unittest.cc |
| diff --git a/chrome/browser/background/background_mode_manager_unittest.cc b/chrome/browser/background/background_mode_manager_unittest.cc |
| index 2f222f1c78345474de3680b6115a39dfbb21e28a..befc0c6f5a6d57a85abd97a01b013b69540ae4b1 100644 |
| --- a/chrome/browser/background/background_mode_manager_unittest.cc |
| +++ b/chrome/browser/background/background_mode_manager_unittest.cc |
| @@ -38,7 +38,9 @@ class TestBackgroundModeManager : public BackgroundModeManager { |
| app_count_(0), |
| profile_app_count_(0), |
| have_status_tray_(false), |
| - launch_on_startup_(false) {} |
| + launch_on_startup_(false) { |
| + ResumeBackgroundMode(); |
| + } |
| virtual void EnableLaunchOnStartup(bool launch) OVERRIDE { |
| launch_on_startup_ = launch; |
| } |
| @@ -84,6 +86,13 @@ static void AssertBackgroundModeInactive( |
| EXPECT_FALSE(manager.IsLaunchOnStartup()); |
| } |
| +static void AssertBackgroundModeSuspended( |
| + const TestBackgroundModeManager& manager) { |
| + EXPECT_FALSE(chrome::WillKeepAlive()); |
| + EXPECT_FALSE(manager.HaveStatusTray()); |
| + EXPECT_TRUE(manager.IsLaunchOnStartup()); |
| +} |
| + |
| TEST_F(BackgroundModeManagerTest, BackgroundAppLoadUnload) { |
| TestingProfile* profile = profile_manager_.CreateTestingProfile("p1"); |
| TestBackgroundModeManager manager( |
| @@ -97,10 +106,24 @@ TEST_F(BackgroundModeManagerTest, BackgroundAppLoadUnload) { |
| manager.OnApplicationListChanged(profile); |
| AssertBackgroundModeActive(manager); |
| + manager.SuspendBackgroundMode(); |
| + AssertBackgroundModeSuspended(manager); |
| + manager.ResumeBackgroundMode(); |
| + |
| // Mimic app unload. |
| manager.SetBackgroundAppCount(0); |
| manager.OnApplicationListChanged(profile); |
| AssertBackgroundModeInactive(manager); |
| + |
| + manager.SuspendBackgroundMode(); |
| + AssertBackgroundModeInactive(manager); |
| + |
| + // Mimic app load while suspended. |
| + manager.OnBackgroundAppInstalled(NULL); |
| + manager.SetBackgroundAppCount(1); |
|
Andrew T Wilson (Slow)
2013/10/23 10:00:21
How would an app get installed in this profile whi
Sam McNally
2013/10/24 02:01:37
Yes, sync is still running. I suspect newly added
|
| + manager.OnApplicationListChanged(profile); |
| + AssertBackgroundModeSuspended(manager); |
| + |
| } |
| // App installs while background mode is disabled should do nothing. |