| 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 "content/public/test/test_utils.h" | 5 #include "content/public/test/test_utils.h" |
| 6 | 6 |
| 7 #include <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
| 11 #include "base/location.h" | 11 #include "base/location.h" |
| 12 #include "base/macros.h" | 12 #include "base/macros.h" |
| 13 #include "base/run_loop.h" | 13 #include "base/run_loop.h" |
| 14 #include "base/single_thread_task_runner.h" | 14 #include "base/single_thread_task_runner.h" |
| 15 #include "base/strings/utf_string_conversions.h" | 15 #include "base/strings/utf_string_conversions.h" |
| 16 #include "base/threading/thread_task_runner_handle.h" | 16 #include "base/threading/thread_task_runner_handle.h" |
| 17 #include "base/values.h" | 17 #include "base/values.h" |
| 18 #include "build/build_config.h" | 18 #include "build/build_config.h" |
| 19 #include "content/common/site_isolation_policy.h" | 19 #include "content/common/site_isolation_policy.h" |
| 20 #include "content/common/url_schemes.h" |
| 20 #include "content/public/browser/browser_child_process_host_iterator.h" | 21 #include "content/public/browser/browser_child_process_host_iterator.h" |
| 21 #include "content/public/browser/notification_service.h" | 22 #include "content/public/browser/notification_service.h" |
| 22 #include "content/public/browser/render_frame_host.h" | 23 #include "content/public/browser/render_frame_host.h" |
| 23 #include "content/public/browser/render_process_host.h" | 24 #include "content/public/browser/render_process_host.h" |
| 24 #include "content/public/browser/web_contents.h" | 25 #include "content/public/browser/web_contents.h" |
| 25 #include "content/public/common/content_switches.h" | 26 #include "content/public/common/content_switches.h" |
| 26 #include "content/public/common/process_type.h" | 27 #include "content/public/common/process_type.h" |
| 27 #include "content/public/test/test_launcher.h" | 28 #include "content/public/test/test_launcher.h" |
| 28 #include "content/public/test/test_service_manager_context.h" | 29 #include "content/public/test/test_service_manager_context.h" |
| 29 #include "testing/gtest/include/gtest/gtest.h" | 30 #include "testing/gtest/include/gtest/gtest.h" |
| 31 #include "url/url_util.h" |
| 30 | 32 |
| 31 #if defined(OS_ANDROID) | 33 #if defined(OS_ANDROID) |
| 32 #include "content/browser/android/browser_jni_registrar.h" | 34 #include "content/browser/android/browser_jni_registrar.h" |
| 33 #endif | 35 #endif |
| 34 | 36 |
| 35 namespace content { | 37 namespace content { |
| 36 | 38 |
| 37 namespace { | 39 namespace { |
| 38 | 40 |
| 39 // Number of times to repost a Quit task so that the MessageLoop finishes up | 41 // Number of times to repost a Quit task so that the MessageLoop finishes up |
| (...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 185 | 187 |
| 186 bool AreAllSitesIsolatedForTesting() { | 188 bool AreAllSitesIsolatedForTesting() { |
| 187 return base::CommandLine::ForCurrentProcess()->HasSwitch( | 189 return base::CommandLine::ForCurrentProcess()->HasSwitch( |
| 188 switches::kSitePerProcess); | 190 switches::kSitePerProcess); |
| 189 } | 191 } |
| 190 | 192 |
| 191 void IsolateAllSitesForTesting(base::CommandLine* command_line) { | 193 void IsolateAllSitesForTesting(base::CommandLine* command_line) { |
| 192 command_line->AppendSwitch(switches::kSitePerProcess); | 194 command_line->AppendSwitch(switches::kSitePerProcess); |
| 193 } | 195 } |
| 194 | 196 |
| 197 void ResetSchemesAndOriginsWhitelist() { |
| 198 url::Shutdown(); |
| 199 RegisterContentSchemes(false); |
| 200 url::Initialize(); |
| 201 } |
| 202 |
| 195 #if defined(OS_ANDROID) | 203 #if defined(OS_ANDROID) |
| 196 // Registers content/browser JNI bindings necessary for some types of tests. | 204 // Registers content/browser JNI bindings necessary for some types of tests. |
| 197 bool RegisterJniForTesting(JNIEnv* env) { | 205 bool RegisterJniForTesting(JNIEnv* env) { |
| 198 return content::android::RegisterBrowserJni(env); | 206 return content::android::RegisterBrowserJni(env); |
| 199 } | 207 } |
| 200 #endif | 208 #endif |
| 201 | 209 |
| 202 MessageLoopRunner::MessageLoopRunner(QuitMode quit_mode) | 210 MessageLoopRunner::MessageLoopRunner(QuitMode quit_mode) |
| 203 : quit_mode_(quit_mode), loop_running_(false), quit_closure_called_(false) { | 211 : quit_mode_(quit_mode), loop_running_(false), quit_closure_called_(false) { |
| 204 } | 212 } |
| (...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 379 | 387 |
| 380 void WebContentsDestroyedWatcher::Wait() { | 388 void WebContentsDestroyedWatcher::Wait() { |
| 381 message_loop_runner_->Run(); | 389 message_loop_runner_->Run(); |
| 382 } | 390 } |
| 383 | 391 |
| 384 void WebContentsDestroyedWatcher::WebContentsDestroyed() { | 392 void WebContentsDestroyedWatcher::WebContentsDestroyed() { |
| 385 message_loop_runner_->Quit(); | 393 message_loop_runner_->Quit(); |
| 386 } | 394 } |
| 387 | 395 |
| 388 } // namespace content | 396 } // namespace content |
| OLD | NEW |