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

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

Issue 2755503002: Add a new entry to omnibox_event.proto to log specific type of contextual suggestions (Closed)
Patch Set: Add unit test for parsing and use type specifier for search suggestions. Created 3 years, 9 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
OLDNEW
1 // Copyright 2012 The Chromium Authors. All rights reserved. 1 // Copyright 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 "components/omnibox/browser/search_provider.h" 5 #include "components/omnibox/browser/search_provider.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <string> 9 #include <string>
10 10
(...skipping 2489 matching lines...) Expand 10 before | Expand all | Expand 10 after
2500 { 2500 {
2501 // Reset the session and check that bits are reset. 2501 // Reset the session and check that bits are reset.
2502 provider_->ResetSession(); 2502 provider_->ResetSession();
2503 ProvidersInfo providers_info; 2503 ProvidersInfo providers_info;
2504 provider_->AddProviderInfo(&providers_info); 2504 provider_->AddProviderInfo(&providers_info);
2505 ASSERT_EQ(1U, providers_info.size()); 2505 ASSERT_EQ(1U, providers_info.size());
2506 EXPECT_EQ(0, providers_info[0].field_trial_triggered_size()); 2506 EXPECT_EQ(0, providers_info[0].field_trial_triggered_size());
2507 EXPECT_EQ(0, providers_info[0].field_trial_triggered_in_session_size()); 2507 EXPECT_EQ(0, providers_info[0].field_trial_triggered_in_session_size());
2508 } 2508 }
2509 } 2509 }
2510 // A basic test that verifies the specific type identifier parsing logic.
2511 TEST_F(SearchProviderTest, SpecificTypeIdentifierParsing) {
2512 struct Match {
2513 std::string contents;
2514 int specific_type_identifier;
2515 };
2516
2517 struct {
2518 const std::string input_text;
2519 const std::string provider_response_json;
2520 const Match matches[2];
Mark P 2017/03/23 22:49:53 nit: expected_matches
gcomanici 2017/03/24 16:24:59 Done.
2521 } cases[] = {
2522 {// Check that the specific type is set to 0 when these values are not
Mark P 2017/03/23 22:49:53 Note to self: I'm not reviewing the rest of this t
2523 // proviede in the response.
2524 "a",
2525 "[\"a\",[\"ab\",\"http://b.com\"],[],[], "
2526 "{\"google:suggesttype\":[\"QUERY\", \"NAVIGATION\"]}]",
2527 {{"ab", 0}, {"b.com", 0}}},
2528 {// Check that the specific type works for zero-suggest suggestions.
2529 "c",
2530 "[\"c\",[\"cd\",\"http://d.com\"],[],[], "
2531 "{\"google:suggesttype\":[\"QUERY\", "
2532 "\"NAVIGATION\"],\"google:specifictypeid\":[1, 3]}]",
2533 {{"cd", 1}, {"d.com", 3}}},
2534 {// Check that the specific type is set to zero when the number of
2535 // suggestions is smaller than the number of typeid's provided.
2536 "foo",
2537 "[\"foo\",[\"foo bar\", \"foo baz\"],[],[], "
2538 "{\"google:suggesttype\":[\"QUERY\"],\"google:specifictypeid\":[1, 2, "
2539 "3]}]",
2540 {{"foo bar", 0}, {"foo baz", 0}}},
2541 {// Check that the specific type is set to zero when the number of
2542 // suggestions is largerthan the number of typeid's provided.
2543 "bar",
2544 "[\"bar\",[\"bar foo\", \"bar foz\"],[],[], "
2545 "{\"google:suggesttype\":[\"QUERY\"],\"google:specifictypeid\":[1]}]",
2546 {{"bar foo", 0}, {"bar foz", 0}}}};
2547
2548 for (size_t i = 0; i < arraysize(cases); ++i) {
2549 QueryForInputAndWaitForFetcherResponses(
2550 ASCIIToUTF16(cases[i].input_text), false,
2551 cases[i].provider_response_json, std::string());
2552
2553 // Check for the match and field trial triggered bits.
2554 const ACMatches& matches = provider_->matches();
2555 ASSERT_FALSE(matches.empty());
2556 for (size_t j = 0; j < arraysize(cases[i].matches); ++j) {
2557 if (cases[i].matches[j].contents == kNotApplicable)
2558 continue;
2559 AutocompleteMatch match;
2560 EXPECT_TRUE(FindMatchWithContents(
2561 ASCIIToUTF16(cases[i].matches[j].contents), &match));
2562 EXPECT_EQ(cases[i].matches[j].specific_type_identifier,
2563 match.specific_type_identifier);
2564 }
2565 }
2566 }
2510 2567
2511 // Verifies inline autocompletion of navigational results. 2568 // Verifies inline autocompletion of navigational results.
2512 TEST_F(SearchProviderTest, NavigationInline) { 2569 TEST_F(SearchProviderTest, NavigationInline) {
2513 struct { 2570 struct {
2514 const std::string input; 2571 const std::string input;
2515 const std::string url; 2572 const std::string url;
2516 // Test the expected fill_into_edit, which may drop "http://". 2573 // Test the expected fill_into_edit, which may drop "http://".
2517 // Some cases do not trim "http://" to match from the start of the scheme. 2574 // Some cases do not trim "http://" to match from the start of the scheme.
2518 const std::string fill_into_edit; 2575 const std::string fill_into_edit;
2519 const std::string inline_autocompletion; 2576 const std::string inline_autocompletion;
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after
2660 "https://abc.com/path/file.htm?q=x#foo", 2717 "https://abc.com/path/file.htm?q=x#foo",
2661 "c.com/path/file.htm?q=x#foo", true, false }, 2718 "c.com/path/file.htm?q=x#foo", true, false },
2662 2719
2663 }; 2720 };
2664 2721
2665 for (size_t i = 0; i < arraysize(cases); ++i) { 2722 for (size_t i = 0; i < arraysize(cases); ++i) {
2666 // First test regular mode. 2723 // First test regular mode.
2667 QueryForInput(ASCIIToUTF16(cases[i].input), false, false); 2724 QueryForInput(ASCIIToUTF16(cases[i].input), false, false);
2668 SearchSuggestionParser::NavigationResult result( 2725 SearchSuggestionParser::NavigationResult result(
2669 ChromeAutocompleteSchemeClassifier(&profile_), GURL(cases[i].url), 2726 ChromeAutocompleteSchemeClassifier(&profile_), GURL(cases[i].url),
2670 AutocompleteMatchType::NAVSUGGEST, base::string16(), std::string(), 2727 AutocompleteMatchType::NAVSUGGEST, 0, base::string16(), std::string(),
2671 false, 0, false, ASCIIToUTF16(cases[i].input)); 2728 false, 0, false, ASCIIToUTF16(cases[i].input));
2672 result.set_received_after_last_keystroke(false); 2729 result.set_received_after_last_keystroke(false);
2673 AutocompleteMatch match(provider_->NavigationToMatch(result)); 2730 AutocompleteMatch match(provider_->NavigationToMatch(result));
2674 EXPECT_EQ(ASCIIToUTF16(cases[i].inline_autocompletion), 2731 EXPECT_EQ(ASCIIToUTF16(cases[i].inline_autocompletion),
2675 match.inline_autocompletion); 2732 match.inline_autocompletion);
2676 EXPECT_EQ(ASCIIToUTF16(cases[i].fill_into_edit), match.fill_into_edit); 2733 EXPECT_EQ(ASCIIToUTF16(cases[i].fill_into_edit), match.fill_into_edit);
2677 EXPECT_EQ(cases[i].allowed_to_be_default_match_in_regular_mode, 2734 EXPECT_EQ(cases[i].allowed_to_be_default_match_in_regular_mode,
2678 match.allowed_to_be_default_match); 2735 match.allowed_to_be_default_match);
2679 2736
2680 // Then test prevent-inline-autocomplete mode. 2737 // Then test prevent-inline-autocomplete mode.
2681 QueryForInput(ASCIIToUTF16(cases[i].input), true, false); 2738 QueryForInput(ASCIIToUTF16(cases[i].input), true, false);
2682 SearchSuggestionParser::NavigationResult result_prevent_inline( 2739 SearchSuggestionParser::NavigationResult result_prevent_inline(
2683 ChromeAutocompleteSchemeClassifier(&profile_), GURL(cases[i].url), 2740 ChromeAutocompleteSchemeClassifier(&profile_), GURL(cases[i].url),
2684 AutocompleteMatchType::NAVSUGGEST, base::string16(), std::string(), 2741 AutocompleteMatchType::NAVSUGGEST, 0, base::string16(), std::string(),
2685 false, 0, false, ASCIIToUTF16(cases[i].input)); 2742 false, 0, false, ASCIIToUTF16(cases[i].input));
2686 result_prevent_inline.set_received_after_last_keystroke(false); 2743 result_prevent_inline.set_received_after_last_keystroke(false);
2687 AutocompleteMatch match_prevent_inline( 2744 AutocompleteMatch match_prevent_inline(
2688 provider_->NavigationToMatch(result_prevent_inline)); 2745 provider_->NavigationToMatch(result_prevent_inline));
2689 EXPECT_EQ(ASCIIToUTF16(cases[i].inline_autocompletion), 2746 EXPECT_EQ(ASCIIToUTF16(cases[i].inline_autocompletion),
2690 match_prevent_inline.inline_autocompletion); 2747 match_prevent_inline.inline_autocompletion);
2691 EXPECT_EQ(ASCIIToUTF16(cases[i].fill_into_edit), 2748 EXPECT_EQ(ASCIIToUTF16(cases[i].fill_into_edit),
2692 match_prevent_inline.fill_into_edit); 2749 match_prevent_inline.fill_into_edit);
2693 EXPECT_EQ(cases[i].allowed_to_be_default_match_in_prevent_inline_mode, 2750 EXPECT_EQ(cases[i].allowed_to_be_default_match_in_prevent_inline_mode,
2694 match_prevent_inline.allowed_to_be_default_match); 2751 match_prevent_inline.allowed_to_be_default_match);
2695 } 2752 }
2696 } 2753 }
2697 2754
2698 // Verifies that "http://" is not trimmed for input that is a leading substring. 2755 // Verifies that "http://" is not trimmed for input that is a leading substring.
2699 TEST_F(SearchProviderTest, NavigationInlineSchemeSubstring) { 2756 TEST_F(SearchProviderTest, NavigationInlineSchemeSubstring) {
2700 const base::string16 input(ASCIIToUTF16("ht")); 2757 const base::string16 input(ASCIIToUTF16("ht"));
2701 const base::string16 url(ASCIIToUTF16("http://a.com")); 2758 const base::string16 url(ASCIIToUTF16("http://a.com"));
2702 SearchSuggestionParser::NavigationResult result( 2759 SearchSuggestionParser::NavigationResult result(
2703 ChromeAutocompleteSchemeClassifier(&profile_), GURL(url), 2760 ChromeAutocompleteSchemeClassifier(&profile_), GURL(url),
2704 AutocompleteMatchType::NAVSUGGEST, 2761 AutocompleteMatchType::NAVSUGGEST, 0, base::string16(), std::string(),
2705 base::string16(), std::string(), false, 0, false, input); 2762 false, 0, false, input);
2706 result.set_received_after_last_keystroke(false); 2763 result.set_received_after_last_keystroke(false);
2707 2764
2708 // Check the offset and strings when inline autocompletion is allowed. 2765 // Check the offset and strings when inline autocompletion is allowed.
2709 QueryForInput(input, false, false); 2766 QueryForInput(input, false, false);
2710 AutocompleteMatch match_inline(provider_->NavigationToMatch(result)); 2767 AutocompleteMatch match_inline(provider_->NavigationToMatch(result));
2711 EXPECT_EQ(url, match_inline.fill_into_edit); 2768 EXPECT_EQ(url, match_inline.fill_into_edit);
2712 EXPECT_EQ(url.substr(2), match_inline.inline_autocompletion); 2769 EXPECT_EQ(url.substr(2), match_inline.inline_autocompletion);
2713 EXPECT_TRUE(match_inline.allowed_to_be_default_match); 2770 EXPECT_TRUE(match_inline.allowed_to_be_default_match);
2714 EXPECT_EQ(url, match_inline.contents); 2771 EXPECT_EQ(url, match_inline.contents);
2715 2772
2716 // Check the same strings when inline autocompletion is prevented. 2773 // Check the same strings when inline autocompletion is prevented.
2717 QueryForInput(input, true, false); 2774 QueryForInput(input, true, false);
2718 AutocompleteMatch match_prevent(provider_->NavigationToMatch(result)); 2775 AutocompleteMatch match_prevent(provider_->NavigationToMatch(result));
2719 EXPECT_EQ(url, match_prevent.fill_into_edit); 2776 EXPECT_EQ(url, match_prevent.fill_into_edit);
2720 EXPECT_FALSE(match_prevent.allowed_to_be_default_match); 2777 EXPECT_FALSE(match_prevent.allowed_to_be_default_match);
2721 EXPECT_EQ(url, match_prevent.contents); 2778 EXPECT_EQ(url, match_prevent.contents);
2722 } 2779 }
2723 2780
2724 // Verifies that input "w" marks a more significant domain label than "www.". 2781 // Verifies that input "w" marks a more significant domain label than "www.".
2725 TEST_F(SearchProviderTest, NavigationInlineDomainClassify) { 2782 TEST_F(SearchProviderTest, NavigationInlineDomainClassify) {
2726 QueryForInput(ASCIIToUTF16("w"), false, false); 2783 QueryForInput(ASCIIToUTF16("w"), false, false);
2727 SearchSuggestionParser::NavigationResult result( 2784 SearchSuggestionParser::NavigationResult result(
2728 ChromeAutocompleteSchemeClassifier(&profile_), 2785 ChromeAutocompleteSchemeClassifier(&profile_), GURL("http://www.wow.com"),
2729 GURL("http://www.wow.com"), AutocompleteMatchType::NAVSUGGEST, 2786 AutocompleteMatchType::NAVSUGGEST, 0, base::string16(), std::string(),
2730 base::string16(), std::string(), false, 0, false, ASCIIToUTF16("w")); 2787 false, 0, false, ASCIIToUTF16("w"));
2731 result.set_received_after_last_keystroke(false); 2788 result.set_received_after_last_keystroke(false);
2732 AutocompleteMatch match(provider_->NavigationToMatch(result)); 2789 AutocompleteMatch match(provider_->NavigationToMatch(result));
2733 EXPECT_EQ(ASCIIToUTF16("ow.com"), match.inline_autocompletion); 2790 EXPECT_EQ(ASCIIToUTF16("ow.com"), match.inline_autocompletion);
2734 EXPECT_TRUE(match.allowed_to_be_default_match); 2791 EXPECT_TRUE(match.allowed_to_be_default_match);
2735 EXPECT_EQ(ASCIIToUTF16("www.wow.com"), match.fill_into_edit); 2792 EXPECT_EQ(ASCIIToUTF16("www.wow.com"), match.fill_into_edit);
2736 EXPECT_EQ(ASCIIToUTF16("www.wow.com"), match.contents); 2793 EXPECT_EQ(ASCIIToUTF16("www.wow.com"), match.contents);
2737 2794
2738 // Ensure that the match for input "w" is marked on "wow" and not "www". 2795 // Ensure that the match for input "w" is marked on "wow" and not "www".
2739 ASSERT_EQ(3U, match.contents_class.size()); 2796 ASSERT_EQ(3U, match.contents_class.size());
2740 EXPECT_EQ(0U, match.contents_class[0].offset); 2797 EXPECT_EQ(0U, match.contents_class[0].offset);
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
2850 AutocompleteMatchType::SEARCH_WHAT_YOU_TYPED, 2907 AutocompleteMatchType::SEARCH_WHAT_YOU_TYPED,
2851 false }; 2908 false };
2852 2909
2853 struct { 2910 struct {
2854 const std::string input_text; 2911 const std::string input_text;
2855 bool prefer_keyword_provider_results; 2912 bool prefer_keyword_provider_results;
2856 const std::string default_provider_response_json; 2913 const std::string default_provider_response_json;
2857 const std::string keyword_provider_response_json; 2914 const std::string keyword_provider_response_json;
2858 const Match matches[5]; 2915 const Match matches[5];
2859 } cases[] = { 2916 } cases[] = {
2860 // Default provider response does not have prefetch details. Ensure that the 2917 // Default provider response does not have prefetch details. Ensure that
2861 // suggestions are not marked as prefetch query. 2918 // the suggestions are not marked as prefetch query.
2862 { "a", 2919 {
2863 false, 2920 "a",
2864 "[\"a\",[\"b\", \"c\"],[],[],{\"google:suggestrelevance\":[1, 2]}]", 2921 false,
2865 std::string(), 2922 "[\"a\",[\"b\", \"c\"],[],[],{\"google:suggestrelevance\":[1, 2]}]",
2866 { { "a", false, AutocompleteMatchType::SEARCH_WHAT_YOU_TYPED, false }, 2923 std::string(),
2867 { "c", false, AutocompleteMatchType::SEARCH_SUGGEST, false }, 2924 {{"a", false, AutocompleteMatchType::SEARCH_WHAT_YOU_TYPED, false},
2868 { "b", false, AutocompleteMatchType::SEARCH_SUGGEST, false }, 2925 {"c", false, AutocompleteMatchType::SEARCH_SUGGEST, false},
2869 kEmptyMatch, 2926 {"b", false, AutocompleteMatchType::SEARCH_SUGGEST, false},
2870 kEmptyMatch 2927 kEmptyMatch,
2928 kEmptyMatch},
2871 }, 2929 },
2872 }, 2930 // Ensure that default provider suggest response prefetch details are
2873 // Ensure that default provider suggest response prefetch details are 2931 // parsed and recorded in AutocompleteMatch.
2874 // parsed and recorded in AutocompleteMatch. 2932 {
2875 { "ab", 2933 "ab",
2876 false, 2934 false,
2877 "[\"ab\",[\"abc\", \"http://b.com\", \"http://c.com\"],[],[]," 2935 "[\"ab\",[\"abc\", \"http://b.com\", \"http://c.com\"],[],[],"
2878 "{\"google:clientdata\":{\"phi\": 0}," 2936 "{\"google:clientdata\":{\"phi\": 0},"
2879 "\"google:suggesttype\":[\"QUERY\", \"NAVIGATION\", \"NAVIGATION\"]," 2937 "\"google:suggesttype\":[\"QUERY\", \"NAVIGATION\", \"NAVIGATION\"],"
2880 "\"google:suggestrelevance\":[999, 12, 1]}]", 2938 "\"google:suggestrelevance\":[999, 12, 1]}]",
2881 std::string(), 2939 std::string(),
2882 { { "ab", false, AutocompleteMatchType::SEARCH_WHAT_YOU_TYPED, false }, 2940 {{"ab", false, AutocompleteMatchType::SEARCH_WHAT_YOU_TYPED, false},
2883 { "abc", true, AutocompleteMatchType::SEARCH_SUGGEST, false }, 2941 {"abc", true, AutocompleteMatchType::SEARCH_SUGGEST, false},
2884 { "b.com", false, AutocompleteMatchType::NAVSUGGEST, false }, 2942 {"b.com", false, AutocompleteMatchType::NAVSUGGEST, false},
2885 { "c.com", false, AutocompleteMatchType::NAVSUGGEST, false }, 2943 {"c.com", false, AutocompleteMatchType::NAVSUGGEST, false},
2886 kEmptyMatch 2944 kEmptyMatch},
2887 }, 2945 },
2888 }, 2946 // Default provider suggest response has prefetch details.
2889 // Default provider suggest response has prefetch details. 2947 // SEARCH_WHAT_YOU_TYPE suggestion outranks SEARCH_SUGGEST suggestion for
2890 // SEARCH_WHAT_YOU_TYPE suggestion outranks SEARCH_SUGGEST suggestion for 2948 // the same query string. Ensure that the prefetch details from
2891 // the same query string. Ensure that the prefetch details from 2949 // SEARCH_SUGGEST match are set onto SEARCH_WHAT_YOU_TYPE match.
2892 // SEARCH_SUGGEST match are set onto SEARCH_WHAT_YOU_TYPE match. 2950 {
2893 { "ab", 2951 "ab",
2894 false, 2952 false,
2895 "[\"ab\",[\"ab\", \"http://ab.com\"],[],[]," 2953 "[\"ab\",[\"ab\", \"http://ab.com\"],[],[],"
2896 "{\"google:clientdata\":{\"phi\": 0}," 2954 "{\"google:clientdata\":{\"phi\": 0},"
2897 "\"google:suggesttype\":[\"QUERY\", \"NAVIGATION\"]," 2955 "\"google:suggesttype\":[\"QUERY\", \"NAVIGATION\"],"
2898 "\"google:suggestrelevance\":[99, 98]}]", 2956 "\"google:suggestrelevance\":[99, 98]}]",
2899 std::string(), 2957 std::string(),
2900 { {"ab", true, AutocompleteMatchType::SEARCH_WHAT_YOU_TYPED, false }, 2958 {{"ab", true, AutocompleteMatchType::SEARCH_WHAT_YOU_TYPED, false},
2901 {"ab.com", false, AutocompleteMatchType::NAVSUGGEST, false }, 2959 {"ab.com", false, AutocompleteMatchType::NAVSUGGEST, false},
2902 kEmptyMatch, 2960 kEmptyMatch,
2903 kEmptyMatch, 2961 kEmptyMatch,
2904 kEmptyMatch 2962 kEmptyMatch},
2905 }, 2963 },
2906 }, 2964 // Default provider response has prefetch details. We prefer keyword
2907 // Default provider response has prefetch details. We prefer keyword 2965 // provider results. Ensure that prefetch bit for a suggestion from the
2908 // provider results. Ensure that prefetch bit for a suggestion from the 2966 // default search provider does not get copied onto a higher-scoring match
2909 // default search provider does not get copied onto a higher-scoring match 2967 // for the same query string from the keyword provider.
2910 // for the same query string from the keyword provider. 2968 {
2911 { "k a", 2969 "k a",
2912 true, 2970 true,
2913 "[\"k a\",[\"a\", \"ab\"],[],[], {\"google:clientdata\":{\"phi\": 0}," 2971 "[\"k a\",[\"a\", \"ab\"],[],[], {\"google:clientdata\":{\"phi\": 0},"
2914 "\"google:suggesttype\":[\"QUERY\", \"QUERY\"]," 2972 "\"google:suggesttype\":[\"QUERY\", \"QUERY\"],"
2915 "\"google:suggestrelevance\":[9, 12]}]", 2973 "\"google:suggestrelevance\":[9, 12]}]",
2916 "[\"a\",[\"b\", \"c\"],[],[],{\"google:suggestrelevance\":[1, 2]}]", 2974 "[\"a\",[\"b\", \"c\"],[],[],{\"google:suggestrelevance\":[1, 2]}]",
2917 { { "a", false, AutocompleteMatchType::SEARCH_OTHER_ENGINE, true}, 2975 {{"a", false, AutocompleteMatchType::SEARCH_OTHER_ENGINE, true},
2918 { "k a", false, AutocompleteMatchType::SEARCH_WHAT_YOU_TYPED, false }, 2976 {"k a", false, AutocompleteMatchType::SEARCH_WHAT_YOU_TYPED, false},
2919 { "ab", false, AutocompleteMatchType::SEARCH_SUGGEST, false }, 2977 {"ab", false, AutocompleteMatchType::SEARCH_SUGGEST, false},
2920 { "c", false, AutocompleteMatchType::SEARCH_SUGGEST, true }, 2978 {"c", false, AutocompleteMatchType::SEARCH_SUGGEST, true},
2921 { "b", false, AutocompleteMatchType::SEARCH_SUGGEST, true } 2979 {"b", false, AutocompleteMatchType::SEARCH_SUGGEST, true}},
2922 }, 2980 }};
2923 }
2924 };
2925 2981
2926 for (size_t i = 0; i < arraysize(cases); ++i) { 2982 for (size_t i = 0; i < arraysize(cases); ++i) {
2927 QueryForInputAndWaitForFetcherResponses( 2983 QueryForInputAndWaitForFetcherResponses(
2928 ASCIIToUTF16(cases[i].input_text), 2984 ASCIIToUTF16(cases[i].input_text),
2929 cases[i].prefer_keyword_provider_results, 2985 cases[i].prefer_keyword_provider_results,
2930 cases[i].default_provider_response_json, 2986 cases[i].default_provider_response_json,
2931 cases[i].prefer_keyword_provider_results ? 2987 cases[i].prefer_keyword_provider_results ?
2932 cases[i].keyword_provider_response_json : std::string()); 2988 cases[i].keyword_provider_response_json : std::string());
2933 2989
2934 const std::string description = 2990 const std::string description =
(...skipping 532 matching lines...) Expand 10 before | Expand all | Expand 10 after
3467 ASSERT_FALSE(provider_->answers_cache_.empty()); 3523 ASSERT_FALSE(provider_->answers_cache_.empty());
3468 3524
3469 // Without scored results, no answers will be retrieved. 3525 // Without scored results, no answers will be retrieved.
3470 AnswersQueryData answer = provider_->FindAnswersPrefetchData(); 3526 AnswersQueryData answer = provider_->FindAnswersPrefetchData();
3471 EXPECT_TRUE(answer.full_query_text.empty()); 3527 EXPECT_TRUE(answer.full_query_text.empty());
3472 EXPECT_TRUE(answer.query_type.empty()); 3528 EXPECT_TRUE(answer.query_type.empty());
3473 3529
3474 // Inject a scored result, which will trigger answer retrieval. 3530 // Inject a scored result, which will trigger answer retrieval.
3475 base::string16 query = base::ASCIIToUTF16("weather los angeles"); 3531 base::string16 query = base::ASCIIToUTF16("weather los angeles");
3476 SearchSuggestionParser::SuggestResult suggest_result( 3532 SearchSuggestionParser::SuggestResult suggest_result(
3477 query, AutocompleteMatchType::SEARCH_HISTORY, query, base::string16(), 3533 query, AutocompleteMatchType::SEARCH_HISTORY, 0, query, base::string16(),
3478 base::string16(), base::string16(), base::string16(), nullptr, 3534 base::string16(), base::string16(), base::string16(), nullptr,
3479 std::string(), std::string(), false, 1200, false, false, query); 3535 std::string(), std::string(), false, 1200, false, false, query);
3480 QueryForInput(ASCIIToUTF16("weather l"), false, false); 3536 QueryForInput(ASCIIToUTF16("weather l"), false, false);
3481 provider_->transformed_default_history_results_.push_back(suggest_result); 3537 provider_->transformed_default_history_results_.push_back(suggest_result);
3482 answer = provider_->FindAnswersPrefetchData(); 3538 answer = provider_->FindAnswersPrefetchData();
3483 EXPECT_EQ(base::ASCIIToUTF16("weather los angeles"), answer.full_query_text); 3539 EXPECT_EQ(base::ASCIIToUTF16("weather los angeles"), answer.full_query_text);
3484 EXPECT_EQ(base::ASCIIToUTF16("2334"), answer.query_type); 3540 EXPECT_EQ(base::ASCIIToUTF16("2334"), answer.query_type);
3485 } 3541 }
3486 3542
3487 TEST_F(SearchProviderTest, RemoveExtraAnswers) { 3543 TEST_F(SearchProviderTest, RemoveExtraAnswers) {
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
3566 EXPECT_TRUE(fetcher); 3622 EXPECT_TRUE(fetcher);
3567 // Even if the fetcher returns results, we should still have no suggestions 3623 // Even if the fetcher returns results, we should still have no suggestions
3568 // (though the provider should now be done). 3624 // (though the provider should now be done).
3569 fetcher->set_response_code(200); 3625 fetcher->set_response_code(200);
3570 fetcher->SetResponseString(R"(["",["a", "b"],[],[],{}])"); 3626 fetcher->SetResponseString(R"(["",["a", "b"],[],[],{}])");
3571 fetcher->delegate()->OnURLFetchComplete(fetcher); 3627 fetcher->delegate()->OnURLFetchComplete(fetcher);
3572 RunTillProviderDone(); 3628 RunTillProviderDone();
3573 EXPECT_TRUE(provider_->done()); 3629 EXPECT_TRUE(provider_->done());
3574 EXPECT_TRUE(provider_->matches().empty()); 3630 EXPECT_TRUE(provider_->matches().empty());
3575 } 3631 }
OLDNEW
« no previous file with comments | « no previous file | components/metrics/proto/omnibox_event.proto » ('j') | components/omnibox/browser/autocomplete_match.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698