Commit ba7b02ff authored by Marc Treib's avatar Marc Treib Committed by Commit Bot

OneGoogleBarFetcherImplTest: Shutdown() the GoogleURLTracker before destruction

GoogleURLTracker registers itself as a NetworkChangeObserver at the
NetworkChangeNotifier singleton, and unregisters itself again in Shutdown().
In non-test code, GoogleURLTracker is a KeyedService and so its Shutdown()
gets called at the proper time automatically. But in unit tests that
instantiate it directly, we have to explicitly call Shutdown(),
otherwise we leave behind a dangling pointer.

Bug: 823858
Change-Id: Idc215823ad81c983c8693c04688eccce40f9f26c
Reviewed-on: https://chromium-review.googlesource.com/973603Reviewed-by: default avatarIlya Sherman <isherman@chromium.org>
Commit-Queue: Marc Treib <treib@chromium.org>
Cr-Commit-Position: refs/heads/master@{#545017}
parent bd89eb6f
......@@ -89,6 +89,10 @@ class OneGoogleBarFetcherImplTest : public testing::Test {
api_url_override,
account_consistency_mirror_required) {}
~OneGoogleBarFetcherImplTest() override {
static_cast<KeyedService&>(google_url_tracker_).Shutdown();
}
net::TestURLFetcher* GetRunningURLFetcher() {
// All created URLFetchers have ID 0 by default.
net::TestURLFetcher* url_fetcher = url_fetcher_factory_.GetFetcherByID(0);
......
......@@ -51,6 +51,8 @@ class GoogleURLTracker
static const char kDefaultGoogleHomepage[];
// Only the GoogleURLTrackerFactory and tests should call this.
// Note: In UNIT_TEST_MODE, you *must* manually call Shutdown() before this
// instance gets destroyed!
GoogleURLTracker(std::unique_ptr<GoogleURLTrackerClient> client, Mode mode);
~GoogleURLTracker() override;
......
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