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 <stdio.h> | 5 #include <stdio.h> |
6 | 6 |
7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/strings/string16.h" | 8 #include "base/strings/string16.h" |
9 #include "base/strings/string_util.h" | 9 #include "base/strings/string_util.h" |
10 #include "base/strings/utf_string_conversions.h" | 10 #include "base/strings/utf_string_conversions.h" |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
50 using base::ASCIIToUTF16; | 50 using base::ASCIIToUTF16; |
51 using base::UTF16ToUTF8; | 51 using base::UTF16ToUTF8; |
52 using base::Time; | 52 using base::Time; |
53 using base::TimeDelta; | 53 using base::TimeDelta; |
54 | 54 |
55 namespace { | 55 namespace { |
56 | 56 |
57 const char kSearchKeyword[] = "foo"; | 57 const char kSearchKeyword[] = "foo"; |
58 const char kSearchKeyword2[] = "footest.com"; | 58 const char kSearchKeyword2[] = "footest.com"; |
59 const wchar_t kSearchKeywordKeys[] = { ui::VKEY_F, ui::VKEY_O, ui::VKEY_O, 0 }; | 59 const wchar_t kSearchKeywordKeys[] = { ui::VKEY_F, ui::VKEY_O, ui::VKEY_O, 0 }; |
60 const wchar_t kSearchKeywordPrefixKeys[] = { ui::VKEY_F, ui::VKEY_O, 0 }; | |
61 const wchar_t kSearchKeywordCompletionKeys[] = { ui::VKEY_O, 0 }; | |
Peter Kasting
2014/08/05 21:03:47
Nit: Since these are only used by SendKeySequence(
Mark P
2014/08/05 22:20:06
Done.
| |
60 const char kSearchURL[] = "http://www.foo.com/search?q={searchTerms}"; | 62 const char kSearchURL[] = "http://www.foo.com/search?q={searchTerms}"; |
61 const char kSearchShortName[] = "foo"; | 63 const char kSearchShortName[] = "foo"; |
62 const char kSearchText[] = "abc"; | 64 const char kSearchText[] = "abc"; |
63 const wchar_t kSearchTextKeys[] = { ui::VKEY_A, ui::VKEY_B, ui::VKEY_C, 0 }; | 65 const wchar_t kSearchTextKeys[] = { ui::VKEY_A, ui::VKEY_B, ui::VKEY_C, 0 }; |
64 const char kSearchTextURL[] = "http://www.foo.com/search?q=abc"; | 66 const char kSearchTextURL[] = "http://www.foo.com/search?q=abc"; |
65 | 67 |
66 const char kInlineAutocompleteText[] = "def"; | 68 const char kInlineAutocompleteText[] = "def"; |
67 const wchar_t kInlineAutocompleteTextKeys[] = { | 69 const wchar_t kInlineAutocompleteTextKeys[] = { |
68 ui::VKEY_D, ui::VKEY_E, ui::VKEY_F, 0 | 70 ui::VKEY_D, ui::VKEY_E, ui::VKEY_F, 0 |
69 }; | 71 }; |
(...skipping 852 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
922 // Space should accept keyword even when inline autocomplete is available. | 924 // Space should accept keyword even when inline autocomplete is available. |
923 omnibox_view->SetUserText(base::string16()); | 925 omnibox_view->SetUserText(base::string16()); |
924 const TestHistoryEntry kHistoryFoobar = { | 926 const TestHistoryEntry kHistoryFoobar = { |
925 "http://www.foobar.com", "Page foobar", 100, 100, true | 927 "http://www.foobar.com", "Page foobar", 100, 100, true |
926 }; | 928 }; |
927 | 929 |
928 // Add a history entry to trigger inline autocomplete when typing "foo". | 930 // Add a history entry to trigger inline autocomplete when typing "foo". |
929 ASSERT_NO_FATAL_FAILURE( | 931 ASSERT_NO_FATAL_FAILURE( |
930 AddHistoryEntry(kHistoryFoobar, Time::Now() - TimeDelta::FromHours(1))); | 932 AddHistoryEntry(kHistoryFoobar, Time::Now() - TimeDelta::FromHours(1))); |
931 | 933 |
932 // Type "foo" to trigger inline autocomplete. | 934 // Type "fo" to trigger inline autocomplete. |
933 ASSERT_NO_FATAL_FAILURE(SendKeySequence(kSearchKeywordKeys)); | 935 ASSERT_NO_FATAL_FAILURE(SendKeySequence(kSearchKeywordPrefixKeys)); |
934 ASSERT_NO_FATAL_FAILURE(WaitForAutocompleteControllerDone()); | 936 ASSERT_NO_FATAL_FAILURE(WaitForAutocompleteControllerDone()); |
935 ASSERT_TRUE(omnibox_view->model()->popup_model()->IsOpen()); | 937 ASSERT_TRUE(omnibox_view->model()->popup_model()->IsOpen()); |
936 ASSERT_NE(search_keyword, omnibox_view->GetText()); | 938 ASSERT_NE(search_keyword, omnibox_view->GetText()); |
937 | 939 |
938 // Keyword hint shouldn't be visible. | 940 // Keyword hint shouldn't be visible. |
939 ASSERT_FALSE(omnibox_view->model()->is_keyword_hint()); | 941 ASSERT_FALSE(omnibox_view->model()->is_keyword_hint()); |
940 ASSERT_TRUE(omnibox_view->model()->keyword().empty()); | 942 ASSERT_TRUE(omnibox_view->model()->keyword().empty()); |
941 | 943 |
944 // Add the "o". Inline autocompletion should still happen, but now we | |
945 // should also get a keyword hint because we've typed a keyword exactly. | |
946 ASSERT_NO_FATAL_FAILURE(SendKeySequence(kSearchKeywordCompletionKeys)); | |
947 ASSERT_NO_FATAL_FAILURE(WaitForAutocompleteControllerDone()); | |
948 ASSERT_TRUE(omnibox_view->model()->popup_model()->IsOpen()); | |
949 ASSERT_NE(search_keyword, omnibox_view->GetText()); | |
950 ASSERT_TRUE(omnibox_view->model()->is_keyword_hint()); | |
951 ASSERT_FALSE(omnibox_view->model()->keyword().empty()); | |
952 | |
942 // Trigger keyword mode by space. | 953 // Trigger keyword mode by space. |
943 ASSERT_NO_FATAL_FAILURE(SendKey(ui::VKEY_SPACE, 0)); | 954 ASSERT_NO_FATAL_FAILURE(SendKey(ui::VKEY_SPACE, 0)); |
944 ASSERT_FALSE(omnibox_view->model()->is_keyword_hint()); | 955 ASSERT_FALSE(omnibox_view->model()->is_keyword_hint()); |
945 ASSERT_EQ(search_keyword, omnibox_view->model()->keyword()); | 956 ASSERT_EQ(search_keyword, omnibox_view->model()->keyword()); |
946 ASSERT_TRUE(omnibox_view->GetText().empty()); | 957 ASSERT_TRUE(omnibox_view->GetText().empty()); |
947 | 958 |
948 // Space in the middle of a temporary text, which separates the text into | 959 // Space in the middle of a temporary text, which separates the text into |
949 // keyword and replacement portions, should trigger keyword mode. | 960 // keyword and replacement portions, should trigger keyword mode. |
950 omnibox_view->SetUserText(base::string16()); | 961 omnibox_view->SetUserText(base::string16()); |
951 ASSERT_NO_FATAL_FAILURE(SendKeySequence(kSearchKeywordKeys)); | 962 ASSERT_NO_FATAL_FAILURE(SendKeySequence(kSearchKeywordKeys)); |
(...skipping 834 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1786 omnibox_view->Update(); | 1797 omnibox_view->Update(); |
1787 EXPECT_EQ(url_c, omnibox_view->GetText()); | 1798 EXPECT_EQ(url_c, omnibox_view->GetText()); |
1788 } | 1799 } |
1789 | 1800 |
1790 IN_PROC_BROWSER_TEST_F(OmniboxViewTest, EscDisablesSearchTermReplacement) { | 1801 IN_PROC_BROWSER_TEST_F(OmniboxViewTest, EscDisablesSearchTermReplacement) { |
1791 browser()->toolbar_model()->set_url_replacement_enabled(true); | 1802 browser()->toolbar_model()->set_url_replacement_enabled(true); |
1792 chrome::FocusLocationBar(browser()); | 1803 chrome::FocusLocationBar(browser()); |
1793 ASSERT_NO_FATAL_FAILURE(SendKey(ui::VKEY_ESCAPE, 0)); | 1804 ASSERT_NO_FATAL_FAILURE(SendKey(ui::VKEY_ESCAPE, 0)); |
1794 EXPECT_FALSE(browser()->toolbar_model()->url_replacement_enabled()); | 1805 EXPECT_FALSE(browser()->toolbar_model()->url_replacement_enabled()); |
1795 } | 1806 } |
OLD | NEW |