Commit a132281a 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/activity_services

This cl is generated with 'git cl split'

This CL was uploaded by git cl split.

R=pkl@chromium.org

Bug: 546640
Change-Id: I4569f1f4ba2fb24928c14b8640cf97123bff8129
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1991755Reviewed-by: default avatarPeter Lee <pkl@chromium.org>
Commit-Queue: Peter Lee <pkl@chromium.org>
Auto-Submit: Oliver Li <olivierli@chromium.org>
Cr-Commit-Position: refs/heads/master@{#730186}
parent 2ccb617e
...@@ -6,6 +6,7 @@ ...@@ -6,6 +6,7 @@
#import <MobileCoreServices/MobileCoreServices.h> #import <MobileCoreServices/MobileCoreServices.h>
#include "base/files/scoped_temp_dir.h"
#include "base/strings/sys_string_conversions.h" #include "base/strings/sys_string_conversions.h"
#import "base/test/ios/wait_util.h" #import "base/test/ios/wait_util.h"
#include "base/test/scoped_feature_list.h" #include "base/test/scoped_feature_list.h"
...@@ -181,6 +182,10 @@ class ActivityServiceControllerTest : public PlatformTest { ...@@ -181,6 +182,10 @@ class ActivityServiceControllerTest : public PlatformTest {
void SetUp() override { void SetUp() override {
PlatformTest::SetUp(); PlatformTest::SetUp();
TestChromeBrowserState::Builder test_cbs_builder; TestChromeBrowserState::Builder test_cbs_builder;
ASSERT_TRUE(state_dir_.CreateUniqueTempDir());
test_cbs_builder.SetPath(state_dir_.GetPath());
chrome_browser_state_ = test_cbs_builder.Build(); chrome_browser_state_ = test_cbs_builder.Build();
chrome_browser_state_->CreateBookmarkModel(false); chrome_browser_state_->CreateBookmarkModel(false);
bookmark_model_ = ios::BookmarkModelFactory::GetForBrowserState( bookmark_model_ = ios::BookmarkModelFactory::GetForBrowserState(
...@@ -315,6 +320,11 @@ class ActivityServiceControllerTest : public PlatformTest { ...@@ -315,6 +320,11 @@ class ActivityServiceControllerTest : public PlatformTest {
EXPECT_FALSE(provider.fakePasswordFormFiller.methodCalled); EXPECT_FALSE(provider.fakePasswordFormFiller.methodCalled);
} }
// 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_; web::WebTaskEnvironment task_environment_;
UIViewController* parentController_; UIViewController* parentController_;
ShareToData* shareData_; ShareToData* shareData_;
......
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