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

Side by Side Diff: chrome/browser/autocomplete/search_provider_unittest.cc

Issue 10381121: Add SearchProvider's most relevant NavigationResult to |matches_|. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Use max_element instead of sorting results. Created 8 years, 7 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/autocomplete/search_provider.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "chrome/browser/autocomplete/search_provider.h" 5 #include "chrome/browser/autocomplete/search_provider.h"
6 6
7 #include "base/string_util.h" 7 #include "base/string_util.h"
8 #include "base/time.h" 8 #include "base/time.h"
9 #include "base/utf_string_conversions.h" 9 #include "base/utf_string_conversions.h"
10 #include "build/build_config.h" 10 #include "build/build_config.h"
(...skipping 623 matching lines...) Expand 10 before | Expand all | Expand 10 after
634 634
635 EXPECT_FALSE(result.match_at(0).keyword.empty()); 635 EXPECT_FALSE(result.match_at(0).keyword.empty());
636 EXPECT_FALSE(result.match_at(1).keyword.empty()); 636 EXPECT_FALSE(result.match_at(1).keyword.empty());
637 EXPECT_NE(result.match_at(0).keyword, result.match_at(1).keyword); 637 EXPECT_NE(result.match_at(0).keyword, result.match_at(1).keyword);
638 638
639 EXPECT_FALSE(result.match_at(0).description.empty()); 639 EXPECT_FALSE(result.match_at(0).description.empty());
640 EXPECT_FALSE(result.match_at(1).description.empty()); 640 EXPECT_FALSE(result.match_at(1).description.empty());
641 EXPECT_NE(result.match_at(0).description, result.match_at(1).description); 641 EXPECT_NE(result.match_at(0).description, result.match_at(1).description);
642 } 642 }
643 643
644 // Verifies Navsuggest results don't set a TemplateURL (which instant relies 644 // Verifies Navsuggest results don't set a TemplateURL, which instant relies on.
645 // on). 645 // Also verifies that just the *first* navigational result is listed as a match.
646 TEST_F(SearchProviderTest, NoTemplateURLForNavsuggest) { 646 TEST_F(SearchProviderTest, Navsuggest) {
647 QueryForInput(ASCIIToUTF16("a.c"), false); 647 QueryForInput(ASCIIToUTF16("a.c"), false);
648 648
649 // Make sure the default providers suggest service was queried. 649 // Make sure the default providers suggest service was queried.
650 TestURLFetcher* fetcher = test_factory_.GetFetcherByID( 650 TestURLFetcher* fetcher = test_factory_.GetFetcherByID(
651 SearchProvider::kDefaultProviderURLFetcherID); 651 SearchProvider::kDefaultProviderURLFetcherID);
652 ASSERT_TRUE(fetcher); 652 ASSERT_TRUE(fetcher);
653 653
654 // Tell the SearchProvider the suggest query is done. 654 // Tell the SearchProvider the suggest query is done.
655 fetcher->set_response_code(200); 655 fetcher->set_response_code(200);
656 fetcher->SetResponseString( 656 fetcher->SetResponseString(
657 "[\"a.c\",[\"a.com\"],[\"\"],[]," 657 "[\"a.c\",[\"a.com\", \"a.com/b\"],[\"\"],[],"
658 "{\"google:suggesttype\":[\"NAVIGATION\"]}]"); 658 "{\"google:suggesttype\":[\"NAVIGATION\", \"NAVIGATION\"]}]");
659 fetcher->delegate()->OnURLFetchComplete(fetcher); 659 fetcher->delegate()->OnURLFetchComplete(fetcher);
660 fetcher = NULL; 660 fetcher = NULL;
661 661
662 // Run till the history results complete. 662 // Run till the history results complete.
663 RunTillProviderDone(); 663 RunTillProviderDone();
664 664
665 // Make sure there is a match for 'a.com' and it doesn't have a template_url. 665 // Make sure the only match is 'a.com' and it doesn't have a template_url.
666 AutocompleteMatch nav_match; 666 AutocompleteMatch nav_match;
667 EXPECT_TRUE(FindMatchWithDestination(GURL("http://a.com"), &nav_match)); 667 EXPECT_TRUE(FindMatchWithDestination(GURL("http://a.com"), &nav_match));
668 EXPECT_FALSE(FindMatchWithDestination(GURL("http://a.com/b"), &nav_match));
668 EXPECT_TRUE(nav_match.keyword.empty()); 669 EXPECT_TRUE(nav_match.keyword.empty());
669 } 670 }
OLDNEW
« no previous file with comments | « chrome/browser/autocomplete/search_provider.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698