| 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 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 42 #include "chrome/browser/ui/host_desktop.h" | 42 #include "chrome/browser/ui/host_desktop.h" |
| 43 #include "chrome/browser/ui/location_bar/location_bar.h" | 43 #include "chrome/browser/ui/location_bar/location_bar.h" |
| 44 #include "chrome/browser/ui/omnibox/omnibox_view.h" | 44 #include "chrome/browser/ui/omnibox/omnibox_view.h" |
| 45 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 45 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
| 46 #include "chrome/common/chrome_paths.h" | 46 #include "chrome/common/chrome_paths.h" |
| 47 #include "chrome/common/pref_names.h" | 47 #include "chrome/common/pref_names.h" |
| 48 #include "chrome/test/base/find_in_page_observer.h" | 48 #include "chrome/test/base/find_in_page_observer.h" |
| 49 #include "components/app_modal_dialogs/app_modal_dialog.h" | 49 #include "components/app_modal_dialogs/app_modal_dialog.h" |
| 50 #include "components/app_modal_dialogs/app_modal_dialog_queue.h" | 50 #include "components/app_modal_dialogs/app_modal_dialog_queue.h" |
| 51 #include "components/bookmarks/browser/bookmark_model.h" | 51 #include "components/bookmarks/browser/bookmark_model.h" |
| 52 #include "components/history/core/browser/history_service_observer.h" |
| 52 #include "components/search_engines/template_url_service.h" | 53 #include "components/search_engines/template_url_service.h" |
| 53 #include "content/public/browser/dom_operation_notification_details.h" | 54 #include "content/public/browser/dom_operation_notification_details.h" |
| 54 #include "content/public/browser/download_item.h" | 55 #include "content/public/browser/download_item.h" |
| 55 #include "content/public/browser/download_manager.h" | 56 #include "content/public/browser/download_manager.h" |
| 56 #include "content/public/browser/geolocation_provider.h" | 57 #include "content/public/browser/geolocation_provider.h" |
| 57 #include "content/public/browser/navigation_controller.h" | 58 #include "content/public/browser/navigation_controller.h" |
| 58 #include "content/public/browser/navigation_entry.h" | 59 #include "content/public/browser/navigation_entry.h" |
| 59 #include "content/public/browser/notification_service.h" | 60 #include "content/public/browser/notification_service.h" |
| 60 #include "content/public/browser/render_process_host.h" | 61 #include "content/public/browser/render_process_host.h" |
| 61 #include "content/public/browser/render_view_host.h" | 62 #include "content/public/browser/render_view_host.h" |
| (...skipping 294 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 356 new content::MessageLoopRunner; | 357 new content::MessageLoopRunner; |
| 357 scoped_ptr<TemplateURLService::Subscription> subscription = | 358 scoped_ptr<TemplateURLService::Subscription> subscription = |
| 358 service->RegisterOnLoadedCallback( | 359 service->RegisterOnLoadedCallback( |
| 359 message_loop_runner->QuitClosure()); | 360 message_loop_runner->QuitClosure()); |
| 360 service->Load(); | 361 service->Load(); |
| 361 message_loop_runner->Run(); | 362 message_loop_runner->Run(); |
| 362 | 363 |
| 363 ASSERT_TRUE(service->loaded()); | 364 ASSERT_TRUE(service->loaded()); |
| 364 } | 365 } |
| 365 | 366 |
| 366 void WaitForHistoryToLoad(HistoryService* history_service) { | |
| 367 content::WindowedNotificationObserver history_loaded_observer( | |
| 368 chrome::NOTIFICATION_HISTORY_LOADED, | |
| 369 content::NotificationService::AllSources()); | |
| 370 if (!history_service->BackendLoaded()) | |
| 371 history_loaded_observer.Wait(); | |
| 372 } | |
| 373 | |
| 374 void DownloadURL(Browser* browser, const GURL& download_url) { | 367 void DownloadURL(Browser* browser, const GURL& download_url) { |
| 375 base::ScopedTempDir downloads_directory; | 368 base::ScopedTempDir downloads_directory; |
| 376 ASSERT_TRUE(downloads_directory.CreateUniqueTempDir()); | 369 ASSERT_TRUE(downloads_directory.CreateUniqueTempDir()); |
| 377 browser->profile()->GetPrefs()->SetFilePath( | 370 browser->profile()->GetPrefs()->SetFilePath( |
| 378 prefs::kDownloadDefaultDirectory, downloads_directory.path()); | 371 prefs::kDownloadDefaultDirectory, downloads_directory.path()); |
| 379 | 372 |
| 380 content::DownloadManager* download_manager = | 373 content::DownloadManager* download_manager = |
| 381 content::BrowserContext::GetDownloadManager(browser->profile()); | 374 content::BrowserContext::GetDownloadManager(browser->profile()); |
| 382 scoped_ptr<content::DownloadTestObserver> observer( | 375 scoped_ptr<content::DownloadTestObserver> observer( |
| 383 new content::DownloadTestObserverTerminal( | 376 new content::DownloadTestObserverTerminal( |
| (...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 533 HistoryEnumerator::~HistoryEnumerator() {} | 526 HistoryEnumerator::~HistoryEnumerator() {} |
| 534 | 527 |
| 535 void HistoryEnumerator::HistoryQueryComplete( | 528 void HistoryEnumerator::HistoryQueryComplete( |
| 536 const base::Closure& quit_task, | 529 const base::Closure& quit_task, |
| 537 history::QueryResults* results) { | 530 history::QueryResults* results) { |
| 538 for (size_t i = 0; i < results->size(); ++i) | 531 for (size_t i = 0; i < results->size(); ++i) |
| 539 urls_.push_back((*results)[i].url()); | 532 urls_.push_back((*results)[i].url()); |
| 540 quit_task.Run(); | 533 quit_task.Run(); |
| 541 } | 534 } |
| 542 | 535 |
| 536 // Wait for HistoryService to load. |
| 537 class WaitHistoryLoadedObserver : public history::HistoryServiceObserver { |
| 538 public: |
| 539 explicit WaitHistoryLoadedObserver(content::MessageLoopRunner* runner); |
| 540 ~WaitHistoryLoadedObserver() override; |
| 541 // history::HistoryServiceObserver: |
| 542 void OnHistoryServiceLoaded(HistoryService* service) override; |
| 543 |
| 544 private: |
| 545 // weak |
| 546 content::MessageLoopRunner* runner_; |
| 547 }; |
| 548 |
| 549 WaitHistoryLoadedObserver::WaitHistoryLoadedObserver( |
| 550 content::MessageLoopRunner* runner) |
| 551 : runner_(runner) { |
| 552 } |
| 553 |
| 554 WaitHistoryLoadedObserver::~WaitHistoryLoadedObserver() { |
| 555 } |
| 556 |
| 557 void WaitHistoryLoadedObserver::OnHistoryServiceLoaded( |
| 558 HistoryService* service) { |
| 559 runner_->Quit(); |
| 560 } |
| 561 |
| 562 void WaitForHistoryToLoad(HistoryService* history_service) { |
| 563 if (!history_service->BackendLoaded()) { |
| 564 scoped_refptr<content::MessageLoopRunner> runner = |
| 565 new content::MessageLoopRunner; |
| 566 WaitHistoryLoadedObserver observer(runner.get()); |
| 567 ScopedObserver<HistoryService, history::HistoryServiceObserver> |
| 568 scoped_observer(&observer); |
| 569 scoped_observer.Add(history_service); |
| 570 runner->Run(); |
| 571 } |
| 572 } |
| 573 |
| 543 } // namespace ui_test_utils | 574 } // namespace ui_test_utils |
| OLD | NEW |