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

Unified Diff: chrome/browser/instant/instant_extended_browsertest.cc

Issue 11889003: Fixing ESC in instant-extended. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Added issue number to TODO. Created 7 years, 10 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 side-by-side diff with in-line comments
Download patch
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 33195fc87f0dd666663ae9343beea3d648726f7b..2252d48d12e92a2d0d25e06836ce87afa2d7735d 100644
--- a/chrome/browser/instant/instant_extended_browsertest.cc
+++ b/chrome/browser/instant/instant_extended_browsertest.cc
@@ -54,6 +54,12 @@ class InstantExtendedTest : public InstantTestBase {
// Wait for JavaScript to run the key handler by executing a blank script.
EXPECT_TRUE(ExecuteScript(std::string()));
}
+
+ void SendEscape() {
+ omnibox()->model()->OnEscapeKeyPressed();
+ // Wait for JavaScript to run the key handler by executing a blank script.
+ EXPECT_TRUE(ExecuteScript(std::string()));
+ }
};
IN_PROC_BROWSER_TEST_F(InstantExtendedTest, ExtendedModeIsOn) {
@@ -188,6 +194,53 @@ IN_PROC_BROWSER_TEST_F(InstantExtendedTest, NavigateSuggestionsWithArrowKeys) {
EXPECT_EQ("result 1", GetOmniboxText());
SendUpArrow();
EXPECT_EQ("hello", GetOmniboxText());
+
+ // Ensure that the API's value is set correctly.
+ std::string result;
+ EXPECT_TRUE(GetStringFromJS(instant()->GetPreviewContents(),
+ "window.chrome.searchBox.value",
+ &result));
+ EXPECT_EQ("hello", result);
+
+ EXPECT_TRUE(HasUserInputInProgress());
+ // TODO(beaudoin): Figure out why this fails.
+ // EXPECT_FALSE(HasTemporaryText());
+
+ // Commit the search by pressing Enter.
+ browser()->window()->GetLocationBar()->AcceptInput();
+ EXPECT_EQ("hello", GetOmniboxText());
+}
+
+// This test simulates a search provider using the InstantExtended API to
+// navigate through the suggested results and hitting escape to get back to the
+// original user query.
+IN_PROC_BROWSER_TEST_F(InstantExtendedTest, NavigateSuggestionsAndHitEscape) {
+ ASSERT_NO_FATAL_FAILURE(SetupInstant());
+ FocusOmniboxAndWaitForInstantSupport();
+
+ SetOmniboxTextAndWaitForInstantToShow("hello");
+ EXPECT_EQ("hello", GetOmniboxText());
+
+ SendDownArrow();
+ EXPECT_EQ("result 1", GetOmniboxText());
+ SendDownArrow();
+ EXPECT_EQ("result 2", GetOmniboxText());
+ SendEscape();
+ EXPECT_EQ("hello", GetOmniboxText());
+
+ // Ensure that the API's value is set correctly.
+ std::string result;
+ EXPECT_TRUE(GetStringFromJS(instant()->GetPreviewContents(),
+ "window.chrome.searchBox.value",
+ &result));
+ EXPECT_EQ("hello", result);
+
+ EXPECT_TRUE(HasUserInputInProgress());
+ EXPECT_FALSE(HasTemporaryText());
+
+ // Commit the search by pressing Enter.
+ browser()->window()->GetLocationBar()->AcceptInput();
+ EXPECT_EQ("hello", GetOmniboxText());
}
IN_PROC_BROWSER_TEST_F(InstantExtendedTest, NTPIsPreloaded) {

Powered by Google App Engine
This is Rietveld 408576698