OLD | NEW |
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 Loading... |
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. |
| 880 ASSERT_NO_FATAL_FAILURE(SendKey(ui::VKEY_OEM_2, ui::EF_SHIFT_DOWN)); |
| 881 ASSERT_FALSE(omnibox_view->model()->is_keyword_hint()); |
| 882 ASSERT_TRUE(omnibox_view->model()->is_keyword_selected()); |
| 883 ASSERT_EQ(search_keyword, omnibox_view->model()->keyword()); |
| 884 ASSERT_EQ(base::string16(), omnibox_view->GetText()); |
| 885 |
| 886 // If the user press backspace, they should be left with '?' in the omnibox. |
| 887 ASSERT_NO_FATAL_FAILURE(SendKey(ui::VKEY_BACK, 0)); |
| 888 EXPECT_EQ(base::ASCIIToUTF16("?"), omnibox_view->GetText()); |
| 889 EXPECT_EQ(base::string16(), omnibox_view->model()->keyword()); |
| 890 EXPECT_FALSE(omnibox_view->model()->is_keyword_hint()); |
| 891 EXPECT_FALSE(omnibox_view->model()->is_keyword_selected()); |
| 892 } |
| 893 |
872 IN_PROC_BROWSER_TEST_F(OmniboxViewTest, AcceptKeywordBySpace) { | 894 IN_PROC_BROWSER_TEST_F(OmniboxViewTest, AcceptKeywordBySpace) { |
873 OmniboxView* omnibox_view = NULL; | 895 OmniboxView* omnibox_view = NULL; |
874 ASSERT_NO_FATAL_FAILURE(GetOmniboxView(&omnibox_view)); | 896 ASSERT_NO_FATAL_FAILURE(GetOmniboxView(&omnibox_view)); |
875 | 897 |
876 base::string16 search_keyword(ASCIIToUTF16(kSearchKeyword)); | 898 base::string16 search_keyword(ASCIIToUTF16(kSearchKeyword)); |
877 | 899 |
878 // Trigger keyword hint mode. | 900 // Trigger keyword hint mode. |
879 ASSERT_NO_FATAL_FAILURE(SendKeySequence(kSearchKeywordKeys)); | 901 ASSERT_NO_FATAL_FAILURE(SendKeySequence(kSearchKeywordKeys)); |
880 ASSERT_TRUE(omnibox_view->model()->is_keyword_hint()); | 902 ASSERT_TRUE(omnibox_view->model()->is_keyword_hint()); |
881 ASSERT_EQ(search_keyword, omnibox_view->model()->keyword()); | 903 ASSERT_EQ(search_keyword, omnibox_view->model()->keyword()); |
(...skipping 1084 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1966 | 1988 |
1967 // Now Shift+Right should do nothing, and Shift+Left should reduce. | 1989 // Now Shift+Right should do nothing, and Shift+Left should reduce. |
1968 // At the end, so Shift+Right should do nothing. | 1990 // At the end, so Shift+Right should do nothing. |
1969 ASSERT_NO_FATAL_FAILURE(SendKey(ui::VKEY_RIGHT, ui::EF_SHIFT_DOWN)); | 1991 ASSERT_NO_FATAL_FAILURE(SendKey(ui::VKEY_RIGHT, ui::EF_SHIFT_DOWN)); |
1970 EXPECT_EQ(2u, GetSelectionSize(omnibox_view)); | 1992 EXPECT_EQ(2u, GetSelectionSize(omnibox_view)); |
1971 | 1993 |
1972 // And Left should reduce by one character. | 1994 // And Left should reduce by one character. |
1973 ASSERT_NO_FATAL_FAILURE(SendKey(ui::VKEY_LEFT, ui::EF_SHIFT_DOWN)); | 1995 ASSERT_NO_FATAL_FAILURE(SendKey(ui::VKEY_LEFT, ui::EF_SHIFT_DOWN)); |
1974 EXPECT_EQ(1u, GetSelectionSize(omnibox_view)); | 1996 EXPECT_EQ(1u, GetSelectionSize(omnibox_view)); |
1975 } | 1997 } |
OLD | NEW |