OLD | NEW |
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 270 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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_ref().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 TemplateURLData data; |
292 t_url->SetURL("http://example.com/"); | 292 data.short_name = keyword; |
293 t_url->set_keyword(keyword); | 293 data.SetKeyword(keyword); |
294 t_url->set_short_name(keyword); | 294 data.SetURL("http://example.com/"); |
295 test_util_.model()->Add(t_url); | 295 test_util_.model()->Add(new TemplateURL(data)); |
296 test_util_.ChangeModelToLoadState(); | 296 test_util_.ChangeModelToLoadState(); |
297 | 297 |
298 ASSERT_TRUE(test_util_.model()->GetTemplateURLForKeyword(keyword)); | 298 ASSERT_TRUE(test_util_.model()->GetTemplateURLForKeyword(keyword)); |
299 | 299 |
300 // This should bail because the keyword already exists. | 300 // This should bail because the keyword already exists. |
301 std::string osdd_file_name("simple_open_search.xml"); | 301 std::string osdd_file_name("simple_open_search.xml"); |
302 StartDownload(keyword, osdd_file_name, | 302 StartDownload(keyword, osdd_file_name, |
303 TemplateURLFetcher::AUTODETECTED_PROVIDER, true); | 303 TemplateURLFetcher::AUTODETECTED_PROVIDER, true); |
304 ASSERT_EQ(0, add_provider_called_); | 304 ASSERT_EQ(0, add_provider_called_); |
305 ASSERT_EQ(1, callbacks_destroyed_); | 305 ASSERT_EQ(1, callbacks_destroyed_); |
(...skipping 12 matching lines...) Expand all Loading... |
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 } |
OLD | NEW |