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

Side by Side Diff: chrome/browser/ui/omnibox/omnibox_view_browsertest.cc

Issue 1855423003: Interpret '?' and Ctrl-K or Ctrl-E as putting omnibox in keyword search mode for Default Search Pro… (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Really removed call to UpdatePopup Created 4 years, 6 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
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 <stddef.h> 5 #include <stddef.h>
6 #include <stdio.h> 6 #include <stdio.h>
7 7
8 #include "base/command_line.h" 8 #include "base/command_line.h"
9 #include "base/macros.h" 9 #include "base/macros.h"
10 #include "base/scoped_observer.h" 10 #include "base/scoped_observer.h"
(...skipping 851 matching lines...) Expand 10 before | Expand all | Expand 10 after
862 862
863 // Check if RevertAll() can set text and cursor correctly. 863 // Check if RevertAll() can set text and cursor correctly.
864 omnibox_view->RevertAll(); 864 omnibox_view->RevertAll();
865 EXPECT_FALSE(omnibox_view->IsSelectAll()); 865 EXPECT_FALSE(omnibox_view->IsSelectAll());
866 EXPECT_EQ(old_text, omnibox_view->GetText()); 866 EXPECT_EQ(old_text, omnibox_view->GetText());
867 omnibox_view->GetSelectionBounds(&start, &end); 867 omnibox_view->GetSelectionBounds(&start, &end);
868 EXPECT_EQ(old_text.size(), start); 868 EXPECT_EQ(old_text.size(), start);
869 EXPECT_EQ(old_text.size(), end); 869 EXPECT_EQ(old_text.size(), end);
870 } 870 }
871 871
872 IN_PROC_BROWSER_TEST_F(OmniboxViewTest, AcceptKeywordByTypingQuestionMark) {
873 OmniboxView* omnibox_view = NULL;
874 ASSERT_NO_FATAL_FAILURE(GetOmniboxView(&omnibox_view));
875
876 base::string16 search_keyword(ASCIIToUTF16(kSearchKeyword));
877
878 // If the user gets into keyword mode by typing '?', they should be put into
879 // keyword mode for their default search provider. If they press backspace,
880 // they should be left with '?' in the omnibox.
Peter Kasting 2016/06/01 01:07:27 Nit: The second sentence here really belongs as pa
Tom (Use chromium acct) 2016/06/02 19:24:40 Done.
881 ASSERT_NO_FATAL_FAILURE(SendKey(ui::VKEY_OEM_2, ui::EF_SHIFT_DOWN));
882 ASSERT_FALSE(omnibox_view->model()->is_keyword_hint());
883 ASSERT_TRUE(omnibox_view->model()->is_keyword_selected());
884 ASSERT_EQ(search_keyword, omnibox_view->model()->keyword());
885 ASSERT_EQ(base::string16(), omnibox_view->GetText());
886
887 // The user presses backspace.
888 ASSERT_NO_FATAL_FAILURE(SendKey(ui::VKEY_BACK, 0));
889 EXPECT_EQ(base::ASCIIToUTF16("?"), omnibox_view->GetText());
890 EXPECT_EQ(base::string16(), omnibox_view->model()->keyword());
891 EXPECT_FALSE(omnibox_view->model()->is_keyword_hint());
892 EXPECT_FALSE(omnibox_view->model()->is_keyword_selected());
893 }
894
872 IN_PROC_BROWSER_TEST_F(OmniboxViewTest, AcceptKeywordBySpace) { 895 IN_PROC_BROWSER_TEST_F(OmniboxViewTest, AcceptKeywordBySpace) {
873 OmniboxView* omnibox_view = NULL; 896 OmniboxView* omnibox_view = NULL;
874 ASSERT_NO_FATAL_FAILURE(GetOmniboxView(&omnibox_view)); 897 ASSERT_NO_FATAL_FAILURE(GetOmniboxView(&omnibox_view));
875 898
876 base::string16 search_keyword(ASCIIToUTF16(kSearchKeyword)); 899 base::string16 search_keyword(ASCIIToUTF16(kSearchKeyword));
877 900
878 // Trigger keyword hint mode. 901 // Trigger keyword hint mode.
879 ASSERT_NO_FATAL_FAILURE(SendKeySequence(kSearchKeywordKeys)); 902 ASSERT_NO_FATAL_FAILURE(SendKeySequence(kSearchKeywordKeys));
880 ASSERT_TRUE(omnibox_view->model()->is_keyword_hint()); 903 ASSERT_TRUE(omnibox_view->model()->is_keyword_hint());
881 ASSERT_EQ(search_keyword, omnibox_view->model()->keyword()); 904 ASSERT_EQ(search_keyword, omnibox_view->model()->keyword());
(...skipping 1084 matching lines...) Expand 10 before | Expand all | Expand 10 after
1966 1989
1967 // Now Shift+Right should do nothing, and Shift+Left should reduce. 1990 // Now Shift+Right should do nothing, and Shift+Left should reduce.
1968 // At the end, so Shift+Right should do nothing. 1991 // At the end, so Shift+Right should do nothing.
1969 ASSERT_NO_FATAL_FAILURE(SendKey(ui::VKEY_RIGHT, ui::EF_SHIFT_DOWN)); 1992 ASSERT_NO_FATAL_FAILURE(SendKey(ui::VKEY_RIGHT, ui::EF_SHIFT_DOWN));
1970 EXPECT_EQ(2u, GetSelectionSize(omnibox_view)); 1993 EXPECT_EQ(2u, GetSelectionSize(omnibox_view));
1971 1994
1972 // And Left should reduce by one character. 1995 // And Left should reduce by one character.
1973 ASSERT_NO_FATAL_FAILURE(SendKey(ui::VKEY_LEFT, ui::EF_SHIFT_DOWN)); 1996 ASSERT_NO_FATAL_FAILURE(SendKey(ui::VKEY_LEFT, ui::EF_SHIFT_DOWN));
1974 EXPECT_EQ(1u, GetSelectionSize(omnibox_view)); 1997 EXPECT_EQ(1u, GetSelectionSize(omnibox_view));
1975 } 1998 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698