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

Unified Diff: chrome/browser/ui/search/instant_extended_browsertest.cc

Issue 12895007: Send onsubmit query down to the instant extended overlay page when a navigation is performed from t… (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Revert to original browser test, add comment re potential brittleness for posterity. Created 7 years, 8 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
« no previous file with comments | « chrome/browser/ui/search/instant_controller.cc ('k') | chrome/renderer/searchbox/searchbox.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/ui/search/instant_extended_browsertest.cc
diff --git a/chrome/browser/ui/search/instant_extended_browsertest.cc b/chrome/browser/ui/search/instant_extended_browsertest.cc
index 981ce6a0f8bb5ae7dca867f80b7098ae1311a202..807e2c3c1258ec07b16e0cac3bbd17bd187c1f64 100644
--- a/chrome/browser/ui/search/instant_extended_browsertest.cc
+++ b/chrome/browser/ui/search/instant_extended_browsertest.cc
@@ -448,13 +448,61 @@ IN_PROC_BROWSER_TEST_F(InstantExtendedTest, NavigateSuggestionsWithArrowKeys) {
// 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 back to the original user query.
+// If this test starts to flake, it may be that the second call to AcceptInput
+// below causes instant()->instant_tab() to no longer be valid due to e.g. a
+// navigation. In that case, see https://codereview.chromium.org/12895007/#msg28
+// and onwards for possible alternatives.
+IN_PROC_BROWSER_TEST_F(InstantExtendedTest,
+ NavigateToURLSuggestionHitEnterAndLookForSubmit) {
+ ASSERT_NO_FATAL_FAILURE(SetupInstant(browser()));
+ FocusOmniboxAndWaitForInstantExtendedSupport();
+
+ // Create an observer to wait for the instant tab to support Instant.
+ content::WindowedNotificationObserver observer(
+ chrome::NOTIFICATION_INSTANT_TAB_SUPPORT_DETERMINED,
+ content::NotificationService::AllSources());
+
+ // Do a search and commit it.
+ SetOmniboxTextAndWaitForOverlayToShow("hello k");
+ EXPECT_EQ(ASCIIToUTF16("hello k"), omnibox()->GetText());
+ browser()->window()->GetLocationBar()->AcceptInput();
+ observer.Wait();
+
+ SetOmniboxText("http");
+ EXPECT_EQ("http", GetOmniboxText());
+
+ SendDownArrow();
+ EXPECT_EQ("result 1", GetOmniboxText());
+ SendDownArrow();
+ EXPECT_EQ("result 2", GetOmniboxText());
+ SendDownArrow();
+ EXPECT_EQ("http://www.google.com", GetOmniboxText());
+
+ EXPECT_TRUE(HasUserInputInProgress());
+
+ int submit_count = 0;
+ GetIntFromJS(instant()->instant_tab()->contents(), "submitCount",
+ &submit_count);
+ // Note the commit count is initially 1 due to the AcceptInput() call above.
+ EXPECT_EQ(1, submit_count);
+
+ // Commit the search by pressing Enter.
+ browser()->window()->GetLocationBar()->AcceptInput();
+
+ // Make sure a submit message got sent.
+ GetIntFromJS(instant()->instant_tab()->contents(), "submitCount",
+ &submit_count);
+ EXPECT_EQ(2, submit_count);
sreeram 2013/04/09 18:49:40 Nit: Check that searchbox.value hasn't changed (as
robertshield 2013/04/10 14:17:15 Done.
+}
+
+// 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) {
« no previous file with comments | « chrome/browser/ui/search/instant_controller.cc ('k') | chrome/renderer/searchbox/searchbox.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698