Commit b535c2a0 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/browsing_data.

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=dullweber@chromium.org

Bug: 1106699
Change-Id: Idea748f489836737cfd60e5e8c4ad98662103680
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2315354
Auto-Submit: Mikel Astiz <mastiz@chromium.org>
Reviewed-by: default avatarChristian Dullweber <dullweber@chromium.org>
Commit-Queue: Christian Dullweber <dullweber@chromium.org>
Cr-Commit-Position: refs/heads/master@{#791769}
parent 2a257ef4
......@@ -22,12 +22,18 @@ class BookmarkCounterTest : public testing::Test {
public:
BookmarkCounterTest() {
run_loop_.reset(new base::RunLoop());
profile_.CreateBookmarkModel(true);
TestingProfile::Builder profile_builder;
profile_builder.AddTestingFactory(
BookmarkModelFactory::GetInstance(),
BookmarkModelFactory::GetDefaultFactory());
profile_ = profile_builder.Build();
model_ =
BookmarkModelFactory::GetInstance()->GetForBrowserContext(profile());
}
Profile* profile() { return &profile_; }
Profile* profile() { return profile_.get(); }
bookmarks::BookmarkModel* model() { return model_; }
......@@ -58,7 +64,7 @@ class BookmarkCounterTest : public testing::Test {
private:
content::BrowserTaskEnvironment task_environment_;
TestingProfile profile_;
std::unique_ptr<TestingProfile> profile_;
std::unique_ptr<base::RunLoop> run_loop_;
bookmarks::BookmarkModel* model_;
......
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