| 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 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 137 int active_match_ordinal_; | 137 int active_match_ordinal_; |
| 138 int number_of_matches_; | 138 int number_of_matches_; |
| 139 // The id of the current find request, obtained from WebContents. Allows us | 139 // The id of the current find request, obtained from WebContents. Allows us |
| 140 // to monitor when the search completes. | 140 // to monitor when the search completes. |
| 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, | |
| 148 const base::Closure& quit_task) { | |
| 149 MessageLoop::current()->PostTask(FROM_HERE, | |
| 150 MessageLoop::QuitWhenIdleClosure()); | |
| 151 content::RunMessageLoop(); | |
| 152 content::BrowserThread::PostTask(thread_id, FROM_HERE, quit_task); | |
| 153 } | |
| 154 | |
| 155 } // namespace | 147 } // namespace |
| 156 | 148 |
| 157 void RunAllPendingInMessageLoop() { | |
| 158 MessageLoop::current()->PostTask(FROM_HERE, | |
| 159 MessageLoop::QuitWhenIdleClosure()); | |
| 160 content::RunMessageLoop(); | |
| 161 } | |
| 162 | |
| 163 void RunAllPendingInMessageLoop(content::BrowserThread::ID thread_id) { | |
| 164 if (content::BrowserThread::CurrentlyOn(thread_id)) { | |
| 165 RunAllPendingInMessageLoop(); | |
| 166 return; | |
| 167 } | |
| 168 content::BrowserThread::ID current_thread_id; | |
| 169 if (!content::BrowserThread::GetCurrentThreadIdentifier(¤t_thread_id)) { | |
| 170 NOTREACHED(); | |
| 171 return; | |
| 172 } | |
| 173 | |
| 174 base::RunLoop run_loop; | |
| 175 content::BrowserThread::PostTask(thread_id, FROM_HERE, | |
| 176 base::Bind(&RunAllPendingMessageAndSendQuit, current_thread_id, | |
| 177 run_loop.QuitClosure())); | |
| 178 content::RunThisRunLoop(&run_loop); | |
| 179 } | |
| 180 | |
| 181 bool GetCurrentTabTitle(const Browser* browser, string16* title) { | 149 bool GetCurrentTabTitle(const Browser* browser, string16* title) { |
| 182 WebContents* web_contents = chrome::GetActiveWebContents(browser); | 150 WebContents* web_contents = chrome::GetActiveWebContents(browser); |
| 183 if (!web_contents) | 151 if (!web_contents) |
| 184 return false; | 152 return false; |
| 185 NavigationEntry* last_entry = web_contents->GetController().GetActiveEntry(); | 153 NavigationEntry* last_entry = web_contents->GetController().GetActiveEntry(); |
| 186 if (!last_entry) | 154 if (!last_entry) |
| 187 return false; | 155 return false; |
| 188 title->assign(last_entry->GetTitleForDisplay("")); | 156 title->assign(last_entry->GetTitleForDisplay("")); |
| 189 return true; | 157 return true; |
| 190 } | 158 } |
| (...skipping 501 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 692 int state, | 660 int state, |
| 693 const base::Closure& followup) { | 661 const base::Closure& followup) { |
| 694 if (!followup.is_null()) | 662 if (!followup.is_null()) |
| 695 ui_controls::SendMouseEventsNotifyWhenDone(button, state, followup); | 663 ui_controls::SendMouseEventsNotifyWhenDone(button, state, followup); |
| 696 else | 664 else |
| 697 ui_controls::SendMouseEvents(button, state); | 665 ui_controls::SendMouseEvents(button, state); |
| 698 } | 666 } |
| 699 | 667 |
| 700 } // namespace internal | 668 } // namespace internal |
| 701 } // namespace ui_test_utils | 669 } // namespace ui_test_utils |
| OLD | NEW |