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

Side by Side Diff: chrome/browser/autocomplete/search_provider_unittest.cc

Issue 9982018: Move most TemplateURL data members to a new struct, TemplateURLData. This allows us to eliminate t… (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 8 years, 8 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 "chrome/browser/autocomplete/search_provider.h" 5 #include "chrome/browser/autocomplete/search_provider.h"
6 6
7 #include "base/string_util.h" 7 #include "base/string_util.h"
8 #include "base/time.h" 8 #include "base/time.h"
9 #include "base/utf_string_conversions.h" 9 #include "base/utf_string_conversions.h"
10 #include "build/build_config.h" 10 #include "build/build_config.h"
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
114 // We need both the history service and template url model loaded. 114 // We need both the history service and template url model loaded.
115 profile_.CreateHistoryService(true, false); 115 profile_.CreateHistoryService(true, false);
116 profile_.CreateTemplateURLService(); 116 profile_.CreateTemplateURLService();
117 117
118 TemplateURLService* turl_model = 118 TemplateURLService* turl_model =
119 TemplateURLServiceFactory::GetForProfile(&profile_); 119 TemplateURLServiceFactory::GetForProfile(&profile_);
120 120
121 turl_model->Load(); 121 turl_model->Load();
122 122
123 // Reset the default TemplateURL. 123 // Reset the default TemplateURL.
124 default_t_url_ = new TemplateURL(); 124 TemplateURLData data;
125 default_t_url_->SetURL("http://defaultturl/{searchTerms}"); 125 data.short_name = ASCIIToUTF16("t");
126 default_t_url_->SetSuggestionsURL("http://defaultturl2/{searchTerms}"); 126 data.SetURL("http://defaultturl/{searchTerms}");
127 default_t_url_->set_short_name(ASCIIToUTF16("t")); 127 data.suggestions_url = "http://defaultturl2/{searchTerms}";
128 default_t_url_ = new TemplateURL(data);
128 turl_model->Add(default_t_url_); 129 turl_model->Add(default_t_url_);
129 turl_model->SetDefaultSearchProvider(default_t_url_); 130 turl_model->SetDefaultSearchProvider(default_t_url_);
130 TemplateURLID default_provider_id = default_t_url_->id(); 131 TemplateURLID default_provider_id = default_t_url_->id();
131 ASSERT_NE(0, default_provider_id); 132 ASSERT_NE(0, default_provider_id);
132 133
133 // Add url1, with search term term1_. 134 // Add url1, with search term term1_.
134 term1_url_ = AddSearchToHistory(default_t_url_, term1_, 1); 135 term1_url_ = AddSearchToHistory(default_t_url_, term1_, 1);
135 136
136 // Create another TemplateURL. 137 // Create another TemplateURL.
137 keyword_t_url_ = new TemplateURL(); 138 data.short_name = ASCIIToUTF16("k");
138 keyword_t_url_->set_keyword(ASCIIToUTF16("k")); 139 data.SetKeyword(ASCIIToUTF16("k"));
139 keyword_t_url_->set_short_name(ASCIIToUTF16("k")); 140 data.SetURL("http://keyword/{searchTerms}");
140 keyword_t_url_->SetURL("http://keyword/{searchTerms}"); 141 data.suggestions_url = "http://suggest_keyword/{searchTerms}";
141 keyword_t_url_->SetSuggestionsURL("http://suggest_keyword/{searchTerms}"); 142 keyword_t_url_ = new TemplateURL(data);
142 turl_model->Add(keyword_t_url_); 143 turl_model->Add(keyword_t_url_);
143 ASSERT_NE(0, keyword_t_url_->id()); 144 ASSERT_NE(0, keyword_t_url_->id());
144 145
145 // Add a page and search term for keyword_t_url_. 146 // Add a page and search term for keyword_t_url_.
146 keyword_url_ = AddSearchToHistory(keyword_t_url_, keyword_term_, 1); 147 keyword_url_ = AddSearchToHistory(keyword_t_url_, keyword_term_, 1);
147 148
148 // Keywords are updated by the InMemoryHistoryBackend only after the message 149 // Keywords are updated by the InMemoryHistoryBackend only after the message
149 // has been processed on the history thread. Block until history processes all 150 // has been processed on the history thread. Block until history processes all
150 // requests to ensure the InMemoryDatabase is the state we expect it. 151 // requests to ensure the InMemoryDatabase is the state we expect it.
151 profile_.BlockUntilHistoryProcessesPendingRequests(); 152 profile_.BlockUntilHistoryProcessesPendingRequests();
(...skipping 508 matching lines...) Expand 10 before | Expand all | Expand 10 after
660 fetcher = NULL; 661 fetcher = NULL;
661 662
662 // Run till the history results complete. 663 // Run till the history results complete.
663 RunTillProviderDone(); 664 RunTillProviderDone();
664 665
665 // Make sure there is a match for 'a.com' and it doesn't have a template_url. 666 // Make sure there is a match for 'a.com' and it doesn't have a template_url.
666 AutocompleteMatch nav_match; 667 AutocompleteMatch nav_match;
667 EXPECT_TRUE(FindMatchWithDestination(GURL("http://a.com"), &nav_match)); 668 EXPECT_TRUE(FindMatchWithDestination(GURL("http://a.com"), &nav_match));
668 EXPECT_FALSE(nav_match.template_url); 669 EXPECT_FALSE(nav_match.template_url);
669 } 670 }
OLDNEW
« no previous file with comments | « chrome/browser/autocomplete/search_provider.h ('k') | chrome/browser/importer/firefox2_importer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698