blob: 087b4fe6f056182e79491f848864953392b87c4b (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
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();
}
|