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

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

Issue 10810062: Moving common code into OmniboxView from OmniboxView* (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: More win fixes Created 8 years, 4 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
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 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
45 45
46 } // namespace 46 } // namespace
47 47
48 class OmniboxApiTest : public ExtensionApiTest { 48 class OmniboxApiTest : public ExtensionApiTest {
49 protected: 49 protected:
50 LocationBar* GetLocationBar(Browser* browser) const { 50 LocationBar* GetLocationBar(Browser* browser) const {
51 return browser->window()->GetLocationBar(); 51 return browser->window()->GetLocationBar();
52 } 52 }
53 53
54 AutocompleteController* GetAutocompleteController(Browser* browser) const { 54 AutocompleteController* GetAutocompleteController(Browser* browser) const {
55 return GetLocationBar(browser)->GetLocationEntry()->model()->popup_model()-> 55 return GetLocationBar(browser)->GetLocationEntry()->GetModel()->
56 autocomplete_controller(); 56 popup_model()->autocomplete_controller();
57 } 57 }
58 58
59 // TODO(phajdan.jr): Get rid of this wait-in-a-loop pattern. 59 // TODO(phajdan.jr): Get rid of this wait-in-a-loop pattern.
60 void WaitForAutocompleteDone(AutocompleteController* controller) { 60 void WaitForAutocompleteDone(AutocompleteController* controller) {
61 while (!controller->done()) { 61 while (!controller->done()) {
62 content::WindowedNotificationObserver ready_observer( 62 content::WindowedNotificationObserver ready_observer(
63 chrome::NOTIFICATION_AUTOCOMPLETE_CONTROLLER_RESULT_READY, 63 chrome::NOTIFICATION_AUTOCOMPLETE_CONTROLLER_RESULT_READY,
64 content::Source<AutocompleteController>(controller)); 64 content::Source<AutocompleteController>(controller));
65 ready_observer.Wait(); 65 ready_observer.Wait();
66 } 66 }
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
187 187
188 // The results depend on the TemplateURLService being loaded. Make sure it is 188 // The results depend on the TemplateURLService being loaded. Make sure it is
189 // loaded so that the autocomplete results are consistent. 189 // loaded so that the autocomplete results are consistent.
190 ui_test_utils::WaitForTemplateURLServiceToLoad( 190 ui_test_utils::WaitForTemplateURLServiceToLoad(
191 TemplateURLServiceFactory::GetForProfile(browser()->profile())); 191 TemplateURLServiceFactory::GetForProfile(browser()->profile()));
192 192
193 LocationBar* location_bar = GetLocationBar(browser()); 193 LocationBar* location_bar = GetLocationBar(browser());
194 OmniboxView* omnibox_view = location_bar->GetLocationEntry(); 194 OmniboxView* omnibox_view = location_bar->GetLocationEntry();
195 AutocompleteController* autocomplete_controller = 195 AutocompleteController* autocomplete_controller =
196 GetAutocompleteController(browser()); 196 GetAutocompleteController(browser());
197 OmniboxPopupModel* popup_model = omnibox_view->model()->popup_model(); 197 OmniboxPopupModel* popup_model = omnibox_view->GetModel()->popup_model();
198 198
199 // Input a keyword query and wait for suggestions from the extension. 199 // Input a keyword query and wait for suggestions from the extension.
200 omnibox_view->OnBeforePossibleChange(); 200 omnibox_view->OnBeforePossibleChange();
201 omnibox_view->SetUserText(ASCIIToUTF16("keyword comman")); 201 omnibox_view->SetUserText(ASCIIToUTF16("keyword comman"));
202 omnibox_view->OnAfterPossibleChange(); 202 omnibox_view->OnAfterPossibleChange();
203 WaitForAutocompleteDone(autocomplete_controller); 203 WaitForAutocompleteDone(autocomplete_controller);
204 EXPECT_TRUE(autocomplete_controller->done()); 204 EXPECT_TRUE(autocomplete_controller->done());
205 EXPECT_TRUE(popup_model->IsOpen()); 205 EXPECT_TRUE(popup_model->IsOpen());
206 206
207 // Quickly type another query and accept it before getting suggestions back 207 // Quickly type another query and accept it before getting suggestions back
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
272 // incognito context. 272 // incognito context.
273 { 273 {
274 ResultCatcher catcher; 274 ResultCatcher catcher;
275 autocomplete_controller->Start( 275 autocomplete_controller->Start(
276 ASCIIToUTF16("keyword command incognito"), string16(), 276 ASCIIToUTF16("keyword command incognito"), string16(),
277 true, false, true, AutocompleteInput::ALL_MATCHES); 277 true, false, true, AutocompleteInput::ALL_MATCHES);
278 location_bar->AcceptInput(); 278 location_bar->AcceptInput();
279 EXPECT_TRUE(catcher.GetNextResult()) << catcher.message(); 279 EXPECT_TRUE(catcher.GetNextResult()) << catcher.message();
280 } 280 }
281 } 281 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698