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/file_util.h" | 5 #include "base/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/browser/search_engines/template_url_parser.h" | 9 #include "chrome/browser/search_engines/template_url_parser.h" |
10 #include "chrome/common/chrome_paths.h" | 10 #include "chrome/common/chrome_paths.h" |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
95 const std::string& file_name, | 95 const std::string& file_name, |
96 TemplateURLParser::ParameterFilter* filter) { | 96 TemplateURLParser::ParameterFilter* filter) { |
97 base::FilePath full_path; | 97 base::FilePath full_path; |
98 ASSERT_TRUE(PathService::Get(chrome::DIR_TEST_DATA, &full_path)); | 98 ASSERT_TRUE(PathService::Get(chrome::DIR_TEST_DATA, &full_path)); |
99 full_path = full_path.AppendASCII("osdd"); | 99 full_path = full_path.AppendASCII("osdd"); |
100 full_path = full_path.AppendASCII(file_name); | 100 full_path = full_path.AppendASCII(file_name); |
101 ASSERT_TRUE(base::PathExists(full_path)); | 101 ASSERT_TRUE(base::PathExists(full_path)); |
102 | 102 |
103 std::string contents; | 103 std::string contents; |
104 ASSERT_TRUE(base::ReadFileToString(full_path, &contents)); | 104 ASSERT_TRUE(base::ReadFileToString(full_path, &contents)); |
105 template_url_.reset(TemplateURLParser::Parse(NULL, false, contents.data(), | 105 template_url_.reset(TemplateURLParser::Parse( |
106 contents.length(), filter)); | 106 SearchTermsData(), false, contents.data(), contents.length(), filter)); |
107 } | 107 } |
108 | 108 |
109 | 109 |
110 // Actual tests --------------------------------------------------------------- | 110 // Actual tests --------------------------------------------------------------- |
111 | 111 |
112 TEST_F(TemplateURLParserTest, FailOnBogusURL) { | 112 TEST_F(TemplateURLParserTest, FailOnBogusURL) { |
113 if (is_disabled()) | 113 if (is_disabled()) |
114 return; | 114 return; |
115 ASSERT_NO_FATAL_FAILURE(ParseFile("bogus.xml", NULL)); | 115 ASSERT_NO_FATAL_FAILURE(ParseFile("bogus.xml", NULL)); |
116 EXPECT_FALSE(template_url_.get()); | 116 EXPECT_FALSE(template_url_.get()); |
(...skipping 137 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 |