OLD | NEW |
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 Loading... |
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 1138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1190 AutocompleteInput::HOMEPAGE; | 1190 AutocompleteInput::HOMEPAGE; |
1191 result = url.url_ref().ReplaceSearchTerms(search_terms_args); | 1191 result = url.url_ref().ReplaceSearchTerms(search_terms_args); |
1192 EXPECT_EQ("http://www.google.com/?pgcl=3&q=foo", result); | 1192 EXPECT_EQ("http://www.google.com/?pgcl=3&q=foo", result); |
1193 } | 1193 } |
1194 | 1194 |
1195 // Test the IsSearchResults function. | 1195 // Test the IsSearchResults function. |
1196 TEST_F(TemplateURLTest, IsSearchResults) { | 1196 TEST_F(TemplateURLTest, IsSearchResults) { |
1197 TemplateURLData data; | 1197 TemplateURLData data; |
1198 data.SetURL("http://bar/search?q={searchTerms}"); | 1198 data.SetURL("http://bar/search?q={searchTerms}"); |
1199 data.instant_url = "http://bar/instant#q={searchTerms}"; | 1199 data.instant_url = "http://bar/instant#q={searchTerms}"; |
| 1200 data.new_tab_url = "http://bar/newtab"; |
1200 data.alternate_urls.push_back("http://bar/?q={searchTerms}"); | 1201 data.alternate_urls.push_back("http://bar/?q={searchTerms}"); |
1201 data.alternate_urls.push_back("http://bar/#q={searchTerms}"); | 1202 data.alternate_urls.push_back("http://bar/#q={searchTerms}"); |
1202 data.alternate_urls.push_back("http://bar/search#q{searchTerms}"); | 1203 data.alternate_urls.push_back("http://bar/search#q{searchTerms}"); |
1203 data.alternate_urls.push_back("http://bar/webhp#q={searchTerms}"); | 1204 data.alternate_urls.push_back("http://bar/webhp#q={searchTerms}"); |
1204 TemplateURL search_provider(NULL, data); | 1205 TemplateURL search_provider(NULL, data); |
1205 | 1206 |
1206 const struct { | 1207 const struct { |
1207 const char* const url; | 1208 const char* const url; |
1208 bool result; | 1209 bool result; |
1209 } url_data[] = { | 1210 } url_data[] = { |
1210 { "http://bar/search?q=foo&oq=foo", true, }, | 1211 { "http://bar/search?q=foo&oq=foo", true, }, |
1211 { "http://bar/?q=foo&oq=foo", true, }, | 1212 { "http://bar/?q=foo&oq=foo", true, }, |
1212 { "http://bar/#output=search&q=foo&oq=foo", true, }, | 1213 { "http://bar/#output=search&q=foo&oq=foo", true, }, |
1213 { "http://bar/webhp#q=foo&oq=foo", true, }, | 1214 { "http://bar/webhp#q=foo&oq=foo", true, }, |
1214 { "http://bar/#q=foo&oq=foo", true, }, | 1215 { "http://bar/#q=foo&oq=foo", true, }, |
1215 { "http://bar/?ext=foo&q=foo#ref=bar", true, }, | 1216 { "http://bar/?ext=foo&q=foo#ref=bar", true, }, |
1216 { "http://bar/url?url=http://www.foo.com/&q=foo#ref=bar", false, }, | 1217 { "http://bar/url?url=http://www.foo.com/&q=foo#ref=bar", false, }, |
1217 { "http://bar/", false, }, | 1218 { "http://bar/", false, }, |
1218 { "http://foo/", false, }, | 1219 { "http://foo/", false, }, |
| 1220 { "http://bar/newtab", false, }, |
1219 }; | 1221 }; |
1220 | 1222 |
1221 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(url_data); ++i) { | 1223 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(url_data); ++i) { |
1222 EXPECT_EQ(url_data[i].result, | 1224 EXPECT_EQ(url_data[i].result, |
1223 search_provider.IsSearchURL(GURL(url_data[i].url))); | 1225 search_provider.IsSearchURL(GURL(url_data[i].url))); |
1224 } | 1226 } |
1225 } | 1227 } |
OLD | NEW |