Skip to content
Snippets Groups Projects
Commit bdca9beb authored by sky@chromium.org's avatar sky@chromium.org
Browse files

Makes search provider honor inline autocomplete.

BUG=63151
TEST=see bug

Review URL: http://codereview.chromium.org/4978002

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@66186 0039d316-1c4b-4281-b951-d872f2087c98
parent b0a9bead
No related branches found
No related tags found
No related merge requests found
......@@ -574,7 +574,8 @@ int SearchProvider::CalculateRelevanceForHistory(const Time& time,
double elapsed_time = std::max((Time::Now() - time).InSecondsF(), 0.);
if (providers_.is_primary_provider(is_keyword) &&
input_.type() != AutocompleteInput::URL) {
input_.type() != AutocompleteInput::URL &&
!input_.prevent_inline_autocomplete()) {
// Searches with the past two days get a different curve.
const double autocomplete_time= 2 * 24 * 60 * 60;
if (elapsed_time < autocomplete_time) {
......
......@@ -58,7 +58,8 @@ class SearchProviderTest : public testing::Test,
void RunTillProviderDone();
// Invokes Start on provider_, then runs all pending tasks.
void QueryForInput(const string16& text);
void QueryForInput(const string16& text,
bool prevent_inline_autocomplete);
// See description above class for details of these fields.
TemplateURL* default_t_url_;
......@@ -162,10 +163,11 @@ void SearchProviderTest::RunTillProviderDone() {
#endif
}
void SearchProviderTest::QueryForInput(const string16& text) {
void SearchProviderTest::QueryForInput(const string16& text,
bool prevent_inline_autocomplete) {
// Start a query.
AutocompleteInput input(UTF16ToWide(text), std::wstring(),
false, false, true, false);
prevent_inline_autocomplete, false, true, false);
provider_->Start(input, false);
// RunAllPending so that the task scheduled by SearchProvider to create the
......@@ -198,7 +200,7 @@ AutocompleteMatch SearchProviderTest::FindMatchWithDestination(
// created for the default provider suggest results.
TEST_F(SearchProviderTest, QueryDefaultProvider) {
string16 term = term1_.substr(0, term1_.size() - 1);
QueryForInput(term);
QueryForInput(term, false);
// Make sure the default providers suggest service was queried.
TestURLFetcher* fetcher = test_factory_.GetFetcherByID(
......@@ -226,12 +228,21 @@ TEST_F(SearchProviderTest, QueryDefaultProvider) {
ASSERT_TRUE(!match.destination_url.is_empty());
}
TEST_F(SearchProviderTest, HonorPreventInlineAutocomplete) {
string16 term = term1_.substr(0, term1_.size() - 1);
QueryForInput(term, true);
ASSERT_FALSE(provider_->matches().empty());
ASSERT_EQ(AutocompleteMatch::SEARCH_WHAT_YOU_TYPED,
provider_->matches()[0].type);
}
// Issues a query that matches the registered keyword and makes sure history
// is queried as well as URLFetchers getting created.
TEST_F(SearchProviderTest, QueryKeywordProvider) {
string16 term = keyword_term_.substr(0, keyword_term_.size() - 1);
QueryForInput(WideToUTF16(keyword_t_url_->keyword()) +
UTF8ToUTF16(" ") + term);
UTF8ToUTF16(" ") + term, false);
// Make sure the default providers suggest service was queried.
TestURLFetcher* default_fetcher = test_factory_.GetFetcherByID(
......@@ -295,7 +306,7 @@ TEST_F(SearchProviderTest, DontSendPrivateDataToSuggest) {
};
for (size_t i = 0; i < arraysize(inputs); ++i) {
QueryForInput(ASCIIToUTF16(inputs[i]));
QueryForInput(ASCIIToUTF16(inputs[i]), false);
// Make sure the default providers suggest service was not queried.
ASSERT_TRUE(test_factory_.GetFetcherByID(
SearchProvider::kDefaultProviderURLFetcherID) == NULL);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment