Chromium Code Reviews| 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 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 107 ui_test_utils::RunMessageLoop(); | 107 ui_test_utils::RunMessageLoop(); |
| 108 } | 108 } |
| 109 | 109 |
| 110 virtual void Observe(int type, | 110 virtual void Observe(int type, |
| 111 const content::NotificationSource& source, | 111 const content::NotificationSource& source, |
| 112 const content::NotificationDetails& details) OVERRIDE { | 112 const content::NotificationDetails& details) OVERRIDE { |
| 113 DCHECK(type == content::NOTIFICATION_DOM_OPERATION_RESPONSE); | 113 DCHECK(type == content::NOTIFICATION_DOM_OPERATION_RESPONSE); |
| 114 content::Details<DomOperationNotificationDetails> dom_op_details(details); | 114 content::Details<DomOperationNotificationDetails> dom_op_details(details); |
| 115 response_ = dom_op_details->json; | 115 response_ = dom_op_details->json; |
| 116 did_respond_ = true; | 116 did_respond_ = true; |
| 117 MessageLoopForUI::current()->Quit(); | 117 MessageLoopForUI::current()->QuitNow(); |
| 118 } | 118 } |
| 119 | 119 |
| 120 // Overridden from content::WebContentsObserver: | 120 // Overridden from content::WebContentsObserver: |
| 121 virtual void RenderViewGone(base::TerminationStatus status) OVERRIDE { | 121 virtual void RenderViewGone(base::TerminationStatus status) OVERRIDE { |
| 122 MessageLoopForUI::current()->Quit(); | 122 MessageLoopForUI::current()->QuitNow(); |
| 123 } | 123 } |
| 124 | 124 |
| 125 bool GetResponse(std::string* response) WARN_UNUSED_RESULT { | 125 bool GetResponse(std::string* response) WARN_UNUSED_RESULT { |
| 126 *response = response_; | 126 *response = response_; |
| 127 return did_respond_; | 127 return did_respond_; |
| 128 } | 128 } |
| 129 | 129 |
| 130 private: | 130 private: |
| 131 content::NotificationRegistrar registrar_; | 131 content::NotificationRegistrar registrar_; |
| 132 std::string response_; | 132 std::string response_; |
| (...skipping 23 matching lines...) Expand all Loading... | |
| 156 const content::NotificationDetails& details) { | 156 const content::NotificationDetails& details) { |
| 157 if (type == chrome::NOTIFICATION_FIND_RESULT_AVAILABLE) { | 157 if (type == chrome::NOTIFICATION_FIND_RESULT_AVAILABLE) { |
| 158 content::Details<FindNotificationDetails> find_details(details); | 158 content::Details<FindNotificationDetails> find_details(details); |
| 159 if (find_details->request_id() == current_find_request_id_) { | 159 if (find_details->request_id() == current_find_request_id_) { |
| 160 // We get multiple responses and one of those will contain the ordinal. | 160 // We get multiple responses and one of those will contain the ordinal. |
| 161 // This message comes to us before the final update is sent. | 161 // This message comes to us before the final update is sent. |
| 162 if (find_details->active_match_ordinal() > -1) | 162 if (find_details->active_match_ordinal() > -1) |
| 163 active_match_ordinal_ = find_details->active_match_ordinal(); | 163 active_match_ordinal_ = find_details->active_match_ordinal(); |
| 164 if (find_details->final_update()) { | 164 if (find_details->final_update()) { |
| 165 number_of_matches_ = find_details->number_of_matches(); | 165 number_of_matches_ = find_details->number_of_matches(); |
| 166 MessageLoopForUI::current()->Quit(); | 166 MessageLoopForUI::current()->QuitNow(); |
| 167 } else { | 167 } else { |
| 168 DVLOG(1) << "Ignoring, since we only care about the final message"; | 168 DVLOG(1) << "Ignoring, since we only care about the final message"; |
| 169 } | 169 } |
| 170 } | 170 } |
| 171 } else { | 171 } else { |
| 172 NOTREACHED(); | 172 NOTREACHED(); |
| 173 } | 173 } |
| 174 } | 174 } |
| 175 | 175 |
| 176 private: | 176 private: |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 258 return false; | 258 return false; |
| 259 } | 259 } |
| 260 | 260 |
| 261 return true; | 261 return true; |
| 262 } | 262 } |
| 263 | 263 |
| 264 void RunAllPendingMessageAndSendQuit(content::BrowserThread::ID thread_id) { | 264 void RunAllPendingMessageAndSendQuit(content::BrowserThread::ID thread_id) { |
| 265 MessageLoop::current()->PostTask(FROM_HERE, MessageLoop::QuitClosure()); | 265 MessageLoop::current()->PostTask(FROM_HERE, MessageLoop::QuitClosure()); |
| 266 RunMessageLoop(); | 266 RunMessageLoop(); |
| 267 content::BrowserThread::PostTask(thread_id, FROM_HERE, | 267 content::BrowserThread::PostTask(thread_id, FROM_HERE, |
| 268 MessageLoop::QuitClosure()); | 268 MessageLoop::QuitNowClosure()); |
| 269 } | 269 } |
| 270 | 270 |
| 271 } // namespace | 271 } // namespace |
| 272 | 272 |
| 273 void RunMessageLoop() { | 273 void RunMessageLoop() { |
| 274 MessageLoop* loop = MessageLoop::current(); | 274 MessageLoop* loop = MessageLoop::current(); |
| 275 MessageLoopForUI* ui_loop = | 275 MessageLoopForUI* ui_loop = |
| 276 content::BrowserThread::CurrentlyOn(content::BrowserThread::UI) ? | 276 content::BrowserThread::CurrentlyOn(content::BrowserThread::UI) ? |
| 277 MessageLoopForUI::current() : NULL; | 277 MessageLoopForUI::current() : NULL; |
| 278 MessageLoop::ScopedNestableTaskAllower allow(loop); | 278 MessageLoop::ScopedNestableTaskAllower allow(loop); |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 324 return true; | 324 return true; |
| 325 } | 325 } |
| 326 | 326 |
| 327 void WaitForNavigations(NavigationController* controller, | 327 void WaitForNavigations(NavigationController* controller, |
| 328 int number_of_navigations) { | 328 int number_of_navigations) { |
| 329 TestNavigationObserver observer( | 329 TestNavigationObserver observer( |
| 330 content::Source<NavigationController>(controller), NULL, | 330 content::Source<NavigationController>(controller), NULL, |
| 331 number_of_navigations); | 331 number_of_navigations); |
| 332 observer.WaitForObservation( | 332 observer.WaitForObservation( |
| 333 base::Bind(&ui_test_utils::RunMessageLoop), | 333 base::Bind(&ui_test_utils::RunMessageLoop), |
| 334 base::Bind(&MessageLoop::Quit, | 334 base::Bind(&MessageLoop::QuitNow, |
|
Paweł Hajdan Jr.
2012/06/05 11:57:44
nit: Would QuitNowClosure be slightly prettier her
jbates
2012/06/07 00:24:02
Done.
| |
| 335 base::Unretained(MessageLoopForUI::current()))); | 335 base::Unretained(MessageLoopForUI::current()))); |
| 336 } | 336 } |
| 337 | 337 |
| 338 void WaitForNewTab(Browser* browser) { | 338 void WaitForNewTab(Browser* browser) { |
| 339 WindowedNotificationObserver observer( | 339 WindowedNotificationObserver observer( |
| 340 chrome::NOTIFICATION_TAB_ADDED, | 340 chrome::NOTIFICATION_TAB_ADDED, |
| 341 content::Source<content::WebContentsDelegate>(browser)); | 341 content::Source<content::WebContentsDelegate>(browser)); |
| 342 observer.Wait(); | 342 observer.Wait(); |
| 343 } | 343 } |
| 344 | 344 |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 384 profile->GetOffTheRecordProfile(), false); | 384 profile->GetOffTheRecordProfile(), false); |
| 385 WaitForNavigations(&browser->GetSelectedWebContents()->GetController(), 1); | 385 WaitForNavigations(&browser->GetSelectedWebContents()->GetController(), 1); |
| 386 } | 386 } |
| 387 | 387 |
| 388 void NavigateToURL(browser::NavigateParams* params) { | 388 void NavigateToURL(browser::NavigateParams* params) { |
| 389 TestNavigationObserver observer( | 389 TestNavigationObserver observer( |
| 390 content::NotificationService::AllSources(), NULL, 1); | 390 content::NotificationService::AllSources(), NULL, 1); |
| 391 browser::Navigate(params); | 391 browser::Navigate(params); |
| 392 observer.WaitForObservation( | 392 observer.WaitForObservation( |
| 393 base::Bind(&ui_test_utils::RunMessageLoop), | 393 base::Bind(&ui_test_utils::RunMessageLoop), |
| 394 base::Bind(&MessageLoop::Quit, | 394 base::Bind(&MessageLoop::QuitNow, |
|
Paweł Hajdan Jr.
2012/06/05 11:57:44
nit: Would QuitNowClosure be slightly prettier her
jbates
2012/06/07 00:24:02
Done.
| |
| 395 base::Unretained(MessageLoopForUI::current()))); | 395 base::Unretained(MessageLoopForUI::current()))); |
| 396 | 396 |
| 397 } | 397 } |
| 398 | 398 |
| 399 void NavigateToURL(Browser* browser, const GURL& url) { | 399 void NavigateToURL(Browser* browser, const GURL& url) { |
| 400 NavigateToURLWithDisposition(browser, url, CURRENT_TAB, | 400 NavigateToURLWithDisposition(browser, url, CURRENT_TAB, |
| 401 BROWSER_TEST_WAIT_FOR_NAVIGATION); | 401 BROWSER_TEST_WAIT_FOR_NAVIGATION); |
| 402 } | 402 } |
| 403 | 403 |
| 404 // Navigates the specified tab (via |disposition|) of |browser| to |url|, | 404 // Navigates the specified tab (via |disposition|) of |browser| to |url|, |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 458 return; | 458 return; |
| 459 } else if ((disposition == CURRENT_TAB) || | 459 } else if ((disposition == CURRENT_TAB) || |
| 460 (disposition == NEW_FOREGROUND_TAB) || | 460 (disposition == NEW_FOREGROUND_TAB) || |
| 461 (disposition == SINGLETON_TAB)) { | 461 (disposition == SINGLETON_TAB)) { |
| 462 // The currently selected tab is the right one. | 462 // The currently selected tab is the right one. |
| 463 web_contents = browser->GetSelectedWebContents(); | 463 web_contents = browser->GetSelectedWebContents(); |
| 464 } | 464 } |
| 465 if (disposition == CURRENT_TAB) { | 465 if (disposition == CURRENT_TAB) { |
| 466 same_tab_observer.WaitForObservation( | 466 same_tab_observer.WaitForObservation( |
| 467 base::Bind(&ui_test_utils::RunMessageLoop), | 467 base::Bind(&ui_test_utils::RunMessageLoop), |
| 468 base::Bind(&MessageLoop::Quit, | 468 base::Bind(&MessageLoop::QuitNow, |
|
Paweł Hajdan Jr.
2012/06/05 11:57:44
nit: Would QuitNowClosure be slightly prettier her
jbates
2012/06/07 00:24:02
Done.
| |
| 469 base::Unretained(MessageLoopForUI::current()))); | 469 base::Unretained(MessageLoopForUI::current()))); |
| 470 return; | 470 return; |
| 471 } else if (web_contents) { | 471 } else if (web_contents) { |
| 472 NavigationController* controller = &web_contents->GetController(); | 472 NavigationController* controller = &web_contents->GetController(); |
| 473 WaitForNavigations(controller, number_of_navigations); | 473 WaitForNavigations(controller, number_of_navigations); |
| 474 return; | 474 return; |
| 475 } | 475 } |
| 476 EXPECT_TRUE(NULL != web_contents) << " Unable to wait for navigation to \"" | 476 EXPECT_TRUE(NULL != web_contents) << " Unable to wait for navigation to \"" |
| 477 << url.spec() << "\"" | 477 << url.spec() << "\"" |
| 478 << " because we can't get the tab contents"; | 478 << " because we can't get the tab contents"; |
| (...skipping 287 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 766 bool control, | 766 bool control, |
| 767 bool shift, | 767 bool shift, |
| 768 bool alt, | 768 bool alt, |
| 769 bool command) { | 769 bool command) { |
| 770 gfx::NativeWindow window = NULL; | 770 gfx::NativeWindow window = NULL; |
| 771 if (!GetNativeWindow(browser, &window)) | 771 if (!GetNativeWindow(browser, &window)) |
| 772 return false; | 772 return false; |
| 773 | 773 |
| 774 bool result; | 774 bool result; |
| 775 result = ui_controls::SendKeyPressNotifyWhenDone( | 775 result = ui_controls::SendKeyPressNotifyWhenDone( |
| 776 window, key, control, shift, alt, command, MessageLoop::QuitClosure()); | 776 window, key, control, shift, alt, command, MessageLoop::QuitNowClosure()); |
| 777 #if defined(OS_WIN) | 777 #if defined(OS_WIN) |
| 778 if (!result && BringBrowserWindowToFront(browser)) { | 778 if (!result && BringBrowserWindowToFront(browser)) { |
| 779 result = ui_controls::SendKeyPressNotifyWhenDone( | 779 result = ui_controls::SendKeyPressNotifyWhenDone( |
| 780 window, key, control, shift, alt, command, MessageLoop::QuitClosure()); | 780 window, key, control, shift, alt, command, |
| 781 MessageLoop::QuitNowClosure()); | |
| 781 } | 782 } |
| 782 #endif | 783 #endif |
| 783 if (!result) { | 784 if (!result) { |
| 784 LOG(ERROR) << "ui_controls::SendKeyPressNotifyWhenDone failed"; | 785 LOG(ERROR) << "ui_controls::SendKeyPressNotifyWhenDone failed"; |
| 785 return false; | 786 return false; |
| 786 } | 787 } |
| 787 | 788 |
| 788 // Run the message loop. It'll stop running when either the key was received | 789 // Run the message loop. It'll stop running when either the key was received |
| 789 // or the test timed out (in which case testing::Test::HasFatalFailure should | 790 // or the test timed out (in which case testing::Test::HasFatalFailure should |
| 790 // be set). | 791 // be set). |
| (...skipping 13 matching lines...) Expand all Loading... | |
| 804 | 805 |
| 805 if (!SendKeyPressSync(browser, key, control, shift, alt, command)) | 806 if (!SendKeyPressSync(browser, key, control, shift, alt, command)) |
| 806 return false; | 807 return false; |
| 807 | 808 |
| 808 observer.Wait(); | 809 observer.Wait(); |
| 809 return !testing::Test::HasFatalFailure(); | 810 return !testing::Test::HasFatalFailure(); |
| 810 } | 811 } |
| 811 | 812 |
| 812 bool SendMouseMoveSync(const gfx::Point& location) { | 813 bool SendMouseMoveSync(const gfx::Point& location) { |
| 813 if (!ui_controls::SendMouseMoveNotifyWhenDone(location.x(), location.y(), | 814 if (!ui_controls::SendMouseMoveNotifyWhenDone(location.x(), location.y(), |
| 814 MessageLoop::QuitClosure())) { | 815 MessageLoop::QuitNowClosure())) { |
| 815 return false; | 816 return false; |
| 816 } | 817 } |
| 817 RunMessageLoop(); | 818 RunMessageLoop(); |
| 818 return !testing::Test::HasFatalFailure(); | 819 return !testing::Test::HasFatalFailure(); |
| 819 } | 820 } |
| 820 | 821 |
| 821 bool SendMouseEventsSync(ui_controls::MouseButton type, int state) { | 822 bool SendMouseEventsSync(ui_controls::MouseButton type, int state) { |
| 822 if (!ui_controls::SendMouseEventsNotifyWhenDone( | 823 if (!ui_controls::SendMouseEventsNotifyWhenDone( |
| 823 type, state, MessageLoop::QuitClosure())) { | 824 type, state, MessageLoop::QuitNowClosure())) { |
| 824 return false; | 825 return false; |
| 825 } | 826 } |
| 826 RunMessageLoop(); | 827 RunMessageLoop(); |
| 827 return !testing::Test::HasFatalFailure(); | 828 return !testing::Test::HasFatalFailure(); |
| 828 } | 829 } |
| 829 | 830 |
| 830 TimedMessageLoopRunner::TimedMessageLoopRunner() | 831 TimedMessageLoopRunner::TimedMessageLoopRunner() |
| 831 : loop_(new MessageLoopForUI()), | 832 : loop_(new MessageLoopForUI()), |
| 832 owned_(true), | 833 owned_(true), |
| 833 quit_loop_invoked_(false) { | 834 quit_loop_invoked_(false) { |
| 834 } | 835 } |
| 835 | 836 |
| 836 TimedMessageLoopRunner::~TimedMessageLoopRunner() { | 837 TimedMessageLoopRunner::~TimedMessageLoopRunner() { |
| 837 if (owned_) | 838 if (owned_) |
| 838 delete loop_; | 839 delete loop_; |
| 839 } | 840 } |
| 840 | 841 |
| 841 void TimedMessageLoopRunner::RunFor(int ms) { | 842 void TimedMessageLoopRunner::RunFor(int ms) { |
| 842 QuitAfter(ms); | 843 QuitAfter(ms); |
| 843 quit_loop_invoked_ = false; | 844 quit_loop_invoked_ = false; |
| 844 loop_->Run(); | 845 loop_->Run(); |
| 845 } | 846 } |
| 846 | 847 |
| 847 void TimedMessageLoopRunner::Quit() { | 848 void TimedMessageLoopRunner::Quit() { |
| 848 quit_loop_invoked_ = true; | 849 quit_loop_invoked_ = true; |
| 849 loop_->PostTask(FROM_HERE, MessageLoop::QuitClosure()); | 850 loop_->PostTask(FROM_HERE, MessageLoop::QuitNowClosure()); |
| 850 } | 851 } |
| 851 | 852 |
| 852 void TimedMessageLoopRunner::QuitAfter(int ms) { | 853 void TimedMessageLoopRunner::QuitAfter(int ms) { |
| 853 quit_loop_invoked_ = true; | 854 quit_loop_invoked_ = true; |
| 854 loop_->PostDelayedTask( | 855 loop_->PostDelayedTask( |
| 855 FROM_HERE, | 856 FROM_HERE, |
| 856 MessageLoop::QuitClosure(), | 857 MessageLoop::QuitNowClosure(), |
| 857 base::TimeDelta::FromMilliseconds(ms)); | 858 base::TimeDelta::FromMilliseconds(ms)); |
| 858 } | 859 } |
| 859 | 860 |
| 860 TestWebSocketServer::TestWebSocketServer() | 861 TestWebSocketServer::TestWebSocketServer() |
| 861 : started_(false), | 862 : started_(false), |
| 862 port_(kDefaultWsPort), | 863 port_(kDefaultWsPort), |
| 863 secure_(false) { | 864 secure_(false) { |
| 864 #if defined(OS_POSIX) | 865 #if defined(OS_POSIX) |
| 865 process_group_id_ = base::kNullProcessHandle; | 866 process_group_id_ = base::kNullProcessHandle; |
| 866 #endif | 867 #endif |
| (...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1024 void WindowedNotificationObserver::Observe( | 1025 void WindowedNotificationObserver::Observe( |
| 1025 int type, | 1026 int type, |
| 1026 const content::NotificationSource& source, | 1027 const content::NotificationSource& source, |
| 1027 const content::NotificationDetails& details) { | 1028 const content::NotificationDetails& details) { |
| 1028 source_ = source; | 1029 source_ = source; |
| 1029 details_ = details; | 1030 details_ = details; |
| 1030 seen_ = true; | 1031 seen_ = true; |
| 1031 if (!running_) | 1032 if (!running_) |
| 1032 return; | 1033 return; |
| 1033 | 1034 |
| 1034 MessageLoopForUI::current()->Quit(); | 1035 MessageLoopForUI::current()->QuitNow(); |
| 1035 running_ = false; | 1036 running_ = false; |
| 1036 } | 1037 } |
| 1037 | 1038 |
| 1038 WindowedTabAddedNotificationObserver::WindowedTabAddedNotificationObserver( | 1039 WindowedTabAddedNotificationObserver::WindowedTabAddedNotificationObserver( |
| 1039 const content::NotificationSource& source) | 1040 const content::NotificationSource& source) |
| 1040 : WindowedNotificationObserver(chrome::NOTIFICATION_TAB_ADDED, source), | 1041 : WindowedNotificationObserver(chrome::NOTIFICATION_TAB_ADDED, source), |
| 1041 added_tab_(NULL) { | 1042 added_tab_(NULL) { |
| 1042 } | 1043 } |
| 1043 | 1044 |
| 1044 void WindowedTabAddedNotificationObserver::Observe( | 1045 void WindowedTabAddedNotificationObserver::Observe( |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1102 | 1103 |
| 1103 std::vector<string16>::const_iterator it = | 1104 std::vector<string16>::const_iterator it = |
| 1104 std::find(expected_titles_.begin(), | 1105 std::find(expected_titles_.begin(), |
| 1105 expected_titles_.end(), | 1106 expected_titles_.end(), |
| 1106 web_contents_->GetTitle()); | 1107 web_contents_->GetTitle()); |
| 1107 if (it == expected_titles_.end()) | 1108 if (it == expected_titles_.end()) |
| 1108 return; | 1109 return; |
| 1109 observed_title_ = *it; | 1110 observed_title_ = *it; |
| 1110 expected_title_observed_ = true; | 1111 expected_title_observed_ = true; |
| 1111 if (quit_loop_on_observation_) | 1112 if (quit_loop_on_observation_) |
| 1112 MessageLoopForUI::current()->Quit(); | 1113 MessageLoopForUI::current()->QuitNow(); |
| 1113 } | 1114 } |
| 1114 | 1115 |
| 1115 BrowserAddedObserver::BrowserAddedObserver() | 1116 BrowserAddedObserver::BrowserAddedObserver() |
| 1116 : notification_observer_( | 1117 : notification_observer_( |
| 1117 chrome::NOTIFICATION_BROWSER_OPENED, | 1118 chrome::NOTIFICATION_BROWSER_OPENED, |
| 1118 content::NotificationService::AllSources()) { | 1119 content::NotificationService::AllSources()) { |
| 1119 original_browsers_.insert(BrowserList::begin(), BrowserList::end()); | 1120 original_browsers_.insert(BrowserList::begin(), BrowserList::end()); |
| 1120 } | 1121 } |
| 1121 | 1122 |
| 1122 BrowserAddedObserver::~BrowserAddedObserver() { | 1123 BrowserAddedObserver::~BrowserAddedObserver() { |
| (...skipping 14 matching lines...) Expand all Loading... | |
| 1137 DOMMessageQueue::~DOMMessageQueue() {} | 1138 DOMMessageQueue::~DOMMessageQueue() {} |
| 1138 | 1139 |
| 1139 void DOMMessageQueue::Observe(int type, | 1140 void DOMMessageQueue::Observe(int type, |
| 1140 const content::NotificationSource& source, | 1141 const content::NotificationSource& source, |
| 1141 const content::NotificationDetails& details) { | 1142 const content::NotificationDetails& details) { |
| 1142 content::Details<DomOperationNotificationDetails> dom_op_details(details); | 1143 content::Details<DomOperationNotificationDetails> dom_op_details(details); |
| 1143 content::Source<RenderViewHost> sender(source); | 1144 content::Source<RenderViewHost> sender(source); |
| 1144 message_queue_.push(dom_op_details->json); | 1145 message_queue_.push(dom_op_details->json); |
| 1145 if (waiting_for_message_) { | 1146 if (waiting_for_message_) { |
| 1146 waiting_for_message_ = false; | 1147 waiting_for_message_ = false; |
| 1147 MessageLoopForUI::current()->Quit(); | 1148 MessageLoopForUI::current()->QuitNow(); |
| 1148 } | 1149 } |
| 1149 } | 1150 } |
| 1150 | 1151 |
| 1151 void DOMMessageQueue::ClearQueue() { | 1152 void DOMMessageQueue::ClearQueue() { |
| 1152 message_queue_ = std::queue<std::string>(); | 1153 message_queue_ = std::queue<std::string>(); |
| 1153 } | 1154 } |
| 1154 | 1155 |
| 1155 bool DOMMessageQueue::WaitForMessage(std::string* message) { | 1156 bool DOMMessageQueue::WaitForMessage(std::string* message) { |
| 1156 if (message_queue_.empty()) { | 1157 if (message_queue_.empty()) { |
| 1157 waiting_for_message_ = true; | 1158 waiting_for_message_ = true; |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1212 // Take the snapshot. | 1213 // Take the snapshot. |
| 1213 gfx::Size page_size(width, height); | 1214 gfx::Size page_size(width, height); |
| 1214 return TakeRenderWidgetSnapshot(rvh, page_size, page_size, bitmap); | 1215 return TakeRenderWidgetSnapshot(rvh, page_size, page_size, bitmap); |
| 1215 } | 1216 } |
| 1216 | 1217 |
| 1217 private: | 1218 private: |
| 1218 // Called when the ThumbnailGenerator has taken the snapshot. | 1219 // Called when the ThumbnailGenerator has taken the snapshot. |
| 1219 void OnSnapshotTaken(const SkBitmap& bitmap) { | 1220 void OnSnapshotTaken(const SkBitmap& bitmap) { |
| 1220 *bitmap_ = bitmap; | 1221 *bitmap_ = bitmap; |
| 1221 snapshot_taken_ = true; | 1222 snapshot_taken_ = true; |
| 1222 MessageLoop::current()->Quit(); | 1223 MessageLoop::current()->QuitNow(); |
| 1223 } | 1224 } |
| 1224 | 1225 |
| 1225 SkBitmap* bitmap_; | 1226 SkBitmap* bitmap_; |
| 1226 // Whether the snapshot was actually taken and received by this SnapshotTaker. | 1227 // Whether the snapshot was actually taken and received by this SnapshotTaker. |
| 1227 // This will be false if the test times out. | 1228 // This will be false if the test times out. |
| 1228 bool snapshot_taken_; | 1229 bool snapshot_taken_; |
| 1229 | 1230 |
| 1230 DISALLOW_COPY_AND_ASSIGN(SnapshotTaker); | 1231 DISALLOW_COPY_AND_ASSIGN(SnapshotTaker); |
| 1231 }; | 1232 }; |
| 1232 | 1233 |
| (...skipping 12 matching lines...) Expand all Loading... | |
| 1245 } | 1246 } |
| 1246 | 1247 |
| 1247 void OverrideGeolocation(double latitude, double longitude) { | 1248 void OverrideGeolocation(double latitude, double longitude) { |
| 1248 content::Geoposition position; | 1249 content::Geoposition position; |
| 1249 position.latitude = latitude; | 1250 position.latitude = latitude; |
| 1250 position.longitude = longitude; | 1251 position.longitude = longitude; |
| 1251 position.altitude = 0.; | 1252 position.altitude = 0.; |
| 1252 position.accuracy = 0.; | 1253 position.accuracy = 0.; |
| 1253 position.timestamp = base::Time::Now(); | 1254 position.timestamp = base::Time::Now(); |
| 1254 content::OverrideLocationForTesting(position, | 1255 content::OverrideLocationForTesting(position, |
| 1255 base::Bind(MessageLoop::QuitClosure())); | 1256 MessageLoop::QuitNowClosure()); |
| 1256 RunMessageLoop(); | 1257 RunMessageLoop(); |
| 1257 } | 1258 } |
| 1258 | 1259 |
| 1259 namespace internal { | 1260 namespace internal { |
| 1260 | 1261 |
| 1261 void ClickTask(ui_controls::MouseButton button, | 1262 void ClickTask(ui_controls::MouseButton button, |
| 1262 int state, | 1263 int state, |
| 1263 const base::Closure& followup) { | 1264 const base::Closure& followup) { |
| 1264 if (!followup.is_null()) | 1265 if (!followup.is_null()) |
| 1265 ui_controls::SendMouseEventsNotifyWhenDone(button, state, followup); | 1266 ui_controls::SendMouseEventsNotifyWhenDone(button, state, followup); |
| 1266 else | 1267 else |
| 1267 ui_controls::SendMouseEvents(button, state); | 1268 ui_controls::SendMouseEvents(button, state); |
| 1268 } | 1269 } |
| 1269 | 1270 |
| 1270 } // namespace internal | 1271 } // namespace internal |
| 1271 } // namespace ui_test_utils | 1272 } // namespace ui_test_utils |
| OLD | NEW |