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

Unified Diff: components/search_engines/template_url_unittest.cc

Issue 396583002: Stop depending on InstantService from BaseSearchProvider (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 5 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 | « components/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: components/search_engines/template_url_unittest.cc
diff --git a/components/search_engines/template_url_unittest.cc b/components/search_engines/template_url_unittest.cc
index f591afc2b11b0752a45f9dca0e7f257c2dd310d4..7056535667c249f52d6d6abfa9ffee9916bbc7ff 100644
--- a/components/search_engines/template_url_unittest.cc
+++ b/components/search_engines/template_url_unittest.cc
@@ -30,6 +30,7 @@ class TestSearchTermsData : public SearchTermsData {
virtual std::string GoogleImageSearchSource() const OVERRIDE;
virtual bool EnableAnswersInSuggest() const OVERRIDE;
virtual bool IsShowingSearchTermsOnSearchResultsPages() const OVERRIDE;
+ virtual int OmniboxStartMargin() const OVERRIDE;
void set_google_base_url(const std::string& google_base_url) {
google_base_url_ = google_base_url;
@@ -43,12 +44,16 @@ class TestSearchTermsData : public SearchTermsData {
void set_is_showing_search_terms_on_search_results_pages(bool value) {
is_showing_search_terms_on_search_results_pages_ = value;
}
+ void set_omnibox_start_margin(int omnibox_start_margin) {
+ omnibox_start_margin_ = omnibox_start_margin;
+ }
private:
std::string google_base_url_;
std::string search_client_;
bool enable_answers_in_suggest_;
bool is_showing_search_terms_on_search_results_pages_;
+ int omnibox_start_margin_;
DISALLOW_COPY_AND_ASSIGN(TestSearchTermsData);
};
@@ -85,6 +90,10 @@ bool TestSearchTermsData::IsShowingSearchTermsOnSearchResultsPages() const {
return is_showing_search_terms_on_search_results_pages_;
}
+int TestSearchTermsData::OmniboxStartMargin() const {
+ return omnibox_start_margin_;
+}
+
// TemplateURLTest ------------------------------------------------------------
class TemplateURLTest : public testing::Test {
@@ -705,6 +714,42 @@ TEST_F(TemplateURLTest, ReplaceCurrentPageUrl) {
}
}
+TEST_F(TemplateURLTest, OmniboxStartmargin) {
+ struct TestData {
+ const bool enable_omnibox_start_margin;
+ const int omnibox_start_margin;
+ const std::string expected_result;
+ } test_data[] = {
+ { false,
+ 0,
+ "http://bar/foo?q=foobar" },
+ { true,
+ 0,
+ "http://bar/foo?es_sm=0&q=foobar" },
+ { true,
+ 42,
+ "http://bar/foo?es_sm=42&q=foobar" },
+ };
+ TemplateURLData data;
+ data.SetURL("http://bar/foo?{google:omniboxStartMarginParameter}"
+ "q={searchTerms}");
+ data.input_encodings.push_back("UTF-8");
+ TemplateURL url(data);
+ EXPECT_TRUE(url.url_ref().IsValid(search_terms_data_));
+ ASSERT_TRUE(url.url_ref().SupportsReplacement(search_terms_data_));
+ for (size_t i = 0; i < ARRAYSIZE_UNSAFE(test_data); ++i) {
+ TemplateURLRef::SearchTermsArgs search_terms_args(ASCIIToUTF16("foobar"));
+ search_terms_args.enable_omnibox_start_margin =
+ test_data[i].enable_omnibox_start_margin;
+ search_terms_data_.set_omnibox_start_margin(
+ test_data[i].omnibox_start_margin);
+ GURL result(url.url_ref().ReplaceSearchTerms(search_terms_args,
+ search_terms_data_));
+ ASSERT_TRUE(result.is_valid());
+ EXPECT_EQ(test_data[i].expected_result, result.spec());
+ }
+}
+
TEST_F(TemplateURLTest, Suggestions) {
struct TestData {
const int accepted_suggestion;
« no previous file with comments | « components/search_engines/template_url.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698