Commit 24dbf230 authored by mpearson@chromium.org's avatar mpearson@chromium.org

Omnibox: Speed Up SearchProviderTest

By reducing the time waited between sending a Autocomplete request and
SearchProvider sending the request to mocked suggest server.

The speeds up the wall time of running SearchProvider test from 30 seconds to 20 seconds.

BUG=


Review URL: https://chromiumcodereview.appspot.com/13461012

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@192584 0039d316-1c4b-4281-b951-d872f2087c98
parent 6db80f97
...@@ -121,6 +121,8 @@ const TemplateURL* SearchProvider::Providers::GetKeywordProviderURL() const { ...@@ -121,6 +121,8 @@ const TemplateURL* SearchProvider::Providers::GetKeywordProviderURL() const {
const int SearchProvider::kDefaultProviderURLFetcherID = 1; const int SearchProvider::kDefaultProviderURLFetcherID = 1;
// static // static
const int SearchProvider::kKeywordProviderURLFetcherID = 2; const int SearchProvider::kKeywordProviderURLFetcherID = 2;
// static
int SearchProvider::kMinimumTimeBetweenSuggestQueriesMs = 100;
SearchProvider::SearchProvider(AutocompleteProviderListener* listener, SearchProvider::SearchProvider(AutocompleteProviderListener* listener,
Profile* profile) Profile* profile)
...@@ -562,9 +564,8 @@ void SearchProvider::StartOrStopSuggestQuery(bool minimal_changes) { ...@@ -562,9 +564,8 @@ void SearchProvider::StartOrStopSuggestQuery(bool minimal_changes) {
if (input_.matches_requested() != AutocompleteInput::ALL_MATCHES) if (input_.matches_requested() != AutocompleteInput::ALL_MATCHES)
return; return;
// To avoid flooding the suggest server, don't send a query until at least 100 // To avoid flooding the suggest server, don't send a query until at
// ms since the last query. // least 100 ms since the last query.
const int kMinimumTimeBetweenSuggestQueriesMs = 100;
base::TimeTicks next_suggest_time(time_suggest_request_sent_ + base::TimeTicks next_suggest_time(time_suggest_request_sent_ +
TimeDelta::FromMilliseconds(kMinimumTimeBetweenSuggestQueriesMs)); TimeDelta::FromMilliseconds(kMinimumTimeBetweenSuggestQueriesMs));
base::TimeTicks now(base::TimeTicks::Now()); base::TimeTicks now(base::TimeTicks::Now());
......
...@@ -29,6 +29,7 @@ ...@@ -29,6 +29,7 @@
#include "net/url_request/url_fetcher_delegate.h" #include "net/url_request/url_fetcher_delegate.h"
class Profile; class Profile;
class SearchProviderTest;
class TemplateURLService; class TemplateURLService;
namespace base { namespace base {
...@@ -52,6 +53,12 @@ class URLFetcher; ...@@ -52,6 +53,12 @@ class URLFetcher;
class SearchProvider : public AutocompleteProvider, class SearchProvider : public AutocompleteProvider,
public net::URLFetcherDelegate { public net::URLFetcherDelegate {
public: public:
// ID used in creating URLFetcher for default provider's suggest results.
static const int kDefaultProviderURLFetcherID;
// ID used in creating URLFetcher for keyword provider's suggest results.
static const int kKeywordProviderURLFetcherID;
SearchProvider(AutocompleteProviderListener* listener, Profile* profile); SearchProvider(AutocompleteProviderListener* listener, Profile* profile);
// Marks the instant query as done. If |input_text| is non-empty this changes // Marks the instant query as done. If |input_text| is non-empty this changes
...@@ -84,19 +91,18 @@ class SearchProvider : public AutocompleteProvider, ...@@ -84,19 +91,18 @@ class SearchProvider : public AutocompleteProvider,
return field_trial_triggered_in_session_; return field_trial_triggered_in_session_;
} }
// ID used in creating URLFetcher for default provider's suggest results.
static const int kDefaultProviderURLFetcherID;
// ID used in creating URLFetcher for keyword provider's suggest results.
static const int kKeywordProviderURLFetcherID;
private: private:
friend class SearchProviderTest;
FRIEND_TEST_ALL_PREFIXES(SearchProviderTest, SuggestRelevanceExperiment); FRIEND_TEST_ALL_PREFIXES(SearchProviderTest, SuggestRelevanceExperiment);
FRIEND_TEST_ALL_PREFIXES(SearchProviderTest, NavigationInline); FRIEND_TEST_ALL_PREFIXES(SearchProviderTest, NavigationInline);
FRIEND_TEST_ALL_PREFIXES(SearchProviderTest, NavigationInlineSchemeSubstring); FRIEND_TEST_ALL_PREFIXES(SearchProviderTest, NavigationInlineSchemeSubstring);
FRIEND_TEST_ALL_PREFIXES(SearchProviderTest, NavigationInlineDomainClassify); FRIEND_TEST_ALL_PREFIXES(SearchProviderTest, NavigationInlineDomainClassify);
FRIEND_TEST_ALL_PREFIXES(AutocompleteProviderTest, GetDestinationURL); FRIEND_TEST_ALL_PREFIXES(AutocompleteProviderTest, GetDestinationURL);
// The amount of time to wait before sending a new suggest request after
// the previous one.
static int kMinimumTimeBetweenSuggestQueriesMs;
virtual ~SearchProvider(); virtual ~SearchProvider();
// Manages the providers (TemplateURLs) used by SearchProvider. Two providers // Manages the providers (TemplateURLs) used by SearchProvider. Two providers
......
...@@ -224,6 +224,7 @@ void SearchProviderTest::SetUp() { ...@@ -224,6 +224,7 @@ void SearchProviderTest::SetUp() {
profile_.BlockUntilHistoryProcessesPendingRequests(); profile_.BlockUntilHistoryProcessesPendingRequests();
provider_ = new SearchProvider(this, &profile_); provider_ = new SearchProvider(this, &profile_);
provider_->kMinimumTimeBetweenSuggestQueriesMs = 0;
} }
void SearchProviderTest::OnProviderUpdate(bool updated_matches) { void SearchProviderTest::OnProviderUpdate(bool updated_matches) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment