diff options
author | atwilson@chromium.org <atwilson@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-08-18 20:55:45 +0000 |
---|---|---|
committer | atwilson@chromium.org <atwilson@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-08-18 20:55:45 +0000 |
commit | 4c793f0298cbafa6826ef1bc2d85d92bf64320ba (patch) | |
tree | 5e6e6a34051417ee4c6847f397713c5d56e99d0d /chrome/browser/background_mode_manager_unittest.cc | |
parent | 0906270c4485c74cf35fed76aee21458702ce68c (diff) | |
download | chromium_src-4c793f0298cbafa6826ef1bc2d85d92bf64320ba.zip chromium_src-4c793f0298cbafa6826ef1bc2d85d92bf64320ba.tar.gz chromium_src-4c793f0298cbafa6826ef1bc2d85d92bf64320ba.tar.bz2 |
Added BackgroundModeManager which tracks when background apps are loaded/unloaded
and puts Chrome into BackgroundMode appropriately.
Added EXTENSION_UNINSTALLING notification which is sent out when a notification
is about to be uninstalled.
Refactored StatusTray code to move StatusTray under the profile rather than
attaching it to the browser process, and removed StatusTrayManager which is
no longer needed now that BackgroundModeManager handles creating status icons.
BUG=43382
TEST=background_mode_manager_unittests.cc
Review URL: http://codereview.chromium.org/3134011
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@56596 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 | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/chrome/browser/background_mode_manager_unittest.cc b/chrome/browser/background_mode_manager_unittest.cc new file mode 100644 index 0000000..087b4fe --- /dev/null +++ b/chrome/browser/background_mode_manager_unittest.cc @@ -0,0 +1,46 @@ +// Copyright (c) 2010 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "chrome/browser/background_mode_manager.h" +#include "chrome/browser/browser_list.h" +#include "chrome/test/testing_profile.h" +#include "testing/gmock/include/gmock/gmock.h" +#include "testing/gtest/include/gtest/gtest.h" + +class TestBackgroundModeManager : public BackgroundModeManager { + public: + explicit TestBackgroundModeManager(Profile* profile) + : BackgroundModeManager(profile) { + } + MOCK_METHOD1(EnableLaunchOnStartup, void(bool)); + MOCK_METHOD0(CreateStatusTrayIcon, void()); + MOCK_METHOD0(RemoveStatusTrayIcon, void()); +}; + +TEST(BackgroundModeManagerTest, BackgroundAppLoadUnload) { + TestingProfile profile; + TestBackgroundModeManager manager(&profile); + 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) { + 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)); + manager.OnBackgroundAppInstalled(); + manager.OnBackgroundAppLoaded(); + EXPECT_CALL(manager, EnableLaunchOnStartup(false)); + manager.OnBackgroundAppUninstalled(); + manager.OnBackgroundAppUnloaded(); +} |