Commit 7863e435 authored by Kevin Bailey's avatar Kevin Bailey Committed by Commit Bot

[omnibox] Clean up some APIs

Some methods appeared to have left off references or that are
needlessly making copies. This CL converts these methods, only in unit
tests, to pass by reference.

Change-Id: I85c5b943e4c2ae0324e9170a08e0428325c3da0c
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1863075Reviewed-by: default avatarTommy Li <tommycli@chromium.org>
Commit-Queue: Kevin Bailey <krb@chromium.org>
Cr-Commit-Position: refs/heads/master@{#706591}
parent dc0f2808
...@@ -95,7 +95,7 @@ class TestProvider : public AutocompleteProvider { ...@@ -95,7 +95,7 @@ class TestProvider : public AutocompleteProvider {
public: public:
TestProvider(int relevance, TestProvider(int relevance,
const base::string16& prefix, const base::string16& prefix,
const base::string16 match_keyword, const base::string16& match_keyword,
AutocompleteProviderClient* client) AutocompleteProviderClient* client)
: AutocompleteProvider(AutocompleteProvider::TYPE_SEARCH), : AutocompleteProvider(AutocompleteProvider::TYPE_SEARCH),
listener_(nullptr), listener_(nullptr),
...@@ -249,7 +249,7 @@ class AutocompleteProviderTest : public testing::Test { ...@@ -249,7 +249,7 @@ class AutocompleteProviderTest : public testing::Test {
}; };
// Registers a test TemplateURL under the given keyword. // Registers a test TemplateURL under the given keyword.
void RegisterTemplateURL(const base::string16 keyword, void RegisterTemplateURL(const base::string16& keyword,
const std::string& template_url, const std::string& template_url,
const std::string& image_url, const std::string& image_url,
const std::string& image_url_post_params); const std::string& image_url_post_params);
...@@ -335,7 +335,7 @@ AutocompleteProviderTest::~AutocompleteProviderTest() { ...@@ -335,7 +335,7 @@ AutocompleteProviderTest::~AutocompleteProviderTest() {
} }
void AutocompleteProviderTest::RegisterTemplateURL( void AutocompleteProviderTest::RegisterTemplateURL(
const base::string16 keyword, const base::string16& keyword,
const std::string& template_url, const std::string& template_url,
const std::string& image_url = "", const std::string& image_url = "",
const std::string& image_url_post_params = "") { const std::string& image_url_post_params = "") {
......
...@@ -146,21 +146,21 @@ class HistoryQuickProviderTest : public testing::Test { ...@@ -146,21 +146,21 @@ class HistoryQuickProviderTest : public testing::Test {
// Runs an autocomplete query on |text| and checks to see that the returned // Runs an autocomplete query on |text| and checks to see that the returned
// results' destination URLs match those provided. |expected_urls| does not // results' destination URLs match those provided. |expected_urls| does not
// need to be in sorted order. // need to be in sorted order.
void RunTest(const base::string16 text, void RunTest(const base::string16& text,
bool prevent_inline_autocomplete, bool prevent_inline_autocomplete,
std::vector<std::string> expected_urls, const std::vector<std::string>& expected_urls,
bool can_inline_top_result, bool can_inline_top_result,
base::string16 expected_fill_into_edit, const base::string16& expected_fill_into_edit,
base::string16 autocompletion); const base::string16& autocompletion);
// As above, simply with a cursor position specified. // As above, simply with a cursor position specified.
void RunTestWithCursor(const base::string16 text, void RunTestWithCursor(const base::string16& text,
const size_t cursor_position, const size_t cursor_position,
bool prevent_inline_autocomplete, bool prevent_inline_autocomplete,
std::vector<std::string> expected_urls, const std::vector<std::string>& expected_urls,
bool can_inline_top_result, bool can_inline_top_result,
base::string16 expected_fill_into_edit, const base::string16& expected_fill_into_edit,
base::string16 autocompletion); const base::string16& autocompletion);
// TODO(shess): From history_service.h in reference to history_backend: // TODO(shess): From history_service.h in reference to history_backend:
// > This class has most of the implementation and runs on the 'thread_'. // > This class has most of the implementation and runs on the 'thread_'.
...@@ -297,25 +297,25 @@ void HistoryQuickProviderTest::SetShouldContain::operator()( ...@@ -297,25 +297,25 @@ void HistoryQuickProviderTest::SetShouldContain::operator()(
} }
void HistoryQuickProviderTest::RunTest( void HistoryQuickProviderTest::RunTest(
const base::string16 text, const base::string16& text,
bool prevent_inline_autocomplete, bool prevent_inline_autocomplete,
std::vector<std::string> expected_urls, const std::vector<std::string>& expected_urls,
bool can_inline_top_result, bool can_inline_top_result,
base::string16 expected_fill_into_edit, const base::string16& expected_fill_into_edit,
base::string16 expected_autocompletion) { const base::string16& expected_autocompletion) {
RunTestWithCursor(text, base::string16::npos, prevent_inline_autocomplete, RunTestWithCursor(text, base::string16::npos, prevent_inline_autocomplete,
expected_urls, can_inline_top_result, expected_urls, can_inline_top_result,
expected_fill_into_edit, expected_autocompletion); expected_fill_into_edit, expected_autocompletion);
} }
void HistoryQuickProviderTest::RunTestWithCursor( void HistoryQuickProviderTest::RunTestWithCursor(
const base::string16 text, const base::string16& text,
const size_t cursor_position, const size_t cursor_position,
bool prevent_inline_autocomplete, bool prevent_inline_autocomplete,
std::vector<std::string> expected_urls, const std::vector<std::string>& expected_urls,
bool can_inline_top_result, bool can_inline_top_result,
base::string16 expected_fill_into_edit, const base::string16& expected_fill_into_edit,
base::string16 expected_autocompletion) { const base::string16& expected_autocompletion) {
SCOPED_TRACE(text); // Minimal hint to query being run. SCOPED_TRACE(text); // Minimal hint to query being run.
base::RunLoop().RunUntilIdle(); base::RunLoop().RunUntilIdle();
AutocompleteInput input(text, cursor_position, AutocompleteInput input(text, cursor_position,
......
...@@ -759,7 +759,7 @@ TEST_F(HistoryURLProviderTest, AutocompleteOnTrailingWhitespace) { ...@@ -759,7 +759,7 @@ TEST_F(HistoryURLProviderTest, AutocompleteOnTrailingWhitespace) {
auto TestAutocompletion = auto TestAutocompletion =
[this](std::string input_text, bool input_prevent_inline_autocomplete, [this](std::string input_text, bool input_prevent_inline_autocomplete,
std::vector<AutocompletionExpectation> expectations) { const std::vector<AutocompletionExpectation>& expectations) {
const std::string debug = base::StringPrintf( const std::string debug = base::StringPrintf(
"input text [%s], prevent inline [%d]", input_text.c_str(), "input text [%s], prevent inline [%d]", input_text.c_str(),
input_prevent_inline_autocomplete); input_prevent_inline_autocomplete);
......
...@@ -101,7 +101,7 @@ class LocalHistoryZeroSuggestProviderTest ...@@ -101,7 +101,7 @@ class LocalHistoryZeroSuggestProviderTest
std::string zero_suggest_variant_value); std::string zero_suggest_variant_value);
// Fills the URLDatabase with search URLs using the provided information. // Fills the URLDatabase with search URLs using the provided information.
void LoadURLs(std::vector<TestURLData> url_data_list); void LoadURLs(const std::vector<TestURLData>& url_data_list);
// Waits for history::HistoryService's async operations. // Waits for history::HistoryService's async operations.
void WaitForHistoryService(); void WaitForHistoryService();
...@@ -112,7 +112,7 @@ class LocalHistoryZeroSuggestProviderTest ...@@ -112,7 +112,7 @@ class LocalHistoryZeroSuggestProviderTest
PageClassification page_classification); PageClassification page_classification);
// Verifies that provider matches are as expected. // Verifies that provider matches are as expected.
void ExpectMatches(std::vector<TestMatchData> match_data_list); void ExpectMatches(const std::vector<TestMatchData>& match_data_list);
const TemplateURL* default_search_provider() { const TemplateURL* default_search_provider() {
return client_->GetTemplateURLService()->GetDefaultSearchProvider(); return client_->GetTemplateURLService()->GetDefaultSearchProvider();
...@@ -141,7 +141,7 @@ void LocalHistoryZeroSuggestProviderTest::SetZeroSuggestVariant( ...@@ -141,7 +141,7 @@ void LocalHistoryZeroSuggestProviderTest::SetZeroSuggestVariant(
} }
void LocalHistoryZeroSuggestProviderTest::LoadURLs( void LocalHistoryZeroSuggestProviderTest::LoadURLs(
std::vector<TestURLData> url_data_list) { const std::vector<TestURLData>& url_data_list) {
const Time now = Time::Now(); const Time now = Time::Now();
for (const auto& entry : url_data_list) { for (const auto& entry : url_data_list) {
TemplateURLRef::SearchTermsArgs search_terms_args( TemplateURLRef::SearchTermsArgs search_terms_args(
...@@ -194,7 +194,7 @@ void LocalHistoryZeroSuggestProviderTest::OnProviderUpdate( ...@@ -194,7 +194,7 @@ void LocalHistoryZeroSuggestProviderTest::OnProviderUpdate(
} }
void LocalHistoryZeroSuggestProviderTest::ExpectMatches( void LocalHistoryZeroSuggestProviderTest::ExpectMatches(
std::vector<TestMatchData> match_data_list) { const std::vector<TestMatchData>& match_data_list) {
ASSERT_EQ(match_data_list.size(), provider_->matches().size()); ASSERT_EQ(match_data_list.size(), provider_->matches().size());
size_t index = 0; size_t index = 0;
for (const auto& expected : match_data_list) { for (const auto& expected : match_data_list) {
......
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