| 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 1513 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1524 bool found_bookmark_match = false; | 1524 bool found_bookmark_match = false; |
| 1525 | 1525 |
| 1526 const AutocompleteResult& result = omnibox()->model()->result(); | 1526 const AutocompleteResult& result = omnibox()->model()->result(); |
| 1527 for (AutocompleteResult::const_iterator iter = result.begin(); | 1527 for (AutocompleteResult::const_iterator iter = result.begin(); |
| 1528 !found_bookmark_match && iter != result.end(); ++iter) { | 1528 !found_bookmark_match && iter != result.end(); ++iter) { |
| 1529 found_bookmark_match = iter->type == AutocompleteMatch::BOOKMARK_TITLE; | 1529 found_bookmark_match = iter->type == AutocompleteMatch::BOOKMARK_TITLE; |
| 1530 } | 1530 } |
| 1531 | 1531 |
| 1532 EXPECT_TRUE(found_bookmark_match); | 1532 EXPECT_TRUE(found_bookmark_match); |
| 1533 } | 1533 } |
| 1534 |
| 1535 // Test that if Instant alters the input from URL to search, it's respected. |
| 1536 IN_PROC_BROWSER_TEST_F(InstantExtendedTest, InputChangedFromURLToSearch) { |
| 1537 ASSERT_NO_FATAL_FAILURE(SetupInstant(browser())); |
| 1538 FocusOmniboxAndWaitForInstantExtendedSupport(); |
| 1539 |
| 1540 content::WebContents* overlay = instant()->GetOverlayContents(); |
| 1541 EXPECT_TRUE(ExecuteScript("suggestions = ['mcqueen.com'];")); |
| 1542 |
| 1543 SetOmniboxTextAndWaitForOverlayToShow("lightning"); |
| 1544 EXPECT_EQ("lightning", GetOmniboxText()); |
| 1545 |
| 1546 SendDownArrow(); |
| 1547 EXPECT_EQ("mcqueen.com", GetOmniboxText()); |
| 1548 |
| 1549 // Press Enter. |
| 1550 browser()->window()->GetLocationBar()->AcceptInput(); |
| 1551 |
| 1552 // Confirm that the Instant overlay was committed. |
| 1553 EXPECT_EQ(overlay, browser()->tab_strip_model()->GetActiveWebContents()); |
| 1554 } |
| 1555 |
| 1556 // Test that if Instant alters the input from search to URL, it's respected. |
| 1557 IN_PROC_BROWSER_TEST_F(InstantExtendedTest, InputChangedFromSearchToURL) { |
| 1558 ASSERT_NO_FATAL_FAILURE(SetupInstant(browser())); |
| 1559 FocusOmniboxAndWaitForInstantExtendedSupport(); |
| 1560 |
| 1561 content::WebContents* overlay = instant()->GetOverlayContents(); |
| 1562 EXPECT_TRUE(ExecuteScript("suggestionType = 1;")); // INSTANT_SUGGESTION_URL |
| 1563 |
| 1564 SetOmniboxTextAndWaitForOverlayToShow("mack.com"); |
| 1565 EXPECT_EQ("mack.com", GetOmniboxText()); |
| 1566 |
| 1567 SendDownArrow(); |
| 1568 EXPECT_EQ("result 1", GetOmniboxText()); |
| 1569 |
| 1570 // Press Enter. |
| 1571 browser()->window()->GetLocationBar()->AcceptInput(); |
| 1572 |
| 1573 // Confirm that the Instant overlay was NOT committed. |
| 1574 EXPECT_NE(overlay, browser()->tab_strip_model()->GetActiveWebContents()); |
| 1575 } |
| OLD | NEW |