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/files/file_util.h" | 5 #include "base/files/file_util.h" |
6 #include "base/logging.h" | 6 #include "base/logging.h" |
7 #include "base/path_service.h" | 7 #include "base/path_service.h" |
8 #include "base/strings/utf_string_conversions.h" | 8 #include "base/strings/utf_string_conversions.h" |
9 #include "chrome/common/chrome_paths.h" | 9 #include "chrome/common/chrome_paths.h" |
10 #include "components/search_engines/search_terms_data.h" | 10 #include "components/search_engines/search_terms_data.h" |
11 #include "components/search_engines/template_url.h" | 11 #include "components/search_engines/template_url.h" |
12 #include "components/search_engines/template_url_parser.h" | 12 #include "components/search_engines/template_url_parser.h" |
13 #include "testing/gtest/include/gtest/gtest.h" | 13 #include "testing/gtest/include/gtest/gtest.h" |
14 | 14 |
15 using base::ASCIIToUTF16; | 15 using base::ASCIIToUTF16; |
16 | 16 |
17 // ParamFilterImpl ------------------------------------------------------------ | 17 // ParamFilterImpl ------------------------------------------------------------ |
18 | 18 |
19 // Filters any param which as an occurrence of name_str_ in its name or an | 19 // Filters any param which as an occurrence of name_str_ in its name or an |
20 // occurrence of value_str_ in its value. | 20 // occurrence of value_str_ in its value. |
21 class ParamFilterImpl : public TemplateURLParser::ParameterFilter { | 21 class ParamFilterImpl : public TemplateURLParser::ParameterFilter { |
22 public: | 22 public: |
23 ParamFilterImpl(std::string name_str, std::string value_str); | 23 ParamFilterImpl(std::string name_str, std::string value_str); |
24 virtual ~ParamFilterImpl(); | 24 virtual ~ParamFilterImpl(); |
25 | 25 |
26 virtual bool KeepParameter(const std::string& key, | 26 virtual bool KeepParameter(const std::string& key, |
27 const std::string& value) OVERRIDE; | 27 const std::string& value) override; |
28 | 28 |
29 private: | 29 private: |
30 std::string name_str_; | 30 std::string name_str_; |
31 std::string value_str_; | 31 std::string value_str_; |
32 | 32 |
33 DISALLOW_COPY_AND_ASSIGN(ParamFilterImpl); | 33 DISALLOW_COPY_AND_ASSIGN(ParamFilterImpl); |
34 }; | 34 }; |
35 | 35 |
36 ParamFilterImpl::ParamFilterImpl(std::string name_str, std::string value_str) | 36 ParamFilterImpl::ParamFilterImpl(std::string name_str, std::string value_str) |
37 : name_str_(name_str), | 37 : name_str_(name_str), |
(...skipping 10 matching lines...) Expand all Loading... |
48 } | 48 } |
49 | 49 |
50 | 50 |
51 // TemplateURLParserTest ------------------------------------------------------ | 51 // TemplateURLParserTest ------------------------------------------------------ |
52 | 52 |
53 class TemplateURLParserTest : public testing::Test { | 53 class TemplateURLParserTest : public testing::Test { |
54 protected: | 54 protected: |
55 TemplateURLParserTest(); | 55 TemplateURLParserTest(); |
56 virtual ~TemplateURLParserTest(); | 56 virtual ~TemplateURLParserTest(); |
57 | 57 |
58 virtual void SetUp() OVERRIDE; | 58 virtual void SetUp() override; |
59 | 59 |
60 bool is_disabled() const; | 60 bool is_disabled() const; |
61 | 61 |
62 // Parses the OpenSearch description document at file_name (relative to the | 62 // Parses the OpenSearch description document at file_name (relative to the |
63 // data dir). The TemplateURL is placed in |template_url_|. | 63 // data dir). The TemplateURL is placed in |template_url_|. |
64 void ParseFile(const std::string& file_name, | 64 void ParseFile(const std::string& file_name, |
65 TemplateURLParser::ParameterFilter* filter); | 65 TemplateURLParser::ParameterFilter* filter); |
66 | 66 |
67 // ParseFile parses the results into this template_url. | 67 // ParseFile parses the results into this template_url. |
68 scoped_ptr<TemplateURL> template_url_; | 68 scoped_ptr<TemplateURL> template_url_; |
(...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
254 EXPECT_EQ(ASCIIToUTF16("Yahoo"), template_url_->short_name()); | 254 EXPECT_EQ(ASCIIToUTF16("Yahoo"), template_url_->short_name()); |
255 EXPECT_TRUE(template_url_->url_ref().SupportsReplacement(SearchTermsData())); | 255 EXPECT_TRUE(template_url_->url_ref().SupportsReplacement(SearchTermsData())); |
256 EXPECT_TRUE(template_url_->suggestions_url().empty()); | 256 EXPECT_TRUE(template_url_->suggestions_url().empty()); |
257 EXPECT_EQ("http://search.yahoo.com/search?p={searchTerms}&ei=UTF-8", | 257 EXPECT_EQ("http://search.yahoo.com/search?p={searchTerms}&ei=UTF-8", |
258 template_url_->url()); | 258 template_url_->url()); |
259 ASSERT_EQ(1U, template_url_->input_encodings().size()); | 259 ASSERT_EQ(1U, template_url_->input_encodings().size()); |
260 EXPECT_EQ("UTF-8", template_url_->input_encodings()[0]); | 260 EXPECT_EQ("UTF-8", template_url_->input_encodings()[0]); |
261 EXPECT_EQ(GURL("http://search.yahoo.com/favicon.ico"), | 261 EXPECT_EQ(GURL("http://search.yahoo.com/favicon.ico"), |
262 template_url_->favicon_url()); | 262 template_url_->favicon_url()); |
263 } | 263 } |
OLD | NEW |