| 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/url_constants.h" | 23 #include "chrome/common/url_constants.h" |
| 23 #include "chrome/test/ui_test_utils.h" | 24 #include "chrome/test/ui_test_utils.h" |
| 24 #include "content/common/notification_type.h" | 25 #include "content/common/content_notification_types.h" |
| 25 | 26 |
| 26 #if defined(TOOLKIT_GTK) | 27 #if defined(TOOLKIT_GTK) |
| 27 #include "chrome/browser/ui/gtk/browser_window_gtk.h" | 28 #include "chrome/browser/ui/gtk/browser_window_gtk.h" |
| 28 #endif | 29 #endif |
| 29 | 30 |
| 30 // Basic test is flaky on ChromeOS. | 31 // Basic test is flaky on ChromeOS. |
| 31 // http://crbug.com/52929 | 32 // http://crbug.com/52929 |
| 32 #if defined(OS_CHROMEOS) | 33 #if defined(OS_CHROMEOS) |
| 33 #define MAYBE_Basic FLAKY_Basic | 34 #define MAYBE_Basic FLAKY_Basic |
| 34 #else | 35 #else |
| (...skipping 26 matching lines...) Expand all Loading... |
| 61 return GetLocationBar()->location_entry()->model()->popup_model()-> | 62 return GetLocationBar()->location_entry()->model()->popup_model()-> |
| 62 autocomplete_controller(); | 63 autocomplete_controller(); |
| 63 } | 64 } |
| 64 | 65 |
| 65 void WaitForTemplateURLServiceToLoad() { | 66 void WaitForTemplateURLServiceToLoad() { |
| 66 TemplateURLService* model = | 67 TemplateURLService* model = |
| 67 TemplateURLServiceFactory::GetForProfile(browser()->profile()); | 68 TemplateURLServiceFactory::GetForProfile(browser()->profile()); |
| 68 model->Load(); | 69 model->Load(); |
| 69 if (!model->loaded()) { | 70 if (!model->loaded()) { |
| 70 ui_test_utils::WaitForNotification( | 71 ui_test_utils::WaitForNotification( |
| 71 NotificationType::TEMPLATE_URL_SERVICE_LOADED); | 72 chrome::NOTIFICATION_TEMPLATE_URL_SERVICE_LOADED); |
| 72 } | 73 } |
| 73 } | 74 } |
| 74 | 75 |
| 75 void WaitForAutocompleteDone(AutocompleteController* controller) { | 76 void WaitForAutocompleteDone(AutocompleteController* controller) { |
| 76 while (!controller->done()) { | 77 while (!controller->done()) { |
| 77 ui_test_utils::WaitForNotification( | 78 ui_test_utils::WaitForNotification( |
| 78 NotificationType::AUTOCOMPLETE_CONTROLLER_RESULT_READY); | 79 chrome::NOTIFICATION_AUTOCOMPLETE_CONTROLLER_RESULT_READY); |
| 79 } | 80 } |
| 80 } | 81 } |
| 81 }; | 82 }; |
| 82 | 83 |
| 83 IN_PROC_BROWSER_TEST_F(OmniboxApiTest, MAYBE_Basic) { | 84 IN_PROC_BROWSER_TEST_F(OmniboxApiTest, MAYBE_Basic) { |
| 84 #if defined(TOOLKIT_GTK) | 85 #if defined(TOOLKIT_GTK) |
| 85 // Disable the timer because, on Lucid at least, it triggers resize/move | 86 // Disable the timer because, on Lucid at least, it triggers resize/move |
| 86 // behavior in the browser window, which dismisses the autocomplete popup | 87 // behavior in the browser window, which dismisses the autocomplete popup |
| 87 // before the results can be read. | 88 // before the results can be read. |
| 88 static_cast<BrowserWindowGtk*>( | 89 static_cast<BrowserWindowGtk*>( |
| (...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 239 ResultCatcher catcher; | 240 ResultCatcher catcher; |
| 240 autocomplete_controller->Start( | 241 autocomplete_controller->Start( |
| 241 ASCIIToUTF16("keyword command"), string16(), true, false, true, | 242 ASCIIToUTF16("keyword command"), string16(), true, false, true, |
| 242 AutocompleteInput::ALL_MATCHES); | 243 AutocompleteInput::ALL_MATCHES); |
| 243 location_bar->AcceptInput(); | 244 location_bar->AcceptInput(); |
| 244 WaitForAutocompleteDone(autocomplete_controller); | 245 WaitForAutocompleteDone(autocomplete_controller); |
| 245 EXPECT_TRUE(autocomplete_controller->done()); | 246 EXPECT_TRUE(autocomplete_controller->done()); |
| 246 EXPECT_TRUE(catcher.GetNextResult()) << catcher.message(); | 247 EXPECT_TRUE(catcher.GetNextResult()) << catcher.message(); |
| 247 EXPECT_FALSE(popup_model->IsOpen()); | 248 EXPECT_FALSE(popup_model->IsOpen()); |
| 248 } | 249 } |
| OLD | NEW |