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 #include "base/strings/utf_string_conversions.h" | 5 #include "base/strings/utf_string_conversions.h" |
6 #include "chrome/browser/autocomplete/autocomplete_classifier_factory.h" | 6 #include "chrome/browser/autocomplete/autocomplete_classifier_factory.h" |
7 #include "chrome/browser/search_engines/template_url_service_factory.h" | 7 #include "chrome/browser/search_engines/template_url_service_factory.h" |
8 #include "chrome/browser/ui/omnibox/omnibox_edit_controller.h" | 8 #include "chrome/browser/ui/omnibox/omnibox_edit_controller.h" |
9 #include "chrome/browser/ui/omnibox/omnibox_edit_model.h" | 9 #include "chrome/browser/ui/omnibox/omnibox_edit_model.h" |
10 #include "chrome/browser/ui/omnibox/omnibox_view.h" | 10 #include "chrome/browser/ui/omnibox/omnibox_view.h" |
(...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
196 TestingProfile profile; | 196 TestingProfile profile; |
197 // NOTE: The TemplateURLService must be created before the | 197 // NOTE: The TemplateURLService must be created before the |
198 // AutocompleteClassifier so that the SearchProvider gets a non-NULL | 198 // AutocompleteClassifier so that the SearchProvider gets a non-NULL |
199 // TemplateURLService at construction time. | 199 // TemplateURLService at construction time. |
200 TemplateURLServiceFactory::GetInstance()->SetTestingFactory( | 200 TemplateURLServiceFactory::GetInstance()->SetTestingFactory( |
201 &profile, &TemplateURLServiceFactory::BuildInstanceFor); | 201 &profile, &TemplateURLServiceFactory::BuildInstanceFor); |
202 AutocompleteClassifierFactory::GetInstance()->SetTestingFactory( | 202 AutocompleteClassifierFactory::GetInstance()->SetTestingFactory( |
203 &profile, &AutocompleteClassifierFactory::BuildInstanceFor); | 203 &profile, &AutocompleteClassifierFactory::BuildInstanceFor); |
204 OmniboxEditModel model(&view, &controller, &profile); | 204 OmniboxEditModel model(&view, &controller, &profile); |
205 | 205 |
206 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(input); ++i) { | 206 for (size_t i = 0; i < arraysize(input); ++i) { |
207 toolbar_model()->set_text(ASCIIToUTF16(input[i].perm_text)); | 207 toolbar_model()->set_text(ASCIIToUTF16(input[i].perm_text)); |
208 model.UpdatePermanentText(); | 208 model.UpdatePermanentText(); |
209 | 209 |
210 toolbar_model()->set_perform_search_term_replacement( | 210 toolbar_model()->set_perform_search_term_replacement( |
211 input[i].extracted_search_terms); | 211 input[i].extracted_search_terms); |
212 | 212 |
213 base::string16 result = ASCIIToUTF16(input[i].input); | 213 base::string16 result = ASCIIToUTF16(input[i].input); |
214 GURL url; | 214 GURL url; |
215 bool write_url; | 215 bool write_url; |
216 model.AdjustTextForCopy(input[i].sel_start, input[i].is_all_selected, | 216 model.AdjustTextForCopy(input[i].sel_start, input[i].is_all_selected, |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
255 | 255 |
256 model.SetUserText(UTF8ToUTF16("he")); | 256 model.SetUserText(UTF8ToUTF16("he")); |
257 model.OnPopupDataChanged(UTF8ToUTF16("llo"), NULL, base::string16(), false); | 257 model.OnPopupDataChanged(UTF8ToUTF16("llo"), NULL, base::string16(), false); |
258 EXPECT_EQ(UTF8ToUTF16("hello"), view.GetText()); | 258 EXPECT_EQ(UTF8ToUTF16("hello"), view.GetText()); |
259 EXPECT_EQ(UTF8ToUTF16("llo"), view.inline_autocomplete_text()); | 259 EXPECT_EQ(UTF8ToUTF16("llo"), view.inline_autocomplete_text()); |
260 | 260 |
261 model.AcceptTemporaryTextAsUserText(); | 261 model.AcceptTemporaryTextAsUserText(); |
262 EXPECT_EQ(UTF8ToUTF16("hello"), view.GetText()); | 262 EXPECT_EQ(UTF8ToUTF16("hello"), view.GetText()); |
263 EXPECT_EQ(base::string16(), view.inline_autocomplete_text()); | 263 EXPECT_EQ(base::string16(), view.inline_autocomplete_text()); |
264 } | 264 } |
OLD | NEW |