OLD | NEW |
---|---|
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 Loading... | |
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 |
456 | |
457 // This test simulates a search provider using the InstantExtended API to | |
458 // navigate through the suggested results and back to the original user query. | |
459 IN_PROC_BROWSER_TEST_F(InstantExtendedTest, | |
460 NavigateToURLSuggestionHitEnterAndLookForSubmit) { | |
461 ASSERT_NO_FATAL_FAILURE(SetupInstant(browser())); | |
462 FocusOmniboxAndWaitForInstantExtendedSupport(); | |
463 | |
464 // Create an observer to wait for the instant tab to support Instant. | |
465 content::WindowedNotificationObserver observer( | |
466 chrome::NOTIFICATION_INSTANT_TAB_SUPPORT_DETERMINED, | |
467 content::NotificationService::AllSources()); | |
468 | |
469 // Do a search and commit it. | |
470 SetOmniboxTextAndWaitForOverlayToShow("hello k"); | |
471 EXPECT_EQ(ASCIIToUTF16("hello k"), omnibox()->GetText()); | |
472 browser()->window()->GetLocationBar()->AcceptInput(); | |
473 observer.Wait(); | |
474 | |
475 SetOmniboxText("http"); | |
476 EXPECT_EQ("http", GetOmniboxText()); | |
477 | |
478 SendDownArrow(); | |
479 EXPECT_EQ("result 1", GetOmniboxText()); | |
480 SendDownArrow(); | |
481 EXPECT_EQ("result 2", GetOmniboxText()); | |
482 SendDownArrow(); | |
483 EXPECT_EQ("http://www.google.com", GetOmniboxText()); | |
484 | |
485 EXPECT_TRUE(HasUserInputInProgress()); | |
486 | |
487 int submit_count = 0; | |
488 GetIntFromJS(instant()->instant_tab()->contents(), "submitCount", | |
489 &submit_count); | |
490 // Note the commit count is initially 1 due to the AcceptInput() call above. | |
491 EXPECT_EQ(1, submit_count); | |
492 | |
493 // Commit the search by pressing Enter. | |
494 browser()->window()->GetLocationBar()->AcceptInput(); | |
495 | |
496 // Make sure a submit message got sent. | |
497 GetIntFromJS(instant()->instant_tab()->contents(), "submitCount", | |
sreeram
2013/04/08 16:20:38
I'm mildly worried that this is brittle. If in the
robertshield
2013/04/09 14:49:29
Maybe. I could examine the IPCs being sent, by sti
sreeram
2013/04/09 16:39:41
Here are some alternatives:
1. Get a handle to th
| |
498 &submit_count); | |
sreeram
2013/04/08 16:20:38
Use UpdateSearchState() and verify both the submit
| |
499 EXPECT_EQ(2, submit_count); | |
500 } | |
501 | |
457 // This test simulates a search provider using the InstantExtended API to | 502 // 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 | 503 // navigate through the suggested results and hitting escape to get back to the |
459 // original user query. | 504 // original user query. |
460 IN_PROC_BROWSER_TEST_F(InstantExtendedTest, NavigateSuggestionsAndHitEscape) { | 505 IN_PROC_BROWSER_TEST_F(InstantExtendedTest, NavigateSuggestionsAndHitEscape) { |
461 ASSERT_NO_FATAL_FAILURE(SetupInstant(browser())); | 506 ASSERT_NO_FATAL_FAILURE(SetupInstant(browser())); |
462 FocusOmniboxAndWaitForInstantExtendedSupport(); | 507 FocusOmniboxAndWaitForInstantExtendedSupport(); |
463 | 508 |
464 SetOmniboxTextAndWaitForOverlayToShow("hello"); | 509 SetOmniboxTextAndWaitForOverlayToShow("hello"); |
465 EXPECT_EQ("hello", GetOmniboxText()); | 510 EXPECT_EQ("hello", GetOmniboxText()); |
466 | 511 |
(...skipping 962 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1429 ASSERT_NO_FATAL_FAILURE(SetupInstant(browser())); | 1474 ASSERT_NO_FATAL_FAILURE(SetupInstant(browser())); |
1430 | 1475 |
1431 EXPECT_EQ(instant_url(), instant()->ntp_->contents()->GetURL()); | 1476 EXPECT_EQ(instant_url(), instant()->ntp_->contents()->GetURL()); |
1432 | 1477 |
1433 // The second argument says to use only the local overlay. | 1478 // The second argument says to use only the local overlay. |
1434 instant()->SetInstantEnabled(false, true); | 1479 instant()->SetInstantEnabled(false, true); |
1435 | 1480 |
1436 EXPECT_EQ(GURL(chrome::kChromeSearchLocalNtpUrl), | 1481 EXPECT_EQ(GURL(chrome::kChromeSearchLocalNtpUrl), |
1437 instant()->ntp_->contents()->GetURL()); | 1482 instant()->ntp_->contents()->GetURL()); |
1438 } | 1483 } |
OLD | NEW |