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

Side by Side Diff: chrome/browser/ui/omnibox/omnibox_view_browsertest.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
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 <stdio.h> 5 #include <stdio.h>
6 6
7 #include "base/message_loop/message_loop.h"
8 #include "base/strings/string16.h" 7 #include "base/strings/string16.h"
9 #include "base/strings/string_util.h" 8 #include "base/strings/string_util.h"
10 #include "base/strings/utf_string_conversions.h" 9 #include "base/strings/utf_string_conversions.h"
11 #include "base/time/time.h" 10 #include "base/time/time.h"
12 #include "chrome/app/chrome_command_ids.h" 11 #include "chrome/app/chrome_command_ids.h"
13 #include "chrome/browser/autocomplete/autocomplete_input.h" 12 #include "chrome/browser/autocomplete/autocomplete_input.h"
14 #include "chrome/browser/autocomplete/autocomplete_match.h" 13 #include "chrome/browser/autocomplete/autocomplete_match.h"
15 #include "chrome/browser/autocomplete/history_quick_provider.h" 14 #include "chrome/browser/autocomplete/history_quick_provider.h"
16 #include "chrome/browser/bookmarks/bookmark_model.h" 15 #include "chrome/browser/bookmarks/bookmark_model.h"
17 #include "chrome/browser/bookmarks/bookmark_model_factory.h" 16 #include "chrome/browser/bookmarks/bookmark_model_factory.h"
(...skipping 237 matching lines...) Expand 10 before | Expand all | Expand 10 after
255 254
256 ASSERT_TRUE(controller->done()); 255 ASSERT_TRUE(controller->done());
257 } 256 }
258 257
259 void SetupSearchEngine() { 258 void SetupSearchEngine() {
260 Profile* profile = browser()->profile(); 259 Profile* profile = browser()->profile();
261 TemplateURLService* model = 260 TemplateURLService* model =
262 TemplateURLServiceFactory::GetForProfile(profile); 261 TemplateURLServiceFactory::GetForProfile(profile);
263 ASSERT_TRUE(model); 262 ASSERT_TRUE(model);
264 263
265 if (!model->loaded()) { 264 ui_test_utils::WaitForTemplateURLServiceToLoad(model);
266 content::NotificationRegistrar registrar;
267 registrar.Add(this, chrome::NOTIFICATION_TEMPLATE_URL_SERVICE_LOADED,
268 content::Source<TemplateURLService>(model));
269 model->Load();
270 content::RunMessageLoop();
271 }
272 265
273 ASSERT_TRUE(model->loaded()); 266 ASSERT_TRUE(model->loaded());
274 // Remove built-in template urls, like google.com, bing.com etc., as they 267 // Remove built-in template urls, like google.com, bing.com etc., as they
275 // may appear as autocomplete suggests and interfere with our tests. 268 // may appear as autocomplete suggests and interfere with our tests.
276 model->SetDefaultSearchProvider(NULL); 269 model->SetDefaultSearchProvider(NULL);
277 TemplateURLService::TemplateURLVector builtins = model->GetTemplateURLs(); 270 TemplateURLService::TemplateURLVector builtins = model->GetTemplateURLs();
278 for (TemplateURLService::TemplateURLVector::const_iterator 271 for (TemplateURLService::TemplateURLVector::const_iterator
279 i = builtins.begin(); i != builtins.end(); ++i) 272 i = builtins.begin(); i != builtins.end(); ++i)
280 model->Remove(*i); 273 model->Remove(*i);
281 274
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
357 350
358 virtual void Observe(int type, 351 virtual void Observe(int type,
359 const content::NotificationSource& source, 352 const content::NotificationSource& source,
360 const content::NotificationDetails& details) OVERRIDE { 353 const content::NotificationDetails& details) OVERRIDE {
361 switch (type) { 354 switch (type) {
362 case content::NOTIFICATION_WEB_CONTENTS_DESTROYED: 355 case content::NOTIFICATION_WEB_CONTENTS_DESTROYED:
363 case chrome::NOTIFICATION_TAB_PARENTED: 356 case chrome::NOTIFICATION_TAB_PARENTED:
364 case chrome::NOTIFICATION_AUTOCOMPLETE_CONTROLLER_RESULT_READY: 357 case chrome::NOTIFICATION_AUTOCOMPLETE_CONTROLLER_RESULT_READY:
365 case chrome::NOTIFICATION_HISTORY_LOADED: 358 case chrome::NOTIFICATION_HISTORY_LOADED:
366 case chrome::NOTIFICATION_HISTORY_URLS_MODIFIED: 359 case chrome::NOTIFICATION_HISTORY_URLS_MODIFIED:
367 case chrome::NOTIFICATION_TEMPLATE_URL_SERVICE_LOADED:
368 break; 360 break;
369 default: 361 default:
370 FAIL() << "Unexpected notification type"; 362 FAIL() << "Unexpected notification type";
371 } 363 }
372 base::MessageLoop::current()->Quit(); 364 base::MessageLoop::current()->Quit();
373 } 365 }
374 366
375 void BrowserAcceleratorsTest() { 367 void BrowserAcceleratorsTest() {
376 OmniboxView* omnibox_view = NULL; 368 OmniboxView* omnibox_view = NULL;
377 ASSERT_NO_FATAL_FAILURE(GetOmniboxView(&omnibox_view)); 369 ASSERT_NO_FATAL_FAILURE(GetOmniboxView(&omnibox_view));
(...skipping 1478 matching lines...) Expand 10 before | Expand all | Expand 10 after
1856 omnibox_view->Update(); 1848 omnibox_view->Update();
1857 EXPECT_EQ(url_c, omnibox_view->GetText()); 1849 EXPECT_EQ(url_c, omnibox_view->GetText());
1858 } 1850 }
1859 1851
1860 IN_PROC_BROWSER_TEST_F(OmniboxViewTest, InputResetsSearchTermReplacement) { 1852 IN_PROC_BROWSER_TEST_F(OmniboxViewTest, InputResetsSearchTermReplacement) {
1861 browser()->toolbar_model()->set_search_term_replacement_enabled(false); 1853 browser()->toolbar_model()->set_search_term_replacement_enabled(false);
1862 chrome::FocusLocationBar(browser()); 1854 chrome::FocusLocationBar(browser());
1863 ASSERT_NO_FATAL_FAILURE(SendKey(ui::VKEY_A, 0)); 1855 ASSERT_NO_FATAL_FAILURE(SendKey(ui::VKEY_A, 0));
1864 EXPECT_TRUE(browser()->toolbar_model()->search_term_replacement_enabled()); 1856 EXPECT_TRUE(browser()->toolbar_model()->search_term_replacement_enabled());
1865 } 1857 }
OLDNEW
« no previous file with comments | « chrome/browser/sync/glue/search_engine_data_type_controller_unittest.cc ('k') | chrome/test/base/ui_test_utils.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698