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

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

Issue 17022004: Replace --google-base-suggest-url and --instant-url with --google-base-url. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 7 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_service.cc ('k') | chrome/browser/search_engines/util.h » ('j') | 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
===================================================================
--- chrome/browser/search_engines/template_url_unittest.cc (revision 208572)
+++ chrome/browser/search_engines/template_url_unittest.cc (working copy)
@@ -3,12 +3,14 @@
// found in the LICENSE file.
#include "base/base_paths.h"
+#include "base/command_line.h"
#include "base/strings/string_util.h"
#include "base/strings/utf_string_conversions.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 "testing/gtest/include/gtest/gtest.h"
#if defined(ENABLE_RLZ)
@@ -1032,3 +1034,38 @@
GURL("http://google.com/alt/?q=#q=123"), search_terms, &result));
EXPECT_EQ(GURL("http://google.com/alt/?q=#q=Bob Morane"), result);
}
+
+// Test the |append_extra_query_params| field of SearchTermsArgs.
+TEST_F(TemplateURLTest, ExtraQueryParams) {
+ UIThreadSearchTermsData::SetGoogleBaseURL("http://www.google.com/");
+ TemplateURLData data;
+ // Pick a URL with replacements before, during, and after the query, to ensure
+ // we don't goof up any of them.
+ data.SetURL("{google:baseURL}search?q={searchTerms}"
+ "#{google:originalQueryForSuggestion}x");
+ TemplateURL url(NULL, data);
+
+ // Baseline: no command-line args, no |append_extra_query_params| flag.
+ TemplateURLRef::SearchTermsArgs search_terms(ASCIIToUTF16("abc"));
+ search_terms.original_query = ASCIIToUTF16("def");
+ search_terms.accepted_suggestion = 0;
+ EXPECT_EQ("http://www.google.com/search?q=abc#oq=def&x",
+ url.url_ref().ReplaceSearchTerms(search_terms));
+
+ // Set the flag. Since there are no command-line args, this should have no
+ // effect.
+ search_terms.append_extra_query_params = true;
+ EXPECT_EQ("http://www.google.com/search?q=abc#oq=def&x",
+ url.url_ref().ReplaceSearchTerms(search_terms));
+
+ // Now append the command-line arg. This should be inserted into the query.
+ CommandLine::ForCurrentProcess()->AppendSwitchASCII(
+ switches::kExtraSearchQueryParams, "a=b");
+ EXPECT_EQ("http://www.google.com/search?a=b&q=abc#oq=def&x",
+ url.url_ref().ReplaceSearchTerms(search_terms));
+
+ // Turn off the flag. Now the command-line arg should be ignored again.
+ search_terms.append_extra_query_params = false;
+ EXPECT_EQ("http://www.google.com/search?q=abc#oq=def&x",
+ url.url_ref().ReplaceSearchTerms(search_terms));
+}
« no previous file with comments | « chrome/browser/search_engines/template_url_service.cc ('k') | chrome/browser/search_engines/util.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698