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 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
141 int current_find_request_id_; | 141 int current_find_request_id_; |
142 scoped_refptr<content::MessageLoopRunner> message_loop_runner_; | 142 scoped_refptr<content::MessageLoopRunner> message_loop_runner_; |
143 | 143 |
144 DISALLOW_COPY_AND_ASSIGN(FindInPageNotificationObserver); | 144 DISALLOW_COPY_AND_ASSIGN(FindInPageNotificationObserver); |
145 }; | 145 }; |
146 | 146 |
147 void RunAllPendingMessageAndSendQuit(content::BrowserThread::ID thread_id, | 147 void RunAllPendingMessageAndSendQuit(content::BrowserThread::ID thread_id, |
148 const base::Closure& quit_task) { | 148 const base::Closure& quit_task) { |
149 MessageLoop::current()->PostTask(FROM_HERE, | 149 MessageLoop::current()->PostTask(FROM_HERE, |
150 MessageLoop::QuitWhenIdleClosure()); | 150 MessageLoop::QuitWhenIdleClosure()); |
151 RunMessageLoop(); | 151 content::RunMessageLoop(); |
152 content::BrowserThread::PostTask(thread_id, FROM_HERE, quit_task); | 152 content::BrowserThread::PostTask(thread_id, FROM_HERE, quit_task); |
153 } | 153 } |
154 | 154 |
155 } // namespace | 155 } // namespace |
156 | 156 |
157 void RunMessageLoop() { | |
158 base::RunLoop run_loop; | |
159 content::RunThisRunLoop(&run_loop); | |
160 } | |
161 | |
162 void RunAllPendingInMessageLoop() { | 157 void RunAllPendingInMessageLoop() { |
163 MessageLoop::current()->PostTask(FROM_HERE, | 158 MessageLoop::current()->PostTask(FROM_HERE, |
164 MessageLoop::QuitWhenIdleClosure()); | 159 MessageLoop::QuitWhenIdleClosure()); |
165 ui_test_utils::RunMessageLoop(); | 160 content::RunMessageLoop(); |
166 } | 161 } |
167 | 162 |
168 void RunAllPendingInMessageLoop(content::BrowserThread::ID thread_id) { | 163 void RunAllPendingInMessageLoop(content::BrowserThread::ID thread_id) { |
169 if (content::BrowserThread::CurrentlyOn(thread_id)) { | 164 if (content::BrowserThread::CurrentlyOn(thread_id)) { |
170 RunAllPendingInMessageLoop(); | 165 RunAllPendingInMessageLoop(); |
171 return; | 166 return; |
172 } | 167 } |
173 content::BrowserThread::ID current_thread_id; | 168 content::BrowserThread::ID current_thread_id; |
174 if (!content::BrowserThread::GetCurrentThreadIdentifier(¤t_thread_id)) { | 169 if (!content::BrowserThread::GetCurrentThreadIdentifier(¤t_thread_id)) { |
175 NOTREACHED(); | 170 NOTREACHED(); |
(...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
383 InfoBarTabHelper* infobar_helper = tab->infobar_tab_helper(); | 378 InfoBarTabHelper* infobar_helper = tab->infobar_tab_helper(); |
384 while (infobar_helper->infobar_count() > 0) | 379 while (infobar_helper->infobar_count() > 0) |
385 infobar_helper->RemoveInfoBar(infobar_helper->GetInfoBarDelegateAt(0)); | 380 infobar_helper->RemoveInfoBar(infobar_helper->GetInfoBarDelegateAt(0)); |
386 } | 381 } |
387 | 382 |
388 void RegisterAndWait(content::NotificationObserver* observer, | 383 void RegisterAndWait(content::NotificationObserver* observer, |
389 int type, | 384 int type, |
390 const content::NotificationSource& source) { | 385 const content::NotificationSource& source) { |
391 content::NotificationRegistrar registrar; | 386 content::NotificationRegistrar registrar; |
392 registrar.Add(observer, type, source); | 387 registrar.Add(observer, type, source); |
393 RunMessageLoop(); | 388 content::RunMessageLoop(); |
394 } | 389 } |
395 | 390 |
396 void WaitForBookmarkModelToLoad(BookmarkModel* model) { | 391 void WaitForBookmarkModelToLoad(BookmarkModel* model) { |
397 if (model->IsLoaded()) | 392 if (model->IsLoaded()) |
398 return; | 393 return; |
399 base::RunLoop run_loop; | 394 base::RunLoop run_loop; |
400 BookmarkLoadObserver observer(content::GetQuitTaskForRunLoop(&run_loop)); | 395 BookmarkLoadObserver observer(content::GetQuitTaskForRunLoop(&run_loop)); |
401 model->AddObserver(&observer); | 396 model->AddObserver(&observer); |
402 content::RunThisRunLoop(&run_loop); | 397 content::RunThisRunLoop(&run_loop); |
403 model->RemoveObserver(&observer); | 398 model->RemoveObserver(&observer); |
(...skipping 302 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
706 int state, | 701 int state, |
707 const base::Closure& followup) { | 702 const base::Closure& followup) { |
708 if (!followup.is_null()) | 703 if (!followup.is_null()) |
709 ui_controls::SendMouseEventsNotifyWhenDone(button, state, followup); | 704 ui_controls::SendMouseEventsNotifyWhenDone(button, state, followup); |
710 else | 705 else |
711 ui_controls::SendMouseEvents(button, state); | 706 ui_controls::SendMouseEvents(button, state); |
712 } | 707 } |
713 | 708 |
714 } // namespace internal | 709 } // namespace internal |
715 } // namespace ui_test_utils | 710 } // namespace ui_test_utils |
OLD | NEW |