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 #include <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include <memory> | 9 #include <memory> |
10 | 10 |
(...skipping 299 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
310 | 310 |
311 app_modal::AppModalDialog* WaitForAppModalDialog() { | 311 app_modal::AppModalDialog* WaitForAppModalDialog() { |
312 app_modal::AppModalDialogQueue* dialog_queue = | 312 app_modal::AppModalDialogQueue* dialog_queue = |
313 app_modal::AppModalDialogQueue::GetInstance(); | 313 app_modal::AppModalDialogQueue::GetInstance(); |
314 if (dialog_queue->HasActiveDialog()) | 314 if (dialog_queue->HasActiveDialog()) |
315 return dialog_queue->active_dialog(); | 315 return dialog_queue->active_dialog(); |
316 AppModalDialogWaiter waiter; | 316 AppModalDialogWaiter waiter; |
317 return waiter.Wait(); | 317 return waiter.Wait(); |
318 } | 318 } |
319 | 319 |
320 void WaitForAutocompleteController( | |
321 const AutocompleteController& autocomplete_controller) { | |
322 while (!autocomplete_controller.done()) { | |
323 content::WindowedNotificationObserver ready_observer( | |
Paweł Hajdan Jr.
2016/09/06 14:22:10
Shouldn't the observer be instantiated before any
| |
324 chrome::NOTIFICATION_AUTOCOMPLETE_CONTROLLER_RESULT_READY, | |
325 content::Source<AutocompleteController>(&autocomplete_controller)); | |
326 ready_observer.Wait(); | |
327 } | |
328 } | |
329 | |
320 int FindInPage(WebContents* tab, | 330 int FindInPage(WebContents* tab, |
321 const base::string16& search_string, | 331 const base::string16& search_string, |
322 bool forward, | 332 bool forward, |
323 bool match_case, | 333 bool match_case, |
324 int* ordinal, | 334 int* ordinal, |
325 gfx::Rect* selection_rect) { | 335 gfx::Rect* selection_rect) { |
326 FindTabHelper* find_tab_helper = FindTabHelper::FromWebContents(tab); | 336 FindTabHelper* find_tab_helper = FindTabHelper::FromWebContents(tab); |
327 find_tab_helper->StartFinding(search_string, forward, match_case); | 337 find_tab_helper->StartFinding(search_string, forward, match_case); |
328 FindInPageNotificationObserver observer(tab); | 338 FindInPageNotificationObserver observer(tab); |
329 observer.Wait(); | 339 observer.Wait(); |
(...skipping 20 matching lines...) Expand all Loading... | |
350 ui_test_utils::NavigateToURL(browser, download_url); | 360 ui_test_utils::NavigateToURL(browser, download_url); |
351 observer->WaitForFinished(); | 361 observer->WaitForFinished(); |
352 } | 362 } |
353 | 363 |
354 void SendToOmniboxAndSubmit(LocationBar* location_bar, | 364 void SendToOmniboxAndSubmit(LocationBar* location_bar, |
355 const std::string& input) { | 365 const std::string& input) { |
356 OmniboxView* omnibox = location_bar->GetOmniboxView(); | 366 OmniboxView* omnibox = location_bar->GetOmniboxView(); |
357 omnibox->model()->OnSetFocus(false); | 367 omnibox->model()->OnSetFocus(false); |
358 omnibox->SetUserText(base::ASCIIToUTF16(input)); | 368 omnibox->SetUserText(base::ASCIIToUTF16(input)); |
359 location_bar->AcceptInput(); | 369 location_bar->AcceptInput(); |
360 while (!omnibox->model()->autocomplete_controller()->done()) { | 370 WaitForAutocompleteController(*omnibox->model()->autocomplete_controller()); |
361 content::WindowedNotificationObserver observer( | |
362 chrome::NOTIFICATION_AUTOCOMPLETE_CONTROLLER_RESULT_READY, | |
363 content::NotificationService::AllSources()); | |
364 observer.Wait(); | |
365 } | |
366 } | 371 } |
367 | 372 |
368 Browser* GetBrowserNotInSet(const std::set<Browser*>& excluded_browsers) { | 373 Browser* GetBrowserNotInSet(const std::set<Browser*>& excluded_browsers) { |
369 for (auto* browser : *BrowserList::GetInstance()) { | 374 for (auto* browser : *BrowserList::GetInstance()) { |
370 if (excluded_browsers.find(browser) == excluded_browsers.end()) | 375 if (excluded_browsers.find(browser) == excluded_browsers.end()) |
371 return browser; | 376 return browser; |
372 } | 377 } |
373 return nullptr; | 378 return nullptr; |
374 } | 379 } |
375 | 380 |
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
536 new content::MessageLoopRunner; | 541 new content::MessageLoopRunner; |
537 WaitHistoryLoadedObserver observer(runner.get()); | 542 WaitHistoryLoadedObserver observer(runner.get()); |
538 ScopedObserver<history::HistoryService, history::HistoryServiceObserver> | 543 ScopedObserver<history::HistoryService, history::HistoryServiceObserver> |
539 scoped_observer(&observer); | 544 scoped_observer(&observer); |
540 scoped_observer.Add(history_service); | 545 scoped_observer.Add(history_service); |
541 runner->Run(); | 546 runner->Run(); |
542 } | 547 } |
543 } | 548 } |
544 | 549 |
545 } // namespace ui_test_utils | 550 } // namespace ui_test_utils |
OLD | NEW |