| 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/location.h" | 5 #include "base/location.h" |
| 6 #include "base/path_service.h" | 6 #include "base/path_service.h" |
| 7 #include "base/single_thread_task_runner.h" | 7 #include "base/single_thread_task_runner.h" |
| 8 #include "base/strings/stringprintf.h" | 8 #include "base/strings/stringprintf.h" |
| 9 #include "base/strings/utf_string_conversions.h" | 9 #include "base/strings/utf_string_conversions.h" |
| 10 #include "base/threading/thread_restrictions.h" |
| 10 #include "base/threading/thread_task_runner_handle.h" | 11 #include "base/threading/thread_task_runner_handle.h" |
| 11 #include "build/build_config.h" | 12 #include "build/build_config.h" |
| 12 #include "chrome/browser/background/background_contents_service.h" | 13 #include "chrome/browser/background/background_contents_service.h" |
| 13 #include "chrome/browser/background/background_contents_service_factory.h" | 14 #include "chrome/browser/background/background_contents_service_factory.h" |
| 14 #include "chrome/browser/background/background_mode_manager.h" | 15 #include "chrome/browser/background/background_mode_manager.h" |
| 15 #include "chrome/browser/browser_process.h" | 16 #include "chrome/browser/browser_process.h" |
| 16 #include "chrome/browser/chrome_notification_types.h" | 17 #include "chrome/browser/chrome_notification_types.h" |
| 17 #include "chrome/browser/extensions/extension_apitest.h" | 18 #include "chrome/browser/extensions/extension_apitest.h" |
| 18 #include "chrome/browser/extensions/extension_service.h" | 19 #include "chrome/browser/extensions/extension_service.h" |
| 19 #include "chrome/browser/profiles/profile.h" | 20 #include "chrome/browser/profiles/profile.h" |
| (...skipping 27 matching lines...) Expand all Loading... |
| 47 class AppBackgroundPageApiTest : public ExtensionApiTest { | 48 class AppBackgroundPageApiTest : public ExtensionApiTest { |
| 48 public: | 49 public: |
| 49 void SetUpCommandLine(base::CommandLine* command_line) override { | 50 void SetUpCommandLine(base::CommandLine* command_line) override { |
| 50 ExtensionApiTest::SetUpCommandLine(command_line); | 51 ExtensionApiTest::SetUpCommandLine(command_line); |
| 51 command_line->AppendSwitch(switches::kDisablePopupBlocking); | 52 command_line->AppendSwitch(switches::kDisablePopupBlocking); |
| 52 command_line->AppendSwitch(extensions::switches::kAllowHTTPBackgroundPage); | 53 command_line->AppendSwitch(extensions::switches::kAllowHTTPBackgroundPage); |
| 53 } | 54 } |
| 54 | 55 |
| 55 bool CreateApp(const std::string& app_manifest, | 56 bool CreateApp(const std::string& app_manifest, |
| 56 base::FilePath* app_dir) { | 57 base::FilePath* app_dir) { |
| 58 base::ThreadRestrictions::ScopedAllowIO allow_io; |
| 57 if (!app_dir_.CreateUniqueTempDir()) { | 59 if (!app_dir_.CreateUniqueTempDir()) { |
| 58 LOG(ERROR) << "Unable to create a temporary directory."; | 60 LOG(ERROR) << "Unable to create a temporary directory."; |
| 59 return false; | 61 return false; |
| 60 } | 62 } |
| 61 base::FilePath manifest_path = | 63 base::FilePath manifest_path = |
| 62 app_dir_.GetPath().AppendASCII("manifest.json"); | 64 app_dir_.GetPath().AppendASCII("manifest.json"); |
| 63 int bytes_written = base::WriteFile(manifest_path, | 65 int bytes_written = base::WriteFile(manifest_path, |
| 64 app_manifest.data(), | 66 app_manifest.data(), |
| 65 app_manifest.size()); | 67 app_manifest.size()); |
| 66 if (bytes_written != static_cast<int>(app_manifest.size())) { | 68 if (bytes_written != static_cast<int>(app_manifest.size())) { |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 122 void SetUpOnMainThread() override { | 124 void SetUpOnMainThread() override { |
| 123 AppBackgroundPageApiTest::SetUpOnMainThread(); | 125 AppBackgroundPageApiTest::SetUpOnMainThread(); |
| 124 extensions::ProcessManager::SetEventPageIdleTimeForTesting(1000); | 126 extensions::ProcessManager::SetEventPageIdleTimeForTesting(1000); |
| 125 extensions::ProcessManager::SetEventPageSuspendingTimeForTesting(1000); | 127 extensions::ProcessManager::SetEventPageSuspendingTimeForTesting(1000); |
| 126 } | 128 } |
| 127 | 129 |
| 128 const Extension* extension() { return extension_; } | 130 const Extension* extension() { return extension_; } |
| 129 | 131 |
| 130 protected: | 132 protected: |
| 131 void LaunchTestingApp() { | 133 void LaunchTestingApp() { |
| 134 base::ThreadRestrictions::ScopedAllowIO allow_io; |
| 132 base::FilePath app_dir; | 135 base::FilePath app_dir; |
| 133 PathService::Get(chrome::DIR_GEN_TEST_DATA, &app_dir); | 136 PathService::Get(chrome::DIR_GEN_TEST_DATA, &app_dir); |
| 134 app_dir = app_dir.AppendASCII( | 137 app_dir = app_dir.AppendASCII( |
| 135 "ppapi/tests/extensions/background_keepalive/newlib"); | 138 "ppapi/tests/extensions/background_keepalive/newlib"); |
| 136 extension_ = LoadExtension(app_dir); | 139 extension_ = LoadExtension(app_dir); |
| 137 ASSERT_TRUE(extension_); | 140 ASSERT_TRUE(extension_); |
| 138 } | 141 } |
| 139 | 142 |
| 140 private: | 143 private: |
| 141 const Extension* extension_; | 144 const Extension* extension_; |
| (...skipping 449 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 591 ExtensionTestMessageListener ready_listener("ready", true); | 594 ExtensionTestMessageListener ready_listener("ready", true); |
| 592 LaunchTestingApp(); | 595 LaunchTestingApp(); |
| 593 EXPECT_TRUE(ready_listener.WaitUntilSatisfied()); | 596 EXPECT_TRUE(ready_listener.WaitUntilSatisfied()); |
| 594 | 597 |
| 595 ExtensionTestMessageListener created_listener("created_module:1", false); | 598 ExtensionTestMessageListener created_listener("created_module:1", false); |
| 596 ready_listener.Reply("create_module_without_hack"); | 599 ready_listener.Reply("create_module_without_hack"); |
| 597 EXPECT_TRUE(created_listener.WaitUntilSatisfied()); | 600 EXPECT_TRUE(created_listener.WaitUntilSatisfied()); |
| 598 } | 601 } |
| 599 | 602 |
| 600 #endif // !defined(DISABLE_NACL) | 603 #endif // !defined(DISABLE_NACL) |
| OLD | NEW |