Chromium Code Reviews| Index: chrome/browser/autocomplete/autocomplete_edit_view_browsertest.cc |
| diff --git a/chrome/browser/autocomplete/autocomplete_edit_view_browsertest.cc b/chrome/browser/autocomplete/autocomplete_edit_view_browsertest.cc |
| index 4cc301979eb4970618a5a85a3d6f0f5e4eae172f..6a3c5d4922af09925cdb804be760af31b6f13380 100644 |
| --- a/chrome/browser/autocomplete/autocomplete_edit_view_browsertest.cc |
| +++ b/chrome/browser/autocomplete/autocomplete_edit_view_browsertest.cc |
| @@ -791,6 +791,57 @@ class AutocompleteEditViewTest : public InProcessBrowserTest, |
| ASSERT_TRUE(edit_view->GetText().empty()); |
| } |
| + // http://crbug.com/70807 |
|
Peter Kasting
2011/01/26 00:58:07
Nit: Probably no need for this comment, other test
|
| + void NonSubstitutingKeywordTest() { |
| + AutocompleteEditView* edit_view = NULL; |
| + ASSERT_NO_FATAL_FAILURE(GetAutocompleteEditView(&edit_view)); |
| + AutocompletePopupModel* popup_model = edit_view->model()->popup_model(); |
| + ASSERT_TRUE(popup_model); |
| + |
| + TemplateURLModel* template_url_model = |
| + browser()->profile()->GetTemplateURLModel(); |
| + |
| + // Add a non-default substituting keyword. |
| + TemplateURL* template_url = new TemplateURL(); |
| + template_url->SetURL("http://abc.com/{searchTerms}", 0, 0); |
| + template_url->set_keyword(UTF8ToUTF16(kSearchText)); |
| + template_url->set_short_name(UTF8ToUTF16("Search abc")); |
| + template_url_model->Add(template_url); |
| + |
| + edit_view->SetUserText(string16()); |
| + |
| + // non-default substituting keyword shouldn't be matched by default. |
|
Peter Kasting
2011/01/26 00:58:07
Nit: non -> Non
|
| + ASSERT_NO_FATAL_FAILURE(SendKeySequence(kSearchTextKeys)); |
| + ASSERT_NO_FATAL_FAILURE(WaitForAutocompleteControllerDone()); |
| + ASSERT_TRUE(popup_model->IsOpen()); |
| + |
| + // Check if the default match result is Search Primary Provider. |
| + ASSERT_EQ(AutocompleteMatch::SEARCH_WHAT_YOU_TYPED, |
| + popup_model->result().default_match()->type); |
| + ASSERT_EQ(kSearchTextURL, |
| + popup_model->result().default_match()->destination_url.spec()); |
| + |
| + edit_view->SetUserText(string16()); |
| + ASSERT_NO_FATAL_FAILURE(WaitForAutocompleteControllerDone()); |
| + ASSERT_FALSE(popup_model->IsOpen()); |
| + |
| + // Try a non-substituting keyword. |
| + template_url_model->Remove(template_url); |
| + template_url = new TemplateURL(); |
| + template_url->SetURL("http://abc.com/", 0, 0); |
| + template_url->set_keyword(UTF8ToUTF16(kSearchText)); |
| + template_url->set_short_name(UTF8ToUTF16("abc")); |
| + template_url_model->Add(template_url); |
| + |
| + // We always allow exact match non-substituting keywords. |
|
Peter Kasting
2011/01/26 00:58:07
Nit: match -> matches for
|
| + ASSERT_NO_FATAL_FAILURE(SendKeySequence(kSearchTextKeys)); |
| + ASSERT_NO_FATAL_FAILURE(WaitForAutocompleteControllerDone()); |
| + ASSERT_TRUE(popup_model->IsOpen()); |
| + ASSERT_EQ(AutocompleteMatch::HISTORY_KEYWORD, |
| + popup_model->result().default_match()->type); |
| + ASSERT_EQ("http://abc.com/", |
| + popup_model->result().default_match()->destination_url.spec()); |
| + } |
| }; |
| // Test if ctrl-* accelerators are workable in omnibox. |
| @@ -844,6 +895,10 @@ IN_PROC_BROWSER_TEST_F(AutocompleteEditViewTest, AcceptKeywordBySpace) { |
| AcceptKeywordBySpaceTest(); |
| } |
| +IN_PROC_BROWSER_TEST_F(AutocompleteEditViewTest, NonSubstitutingKeywordTest) { |
| + NonSubstitutingKeywordTest(); |
| +} |
| + |
| #if defined(OS_LINUX) |
| // TODO(oshima): enable these tests for views-implmentation when |
| // these featuers are supported. |
| @@ -1020,4 +1075,8 @@ IN_PROC_BROWSER_TEST_F(AutocompleteEditViewViewsTest, AcceptKeywordBySpace) { |
| AcceptKeywordBySpaceTest(); |
| } |
| +IN_PROC_BROWSER_TEST_F(AutocompleteEditViewViewsTest, NonSubstitutingKeywordTest) { |
| + NonSubstitutingKeywordTest(); |
| +} |
| + |
| #endif |