#include "base/strings/utf_string_conversions.h"
#include "base/time/time.h"
#include "chrome/app/chrome_command_ids.h"
-#include "chrome/browser/autocomplete/autocomplete_input.h"
-#include "chrome/browser/autocomplete/autocomplete_match.h"
#include "chrome/browser/autocomplete/history_quick_provider.h"
#include "chrome/browser/bookmarks/bookmark_model_factory.h"
#include "chrome/browser/chrome_notification_types.h"
#include "chrome/browser/history/history_service.h"
#include "chrome/browser/history/history_service_factory.h"
#include "chrome/browser/profiles/profile.h"
-#include "chrome/browser/search_engines/template_url.h"
-#include "chrome/browser/search_engines/template_url_service.h"
#include "chrome/browser/search_engines/template_url_service_factory.h"
#include "chrome/browser/ui/browser.h"
#include "chrome/browser/ui/browser_commands.h"
#include "chrome/browser/ui/browser_window.h"
-#include "chrome/browser/ui/omnibox/location_bar.h"
+#include "chrome/browser/ui/location_bar/location_bar.h"
#include "chrome/browser/ui/omnibox/omnibox_popup_model.h"
#include "chrome/browser/ui/omnibox/omnibox_view.h"
#include "chrome/browser/ui/tabs/tab_strip_model.h"
#include "components/bookmarks/browser/bookmark_model.h"
#include "components/bookmarks/browser/bookmark_utils.h"
#include "components/bookmarks/test/bookmark_test_helpers.h"
+#include "components/omnibox/autocomplete_input.h"
+#include "components/omnibox/autocomplete_match.h"
+#include "components/search_engines/template_url.h"
+#include "components/search_engines/template_url_service.h"
#include "content/public/browser/notification_service.h"
#include "content/public/browser/web_contents.h"
#include "net/dns/mock_host_resolver.h"
const char kSearchKeyword[] = "foo";
const char kSearchKeyword2[] = "footest.com";
-const wchar_t kSearchKeywordKeys[] = { ui::VKEY_F, ui::VKEY_O, ui::VKEY_O, 0 };
+const ui::KeyboardCode kSearchKeywordKeys[] = {
+ ui::VKEY_F, ui::VKEY_O, ui::VKEY_O, ui::VKEY_UNKNOWN
+};
+const ui::KeyboardCode kSearchKeywordPrefixKeys[] = {
+ ui::VKEY_F, ui::VKEY_O, ui::VKEY_UNKNOWN
+};
+const ui::KeyboardCode kSearchKeywordCompletionKeys[] = {
+ ui::VKEY_O, ui::VKEY_UNKNOWN
+};
const char kSearchURL[] = "http://www.foo.com/search?q={searchTerms}";
const char kSearchShortName[] = "foo";
const char kSearchText[] = "abc";
-const wchar_t kSearchTextKeys[] = { ui::VKEY_A, ui::VKEY_B, ui::VKEY_C, 0 };
+const ui::KeyboardCode kSearchTextKeys[] = {
+ ui::VKEY_A, ui::VKEY_B, ui::VKEY_C, ui::VKEY_UNKNOWN
+};
const char kSearchTextURL[] = "http://www.foo.com/search?q=abc";
const char kInlineAutocompleteText[] = "def";
-const wchar_t kInlineAutocompleteTextKeys[] = {
- ui::VKEY_D, ui::VKEY_E, ui::VKEY_F, 0
+const ui::KeyboardCode kInlineAutocompleteTextKeys[] = {
+ ui::VKEY_D, ui::VKEY_E, ui::VKEY_F, ui::VKEY_UNKNOWN
};
// Hostnames that shall be blocked by host resolver.
SendKeyForBrowser(browser(), key, modifiers);
}
- void SendKeySequence(const wchar_t* keys) {
- for (; *keys; ++keys)
- ASSERT_NO_FATAL_FAILURE(SendKey(static_cast<ui::KeyboardCode>(*keys), 0));
+ void SendKeySequence(const ui::KeyboardCode* keys) {
+ for (; *keys != ui::VKEY_UNKNOWN; ++keys)
+ ASSERT_NO_FATAL_FAILURE(SendKey(*keys, 0));
}
bool SendKeyAndWait(const Browser* browser,
entry.typed_count, time, false,
history::SOURCE_BROWSED);
if (entry.starred)
- bookmark_utils::AddIfNotBookmarked(bookmark_model, url, base::string16());
+ bookmarks::AddIfNotBookmarked(bookmark_model, url, base::string16());
// Wait at least for the AddPageWithDetails() call to finish.
{
content::NotificationRegistrar registrar;
ASSERT_TRUE(popup_model);
// Test ctrl-Enter.
- const wchar_t kKeys[] = { ui::VKEY_B, ui::VKEY_A, ui::VKEY_R, 0 };
+ const ui::KeyboardCode kKeys[] = {
+ ui::VKEY_B, ui::VKEY_A, ui::VKEY_R, ui::VKEY_UNKNOWN
+ };
ASSERT_NO_FATAL_FAILURE(SendKeySequence(kKeys));
ASSERT_NO_FATAL_FAILURE(WaitForAutocompleteControllerDone());
ASSERT_TRUE(popup_model->IsOpen());
template_url_service->Add(new TemplateURL(data));
// Send "ab", so that an "abc" entry appears in the popup.
- const wchar_t kSearchTextPrefixKeys[] = { ui::VKEY_A, ui::VKEY_B, 0 };
+ const ui::KeyboardCode kSearchTextPrefixKeys[] = {
+ ui::VKEY_A, ui::VKEY_B, ui::VKEY_UNKNOWN
+ };
ASSERT_NO_FATAL_FAILURE(SendKeySequence(kSearchTextPrefixKeys));
ASSERT_NO_FATAL_FAILURE(WaitForAutocompleteControllerDone());
ASSERT_TRUE(popup_model->IsOpen());
EXPECT_EQ(kSearchTextURL, url.spec());
// Test that entering a single character then Enter performs a search.
- const wchar_t kSearchSingleCharKeys[] = { ui::VKEY_Z, 0 };
+ const ui::KeyboardCode kSearchSingleCharKeys[] = {
+ ui::VKEY_Z, ui::VKEY_UNKNOWN
+ };
chrome::FocusLocationBar(browser());
EXPECT_TRUE(omnibox_view->IsSelectAll());
ASSERT_NO_FATAL_FAILURE(SendKeySequence(kSearchSingleCharKeys));
ASSERT_NO_FATAL_FAILURE(
AddHistoryEntry(kHistoryFoobar, Time::Now() - TimeDelta::FromHours(1)));
- // Type "foo" to trigger inline autocomplete.
- ASSERT_NO_FATAL_FAILURE(SendKeySequence(kSearchKeywordKeys));
+ // Type "fo" to trigger inline autocomplete.
+ ASSERT_NO_FATAL_FAILURE(SendKeySequence(kSearchKeywordPrefixKeys));
ASSERT_NO_FATAL_FAILURE(WaitForAutocompleteControllerDone());
ASSERT_TRUE(omnibox_view->model()->popup_model()->IsOpen());
ASSERT_NE(search_keyword, omnibox_view->GetText());
ASSERT_FALSE(omnibox_view->model()->is_keyword_hint());
ASSERT_TRUE(omnibox_view->model()->keyword().empty());
+ // Add the "o". Inline autocompletion should still happen, but now we
+ // should also get a keyword hint because we've typed a keyword exactly.
+ ASSERT_NO_FATAL_FAILURE(SendKeySequence(kSearchKeywordCompletionKeys));
+ ASSERT_NO_FATAL_FAILURE(WaitForAutocompleteControllerDone());
+ ASSERT_TRUE(omnibox_view->model()->popup_model()->IsOpen());
+ ASSERT_NE(search_keyword, omnibox_view->GetText());
+ ASSERT_TRUE(omnibox_view->model()->is_keyword_hint());
+ ASSERT_FALSE(omnibox_view->model()->keyword().empty());
+
// Trigger keyword mode by space.
ASSERT_NO_FATAL_FAILURE(SendKey(ui::VKEY_SPACE, 0));
ASSERT_FALSE(omnibox_view->model()->is_keyword_hint());
ASSERT_TRUE(popup_model);
// Input something to trigger results.
- const wchar_t kKeys[] = { ui::VKEY_B, ui::VKEY_A, ui::VKEY_R, 0 };
+ const ui::KeyboardCode kKeys[] = {
+ ui::VKEY_B, ui::VKEY_A, ui::VKEY_R, ui::VKEY_UNKNOWN
+ };
ASSERT_NO_FATAL_FAILURE(SendKeySequence(kKeys));
ASSERT_NO_FATAL_FAILURE(WaitForAutocompleteControllerDone());
ASSERT_TRUE(popup_model->IsOpen());
ASSERT_TRUE(popup_model);
// Input something to trigger results.
- const wchar_t kKeys[] = { ui::VKEY_B, ui::VKEY_A, ui::VKEY_R, 0 };
+ const ui::KeyboardCode kKeys[] = {
+ ui::VKEY_B, ui::VKEY_A, ui::VKEY_R, ui::VKEY_UNKNOWN
+ };
ASSERT_NO_FATAL_FAILURE(SendKeySequence(kKeys));
ASSERT_NO_FATAL_FAILURE(WaitForAutocompleteControllerDone());
ASSERT_TRUE(popup_model->IsOpen());