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

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: fix (legitimate) clang error Created 6 years, 6 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
« no previous file with comments | « chrome/browser/search_engines/template_url.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 18db3bb779b28ef381ba8eba39f19fd0b70e71ad..1bbf9e2fc3398fd10f058cfbf6cd153da3d9625b 100644
--- a/chrome/browser/search_engines/template_url_unittest.cc
+++ b/chrome/browser/search_engines/template_url_unittest.cc
@@ -7,11 +7,13 @@
#include "base/strings/string_number_conversions.h"
#include "base/strings/string_util.h"
#include "base/strings/utf_string_conversions.h"
+#include "chrome/browser/autocomplete/autocomplete_input.h"
#include "chrome/browser/browser_process.h"
#include "chrome/browser/rlz/rlz.h"
#include "chrome/browser/search_engines/search_terms_data.h"
#include "chrome/browser/search_engines/template_url.h"
#include "chrome/common/chrome_switches.h"
+#include "components/metrics/proto/omnibox_input_type.pb.h"
#include "testing/gtest/include/gtest/gtest.h"
#if defined(ENABLE_RLZ)
@@ -580,6 +582,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"),
+ metrics::OmniboxInputType::UNKNOWN,
+ "{google:baseURL}?{searchTerms}&{google:inputType}",
+ "http://www.google.com/?foo&oit=1&" },
+ { ASCIIToUTF16("foo"),
+ metrics::OmniboxInputType::URL,
+ "{google:baseURL}?{searchTerms}&{google:inputType}",
+ "http://www.google.com/?foo&oit=3&" },
+ { ASCIIToUTF16("foo"),
+ metrics::OmniboxInputType::FORCED_QUERY,
+ "{google:baseURL}?{searchTerms}&{google:inputType}",
+ "http://www.google.com/?foo&oit=5&" },
+ };
+ 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 {
« no previous file with comments | « 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