OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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.h" | 9 #include "chrome/browser/autocomplete/autocomplete.h" |
10 #include "chrome/browser/autocomplete/autocomplete_edit.h" | 10 #include "chrome/browser/autocomplete/autocomplete_edit.h" |
11 #include "chrome/browser/autocomplete/autocomplete_match.h" | 11 #include "chrome/browser/autocomplete/autocomplete_match.h" |
12 #include "chrome/browser/autocomplete/autocomplete_popup_model.h" | 12 #include "chrome/browser/autocomplete/autocomplete_popup_model.h" |
13 #include "chrome/browser/extensions/extension_apitest.h" | 13 #include "chrome/browser/extensions/extension_apitest.h" |
14 #include "chrome/browser/profiles/profile.h" | 14 #include "chrome/browser/profiles/profile.h" |
15 #include "chrome/browser/search_engines/template_url.h" | 15 #include "chrome/browser/search_engines/template_url.h" |
16 #include "chrome/browser/search_engines/template_url_service.h" | 16 #include "chrome/browser/search_engines/template_url_service.h" |
17 #include "chrome/browser/search_engines/template_url_service_factory.h" | 17 #include "chrome/browser/search_engines/template_url_service_factory.h" |
18 #include "chrome/browser/ui/browser.h" | 18 #include "chrome/browser/ui/browser.h" |
19 #include "chrome/browser/ui/browser_window.h" | 19 #include "chrome/browser/ui/browser_window.h" |
20 #include "chrome/browser/ui/omnibox/location_bar.h" | 20 #include "chrome/browser/ui/omnibox/location_bar.h" |
21 #include "chrome/browser/ui/omnibox/omnibox_view.h" | 21 #include "chrome/browser/ui/omnibox/omnibox_view.h" |
22 #include "chrome/common/chrome_notification_types.h" | 22 #include "chrome/common/chrome_notification_types.h" |
23 #include "chrome/common/url_constants.h" | 23 #include "chrome/common/url_constants.h" |
24 #include "chrome/test/base/ui_test_utils.h" | 24 #include "chrome/test/base/ui_test_utils.h" |
25 #include "content/public/browser/notification_types.h" | 25 #include "content/public/browser/notification_types.h" |
| 26 #include "content/public/browser/notification_service.h" |
26 | 27 |
27 #if defined(TOOLKIT_GTK) | 28 #if defined(TOOLKIT_GTK) |
28 #include "chrome/browser/ui/gtk/browser_window_gtk.h" | 29 #include "chrome/browser/ui/gtk/browser_window_gtk.h" |
29 #endif | 30 #endif |
30 | 31 |
31 // Basic test is flaky on ChromeOS and Linux. | 32 // Basic test is flaky on ChromeOS and Linux. |
32 // http://crbug.com/52929 | 33 // http://crbug.com/52929 |
33 #if defined(OS_CHROMEOS) || defined(OS_LINUX) | 34 #if defined(OS_CHROMEOS) || defined(OS_LINUX) |
34 #define MAYBE_Basic FLAKY_Basic | 35 #define MAYBE_Basic FLAKY_Basic |
35 #else | 36 #else |
(...skipping 23 matching lines...) Expand all Loading... |
59 } | 60 } |
60 | 61 |
61 AutocompleteController* GetAutocompleteController() const { | 62 AutocompleteController* GetAutocompleteController() const { |
62 return GetLocationBar()->location_entry()->model()->popup_model()-> | 63 return GetLocationBar()->location_entry()->model()->popup_model()-> |
63 autocomplete_controller(); | 64 autocomplete_controller(); |
64 } | 65 } |
65 | 66 |
66 void WaitForTemplateURLServiceToLoad() { | 67 void WaitForTemplateURLServiceToLoad() { |
67 ui_test_utils::WindowedNotificationObserver loaded_observer( | 68 ui_test_utils::WindowedNotificationObserver loaded_observer( |
68 chrome::NOTIFICATION_TEMPLATE_URL_SERVICE_LOADED, | 69 chrome::NOTIFICATION_TEMPLATE_URL_SERVICE_LOADED, |
69 NotificationService::AllSources()); | 70 content::NotificationService::AllSources()); |
70 TemplateURLService* model = | 71 TemplateURLService* model = |
71 TemplateURLServiceFactory::GetForProfile(browser()->profile()); | 72 TemplateURLServiceFactory::GetForProfile(browser()->profile()); |
72 model->Load(); | 73 model->Load(); |
73 if (!model->loaded()) | 74 if (!model->loaded()) |
74 loaded_observer.Wait(); | 75 loaded_observer.Wait(); |
75 } | 76 } |
76 | 77 |
77 // TODO(phajdan.jr): Get rid of this wait-in-a-loop pattern. | 78 // TODO(phajdan.jr): Get rid of this wait-in-a-loop pattern. |
78 void WaitForAutocompleteDone(AutocompleteController* controller) { | 79 void WaitForAutocompleteDone(AutocompleteController* controller) { |
79 while (!controller->done()) { | 80 while (!controller->done()) { |
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
244 ResultCatcher catcher; | 245 ResultCatcher catcher; |
245 autocomplete_controller->Start( | 246 autocomplete_controller->Start( |
246 ASCIIToUTF16("keyword command"), string16(), true, false, true, | 247 ASCIIToUTF16("keyword command"), string16(), true, false, true, |
247 AutocompleteInput::ALL_MATCHES); | 248 AutocompleteInput::ALL_MATCHES); |
248 location_bar->AcceptInput(); | 249 location_bar->AcceptInput(); |
249 WaitForAutocompleteDone(autocomplete_controller); | 250 WaitForAutocompleteDone(autocomplete_controller); |
250 EXPECT_TRUE(autocomplete_controller->done()); | 251 EXPECT_TRUE(autocomplete_controller->done()); |
251 EXPECT_TRUE(catcher.GetNextResult()) << catcher.message(); | 252 EXPECT_TRUE(catcher.GetNextResult()) << catcher.message(); |
252 EXPECT_FALSE(popup_model->IsOpen()); | 253 EXPECT_FALSE(popup_model->IsOpen()); |
253 } | 254 } |
OLD | NEW |