| 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/path_service.h" | 5 #include "base/path_service.h" |
| 6 #include "base/strings/stringprintf.h" | 6 #include "base/strings/stringprintf.h" |
| 7 #include "base/strings/utf_string_conversions.h" | 7 #include "base/strings/utf_string_conversions.h" |
| 8 #include "chrome/browser/background/background_contents_service.h" | 8 #include "chrome/browser/background/background_contents_service.h" |
| 9 #include "chrome/browser/background/background_contents_service_factory.h" | 9 #include "chrome/browser/background/background_contents_service_factory.h" |
| 10 #include "chrome/browser/background/background_mode_manager.h" | 10 #include "chrome/browser/background/background_mode_manager.h" |
| (...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 114 base::ScopedTempDir app_dir_; | 114 base::ScopedTempDir app_dir_; |
| 115 }; | 115 }; |
| 116 | 116 |
| 117 namespace { | 117 namespace { |
| 118 | 118 |
| 119 // Fixture to assist in testing v2 app background pages containing | 119 // Fixture to assist in testing v2 app background pages containing |
| 120 // Native Client embeds. | 120 // Native Client embeds. |
| 121 class AppBackgroundPageNaClTest : public AppBackgroundPageApiTest { | 121 class AppBackgroundPageNaClTest : public AppBackgroundPageApiTest { |
| 122 public: | 122 public: |
| 123 AppBackgroundPageNaClTest() | 123 AppBackgroundPageNaClTest() |
| 124 : extension_(NULL) { | 124 : extension_(NULL) {} |
| 125 PathService::Get(chrome::DIR_GEN_TEST_DATA, &app_dir_); | |
| 126 app_dir_ = app_dir_.AppendASCII( | |
| 127 "ppapi/tests/extensions/background_keepalive/newlib"); | |
| 128 } | |
| 129 virtual ~AppBackgroundPageNaClTest() { | 125 virtual ~AppBackgroundPageNaClTest() { |
| 130 } | 126 } |
| 131 | 127 |
| 132 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE { | 128 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE { |
| 133 AppBackgroundPageApiTest::SetUpCommandLine(command_line); | 129 AppBackgroundPageApiTest::SetUpCommandLine(command_line); |
| 134 command_line->AppendSwitchASCII( | 130 command_line->AppendSwitchASCII( |
| 135 switches::kPpapiKeepAliveThrottle, "50"); | 131 switches::kPpapiKeepAliveThrottle, "50"); |
| 136 command_line->AppendSwitchASCII( | 132 command_line->AppendSwitchASCII( |
| 137 extensions::switches::kEventPageIdleTime, "1000"); | 133 extensions::switches::kEventPageIdleTime, "1000"); |
| 138 command_line->AppendSwitchASCII( | 134 command_line->AppendSwitchASCII( |
| 139 extensions::switches::kEventPageSuspendingTime, "1000"); | 135 extensions::switches::kEventPageSuspendingTime, "1000"); |
| 140 } | 136 } |
| 141 | 137 |
| 142 const Extension* extension() { return extension_; } | 138 const Extension* extension() { return extension_; } |
| 143 | 139 |
| 144 protected: | 140 protected: |
| 145 void LaunchTestingApp() { | 141 void LaunchTestingApp() { |
| 146 extension_ = LoadExtension(app_dir_); | 142 base::FilePath app_dir; |
| 143 PathService::Get(chrome::DIR_GEN_TEST_DATA, &app_dir); |
| 144 app_dir = app_dir.AppendASCII( |
| 145 "ppapi/tests/extensions/background_keepalive/newlib"); |
| 146 extension_ = LoadExtension(app_dir); |
| 147 ASSERT_TRUE(extension_); | 147 ASSERT_TRUE(extension_); |
| 148 } | 148 } |
| 149 | 149 |
| 150 private: | 150 private: |
| 151 base::FilePath app_dir_; | |
| 152 const Extension* extension_; | 151 const Extension* extension_; |
| 153 }; | 152 }; |
| 154 | 153 |
| 155 // Produces an extensions::ProcessManager::ImpulseCallbackForTesting callback | 154 // Produces an extensions::ProcessManager::ImpulseCallbackForTesting callback |
| 156 // that will match a specified goal and can be waited on. | 155 // that will match a specified goal and can be waited on. |
| 157 class ImpulseCallbackCounter { | 156 class ImpulseCallbackCounter { |
| 158 public: | 157 public: |
| 159 explicit ImpulseCallbackCounter(extensions::ProcessManager* manager, | 158 explicit ImpulseCallbackCounter(extensions::ProcessManager* manager, |
| 160 const std::string& extension_id) | 159 const std::string& extension_id) |
| 161 : observed_(0), | 160 : observed_(0), |
| (...skipping 476 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 638 extensions::ExtensionSystem::Get(browser()->profile())->process_manager(); | 637 extensions::ExtensionSystem::Get(browser()->profile())->process_manager(); |
| 639 ImpulseCallbackCounter idle_impulse_counter(manager, extension()->id()); | 638 ImpulseCallbackCounter idle_impulse_counter(manager, extension()->id()); |
| 640 EXPECT_TRUE(nacl_modules_loaded.WaitUntilSatisfied()); | 639 EXPECT_TRUE(nacl_modules_loaded.WaitUntilSatisfied()); |
| 641 | 640 |
| 642 manager->SetKeepaliveImpulseDecrementCallbackForTesting( | 641 manager->SetKeepaliveImpulseDecrementCallbackForTesting( |
| 643 idle_impulse_counter.SetGoalAndGetCallback(1)); | 642 idle_impulse_counter.SetGoalAndGetCallback(1)); |
| 644 nacl_modules_loaded.Reply("be idle"); | 643 nacl_modules_loaded.Reply("be idle"); |
| 645 idle_impulse_counter.Wait(); | 644 idle_impulse_counter.Wait(); |
| 646 } | 645 } |
| 647 | 646 |
| OLD | NEW |