| OLD | NEW |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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 "base/command_line.h" | 5 #include "base/command_line.h" |
| 6 #include "base/metrics/field_trial.h" | 6 #include "base/metrics/field_trial.h" |
| 7 #include "base/metrics/histogram_base.h" | 7 #include "base/metrics/histogram_base.h" |
| 8 #include "base/metrics/histogram_samples.h" | 8 #include "base/metrics/histogram_samples.h" |
| 9 #include "base/metrics/statistics_recorder.h" | 9 #include "base/metrics/statistics_recorder.h" |
| 10 #include "base/prefs/pref_service.h" | 10 #include "base/prefs/pref_service.h" |
| (...skipping 653 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 664 // query portion of the instant URL. | 664 // query portion of the instant URL. |
| 665 CommandLine::ForCurrentProcess()->AppendSwitchASCII( | 665 CommandLine::ForCurrentProcess()->AppendSwitchASCII( |
| 666 switches::kExtraSearchQueryParams, "a=b"); | 666 switches::kExtraSearchQueryParams, "a=b"); |
| 667 instant_url = GetInstantURL(profile(), kDisableStartMargin, false); | 667 instant_url = GetInstantURL(profile(), kDisableStartMargin, false); |
| 668 ASSERT_TRUE(instant_url.is_valid()); | 668 ASSERT_TRUE(instant_url.is_valid()); |
| 669 EXPECT_EQ("http://www.bar.com/webhp?a=b&strk", instant_url.spec()); | 669 EXPECT_EQ("http://www.bar.com/webhp?a=b&strk", instant_url.spec()); |
| 670 } | 670 } |
| 671 | 671 |
| 672 TEST_F(SearchTest, ShouldPrefetchSearchResults_InstantExtendedAPIEnabled) { | 672 TEST_F(SearchTest, ShouldPrefetchSearchResults_InstantExtendedAPIEnabled) { |
| 673 ASSERT_TRUE(base::FieldTrialList::CreateFieldTrial( | 673 ASSERT_TRUE(base::FieldTrialList::CreateFieldTrial( |
| 674 "EmbeddedSearch", | 674 "EmbeddedSearch", "Group1 espv:2")); |
| 675 "Group1 espv:2 prefetch_results:1")); | 675 #if defined(OS_IOS) |
| 676 EXPECT_EQ(1ul, EmbeddedSearchPageVersion()); |
| 676 EXPECT_TRUE(ShouldPrefetchSearchResults()); | 677 EXPECT_TRUE(ShouldPrefetchSearchResults()); |
| 677 #if defined(OS_IOS) || defined(OS_ANDROID) | |
| 678 EXPECT_EQ(1ul, EmbeddedSearchPageVersion()); | |
| 679 #else | 678 #else |
| 680 EXPECT_EQ(2ul, EmbeddedSearchPageVersion()); | 679 EXPECT_EQ(2ul, EmbeddedSearchPageVersion()); |
| 680 EXPECT_TRUE(ShouldPrefetchSearchResults()); |
| 681 #endif | 681 #endif |
| 682 } | 682 } |
| 683 | 683 |
| 684 TEST_F(SearchTest, ShouldPrefetchSearchResults_DisabledViaFieldTrial) { | 684 TEST_F(SearchTest, ShouldPrefetchSearchResults_Default) { |
| 685 ASSERT_TRUE(base::FieldTrialList::CreateFieldTrial( | 685 #if defined(OS_IOS) |
| 686 "EmbeddedSearch", | |
| 687 "Group1 espv:89 prefetch_results:0")); | |
| 688 EXPECT_FALSE(ShouldPrefetchSearchResults()); | 686 EXPECT_FALSE(ShouldPrefetchSearchResults()); |
| 689 EXPECT_EQ(89ul, EmbeddedSearchPageVersion()); | 687 #else |
| 688 EXPECT_TRUE(ShouldPrefetchSearchResults()); |
| 689 #endif |
| 690 } | 690 } |
| 691 | 691 |
| 692 TEST_F(SearchTest, ShouldPrefetchSearchResults_EnabledViaFieldTrial) { | 692 TEST_F(SearchTest, ShouldReuseInstantSearchBasePage_Default) { |
| 693 ASSERT_TRUE(base::FieldTrialList::CreateFieldTrial( | 693 #if defined(OS_IOS) |
| 694 "EmbeddedSearch", | 694 EXPECT_FALSE(ShouldReuseInstantSearchBasePage()); |
| 695 "Group1 espv:80 prefetch_results:1")); | 695 #else |
| 696 EXPECT_TRUE(ShouldPrefetchSearchResults()); | 696 EXPECT_TRUE(ShouldReuseInstantSearchBasePage()); |
| 697 EXPECT_EQ(80ul, EmbeddedSearchPageVersion()); | 697 #endif |
| 698 } | |
| 699 | |
| 700 TEST_F(SearchTest, ShouldPrefetchSearchResults_EnabledViaCommandLine) { | |
| 701 CommandLine::ForCurrentProcess()->AppendSwitch( | |
| 702 switches::kPrefetchSearchResults); | |
| 703 // Command-line enable should override Finch. | |
| 704 ASSERT_TRUE(base::FieldTrialList::CreateFieldTrial( | |
| 705 "EmbeddedSearch", "Group1 espv:80 prefetch_results:0")); | |
| 706 EXPECT_TRUE(ShouldPrefetchSearchResults()); | |
| 707 EXPECT_EQ(80ul, EmbeddedSearchPageVersion()); | |
| 708 } | |
| 709 | |
| 710 TEST_F(SearchTest, | |
| 711 ShouldAllowPrefetchNonDefaultMatch_PrefetchResultsFlagDisabled) { | |
| 712 ASSERT_TRUE(base::FieldTrialList::CreateFieldTrial( | |
| 713 "EmbeddedSearch", | |
| 714 "Group1 espv:80 prefetch_results:0 allow_prefetch_non_default_match:1")); | |
| 715 EXPECT_FALSE(ShouldAllowPrefetchNonDefaultMatch()); | |
| 716 EXPECT_EQ(80ul, EmbeddedSearchPageVersion()); | |
| 717 } | 698 } |
| 718 | 699 |
| 719 TEST_F(SearchTest, ShouldAllowPrefetchNonDefaultMatch_DisabledViaFieldTrial) { | 700 TEST_F(SearchTest, ShouldAllowPrefetchNonDefaultMatch_DisabledViaFieldTrial) { |
| 720 ASSERT_TRUE(base::FieldTrialList::CreateFieldTrial( | 701 ASSERT_TRUE(base::FieldTrialList::CreateFieldTrial( |
| 721 "EmbeddedSearch", | 702 "EmbeddedSearch", "Group1 espv:89 allow_prefetch_non_default_match:0")); |
| 722 "Group1 espv:89 prefetch_results:1 allow_prefetch_non_default_match:0")); | |
| 723 EXPECT_FALSE(ShouldAllowPrefetchNonDefaultMatch()); | 703 EXPECT_FALSE(ShouldAllowPrefetchNonDefaultMatch()); |
| 724 EXPECT_EQ(89ul, EmbeddedSearchPageVersion()); | 704 EXPECT_EQ(89ul, EmbeddedSearchPageVersion()); |
| 725 } | 705 } |
| 726 | 706 |
| 727 TEST_F(SearchTest, ShouldAllowPrefetchNonDefaultMatch_EnabledViaFieldTrial) { | 707 TEST_F(SearchTest, ShouldAllowPrefetchNonDefaultMatch_EnabledViaFieldTrial) { |
| 728 ASSERT_TRUE(base::FieldTrialList::CreateFieldTrial( | 708 ASSERT_TRUE(base::FieldTrialList::CreateFieldTrial( |
| 729 "EmbeddedSearch", | 709 "EmbeddedSearch", "Group1 espv:80 allow_prefetch_non_default_match:1")); |
| 730 "Group1 espv:80 prefetch_results:1 allow_prefetch_non_default_match:1")); | |
| 731 EXPECT_TRUE(ShouldAllowPrefetchNonDefaultMatch()); | 710 EXPECT_TRUE(ShouldAllowPrefetchNonDefaultMatch()); |
| 732 EXPECT_EQ(80ul, EmbeddedSearchPageVersion()); | 711 EXPECT_EQ(80ul, EmbeddedSearchPageVersion()); |
| 733 } | 712 } |
| 734 | 713 |
| 735 TEST_F(SearchTest, ShouldUseAltInstantURL_DisabledViaFieldTrial) { | 714 TEST_F(SearchTest, ShouldUseAltInstantURL_DisabledViaFieldTrial) { |
| 736 ASSERT_TRUE(base::FieldTrialList::CreateFieldTrial( | 715 ASSERT_TRUE(base::FieldTrialList::CreateFieldTrial( |
| 737 "EmbeddedSearch", "Group1 espv:8 use_alternate_instant_url:0")); | 716 "EmbeddedSearch", "Group1 espv:8 use_alternate_instant_url:0")); |
| 738 EXPECT_FALSE(ShouldUseAltInstantURL()); | 717 EXPECT_FALSE(ShouldUseAltInstantURL()); |
| 739 } | 718 } |
| 740 | 719 |
| 741 TEST_F(SearchTest, ShouldUseAltInstantURL_EnabledViaFieldTrial) { | 720 TEST_F(SearchTest, ShouldUseAltInstantURL_EnabledViaFieldTrial) { |
| 742 ASSERT_TRUE(base::FieldTrialList::CreateFieldTrial( | 721 ASSERT_TRUE(base::FieldTrialList::CreateFieldTrial( |
| 743 "EmbeddedSearch", "Group1 espv:8 use_alternate_instant_url:1")); | 722 "EmbeddedSearch", "Group1 espv:8 use_alternate_instant_url:1")); |
| 744 EXPECT_TRUE(ShouldUseAltInstantURL()); | 723 EXPECT_TRUE(ShouldUseAltInstantURL()); |
| 745 } | 724 } |
| 746 | 725 |
| 747 TEST_F(SearchTest, | 726 TEST_F(SearchTest, |
| 748 ShouldPrerenderInstantUrlOnOmniboxFocus_PrefetchResultsFlagDisabled) { | |
| 749 ASSERT_TRUE(base::FieldTrialList::CreateFieldTrial( | |
| 750 "EmbeddedSearch", | |
| 751 "Group1 espv:80 prefetch_results:0 " | |
| 752 "prerender_instant_url_on_omnibox_focus:1")); | |
| 753 EXPECT_FALSE(ShouldPrerenderInstantUrlOnOmniboxFocus()); | |
| 754 EXPECT_EQ(80ul, EmbeddedSearchPageVersion()); | |
| 755 } | |
| 756 | |
| 757 TEST_F(SearchTest, | |
| 758 ShouldPrerenderInstantUrlOnOmniboxFocus_DisabledViaFieldTrial) { | 727 ShouldPrerenderInstantUrlOnOmniboxFocus_DisabledViaFieldTrial) { |
| 759 ASSERT_TRUE(base::FieldTrialList::CreateFieldTrial( | 728 ASSERT_TRUE(base::FieldTrialList::CreateFieldTrial( |
| 760 "EmbeddedSearch", | 729 "EmbeddedSearch", |
| 761 "Group1 espv:89 prefetch_results:1 " | 730 "Group1 espv:89 prerender_instant_url_on_omnibox_focus:0")); |
| 762 "prerender_instant_url_on_omnibox_focus:0")); | |
| 763 EXPECT_FALSE(ShouldPrerenderInstantUrlOnOmniboxFocus()); | 731 EXPECT_FALSE(ShouldPrerenderInstantUrlOnOmniboxFocus()); |
| 764 EXPECT_EQ(89ul, EmbeddedSearchPageVersion()); | 732 EXPECT_EQ(89ul, EmbeddedSearchPageVersion()); |
| 765 } | 733 } |
| 766 | 734 |
| 767 TEST_F(SearchTest, | 735 TEST_F(SearchTest, |
| 768 ShouldPrerenderInstantUrlOnOmniboxFocus_EnabledViaFieldTrial) { | 736 ShouldPrerenderInstantUrlOnOmniboxFocus_EnabledViaFieldTrial) { |
| 769 ASSERT_TRUE(base::FieldTrialList::CreateFieldTrial( | 737 ASSERT_TRUE(base::FieldTrialList::CreateFieldTrial( |
| 770 "EmbeddedSearch", | 738 "EmbeddedSearch", |
| 771 "Group1 espv:80 prefetch_results:1 " | 739 "Group1 espv:80 prerender_instant_url_on_omnibox_focus:1")); |
| 772 "prerender_instant_url_on_omnibox_focus:1")); | |
| 773 EXPECT_TRUE(ShouldPrerenderInstantUrlOnOmniboxFocus()); | 740 EXPECT_TRUE(ShouldPrerenderInstantUrlOnOmniboxFocus()); |
| 774 EXPECT_EQ(80ul, EmbeddedSearchPageVersion()); | 741 EXPECT_EQ(80ul, EmbeddedSearchPageVersion()); |
| 775 } | 742 } |
| 776 | 743 |
| 777 TEST_F(SearchTest, | |
| 778 ShouldReuseInstantSearchBasePage_PrefetchResultsFlagDisabled) { | |
| 779 ASSERT_TRUE(base::FieldTrialList::CreateFieldTrial( | |
| 780 "EmbeddedSearch", | |
| 781 "Group1 espv:89 prefetch_results:0 reuse_instant_search_base_page:1")); | |
| 782 EXPECT_FALSE(ShouldPrefetchSearchResults()); | |
| 783 EXPECT_FALSE(ShouldReuseInstantSearchBasePage()); | |
| 784 EXPECT_EQ(89ul, EmbeddedSearchPageVersion()); | |
| 785 } | |
| 786 | 744 |
| 787 TEST_F(SearchTest, ShouldReuseInstantSearchBasePage_EnabledViaFieldTrial) { | |
| 788 ASSERT_TRUE(base::FieldTrialList::CreateFieldTrial( | |
| 789 "EmbeddedSearch", | |
| 790 "Group1 espv:89 prefetch_results:1 reuse_instant_search_base_page:1")); | |
| 791 EXPECT_TRUE(ShouldReuseInstantSearchBasePage()); | |
| 792 EXPECT_EQ(89ul, EmbeddedSearchPageVersion()); | |
| 793 } | |
| 794 | |
| 795 TEST_F(SearchTest, ShouldReuseInstantSearchBasePage_DisabledViaFieldTrial) { | |
| 796 ASSERT_TRUE(base::FieldTrialList::CreateFieldTrial( | |
| 797 "EmbeddedSearch", | |
| 798 "Group1 espv:89 prefetch_results:1 reuse_instant_search_base_page:0")); | |
| 799 EXPECT_FALSE(ShouldReuseInstantSearchBasePage()); | |
| 800 EXPECT_EQ(89ul, EmbeddedSearchPageVersion()); | |
| 801 } | |
| 802 | 745 |
| 803 TEST_F(SearchTest, ShouldShowGoogleLocalNTP_Default) { | 746 TEST_F(SearchTest, ShouldShowGoogleLocalNTP_Default) { |
| 804 EXPECT_TRUE(ShouldShowGoogleLocalNTP()); | 747 EXPECT_TRUE(ShouldShowGoogleLocalNTP()); |
| 805 } | 748 } |
| 806 | 749 |
| 807 TEST_F(SearchTest, ShouldShowGoogleLocalNTP_EnabledViaFinch) { | 750 TEST_F(SearchTest, ShouldShowGoogleLocalNTP_EnabledViaFinch) { |
| 808 ASSERT_TRUE(base::FieldTrialList::CreateFieldTrial( | 751 ASSERT_TRUE(base::FieldTrialList::CreateFieldTrial( |
| 809 "EmbeddedSearch", "Group1 espv:2 google_local_ntp:1")); | 752 "EmbeddedSearch", "Group1 espv:2 google_local_ntp:1")); |
| 810 EXPECT_TRUE(ShouldShowGoogleLocalNTP()); | 753 EXPECT_TRUE(ShouldShowGoogleLocalNTP()); |
| 811 } | 754 } |
| 812 | 755 |
| 813 TEST_F(SearchTest, ShouldShowGoogleLocalNTP_DisabledViaFinch) { | 756 TEST_F(SearchTest, ShouldShowGoogleLocalNTP_DisabledViaFinch) { |
| 814 ASSERT_TRUE(base::FieldTrialList::CreateFieldTrial( | 757 ASSERT_TRUE(base::FieldTrialList::CreateFieldTrial( |
| 815 "EmbeddedSearch", "Group1 espv:2 google_local_ntp:0")); | 758 "EmbeddedSearch", "Group1 espv:2 google_local_ntp:0")); |
| 816 EXPECT_FALSE(ShouldShowGoogleLocalNTP()); | 759 EXPECT_FALSE(ShouldShowGoogleLocalNTP()); |
| 817 } | 760 } |
| 818 | 761 |
| 819 TEST_F(SearchTest, ShouldReuseInstantSearchBasePage_EnabledViaCommandLine) { | |
| 820 CommandLine::ForCurrentProcess()->AppendSwitch( | |
| 821 switches::kPrefetchSearchResults); | |
| 822 // Command-line enable should override Finch. | |
| 823 ASSERT_TRUE(base::FieldTrialList::CreateFieldTrial( | |
| 824 "EmbeddedSearch", | |
| 825 "Group1 espv:89 prefetch_results:0 reuse_instant_search_base_page:1")); | |
| 826 EXPECT_TRUE(ShouldPrefetchSearchResults()); | |
| 827 EXPECT_TRUE(ShouldReuseInstantSearchBasePage()); | |
| 828 EXPECT_EQ(89ul, EmbeddedSearchPageVersion()); | |
| 829 } | |
| 830 | 762 |
| 831 TEST_F(SearchTest, IsNTPURL) { | 763 TEST_F(SearchTest, IsNTPURL) { |
| 832 GURL invalid_url; | 764 GURL invalid_url; |
| 833 GURL ntp_url(chrome::kChromeUINewTabURL); | 765 GURL ntp_url(chrome::kChromeUINewTabURL); |
| 834 GURL local_ntp_url(GetLocalInstantURL(profile())); | 766 GURL local_ntp_url(GetLocalInstantURL(profile())); |
| 835 | 767 |
| 836 EXPECT_FALSE(chrome::IsNTPURL(invalid_url, profile())); | 768 EXPECT_FALSE(chrome::IsNTPURL(invalid_url, profile())); |
| 837 // No margin. | 769 // No margin. |
| 838 EnableQueryExtractionForTesting(); | 770 EnableQueryExtractionForTesting(); |
| 839 profile()->GetPrefs()->SetBoolean(prefs::kSearchSuggestEnabled, true); | 771 profile()->GetPrefs()->SetBoolean(prefs::kSearchSuggestEnabled, true); |
| (...skipping 15 matching lines...) Expand all Loading... |
| 855 } | 787 } |
| 856 | 788 |
| 857 TEST_F(SearchTest, GetSearchURLs) { | 789 TEST_F(SearchTest, GetSearchURLs) { |
| 858 std::vector<GURL> search_urls = GetSearchURLs(profile()); | 790 std::vector<GURL> search_urls = GetSearchURLs(profile()); |
| 859 EXPECT_EQ(2U, search_urls.size()); | 791 EXPECT_EQ(2U, search_urls.size()); |
| 860 EXPECT_EQ("http://foo.com/alt#quux=", search_urls[0].spec()); | 792 EXPECT_EQ("http://foo.com/alt#quux=", search_urls[0].spec()); |
| 861 EXPECT_EQ("http://foo.com/url?bar=", search_urls[1].spec()); | 793 EXPECT_EQ("http://foo.com/url?bar=", search_urls[1].spec()); |
| 862 } | 794 } |
| 863 | 795 |
| 864 TEST_F(SearchTest, GetSearchResultPrefetchBaseURL) { | 796 TEST_F(SearchTest, GetSearchResultPrefetchBaseURL) { |
| 865 // "prefetch_results" flag is disabled. | 797 #if defined(OS_IOS) |
| 798 EXPECT_FALSE(ShouldPrefetchSearchResults()); |
| 866 EXPECT_EQ(GURL(), GetSearchResultPrefetchBaseURL(profile())); | 799 EXPECT_EQ(GURL(), GetSearchResultPrefetchBaseURL(profile())); |
| 867 | 800 #else |
| 868 // "prefetch_results" flag is enabled via field trials. | |
| 869 ASSERT_TRUE(base::FieldTrialList::CreateFieldTrial( | |
| 870 "EmbeddedSearch", | |
| 871 "Group1 espv:80 prefetch_results:1")); | |
| 872 EXPECT_TRUE(ShouldPrefetchSearchResults()); | 801 EXPECT_TRUE(ShouldPrefetchSearchResults()); |
| 873 | |
| 874 EXPECT_EQ(GURL("https://foo.com/instant?ion=1&foo=foo#foo=foo&strk"), | 802 EXPECT_EQ(GURL("https://foo.com/instant?ion=1&foo=foo#foo=foo&strk"), |
| 875 GetSearchResultPrefetchBaseURL(profile())); | 803 GetSearchResultPrefetchBaseURL(profile())); |
| 804 #endif |
| 876 } | 805 } |
| 877 | 806 |
| 878 TEST_F(SearchTest, ForceInstantResultsParam) { | 807 TEST_F(SearchTest, ForceInstantResultsParam) { |
| 879 ASSERT_TRUE(base::FieldTrialList::CreateFieldTrial("EmbeddedSearch", | 808 ASSERT_TRUE(base::FieldTrialList::CreateFieldTrial("EmbeddedSearch", |
| 880 "Group1 espv:2")); | 809 "Group1 espv:2")); |
| 881 EXPECT_TRUE(IsInstantExtendedAPIEnabled()); | 810 EXPECT_TRUE(IsInstantExtendedAPIEnabled()); |
| 882 EXPECT_EQ("ion=1&", ForceInstantResultsParam(true)); | 811 EXPECT_EQ("ion=1&", ForceInstantResultsParam(true)); |
| 883 EXPECT_EQ(std::string(), ForceInstantResultsParam(false)); | 812 EXPECT_EQ(std::string(), ForceInstantResultsParam(false)); |
| 884 } | 813 } |
| 885 | 814 |
| (...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 977 EXPECT_EQ("http://www.google.com/search?q=foo", result.spec()); | 906 EXPECT_EQ("http://www.google.com/search?q=foo", result.spec()); |
| 978 } | 907 } |
| 979 | 908 |
| 980 typedef SearchTest InstantExtendedEnabledParamTest; | 909 typedef SearchTest InstantExtendedEnabledParamTest; |
| 981 | 910 |
| 982 TEST_F(InstantExtendedEnabledParamTest, QueryExtractionDisabled) { | 911 TEST_F(InstantExtendedEnabledParamTest, QueryExtractionDisabled) { |
| 983 ASSERT_TRUE(base::FieldTrialList::CreateFieldTrial("EmbeddedSearch", | 912 ASSERT_TRUE(base::FieldTrialList::CreateFieldTrial("EmbeddedSearch", |
| 984 "Group1 espv:12")); | 913 "Group1 espv:12")); |
| 985 // Make sure InstantExtendedEnabledParam() returns an empty string for search | 914 // Make sure InstantExtendedEnabledParam() returns an empty string for search |
| 986 // requests. | 915 // requests. |
| 987 #if defined(OS_IOS) || defined(OS_ANDROID) | 916 #if defined(OS_IOS) |
| 988 // Query extraction is always enabled on mobile. | 917 // Query extraction is always enabled on mobile. |
| 989 EXPECT_TRUE(IsQueryExtractionEnabled()); | 918 EXPECT_TRUE(IsQueryExtractionEnabled()); |
| 990 EXPECT_EQ("espv=12&", InstantExtendedEnabledParam(true)); | 919 EXPECT_EQ("espv=12&", InstantExtendedEnabledParam(true)); |
| 991 #else | 920 #else |
| 992 EXPECT_FALSE(IsQueryExtractionEnabled()); | 921 EXPECT_FALSE(IsQueryExtractionEnabled()); |
| 993 EXPECT_EQ("", InstantExtendedEnabledParam(true)); | 922 EXPECT_EQ("", InstantExtendedEnabledParam(true)); |
| 994 #endif | 923 #endif |
| 995 EXPECT_EQ("espv=12&", InstantExtendedEnabledParam(false)); | 924 EXPECT_EQ("espv=12&", InstantExtendedEnabledParam(false)); |
| 996 } | 925 } |
| 997 | 926 |
| 998 TEST_F(InstantExtendedEnabledParamTest, QueryExtractionEnabled) { | 927 TEST_F(InstantExtendedEnabledParamTest, QueryExtractionEnabled) { |
| 999 ASSERT_TRUE(base::FieldTrialList::CreateFieldTrial( | 928 ASSERT_TRUE(base::FieldTrialList::CreateFieldTrial( |
| 1000 "EmbeddedSearch", "Group1 espv:10 query_extraction:1")); | 929 "EmbeddedSearch", "Group1 espv:10 query_extraction:1")); |
| 1001 EXPECT_TRUE(IsQueryExtractionEnabled()); | 930 EXPECT_TRUE(IsQueryExtractionEnabled()); |
| 1002 // Make sure InstantExtendedEnabledParam() returns a non-empty param string | 931 // Make sure InstantExtendedEnabledParam() returns a non-empty param string |
| 1003 // for search requests. | 932 // for search requests. |
| 1004 EXPECT_EQ("espv=10&", InstantExtendedEnabledParam(true)); | 933 EXPECT_EQ("espv=10&", InstantExtendedEnabledParam(true)); |
| 1005 EXPECT_EQ("espv=10&", InstantExtendedEnabledParam(false)); | 934 EXPECT_EQ("espv=10&", InstantExtendedEnabledParam(false)); |
| 1006 } | 935 } |
| 1007 | 936 |
| 1008 TEST_F(InstantExtendedEnabledParamTest, UseDefaultEmbeddedSearchPageVersion) { | 937 TEST_F(InstantExtendedEnabledParamTest, UseDefaultEmbeddedSearchPageVersion) { |
| 1009 ASSERT_TRUE(base::FieldTrialList::CreateFieldTrial( | 938 ASSERT_TRUE(base::FieldTrialList::CreateFieldTrial( |
| 1010 "EmbeddedSearch", "Group1 espv:-1 query_extraction:1")); | 939 "EmbeddedSearch", "Group1 espv:-1 query_extraction:1")); |
| 1011 EXPECT_TRUE(IsQueryExtractionEnabled()); | 940 EXPECT_TRUE(IsQueryExtractionEnabled()); |
| 1012 #if defined(OS_IOS) || defined(OS_ANDROID) | 941 #if defined(OS_IOS) |
| 1013 EXPECT_EQ("espv=1&", InstantExtendedEnabledParam(true)); | 942 EXPECT_EQ("espv=1&", InstantExtendedEnabledParam(true)); |
| 1014 EXPECT_EQ("espv=1&", InstantExtendedEnabledParam(false)); | 943 EXPECT_EQ("espv=1&", InstantExtendedEnabledParam(false)); |
| 1015 #else | 944 #else |
| 1016 EXPECT_EQ("espv=2&", InstantExtendedEnabledParam(true)); | 945 EXPECT_EQ("espv=2&", InstantExtendedEnabledParam(true)); |
| 1017 EXPECT_EQ("espv=2&", InstantExtendedEnabledParam(false)); | 946 EXPECT_EQ("espv=2&", InstantExtendedEnabledParam(false)); |
| 1018 #endif | 947 #endif |
| 1019 } | 948 } |
| 1020 | 949 |
| 1021 typedef SearchTest IsQueryExtractionEnabledTest; | 950 typedef SearchTest IsQueryExtractionEnabledTest; |
| 1022 | 951 |
| (...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1213 } | 1142 } |
| 1214 | 1143 |
| 1215 TEST_F(OriginChipTest, CommandLineOnSrp) { | 1144 TEST_F(OriginChipTest, CommandLineOnSrp) { |
| 1216 CommandLine::ForCurrentProcess()->AppendSwitch( | 1145 CommandLine::ForCurrentProcess()->AppendSwitch( |
| 1217 switches::kEnableOriginChipOnSrp); | 1146 switches::kEnableOriginChipOnSrp); |
| 1218 EXPECT_TRUE(ShouldDisplayOriginChip()); | 1147 EXPECT_TRUE(ShouldDisplayOriginChip()); |
| 1219 EXPECT_EQ(ORIGIN_CHIP_ON_SRP, GetOriginChipCondition()); | 1148 EXPECT_EQ(ORIGIN_CHIP_ON_SRP, GetOriginChipCondition()); |
| 1220 } | 1149 } |
| 1221 | 1150 |
| 1222 } // namespace chrome | 1151 } // namespace chrome |
| OLD | NEW |