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

Unified Diff: chrome/common/instant_types_unittest.cc

Issue 609493002: Propagate the search request params from the browser to the Instant search base page to fix the embe (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase Created 6 years, 1 month 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/common/instant_types.cc ('k') | chrome/common/render_messages.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/common/instant_types_unittest.cc
diff --git a/chrome/common/instant_types_unittest.cc b/chrome/common/instant_types_unittest.cc
new file mode 100644
index 0000000000000000000000000000000000000000..47ebebdfd7fa92d66d47c9efaa467fb5419d5bfe
--- /dev/null
+++ b/chrome/common/instant_types_unittest.cc
@@ -0,0 +1,69 @@
+// Copyright 2014 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "chrome/common/instant_types.h"
+
+#include "base/strings/utf_string_conversions.h"
+#include "testing/gtest/include/gtest/gtest.h"
+
+struct TestData {
+ const char* search_request_url;
+ const char* expected_search_query;
+ const char* expected_original_query;
+ const char* expected_rlz_param;
+ const char* expected_input_encoding;
+ const char* expected_assisted_query_stats;
+};
+
+TEST(EmbeddedSearchRequestParams, ExtractParams) {
+ TestData cases[] = {
+ {"https://foo/search?q=google&oq=g&rlz=30ls&ie=utf-8&aqs=chrome..6l5.j04",
+ "google",
+ "g",
+ "30ls",
+ "utf-8",
+ "chrome..6l5.j04"
+ },
+ // Do not populate "rlz" param.
+ {"https://foo/search?q=google%20j&oq=g&ie=utf-8&aqs=chrome.2.65.j04",
+ "google j",
+ "g",
+ "",
+ "utf-8",
+ "chrome.2.65.j04"
+ },
+ // Unescape search query.
+ {"https://foo/search?q=google+j&oq=g&rlz=30&ie=utf-8&aqs=chrome.2.65.j04",
+ "google j",
+ "g",
+ "30",
+ "utf-8",
+ "chrome.2.65.j04"
+ },
+ // Unescape original query.
+ {"https://foo/search?q=g+j%20j&oq=g+j&rlz=30&ie=utf-8&aqs=chrome.2.65.j04",
+ "g j j",
+ "g j",
+ "30",
+ "utf-8",
+ "chrome.2.65.j04"
+ },
+ };
+
+ for (size_t i = 0; i < arraysize(cases); ++i) {
+ EmbeddedSearchRequestParams params(GURL(cases[i].search_request_url));
+ EXPECT_EQ(cases[i].expected_search_query,
+ base::UTF16ToASCII(params.search_query)) << "For index: " << i;
+ EXPECT_EQ(cases[i].expected_original_query,
+ base::UTF16ToASCII(params.original_query)) << "For index: " << i;
+ EXPECT_EQ(cases[i].expected_rlz_param,
+ base::UTF16ToASCII(params.rlz_parameter_value)) <<
+ "For index: " << i;
+ EXPECT_EQ(cases[i].expected_input_encoding,
+ base::UTF16ToASCII(params.input_encoding)) << "For index: " << i;
+ EXPECT_EQ(cases[i].expected_assisted_query_stats,
+ base::UTF16ToASCII(params.assisted_query_stats)) <<
+ "For index: " << i;
+ }
+}
« no previous file with comments | « chrome/common/instant_types.cc ('k') | chrome/common/render_messages.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698