OLD | NEW |
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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/string_util.h" | 6 #include "base/string_util.h" |
7 #include "base/utf_string_conversions.h" | 7 #include "base/utf_string_conversions.h" |
8 #include "chrome/browser/browser_process.h" | 8 #include "chrome/browser/browser_process.h" |
9 #include "chrome/browser/rlz/rlz.h" | 9 #include "chrome/browser/rlz/rlz.h" |
10 #include "chrome/browser/search_engines/template_url.h" | 10 #include "chrome/browser/search_engines/template_url.h" |
(...skipping 309 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
320 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(data); ++i) { | 320 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(data); ++i) { |
321 GURL result = GURL(WideToUTF8(ref.ReplaceSearchTerms(turl, L"foobar", | 321 GURL result = GURL(WideToUTF8(ref.ReplaceSearchTerms(turl, L"foobar", |
322 data[i].accepted_suggestion, data[i].original_query_for_suggestion))); | 322 data[i].accepted_suggestion, data[i].original_query_for_suggestion))); |
323 EXPECT_TRUE(result.is_valid()); | 323 EXPECT_TRUE(result.is_valid()); |
324 EXPECT_EQ(data[i].expected_result, result.spec()); | 324 EXPECT_EQ(data[i].expected_result, result.spec()); |
325 } | 325 } |
326 } | 326 } |
327 | 327 |
328 #if defined(OS_WIN) | 328 #if defined(OS_WIN) |
329 TEST_F(TemplateURLTest, RLZ) { | 329 TEST_F(TemplateURLTest, RLZ) { |
330 RLZTracker::InitRlz(base::DIR_EXE); | |
331 std::wstring rlz_string; | 330 std::wstring rlz_string; |
332 RLZTracker::GetAccessPointRlz(RLZTracker::CHROME_OMNIBOX, &rlz_string); | 331 RLZTracker::GetAccessPointRlz(rlz_lib::CHROME_OMNIBOX, &rlz_string); |
333 | 332 |
334 TemplateURL t_url; | 333 TemplateURL t_url; |
335 TemplateURLRef ref(L"http://bar/?{google:RLZ}{searchTerms}", 1, 2); | 334 TemplateURLRef ref(L"http://bar/?{google:RLZ}{searchTerms}", 1, 2); |
336 ASSERT_TRUE(ref.IsValid()); | 335 ASSERT_TRUE(ref.IsValid()); |
337 ASSERT_TRUE(ref.SupportsReplacement()); | 336 ASSERT_TRUE(ref.SupportsReplacement()); |
338 GURL result = GURL(WideToUTF8(ref.ReplaceSearchTerms(t_url, L"x", | 337 GURL result = GURL(WideToUTF8(ref.ReplaceSearchTerms(t_url, L"x", |
339 TemplateURLRef::NO_SUGGESTIONS_AVAILABLE, std::wstring()))); | 338 TemplateURLRef::NO_SUGGESTIONS_AVAILABLE, std::wstring()))); |
340 ASSERT_TRUE(result.is_valid()); | 339 ASSERT_TRUE(result.is_valid()); |
341 std::string expected_url = "http://bar/?"; | 340 std::string expected_url = "http://bar/?"; |
342 if (!rlz_string.empty()) { | 341 if (!rlz_string.empty()) { |
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
476 TEST_F(TemplateURLTest, ParseURLNestedParameter) { | 475 TEST_F(TemplateURLTest, ParseURLNestedParameter) { |
477 TemplateURLRef url_ref(L"{%s", 0, 0); | 476 TemplateURLRef url_ref(L"{%s", 0, 0); |
478 TemplateURLRef::Replacements replacements; | 477 TemplateURLRef::Replacements replacements; |
479 bool valid = false; | 478 bool valid = false; |
480 EXPECT_EQ(L"{", url_ref.ParseURL(L"{{searchTerms}", &replacements, &valid)); | 479 EXPECT_EQ(L"{", url_ref.ParseURL(L"{{searchTerms}", &replacements, &valid)); |
481 ASSERT_EQ(1U, replacements.size()); | 480 ASSERT_EQ(1U, replacements.size()); |
482 EXPECT_EQ(static_cast<size_t>(1), replacements[0].index); | 481 EXPECT_EQ(static_cast<size_t>(1), replacements[0].index); |
483 EXPECT_EQ(TemplateURLRef::SEARCH_TERMS, replacements[0].type); | 482 EXPECT_EQ(TemplateURLRef::SEARCH_TERMS, replacements[0].type); |
484 EXPECT_TRUE(valid); | 483 EXPECT_TRUE(valid); |
485 } | 484 } |
OLD | NEW |