Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(305)

Side by Side Diff: chrome/browser/ui/omnibox/omnibox_view_browsertest.cc

Issue 1135163002: Omnibox - Strip Extra Whitespace from Custom Search Engine Names (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix more tests that don't set short_name Created 5 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 <stdio.h> 5 #include <stdio.h>
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/scoped_observer.h" 8 #include "base/scoped_observer.h"
9 #include "base/strings/string16.h" 9 #include "base/strings/string16.h"
10 #include "base/strings/string_util.h" 10 #include "base/strings/string_util.h"
(...skipping 249 matching lines...) Expand 10 before | Expand all | Expand 10 after
260 Profile* profile = browser()->profile(); 260 Profile* profile = browser()->profile();
261 TemplateURLService* model = 261 TemplateURLService* model =
262 TemplateURLServiceFactory::GetForProfile(profile); 262 TemplateURLServiceFactory::GetForProfile(profile);
263 ASSERT_TRUE(model); 263 ASSERT_TRUE(model);
264 264
265 ui_test_utils::WaitForTemplateURLServiceToLoad(model); 265 ui_test_utils::WaitForTemplateURLServiceToLoad(model);
266 266
267 ASSERT_TRUE(model->loaded()); 267 ASSERT_TRUE(model->loaded());
268 268
269 TemplateURLData data; 269 TemplateURLData data;
270 data.short_name = ASCIIToUTF16(kSearchShortName); 270 data.SetShortName(ASCIIToUTF16(kSearchShortName));
271 data.SetKeyword(ASCIIToUTF16(kSearchKeyword)); 271 data.SetKeyword(ASCIIToUTF16(kSearchKeyword));
272 data.SetURL(kSearchURL); 272 data.SetURL(kSearchURL);
273 TemplateURL* template_url = new TemplateURL(data); 273 TemplateURL* template_url = new TemplateURL(data);
274 model->Add(template_url); 274 model->Add(template_url);
275 model->SetUserSelectedDefaultSearchProvider(template_url); 275 model->SetUserSelectedDefaultSearchProvider(template_url);
276 276
277 data.SetKeyword(ASCIIToUTF16(kSearchKeyword2)); 277 data.SetKeyword(ASCIIToUTF16(kSearchKeyword2));
278 model->Add(new TemplateURL(data)); 278 model->Add(new TemplateURL(data));
279 279
280 // Remove built-in template urls, like google.com, bing.com etc., as they 280 // Remove built-in template urls, like google.com, bing.com etc., as they
(...skipping 342 matching lines...) Expand 10 before | Expand all | Expand 10 after
623 ASSERT_TRUE(popup_model); 623 ASSERT_TRUE(popup_model);
624 624
625 Profile* profile = browser()->profile(); 625 Profile* profile = browser()->profile();
626 TemplateURLService* template_url_service = 626 TemplateURLService* template_url_service =
627 TemplateURLServiceFactory::GetForProfile(profile); 627 TemplateURLServiceFactory::GetForProfile(profile);
628 628
629 // Add a non-substituting keyword. This ensures the popup will have a 629 // Add a non-substituting keyword. This ensures the popup will have a
630 // non-verbatim entry with "ab" as a prefix. This way, by arrowing down, we 630 // non-verbatim entry with "ab" as a prefix. This way, by arrowing down, we
631 // can set "abc" as temporary text in the omnibox. 631 // can set "abc" as temporary text in the omnibox.
632 TemplateURLData data; 632 TemplateURLData data;
633 data.short_name = ASCIIToUTF16("abc"); 633 data.SetShortName(ASCIIToUTF16("abc"));
634 data.SetKeyword(ASCIIToUTF16(kSearchText)); 634 data.SetKeyword(ASCIIToUTF16(kSearchText));
635 data.SetURL("http://abc.com/"); 635 data.SetURL("http://abc.com/");
636 template_url_service->Add(new TemplateURL(data)); 636 template_url_service->Add(new TemplateURL(data));
637 637
638 // Send "ab", so that an "abc" entry appears in the popup. 638 // Send "ab", so that an "abc" entry appears in the popup.
639 const ui::KeyboardCode kSearchTextPrefixKeys[] = { 639 const ui::KeyboardCode kSearchTextPrefixKeys[] = {
640 ui::VKEY_A, ui::VKEY_B, ui::VKEY_UNKNOWN 640 ui::VKEY_A, ui::VKEY_B, ui::VKEY_UNKNOWN
641 }; 641 };
642 ASSERT_NO_FATAL_FAILURE(SendKeySequence(kSearchTextPrefixKeys)); 642 ASSERT_NO_FATAL_FAILURE(SendKeySequence(kSearchTextPrefixKeys));
643 ASSERT_NO_FATAL_FAILURE(WaitForAutocompleteControllerDone()); 643 ASSERT_NO_FATAL_FAILURE(WaitForAutocompleteControllerDone());
(...skipping 426 matching lines...) Expand 10 before | Expand all | Expand 10 after
1070 ASSERT_NO_FATAL_FAILURE(GetOmniboxView(&omnibox_view)); 1070 ASSERT_NO_FATAL_FAILURE(GetOmniboxView(&omnibox_view));
1071 OmniboxPopupModel* popup_model = omnibox_view->model()->popup_model(); 1071 OmniboxPopupModel* popup_model = omnibox_view->model()->popup_model();
1072 ASSERT_TRUE(popup_model); 1072 ASSERT_TRUE(popup_model);
1073 1073
1074 Profile* profile = browser()->profile(); 1074 Profile* profile = browser()->profile();
1075 TemplateURLService* template_url_service = 1075 TemplateURLService* template_url_service =
1076 TemplateURLServiceFactory::GetForProfile(profile); 1076 TemplateURLServiceFactory::GetForProfile(profile);
1077 1077
1078 // Add a non-default substituting keyword. 1078 // Add a non-default substituting keyword.
1079 TemplateURLData data; 1079 TemplateURLData data;
1080 data.short_name = ASCIIToUTF16("Search abc"); 1080 data.SetShortName(ASCIIToUTF16("Search abc"));
1081 data.SetKeyword(ASCIIToUTF16(kSearchText)); 1081 data.SetKeyword(ASCIIToUTF16(kSearchText));
1082 data.SetURL("http://abc.com/{searchTerms}"); 1082 data.SetURL("http://abc.com/{searchTerms}");
1083 TemplateURL* template_url = new TemplateURL(data); 1083 TemplateURL* template_url = new TemplateURL(data);
1084 template_url_service->Add(template_url); 1084 template_url_service->Add(template_url);
1085 1085
1086 omnibox_view->SetUserText(base::string16()); 1086 omnibox_view->SetUserText(base::string16());
1087 1087
1088 // Non-default substituting keyword shouldn't be matched by default. 1088 // Non-default substituting keyword shouldn't be matched by default.
1089 ASSERT_NO_FATAL_FAILURE(SendKeySequence(kSearchTextKeys)); 1089 ASSERT_NO_FATAL_FAILURE(SendKeySequence(kSearchTextKeys));
1090 ASSERT_NO_FATAL_FAILURE(WaitForAutocompleteControllerDone()); 1090 ASSERT_NO_FATAL_FAILURE(WaitForAutocompleteControllerDone());
1091 ASSERT_TRUE(popup_model->IsOpen()); 1091 ASSERT_TRUE(popup_model->IsOpen());
1092 1092
1093 // Check if the default match result is Search Primary Provider. 1093 // Check if the default match result is Search Primary Provider.
1094 ASSERT_EQ(AutocompleteMatchType::SEARCH_WHAT_YOU_TYPED, 1094 ASSERT_EQ(AutocompleteMatchType::SEARCH_WHAT_YOU_TYPED,
1095 popup_model->result().default_match()->type); 1095 popup_model->result().default_match()->type);
1096 ASSERT_EQ(kSearchTextURL, 1096 ASSERT_EQ(kSearchTextURL,
1097 popup_model->result().default_match()->destination_url.spec()); 1097 popup_model->result().default_match()->destination_url.spec());
1098 1098
1099 omnibox_view->SetUserText(base::string16()); 1099 omnibox_view->SetUserText(base::string16());
1100 ASSERT_NO_FATAL_FAILURE(WaitForAutocompleteControllerDone()); 1100 ASSERT_NO_FATAL_FAILURE(WaitForAutocompleteControllerDone());
1101 ASSERT_FALSE(popup_model->IsOpen()); 1101 ASSERT_FALSE(popup_model->IsOpen());
1102 1102
1103 // Try a non-substituting keyword. 1103 // Try a non-substituting keyword.
1104 template_url_service->Remove(template_url); 1104 template_url_service->Remove(template_url);
1105 data.short_name = ASCIIToUTF16("abc"); 1105 data.SetShortName(ASCIIToUTF16("abc"));
1106 data.SetURL("http://abc.com/"); 1106 data.SetURL("http://abc.com/");
1107 template_url_service->Add(new TemplateURL(data)); 1107 template_url_service->Add(new TemplateURL(data));
1108 1108
1109 // We always allow exact matches for non-substituting keywords. 1109 // We always allow exact matches for non-substituting keywords.
1110 ASSERT_NO_FATAL_FAILURE(SendKeySequence(kSearchTextKeys)); 1110 ASSERT_NO_FATAL_FAILURE(SendKeySequence(kSearchTextKeys));
1111 ASSERT_NO_FATAL_FAILURE(WaitForAutocompleteControllerDone()); 1111 ASSERT_NO_FATAL_FAILURE(WaitForAutocompleteControllerDone());
1112 ASSERT_TRUE(popup_model->IsOpen()); 1112 ASSERT_TRUE(popup_model->IsOpen());
1113 ASSERT_EQ(AutocompleteMatchType::HISTORY_KEYWORD, 1113 ASSERT_EQ(AutocompleteMatchType::HISTORY_KEYWORD,
1114 popup_model->result().default_match()->type); 1114 popup_model->result().default_match()->type);
1115 ASSERT_EQ("http://abc.com/", 1115 ASSERT_EQ("http://abc.com/",
(...skipping 743 matching lines...) Expand 10 before | Expand all | Expand 10 after
1859 browser()->toolbar_model()->set_url_replacement_enabled(false); 1859 browser()->toolbar_model()->set_url_replacement_enabled(false);
1860 test_toolbar_model->set_text(url_b); 1860 test_toolbar_model->set_text(url_b);
1861 omnibox_view->Update(); 1861 omnibox_view->Update();
1862 EXPECT_EQ(url_a, omnibox_view->GetText()); 1862 EXPECT_EQ(url_a, omnibox_view->GetText());
1863 omnibox_view->RevertAll(); 1863 omnibox_view->RevertAll();
1864 EXPECT_EQ(url_b, omnibox_view->GetText()); 1864 EXPECT_EQ(url_b, omnibox_view->GetText());
1865 test_toolbar_model->set_text(url_c); 1865 test_toolbar_model->set_text(url_c);
1866 omnibox_view->Update(); 1866 omnibox_view->Update();
1867 EXPECT_EQ(url_c, omnibox_view->GetText()); 1867 EXPECT_EQ(url_c, omnibox_view->GetText());
1868 } 1868 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698