diff options
author | atwilson@chromium.org <atwilson@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-08-27 07:06:18 +0000 |
---|---|---|
committer | atwilson@chromium.org <atwilson@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-08-27 07:06:18 +0000 |
commit | a16e9ab23c91b7cf2a9bbef3bf646f75c14843c8 (patch) | |
tree | 60904021b970035586afd0fbe47ae18c652d396d /chrome/browser/background_mode_manager_unittest.cc | |
parent | 97a1122a346843cd92c74173c6011d0abd810816 (diff) | |
download | chromium_src-a16e9ab23c91b7cf2a9bbef3bf646f75c14843c8.zip chromium_src-a16e9ab23c91b7cf2a9bbef3bf646f75c14843c8.tar.gz chromium_src-a16e9ab23c91b7cf2a9bbef3bf646f75c14843c8.tar.bz2 |
Revert 57642 - Disable background mode when associated pref changes.
BUG=53173
TEST=new BackgroundModeManager unit tests
Review URL: http://codereview.chromium.org/3205008
TBR=atwilson@chromium.org
Review URL: http://codereview.chromium.org/3226006
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@57644 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/background_mode_manager_unittest.cc')
-rw-r--r-- | chrome/browser/background_mode_manager_unittest.cc | 61 |
1 files changed, 3 insertions, 58 deletions
diff --git a/chrome/browser/background_mode_manager_unittest.cc b/chrome/browser/background_mode_manager_unittest.cc index f028c7c..087b4fe 100644 --- a/chrome/browser/background_mode_manager_unittest.cc +++ b/chrome/browser/background_mode_manager_unittest.cc @@ -4,14 +4,10 @@ #include "chrome/browser/background_mode_manager.h" #include "chrome/browser/browser_list.h" -#include "chrome/browser/prefs/pref_service.h" -#include "chrome/common/pref_names.h" #include "chrome/test/testing_profile.h" #include "testing/gmock/include/gmock/gmock.h" #include "testing/gtest/include/gtest/gtest.h" -using testing::InSequence; - class TestBackgroundModeManager : public BackgroundModeManager { public: explicit TestBackgroundModeManager(Profile* profile) @@ -23,79 +19,28 @@ class TestBackgroundModeManager : public BackgroundModeManager { }; TEST(BackgroundModeManagerTest, BackgroundAppLoadUnload) { - InSequence s; TestingProfile profile; TestBackgroundModeManager manager(&profile); - EXPECT_CALL(manager, CreateStatusTrayIcon()); - EXPECT_CALL(manager, RemoveStatusTrayIcon()); EXPECT_FALSE(BrowserList::WillKeepAlive()); // Call to AppLoaded() will cause the status tray to be created, then call to // unloaded will result in call to remove the icon. + EXPECT_CALL(manager, CreateStatusTrayIcon()); manager.OnBackgroundAppLoaded(); EXPECT_TRUE(BrowserList::WillKeepAlive()); + EXPECT_CALL(manager, RemoveStatusTrayIcon()); manager.OnBackgroundAppUnloaded(); EXPECT_FALSE(BrowserList::WillKeepAlive()); } TEST(BackgroundModeManagerTest, BackgroundAppInstallUninstall) { - InSequence s; TestingProfile profile; TestBackgroundModeManager manager(&profile); // Call to AppInstalled() will cause chrome to be set to launch on startup, // and call to AppUninstalling() set chrome to not launch on startup. EXPECT_CALL(manager, EnableLaunchOnStartup(true)); - EXPECT_CALL(manager, CreateStatusTrayIcon()); - EXPECT_CALL(manager, EnableLaunchOnStartup(false)); - EXPECT_CALL(manager, RemoveStatusTrayIcon()); - manager.OnBackgroundAppInstalled(); - manager.OnBackgroundAppLoaded(); - manager.OnBackgroundAppUninstalled(); - manager.OnBackgroundAppUnloaded(); -} - -TEST(BackgroundModeManagerTest, BackgroundPrefDisabled) { - InSequence s; - TestingProfile profile; - profile.GetPrefs()->SetBoolean(prefs::kBackgroundModeEnabled, false); - TestBackgroundModeManager manager(&profile); - // Should not change launch on startup status when installing/uninstalling - // if background mode is disabled. - EXPECT_CALL(manager, EnableLaunchOnStartup(true)).Times(0); - EXPECT_CALL(manager, CreateStatusTrayIcon()).Times(0); manager.OnBackgroundAppInstalled(); manager.OnBackgroundAppLoaded(); - EXPECT_FALSE(BrowserList::WillKeepAlive()); + EXPECT_CALL(manager, EnableLaunchOnStartup(false)); manager.OnBackgroundAppUninstalled(); manager.OnBackgroundAppUnloaded(); } - -TEST(BackgroundModeManagerTest, BackgroundPrefDynamicDisable) { - InSequence s; - TestingProfile profile; - TestBackgroundModeManager manager(&profile); - EXPECT_CALL(manager, EnableLaunchOnStartup(true)); - EXPECT_CALL(manager, CreateStatusTrayIcon()); - EXPECT_CALL(manager, EnableLaunchOnStartup(false)); - EXPECT_CALL(manager, RemoveStatusTrayIcon()); - manager.OnBackgroundAppInstalled(); - manager.OnBackgroundAppLoaded(); - EXPECT_TRUE(BrowserList::WillKeepAlive()); - // Disable status on the fly. - profile.GetPrefs()->SetBoolean(prefs::kBackgroundModeEnabled, false); - EXPECT_FALSE(BrowserList::WillKeepAlive()); -} - -TEST(BackgroundModeManagerTest, BackgroundPrefDynamicEnable) { - InSequence s; - TestingProfile profile; - TestBackgroundModeManager manager(&profile); - profile.GetPrefs()->SetBoolean(prefs::kBackgroundModeEnabled, false); - EXPECT_CALL(manager, EnableLaunchOnStartup(true)); - EXPECT_CALL(manager, CreateStatusTrayIcon()); - manager.OnBackgroundAppInstalled(); - manager.OnBackgroundAppLoaded(); - EXPECT_FALSE(BrowserList::WillKeepAlive()); - // Enable status on the fly. - profile.GetPrefs()->SetBoolean(prefs::kBackgroundModeEnabled, true); - EXPECT_TRUE(BrowserList::WillKeepAlive()); -} |