Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(3954)

Unified Diff: chrome/browser/background_mode_manager_unittest.cc

Issue 6954001: Add "Keep chrome running in background" preference. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fixed problem that was making UI visible on Mac. Created 9 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/background_mode_manager.cc ('k') | chrome/browser/resources/options/advanced_options.html » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/background_mode_manager_unittest.cc
diff --git a/chrome/browser/background_mode_manager_unittest.cc b/chrome/browser/background_mode_manager_unittest.cc
index abfbf904791a1c1f24a82ae2cbe87158aad4a0f0..dc19e2aeda3720bc87aab13bc93431b85d71811b 100644
--- a/chrome/browser/background_mode_manager_unittest.cc
+++ b/chrome/browser/background_mode_manager_unittest.cc
@@ -13,7 +13,9 @@
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"
+using testing::AtLeast;
using testing::InSequence;
+using testing::Return;
class BackgroundModeManagerTest : public TestingBrowserProcessTest {
public:
@@ -28,11 +30,15 @@ class BackgroundModeManagerTest : public TestingBrowserProcessTest {
class TestBackgroundModeManager : public BackgroundModeManager {
public:
TestBackgroundModeManager(Profile* profile, CommandLine* cl)
- : BackgroundModeManager(profile, cl) {
- }
+ : BackgroundModeManager(profile, cl),
+ enabled_(true) {}
MOCK_METHOD1(EnableLaunchOnStartup, void(bool));
MOCK_METHOD0(CreateStatusTrayIcon, void());
MOCK_METHOD0(RemoveStatusTrayIcon, void());
+ virtual bool IsBackgroundModePrefEnabled() { return enabled_; }
+ void SetEnabled(bool enabled) { enabled_ = enabled; }
+ private:
+ bool enabled_;
};
TEST_F(BackgroundModeManagerTest, BackgroundAppLoadUnload) {
@@ -65,3 +71,57 @@ TEST_F(BackgroundModeManagerTest, BackgroundAppInstallUninstall) {
manager.OnBackgroundAppUnloaded();
manager.OnBackgroundAppUninstalled();
}
+
+// App installs while disabled should do nothing.
+TEST_F(BackgroundModeManagerTest, BackgroundAppInstallUninstallWhileDisabled) {
+ InSequence s;
+ TestingProfile profile;
+ TestBackgroundModeManager manager(&profile, command_line_.get());
+ // Turn off background mode.
+ manager.SetEnabled(false);
+ manager.DisableBackgroundMode();
+
+ // Status tray icons will not be created, launch on startup status will be set
+ // to "do not launch on startup".
+ EXPECT_CALL(manager, EnableLaunchOnStartup(false));
+ manager.OnBackgroundAppInstalled(NULL);
+ manager.OnBackgroundAppLoaded();
+ manager.OnBackgroundAppUnloaded();
+ manager.OnBackgroundAppUninstalled();
+
+ // Re-enable background mode.
+ manager.SetEnabled(true);
+ manager.EnableBackgroundMode();
+}
+
+
+// App installs while disabled should do nothing.
+TEST_F(BackgroundModeManagerTest, EnableAfterBackgroundAppInstall) {
+ InSequence s;
+ TestingProfile profile;
+ TestBackgroundModeManager manager(&profile, command_line_.get());
+ EXPECT_CALL(manager, EnableLaunchOnStartup(true));
+ EXPECT_CALL(manager, CreateStatusTrayIcon());
+ EXPECT_CALL(manager, RemoveStatusTrayIcon());
+ EXPECT_CALL(manager, EnableLaunchOnStartup(false));
+ EXPECT_CALL(manager, CreateStatusTrayIcon());
+ EXPECT_CALL(manager, EnableLaunchOnStartup(true));
+ EXPECT_CALL(manager, RemoveStatusTrayIcon());
+ EXPECT_CALL(manager, EnableLaunchOnStartup(false));
+
+ // Install app, should show status tray icon.
+ manager.OnBackgroundAppInstalled(NULL);
+ manager.OnBackgroundAppLoaded();
+
+ // Turn off background mode - should hide status tray icon.
+ manager.SetEnabled(false);
+ manager.DisableBackgroundMode();
+
+ // Turn back on background mode - should show status tray icon.
+ manager.SetEnabled(true);
+ manager.EnableBackgroundMode();
+
+ // Uninstall app, should hide status tray icon again.
+ manager.OnBackgroundAppUnloaded();
+ manager.OnBackgroundAppUninstalled();
+}
« no previous file with comments | « chrome/browser/background_mode_manager.cc ('k') | chrome/browser/resources/options/advanced_options.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698