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

Side by Side Diff: components/omnibox/autocomplete_result_unittest.cc

Issue 1154063003: removing ShouldHideTopMatch (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: changed deprecated var name Created 5 years, 6 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
« no previous file with comments | « components/omnibox/autocomplete_result.cc ('k') | components/search/search.h » ('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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "components/omnibox/autocomplete_result.h" 5 #include "components/omnibox/autocomplete_result.h"
6 6
7 #include <vector> 7 #include <vector>
8 8
9 #include "base/memory/scoped_ptr.h" 9 #include "base/memory/scoped_ptr.h"
10 #include "base/metrics/field_trial.h" 10 #include "base/metrics/field_trial.h"
(...skipping 629 matching lines...) Expand 10 before | Expand all | Expand 10 after
640 result.AppendMatches(input, matches); 640 result.AppendMatches(input, matches);
641 result.SortAndCull(input, template_url_service_.get()); 641 result.SortAndCull(input, template_url_service_.get());
642 ASSERT_EQ(4U, result.size()); 642 ASSERT_EQ(4U, result.size());
643 EXPECT_EQ("http://c/", result.match_at(0)->destination_url.spec()); 643 EXPECT_EQ("http://c/", result.match_at(0)->destination_url.spec());
644 EXPECT_EQ("http://a/", result.match_at(1)->destination_url.spec()); 644 EXPECT_EQ("http://a/", result.match_at(1)->destination_url.spec());
645 EXPECT_EQ("http://b/", result.match_at(2)->destination_url.spec()); 645 EXPECT_EQ("http://b/", result.match_at(2)->destination_url.spec());
646 EXPECT_EQ("http://d/", result.match_at(3)->destination_url.spec()); 646 EXPECT_EQ("http://d/", result.match_at(3)->destination_url.spec());
647 } 647 }
648 } 648 }
649 649
650 TEST_F(AutocompleteResultTest, ShouldHideTopMatch) {
651 base::FieldTrialList::CreateFieldTrial("InstantExtended",
652 "Group1 hide_verbatim:1");
653 ACMatches matches;
654
655 // Case 1: Top match is a verbatim match.
656 PopulateAutocompleteMatchesFromTestData(kVerbatimMatches, 1, &matches);
657 AutocompleteResult result;
658 result.AppendMatches(AutocompleteInput(), matches);
659 EXPECT_TRUE(result.ShouldHideTopMatch());
660 matches.clear();
661 result.Reset();
662
663 // Case 2: If the verbatim first match is followed by another verbatim match,
664 // don't hide the top verbatim match.
665 PopulateAutocompleteMatchesFromTestData(kVerbatimMatches,
666 arraysize(kVerbatimMatches),
667 &matches);
668 result.AppendMatches(AutocompleteInput(), matches);
669 EXPECT_FALSE(result.ShouldHideTopMatch());
670 matches.clear();
671 result.Reset();
672
673 // Case 3: Top match is not a verbatim match. Do not hide the top match.
674 PopulateAutocompleteMatchesFromTestData(kNonVerbatimMatches, 1, &matches);
675 PopulateAutocompleteMatchesFromTestData(kVerbatimMatches,
676 arraysize(kVerbatimMatches),
677 &matches);
678 result.AppendMatches(AutocompleteInput(), matches);
679 EXPECT_FALSE(result.ShouldHideTopMatch());
680 }
681
682 TEST_F(AutocompleteResultTest, ShouldHideTopMatchAfterCopy) {
683 base::FieldTrialList::CreateFieldTrial("InstantExtended",
684 "Group1 hide_verbatim:1");
685 ACMatches matches;
686
687 // Case 1: Top match is a verbatim match followed by only copied matches.
688 PopulateAutocompleteMatchesFromTestData(kVerbatimMatches,
689 arraysize(kVerbatimMatches),
690 &matches);
691 for (size_t i = 1; i < arraysize(kVerbatimMatches); ++i)
692 matches[i].from_previous = true;
693 AutocompleteResult result;
694 result.AppendMatches(AutocompleteInput(), matches);
695 EXPECT_TRUE(result.ShouldHideTopMatch());
696 result.Reset();
697
698 // Case 2: The copied matches are then followed by a non-verbatim match.
699 PopulateAutocompleteMatchesFromTestData(kNonVerbatimMatches, 1, &matches);
700 result.AppendMatches(AutocompleteInput(), matches);
701 EXPECT_TRUE(result.ShouldHideTopMatch());
702 result.Reset();
703
704 // Case 3: The copied matches are instead followed by a verbatim match.
705 matches.back().from_previous = true;
706 PopulateAutocompleteMatchesFromTestData(kVerbatimMatches, 1, &matches);
707 result.AppendMatches(AutocompleteInput(), matches);
708 EXPECT_FALSE(result.ShouldHideTopMatch());
709 }
710
711 TEST_F(AutocompleteResultTest, DoNotHideTopMatch_FieldTrialFlagDisabled) {
712 // This test config is identical to ShouldHideTopMatch test ("Case 1") except
713 // that the "hide_verbatim" flag is disabled in the field trials.
714 base::FieldTrialList::CreateFieldTrial("InstantExtended",
715 "Group1 hide_verbatim:0");
716 ACMatches matches;
717 PopulateAutocompleteMatchesFromTestData(kVerbatimMatches, 1, &matches);
718 AutocompleteResult result;
719 result.AppendMatches(AutocompleteInput(), matches);
720 // Field trial flag "hide_verbatim" is disabled. Do not hide top match.
721 EXPECT_FALSE(result.ShouldHideTopMatch());
722 }
723
724 TEST_F(AutocompleteResultTest, TopMatchIsStandaloneVerbatimMatch) { 650 TEST_F(AutocompleteResultTest, TopMatchIsStandaloneVerbatimMatch) {
725 ACMatches matches; 651 ACMatches matches;
726 AutocompleteResult result; 652 AutocompleteResult result;
727 result.AppendMatches(AutocompleteInput(), matches); 653 result.AppendMatches(AutocompleteInput(), matches);
728 654
729 // Case 1: Result set is empty. 655 // Case 1: Result set is empty.
730 EXPECT_FALSE(result.TopMatchIsStandaloneVerbatimMatch()); 656 EXPECT_FALSE(result.TopMatchIsStandaloneVerbatimMatch());
731 657
732 // Case 2: Top match is not a verbatim match. 658 // Case 2: Top match is not a verbatim match.
733 PopulateAutocompleteMatchesFromTestData(kNonVerbatimMatches, 1, &matches); 659 PopulateAutocompleteMatchesFromTestData(kNonVerbatimMatches, 1, &matches);
734 result.AppendMatches(AutocompleteInput(), matches); 660 result.AppendMatches(AutocompleteInput(), matches);
735 EXPECT_FALSE(result.TopMatchIsStandaloneVerbatimMatch()); 661 EXPECT_FALSE(result.TopMatchIsStandaloneVerbatimMatch());
736 result.Reset(); 662 result.Reset();
737 matches.clear(); 663 matches.clear();
738 664
739 // Case 3: Top match is a verbatim match. 665 // Case 3: Top match is a verbatim match.
740 PopulateAutocompleteMatchesFromTestData(kVerbatimMatches, 1, &matches); 666 PopulateAutocompleteMatchesFromTestData(kVerbatimMatches, 1, &matches);
741 result.AppendMatches(AutocompleteInput(), matches); 667 result.AppendMatches(AutocompleteInput(), matches);
742 EXPECT_TRUE(result.TopMatchIsStandaloneVerbatimMatch()); 668 EXPECT_TRUE(result.TopMatchIsStandaloneVerbatimMatch());
743 result.Reset(); 669 result.Reset();
744 matches.clear(); 670 matches.clear();
745 671
746 // Case 4: Standalone verbatim match found in AutocompleteResult. 672 // Case 4: Standalone verbatim match found in AutocompleteResult.
747 PopulateAutocompleteMatchesFromTestData(kVerbatimMatches, 1, &matches); 673 PopulateAutocompleteMatchesFromTestData(kVerbatimMatches, 1, &matches);
748 PopulateAutocompleteMatchesFromTestData(kNonVerbatimMatches, 1, &matches); 674 PopulateAutocompleteMatchesFromTestData(kNonVerbatimMatches, 1, &matches);
749 result.AppendMatches(AutocompleteInput(), matches); 675 result.AppendMatches(AutocompleteInput(), matches);
750 EXPECT_TRUE(result.TopMatchIsStandaloneVerbatimMatch()); 676 EXPECT_TRUE(result.TopMatchIsStandaloneVerbatimMatch());
751 result.Reset(); 677 result.Reset();
752 matches.clear(); 678 matches.clear();
753
754 // Case 5: Multiple verbatim matches found in AutocompleteResult.
755 PopulateAutocompleteMatchesFromTestData(kVerbatimMatches,
756 arraysize(kVerbatimMatches),
757 &matches);
758 result.AppendMatches(AutocompleteInput(), matches);
759 EXPECT_FALSE(result.ShouldHideTopMatch());
760 } 679 }
OLDNEW
« no previous file with comments | « components/omnibox/autocomplete_result.cc ('k') | components/search/search.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698