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

Side by Side 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « chrome/browser/ui/search/instant_controller.cc ('k') | chrome/renderer/searchbox/searchbox.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 <sstream> 5 #include <sstream>
6 6
7 #include "base/prefs/pref_service.h" 7 #include "base/prefs/pref_service.h"
8 #include "base/string_util.h" 8 #include "base/string_util.h"
9 #include "base/stringprintf.h" 9 #include "base/stringprintf.h"
10 #include "base/utf_string_conversions.h" 10 #include "base/utf_string_conversions.h"
(...skipping 430 matching lines...) Expand 10 before | Expand all | Expand 10 after
441 std::string result; 441 std::string result;
442 EXPECT_TRUE(GetStringFromJS(instant()->GetOverlayContents(), 442 EXPECT_TRUE(GetStringFromJS(instant()->GetOverlayContents(),
443 "window.chrome.searchBox.value", 443 "window.chrome.searchBox.value",
444 &result)); 444 &result));
445 EXPECT_EQ("hello", result); 445 EXPECT_EQ("hello", result);
446 446
447 EXPECT_TRUE(HasUserInputInProgress()); 447 EXPECT_TRUE(HasUserInputInProgress());
448 // TODO(beaudoin): Figure out why this fails. 448 // TODO(beaudoin): Figure out why this fails.
449 // EXPECT_FALSE(HasTemporaryText()); 449 // EXPECT_FALSE(HasTemporaryText());
450 450
451
452 // Commit the search by pressing Enter. 451 // Commit the search by pressing Enter.
453 browser()->window()->GetLocationBar()->AcceptInput(); 452 browser()->window()->GetLocationBar()->AcceptInput();
454 EXPECT_EQ("hello", GetOmniboxText()); 453 EXPECT_EQ("hello", GetOmniboxText());
455 } 454 }
456 455
457 // This test simulates a search provider using the InstantExtended API to 456 // This test simulates a search provider using the InstantExtended API to
457 // navigate through the suggested results and back to the original user query.
458 // If this test starts to flake, it may be that the second call to AcceptInput
459 // below causes instant()->instant_tab() to no longer be valid due to e.g. a
460 // navigation. In that case, see https://codereview.chromium.org/12895007/#msg28
461 // and onwards for possible alternatives.
462 IN_PROC_BROWSER_TEST_F(InstantExtendedTest,
463 NavigateToURLSuggestionHitEnterAndLookForSubmit) {
464 ASSERT_NO_FATAL_FAILURE(SetupInstant(browser()));
465 FocusOmniboxAndWaitForInstantExtendedSupport();
466
467 // Create an observer to wait for the instant tab to support Instant.
468 content::WindowedNotificationObserver observer(
469 chrome::NOTIFICATION_INSTANT_TAB_SUPPORT_DETERMINED,
470 content::NotificationService::AllSources());
471
472 // Do a search and commit it.
473 SetOmniboxTextAndWaitForOverlayToShow("hello k");
474 EXPECT_EQ(ASCIIToUTF16("hello k"), omnibox()->GetText());
475 browser()->window()->GetLocationBar()->AcceptInput();
476 observer.Wait();
477
478 SetOmniboxText("http");
479 EXPECT_EQ("http", GetOmniboxText());
480
481 SendDownArrow();
482 EXPECT_EQ("result 1", GetOmniboxText());
483 SendDownArrow();
484 EXPECT_EQ("result 2", GetOmniboxText());
485 SendDownArrow();
486 EXPECT_EQ("http://www.google.com", GetOmniboxText());
487
488 EXPECT_TRUE(HasUserInputInProgress());
489
490 int submit_count = 0;
491 GetIntFromJS(instant()->instant_tab()->contents(), "submitCount",
492 &submit_count);
493 // Note the commit count is initially 1 due to the AcceptInput() call above.
494 EXPECT_EQ(1, submit_count);
495
496 // Commit the search by pressing Enter.
497 browser()->window()->GetLocationBar()->AcceptInput();
498
499 // Make sure a submit message got sent.
500 GetIntFromJS(instant()->instant_tab()->contents(), "submitCount",
501 &submit_count);
502 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.
503 }
504
505 // This test simulates a search provider using the InstantExtended API to
458 // navigate through the suggested results and hitting escape to get back to the 506 // navigate through the suggested results and hitting escape to get back to the
459 // original user query. 507 // original user query.
460 IN_PROC_BROWSER_TEST_F(InstantExtendedTest, NavigateSuggestionsAndHitEscape) { 508 IN_PROC_BROWSER_TEST_F(InstantExtendedTest, NavigateSuggestionsAndHitEscape) {
461 ASSERT_NO_FATAL_FAILURE(SetupInstant(browser())); 509 ASSERT_NO_FATAL_FAILURE(SetupInstant(browser()));
462 FocusOmniboxAndWaitForInstantExtendedSupport(); 510 FocusOmniboxAndWaitForInstantExtendedSupport();
463 511
464 SetOmniboxTextAndWaitForOverlayToShow("hello"); 512 SetOmniboxTextAndWaitForOverlayToShow("hello");
465 EXPECT_EQ("hello", GetOmniboxText()); 513 EXPECT_EQ("hello", GetOmniboxText());
466 514
467 SendDownArrow(); 515 SendDownArrow();
(...skipping 961 matching lines...) Expand 10 before | Expand all | Expand 10 after
1429 ASSERT_NO_FATAL_FAILURE(SetupInstant(browser())); 1477 ASSERT_NO_FATAL_FAILURE(SetupInstant(browser()));
1430 1478
1431 EXPECT_EQ(instant_url(), instant()->ntp_->contents()->GetURL()); 1479 EXPECT_EQ(instant_url(), instant()->ntp_->contents()->GetURL());
1432 1480
1433 // The second argument says to use only the local overlay. 1481 // The second argument says to use only the local overlay.
1434 instant()->SetInstantEnabled(false, true); 1482 instant()->SetInstantEnabled(false, true);
1435 1483
1436 EXPECT_EQ(GURL(chrome::kChromeSearchLocalNtpUrl), 1484 EXPECT_EQ(GURL(chrome::kChromeSearchLocalNtpUrl),
1437 instant()->ntp_->contents()->GetURL()); 1485 instant()->ntp_->contents()->GetURL());
1438 } 1486 }
OLDNEW
« 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