MacViews: Get c/b/ui/views/tabs to build on Mac
[chromium-blink-merge.git] / chrome / browser / extensions / background_app_browsertest.cc
blobaa151047439bba53870d57c556306e731e582516
1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "chrome/browser/background/background_mode_manager.h"
6 #include "chrome/browser/browser_process.h"
7 #include "chrome/browser/extensions/extension_browsertest.h"
8 #include "chrome/browser/profiles/profile_manager.h"
9 #include "chrome/test/base/ui_test_utils.h"
11 class TestBackgroundModeManager : public BackgroundModeManager {
12 public:
13 TestBackgroundModeManager(CommandLine* command_line,
14 ProfileInfoCache* profile_cache)
15 : BackgroundModeManager(command_line, profile_cache),
16 showed_background_app_installed_notification_for_test_(false) {}
18 ~TestBackgroundModeManager() override {}
20 void DisplayAppInstalledNotification(
21 const extensions::Extension* extension) override {
22 showed_background_app_installed_notification_for_test_ = true;
25 bool showed_background_app_installed_notification_for_test() {
26 return showed_background_app_installed_notification_for_test_;
29 void set_showed_background_app_installed_notification_for_test(
30 bool showed) {
31 showed_background_app_installed_notification_for_test_ = showed;
34 private:
35 // Tracks if we have shown a "Background App Installed" notification to the
36 // user. Used for unit tests only.
37 bool showed_background_app_installed_notification_for_test_;
39 FRIEND_TEST_ALL_PREFIXES(BackgroundAppBrowserTest,
40 ReloadBackgroundApp);
42 DISALLOW_COPY_AND_ASSIGN(TestBackgroundModeManager);
45 class BackgroundAppBrowserTest: public ExtensionBrowserTest {};
47 // Tests that if we reload a background app, we don't get a popup bubble
48 // telling us that a new background app has been installed.
49 IN_PROC_BROWSER_TEST_F(BackgroundAppBrowserTest, ReloadBackgroundApp) {
51 // Pass this in to the browser test.
52 scoped_ptr<BackgroundModeManager> test_background_mode_manager(
53 new TestBackgroundModeManager(
54 CommandLine::ForCurrentProcess(),
55 &(g_browser_process->profile_manager()->GetProfileInfoCache())));
56 g_browser_process->set_background_mode_manager_for_test(
57 test_background_mode_manager.Pass());
58 TestBackgroundModeManager* manager =
59 reinterpret_cast<TestBackgroundModeManager*>(
60 g_browser_process->background_mode_manager());
62 // Load our background extension
63 ASSERT_FALSE(
64 manager->showed_background_app_installed_notification_for_test());
65 const extensions::Extension* extension = LoadExtension(
66 test_data_dir_.AppendASCII("background_app"));
67 ASSERT_FALSE(extension == NULL);
69 // Set the test flag to not shown.
70 manager->set_showed_background_app_installed_notification_for_test(false);
72 // Reload our background extension
73 ReloadExtension(extension->id());
75 // Ensure that we did not see a "Background extension loaded" dialog.
76 EXPECT_FALSE(
77 manager->showed_background_app_installed_notification_for_test());