| 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 |
| 11 #include "base/bind.h" | 11 #include "base/bind.h" |
| 12 #include "base/bind_helpers.h" | 12 #include "base/bind_helpers.h" |
| 13 #include "base/callback.h" | 13 #include "base/callback.h" |
| 14 #include "base/command_line.h" | 14 #include "base/command_line.h" |
| 15 #include "base/file_util.h" | 15 #include "base/file_util.h" |
| 16 #include "base/files/file_path.h" | 16 #include "base/files/file_path.h" |
| 17 #include "base/json/json_reader.h" | 17 #include "base/json/json_reader.h" |
| 18 #include "base/memory/ref_counted.h" |
| 18 #include "base/memory/scoped_ptr.h" | 19 #include "base/memory/scoped_ptr.h" |
| 19 #include "base/message_loop/message_loop.h" | |
| 20 #include "base/path_service.h" | 20 #include "base/path_service.h" |
| 21 #include "base/prefs/pref_service.h" | 21 #include "base/prefs/pref_service.h" |
| 22 #include "base/strings/stringprintf.h" | 22 #include "base/strings/stringprintf.h" |
| 23 #include "base/strings/utf_string_conversions.h" | 23 #include "base/strings/utf_string_conversions.h" |
| 24 #include "base/test/test_timeouts.h" | 24 #include "base/test/test_timeouts.h" |
| 25 #include "base/time/time.h" | 25 #include "base/time/time.h" |
| 26 #include "base/values.h" | 26 #include "base/values.h" |
| 27 #include "chrome/browser/autocomplete/autocomplete_controller.h" | 27 #include "chrome/browser/autocomplete/autocomplete_controller.h" |
| 28 #include "chrome/browser/bookmarks/bookmark_model.h" | 28 #include "chrome/browser/bookmarks/bookmark_model.h" |
| 29 #include "chrome/browser/bookmarks/bookmark_model_factory.h" | 29 #include "chrome/browser/bookmarks/bookmark_model_factory.h" |
| (...skipping 318 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 348 int type, | 348 int type, |
| 349 const content::NotificationSource& source) { | 349 const content::NotificationSource& source) { |
| 350 content::NotificationRegistrar registrar; | 350 content::NotificationRegistrar registrar; |
| 351 registrar.Add(observer, type, source); | 351 registrar.Add(observer, type, source); |
| 352 content::RunMessageLoop(); | 352 content::RunMessageLoop(); |
| 353 } | 353 } |
| 354 | 354 |
| 355 void WaitForTemplateURLServiceToLoad(TemplateURLService* service) { | 355 void WaitForTemplateURLServiceToLoad(TemplateURLService* service) { |
| 356 if (service->loaded()) | 356 if (service->loaded()) |
| 357 return; | 357 return; |
| 358 | 358 scoped_refptr<content::MessageLoopRunner> message_loop_runner = |
| 359 content::WindowedNotificationObserver observer( | 359 new content::MessageLoopRunner; |
| 360 chrome::NOTIFICATION_TEMPLATE_URL_SERVICE_LOADED, | 360 scoped_ptr<TemplateURLService::Subscription> subscription = |
| 361 content::Source<TemplateURLService>(service)); | 361 service->RegisterOnLoadedCallback( |
| 362 message_loop_runner->QuitClosure()); |
| 362 service->Load(); | 363 service->Load(); |
| 363 observer.Wait(); | 364 message_loop_runner->Run(); |
| 364 | 365 |
| 365 ASSERT_TRUE(service->loaded()); | 366 ASSERT_TRUE(service->loaded()); |
| 366 } | 367 } |
| 367 | 368 |
| 368 void WaitForHistoryToLoad(HistoryService* history_service) { | 369 void WaitForHistoryToLoad(HistoryService* history_service) { |
| 369 content::WindowedNotificationObserver history_loaded_observer( | 370 content::WindowedNotificationObserver history_loaded_observer( |
| 370 chrome::NOTIFICATION_HISTORY_LOADED, | 371 chrome::NOTIFICATION_HISTORY_LOADED, |
| 371 content::NotificationService::AllSources()); | 372 content::NotificationService::AllSources()); |
| 372 if (!history_service->BackendLoaded()) | 373 if (!history_service->BackendLoaded()) |
| 373 history_loaded_observer.Wait(); | 374 history_loaded_observer.Wait(); |
| (...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 540 void HistoryEnumerator::HistoryQueryComplete( | 541 void HistoryEnumerator::HistoryQueryComplete( |
| 541 const base::Closure& quit_task, | 542 const base::Closure& quit_task, |
| 542 HistoryService::Handle request_handle, | 543 HistoryService::Handle request_handle, |
| 543 history::QueryResults* results) { | 544 history::QueryResults* results) { |
| 544 for (size_t i = 0; i < results->size(); ++i) | 545 for (size_t i = 0; i < results->size(); ++i) |
| 545 urls_.push_back((*results)[i].url()); | 546 urls_.push_back((*results)[i].url()); |
| 546 quit_task.Run(); | 547 quit_task.Run(); |
| 547 } | 548 } |
| 548 | 549 |
| 549 } // namespace ui_test_utils | 550 } // namespace ui_test_utils |
| OLD | NEW |