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

Side by Side 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: Minor clean-ups 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 "chrome/test/base/ui_test_utils.h" 5 #include "chrome/test/base/ui_test_utils.h"
6 6
7 #include <vector> 7 #include <vector>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/bind_helpers.h" 10 #include "base/bind_helpers.h"
(...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after
221 ListValue* list = static_cast<ListValue*>(root_val.get()); 221 ListValue* list = static_cast<ListValue*>(root_val.get());
222 Value* result_val; 222 Value* result_val;
223 if (!list || !list->GetSize() || 223 if (!list || !list->GetSize() ||
224 !list->Remove(0, &result_val)) // Remove gives us ownership of the value. 224 !list->Remove(0, &result_val)) // Remove gives us ownership of the value.
225 return false; 225 return false;
226 226
227 result->reset(result_val); 227 result->reset(result_val);
228 return true; 228 return true;
229 } 229 }
230 230
231 void RunAllPendingMessageAndSendQuit(content::BrowserThread::ID thread_id) {
232 MessageLoop::current()->PostTask(FROM_HERE, new MessageLoop::QuitTask());
sky 2011/11/18 23:24:56 Can you use RunAllPendingInMessageLoop again here?
Jay Civelli 2011/11/19 00:01:12 Done.
233 MessageLoop* loop = MessageLoop::current();
234 bool did_allow_task_nesting = loop->NestableTasksAllowed();
235 loop->SetNestableTasksAllowed(true);
236 loop->Run();
237 loop->SetNestableTasksAllowed(did_allow_task_nesting);
238 content::BrowserThread::PostTask(thread_id, FROM_HERE,
239 new MessageLoop::QuitTask());
240 }
241
231 } // namespace 242 } // namespace
232 243
233 void RunMessageLoop() { 244 void RunMessageLoop() {
234 MessageLoopForUI* loop = MessageLoopForUI::current(); 245 MessageLoopForUI* loop = MessageLoopForUI::current();
235 bool did_allow_task_nesting = loop->NestableTasksAllowed(); 246 bool did_allow_task_nesting = loop->NestableTasksAllowed();
236 loop->SetNestableTasksAllowed(true); 247 loop->SetNestableTasksAllowed(true);
237 #if defined(USE_AURA) 248 #if defined(USE_AURA)
238 aura::Desktop::GetInstance()->Run(); 249 aura::Desktop::GetInstance()->Run();
239 #elif defined(TOOLKIT_VIEWS) 250 #elif defined(TOOLKIT_VIEWS)
240 views::AcceleratorHandler handler; 251 views::AcceleratorHandler handler;
241 loop->RunWithDispatcher(&handler); 252 loop->RunWithDispatcher(&handler);
242 #elif defined(OS_POSIX) && !defined(OS_MACOSX) 253 #elif defined(OS_POSIX) && !defined(OS_MACOSX)
243 loop->RunWithDispatcher(NULL); 254 loop->RunWithDispatcher(NULL);
244 #else 255 #else
245 loop->Run(); 256 loop->Run();
246 #endif 257 #endif
247 loop->SetNestableTasksAllowed(did_allow_task_nesting); 258 loop->SetNestableTasksAllowed(did_allow_task_nesting);
248 } 259 }
249 260
250 void RunAllPendingInMessageLoop() { 261 void RunAllPendingInMessageLoop() {
251 MessageLoop::current()->PostTask(FROM_HERE, new MessageLoop::QuitTask()); 262 MessageLoop::current()->PostTask(FROM_HERE, new MessageLoop::QuitTask());
252 ui_test_utils::RunMessageLoop(); 263 ui_test_utils::RunMessageLoop();
253 } 264 }
254 265
266 void RunAllPendingInMessageLoop(content::BrowserThread::ID thread_id) {
267 if (content::BrowserThread::CurrentlyOn(thread_id)) {
268 RunAllPendingInMessageLoop();
269 return;
270 }
271 content::BrowserThread::ID current_thread_id;
272 if (!content::BrowserThread::GetCurrentThreadIdentifier(&current_thread_id)) {
273 NOTREACHED();
274 return;
275 }
276 content::BrowserThread::PostTask(thread_id, FROM_HERE,
277 base::Bind(&RunAllPendingMessageAndSendQuit, current_thread_id));
278
279 ui_test_utils::RunMessageLoop();
280 }
281
sky 2011/11/18 23:24:56 nit: remove line.
Jay Civelli 2011/11/19 00:01:12 Done.
282
255 bool GetCurrentTabTitle(const Browser* browser, string16* title) { 283 bool GetCurrentTabTitle(const Browser* browser, string16* title) {
256 TabContents* tab_contents = browser->GetSelectedTabContents(); 284 TabContents* tab_contents = browser->GetSelectedTabContents();
257 if (!tab_contents) 285 if (!tab_contents)
258 return false; 286 return false;
259 NavigationEntry* last_entry = tab_contents->controller().GetActiveEntry(); 287 NavigationEntry* last_entry = tab_contents->controller().GetActiveEntry();
260 if (!last_entry) 288 if (!last_entry)
261 return false; 289 return false;
262 title->assign(last_entry->GetTitleForDisplay("")); 290 title->assign(last_entry->GetTitleForDisplay(""));
263 return true; 291 return true;
264 } 292 }
(...skipping 730 matching lines...) Expand 10 before | Expand all | Expand 10 after
995 return taker.TakeRenderWidgetSnapshot(rwh, page_size, page_size, bitmap); 1023 return taker.TakeRenderWidgetSnapshot(rwh, page_size, page_size, bitmap);
996 } 1024 }
997 1025
998 bool TakeEntirePageSnapshot(RenderViewHost* rvh, SkBitmap* bitmap) { 1026 bool TakeEntirePageSnapshot(RenderViewHost* rvh, SkBitmap* bitmap) {
999 DCHECK(bitmap); 1027 DCHECK(bitmap);
1000 SnapshotTaker taker; 1028 SnapshotTaker taker;
1001 return taker.TakeEntirePageSnapshot(rvh, bitmap); 1029 return taker.TakeEntirePageSnapshot(rvh, bitmap);
1002 } 1030 }
1003 1031
1004 } // namespace ui_test_utils 1032 } // namespace ui_test_utils
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698