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

Unified Diff: chrome/browser/search_engines/template_url_unittest.cc

Issue 314773002: Omnibox: Send Input Type to Suggest Server (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 7 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/search_engines/template_url_unittest.cc
diff --git a/chrome/browser/search_engines/template_url_unittest.cc b/chrome/browser/search_engines/template_url_unittest.cc
index 626b5eb2aabe7fcb3b2ed1604cf20c994098464b..de9988e7c52227c9a3e88196f3a2eeb0e0dc7c74 100644
--- a/chrome/browser/search_engines/template_url_unittest.cc
+++ b/chrome/browser/search_engines/template_url_unittest.cc
@@ -581,6 +581,43 @@ TEST_F(TemplateURLTest, ReplaceCursorPosition) {
}
}
+// Tests replacing input type (&oit=).
+TEST_F(TemplateURLTest, ReplaceInputType) {
+ struct TestData {
+ const base::string16 search_term;
+ AutocompleteInput::Type input_type;
+ const std::string url;
+ const std::string expected_result;
+ } test_data[] = {
+ { ASCIIToUTF16("foo"),
+ AutocompleteInput::UNKNOWN,
+ "{google:baseURL}?{searchTerms}&{google:inputType}",
+ "http://www.google.com/?foo&oit=1&" },
+ { ASCIIToUTF16("foo"),
+ AutocompleteInput::URL,
+ "{google:baseURL}?{searchTerms}&{google:inputType}",
+ "http://www.google.com/?foo&oit=2&" },
+ { ASCIIToUTF16("foo"),
+ AutocompleteInput::FORCED_QUERY,
+ "{google:baseURL}?{searchTerms}&{google:inputType}",
+ "http://www.google.com/?foo&oit=4&" },
+ };
+ UIThreadSearchTermsData::SetGoogleBaseURL("http://www.google.com/");
+ TemplateURLData data;
+ data.input_encodings.push_back("UTF-8");
+ for (size_t i = 0; i < ARRAYSIZE_UNSAFE(test_data); ++i) {
+ data.SetURL(test_data[i].url);
+ TemplateURL url(NULL, data);
+ EXPECT_TRUE(url.url_ref().IsValid());
+ ASSERT_TRUE(url.url_ref().SupportsReplacement());
+ TemplateURLRef::SearchTermsArgs search_terms_args(test_data[i].search_term);
+ search_terms_args.input_type = test_data[i].input_type;
+ GURL result(url.url_ref().ReplaceSearchTerms(search_terms_args));
+ ASSERT_TRUE(result.is_valid());
+ EXPECT_EQ(test_data[i].expected_result, result.spec());
+ }
+}
+
// Tests replacing currentPageUrl.
TEST_F(TemplateURLTest, ReplaceCurrentPageUrl) {
struct TestData {
« chrome/browser/search_engines/template_url.h ('K') | « chrome/browser/search_engines/template_url.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698