OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "chrome/browser/background/background_mode_manager.h" | 5 #include "chrome/browser/background/background_mode_manager.h" |
6 #include "chrome/browser/browser_process.h" | 6 #include "chrome/browser/browser_process.h" |
7 #include "chrome/browser/extensions/extension_browsertest.h" | 7 #include "chrome/browser/extensions/extension_browsertest.h" |
8 #include "chrome/browser/profiles/profile_manager.h" | 8 #include "chrome/browser/profiles/profile_manager.h" |
9 | 9 |
10 class TestBackgroundModeManager : public BackgroundModeManager { | 10 class TestBackgroundModeManager : public BackgroundModeManager { |
11 public: | 11 public: |
12 TestBackgroundModeManager(CommandLine* command_line, | 12 TestBackgroundModeManager(base::CommandLine* command_line, |
13 ProfileInfoCache* profile_cache) | 13 ProfileInfoCache* profile_cache) |
14 : BackgroundModeManager(command_line, profile_cache), | 14 : BackgroundModeManager(command_line, profile_cache), |
15 showed_background_app_installed_notification_for_test_(false) {} | 15 showed_background_app_installed_notification_for_test_(false) {} |
16 | 16 |
17 ~TestBackgroundModeManager() override {} | 17 ~TestBackgroundModeManager() override {} |
18 | 18 |
19 void DisplayAppInstalledNotification( | 19 void DisplayAppInstalledNotification( |
20 const extensions::Extension* extension) override { | 20 const extensions::Extension* extension) override { |
21 showed_background_app_installed_notification_for_test_ = true; | 21 showed_background_app_installed_notification_for_test_ = true; |
22 } | 22 } |
(...skipping 20 matching lines...) Expand all Loading... |
43 | 43 |
44 class BackgroundAppBrowserTest: public ExtensionBrowserTest {}; | 44 class BackgroundAppBrowserTest: public ExtensionBrowserTest {}; |
45 | 45 |
46 // Tests that if we reload a background app, we don't get a popup bubble | 46 // Tests that if we reload a background app, we don't get a popup bubble |
47 // telling us that a new background app has been installed. | 47 // telling us that a new background app has been installed. |
48 IN_PROC_BROWSER_TEST_F(BackgroundAppBrowserTest, ReloadBackgroundApp) { | 48 IN_PROC_BROWSER_TEST_F(BackgroundAppBrowserTest, ReloadBackgroundApp) { |
49 | 49 |
50 // Pass this in to the browser test. | 50 // Pass this in to the browser test. |
51 scoped_ptr<BackgroundModeManager> test_background_mode_manager( | 51 scoped_ptr<BackgroundModeManager> test_background_mode_manager( |
52 new TestBackgroundModeManager( | 52 new TestBackgroundModeManager( |
53 CommandLine::ForCurrentProcess(), | 53 base::CommandLine::ForCurrentProcess(), |
54 &(g_browser_process->profile_manager()->GetProfileInfoCache()))); | 54 &(g_browser_process->profile_manager()->GetProfileInfoCache()))); |
55 g_browser_process->set_background_mode_manager_for_test( | 55 g_browser_process->set_background_mode_manager_for_test( |
56 test_background_mode_manager.Pass()); | 56 test_background_mode_manager.Pass()); |
57 TestBackgroundModeManager* manager = | 57 TestBackgroundModeManager* manager = |
58 reinterpret_cast<TestBackgroundModeManager*>( | 58 reinterpret_cast<TestBackgroundModeManager*>( |
59 g_browser_process->background_mode_manager()); | 59 g_browser_process->background_mode_manager()); |
60 | 60 |
61 // Load our background extension | 61 // Load our background extension |
62 ASSERT_FALSE( | 62 ASSERT_FALSE( |
63 manager->showed_background_app_installed_notification_for_test()); | 63 manager->showed_background_app_installed_notification_for_test()); |
64 const extensions::Extension* extension = LoadExtension( | 64 const extensions::Extension* extension = LoadExtension( |
65 test_data_dir_.AppendASCII("background_app")); | 65 test_data_dir_.AppendASCII("background_app")); |
66 ASSERT_FALSE(extension == NULL); | 66 ASSERT_FALSE(extension == NULL); |
67 | 67 |
68 // Set the test flag to not shown. | 68 // Set the test flag to not shown. |
69 manager->set_showed_background_app_installed_notification_for_test(false); | 69 manager->set_showed_background_app_installed_notification_for_test(false); |
70 | 70 |
71 // Reload our background extension | 71 // Reload our background extension |
72 ReloadExtension(extension->id()); | 72 ReloadExtension(extension->id()); |
73 | 73 |
74 // Ensure that we did not see a "Background extension loaded" dialog. | 74 // Ensure that we did not see a "Background extension loaded" dialog. |
75 EXPECT_FALSE( | 75 EXPECT_FALSE( |
76 manager->showed_background_app_installed_notification_for_test()); | 76 manager->showed_background_app_installed_notification_for_test()); |
77 } | 77 } |
OLD | NEW |