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

Side by Side Diff: chrome/browser/search_engines/template_url_unittest.cc

Issue 22945004: InstantExtended: Add new_tab_url to TemplateURL. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Address comments. Created 7 years, 4 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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_util.h" 7 #include "base/strings/string_util.h"
8 #include "base/strings/utf_string_conversions.h" 8 #include "base/strings/utf_string_conversions.h"
9 #include "chrome/browser/browser_process.h" 9 #include "chrome/browser/browser_process.h"
10 #include "chrome/browser/rlz/rlz.h" 10 #include "chrome/browser/rlz/rlz.h"
(...skipping 20 matching lines...) Expand all
31 31
32 virtual std::string GoogleBaseURLValue() const OVERRIDE; 32 virtual std::string GoogleBaseURLValue() const OVERRIDE;
33 33
34 private: 34 private:
35 std::string google_base_url_; 35 std::string google_base_url_;
36 36
37 DISALLOW_COPY_AND_ASSIGN(TestSearchTermsData); 37 DISALLOW_COPY_AND_ASSIGN(TestSearchTermsData);
38 }; 38 };
39 39
40 TestSearchTermsData::TestSearchTermsData(const std::string& google_base_url) 40 TestSearchTermsData::TestSearchTermsData(const std::string& google_base_url)
41 : google_base_url_(google_base_url) { 41 : google_base_url_(google_base_url) {
42 } 42 }
43 43
44 std::string TestSearchTermsData::GoogleBaseURLValue() const { 44 std::string TestSearchTermsData::GoogleBaseURLValue() const {
45 return google_base_url_; 45 return google_base_url_;
46 } 46 }
47 47
48 // TemplateURLTest ------------------------------------------------------------ 48 // TemplateURLTest ------------------------------------------------------------
49 49
50 class TemplateURLTest : public testing::Test { 50 class TemplateURLTest : public testing::Test {
51 public: 51 public:
(...skipping 825 matching lines...) Expand 10 before | Expand all | Expand 10 after
877 } 877 }
878 878
879 TEST_F(TemplateURLTest, GetURLOnlyOneURL) { 879 TEST_F(TemplateURLTest, GetURLOnlyOneURL) {
880 TemplateURLData data; 880 TemplateURLData data;
881 data.SetURL("http://www.google.co.uk/"); 881 data.SetURL("http://www.google.co.uk/");
882 TemplateURL url(NULL, data); 882 TemplateURL url(NULL, data);
883 ASSERT_EQ(1U, url.URLCount()); 883 ASSERT_EQ(1U, url.URLCount());
884 EXPECT_EQ("http://www.google.co.uk/", url.GetURL(0)); 884 EXPECT_EQ("http://www.google.co.uk/", url.GetURL(0));
885 } 885 }
886 886
887 TEST_F(TemplateURLTest, GetURLWithNewTabURL) {
Peter Kasting 2013/08/14 23:21:45 TBH I probably wouldn't add this test. It's so lo
Jered 2013/08/15 16:44:03 Done.
888 TemplateURLData data;
889 data.SetURL("http://google.com/?q={searchTerms}");
890 data.new_tab_url = "http://google.com/newtab";
891 TemplateURL url(NULL, data);
892 EXPECT_EQ("http://google.com/newtab", url.new_tab_url());
893 }
894
887 TEST_F(TemplateURLTest, ExtractSearchTermsFromURL) { 895 TEST_F(TemplateURLTest, ExtractSearchTermsFromURL) {
888 TemplateURLData data; 896 TemplateURLData data;
889 data.SetURL("http://google.com/?q={searchTerms}"); 897 data.SetURL("http://google.com/?q={searchTerms}");
890 data.instant_url = "http://google.com/instant#q={searchTerms}"; 898 data.instant_url = "http://google.com/instant#q={searchTerms}";
891 data.alternate_urls.push_back("http://google.com/alt/#q={searchTerms}"); 899 data.alternate_urls.push_back("http://google.com/alt/#q={searchTerms}");
892 data.alternate_urls.push_back( 900 data.alternate_urls.push_back(
893 "http://google.com/alt/?ext=foo&q={searchTerms}#ref=bar"); 901 "http://google.com/alt/?ext=foo&q={searchTerms}#ref=bar");
894 TemplateURL url(NULL, data); 902 TemplateURL url(NULL, data);
895 string16 result; 903 string16 result;
896 904
(...skipping 293 matching lines...) Expand 10 before | Expand all | Expand 10 after
1190 AutocompleteInput::HOMEPAGE; 1198 AutocompleteInput::HOMEPAGE;
1191 result = url.url_ref().ReplaceSearchTerms(search_terms_args); 1199 result = url.url_ref().ReplaceSearchTerms(search_terms_args);
1192 EXPECT_EQ("http://www.google.com/?pgcl=3&q=foo", result); 1200 EXPECT_EQ("http://www.google.com/?pgcl=3&q=foo", result);
1193 } 1201 }
1194 1202
1195 // Test the IsSearchResults function. 1203 // Test the IsSearchResults function.
1196 TEST_F(TemplateURLTest, IsSearchResults) { 1204 TEST_F(TemplateURLTest, IsSearchResults) {
1197 TemplateURLData data; 1205 TemplateURLData data;
1198 data.SetURL("http://bar/search?q={searchTerms}"); 1206 data.SetURL("http://bar/search?q={searchTerms}");
1199 data.instant_url = "http://bar/instant#q={searchTerms}"; 1207 data.instant_url = "http://bar/instant#q={searchTerms}";
1208 data.new_tab_url = "http://bar/newtab";
1200 data.alternate_urls.push_back("http://bar/?q={searchTerms}"); 1209 data.alternate_urls.push_back("http://bar/?q={searchTerms}");
1201 data.alternate_urls.push_back("http://bar/#q={searchTerms}"); 1210 data.alternate_urls.push_back("http://bar/#q={searchTerms}");
1202 data.alternate_urls.push_back("http://bar/search#q{searchTerms}"); 1211 data.alternate_urls.push_back("http://bar/search#q{searchTerms}");
1203 data.alternate_urls.push_back("http://bar/webhp#q={searchTerms}"); 1212 data.alternate_urls.push_back("http://bar/webhp#q={searchTerms}");
1204 TemplateURL search_provider(NULL, data); 1213 TemplateURL search_provider(NULL, data);
1205 1214
1206 const struct { 1215 const struct {
1207 const char* const url; 1216 const char* const url;
1208 bool result; 1217 bool result;
1209 } url_data[] = { 1218 } url_data[] = {
1210 { "http://bar/search?q=foo&oq=foo", true, }, 1219 { "http://bar/search?q=foo&oq=foo", true, },
1211 { "http://bar/?q=foo&oq=foo", true, }, 1220 { "http://bar/?q=foo&oq=foo", true, },
1212 { "http://bar/#output=search&q=foo&oq=foo", true, }, 1221 { "http://bar/#output=search&q=foo&oq=foo", true, },
1213 { "http://bar/webhp#q=foo&oq=foo", true, }, 1222 { "http://bar/webhp#q=foo&oq=foo", true, },
1214 { "http://bar/#q=foo&oq=foo", true, }, 1223 { "http://bar/#q=foo&oq=foo", true, },
1215 { "http://bar/?ext=foo&q=foo#ref=bar", true, }, 1224 { "http://bar/?ext=foo&q=foo#ref=bar", true, },
1216 { "http://bar/url?url=http://www.foo.com/&q=foo#ref=bar", false, }, 1225 { "http://bar/url?url=http://www.foo.com/&q=foo#ref=bar", false, },
1217 { "http://bar/", false, }, 1226 { "http://bar/", false, },
1218 { "http://foo/", false, }, 1227 { "http://foo/", false, },
1228 { "http://bar/newtab", false, },
1219 }; 1229 };
1220 1230
1221 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(url_data); ++i) { 1231 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(url_data); ++i) {
1222 EXPECT_EQ(url_data[i].result, 1232 EXPECT_EQ(url_data[i].result,
1223 search_provider.IsSearchURL(GURL(url_data[i].url))); 1233 search_provider.IsSearchURL(GURL(url_data[i].url)));
1224 } 1234 }
1225 } 1235 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698