diff options
author | pkasting@chromium.org <pkasting@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-07-02 20:25:53 +0000 |
---|---|---|
committer | pkasting@chromium.org <pkasting@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-07-02 20:25:53 +0000 |
commit | 56fa29593af8afdbd286100f8e7e36acc96de8a8 (patch) | |
tree | 1289161c33b1a9c9450453fcb3d9fbdcad8c5c33 /chrome/browser/autocomplete/keyword_provider_unittest.cc | |
parent | 918104f95eff808cba4c4a4386866fc87efc27c6 (diff) | |
download | chromium_src-56fa29593af8afdbd286100f8e7e36acc96de8a8.zip chromium_src-56fa29593af8afdbd286100f8e7e36acc96de8a8.tar.gz chromium_src-56fa29593af8afdbd286100f8e7e36acc96de8a8.tar.bz2 |
Add --extra-search-query-params, which allows testers to pass additional query
params in the search and instant URLs of the default search provider.
BUG=254670
TEST=Run chrome with --extra-search-query-params="a=b&c=d" and note that omnibox search URLs now contain these flags (use about:omnibox to check this)
R=michaelbai@chromium.org, samarth@chromium.org, yfriedman@chromium.org
Review URL: https://codereview.chromium.org/18377002
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@209765 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/autocomplete/keyword_provider_unittest.cc')
-rw-r--r-- | chrome/browser/autocomplete/keyword_provider_unittest.cc | 46 |
1 files changed, 33 insertions, 13 deletions
diff --git a/chrome/browser/autocomplete/keyword_provider_unittest.cc b/chrome/browser/autocomplete/keyword_provider_unittest.cc index b5f4e4c..45b5ac9 100644 --- a/chrome/browser/autocomplete/keyword_provider_unittest.cc +++ b/chrome/browser/autocomplete/keyword_provider_unittest.cc @@ -2,12 +2,14 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +#include "base/command_line.h" #include "base/message_loop.h" #include "base/strings/utf_string_conversions.h" #include "chrome/browser/autocomplete/autocomplete_match.h" #include "chrome/browser/autocomplete/keyword_provider.h" #include "chrome/browser/search_engines/template_url.h" #include "chrome/browser/search_engines/template_url_service.h" +#include "chrome/common/chrome_switches.h" #include "chrome/test/base/testing_browser_process.h" #include "testing/gtest/include/gtest/gtest.h" #include "url/gurl.h" @@ -33,23 +35,25 @@ class KeywordProviderTest : public testing::Test { ResultType AutocompleteMatch::* member); protected: + static const TemplateURLService::Initializer kTestData[]; + scoped_refptr<KeywordProvider> kw_provider_; scoped_ptr<TemplateURLService> model_; }; -void KeywordProviderTest::SetUp() { - static const TemplateURLService::Initializer kTestKeywordData[] = { - { "aa", "aa.com?foo=%s", "aa" }, - { "aaaa", "http://aaaa/?aaaa=1&b=%s&c", "aaaa" }, - { "aaaaa", "%s", "aaaaa" }, - { "ab", "bogus URL %s", "ab" }, - { "weasel", "weasel%sweasel", "weasel" }, - { "www", " +%2B?=%sfoo ", "www" }, - { "z", "%s=z", "z" }, - }; +// static +const TemplateURLService::Initializer KeywordProviderTest::kTestData[] = { + { "aa", "aa.com?foo=%s", "aa" }, + { "aaaa", "http://aaaa/?aaaa=1&b=%s&c", "aaaa" }, + { "aaaaa", "%s", "aaaaa" }, + { "ab", "bogus URL %s", "ab" }, + { "weasel", "weasel%sweasel", "weasel" }, + { "www", " +%2B?=%sfoo ", "www" }, + { "z", "%s=z", "z" }, +}; - model_.reset(new TemplateURLService(kTestKeywordData, - arraysize(kTestKeywordData))); +void KeywordProviderTest::SetUp() { + model_.reset(new TemplateURLService(kTestData, arraysize(kTestData))); kw_provider_ = new KeywordProvider(NULL, model_.get()); } @@ -189,7 +193,7 @@ TEST_F(KeywordProviderTest, Contents) { }; RunTest<string16>(contents_cases, arraysize(contents_cases), - &AutocompleteMatch::contents); + &AutocompleteMatch::contents); } TEST_F(KeywordProviderTest, AddKeyword) { @@ -274,3 +278,19 @@ TEST_F(KeywordProviderTest, GetSubstitutingTemplateURLForInput) { EXPECT_EQ(cases[i].updated_cursor_position, input.cursor_position()); } } + +// If extra query params are specified on the command line, they should be +// reflected (only) in the default search provider's destination URL. +TEST_F(KeywordProviderTest, ExtraQueryParams) { + CommandLine::ForCurrentProcess()->AppendSwitchASCII( + switches::kExtraSearchQueryParams, "a=b"); + + test_data<GURL> url_cases[] = { + {ASCIIToUTF16("a 1 2 3"), 3, {GURL("aa.com?a=b&foo=1+2+3"), + GURL("bogus URL 1+2+3"), + GURL("http://aaaa/?aaaa=1&b=1+2+3&c")}}, + }; + + RunTest<GURL>(url_cases, arraysize(url_cases), + &AutocompleteMatch::destination_url); +} |