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 "chrome/test/base/ui_test_utils.h" | 5 #include "chrome/test/base/ui_test_utils.h" |
6 | 6 |
7 #if defined(OS_WIN) | 7 #if defined(OS_WIN) |
8 #include <windows.h> | 8 #include <windows.h> |
9 #endif | 9 #endif |
10 | 10 |
(...skipping 248 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
259 MessageLoop::QuitClosure()); | 259 MessageLoop::QuitClosure()); |
260 } | 260 } |
261 | 261 |
262 } // namespace | 262 } // namespace |
263 | 263 |
264 void RunMessageLoop() { | 264 void RunMessageLoop() { |
265 MessageLoop* loop = MessageLoop::current(); | 265 MessageLoop* loop = MessageLoop::current(); |
266 MessageLoopForUI* ui_loop = | 266 MessageLoopForUI* ui_loop = |
267 content::BrowserThread::CurrentlyOn(content::BrowserThread::UI) ? | 267 content::BrowserThread::CurrentlyOn(content::BrowserThread::UI) ? |
268 MessageLoopForUI::current() : NULL; | 268 MessageLoopForUI::current() : NULL; |
269 bool did_allow_task_nesting = loop->NestableTasksAllowed(); | 269 MessageLoop::ScopedNestableTaskAllower allow(loop); |
270 loop->SetNestableTasksAllowed(true); | |
271 if (ui_loop) { | 270 if (ui_loop) { |
272 #if defined(USE_AURA) | 271 #if defined(USE_AURA) |
273 aura::RootWindow::GetInstance()->Run(); | 272 aura::RootWindow::GetInstance()->Run(); |
274 #elif defined(TOOLKIT_VIEWS) | 273 #elif defined(TOOLKIT_VIEWS) |
275 views::AcceleratorHandler handler; | 274 views::AcceleratorHandler handler; |
276 ui_loop->RunWithDispatcher(&handler); | 275 ui_loop->RunWithDispatcher(&handler); |
277 #elif defined(OS_POSIX) && !defined(OS_MACOSX) && !defined(OS_ANDROID) | 276 #elif defined(OS_POSIX) && !defined(OS_MACOSX) && !defined(OS_ANDROID) |
278 ui_loop->RunWithDispatcher(NULL); | 277 ui_loop->RunWithDispatcher(NULL); |
279 #else | 278 #else |
280 ui_loop->Run(); | 279 ui_loop->Run(); |
281 #endif | 280 #endif |
282 } else { | 281 } else { |
283 loop->Run(); | 282 loop->Run(); |
284 } | 283 } |
285 loop->SetNestableTasksAllowed(did_allow_task_nesting); | |
286 } | 284 } |
287 | 285 |
288 void RunAllPendingInMessageLoop() { | 286 void RunAllPendingInMessageLoop() { |
289 MessageLoop::current()->PostTask(FROM_HERE, MessageLoop::QuitClosure()); | 287 MessageLoop::current()->PostTask(FROM_HERE, MessageLoop::QuitClosure()); |
290 ui_test_utils::RunMessageLoop(); | 288 ui_test_utils::RunMessageLoop(); |
291 } | 289 } |
292 | 290 |
293 void RunAllPendingInMessageLoop(content::BrowserThread::ID thread_id) { | 291 void RunAllPendingInMessageLoop(content::BrowserThread::ID thread_id) { |
294 if (content::BrowserThread::CurrentlyOn(thread_id)) { | 292 if (content::BrowserThread::CurrentlyOn(thread_id)) { |
295 RunAllPendingInMessageLoop(); | 293 RunAllPendingInMessageLoop(); |
(...skipping 807 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1103 return taker.TakeRenderWidgetSnapshot(rwh, page_size, page_size, bitmap); | 1101 return taker.TakeRenderWidgetSnapshot(rwh, page_size, page_size, bitmap); |
1104 } | 1102 } |
1105 | 1103 |
1106 bool TakeEntirePageSnapshot(RenderViewHost* rvh, SkBitmap* bitmap) { | 1104 bool TakeEntirePageSnapshot(RenderViewHost* rvh, SkBitmap* bitmap) { |
1107 DCHECK(bitmap); | 1105 DCHECK(bitmap); |
1108 SnapshotTaker taker; | 1106 SnapshotTaker taker; |
1109 return taker.TakeEntirePageSnapshot(rvh, bitmap); | 1107 return taker.TakeEntirePageSnapshot(rvh, bitmap); |
1110 } | 1108 } |
1111 | 1109 |
1112 } // namespace ui_test_utils | 1110 } // namespace ui_test_utils |
OLD | NEW |