Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(113)

Side by Side Diff: chrome/test/base/ui_test_utils.cc

Issue 23710022: Convert NOTIFICATION_TEMPLATE_URL_SERVICE_LOADED to CallbackList (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « chrome/browser/ui/omnibox/omnibox_view_browsertest.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 298 matching lines...) Expand 10 before | Expand all | Expand 10 after
328 if (ordinal) 328 if (ordinal)
329 *ordinal = observer.active_match_ordinal(); 329 *ordinal = observer.active_match_ordinal();
330 if (selection_rect) 330 if (selection_rect)
331 *selection_rect = observer.selection_rect(); 331 *selection_rect = observer.selection_rect();
332 return observer.number_of_matches(); 332 return observer.number_of_matches();
333 } 333 }
334 334
335 void WaitForTemplateURLServiceToLoad(TemplateURLService* service) { 335 void WaitForTemplateURLServiceToLoad(TemplateURLService* service) {
336 if (service->loaded()) 336 if (service->loaded())
337 return; 337 return;
338 338 scoped_refptr<content::MessageLoopRunner> message_loop_runner =
339 content::WindowedNotificationObserver observer( 339 new content::MessageLoopRunner;
340 chrome::NOTIFICATION_TEMPLATE_URL_SERVICE_LOADED, 340 scoped_ptr<TemplateURLService::Subscription> subscription =
341 content::Source<TemplateURLService>(service)); 341 service->RegisterOnLoadedCallback(
342 message_loop_runner->QuitClosure());
342 service->Load(); 343 service->Load();
343 observer.Wait(); 344 message_loop_runner->Run();
344 345
345 ASSERT_TRUE(service->loaded()); 346 ASSERT_TRUE(service->loaded());
346 } 347 }
347 348
348 void WaitForHistoryToLoad(HistoryService* history_service) { 349 void WaitForHistoryToLoad(HistoryService* history_service) {
349 content::WindowedNotificationObserver history_loaded_observer( 350 content::WindowedNotificationObserver history_loaded_observer(
350 chrome::NOTIFICATION_HISTORY_LOADED, 351 chrome::NOTIFICATION_HISTORY_LOADED,
351 content::NotificationService::AllSources()); 352 content::NotificationService::AllSources());
352 if (!history_service->BackendLoaded()) 353 if (!history_service->BackendLoaded())
353 history_loaded_observer.Wait(); 354 history_loaded_observer.Wait();
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after
520 void HistoryEnumerator::HistoryQueryComplete( 521 void HistoryEnumerator::HistoryQueryComplete(
521 const base::Closure& quit_task, 522 const base::Closure& quit_task,
522 HistoryService::Handle request_handle, 523 HistoryService::Handle request_handle,
523 history::QueryResults* results) { 524 history::QueryResults* results) {
524 for (size_t i = 0; i < results->size(); ++i) 525 for (size_t i = 0; i < results->size(); ++i)
525 urls_.push_back((*results)[i].url()); 526 urls_.push_back((*results)[i].url());
526 quit_task.Run(); 527 quit_task.Run();
527 } 528 }
528 529
529 } // namespace ui_test_utils 530 } // namespace ui_test_utils
OLDNEW
« no previous file with comments | « chrome/browser/ui/omnibox/omnibox_view_browsertest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698