Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(3529)

Unified Diff: chrome/test/base/ui_test_utils.cc

Issue 8530003: Delete the temporary file when generating MHTML with the extension API. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: One more sync Created 9 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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(&current_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)

Powered by Google App Engine
This is Rietveld 408576698