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/strings/stringprintf.h" | 5 #include "base/strings/stringprintf.h" |
6 #include "base/strings/utf_string_conversions.h" | 6 #include "base/strings/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/chrome_notification_types.h" | 11 #include "chrome/browser/chrome_notification_types.h" |
12 #include "chrome/browser/extensions/extension_apitest.h" | 12 #include "chrome/browser/extensions/extension_apitest.h" |
13 #include "chrome/browser/extensions/extension_service.h" | 13 #include "chrome/browser/extensions/extension_service.h" |
14 #include "chrome/browser/profiles/profile.h" | 14 #include "chrome/browser/profiles/profile.h" |
15 #include "chrome/browser/ui/browser.h" | 15 #include "chrome/browser/ui/browser.h" |
16 #include "chrome/browser/ui/browser_dialogs.h" | 16 #include "chrome/browser/ui/browser_dialogs.h" |
17 #include "chrome/browser/ui/browser_window.h" | 17 #include "chrome/browser/ui/browser_window.h" |
18 #include "chrome/common/chrome_switches.h" | 18 #include "chrome/common/chrome_switches.h" |
19 #include "chrome/common/extensions/extension.h" | 19 #include "chrome/common/extensions/extension.h" |
20 #include "content/public/browser/notification_service.h" | 20 #include "content/public/browser/notification_service.h" |
21 #include "content/public/test/test_notification_tracker.h" | 21 #include "content/public/test/test_notification_tracker.h" |
22 #include "content/public/test/test_utils.h" | 22 #include "content/public/test/test_utils.h" |
| 23 #include "extensions/common/switches.h" |
23 #include "net/dns/mock_host_resolver.h" | 24 #include "net/dns/mock_host_resolver.h" |
24 #include "net/test/embedded_test_server/embedded_test_server.h" | 25 #include "net/test/embedded_test_server/embedded_test_server.h" |
25 | 26 |
26 #if defined(OS_MACOSX) | 27 #if defined(OS_MACOSX) |
27 #include "base/mac/scoped_nsautorelease_pool.h" | 28 #include "base/mac/scoped_nsautorelease_pool.h" |
28 #endif | 29 #endif |
29 | 30 |
30 using extensions::Extension; | 31 using extensions::Extension; |
31 | 32 |
32 class AppBackgroundPageApiTest : public ExtensionApiTest { | 33 class AppBackgroundPageApiTest : public ExtensionApiTest { |
33 public: | 34 public: |
34 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE { | 35 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE { |
35 ExtensionApiTest::SetUpCommandLine(command_line); | 36 ExtensionApiTest::SetUpCommandLine(command_line); |
36 command_line->AppendSwitch(switches::kDisablePopupBlocking); | 37 command_line->AppendSwitch(switches::kDisablePopupBlocking); |
37 command_line->AppendSwitch(switches::kAllowHTTPBackgroundPage); | 38 command_line->AppendSwitch(extensions::switches::kAllowHTTPBackgroundPage); |
38 } | 39 } |
39 | 40 |
40 bool CreateApp(const std::string& app_manifest, | 41 bool CreateApp(const std::string& app_manifest, |
41 base::FilePath* app_dir) { | 42 base::FilePath* app_dir) { |
42 if (!app_dir_.CreateUniqueTempDir()) { | 43 if (!app_dir_.CreateUniqueTempDir()) { |
43 LOG(ERROR) << "Unable to create a temporary directory."; | 44 LOG(ERROR) << "Unable to create a temporary directory."; |
44 return false; | 45 return false; |
45 } | 46 } |
46 base::FilePath manifest_path = app_dir_.path().AppendASCII("manifest.json"); | 47 base::FilePath manifest_path = app_dir_.path().AppendASCII("manifest.json"); |
47 int bytes_written = file_util::WriteFile(manifest_path, | 48 int bytes_written = file_util::WriteFile(manifest_path, |
(...skipping 446 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
494 // Close all browsers - app should continue running. | 495 // Close all browsers - app should continue running. |
495 set_exit_when_last_browser_closes(false); | 496 set_exit_when_last_browser_closes(false); |
496 CloseBrowser(browser()); | 497 CloseBrowser(browser()); |
497 | 498 |
498 // Post a task to unload the extension - this should cause Chrome to exit | 499 // Post a task to unload the extension - this should cause Chrome to exit |
499 // cleanly (not crash). | 500 // cleanly (not crash). |
500 UnloadExtensionViaTask(extension->id()); | 501 UnloadExtensionViaTask(extension->id()); |
501 content::RunAllPendingInMessageLoop(); | 502 content::RunAllPendingInMessageLoop(); |
502 ASSERT_TRUE(WaitForBackgroundMode(false)); | 503 ASSERT_TRUE(WaitForBackgroundMode(false)); |
503 } | 504 } |
OLD | NEW |