Index: content/public/test/browser_test_base.cc |
=================================================================== |
--- content/public/test/browser_test_base.cc (revision 195684) |
+++ content/public/test/browser_test_base.cc (working copy) |
@@ -8,8 +8,11 @@ |
#include "base/command_line.h" |
#include "base/debug/stack_trace.h" |
#include "base/process_util.h" |
+#include "content/browser/renderer_host/render_process_host_impl.h" |
+#include "content/public/browser/browser_thread.h" |
#include "content/public/common/content_switches.h" |
#include "content/public/common/main_function_params.h" |
+#include "content/public/test/test_utils.h" |
#if defined(OS_MACOSX) |
#include "base/mac/mac_util.h" |
@@ -22,6 +25,7 @@ |
#include "content/public/browser/browser_thread.h" |
#endif |
+namespace content { |
namespace { |
#if defined(OS_POSIX) |
@@ -43,12 +47,16 @@ |
} |
#endif // defined(OS_POSIX) |
+void RunTaskOnRendererThread(const base::Closure& task, |
+ const base::Closure& quit_task) { |
+ task.Run(); |
+ BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, quit_task); |
+} |
+ |
} // namespace |
-namespace content { |
+extern int BrowserMain(const MainFunctionParams&); |
-extern int BrowserMain(const content::MainFunctionParams&); |
- |
BrowserTestBase::BrowserTestBase() { |
#if defined(OS_MACOSX) |
base::mac::SetOverrideAmIBundled(true); |
@@ -120,4 +128,20 @@ |
test_server_base)); |
} |
+void BrowserTestBase::PostTaskToInProcessRendererAndWait( |
+ const base::Closure& task) { |
+ CHECK(CommandLine::ForCurrentProcess()->HasSwitch(switches::kSingleProcess)); |
+ |
+ scoped_refptr<MessageLoopRunner> runner = new MessageLoopRunner; |
+ |
+ base::MessageLoop* renderer_loop = |
+ RenderProcessHostImpl::GetInProcessRendererThreadForTesting(); |
+ CHECK(renderer_loop); |
+ |
+ renderer_loop->PostTask( |
+ FROM_HERE, |
+ base::Bind(&RunTaskOnRendererThread, task, runner->QuitClosure())); |
+ runner->Run(); |
+} |
+ |
} // namespace content |