Commit 9f04af03 authored by Olivier Li's avatar Olivier Li Committed by Commit Bot

Set browser state builder dir to avoid file leaks in ios tests in...

Set browser state builder dir to avoid file leaks in ios tests in /ios/chrome/browser/ui/location_bar

This cl is generated with 'git cl split'

This CL was uploaded by git cl split.

R=stkhapugin@chromium.org

Bug: 546640
Change-Id: If47000191d0170327c9e74d270c7b6cb0506367a
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1991752Reviewed-by: default avatarStepan Khapugin <stkhapugin@chromium.org>
Commit-Queue: Stepan Khapugin <stkhapugin@chromium.org>
Auto-Submit: Oliver Li <olivierli@chromium.org>
Cr-Commit-Position: refs/heads/master@{#730144}
parent 5fc97393
......@@ -8,6 +8,7 @@
#include <string>
#include <vector>
#include "base/files/scoped_temp_dir.h"
#include "components/omnibox/browser/test_location_bar_model.h"
#include "components/variations/variations_http_header_provider.h"
#include "ios/chrome/browser/autocomplete/autocomplete_classifier_factory.h"
......@@ -70,6 +71,10 @@ class LocationBarCoordinatorTest : public PlatformTest {
PlatformTest::SetUp();
TestChromeBrowserState::Builder test_cbs_builder;
ASSERT_TRUE(state_dir_.CreateUniqueTempDir());
test_cbs_builder.SetPath(state_dir_.GetPath());
test_cbs_builder.AddTestingFactory(
ios::TemplateURLServiceFactory::GetInstance(),
ios::TemplateURLServiceFactory::GetDefaultFactory());
......@@ -119,6 +124,11 @@ class LocationBarCoordinatorTest : public PlatformTest {
PlatformTest::TearDown();
}
// A state directory that outlives |task_environment_| is needed because
// CreateHistoryService/CreateBookmarkModel use the directory to host
// databases. See https://crbug.com/546640 for more details.
base::ScopedTempDir state_dir_;
web::WebTaskEnvironment task_environment_;
LocationBarCoordinator* coordinator_;
std::unique_ptr<TestChromeBrowserState> browser_state_;
......
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