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/macros.h" | 7 #include "base/macros.h" |
8 #include "base/path_service.h" | 8 #include "base/path_service.h" |
9 #include "base/strings/utf_string_conversions.h" | 9 #include "base/strings/utf_string_conversions.h" |
10 #include "chrome/common/chrome_paths.h" | 10 #include "chrome/common/chrome_paths.h" |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
94 const std::string& file_name, | 94 const std::string& file_name, |
95 TemplateURLParser::ParameterFilter* filter) { | 95 TemplateURLParser::ParameterFilter* filter) { |
96 base::FilePath full_path; | 96 base::FilePath full_path; |
97 ASSERT_TRUE(PathService::Get(chrome::DIR_TEST_DATA, &full_path)); | 97 ASSERT_TRUE(PathService::Get(chrome::DIR_TEST_DATA, &full_path)); |
98 full_path = full_path.AppendASCII("osdd"); | 98 full_path = full_path.AppendASCII("osdd"); |
99 full_path = full_path.AppendASCII(file_name); | 99 full_path = full_path.AppendASCII(file_name); |
100 ASSERT_TRUE(base::PathExists(full_path)); | 100 ASSERT_TRUE(base::PathExists(full_path)); |
101 | 101 |
102 std::string contents; | 102 std::string contents; |
103 ASSERT_TRUE(base::ReadFileToString(full_path, &contents)); | 103 ASSERT_TRUE(base::ReadFileToString(full_path, &contents)); |
104 template_url_ = TemplateURLParser::Parse( | 104 template_url_ = TemplateURLParser::Parse(SearchTermsData(), contents.data(), |
105 SearchTermsData(), false, contents.data(), contents.length(), filter); | 105 contents.length(), filter); |
106 } | 106 } |
107 | 107 |
108 | 108 |
109 // Actual tests --------------------------------------------------------------- | 109 // Actual tests --------------------------------------------------------------- |
110 | 110 |
111 TEST_F(TemplateURLParserTest, FailOnBogusURL) { | 111 TEST_F(TemplateURLParserTest, FailOnBogusURL) { |
112 if (is_disabled()) | 112 if (is_disabled()) |
113 return; | 113 return; |
114 ASSERT_NO_FATAL_FAILURE(ParseFile("bogus.xml", NULL)); | 114 ASSERT_NO_FATAL_FAILURE(ParseFile("bogus.xml", NULL)); |
115 EXPECT_FALSE(template_url_.get()); | 115 EXPECT_FALSE(template_url_.get()); |
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
253 EXPECT_EQ(ASCIIToUTF16("Yahoo"), template_url_->short_name()); | 253 EXPECT_EQ(ASCIIToUTF16("Yahoo"), template_url_->short_name()); |
254 EXPECT_TRUE(template_url_->url_ref().SupportsReplacement(SearchTermsData())); | 254 EXPECT_TRUE(template_url_->url_ref().SupportsReplacement(SearchTermsData())); |
255 EXPECT_TRUE(template_url_->suggestions_url().empty()); | 255 EXPECT_TRUE(template_url_->suggestions_url().empty()); |
256 EXPECT_EQ("http://search.yahoo.com/search?p={searchTerms}&ei=UTF-8", | 256 EXPECT_EQ("http://search.yahoo.com/search?p={searchTerms}&ei=UTF-8", |
257 template_url_->url()); | 257 template_url_->url()); |
258 ASSERT_EQ(1U, template_url_->input_encodings().size()); | 258 ASSERT_EQ(1U, template_url_->input_encodings().size()); |
259 EXPECT_EQ("UTF-8", template_url_->input_encodings()[0]); | 259 EXPECT_EQ("UTF-8", template_url_->input_encodings()[0]); |
260 EXPECT_EQ(GURL("http://search.yahoo.com/favicon.ico"), | 260 EXPECT_EQ(GURL("http://search.yahoo.com/favicon.ico"), |
261 template_url_->favicon_url()); | 261 template_url_->favicon_url()); |
262 } | 262 } |
OLD | NEW |