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

Side by Side Diff: chrome/browser/search_engines/template_url_fetcher_unittest.cc

Issue 9968016: Move the URL string from TemplateURLRef onto the owning TemplateURL. This will make it easier to m… (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 "base/file_util.h" 5 #include "base/file_util.h"
6 #include "base/memory/scoped_ptr.h" 6 #include "base/memory/scoped_ptr.h"
7 #include "base/message_loop.h" 7 #include "base/message_loop.h"
8 #include "base/path_service.h" 8 #include "base/path_service.h"
9 #include "base/utf_string_conversions.h" 9 #include "base/utf_string_conversions.h"
10 #include "chrome/browser/search_engines/template_url.h" 10 #include "chrome/browser/search_engines/template_url.h"
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after
171 ASSERT_EQ(0, callbacks_destroyed_); 171 ASSERT_EQ(0, callbacks_destroyed_);
172 172
173 WaitForDownloadToFinish(); 173 WaitForDownloadToFinish();
174 ASSERT_EQ(0, add_provider_called_); 174 ASSERT_EQ(0, add_provider_called_);
175 ASSERT_EQ(1, callbacks_destroyed_); 175 ASSERT_EQ(1, callbacks_destroyed_);
176 176
177 const TemplateURL* t_url = test_util_.model()->GetTemplateURLForKeyword( 177 const TemplateURL* t_url = test_util_.model()->GetTemplateURLForKeyword(
178 keyword); 178 keyword);
179 ASSERT_TRUE(t_url); 179 ASSERT_TRUE(t_url);
180 EXPECT_EQ(ASCIIToUTF16("http://example.com/%s/other_stuff"), 180 EXPECT_EQ(ASCIIToUTF16("http://example.com/%s/other_stuff"),
181 t_url->url()->DisplayURL()); 181 t_url->url_ref().DisplayURL());
182 EXPECT_TRUE(t_url->safe_for_autoreplace()); 182 EXPECT_TRUE(t_url->safe_for_autoreplace());
183 } 183 }
184 184
185 TEST_F(TemplateURLFetcherTest, DuplicatesThrownAway) { 185 TEST_F(TemplateURLFetcherTest, DuplicatesThrownAway) {
186 string16 keyword(ASCIIToUTF16("test")); 186 string16 keyword(ASCIIToUTF16("test"));
187 187
188 test_util_.ChangeModelToLoadState(); 188 test_util_.ChangeModelToLoadState();
189 ASSERT_FALSE(test_util_.model()->GetTemplateURLForKeyword(keyword)); 189 ASSERT_FALSE(test_util_.model()->GetTemplateURLForKeyword(keyword));
190 190
191 std::string osdd_file_name("simple_open_search.xml"); 191 std::string osdd_file_name("simple_open_search.xml");
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
236 TemplateURLFetcher::EXPLICIT_PROVIDER, true); 236 TemplateURLFetcher::EXPLICIT_PROVIDER, true);
237 ASSERT_EQ(0, add_provider_called_); 237 ASSERT_EQ(0, add_provider_called_);
238 ASSERT_EQ(0, callbacks_destroyed_); 238 ASSERT_EQ(0, callbacks_destroyed_);
239 239
240 WaitForDownloadToFinish(); 240 WaitForDownloadToFinish();
241 ASSERT_EQ(1, add_provider_called_); 241 ASSERT_EQ(1, add_provider_called_);
242 ASSERT_EQ(1, callbacks_destroyed_); 242 ASSERT_EQ(1, callbacks_destroyed_);
243 243
244 ASSERT_TRUE(last_callback_template_url_.get()); 244 ASSERT_TRUE(last_callback_template_url_.get());
245 EXPECT_EQ(ASCIIToUTF16("http://example.com/%s/other_stuff"), 245 EXPECT_EQ(ASCIIToUTF16("http://example.com/%s/other_stuff"),
246 last_callback_template_url_->url()->DisplayURL()); 246 last_callback_template_url_->url_ref().DisplayURL());
247 EXPECT_EQ(ASCIIToUTF16("example.com"), 247 EXPECT_EQ(ASCIIToUTF16("example.com"),
248 last_callback_template_url_->keyword()); 248 last_callback_template_url_->keyword());
249 EXPECT_FALSE(last_callback_template_url_->safe_for_autoreplace()); 249 EXPECT_FALSE(last_callback_template_url_->safe_for_autoreplace());
250 } 250 }
251 251
252 TEST_F(TemplateURLFetcherTest, AutodetectedBeforeLoadTest) { 252 TEST_F(TemplateURLFetcherTest, AutodetectedBeforeLoadTest) {
253 string16 keyword(ASCIIToUTF16("test")); 253 string16 keyword(ASCIIToUTF16("test"));
254 ASSERT_FALSE(test_util_.model()->GetTemplateURLForKeyword(keyword)); 254 ASSERT_FALSE(test_util_.model()->GetTemplateURLForKeyword(keyword));
255 255
256 std::string osdd_file_name("simple_open_search.xml"); 256 std::string osdd_file_name("simple_open_search.xml");
(...skipping 12 matching lines...) Expand all
269 TemplateURLFetcher::EXPLICIT_PROVIDER, true); 269 TemplateURLFetcher::EXPLICIT_PROVIDER, true);
270 ASSERT_EQ(0, add_provider_called_); 270 ASSERT_EQ(0, add_provider_called_);
271 ASSERT_EQ(0, callbacks_destroyed_); 271 ASSERT_EQ(0, callbacks_destroyed_);
272 272
273 WaitForDownloadToFinish(); 273 WaitForDownloadToFinish();
274 ASSERT_EQ(1, add_provider_called_); 274 ASSERT_EQ(1, add_provider_called_);
275 ASSERT_EQ(1, callbacks_destroyed_); 275 ASSERT_EQ(1, callbacks_destroyed_);
276 276
277 ASSERT_TRUE(last_callback_template_url_.get()); 277 ASSERT_TRUE(last_callback_template_url_.get());
278 EXPECT_EQ(ASCIIToUTF16("http://example.com/%s/other_stuff"), 278 EXPECT_EQ(ASCIIToUTF16("http://example.com/%s/other_stuff"),
279 last_callback_template_url_->url()->DisplayURL()); 279 last_callback_template_url_->url_ref().DisplayURL());
280 EXPECT_EQ(ASCIIToUTF16("example.com"), 280 EXPECT_EQ(ASCIIToUTF16("example.com"),
281 last_callback_template_url_->keyword()); 281 last_callback_template_url_->keyword());
282 EXPECT_FALSE(last_callback_template_url_->safe_for_autoreplace()); 282 EXPECT_FALSE(last_callback_template_url_->safe_for_autoreplace());
283 } 283 }
284 284
285 TEST_F(TemplateURLFetcherTest, DuplicateKeywordsTest) { 285 TEST_F(TemplateURLFetcherTest, DuplicateKeywordsTest) {
286 string16 keyword(ASCIIToUTF16("test")); 286 string16 keyword(ASCIIToUTF16("test"));
287 287
288 TemplateURL* t_url = new TemplateURL(); 288 TemplateURL* t_url = new TemplateURL();
289 t_url->SetURL("http://example.com/"); 289 t_url->SetURL("http://example.com/");
(...skipping 25 matching lines...) Expand all
315 StartDownload(keyword, osdd_file_name, 315 StartDownload(keyword, osdd_file_name,
316 TemplateURLFetcher::EXPLICIT_PROVIDER, true); 316 TemplateURLFetcher::EXPLICIT_PROVIDER, true);
317 ASSERT_EQ(0, add_provider_called_); 317 ASSERT_EQ(0, add_provider_called_);
318 ASSERT_EQ(1, callbacks_destroyed_); 318 ASSERT_EQ(1, callbacks_destroyed_);
319 319
320 WaitForDownloadToFinish(); 320 WaitForDownloadToFinish();
321 ASSERT_EQ(1, add_provider_called_); 321 ASSERT_EQ(1, add_provider_called_);
322 ASSERT_EQ(2, callbacks_destroyed_); 322 ASSERT_EQ(2, callbacks_destroyed_);
323 ASSERT_TRUE(last_callback_template_url_.get()); 323 ASSERT_TRUE(last_callback_template_url_.get());
324 } 324 }
OLDNEW
« no previous file with comments | « chrome/browser/search_engines/template_url_fetcher.cc ('k') | chrome/browser/search_engines/template_url_parser.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698