| Index: components/search_engines/template_url_unittest.cc
|
| diff --git a/components/search_engines/template_url_unittest.cc b/components/search_engines/template_url_unittest.cc
|
| index 47630f348925dd2bb0dcf7e096f5724ea6f76dd3..170807f17f36a74c46898a97e6b742699efa7c60 100644
|
| --- a/components/search_engines/template_url_unittest.cc
|
| +++ b/components/search_engines/template_url_unittest.cc
|
| @@ -10,12 +10,14 @@
|
| #include "base/strings/string_number_conversions.h"
|
| #include "base/strings/string_util.h"
|
| #include "base/strings/utf_string_conversions.h"
|
| +#include "components/google/core/browser/google_util.h"
|
| #include "components/metrics/proto/omnibox_event.pb.h"
|
| #include "components/metrics/proto/omnibox_input_type.pb.h"
|
| #include "components/search_engines/search_engines_switches.h"
|
| #include "components/search_engines/search_terms_data.h"
|
| #include "components/search_engines/template_url.h"
|
| #include "components/search_engines/testing_search_terms_data.h"
|
| +#include "net/base/url_util.h"
|
| #include "testing/gtest/include/gtest/gtest.h"
|
|
|
| using base::ASCIIToUTF16;
|
| @@ -1868,3 +1870,43 @@ TEST_F(TemplateURLTest, InvalidateCachedValues) {
|
|
|
| search_terms_data_.set_google_base_url("http://www.google.com/");
|
| }
|
| +
|
| +// search_terms_replacement_key param of TemplateURLData with value of
|
| +// "{google:instantExtendedEnabledKey}" is replaced inside TemplateUrl
|
| +// constructor so must be handled specially inside MatchesData.
|
| +// Test that TemplateURL object created with such param matches correctly its
|
| +// TemplateURLData.
|
| +TEST_F(TemplateURLTest, MatchesData) {
|
| + TemplateURLData data;
|
| + data.search_terms_replacement_key =
|
| + google_util::kGoogleInstantExtendedEnabledKeyFull;
|
| + TemplateURL url(data);
|
| + EXPECT_NE(google_util::kGoogleInstantExtendedEnabledKeyFull,
|
| + url.search_terms_replacement_key());
|
| + EXPECT_TRUE(TemplateURL::MatchesData(&url, &data, search_terms_data_));
|
| +}
|
| +
|
| +// Test for correct replacement of GoogleInstantExtendedEnabledKey param.
|
| +TEST_F(TemplateURLTest, GoogleInstantExtendedEnabledReplacement) {
|
| + TemplateURLData data;
|
| + data.SetURL(std::string("https://www.google.com?") +
|
| + google_util::kGoogleInstantExtendedEnabledKeyFull +
|
| + "&q={searchTerms}");
|
| + data.SetShortName(ASCIIToUTF16("Google"));
|
| + data.SetKeyword(ASCIIToUTF16("google.com"));
|
| + data.search_terms_replacement_key =
|
| + google_util::kGoogleInstantExtendedEnabledKeyFull;
|
| + TemplateURL turl(data);
|
| + EXPECT_TRUE(TemplateURL::MatchesData(&turl, &data, search_terms_data_));
|
| + // Expect that replacement of search_terms_replacement_key in TemplateURL
|
| + // constructor is correct.
|
| + EXPECT_EQ(google_util::kInstantExtendedAPIParam,
|
| + turl.search_terms_replacement_key());
|
| + // Expect that replacement of {google:instantExtendedEnabledKey} in search url
|
| + // is correct.
|
| + GURL search_generated = turl.GenerateSearchURL(search_terms_data_);
|
| + EXPECT_TRUE(turl.HasSearchTermsReplacementKey(search_generated));
|
| + net::QueryIterator it(search_generated);
|
| + ASSERT_FALSE(it.IsAtEnd());
|
| + EXPECT_EQ(google_util::kInstantExtendedAPIParam, it.GetKey());
|
| +}
|
|
|