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

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

Issue 16295003: Update chrome/ to use scoped_refptr<T>::get() rather than implicit "operator T*" (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebased Created 7 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 | Annotate | Revision Log
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 "chrome/browser/autocomplete/search_provider.h" 5 #include "chrome/browser/autocomplete/search_provider.h"
6 6
7 #include "base/metrics/field_trial.h" 7 #include "base/metrics/field_trial.h"
8 #include "base/prefs/pref_service.h" 8 #include "base/prefs/pref_service.h"
9 #include "base/run_loop.h" 9 #include "base/run_loop.h"
10 #include "base/string_util.h" 10 #include "base/string_util.h"
(...skipping 1911 matching lines...) Expand 10 before | Expand all | Expand 10 after
1922 "?http://www.abc.com", 14 }, 1922 "?http://www.abc.com", 14 },
1923 { "?www.ab", "http://www.abc.com", 1923 { "?www.ab", "http://www.abc.com",
1924 "?www.abc.com", 7 }, 1924 "?www.abc.com", 7 },
1925 { "?ab", "http://www.abc.com", 1925 { "?ab", "http://www.abc.com",
1926 "?www.abc.com", 7 }, 1926 "?www.abc.com", 7 },
1927 }; 1927 };
1928 1928
1929 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(cases); i++) { 1929 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(cases); i++) {
1930 QueryForInput(ASCIIToUTF16(cases[i].input), false, false); 1930 QueryForInput(ASCIIToUTF16(cases[i].input), false, false);
1931 SearchProvider::NavigationResult result( 1931 SearchProvider::NavigationResult result(
1932 *provider_, GURL(cases[i].url), string16(), false, 0); 1932 *provider_.get(), GURL(cases[i].url), string16(), false, 0);
1933 AutocompleteMatch match(provider_->NavigationToMatch(result)); 1933 AutocompleteMatch match(provider_->NavigationToMatch(result));
1934 EXPECT_EQ(cases[i].inline_offset, match.inline_autocomplete_offset); 1934 EXPECT_EQ(cases[i].inline_offset, match.inline_autocomplete_offset);
1935 EXPECT_EQ(ASCIIToUTF16(cases[i].fill_into_edit), match.fill_into_edit); 1935 EXPECT_EQ(ASCIIToUTF16(cases[i].fill_into_edit), match.fill_into_edit);
1936 } 1936 }
1937 } 1937 }
1938 1938
1939 // Verifies that "http://" is not trimmed for input that is a leading substring. 1939 // Verifies that "http://" is not trimmed for input that is a leading substring.
1940 TEST_F(SearchProviderTest, NavigationInlineSchemeSubstring) { 1940 TEST_F(SearchProviderTest, NavigationInlineSchemeSubstring) {
1941 const string16 input(ASCIIToUTF16("ht")); 1941 const string16 input(ASCIIToUTF16("ht"));
1942 const string16 url(ASCIIToUTF16("http://a.com")); 1942 const string16 url(ASCIIToUTF16("http://a.com"));
1943 const SearchProvider::NavigationResult result( 1943 const SearchProvider::NavigationResult result(
1944 *provider_, GURL(url), string16(), false, 0); 1944 *provider_.get(), GURL(url), string16(), false, 0);
1945 1945
1946 // Check the offset and strings when inline autocompletion is allowed. 1946 // Check the offset and strings when inline autocompletion is allowed.
1947 QueryForInput(input, false, false); 1947 QueryForInput(input, false, false);
1948 AutocompleteMatch match_inline(provider_->NavigationToMatch(result)); 1948 AutocompleteMatch match_inline(provider_->NavigationToMatch(result));
1949 EXPECT_EQ(2U, match_inline.inline_autocomplete_offset); 1949 EXPECT_EQ(2U, match_inline.inline_autocomplete_offset);
1950 EXPECT_EQ(url, match_inline.fill_into_edit); 1950 EXPECT_EQ(url, match_inline.fill_into_edit);
1951 EXPECT_EQ(url, match_inline.contents); 1951 EXPECT_EQ(url, match_inline.contents);
1952 1952
1953 // Check the same offset and strings when inline autocompletion is prevented. 1953 // Check the same offset and strings when inline autocompletion is prevented.
1954 QueryForInput(input, true, false); 1954 QueryForInput(input, true, false);
1955 AutocompleteMatch match_prevent(provider_->NavigationToMatch(result)); 1955 AutocompleteMatch match_prevent(provider_->NavigationToMatch(result));
1956 EXPECT_EQ(string16::npos, match_prevent.inline_autocomplete_offset); 1956 EXPECT_EQ(string16::npos, match_prevent.inline_autocomplete_offset);
1957 EXPECT_EQ(url, match_prevent.fill_into_edit); 1957 EXPECT_EQ(url, match_prevent.fill_into_edit);
1958 EXPECT_EQ(url, match_prevent.contents); 1958 EXPECT_EQ(url, match_prevent.contents);
1959 } 1959 }
1960 1960
1961 // Verifies that input "w" marks a more significant domain label than "www.". 1961 // Verifies that input "w" marks a more significant domain label than "www.".
1962 TEST_F(SearchProviderTest, NavigationInlineDomainClassify) { 1962 TEST_F(SearchProviderTest, NavigationInlineDomainClassify) {
1963 QueryForInput(ASCIIToUTF16("w"), false, false); 1963 QueryForInput(ASCIIToUTF16("w"), false, false);
1964 const GURL url("http://www.wow.com"); 1964 const GURL url("http://www.wow.com");
1965 const SearchProvider::NavigationResult result( 1965 const SearchProvider::NavigationResult result(
1966 *provider_, url, string16(), false, 0); 1966 *provider_.get(), url, string16(), false, 0);
1967 AutocompleteMatch match(provider_->NavigationToMatch(result)); 1967 AutocompleteMatch match(provider_->NavigationToMatch(result));
1968 EXPECT_EQ(5U, match.inline_autocomplete_offset); 1968 EXPECT_EQ(5U, match.inline_autocomplete_offset);
1969 EXPECT_EQ(ASCIIToUTF16("www.wow.com"), match.fill_into_edit); 1969 EXPECT_EQ(ASCIIToUTF16("www.wow.com"), match.fill_into_edit);
1970 EXPECT_EQ(ASCIIToUTF16("www.wow.com"), match.contents); 1970 EXPECT_EQ(ASCIIToUTF16("www.wow.com"), match.contents);
1971 1971
1972 // Ensure that the match for input "w" is marked on "wow" and not "www". 1972 // Ensure that the match for input "w" is marked on "wow" and not "www".
1973 ASSERT_EQ(3U, match.contents_class.size()); 1973 ASSERT_EQ(3U, match.contents_class.size());
1974 EXPECT_EQ(0U, match.contents_class[0].offset); 1974 EXPECT_EQ(0U, match.contents_class[0].offset);
1975 EXPECT_EQ(AutocompleteMatch::ACMatchClassification::URL, 1975 EXPECT_EQ(AutocompleteMatch::ACMatchClassification::URL,
1976 match.contents_class[0].style); 1976 match.contents_class[0].style);
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after
2117 provider_->default_results_.verbatim_relevance = 2117 provider_->default_results_.verbatim_relevance =
2118 cases[i].verbatim_relevance; 2118 cases[i].verbatim_relevance;
2119 provider_->default_results_.navigation_results.clear(); 2119 provider_->default_results_.navigation_results.clear();
2120 provider_->default_results_.suggest_results.clear(); 2120 provider_->default_results_.suggest_results.clear();
2121 for (size_t j = 0; j < ARRAYSIZE_UNSAFE(cases[i].results); ++j) { 2121 for (size_t j = 0; j < ARRAYSIZE_UNSAFE(cases[i].results); ++j) {
2122 const std::string& suggestion = cases[i].results[j].suggestion; 2122 const std::string& suggestion = cases[i].results[j].suggestion;
2123 if (suggestion == kNotApplicable) 2123 if (suggestion == kNotApplicable)
2124 break; 2124 break;
2125 if (cases[i].results[j].is_navigation_result) { 2125 if (cases[i].results[j].is_navigation_result) {
2126 provider_->default_results_.navigation_results.push_back( 2126 provider_->default_results_.navigation_results.push_back(
2127 SearchProvider::NavigationResult( 2127 SearchProvider::NavigationResult(*provider_.get(),
2128 *provider_, GURL(suggestion), string16(), 2128 GURL(suggestion),
2129 false, cases[i].results[j].relevance)); 2129 string16(),
2130 false,
2131 cases[i].results[j].relevance));
2130 } else { 2132 } else {
2131 provider_->default_results_.suggest_results.push_back( 2133 provider_->default_results_.suggest_results.push_back(
2132 SearchProvider::SuggestResult(ASCIIToUTF16(suggestion), false, 2134 SearchProvider::SuggestResult(ASCIIToUTF16(suggestion), false,
2133 cases[i].results[j].relevance)); 2135 cases[i].results[j].relevance));
2134 } 2136 }
2135 } 2137 }
2136 2138
2137 provider_->input_ = AutocompleteInput( 2139 provider_->input_ = AutocompleteInput(
2138 ASCIIToUTF16(cases[i].omnibox_input), string16::npos, string16(), 2140 ASCIIToUTF16(cases[i].omnibox_input), string16::npos, string16(),
2139 GURL(), false, false, true, AutocompleteInput::ALL_MATCHES); 2141 GURL(), false, false, true, AutocompleteInput::ALL_MATCHES);
(...skipping 21 matching lines...) Expand all
2161 } else { 2163 } else {
2162 ASSERT_NE(sug_end, sug_it) << "Failed to find " << suggestion; 2164 ASSERT_NE(sug_end, sug_it) << "Failed to find " << suggestion;
2163 EXPECT_EQ(ASCIIToUTF16(suggestion), sug_it->suggestion()); 2165 EXPECT_EQ(ASCIIToUTF16(suggestion), sug_it->suggestion());
2164 ++sug_it; 2166 ++sug_it;
2165 } 2167 }
2166 } 2168 }
2167 EXPECT_EQ(sug_end, sug_it); 2169 EXPECT_EQ(sug_end, sug_it);
2168 EXPECT_EQ(nav_end, nav_it); 2170 EXPECT_EQ(nav_end, nav_it);
2169 } 2171 }
2170 } 2172 }
OLDNEW
« no previous file with comments | « chrome/browser/autocomplete/bookmark_provider_unittest.cc ('k') | chrome/browser/autocomplete/shortcuts_provider.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698