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