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/message_loop.h" | 5 #include "base/message_loop.h" |
6 #include "base/utf_string_conversions.h" | 6 #include "base/utf_string_conversions.h" |
7 #include "chrome/browser/autocomplete/autocomplete_match.h" | 7 #include "chrome/browser/autocomplete/autocomplete_match.h" |
8 #include "chrome/browser/autocomplete/keyword_provider.h" | 8 #include "chrome/browser/autocomplete/keyword_provider.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_model.h" | 10 #include "chrome/browser/search_engines/template_url_model.h" |
11 #include "chrome/test/testing_browser_process.h" | |
11 #include "googleurl/src/gurl.h" | 12 #include "googleurl/src/gurl.h" |
12 #include "testing/gtest/include/gtest/gtest.h" | 13 #include "testing/gtest/include/gtest/gtest.h" |
13 | 14 |
14 class KeywordProviderTest : public testing::Test { | 15 class KeywordProviderTest : public testing::Test { |
sky
2011/02/14 17:01:19
TestingBrowserProcessTest?
| |
15 protected: | 16 protected: |
16 template<class ResultType> | 17 template<class ResultType> |
17 struct test_data { | 18 struct test_data { |
18 const string16 input; | 19 const string16 input; |
19 const size_t num_results; | 20 const size_t num_results; |
20 const ResultType output[3]; | 21 const ResultType output[3]; |
21 }; | 22 }; |
22 | 23 |
23 KeywordProviderTest() : kw_provider_(NULL) { } | 24 KeywordProviderTest() : kw_provider_(NULL) { } |
24 virtual ~KeywordProviderTest() { } | 25 virtual ~KeywordProviderTest() { } |
25 | 26 |
26 virtual void SetUp(); | 27 virtual void SetUp(); |
27 virtual void TearDown(); | 28 virtual void TearDown(); |
28 | 29 |
29 template<class ResultType> | 30 template<class ResultType> |
30 void RunTest(test_data<ResultType>* keyword_cases, | 31 void RunTest(test_data<ResultType>* keyword_cases, |
31 int num_cases, | 32 int num_cases, |
32 ResultType AutocompleteMatch::* member); | 33 ResultType AutocompleteMatch::* member); |
33 | 34 |
34 protected: | 35 protected: |
36 ScopedTestingBrowserProcess browser_process_; | |
35 scoped_refptr<KeywordProvider> kw_provider_; | 37 scoped_refptr<KeywordProvider> kw_provider_; |
36 scoped_ptr<TemplateURLModel> model_; | 38 scoped_ptr<TemplateURLModel> model_; |
37 }; | 39 }; |
38 | 40 |
39 void KeywordProviderTest::SetUp() { | 41 void KeywordProviderTest::SetUp() { |
40 static const TemplateURLModel::Initializer kTestKeywordData[] = { | 42 static const TemplateURLModel::Initializer kTestKeywordData[] = { |
41 { "aa", "aa.com?foo=%s", "aa" }, | 43 { "aa", "aa.com?foo=%s", "aa" }, |
42 { "aaaa", "http://aaaa/?aaaa=1&b=%s&c", "aaaa" }, | 44 { "aaaa", "http://aaaa/?aaaa=1&b=%s&c", "aaaa" }, |
43 { "aaaaa", "%s", "aaaaa" }, | 45 { "aaaaa", "%s", "aaaaa" }, |
44 { "ab", "bogus URL %s", "ab" }, | 46 { "ab", "bogus URL %s", "ab" }, |
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
207 template_url->set_short_name(ASCIIToUTF16("Test")); | 209 template_url->set_short_name(ASCIIToUTF16("Test")); |
208 model_->Add(template_url); | 210 model_->Add(template_url); |
209 ASSERT_TRUE(template_url == model_->GetTemplateURLForKeyword(keyword)); | 211 ASSERT_TRUE(template_url == model_->GetTemplateURLForKeyword(keyword)); |
210 } | 212 } |
211 | 213 |
212 TEST_F(KeywordProviderTest, RemoveKeyword) { | 214 TEST_F(KeywordProviderTest, RemoveKeyword) { |
213 string16 url(ASCIIToUTF16("http://aaaa/?aaaa=1&b={searchTerms}&c")); | 215 string16 url(ASCIIToUTF16("http://aaaa/?aaaa=1&b={searchTerms}&c")); |
214 model_->Remove(model_->GetTemplateURLForKeyword(ASCIIToUTF16("aaaa"))); | 216 model_->Remove(model_->GetTemplateURLForKeyword(ASCIIToUTF16("aaaa"))); |
215 ASSERT_TRUE(model_->GetTemplateURLForKeyword(ASCIIToUTF16("aaaa")) == NULL); | 217 ASSERT_TRUE(model_->GetTemplateURLForKeyword(ASCIIToUTF16("aaaa")) == NULL); |
216 } | 218 } |
OLD | NEW |