From 4c793f0298cbafa6826ef1bc2d85d92bf64320ba Mon Sep 17 00:00:00 2001 From: "atwilson@chromium.org" Date: Wed, 18 Aug 2010 20:55:45 +0000 Subject: 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 --- chrome/browser/background_mode_manager_unittest.cc | 46 ++++++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 chrome/browser/background_mode_manager_unittest.cc (limited to '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 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(); +} -- cgit v1.1