Index: chrome/test/base/ui_test_utils.cc |
diff --git a/chrome/test/base/ui_test_utils.cc b/chrome/test/base/ui_test_utils.cc |
index 6ef89a132effffa558afc35295f72dbacaae0869..44aed98add084ddcb03d67a39670b0c2d9c6c975 100644 |
--- a/chrome/test/base/ui_test_utils.cc |
+++ b/chrome/test/base/ui_test_utils.cc |
@@ -228,22 +228,36 @@ bool ExecuteJavaScriptHelper(RenderViewHost* render_view_host, |
return true; |
} |
+void RunAllPendingMessageAndSendQuit(content::BrowserThread::ID thread_id) { |
+ MessageLoop::current()->PostTask(FROM_HERE, new MessageLoop::QuitTask()); |
+ RunMessageLoop(); |
+ content::BrowserThread::PostTask(thread_id, FROM_HERE, |
+ new MessageLoop::QuitTask()); |
+} |
+ |
} // namespace |
void RunMessageLoop() { |
- MessageLoopForUI* loop = MessageLoopForUI::current(); |
+ MessageLoop* loop = MessageLoop::current(); |
+ MessageLoopForUI* ui_loop = |
+ content::BrowserThread::CurrentlyOn(content::BrowserThread::UI) ? |
+ MessageLoopForUI::current() : NULL; |
bool did_allow_task_nesting = loop->NestableTasksAllowed(); |
loop->SetNestableTasksAllowed(true); |
+ if (ui_loop) { |
#if defined(USE_AURA) |
- aura::Desktop::GetInstance()->Run(); |
+ aura::Desktop::GetInstance()->Run(); |
#elif defined(TOOLKIT_VIEWS) |
- views::AcceleratorHandler handler; |
- loop->RunWithDispatcher(&handler); |
+ views::AcceleratorHandler handler; |
+ ui_loop->RunWithDispatcher(&handler); |
#elif defined(OS_POSIX) && !defined(OS_MACOSX) |
- loop->RunWithDispatcher(NULL); |
+ ui_loop->RunWithDispatcher(NULL); |
#else |
- loop->Run(); |
+ ui_loop->Run(); |
#endif |
+ } else { |
+ loop->Run(); |
+ } |
loop->SetNestableTasksAllowed(did_allow_task_nesting); |
} |
@@ -252,6 +266,22 @@ void RunAllPendingInMessageLoop() { |
ui_test_utils::RunMessageLoop(); |
} |
+void RunAllPendingInMessageLoop(content::BrowserThread::ID thread_id) { |
+ if (content::BrowserThread::CurrentlyOn(thread_id)) { |
+ RunAllPendingInMessageLoop(); |
+ return; |
+ } |
+ content::BrowserThread::ID current_thread_id; |
+ if (!content::BrowserThread::GetCurrentThreadIdentifier(¤t_thread_id)) { |
+ NOTREACHED(); |
+ return; |
+ } |
+ content::BrowserThread::PostTask(thread_id, FROM_HERE, |
+ base::Bind(&RunAllPendingMessageAndSendQuit, current_thread_id)); |
+ |
+ ui_test_utils::RunMessageLoop(); |
+} |
+ |
bool GetCurrentTabTitle(const Browser* browser, string16* title) { |
TabContents* tab_contents = browser->GetSelectedTabContents(); |
if (!tab_contents) |