Chromium Code Reviews| Index: chrome/browser/instant/instant_extended_browsertest.cc |
| diff --git a/chrome/browser/instant/instant_extended_browsertest.cc b/chrome/browser/instant/instant_extended_browsertest.cc |
| index 08f8b4d094579c90ea12e3e047faf8820e4c4b55..25c33577a53ff5a44c8520a82c824fcd3681ae28 100644 |
| --- a/chrome/browser/instant/instant_extended_browsertest.cc |
| +++ b/chrome/browser/instant/instant_extended_browsertest.cc |
| @@ -2,9 +2,12 @@ |
| // Use of this source code is governed by a BSD-style license that can be |
| // found in the LICENSE file. |
| +#include "chrome/browser/instant/instant_commit_type.h" |
| #include "chrome/browser/instant/instant_loader.h" |
| #include "chrome/browser/instant/instant_test_utils.h" |
| #include "chrome/browser/ui/search/search.h" |
| +#include "chrome/common/instant_types.h" |
| +#include "chrome/common/search_types.h" |
| #include "chrome/test/base/interactive_test_utils.h" |
| #include "chrome/test/base/ui_test_utils.h" |
| @@ -12,8 +15,9 @@ class InstantExtendedTest : public InstantTestBase { |
| protected: |
| virtual void SetUpInProcessBrowserTestFixture() OVERRIDE { |
| chrome::search::EnableInstantExtendedAPIForTesting(); |
| - ASSERT_TRUE(test_server()->Start()); |
| - instant_url_ = test_server()->GetURL("files/instant_extended.html"); |
| + ASSERT_TRUE(https_test_server_->Start()); |
| + instant_url_ = https_test_server_-> |
| + GetURL("files/instant_extended.html?espv=1"); |
| } |
| }; |
| @@ -80,3 +84,54 @@ IN_PROC_BROWSER_TEST_F(InstantExtendedTest, InputShowsOverlay) { |
| EXPECT_TRUE(instant()->model()->mode().is_search_suggestions()); |
| EXPECT_EQ(preview_tab, instant()->GetPreviewContents()); |
| } |
| + |
| +// Test that omnibox text is correctly set when overlay is committed with Enter. |
| +IN_PROC_BROWSER_TEST_F(InstantExtendedTest, OmniboxTextUponEnterCommit) { |
| + ASSERT_NO_FATAL_FAILURE(SetupInstant()); |
| + FocusOmniboxAndWaitForInstantSupport(); |
| + |
| + // Set the text, and wait for suggestions to show up. |
| + SetOmniboxTextAndWaitForInstantToShow("santa"); |
| + EXPECT_EQ(ASCIIToUTF16("santa"), omnibox()->GetText()); |
| + |
| + // Set autocomplete text (grey text). |
| + EXPECT_TRUE(ExecuteScript( |
| + "window.chrome.searchBox.setAutocompleteText('santa claus', 2)")); |
| + |
| + // Make the InstantController think we are in Search Suggestions. |
| + chrome::search::Mode mode; |
| + mode.mode = chrome::search::Mode::MODE_SEARCH_SUGGESTIONS; |
| + instant()->model()->SetPreviewState(mode, 100, INSTANT_SIZE_PERCENT); |
|
sreeram
2013/02/01 22:03:24
These lines (98-104) are hacking the public APIs t
Mathieu
2013/02/04 20:37:36
Done.
|
| + |
| + // Commit the overlay by pressing 'Enter'. |
| + instant()->CommitIfPossible(INSTANT_COMMIT_PRESSED_ENTER); |
| + |
| + // 'Enter' commits the query as it was typed. |
| + EXPECT_EQ(ASCIIToUTF16("santa"), omnibox()->GetText()); |
|
sreeram
2013/02/01 22:03:24
You should check that omnibox()->GetInstantSuggest
Mathieu
2013/02/04 20:37:36
Done.
|
| +} |
| + |
| +// Test that omnibox text is correctly set when overlay is committed with focus |
| +// lost. |
| +IN_PROC_BROWSER_TEST_F(InstantExtendedTest, OmniboxTextUponFocusLostCommit) { |
| + ASSERT_NO_FATAL_FAILURE(SetupInstant()); |
| + FocusOmniboxAndWaitForInstantSupport(); |
| + |
| + // Set the text, and wait for suggestions to show up. |
| + SetOmniboxTextAndWaitForInstantToShow("johnny"); |
| + EXPECT_EQ(ASCIIToUTF16("johnny"), omnibox()->GetText()); |
| + |
| + // Set autocomplete text (grey text). |
| + EXPECT_TRUE(ExecuteScript( |
| + "window.chrome.searchBox.setAutocompleteText('johnny depp', 2)")); |
| + |
| + // Make the InstantController think we are in Search Suggestions. |
| + chrome::search::Mode mode; |
| + mode.mode = chrome::search::Mode::MODE_SEARCH_SUGGESTIONS; |
| + instant()->model()->SetPreviewState(mode, 100, INSTANT_SIZE_PERCENT); |
| + |
| + // Commit the overlay by lost focus (e.g. clicking on the page). |
| + instant()->CommitIfPossible(INSTANT_COMMIT_FOCUS_LOST); |
| + |
| + // Search term extraction should kick in with the autocompleted text. |
| + EXPECT_EQ(ASCIIToUTF16("johnny depp"), omnibox()->GetText()); |
| +} |