Commit f86fb936 authored by Antonio Gomes's avatar Antonio Gomes Committed by Commit Bot

Lazy initialize OneGoogleBarFetcherImpl in OneGoogleBarFetcherImplTest

This is a preparation CL to migrate
OneGoogleBarFetcherImpl::AuthenticatedURLFetcher from using URLFetcher
to SimpleURLLoader.

In practice, when creating an OneGoogleBarFetcherImpl instance, we need
to pass the |api_url_override| as a parameter. When running SimpleURLLoader and
EmbeddedTestServer (for unit testing), we can only set the proper
|api_url_override| value after EmbeddedTestServer is instantiated, which
will happen from ::SetUp (see [1]).

This CL prepares the ground for it. No functionality change.

[1] https://crrev.com/c/1031450/

BUG=773295

Change-Id: Iebd0d8dc0134a343e5187812982b6b5570f3ebe3
Reviewed-on: https://chromium-review.googlesource.com/1035862
Commit-Queue: Antonio Gomes <tonikitoo@igalia.com>
Reviewed-by: default avatarMatt Menke <mmenke@chromium.org>
Reviewed-by: default avatarMarc Treib <treib@chromium.org>
Cr-Commit-Position: refs/heads/master@{#555354}
parent e3e32d3d
......@@ -82,16 +82,22 @@ class OneGoogleBarFetcherImplTest : public testing::Test {
new net::TestURLRequestContextGetter(task_runner_)),
google_url_tracker_(std::make_unique<GoogleURLTrackerClientStub>(),
GoogleURLTracker::ALWAYS_DOT_COM_MODE),
one_google_bar_fetcher_(request_context_getter_.get(),
&google_url_tracker_,
kApplicationLocale,
api_url_override,
account_consistency_mirror_required) {}
api_url_override_(api_url_override),
account_consistency_mirror_required_(
account_consistency_mirror_required) {}
~OneGoogleBarFetcherImplTest() override {
static_cast<KeyedService&>(google_url_tracker_).Shutdown();
}
void SetUp() override {
testing::Test::SetUp();
one_google_bar_fetcher_ = std::make_unique<OneGoogleBarFetcherImpl>(
request_context_getter_.get(), &google_url_tracker_, kApplicationLocale,
api_url_override_, account_consistency_mirror_required_);
}
net::TestURLFetcher* GetRunningURLFetcher() {
// All created URLFetchers have ID 0 by default.
net::TestURLFetcher* url_fetcher = url_fetcher_factory_.GetFetcherByID(0);
......@@ -123,7 +129,7 @@ class OneGoogleBarFetcherImplTest : public testing::Test {
}
OneGoogleBarFetcherImpl* one_google_bar_fetcher() {
return &one_google_bar_fetcher_;
return one_google_bar_fetcher_.get();
}
private:
......@@ -140,7 +146,9 @@ class OneGoogleBarFetcherImplTest : public testing::Test {
scoped_refptr<net::TestURLRequestContextGetter> request_context_getter_;
GoogleURLTracker google_url_tracker_;
OneGoogleBarFetcherImpl one_google_bar_fetcher_;
base::Optional<std::string> api_url_override_;
bool account_consistency_mirror_required_;
std::unique_ptr<OneGoogleBarFetcherImpl> one_google_bar_fetcher_;
};
TEST_F(OneGoogleBarFetcherImplTest, RequestUrlContainsLanguage) {
......
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