| 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/base_paths.h" | 5 #include "base/base_paths.h" |
| 6 #include "base/string_util.h" | 6 #include "base/string_util.h" |
| 7 #include "base/utf_string_conversions.h" | 7 #include "base/utf_string_conversions.h" |
| 8 #include "chrome/browser/browser_process.h" | 8 #include "chrome/browser/browser_process.h" |
| 9 #include "chrome/browser/rlz/rlz.h" | 9 #include "chrome/browser/rlz/rlz.h" |
| 10 #include "chrome/browser/search_engines/search_terms_data.h" | 10 #include "chrome/browser/search_engines/search_terms_data.h" |
| (...skipping 473 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 484 { "http://www.google.com/", "http://www.google.com/complete/", }, | 484 { "http://www.google.com/", "http://www.google.com/complete/", }, |
| 485 { "http://www.google.co.uk/", "http://www.google.co.uk/complete/", }, | 485 { "http://www.google.co.uk/", "http://www.google.co.uk/complete/", }, |
| 486 { "http://www.google.com.by/", "http://www.google.com.by/complete/", }, | 486 { "http://www.google.com.by/", "http://www.google.com.by/complete/", }, |
| 487 { "http://google.com/intl/xx/", "http://google.com/complete/", }, | 487 { "http://google.com/intl/xx/", "http://google.com/complete/", }, |
| 488 }; | 488 }; |
| 489 | 489 |
| 490 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(data); ++i) | 490 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(data); ++i) |
| 491 CheckSuggestBaseURL(data[i].base_url, data[i].base_suggest_url); | 491 CheckSuggestBaseURL(data[i].base_url, data[i].base_suggest_url); |
| 492 } | 492 } |
| 493 | 493 |
| 494 TEST_F(TemplateURLTest, Keyword) { | |
| 495 TemplateURLData data; | |
| 496 data.SetURL("http://www.google.com/search"); | |
| 497 EXPECT_FALSE(data.autogenerate_keyword()); | |
| 498 data.SetKeyword(ASCIIToUTF16("foo")); | |
| 499 EXPECT_EQ(ASCIIToUTF16("foo"), TemplateURL(NULL, data).keyword()); | |
| 500 data.SetAutogenerateKeyword(true); | |
| 501 EXPECT_TRUE(data.autogenerate_keyword()); | |
| 502 EXPECT_EQ(ASCIIToUTF16("google.com"), TemplateURL(NULL, data).keyword()); | |
| 503 data.SetKeyword(ASCIIToUTF16("foo")); | |
| 504 EXPECT_FALSE(data.autogenerate_keyword()); | |
| 505 EXPECT_EQ(ASCIIToUTF16("foo"), TemplateURL(NULL, data).keyword()); | |
| 506 } | |
| 507 | |
| 508 TEST_F(TemplateURLTest, ParseParameterKnown) { | 494 TEST_F(TemplateURLTest, ParseParameterKnown) { |
| 509 std::string parsed_url("{searchTerms}"); | 495 std::string parsed_url("{searchTerms}"); |
| 510 TemplateURLData data; | 496 TemplateURLData data; |
| 511 data.SetURL(parsed_url); | 497 data.SetURL(parsed_url); |
| 512 TemplateURL url(NULL, data); | 498 TemplateURL url(NULL, data); |
| 513 TemplateURLRef::Replacements replacements; | 499 TemplateURLRef::Replacements replacements; |
| 514 EXPECT_TRUE(url.url_ref().ParseParameter(0, 12, &parsed_url, &replacements)); | 500 EXPECT_TRUE(url.url_ref().ParseParameter(0, 12, &parsed_url, &replacements)); |
| 515 EXPECT_EQ(std::string(), parsed_url); | 501 EXPECT_EQ(std::string(), parsed_url); |
| 516 ASSERT_EQ(1U, replacements.size()); | 502 ASSERT_EQ(1U, replacements.size()); |
| 517 EXPECT_EQ(0U, replacements[0].index); | 503 EXPECT_EQ(0U, replacements[0].index); |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 593 TemplateURL url(NULL, data); | 579 TemplateURL url(NULL, data); |
| 594 TemplateURLRef::Replacements replacements; | 580 TemplateURLRef::Replacements replacements; |
| 595 bool valid = false; | 581 bool valid = false; |
| 596 EXPECT_EQ("{", | 582 EXPECT_EQ("{", |
| 597 url.url_ref().ParseURL("{{searchTerms}", &replacements, &valid)); | 583 url.url_ref().ParseURL("{{searchTerms}", &replacements, &valid)); |
| 598 ASSERT_EQ(1U, replacements.size()); | 584 ASSERT_EQ(1U, replacements.size()); |
| 599 EXPECT_EQ(1U, replacements[0].index); | 585 EXPECT_EQ(1U, replacements[0].index); |
| 600 EXPECT_EQ(TemplateURLRef::SEARCH_TERMS, replacements[0].type); | 586 EXPECT_EQ(TemplateURLRef::SEARCH_TERMS, replacements[0].type); |
| 601 EXPECT_TRUE(valid); | 587 EXPECT_TRUE(valid); |
| 602 } | 588 } |
| OLD | NEW |