OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/utf_string_conversions.h" | 8 #include "base/utf_string_conversions.h" |
9 #include "chrome/browser/search_engines/template_url.h" | 9 #include "chrome/browser/search_engines/template_url.h" |
10 #include "chrome/browser/search_engines/template_url_parser.h" | 10 #include "chrome/browser/search_engines/template_url_parser.h" |
11 #include "chrome/common/chrome_paths.h" | 11 #include "chrome/common/chrome_paths.h" |
12 #include "testing/gtest/include/gtest/gtest.h" | 12 #include "testing/gtest/include/gtest/gtest.h" |
13 | 13 |
| 14 #if defined(TOUCH_UI) |
| 15 // Tests that fail on touch .. http://crbug/84855 |
| 16 #define MAYBE_TestDictionary FAILS_TestDictionary |
| 17 #define MAYBE_TestMSDN FAILS_TestMSDN |
| 18 #define MAYBE_TestWikipedia FAILS_TestWikipedia |
| 19 #else |
| 20 #define MAYBE_TestDictionary TestDictionary |
| 21 #define MAYBE_TestMSDN TestMSDN |
| 22 #define MAYBE_TestWikipedia TestWikipedia |
| 23 #endif |
| 24 |
| 25 |
14 class TemplateURLParserTest : public testing::Test { | 26 class TemplateURLParserTest : public testing::Test { |
15 public: | 27 public: |
16 TemplateURLParserTest() : parse_result_(true) { | 28 TemplateURLParserTest() : parse_result_(true) { |
17 } | 29 } |
18 | 30 |
19 virtual void SetUp() { | 31 virtual void SetUp() { |
20 ASSERT_TRUE(PathService::Get(chrome::DIR_TEST_DATA, &full_path_)); | 32 ASSERT_TRUE(PathService::Get(chrome::DIR_TEST_DATA, &full_path_)); |
21 full_path_ = full_path_.AppendASCII("osdd"); | 33 full_path_ = full_path_.AppendASCII("osdd"); |
22 if (!file_util::PathExists(full_path_)) { | 34 if (!file_util::PathExists(full_path_)) { |
23 LOG(ERROR) << | 35 LOG(ERROR) << |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
73 EXPECT_TRUE(parse_result_); | 85 EXPECT_TRUE(parse_result_); |
74 } | 86 } |
75 | 87 |
76 TEST_F(TemplateURLParserTest, FailOnPost) { | 88 TEST_F(TemplateURLParserTest, FailOnPost) { |
77 if (IsDisabled()) | 89 if (IsDisabled()) |
78 return; | 90 return; |
79 ParseFile("post.xml", NULL); | 91 ParseFile("post.xml", NULL); |
80 EXPECT_FALSE(parse_result_); | 92 EXPECT_FALSE(parse_result_); |
81 } | 93 } |
82 | 94 |
83 TEST_F(TemplateURLParserTest, TestDictionary) { | 95 TEST_F(TemplateURLParserTest, MAYBE_TestDictionary) { |
84 if (IsDisabled()) | 96 if (IsDisabled()) |
85 return; | 97 return; |
86 ParseFile("dictionary.xml", NULL); | 98 ParseFile("dictionary.xml", NULL); |
87 ASSERT_TRUE(parse_result_); | 99 ASSERT_TRUE(parse_result_); |
88 EXPECT_EQ(ASCIIToUTF16("Dictionary.com"), template_url_.short_name()); | 100 EXPECT_EQ(ASCIIToUTF16("Dictionary.com"), template_url_.short_name()); |
89 EXPECT_TRUE(template_url_.GetFaviconURL() == | 101 EXPECT_TRUE(template_url_.GetFaviconURL() == |
90 GURL("http://cache.lexico.com/g/d/favicon.ico")); | 102 GURL("http://cache.lexico.com/g/d/favicon.ico")); |
91 EXPECT_TRUE(template_url_.url() != NULL); | 103 EXPECT_TRUE(template_url_.url() != NULL); |
92 EXPECT_TRUE(template_url_.url()->SupportsReplacement()); | 104 EXPECT_TRUE(template_url_.url()->SupportsReplacement()); |
93 EXPECT_EQ(template_url_.url()->url(), | 105 EXPECT_EQ(template_url_.url()->url(), |
94 "http://dictionary.reference.com/browse/{searchTerms}?r=75"); | 106 "http://dictionary.reference.com/browse/{searchTerms}?r=75"); |
95 } | 107 } |
96 | 108 |
97 TEST_F(TemplateURLParserTest, TestMSDN) { | 109 TEST_F(TemplateURLParserTest, MAYBE_TestMSDN) { |
98 if (IsDisabled()) | 110 if (IsDisabled()) |
99 return; | 111 return; |
100 ParseFile("msdn.xml", NULL); | 112 ParseFile("msdn.xml", NULL); |
101 ASSERT_TRUE(parse_result_); | 113 ASSERT_TRUE(parse_result_); |
102 EXPECT_EQ(ASCIIToUTF16("Search \" MSDN"), template_url_.short_name()); | 114 EXPECT_EQ(ASCIIToUTF16("Search \" MSDN"), template_url_.short_name()); |
103 EXPECT_TRUE(template_url_.GetFaviconURL() == | 115 EXPECT_TRUE(template_url_.GetFaviconURL() == |
104 GURL("http://search.msdn.microsoft.com/search/favicon.ico")); | 116 GURL("http://search.msdn.microsoft.com/search/favicon.ico")); |
105 EXPECT_TRUE(template_url_.url() != NULL); | 117 EXPECT_TRUE(template_url_.url() != NULL); |
106 EXPECT_TRUE(template_url_.url()->SupportsReplacement()); | 118 EXPECT_TRUE(template_url_.url()->SupportsReplacement()); |
107 EXPECT_EQ(template_url_.url()->url(), | 119 EXPECT_EQ(template_url_.url()->url(), |
108 "http://search.msdn.microsoft.com/search/default.aspx?Query={searchT
erms}&brand=msdn&locale=en-US"); | 120 "http://search.msdn.microsoft.com/search/default.aspx?Query={searchT
erms}&brand=msdn&locale=en-US"); |
109 } | 121 } |
110 | 122 |
111 TEST_F(TemplateURLParserTest, TestWikipedia) { | 123 TEST_F(TemplateURLParserTest, MAYBE_TestWikipedia) { |
112 if (IsDisabled()) | 124 if (IsDisabled()) |
113 return; | 125 return; |
114 ParseFile("wikipedia.xml", NULL); | 126 ParseFile("wikipedia.xml", NULL); |
115 ASSERT_TRUE(parse_result_); | 127 ASSERT_TRUE(parse_result_); |
116 EXPECT_EQ(ASCIIToUTF16("Wikipedia (English)"), template_url_.short_name()); | 128 EXPECT_EQ(ASCIIToUTF16("Wikipedia (English)"), template_url_.short_name()); |
117 EXPECT_TRUE(template_url_.GetFaviconURL() == | 129 EXPECT_TRUE(template_url_.GetFaviconURL() == |
118 GURL("http://en.wikipedia.org/favicon.ico")); | 130 GURL("http://en.wikipedia.org/favicon.ico")); |
119 EXPECT_TRUE(template_url_.url() != NULL); | 131 EXPECT_TRUE(template_url_.url() != NULL); |
120 EXPECT_TRUE(template_url_.url()->SupportsReplacement()); | 132 EXPECT_TRUE(template_url_.url()->SupportsReplacement()); |
121 EXPECT_EQ(template_url_.url()->url(), | 133 EXPECT_EQ(template_url_.url()->url(), |
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
230 EXPECT_TRUE(template_url_.url() != NULL); | 242 EXPECT_TRUE(template_url_.url() != NULL); |
231 EXPECT_TRUE(template_url_.url()->SupportsReplacement()); | 243 EXPECT_TRUE(template_url_.url()->SupportsReplacement()); |
232 EXPECT_TRUE(template_url_.suggestions_url() == NULL); | 244 EXPECT_TRUE(template_url_.suggestions_url() == NULL); |
233 EXPECT_EQ("http://search.yahoo.com/search?p={searchTerms}&ei=UTF-8", | 245 EXPECT_EQ("http://search.yahoo.com/search?p={searchTerms}&ei=UTF-8", |
234 template_url_.url()->url()); | 246 template_url_.url()->url()); |
235 ASSERT_EQ(1U, template_url_.input_encodings().size()); | 247 ASSERT_EQ(1U, template_url_.input_encodings().size()); |
236 EXPECT_EQ("UTF-8", template_url_.input_encodings()[0]); | 248 EXPECT_EQ("UTF-8", template_url_.input_encodings()[0]); |
237 EXPECT_EQ(GURL("http://search.yahoo.com/favicon.ico"), | 249 EXPECT_EQ(GURL("http://search.yahoo.com/favicon.ico"), |
238 template_url_.GetFaviconURL()); | 250 template_url_.GetFaviconURL()); |
239 } | 251 } |
OLD | NEW |