| 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 "base/gtest_prod_util.h" |
| 5 #include "chrome/browser/background/background_mode_manager.h" | 6 #include "chrome/browser/background/background_mode_manager.h" |
| 6 #include "chrome/browser/browser_process.h" | 7 #include "chrome/browser/browser_process.h" |
| 7 #include "chrome/browser/extensions/extension_browsertest.h" | 8 #include "chrome/browser/extensions/extension_browsertest.h" |
| 8 #include "chrome/browser/profiles/profile_manager.h" | 9 #include "chrome/browser/profiles/profile_manager.h" |
| 9 | 10 |
| 10 class TestBackgroundModeManager : public BackgroundModeManager { | 11 class TestBackgroundModeManager : public BackgroundModeManager { |
| 11 public: | 12 public: |
| 12 TestBackgroundModeManager(const base::CommandLine& command_line, | 13 TestBackgroundModeManager(const base::CommandLine& command_line, |
| 13 ProfileInfoCache* profile_cache) | 14 ProfileInfoCache* profile_cache) |
| 14 : BackgroundModeManager(command_line, profile_cache), | 15 : BackgroundModeManager(command_line, profile_cache), |
| (...skipping 23 matching lines...) Expand all Loading... |
| 38 ReloadBackgroundApp); | 39 ReloadBackgroundApp); |
| 39 | 40 |
| 40 DISALLOW_COPY_AND_ASSIGN(TestBackgroundModeManager); | 41 DISALLOW_COPY_AND_ASSIGN(TestBackgroundModeManager); |
| 41 }; | 42 }; |
| 42 | 43 |
| 43 class BackgroundAppBrowserTest: public ExtensionBrowserTest {}; | 44 class BackgroundAppBrowserTest: public ExtensionBrowserTest {}; |
| 44 | 45 |
| 45 // 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 |
| 46 // telling us that a new background app has been installed. | 47 // telling us that a new background app has been installed. |
| 47 IN_PROC_BROWSER_TEST_F(BackgroundAppBrowserTest, ReloadBackgroundApp) { | 48 IN_PROC_BROWSER_TEST_F(BackgroundAppBrowserTest, ReloadBackgroundApp) { |
| 48 | |
| 49 // Pass this in to the browser test. | 49 // Pass this in to the browser test. |
| 50 scoped_ptr<BackgroundModeManager> test_background_mode_manager( | 50 scoped_ptr<BackgroundModeManager> test_background_mode_manager( |
| 51 new TestBackgroundModeManager( | 51 new TestBackgroundModeManager( |
| 52 *base::CommandLine::ForCurrentProcess(), | 52 *base::CommandLine::ForCurrentProcess(), |
| 53 &(g_browser_process->profile_manager()->GetProfileInfoCache()))); | 53 &(g_browser_process->profile_manager()->GetProfileInfoCache()))); |
| 54 g_browser_process->set_background_mode_manager_for_test( | 54 g_browser_process->set_background_mode_manager_for_test( |
| 55 test_background_mode_manager.Pass()); | 55 test_background_mode_manager.Pass()); |
| 56 TestBackgroundModeManager* manager = | 56 TestBackgroundModeManager* manager = |
| 57 reinterpret_cast<TestBackgroundModeManager*>( | 57 reinterpret_cast<TestBackgroundModeManager*>( |
| 58 g_browser_process->background_mode_manager()); | 58 g_browser_process->background_mode_manager()); |
| 59 | 59 |
| 60 // Load our background extension | 60 // Load our background extension |
| 61 ASSERT_FALSE( | 61 ASSERT_FALSE( |
| 62 manager->showed_background_app_installed_notification_for_test()); | 62 manager->showed_background_app_installed_notification_for_test()); |
| 63 const extensions::Extension* extension = LoadExtension( | 63 const extensions::Extension* extension = LoadExtension( |
| 64 test_data_dir_.AppendASCII("background_app")); | 64 test_data_dir_.AppendASCII("background_app")); |
| 65 ASSERT_FALSE(extension == NULL); | 65 ASSERT_FALSE(extension == NULL); |
| 66 | 66 |
| 67 // Set the test flag to not shown. | 67 // Set the test flag to not shown. |
| 68 manager->set_showed_background_app_installed_notification_for_test(false); | 68 manager->set_showed_background_app_installed_notification_for_test(false); |
| 69 | 69 |
| 70 // Reload our background extension | 70 // Reload our background extension |
| 71 ReloadExtension(extension->id()); | 71 ReloadExtension(extension->id()); |
| 72 | 72 |
| 73 // Ensure that we did not see a "Background extension loaded" dialog. | 73 // Ensure that we did not see a "Background extension loaded" dialog. |
| 74 EXPECT_FALSE( | 74 EXPECT_FALSE( |
| 75 manager->showed_background_app_installed_notification_for_test()); | 75 manager->showed_background_app_installed_notification_for_test()); |
| 76 } | 76 } |
| OLD | NEW |