| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/stringprintf.h" | 5 #include "base/stringprintf.h" |
| 6 #include "base/utf_string_conversions.h" | 6 #include "base/utf_string_conversions.h" |
| 7 #include "chrome/browser/background/background_contents_service.h" | 7 #include "chrome/browser/background/background_contents_service.h" |
| 8 #include "chrome/browser/background/background_contents_service_factory.h" | 8 #include "chrome/browser/background/background_contents_service_factory.h" |
| 9 #include "chrome/browser/background/background_mode_manager.h" | 9 #include "chrome/browser/background/background_mode_manager.h" |
| 10 #include "chrome/browser/browser_process.h" | 10 #include "chrome/browser/browser_process.h" |
| 11 #include "chrome/browser/extensions/extension_apitest.h" | 11 #include "chrome/browser/extensions/extension_apitest.h" |
| 12 #include "chrome/browser/extensions/extension_service.h" | 12 #include "chrome/browser/extensions/extension_service.h" |
| 13 #include "chrome/browser/profiles/profile.h" | 13 #include "chrome/browser/profiles/profile.h" |
| 14 #include "chrome/browser/ui/browser.h" | 14 #include "chrome/browser/ui/browser.h" |
| 15 #include "chrome/common/chrome_notification_types.h" | 15 #include "chrome/common/chrome_notification_types.h" |
| 16 #include "chrome/common/chrome_switches.h" | 16 #include "chrome/common/chrome_switches.h" |
| 17 #include "chrome/common/extensions/extension.h" | 17 #include "chrome/common/extensions/extension.h" |
| 18 #include "chrome/test/base/ui_test_utils.h" | |
| 19 #include "content/public/browser/notification_service.h" | 18 #include "content/public/browser/notification_service.h" |
| 20 #include "content/public/test/test_notification_tracker.h" | 19 #include "content/public/test/test_notification_tracker.h" |
| 20 #include "content/public/test/test_utils.h" |
| 21 #include "net/base/mock_host_resolver.h" | 21 #include "net/base/mock_host_resolver.h" |
| 22 | 22 |
| 23 using extensions::Extension; | 23 using extensions::Extension; |
| 24 | 24 |
| 25 class AppBackgroundPageApiTest : public ExtensionApiTest { | 25 class AppBackgroundPageApiTest : public ExtensionApiTest { |
| 26 public: | 26 public: |
| 27 void SetUpCommandLine(CommandLine* command_line) OVERRIDE { | 27 void SetUpCommandLine(CommandLine* command_line) OVERRIDE { |
| 28 ExtensionApiTest::SetUpCommandLine(command_line); | 28 ExtensionApiTest::SetUpCommandLine(command_line); |
| 29 command_line->AppendSwitch(switches::kDisablePopupBlocking); | 29 command_line->AppendSwitch(switches::kDisablePopupBlocking); |
| 30 command_line->AppendSwitch(switches::kAllowHTTPBackgroundPage); | 30 command_line->AppendSwitch(switches::kAllowHTTPBackgroundPage); |
| (...skipping 30 matching lines...) Expand all Loading... |
| 61 // this check. | 61 // this check. |
| 62 if (!manager || !manager->IsBackgroundModePrefEnabled()) { | 62 if (!manager || !manager->IsBackgroundModePrefEnabled()) { |
| 63 DLOG(WARNING) << "Skipping check - background mode disabled"; | 63 DLOG(WARNING) << "Skipping check - background mode disabled"; |
| 64 return true; | 64 return true; |
| 65 } | 65 } |
| 66 if (manager->IsBackgroundModeActiveForTest() == expected_background_mode) | 66 if (manager->IsBackgroundModeActiveForTest() == expected_background_mode) |
| 67 return true; | 67 return true; |
| 68 | 68 |
| 69 // We are not currently in the expected state - wait for the state to | 69 // We are not currently in the expected state - wait for the state to |
| 70 // change. | 70 // change. |
| 71 ui_test_utils::WindowedNotificationObserver watcher( | 71 content::WindowedNotificationObserver watcher( |
| 72 chrome::NOTIFICATION_BACKGROUND_MODE_CHANGED, | 72 chrome::NOTIFICATION_BACKGROUND_MODE_CHANGED, |
| 73 content::NotificationService::AllSources()); | 73 content::NotificationService::AllSources()); |
| 74 watcher.Wait(); | 74 watcher.Wait(); |
| 75 return manager->IsBackgroundModeActiveForTest() == expected_background_mode; | 75 return manager->IsBackgroundModeActiveForTest() == expected_background_mode; |
| 76 #endif | 76 #endif |
| 77 } | 77 } |
| 78 | 78 |
| 79 private: | 79 private: |
| 80 ScopedTempDir app_dir_; | 80 ScopedTempDir app_dir_; |
| 81 }; | 81 }; |
| (...skipping 323 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 405 BackgroundContentsServiceFactory::GetForProfile(browser()->profile())-> | 405 BackgroundContentsServiceFactory::GetForProfile(browser()->profile())-> |
| 406 GetAppBackgroundContents(ASCIIToUTF16(extension->id()))); | 406 GetAppBackgroundContents(ASCIIToUTF16(extension->id()))); |
| 407 // Now close the BackgroundContents. | 407 // Now close the BackgroundContents. |
| 408 ASSERT_TRUE(RunExtensionTest("app_background_page/basic_close")) << message_; | 408 ASSERT_TRUE(RunExtensionTest("app_background_page/basic_close")) << message_; |
| 409 // Background mode should no longer be active. | 409 // Background mode should no longer be active. |
| 410 ASSERT_TRUE(WaitForBackgroundMode(false)); | 410 ASSERT_TRUE(WaitForBackgroundMode(false)); |
| 411 ASSERT_FALSE( | 411 ASSERT_FALSE( |
| 412 BackgroundContentsServiceFactory::GetForProfile(browser()->profile())-> | 412 BackgroundContentsServiceFactory::GetForProfile(browser()->profile())-> |
| 413 GetAppBackgroundContents(ASCIIToUTF16(extension->id()))); | 413 GetAppBackgroundContents(ASCIIToUTF16(extension->id()))); |
| 414 } | 414 } |
| OLD | NEW |