Chromium Code Reviews| 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) { |