Chromium Code Reviews| 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 "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
| 9 #include "base/location.h" | 9 #include "base/location.h" |
| 10 #include "base/run_loop.h" | 10 #include "base/run_loop.h" |
| 11 #include "base/single_thread_task_runner.h" | 11 #include "base/single_thread_task_runner.h" |
| 12 #include "base/strings/utf_string_conversions.h" | 12 #include "base/strings/utf_string_conversions.h" |
| 13 #include "base/thread_task_runner_handle.h" | 13 #include "base/thread_task_runner_handle.h" |
| 14 #include "base/values.h" | 14 #include "base/values.h" |
| 15 #include "content/common/site_isolation_policy.h" | 15 #include "content/common/site_isolation_policy.h" |
| 16 #include "content/public/browser/browser_child_process_host_iterator.h" | 16 #include "content/public/browser/browser_child_process_host_iterator.h" |
| 17 #include "content/public/browser/notification_service.h" | 17 #include "content/public/browser/notification_service.h" |
| 18 #include "content/public/browser/render_frame_host.h" | 18 #include "content/public/browser/render_frame_host.h" |
| 19 #include "content/public/browser/render_process_host.h" | 19 #include "content/public/browser/render_process_host.h" |
| 20 #include "content/public/browser/web_contents.h" | 20 #include "content/public/browser/web_contents.h" |
| 21 #include "content/public/common/content_switches.h" | 21 #include "content/public/common/content_switches.h" |
| 22 #include "content/public/common/process_type.h" | 22 #include "content/public/common/process_type.h" |
| 23 #include "content/public/test/test_launcher.h" | 23 #include "content/public/test/test_launcher.h" |
| 24 #include "testing/gtest/include/gtest/gtest.h" | 24 #include "testing/gtest/include/gtest/gtest.h" |
| 25 | 25 |
| 26 #if defined(OS_ANDROID) | |
| 27 #include "content/browser/android/browser_jni_registrar.h" | |
| 28 #endif | |
| 29 | |
| 26 namespace content { | 30 namespace content { |
| 27 | 31 |
| 28 namespace { | 32 namespace { |
| 29 | 33 |
| 30 // Number of times to repost a Quit task so that the MessageLoop finishes up | 34 // Number of times to repost a Quit task so that the MessageLoop finishes up |
| 31 // pending tasks and tasks posted by those pending tasks without risking the | 35 // pending tasks and tasks posted by those pending tasks without risking the |
| 32 // potential hang behavior of MessageLoop::QuitWhenIdle. | 36 // potential hang behavior of MessageLoop::QuitWhenIdle. |
| 33 // The criteria for choosing this number: it should be high enough to make the | 37 // The criteria for choosing this number: it should be high enough to make the |
| 34 // quit act like QuitWhenIdle, while taking into account that any page which is | 38 // quit act like QuitWhenIdle, while taking into account that any page which is |
| 35 // animating may be rendering another frame for each quit deferral. For an | 39 // animating may be rendering another frame for each quit deferral. For an |
| (...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 189 | 193 |
| 190 bool AreAllSitesIsolatedForTesting() { | 194 bool AreAllSitesIsolatedForTesting() { |
| 191 return base::CommandLine::ForCurrentProcess()->HasSwitch( | 195 return base::CommandLine::ForCurrentProcess()->HasSwitch( |
| 192 switches::kSitePerProcess); | 196 switches::kSitePerProcess); |
| 193 } | 197 } |
| 194 | 198 |
| 195 void IsolateAllSitesForTesting(base::CommandLine* command_line) { | 199 void IsolateAllSitesForTesting(base::CommandLine* command_line) { |
| 196 command_line->AppendSwitch(switches::kSitePerProcess); | 200 command_line->AppendSwitch(switches::kSitePerProcess); |
| 197 } | 201 } |
| 198 | 202 |
| 203 #if defined(OS_ANDROID) | |
| 204 // Registers content/browser JNI bindings necessary for some types of tests. | |
| 205 bool RegisterJniForTesting(JNIEnv* env) { | |
| 206 return content::android::RegisterBrowserJni(env); | |
|
jam
2015/12/01 19:14:17
no content::
| |
| 207 } | |
| 208 #endif | |
| 209 | |
| 199 MessageLoopRunner::MessageLoopRunner() | 210 MessageLoopRunner::MessageLoopRunner() |
| 200 : loop_running_(false), | 211 : loop_running_(false), |
| 201 quit_closure_called_(false) { | 212 quit_closure_called_(false) { |
| 202 } | 213 } |
| 203 | 214 |
| 204 MessageLoopRunner::~MessageLoopRunner() { | 215 MessageLoopRunner::~MessageLoopRunner() { |
| 205 } | 216 } |
| 206 | 217 |
| 207 void MessageLoopRunner::Run() { | 218 void MessageLoopRunner::Run() { |
| 208 // Do not run the message loop if our quit closure has already been called. | 219 // Do not run the message loop if our quit closure has already been called. |
| (...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 367 | 378 |
| 368 void WebContentsDestroyedWatcher::Wait() { | 379 void WebContentsDestroyedWatcher::Wait() { |
| 369 message_loop_runner_->Run(); | 380 message_loop_runner_->Run(); |
| 370 } | 381 } |
| 371 | 382 |
| 372 void WebContentsDestroyedWatcher::WebContentsDestroyed() { | 383 void WebContentsDestroyedWatcher::WebContentsDestroyed() { |
| 373 message_loop_runner_->Quit(); | 384 message_loop_runner_->Quit(); |
| 374 } | 385 } |
| 375 | 386 |
| 376 } // namespace content | 387 } // namespace content |
| OLD | NEW |