OLD | NEW |
1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 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 #include "components/omnibox/search_provider.h" | 5 #include "components/omnibox/search_provider.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 | 8 |
9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
10 #include "base/metrics/field_trial.h" | 10 #include "base/metrics/field_trial.h" |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
71 public: | 71 public: |
72 SearchProviderForTest(AutocompleteProviderListener* listener, | 72 SearchProviderForTest(AutocompleteProviderListener* listener, |
73 TemplateURLService* template_url_service, | 73 TemplateURLService* template_url_service, |
74 Profile* profile); | 74 Profile* profile); |
75 bool is_success() { return is_success_; }; | 75 bool is_success() { return is_success_; }; |
76 | 76 |
77 protected: | 77 protected: |
78 virtual ~SearchProviderForTest(); | 78 virtual ~SearchProviderForTest(); |
79 | 79 |
80 private: | 80 private: |
81 virtual void RecordDeletionResult(bool success) OVERRIDE; | 81 virtual void RecordDeletionResult(bool success) override; |
82 bool is_success_; | 82 bool is_success_; |
83 DISALLOW_COPY_AND_ASSIGN(SearchProviderForTest); | 83 DISALLOW_COPY_AND_ASSIGN(SearchProviderForTest); |
84 }; | 84 }; |
85 | 85 |
86 SearchProviderForTest::SearchProviderForTest( | 86 SearchProviderForTest::SearchProviderForTest( |
87 AutocompleteProviderListener* listener, | 87 AutocompleteProviderListener* listener, |
88 TemplateURLService* template_url_service, | 88 TemplateURLService* template_url_service, |
89 Profile* profile) | 89 Profile* profile) |
90 : SearchProvider(listener, template_url_service, | 90 : SearchProvider(listener, template_url_service, |
91 scoped_ptr<AutocompleteProviderClient>( | 91 scoped_ptr<AutocompleteProviderClient>( |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
150 SearchProviderTest() | 150 SearchProviderTest() |
151 : default_t_url_(NULL), | 151 : default_t_url_(NULL), |
152 term1_(ASCIIToUTF16("term1")), | 152 term1_(ASCIIToUTF16("term1")), |
153 keyword_t_url_(NULL), | 153 keyword_t_url_(NULL), |
154 keyword_term_(ASCIIToUTF16("keyword")), | 154 keyword_term_(ASCIIToUTF16("keyword")), |
155 run_loop_(NULL) { | 155 run_loop_(NULL) { |
156 ResetFieldTrialList(); | 156 ResetFieldTrialList(); |
157 } | 157 } |
158 | 158 |
159 // See description above class for what this registers. | 159 // See description above class for what this registers. |
160 virtual void SetUp() OVERRIDE; | 160 virtual void SetUp() override; |
161 virtual void TearDown() OVERRIDE; | 161 virtual void TearDown() override; |
162 | 162 |
163 void RunTest(TestData* cases, int num_cases, bool prefer_keyword); | 163 void RunTest(TestData* cases, int num_cases, bool prefer_keyword); |
164 | 164 |
165 protected: | 165 protected: |
166 // Needed for AutocompleteFieldTrial::ActivateStaticTrials(); | 166 // Needed for AutocompleteFieldTrial::ActivateStaticTrials(); |
167 scoped_ptr<base::FieldTrialList> field_trial_list_; | 167 scoped_ptr<base::FieldTrialList> field_trial_list_; |
168 | 168 |
169 // Default values used for testing. | 169 // Default values used for testing. |
170 static const std::string kNotApplicable; | 170 static const std::string kNotApplicable; |
171 static const ExpectedMatch kEmptyExpectedMatch; | 171 static const ExpectedMatch kEmptyExpectedMatch; |
172 | 172 |
173 // Adds a search for |term|, using the engine |t_url| to the history, and | 173 // Adds a search for |term|, using the engine |t_url| to the history, and |
174 // returns the URL for that search. | 174 // returns the URL for that search. |
175 GURL AddSearchToHistory(TemplateURL* t_url, base::string16 term, int visit_cou
nt); | 175 GURL AddSearchToHistory(TemplateURL* t_url, base::string16 term, int visit_cou
nt); |
176 | 176 |
177 // Looks for a match in |provider_| with |contents| equal to |contents|. | 177 // Looks for a match in |provider_| with |contents| equal to |contents|. |
178 // Sets |match| to it if found. Returns whether |match| was set. | 178 // Sets |match| to it if found. Returns whether |match| was set. |
179 bool FindMatchWithContents(const base::string16& contents, | 179 bool FindMatchWithContents(const base::string16& contents, |
180 AutocompleteMatch* match); | 180 AutocompleteMatch* match); |
181 | 181 |
182 // Looks for a match in |provider_| with destination |url|. Sets |match| to | 182 // Looks for a match in |provider_| with destination |url|. Sets |match| to |
183 // it if found. Returns whether |match| was set. | 183 // it if found. Returns whether |match| was set. |
184 bool FindMatchWithDestination(const GURL& url, AutocompleteMatch* match); | 184 bool FindMatchWithDestination(const GURL& url, AutocompleteMatch* match); |
185 | 185 |
186 // AutocompleteProviderListener: | 186 // AutocompleteProviderListener: |
187 // If we're waiting for the provider to finish, this exits the message loop. | 187 // If we're waiting for the provider to finish, this exits the message loop. |
188 virtual void OnProviderUpdate(bool updated_matches) OVERRIDE; | 188 virtual void OnProviderUpdate(bool updated_matches) override; |
189 | 189 |
190 // Runs a nested message loop until provider_ is done. The message loop is | 190 // Runs a nested message loop until provider_ is done. The message loop is |
191 // exited by way of OnProviderUpdate. | 191 // exited by way of OnProviderUpdate. |
192 void RunTillProviderDone(); | 192 void RunTillProviderDone(); |
193 | 193 |
194 // Invokes Start on provider_, then runs all pending tasks. | 194 // Invokes Start on provider_, then runs all pending tasks. |
195 void QueryForInput(const base::string16& text, | 195 void QueryForInput(const base::string16& text, |
196 bool prevent_inline_autocomplete, | 196 bool prevent_inline_autocomplete, |
197 bool prefer_keyword); | 197 bool prefer_keyword); |
198 | 198 |
(...skipping 3249 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3448 EXPECT_EQ(base::ASCIIToUTF16("42"), matches[0].answer_type); | 3448 EXPECT_EQ(base::ASCIIToUTF16("42"), matches[0].answer_type); |
3449 EXPECT_TRUE(matches[1].answer_contents.empty()); | 3449 EXPECT_TRUE(matches[1].answer_contents.empty()); |
3450 EXPECT_TRUE(matches[1].answer_type.empty()); | 3450 EXPECT_TRUE(matches[1].answer_type.empty()); |
3451 EXPECT_TRUE(matches[2].answer_contents.empty()); | 3451 EXPECT_TRUE(matches[2].answer_contents.empty()); |
3452 EXPECT_TRUE(matches[2].answer_type.empty()); | 3452 EXPECT_TRUE(matches[2].answer_type.empty()); |
3453 EXPECT_TRUE(matches[3].answer_contents.empty()); | 3453 EXPECT_TRUE(matches[3].answer_contents.empty()); |
3454 EXPECT_TRUE(matches[3].answer_type.empty()); | 3454 EXPECT_TRUE(matches[3].answer_type.empty()); |
3455 EXPECT_TRUE(matches[4].answer_contents.empty()); | 3455 EXPECT_TRUE(matches[4].answer_contents.empty()); |
3456 EXPECT_TRUE(matches[4].answer_type.empty()); | 3456 EXPECT_TRUE(matches[4].answer_type.empty()); |
3457 } | 3457 } |
OLD | NEW |