OLD | NEW |
---|---|
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 #ifndef CHROME_BROWSER_SEARCH_ENGINES_TEMPLATE_URL_SERVICE_TEST_UTIL_H_ | 5 #ifndef CHROME_BROWSER_SEARCH_ENGINES_TEMPLATE_URL_SERVICE_TEST_UTIL_H_ |
6 #define CHROME_BROWSER_SEARCH_ENGINES_TEMPLATE_URL_SERVICE_TEST_UTIL_H_ | 6 #define CHROME_BROWSER_SEARCH_ENGINES_TEMPLATE_URL_SERVICE_TEST_UTIL_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
11 #include "base/files/scoped_temp_dir.h" | 11 #include "base/files/scoped_temp_dir.h" |
12 #include "base/memory/ref_counted.h" | |
12 #include "base/memory/scoped_ptr.h" | 13 #include "base/memory/scoped_ptr.h" |
13 #include "base/strings/string16.h" | 14 #include "base/strings/string16.h" |
14 #include "components/search_engines/template_url_service_observer.h" | 15 #include "components/search_engines/template_url_service_observer.h" |
15 #include "content/public/test/test_browser_thread_bundle.h" | |
16 | 16 |
17 class GURL; | 17 class GURL; |
18 class KeywordWebDataService; | |
18 class TemplateURLService; | 19 class TemplateURLService; |
19 class TestingProfile; | 20 class TestingProfile; |
20 class TestingSearchTermsData; | 21 class TestingSearchTermsData; |
21 class TestingTemplateURLService; | |
22 | 22 |
23 class TemplateURLServiceTestUtil : public TemplateURLServiceObserver { | 23 class TemplateURLServiceTestUtil : public TemplateURLServiceObserver { |
24 public: | 24 public: |
25 TemplateURLServiceTestUtil(); | 25 TemplateURLServiceTestUtil(); |
26 virtual ~TemplateURLServiceTestUtil(); | 26 virtual ~TemplateURLServiceTestUtil(); |
27 | 27 |
28 // TemplateURLServiceObserver implemementation. | 28 // TemplateURLServiceObserver implemementation. |
29 virtual void OnTemplateURLServiceChanged() OVERRIDE; | 29 virtual void OnTemplateURLServiceChanged() OVERRIDE; |
30 | 30 |
31 // Gets the observer count. | 31 // Gets the observer count. |
(...skipping 13 matching lines...) Expand all Loading... | |
45 // Deletes the current model (and doesn't create a new one). | 45 // Deletes the current model (and doesn't create a new one). |
46 void ClearModel(); | 46 void ClearModel(); |
47 | 47 |
48 // Creates a new TemplateURLService. | 48 // Creates a new TemplateURLService. |
49 void ResetModel(bool verify_load); | 49 void ResetModel(bool verify_load); |
50 | 50 |
51 // Returns the search term from the last invocation of | 51 // Returns the search term from the last invocation of |
52 // TemplateURLService::SetKeywordSearchTermsForURL and clears the search term. | 52 // TemplateURLService::SetKeywordSearchTermsForURL and clears the search term. |
53 base::string16 GetAndClearSearchTerm(); | 53 base::string16 GetAndClearSearchTerm(); |
54 | 54 |
55 // Set the google base url. |base_url| must be valid. | 55 // Set the google base url. |base_url| must be valid. |
Peter Kasting
2014/08/28 19:06:19
Nit: Set -> Sets
hashimoto
2014/08/29 08:06:26
Done.
| |
56 void SetGoogleBaseURL(const GURL& base_url); | 56 void SetGoogleBaseURL(const GURL& base_url); |
57 | 57 |
58 // Set the managed preferences for the default search provider and trigger | 58 // Set the managed preferences for the default search provider and trigger |
Peter Kasting
2014/08/28 19:06:19
Nit: Set -> Sets
hashimoto
2014/08/29 08:06:26
Done.
| |
59 // notification. If |alternate_url| is empty, uses an empty list of alternate | 59 // notification. If |alternate_url| is empty, uses an empty list of alternate |
60 // URLs, otherwise use a list containing a single entry. | 60 // URLs, otherwise use a list containing a single entry. |
Peter Kasting
2014/08/28 19:06:20
Nit: use -> uses
hashimoto
2014/08/29 08:06:26
Done.
| |
61 void SetManagedDefaultSearchPreferences( | 61 void SetManagedDefaultSearchPreferences( |
62 bool enabled, | 62 bool enabled, |
63 const std::string& name, | 63 const std::string& name, |
64 const std::string& keyword, | 64 const std::string& keyword, |
65 const std::string& search_url, | 65 const std::string& search_url, |
66 const std::string& suggest_url, | 66 const std::string& suggest_url, |
67 const std::string& icon_url, | 67 const std::string& icon_url, |
68 const std::string& encodings, | 68 const std::string& encodings, |
69 const std::string& alternate_url, | 69 const std::string& alternate_url, |
70 const std::string& search_terms_replacement_key); | 70 const std::string& search_terms_replacement_key); |
71 | 71 |
72 // Remove all the managed preferences for the default search provider and | 72 // Remove all the managed preferences for the default search provider and |
Peter Kasting
2014/08/28 19:06:19
Nit: Remove -> Removes
hashimoto
2014/08/29 08:06:26
Done.
| |
73 // trigger notification. | 73 // trigger notification. |
Peter Kasting
2014/08/28 19:06:19
Nit: trigger -> triggers
hashimoto
2014/08/29 08:06:26
Done.
| |
74 void RemoveManagedDefaultSearchPreferences(); | 74 void RemoveManagedDefaultSearchPreferences(); |
75 | 75 |
76 // Returns the KeywordWebDataService. | |
Peter Kasting
2014/08/28 19:06:19
Nit: Remove this comment ant the two below, they a
hashimoto
2014/08/29 08:06:26
Done.
| |
77 KeywordWebDataService* web_data_service() { return web_data_service_.get(); } | |
78 | |
76 // Returns the TemplateURLService. | 79 // Returns the TemplateURLService. |
77 TemplateURLService* model(); | 80 TemplateURLService* model() { return model_.get(); } |
78 | 81 |
79 // Returns the TestingProfile. | 82 // Returns the TestingProfile. |
80 TestingProfile* profile() { return profile_.get(); } | 83 TestingProfile* profile() { return profile_.get(); } |
81 | 84 |
82 private: | 85 private: |
83 content::TestBrowserThreadBundle thread_bundle_; | |
84 scoped_ptr<TestingProfile> profile_; | 86 scoped_ptr<TestingProfile> profile_; |
85 base::ScopedTempDir temp_dir_; | 87 base::ScopedTempDir temp_dir_; |
86 int changed_count_; | 88 int changed_count_; |
89 base::string16 search_term_; | |
90 scoped_refptr<KeywordWebDataService> web_data_service_; | |
87 TestingSearchTermsData* search_terms_data_; | 91 TestingSearchTermsData* search_terms_data_; |
88 scoped_ptr<TestingTemplateURLService> model_; | 92 scoped_ptr<TemplateURLService> model_; |
89 | 93 |
90 DISALLOW_COPY_AND_ASSIGN(TemplateURLServiceTestUtil); | 94 DISALLOW_COPY_AND_ASSIGN(TemplateURLServiceTestUtil); |
91 }; | 95 }; |
92 | 96 |
93 #endif // CHROME_BROWSER_SEARCH_ENGINES_TEMPLATE_URL_SERVICE_TEST_UTIL_H_ | 97 #endif // CHROME_BROWSER_SEARCH_ENGINES_TEMPLATE_URL_SERVICE_TEST_UTIL_H_ |
OLD | NEW |