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

Side by Side Diff: chrome/browser/extensions/api/omnibox/omnibox_apitest.cc

Issue 12090006: Omnibox: Create Keyword Verbatim Result in Search Provider (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: roperly resolved (variable rename) Created 7 years, 10 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 | Annotate | Revision Log
« no previous file with comments | « chrome/browser/autocomplete/search_provider_unittest.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "base/format_macros.h" 5 #include "base/format_macros.h"
6 #include "base/string_util.h" 6 #include "base/string_util.h"
7 #include "base/stringprintf.h" 7 #include "base/stringprintf.h"
8 #include "base/utf_string_conversions.h" 8 #include "base/utf_string_conversions.h"
9 #include "chrome/browser/autocomplete/autocomplete_input.h" 9 #include "chrome/browser/autocomplete/autocomplete_input.h"
10 #include "chrome/browser/autocomplete/autocomplete_match.h" 10 #include "chrome/browser/autocomplete/autocomplete_match.h"
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
56 void WaitForAutocompleteDone(AutocompleteController* controller) { 56 void WaitForAutocompleteDone(AutocompleteController* controller) {
57 while (!controller->done()) { 57 while (!controller->done()) {
58 content::WindowedNotificationObserver ready_observer( 58 content::WindowedNotificationObserver ready_observer(
59 chrome::NOTIFICATION_AUTOCOMPLETE_CONTROLLER_RESULT_READY, 59 chrome::NOTIFICATION_AUTOCOMPLETE_CONTROLLER_RESULT_READY,
60 content::Source<AutocompleteController>(controller)); 60 content::Source<AutocompleteController>(controller));
61 ready_observer.Wait(); 61 ready_observer.Wait();
62 } 62 }
63 } 63 }
64 }; 64 };
65 65
66 // Flaky, http://crbug.com/167158 . 66 IN_PROC_BROWSER_TEST_F(OmniboxApiTest, Basic) {
67 IN_PROC_BROWSER_TEST_F(OmniboxApiTest, DISABLED_Basic) {
68 ASSERT_TRUE(RunExtensionTest("omnibox")) << message_; 67 ASSERT_TRUE(RunExtensionTest("omnibox")) << message_;
69 68
70 // The results depend on the TemplateURLService being loaded. Make sure it is 69 // The results depend on the TemplateURLService being loaded. Make sure it is
71 // loaded so that the autocomplete results are consistent. 70 // loaded so that the autocomplete results are consistent.
72 ui_test_utils::WaitForTemplateURLServiceToLoad( 71 ui_test_utils::WaitForTemplateURLServiceToLoad(
73 TemplateURLServiceFactory::GetForProfile(browser()->profile())); 72 TemplateURLServiceFactory::GetForProfile(browser()->profile()));
74 73
75 LocationBar* location_bar = GetLocationBar(browser());
76 AutocompleteController* autocomplete_controller = 74 AutocompleteController* autocomplete_controller =
77 GetAutocompleteController(browser()); 75 GetAutocompleteController(browser());
78 76
79 // Test that our extension's keyword is suggested to us when we partially type 77 // Test that our extension's keyword is suggested to us when we partially type
80 // it. 78 // it.
81 { 79 {
82 autocomplete_controller->Start( 80 autocomplete_controller->Start(
83 AutocompleteInput(ASCIIToUTF16("keywor"), string16::npos, string16(), 81 AutocompleteInput(ASCIIToUTF16("keywor"), string16::npos, string16(),
84 true, false, true, AutocompleteInput::ALL_MATCHES)); 82 true, false, true, AutocompleteInput::ALL_MATCHES));
85 WaitForAutocompleteDone(autocomplete_controller); 83 WaitForAutocompleteDone(autocomplete_controller);
(...skipping 21 matching lines...) Expand all
107 WaitForAutocompleteDone(autocomplete_controller); 105 WaitForAutocompleteDone(autocomplete_controller);
108 EXPECT_TRUE(autocomplete_controller->done()); 106 EXPECT_TRUE(autocomplete_controller->done());
109 107
110 // Now, peek into the controller to see if it has the results we expect. 108 // Now, peek into the controller to see if it has the results we expect.
111 // First result should be to invoke the keyword with what we typed, 2-4 109 // First result should be to invoke the keyword with what we typed, 2-4
112 // should be to invoke with suggestions from the extension, and the last 110 // should be to invoke with suggestions from the extension, and the last
113 // should be to search for what we typed. 111 // should be to search for what we typed.
114 const AutocompleteResult& result = autocomplete_controller->result(); 112 const AutocompleteResult& result = autocomplete_controller->result();
115 ASSERT_EQ(5U, result.size()) << AutocompleteResultAsString(result); 113 ASSERT_EQ(5U, result.size()) << AutocompleteResultAsString(result);
116 114
117 ASSERT_FALSE(result.match_at(0).keyword.empty()); 115 EXPECT_EQ(ASCIIToUTF16("keyword"), result.match_at(0).keyword);
118 EXPECT_EQ(ASCIIToUTF16("keyword suggestio"), 116 EXPECT_EQ(ASCIIToUTF16("keyword suggestio"),
119 result.match_at(0).fill_into_edit); 117 result.match_at(0).fill_into_edit);
118 EXPECT_EQ(AutocompleteMatch::SEARCH_OTHER_ENGINE, result.match_at(0).type);
119 EXPECT_EQ(AutocompleteProvider::TYPE_KEYWORD,
120 result.match_at(0).provider->type());
121 EXPECT_EQ(ASCIIToUTF16("keyword"), result.match_at(1).keyword);
120 EXPECT_EQ(ASCIIToUTF16("keyword suggestion1"), 122 EXPECT_EQ(ASCIIToUTF16("keyword suggestion1"),
121 result.match_at(1).fill_into_edit); 123 result.match_at(1).fill_into_edit);
124 EXPECT_EQ(AutocompleteProvider::TYPE_KEYWORD,
125 result.match_at(1).provider->type());
126 EXPECT_EQ(ASCIIToUTF16("keyword"), result.match_at(2).keyword);
122 EXPECT_EQ(ASCIIToUTF16("keyword suggestion2"), 127 EXPECT_EQ(ASCIIToUTF16("keyword suggestion2"),
123 result.match_at(2).fill_into_edit); 128 result.match_at(2).fill_into_edit);
129 EXPECT_EQ(AutocompleteProvider::TYPE_KEYWORD,
130 result.match_at(2).provider->type());
131 EXPECT_EQ(ASCIIToUTF16("keyword"), result.match_at(3).keyword);
124 EXPECT_EQ(ASCIIToUTF16("keyword suggestion3"), 132 EXPECT_EQ(ASCIIToUTF16("keyword suggestion3"),
125 result.match_at(3).fill_into_edit); 133 result.match_at(3).fill_into_edit);
134 EXPECT_EQ(AutocompleteProvider::TYPE_KEYWORD,
135 result.match_at(3).provider->type());
126 136
127 string16 description = 137 string16 description =
128 ASCIIToUTF16("Description with style: <match>, [dim], (url till end)"); 138 ASCIIToUTF16("Description with style: <match>, [dim], (url till end)");
129 EXPECT_EQ(description, result.match_at(1).contents); 139 EXPECT_EQ(description, result.match_at(1).contents);
130 ASSERT_EQ(6u, result.match_at(1).contents_class.size()); 140 ASSERT_EQ(6u, result.match_at(1).contents_class.size());
131 141
132 EXPECT_EQ(0u, 142 EXPECT_EQ(0u,
133 result.match_at(1).contents_class[0].offset); 143 result.match_at(1).contents_class[0].offset);
134 EXPECT_EQ(ACMatchClassification::NONE, 144 EXPECT_EQ(ACMatchClassification::NONE,
135 result.match_at(1).contents_class[0].style); 145 result.match_at(1).contents_class[0].style);
(...skipping 18 matching lines...) Expand all
154 EXPECT_EQ(ACMatchClassification::NONE, 164 EXPECT_EQ(ACMatchClassification::NONE,
155 result.match_at(1).contents_class[4].style); 165 result.match_at(1).contents_class[4].style);
156 166
157 EXPECT_EQ(description.find('('), 167 EXPECT_EQ(description.find('('),
158 result.match_at(1).contents_class[5].offset); 168 result.match_at(1).contents_class[5].offset);
159 EXPECT_EQ(ACMatchClassification::URL, 169 EXPECT_EQ(ACMatchClassification::URL,
160 result.match_at(1).contents_class[5].style); 170 result.match_at(1).contents_class[5].style);
161 171
162 AutocompleteMatch match = result.match_at(4); 172 AutocompleteMatch match = result.match_at(4);
163 EXPECT_EQ(AutocompleteMatch::SEARCH_WHAT_YOU_TYPED, match.type); 173 EXPECT_EQ(AutocompleteMatch::SEARCH_WHAT_YOU_TYPED, match.type);
174 EXPECT_EQ(AutocompleteProvider::TYPE_SEARCH,
175 result.match_at(4).provider->type());
164 EXPECT_FALSE(match.deletable); 176 EXPECT_FALSE(match.deletable);
165 } 177 }
166 178
179 // Flaky, see http://crbug.com/167158
180 /*
167 { 181 {
182 LocationBar* location_bar = GetLocationBar(browser());
168 ResultCatcher catcher; 183 ResultCatcher catcher;
169 OmniboxView* omnibox_view = location_bar->GetLocationEntry(); 184 OmniboxView* omnibox_view = location_bar->GetLocationEntry();
170 omnibox_view->OnBeforePossibleChange(); 185 omnibox_view->OnBeforePossibleChange();
171 omnibox_view->SetUserText( ASCIIToUTF16("keyword command")); 186 omnibox_view->SetUserText(ASCIIToUTF16("keyword command"));
172 omnibox_view->OnAfterPossibleChange(); 187 omnibox_view->OnAfterPossibleChange();
173 location_bar->AcceptInput(); 188 location_bar->AcceptInput();
174 // This checks that the keyword provider (via javascript) 189 // This checks that the keyword provider (via javascript)
175 // gets told to navigate to the string "command". 190 // gets told to navigate to the string "command".
176 EXPECT_TRUE(catcher.GetNextResult()) << catcher.message(); 191 EXPECT_TRUE(catcher.GetNextResult()) << catcher.message();
177 } 192 }
193 */
178 } 194 }
179 195
180 // Tests that the autocomplete popup doesn't reopen after accepting input for 196 // Tests that the autocomplete popup doesn't reopen after accepting input for
181 // a given query. 197 // a given query.
182 // http://crbug.com/88552 198 // http://crbug.com/88552
183 IN_PROC_BROWSER_TEST_F(OmniboxApiTest, PopupStaysClosed) { 199 IN_PROC_BROWSER_TEST_F(OmniboxApiTest, PopupStaysClosed) {
184 ASSERT_TRUE(RunExtensionTest("omnibox")) << message_; 200 ASSERT_TRUE(RunExtensionTest("omnibox")) << message_;
185 201
186 // The results depend on the TemplateURLService being loaded. Make sure it is 202 // The results depend on the TemplateURLService being loaded. Make sure it is
187 // loaded so that the autocomplete results are consistent. 203 // loaded so that the autocomplete results are consistent.
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
273 { 289 {
274 ResultCatcher catcher; 290 ResultCatcher catcher;
275 autocomplete_controller->Start( 291 autocomplete_controller->Start(
276 AutocompleteInput(ASCIIToUTF16("keyword command incognito"), 292 AutocompleteInput(ASCIIToUTF16("keyword command incognito"),
277 string16::npos, string16(), true, false, true, 293 string16::npos, string16(), true, false, true,
278 AutocompleteInput::ALL_MATCHES)); 294 AutocompleteInput::ALL_MATCHES));
279 location_bar->AcceptInput(); 295 location_bar->AcceptInput();
280 EXPECT_TRUE(catcher.GetNextResult()) << catcher.message(); 296 EXPECT_TRUE(catcher.GetNextResult()) << catcher.message();
281 } 297 }
282 } 298 }
OLDNEW
« no previous file with comments | « chrome/browser/autocomplete/search_provider_unittest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698