Commit 6ec89db7 authored by Mikel Astiz's avatar Mikel Astiz Committed by Commit Bot

Avoid late keyed services with TestingProfile

This patch migrates tests away from deprecated APIs and adopts
TestingProfile::Builder for tests in
/chrome/browser/ui/webui/history.

Rationale: creating or overriding keyed services after the profile has
been created is problematic and known to cause hard-to-debug test
flakiness, because it bypasses BrowserContextDependencyManager and often
leading to use-after-free.

This CL was uploaded by git cl split.

R=calamity@chromium.org

Bug: 1106699
Change-Id: Ic96df4cdd31606f2d8b0397a67304ffa0d6d0ac7
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2316578Reviewed-by: default avatarcalamity <calamity@chromium.org>
Commit-Queue: Mikel Astiz <mastiz@chromium.org>
Cr-Commit-Position: refs/heads/master@{#791532}
parent 2e4bec79
......@@ -17,6 +17,7 @@
#include "base/test/simple_test_clock.h"
#include "base/values.h"
#include "build/build_config.h"
#include "chrome/browser/bookmarks/bookmark_model_factory.h"
#include "chrome/browser/history/web_history_service_factory.h"
#include "chrome/browser/sync/profile_sync_service_factory.h"
#include "chrome/test/base/chrome_render_view_host_test_harness.h"
......@@ -83,7 +84,6 @@ class BrowsingHistoryHandlerTest : public ChromeRenderViewHostTestHarness {
public:
void SetUp() override {
ChromeRenderViewHostTestHarness::SetUp();
profile()->CreateBookmarkModel(false);
sync_service_ = static_cast<syncer::TestSyncService*>(
ProfileSyncServiceFactory::GetForProfile(profile()));
......@@ -106,6 +106,8 @@ class BrowsingHistoryHandlerTest : public ChromeRenderViewHostTestHarness {
base::BindRepeating(&BuildTestSyncService)},
{WebHistoryServiceFactory::GetInstance(),
base::BindRepeating(&BuildFakeWebHistoryService)},
{BookmarkModelFactory::GetInstance(),
BookmarkModelFactory::GetDefaultFactory()},
};
}
......
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