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

Side by Side Diff: components/search_engines/template_url_unittest.cc

Issue 1224083010: Enable Answers in Suggest always. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Respond to comment Created 5 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 unified diff | Download patch
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "base/base_paths.h" 5 #include "base/base_paths.h"
6 #include "base/command_line.h" 6 #include "base/command_line.h"
7 #include "base/strings/string_number_conversions.h" 7 #include "base/strings/string_number_conversions.h"
8 #include "base/strings/string_util.h" 8 #include "base/strings/string_util.h"
9 #include "base/strings/utf_string_conversions.h" 9 #include "base/strings/utf_string_conversions.h"
10 #include "components/metrics/proto/omnibox_event.pb.h" 10 #include "components/metrics/proto/omnibox_event.pb.h"
(...skipping 1613 matching lines...) Expand 10 before | Expand all | Expand 10 after
1624 search_terms_data_); 1624 search_terms_data_);
1625 EXPECT_EQ("http://www.google.com/?bmbp=0&q=foo", result); 1625 EXPECT_EQ("http://www.google.com/?bmbp=0&q=foo", result);
1626 1626
1627 search_terms_data_.set_is_showing_search_terms_on_search_results_pages(true); 1627 search_terms_data_.set_is_showing_search_terms_on_search_results_pages(true);
1628 search_terms_args.bookmark_bar_pinned = true; 1628 search_terms_args.bookmark_bar_pinned = true;
1629 result = url.url_ref().ReplaceSearchTerms(search_terms_args, 1629 result = url.url_ref().ReplaceSearchTerms(search_terms_args,
1630 search_terms_data_); 1630 search_terms_data_);
1631 EXPECT_EQ("http://www.google.com/?bmbp=1&q=foo", result); 1631 EXPECT_EQ("http://www.google.com/?bmbp=1&q=foo", result);
1632 } 1632 }
1633 1633
1634 TEST_F(TemplateURLTest, AnswersHasVersion) { 1634 TEST_F(TemplateURLTest, SearchboxVersionIncludedForAnswers) {
1635 TemplateURLData data; 1635 TemplateURLData data;
1636 search_terms_data_.set_google_base_url("http://bar/"); 1636 search_terms_data_.set_google_base_url("http://bar/");
1637 data.SetURL("http://bar/search?q={searchTerms}&{google:searchVersion}xssi=t"); 1637 data.SetURL("http://bar/search?q={searchTerms}&{google:searchVersion}xssi=t");
1638 1638
1639 TemplateURL url(data); 1639 TemplateURL url(data);
1640 TemplateURLRef::SearchTermsArgs search_terms_args(ASCIIToUTF16("foo")); 1640 TemplateURLRef::SearchTermsArgs search_terms_args(ASCIIToUTF16("foo"));
1641 std::string result = url.url_ref().ReplaceSearchTerms(search_terms_args, 1641 std::string result = url.url_ref().ReplaceSearchTerms(search_terms_args,
1642 search_terms_data_); 1642 search_terms_data_);
1643 EXPECT_EQ("http://bar/search?q=foo&xssi=t", result);
1644
1645 search_terms_data_.set_enable_answers_in_suggest(true);
1646 TemplateURL url2(data);
1647 result = url2.url_ref().ReplaceSearchTerms(search_terms_args,
1648 search_terms_data_);
1649 EXPECT_EQ("http://bar/search?q=foo&gs_rn=42&xssi=t", result); 1643 EXPECT_EQ("http://bar/search?q=foo&gs_rn=42&xssi=t", result);
1650 } 1644 }
1651 1645
1652 TEST_F(TemplateURLTest, SessionToken) { 1646 TEST_F(TemplateURLTest, SessionToken) {
1653 TemplateURLData data; 1647 TemplateURLData data;
1654 search_terms_data_.set_google_base_url("http://bar/"); 1648 search_terms_data_.set_google_base_url("http://bar/");
1655 data.SetURL("http://bar/search?q={searchTerms}&{google:sessionToken}xssi=t"); 1649 data.SetURL("http://bar/search?q={searchTerms}&{google:sessionToken}xssi=t");
1656 1650
1657 TemplateURL url(data); 1651 TemplateURL url(data);
1658 TemplateURLRef::SearchTermsArgs search_terms_args(ASCIIToUTF16("foo")); 1652 TemplateURLRef::SearchTermsArgs search_terms_args(ASCIIToUTF16("foo"));
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
1749 EXPECT_EQ("http://bar/search?q=foo&pfq=full%20query%20text&qha=2338&xssi=t", 1743 EXPECT_EQ("http://bar/search?q=foo&pfq=full%20query%20text&qha=2338&xssi=t",
1750 result); 1744 result);
1751 1745
1752 TemplateURL url2(data); 1746 TemplateURL url2(data);
1753 search_terms_args.prefetch_query.clear(); 1747 search_terms_args.prefetch_query.clear();
1754 search_terms_args.prefetch_query_type.clear(); 1748 search_terms_args.prefetch_query_type.clear();
1755 result = 1749 result =
1756 url2.url_ref().ReplaceSearchTerms(search_terms_args, search_terms_data_); 1750 url2.url_ref().ReplaceSearchTerms(search_terms_args, search_terms_data_);
1757 EXPECT_EQ("http://bar/search?q=foo&xssi=t", result); 1751 EXPECT_EQ("http://bar/search?q=foo&xssi=t", result);
1758 } 1752 }
OLDNEW
« no previous file with comments | « components/search_engines/template_url.cc ('k') | components/search_engines/testing_search_terms_data.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698