| 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/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/search_terms_data.h" | 10 #include "chrome/browser/search_engines/search_terms_data.h" |
| 11 #include "chrome/browser/search_engines/template_url.h" | 11 #include "chrome/browser/search_engines/template_url.h" |
| 12 #include "chrome/test/testing_browser_process_test.h" |
| 12 #include "testing/gtest/include/gtest/gtest.h" | 13 #include "testing/gtest/include/gtest/gtest.h" |
| 13 | 14 |
| 14 // Simple implementation of SearchTermsData. | 15 // Simple implementation of SearchTermsData. |
| 15 class TestSearchTermsData : public SearchTermsData { | 16 class TestSearchTermsData : public SearchTermsData { |
| 16 public: | 17 public: |
| 17 explicit TestSearchTermsData(const char* google_base_url) | 18 explicit TestSearchTermsData(const char* google_base_url) |
| 18 : google_base_url_(google_base_url) { | 19 : google_base_url_(google_base_url) { |
| 19 } | 20 } |
| 20 | 21 |
| 21 virtual std::string GoogleBaseURLValue() const { | 22 virtual std::string GoogleBaseURLValue() const { |
| (...skipping 10 matching lines...) Expand all Loading... |
| 32 return string16(); | 33 return string16(); |
| 33 } | 34 } |
| 34 #endif | 35 #endif |
| 35 | 36 |
| 36 private: | 37 private: |
| 37 std::string google_base_url_; | 38 std::string google_base_url_; |
| 38 | 39 |
| 39 DISALLOW_COPY_AND_ASSIGN(TestSearchTermsData); | 40 DISALLOW_COPY_AND_ASSIGN(TestSearchTermsData); |
| 40 }; | 41 }; |
| 41 | 42 |
| 42 class TemplateURLTest : public testing::Test { | 43 class TemplateURLTest : public TestingBrowserProcessTest { |
| 43 public: | 44 public: |
| 44 virtual void TearDown() { | 45 virtual void TearDown() { |
| 45 TemplateURLRef::SetGoogleBaseURL(NULL); | 46 TemplateURLRef::SetGoogleBaseURL(NULL); |
| 46 } | 47 } |
| 47 | 48 |
| 48 void CheckSuggestBaseURL(const char* base_url, | 49 void CheckSuggestBaseURL(const char* base_url, |
| 49 const char* base_suggest_url) const { | 50 const char* base_suggest_url) const { |
| 50 TestSearchTermsData search_terms_data(base_url); | 51 TestSearchTermsData search_terms_data(base_url); |
| 51 EXPECT_STREQ(base_suggest_url, | 52 EXPECT_STREQ(base_suggest_url, |
| 52 search_terms_data.GoogleBaseSuggestURLValue().c_str()); | 53 search_terms_data.GoogleBaseSuggestURLValue().c_str()); |
| (...skipping 516 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 569 TEST_F(TemplateURLTest, ParseURLNestedParameter) { | 570 TEST_F(TemplateURLTest, ParseURLNestedParameter) { |
| 570 TemplateURLRef url_ref("{%s", 0, 0); | 571 TemplateURLRef url_ref("{%s", 0, 0); |
| 571 TemplateURLRef::Replacements replacements; | 572 TemplateURLRef::Replacements replacements; |
| 572 bool valid = false; | 573 bool valid = false; |
| 573 EXPECT_EQ("{", url_ref.ParseURL("{{searchTerms}", &replacements, &valid)); | 574 EXPECT_EQ("{", url_ref.ParseURL("{{searchTerms}", &replacements, &valid)); |
| 574 ASSERT_EQ(1U, replacements.size()); | 575 ASSERT_EQ(1U, replacements.size()); |
| 575 EXPECT_EQ(static_cast<size_t>(1), replacements[0].index); | 576 EXPECT_EQ(static_cast<size_t>(1), replacements[0].index); |
| 576 EXPECT_EQ(TemplateURLRef::SEARCH_TERMS, replacements[0].type); | 577 EXPECT_EQ(TemplateURLRef::SEARCH_TERMS, replacements[0].type); |
| 577 EXPECT_TRUE(valid); | 578 EXPECT_TRUE(valid); |
| 578 } | 579 } |
| OLD | NEW |