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

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: Clean-up 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" 7 #include "base/message_loop/message_loop.h"
8 #include "base/strings/string16.h" 8 #include "base/strings/string16.h"
9 #include "base/strings/string_util.h" 9 #include "base/strings/string_util.h"
10 #include "base/strings/utf_string_conversions.h" 10 #include "base/strings/utf_string_conversions.h"
(...skipping 245 matching lines...) Expand 10 before | Expand all | Expand 10 after
256 ASSERT_TRUE(controller->done()); 256 ASSERT_TRUE(controller->done());
257 } 257 }
258 258
259 void SetupSearchEngine() { 259 void SetupSearchEngine() {
260 Profile* profile = browser()->profile(); 260 Profile* profile = browser()->profile();
261 TemplateURLService* model = 261 TemplateURLService* model =
262 TemplateURLServiceFactory::GetForProfile(profile); 262 TemplateURLServiceFactory::GetForProfile(profile);
263 ASSERT_TRUE(model); 263 ASSERT_TRUE(model);
264 264
265 if (!model->loaded()) { 265 if (!model->loaded()) {
266 content::NotificationRegistrar registrar; 266 base::RunLoop run_loop;
267 registrar.Add(this, chrome::NOTIFICATION_TEMPLATE_URL_SERVICE_LOADED, 267 scoped_ptr<TemplateURLService::Subscription> sub =
268 content::Source<TemplateURLService>(model)); 268 model->RegisterOnLoadedCallback(
269 content::GetQuitTaskForRunLoop(&run_loop));
269 model->Load(); 270 model->Load();
270 content::RunMessageLoop(); 271 content::RunThisRunLoop(&run_loop);
Avi (use Gerrit) 2013/10/02 22:27:52 Again, MessageLoopRunner?
Cait (Slow) 2013/10/03 15:36:45 Done.
271 } 272 }
272 273
273 ASSERT_TRUE(model->loaded()); 274 ASSERT_TRUE(model->loaded());
274 // Remove built-in template urls, like google.com, bing.com etc., as they 275 // Remove built-in template urls, like google.com, bing.com etc., as they
275 // may appear as autocomplete suggests and interfere with our tests. 276 // may appear as autocomplete suggests and interfere with our tests.
276 model->SetDefaultSearchProvider(NULL); 277 model->SetDefaultSearchProvider(NULL);
277 TemplateURLService::TemplateURLVector builtins = model->GetTemplateURLs(); 278 TemplateURLService::TemplateURLVector builtins = model->GetTemplateURLs();
278 for (TemplateURLService::TemplateURLVector::const_iterator 279 for (TemplateURLService::TemplateURLVector::const_iterator
279 i = builtins.begin(); i != builtins.end(); ++i) 280 i = builtins.begin(); i != builtins.end(); ++i)
280 model->Remove(*i); 281 model->Remove(*i);
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
357 358
358 virtual void Observe(int type, 359 virtual void Observe(int type,
359 const content::NotificationSource& source, 360 const content::NotificationSource& source,
360 const content::NotificationDetails& details) OVERRIDE { 361 const content::NotificationDetails& details) OVERRIDE {
361 switch (type) { 362 switch (type) {
362 case content::NOTIFICATION_WEB_CONTENTS_DESTROYED: 363 case content::NOTIFICATION_WEB_CONTENTS_DESTROYED:
363 case chrome::NOTIFICATION_TAB_PARENTED: 364 case chrome::NOTIFICATION_TAB_PARENTED:
364 case chrome::NOTIFICATION_AUTOCOMPLETE_CONTROLLER_RESULT_READY: 365 case chrome::NOTIFICATION_AUTOCOMPLETE_CONTROLLER_RESULT_READY:
365 case chrome::NOTIFICATION_HISTORY_LOADED: 366 case chrome::NOTIFICATION_HISTORY_LOADED:
366 case chrome::NOTIFICATION_HISTORY_URLS_MODIFIED: 367 case chrome::NOTIFICATION_HISTORY_URLS_MODIFIED:
367 case chrome::NOTIFICATION_TEMPLATE_URL_SERVICE_LOADED:
368 break; 368 break;
369 default: 369 default:
370 FAIL() << "Unexpected notification type"; 370 FAIL() << "Unexpected notification type";
371 } 371 }
372 base::MessageLoop::current()->Quit(); 372 base::MessageLoop::current()->Quit();
373 } 373 }
374 374
375 void BrowserAcceleratorsTest() { 375 void BrowserAcceleratorsTest() {
376 OmniboxView* omnibox_view = NULL; 376 OmniboxView* omnibox_view = NULL;
377 ASSERT_NO_FATAL_FAILURE(GetOmniboxView(&omnibox_view)); 377 ASSERT_NO_FATAL_FAILURE(GetOmniboxView(&omnibox_view));
(...skipping 1472 matching lines...) Expand 10 before | Expand all | Expand 10 after
1850 omnibox_view->Update(); 1850 omnibox_view->Update();
1851 EXPECT_EQ(url_c, omnibox_view->GetText()); 1851 EXPECT_EQ(url_c, omnibox_view->GetText());
1852 } 1852 }
1853 1853
1854 IN_PROC_BROWSER_TEST_F(OmniboxViewTest, InputResetsSearchTermReplacement) { 1854 IN_PROC_BROWSER_TEST_F(OmniboxViewTest, InputResetsSearchTermReplacement) {
1855 browser()->toolbar_model()->set_search_term_replacement_enabled(false); 1855 browser()->toolbar_model()->set_search_term_replacement_enabled(false);
1856 chrome::FocusLocationBar(browser()); 1856 chrome::FocusLocationBar(browser());
1857 ASSERT_NO_FATAL_FAILURE(SendKey(ui::VKEY_A, 0)); 1857 ASSERT_NO_FATAL_FAILURE(SendKey(ui::VKEY_A, 0));
1858 EXPECT_TRUE(browser()->toolbar_model()->search_term_replacement_enabled()); 1858 EXPECT_TRUE(browser()->toolbar_model()->search_term_replacement_enabled());
1859 } 1859 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698