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

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

Issue 9965143: Revert 130431 - Move the URL string from TemplateURLRef onto the owning TemplateURL. This will mak… (Closed) Base URL: svn://svn.chromium.org/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 162 matching lines...) Expand 10 before | Expand all | Expand 10 after
173 ASSERT_EQ(0, callbacks_destroyed_); 173 ASSERT_EQ(0, callbacks_destroyed_);
174 174
175 WaitForDownloadToFinish(); 175 WaitForDownloadToFinish();
176 ASSERT_EQ(0, add_provider_called_); 176 ASSERT_EQ(0, add_provider_called_);
177 ASSERT_EQ(1, callbacks_destroyed_); 177 ASSERT_EQ(1, callbacks_destroyed_);
178 178
179 const TemplateURL* t_url = test_util_.model()->GetTemplateURLForKeyword( 179 const TemplateURL* t_url = test_util_.model()->GetTemplateURLForKeyword(
180 keyword); 180 keyword);
181 ASSERT_TRUE(t_url); 181 ASSERT_TRUE(t_url);
182 EXPECT_EQ(ASCIIToUTF16("http://example.com/%s/other_stuff"), 182 EXPECT_EQ(ASCIIToUTF16("http://example.com/%s/other_stuff"),
183 t_url->url_ref().DisplayURL()); 183 t_url->url()->DisplayURL());
184 EXPECT_TRUE(t_url->safe_for_autoreplace()); 184 EXPECT_TRUE(t_url->safe_for_autoreplace());
185 } 185 }
186 186
187 TEST_F(TemplateURLFetcherTest, DuplicatesThrownAway) { 187 TEST_F(TemplateURLFetcherTest, DuplicatesThrownAway) {
188 string16 keyword(ASCIIToUTF16("test")); 188 string16 keyword(ASCIIToUTF16("test"));
189 189
190 test_util_.ChangeModelToLoadState(); 190 test_util_.ChangeModelToLoadState();
191 ASSERT_FALSE(test_util_.model()->GetTemplateURLForKeyword(keyword)); 191 ASSERT_FALSE(test_util_.model()->GetTemplateURLForKeyword(keyword));
192 192
193 std::string osdd_file_name("simple_open_search.xml"); 193 std::string osdd_file_name("simple_open_search.xml");
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
239 TemplateURLFetcher::EXPLICIT_PROVIDER, true); 239 TemplateURLFetcher::EXPLICIT_PROVIDER, true);
240 ASSERT_EQ(0, add_provider_called_); 240 ASSERT_EQ(0, add_provider_called_);
241 ASSERT_EQ(0, callbacks_destroyed_); 241 ASSERT_EQ(0, callbacks_destroyed_);
242 242
243 WaitForDownloadToFinish(); 243 WaitForDownloadToFinish();
244 ASSERT_EQ(1, add_provider_called_); 244 ASSERT_EQ(1, add_provider_called_);
245 ASSERT_EQ(1, callbacks_destroyed_); 245 ASSERT_EQ(1, callbacks_destroyed_);
246 246
247 ASSERT_TRUE(last_callback_template_url_.get()); 247 ASSERT_TRUE(last_callback_template_url_.get());
248 EXPECT_EQ(ASCIIToUTF16("http://example.com/%s/other_stuff"), 248 EXPECT_EQ(ASCIIToUTF16("http://example.com/%s/other_stuff"),
249 last_callback_template_url_->url_ref().DisplayURL()); 249 last_callback_template_url_->url()->DisplayURL());
250 EXPECT_EQ(ASCIIToUTF16("example.com"), 250 EXPECT_EQ(ASCIIToUTF16("example.com"),
251 last_callback_template_url_->keyword()); 251 last_callback_template_url_->keyword());
252 EXPECT_FALSE(last_callback_template_url_->safe_for_autoreplace()); 252 EXPECT_FALSE(last_callback_template_url_->safe_for_autoreplace());
253 } 253 }
254 254
255 TEST_F(TemplateURLFetcherTest, AutodetectedBeforeLoadTest) { 255 TEST_F(TemplateURLFetcherTest, AutodetectedBeforeLoadTest) {
256 string16 keyword(ASCIIToUTF16("test")); 256 string16 keyword(ASCIIToUTF16("test"));
257 ASSERT_FALSE(test_util_.model()->GetTemplateURLForKeyword(keyword)); 257 ASSERT_FALSE(test_util_.model()->GetTemplateURLForKeyword(keyword));
258 258
259 std::string osdd_file_name("simple_open_search.xml"); 259 std::string osdd_file_name("simple_open_search.xml");
(...skipping 12 matching lines...) Expand all
272 TemplateURLFetcher::EXPLICIT_PROVIDER, true); 272 TemplateURLFetcher::EXPLICIT_PROVIDER, true);
273 ASSERT_EQ(0, add_provider_called_); 273 ASSERT_EQ(0, add_provider_called_);
274 ASSERT_EQ(0, callbacks_destroyed_); 274 ASSERT_EQ(0, callbacks_destroyed_);
275 275
276 WaitForDownloadToFinish(); 276 WaitForDownloadToFinish();
277 ASSERT_EQ(1, add_provider_called_); 277 ASSERT_EQ(1, add_provider_called_);
278 ASSERT_EQ(1, callbacks_destroyed_); 278 ASSERT_EQ(1, callbacks_destroyed_);
279 279
280 ASSERT_TRUE(last_callback_template_url_.get()); 280 ASSERT_TRUE(last_callback_template_url_.get());
281 EXPECT_EQ(ASCIIToUTF16("http://example.com/%s/other_stuff"), 281 EXPECT_EQ(ASCIIToUTF16("http://example.com/%s/other_stuff"),
282 last_callback_template_url_->url_ref().DisplayURL()); 282 last_callback_template_url_->url()->DisplayURL());
283 EXPECT_EQ(ASCIIToUTF16("example.com"), 283 EXPECT_EQ(ASCIIToUTF16("example.com"),
284 last_callback_template_url_->keyword()); 284 last_callback_template_url_->keyword());
285 EXPECT_FALSE(last_callback_template_url_->safe_for_autoreplace()); 285 EXPECT_FALSE(last_callback_template_url_->safe_for_autoreplace());
286 } 286 }
287 287
288 TEST_F(TemplateURLFetcherTest, DuplicateKeywordsTest) { 288 TEST_F(TemplateURLFetcherTest, DuplicateKeywordsTest) {
289 string16 keyword(ASCIIToUTF16("test")); 289 string16 keyword(ASCIIToUTF16("test"));
290 290
291 TemplateURL* t_url = new TemplateURL(); 291 TemplateURL* t_url = new TemplateURL();
292 t_url->SetURL("http://example.com/"); 292 t_url->SetURL("http://example.com/");
(...skipping 25 matching lines...) Expand all
318 StartDownload(keyword, osdd_file_name, 318 StartDownload(keyword, osdd_file_name,
319 TemplateURLFetcher::EXPLICIT_PROVIDER, true); 319 TemplateURLFetcher::EXPLICIT_PROVIDER, true);
320 ASSERT_EQ(0, add_provider_called_); 320 ASSERT_EQ(0, add_provider_called_);
321 ASSERT_EQ(1, callbacks_destroyed_); 321 ASSERT_EQ(1, callbacks_destroyed_);
322 322
323 WaitForDownloadToFinish(); 323 WaitForDownloadToFinish();
324 ASSERT_EQ(1, add_provider_called_); 324 ASSERT_EQ(1, add_provider_called_);
325 ASSERT_EQ(2, callbacks_destroyed_); 325 ASSERT_EQ(2, callbacks_destroyed_);
326 ASSERT_TRUE(last_callback_template_url_.get()); 326 ASSERT_TRUE(last_callback_template_url_.get());
327 } 327 }
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