OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "chrome/browser/instant/instant_commit_type.h" | 5 #include "chrome/browser/instant/instant_commit_type.h" |
6 #include "chrome/browser/instant/instant_loader.h" | 6 #include "chrome/browser/instant/instant_loader.h" |
7 #include "chrome/browser/instant/instant_test_utils.h" | 7 #include "chrome/browser/instant/instant_test_utils.h" |
8 #include "chrome/browser/ui/search/search.h" | 8 #include "chrome/browser/ui/search/search.h" |
9 #include "chrome/test/base/interactive_test_utils.h" | 9 #include "chrome/test/base/interactive_test_utils.h" |
10 #include "chrome/test/base/ui_test_utils.h" | 10 #include "chrome/test/base/ui_test_utils.h" |
(...skipping 15 matching lines...) Expand all Loading... |
26 omnibox()->model()->OnUpOrDownKeyPressed(1); | 26 omnibox()->model()->OnUpOrDownKeyPressed(1); |
27 // Wait for JavaScript to run the key handler by executing a blank script. | 27 // Wait for JavaScript to run the key handler by executing a blank script. |
28 EXPECT_TRUE(ExecuteScript(std::string())); | 28 EXPECT_TRUE(ExecuteScript(std::string())); |
29 } | 29 } |
30 | 30 |
31 void SendUpArrow() { | 31 void SendUpArrow() { |
32 omnibox()->model()->OnUpOrDownKeyPressed(-1); | 32 omnibox()->model()->OnUpOrDownKeyPressed(-1); |
33 // Wait for JavaScript to run the key handler by executing a blank script. | 33 // Wait for JavaScript to run the key handler by executing a blank script. |
34 EXPECT_TRUE(ExecuteScript(std::string())); | 34 EXPECT_TRUE(ExecuteScript(std::string())); |
35 } | 35 } |
| 36 |
| 37 void SendEscape() { |
| 38 omnibox()->model()->OnEscapeKeyPressed(); |
| 39 // Wait for JavaScript to run the key handler by executing a blank script. |
| 40 EXPECT_TRUE(ExecuteScript(std::string())); |
| 41 } |
36 }; | 42 }; |
37 | 43 |
38 IN_PROC_BROWSER_TEST_F(InstantExtendedTest, ExtendedModeIsOn) { | 44 IN_PROC_BROWSER_TEST_F(InstantExtendedTest, ExtendedModeIsOn) { |
39 ASSERT_NO_FATAL_FAILURE(SetupInstant()); | 45 ASSERT_NO_FATAL_FAILURE(SetupInstant()); |
40 EXPECT_TRUE(instant()->extended_enabled_); | 46 EXPECT_TRUE(instant()->extended_enabled_); |
41 } | 47 } |
42 | 48 |
43 // Test that Instant is preloaded when the omnibox is focused. | 49 // Test that Instant is preloaded when the omnibox is focused. |
44 IN_PROC_BROWSER_TEST_F(InstantExtendedTest, OmniboxFocusLoadsInstant) { | 50 IN_PROC_BROWSER_TEST_F(InstantExtendedTest, OmniboxFocusLoadsInstant) { |
45 ASSERT_NO_FATAL_FAILURE(SetupInstant()); | 51 ASSERT_NO_FATAL_FAILURE(SetupInstant()); |
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
143 // Commit the overlay by lost focus (e.g. clicking on the page). | 149 // Commit the overlay by lost focus (e.g. clicking on the page). |
144 instant()->CommitIfPossible(INSTANT_COMMIT_FOCUS_LOST); | 150 instant()->CommitIfPossible(INSTANT_COMMIT_FOCUS_LOST); |
145 | 151 |
146 // Search term extraction should kick in with the autocompleted text. | 152 // Search term extraction should kick in with the autocompleted text. |
147 EXPECT_EQ(ASCIIToUTF16("johnny depp"), omnibox()->GetText()); | 153 EXPECT_EQ(ASCIIToUTF16("johnny depp"), omnibox()->GetText()); |
148 | 154 |
149 // Suggestion should be cleared at this point. | 155 // Suggestion should be cleared at this point. |
150 EXPECT_EQ(ASCIIToUTF16(""), omnibox()->GetInstantSuggestion()); | 156 EXPECT_EQ(ASCIIToUTF16(""), omnibox()->GetInstantSuggestion()); |
151 } | 157 } |
152 | 158 |
153 // This test simulates a search provider using the InstantExtended API to | |
154 // navigate through the suggested results and back to the original user query. | |
155 IN_PROC_BROWSER_TEST_F(InstantExtendedTest, NavigateSuggestionsWithArrowKeys) { | 159 IN_PROC_BROWSER_TEST_F(InstantExtendedTest, NavigateSuggestionsWithArrowKeys) { |
| 160 // This test simulates a search provider using the InstantExtended API to |
| 161 // navigate through the suggested results and back to the original user query. |
156 ASSERT_NO_FATAL_FAILURE(SetupInstant()); | 162 ASSERT_NO_FATAL_FAILURE(SetupInstant()); |
157 FocusOmniboxAndWaitForInstantSupport(); | 163 FocusOmniboxAndWaitForInstantSupport(); |
158 | 164 |
159 SetOmniboxTextAndWaitForInstantToShow("hello"); | 165 SetOmniboxTextAndWaitForInstantToShow("hello"); |
160 EXPECT_EQ("hello", GetOmniboxText()); | 166 EXPECT_EQ("hello", GetOmniboxText()); |
161 | 167 |
162 SendDownArrow(); | 168 SendDownArrow(); |
163 EXPECT_EQ("result 1", GetOmniboxText()); | 169 EXPECT_EQ("result 1", GetOmniboxText()); |
164 SendDownArrow(); | 170 SendDownArrow(); |
165 EXPECT_EQ("result 2", GetOmniboxText()); | 171 EXPECT_EQ("result 2", GetOmniboxText()); |
166 SendUpArrow(); | 172 SendUpArrow(); |
167 EXPECT_EQ("result 1", GetOmniboxText()); | 173 EXPECT_EQ("result 1", GetOmniboxText()); |
168 SendUpArrow(); | 174 SendUpArrow(); |
169 EXPECT_EQ("hello", GetOmniboxText()); | 175 EXPECT_EQ("hello", GetOmniboxText()); |
170 } | 176 } |
| 177 |
| 178 IN_PROC_BROWSER_TEST_F(InstantExtendedTest, NavigateSuggestionsAndHitEscape) { |
| 179 // This test simulates a search provider using the InstantExtended API to |
| 180 // navigate through the suggested results and hitting escape to get back to |
| 181 // the original user query. |
| 182 ASSERT_NO_FATAL_FAILURE(SetupInstant()); |
| 183 FocusOmniboxAndWaitForInstantSupport(); |
| 184 |
| 185 SetOmniboxTextAndWaitForInstantToShow("hello"); |
| 186 EXPECT_EQ("hello", GetOmniboxText()); |
| 187 |
| 188 SendDownArrow(); |
| 189 EXPECT_EQ("result 1", GetOmniboxText()); |
| 190 SendDownArrow(); |
| 191 EXPECT_EQ("result 2", GetOmniboxText()); |
| 192 SendEscape(); |
| 193 EXPECT_EQ("hello", GetOmniboxText()); |
| 194 } |
OLD | NEW |