Commit 968d4291 authored by Greg Thompson's avatar Greg Thompson Committed by Commit Bot

Fix file leaks in sync_file_system tests.

open. This CL takes a few extra steps to ensure that pending tasks are
run during teardown so that open files can be closed.

R=pwnall@chromium.org


base: :ScopedTempDir cannot delete its contents while files are
Bug: 546640
Change-Id: Id1a6db0b2a50140c6b77b39c21c243cb60658a99
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1895338
Auto-Submit: Greg Thompson <grt@chromium.org>
Commit-Queue: Victor Costan <pwnall@chromium.org>
Reviewed-by: default avatarVictor Costan <pwnall@chromium.org>
Cr-Commit-Position: refs/heads/master@{#712020}
parent f54cb9fd
......@@ -72,8 +72,8 @@ TEST(DriveMetadataDBMigrationUtilTest, RollbackFromV4ToV3) {
const char kDemotedDirtyIDKeyPrefix[] = "DEMOTED_DIRTY: ";
// Set up environment.
std::unique_ptr<leveldb::DB> db;
base::ScopedTempDir base_dir;
std::unique_ptr<leveldb::DB> db;
ASSERT_TRUE(base_dir.CreateUniqueTempDir());
{
leveldb_env::Options options;
......
......@@ -17,6 +17,7 @@
#include "base/macros.h"
#include "base/run_loop.h"
#include "base/single_thread_task_runner.h"
#include "base/task/thread_pool/thread_pool_instance.h"
#include "base/task_runner_util.h"
#include "base/threading/thread_task_runner_handle.h"
#include "chrome/browser/sync_file_system/file_change.h"
......@@ -266,6 +267,7 @@ void CannedSyncableFileSystem::TearDown() {
// Make sure we give some more time to finish tasks on other threads.
EnsureLastTaskRuns(io_task_runner_.get());
EnsureLastTaskRuns(file_task_runner_.get());
base::ThreadPoolInstance::Get()->FlushForTesting();
}
FileSystemURL CannedSyncableFileSystem::URL(const std::string& path) const {
......
......@@ -70,6 +70,7 @@ class LocalFileChangeTrackerTest : public testing::Test {
// (CannedSyncableFileSystem::TearDown does not do this as there may be
// multiple syncable file systems registered for the name)
RevokeSyncableFileSystem();
content::RunAllTasksUntilIdle();
}
protected:
......@@ -113,8 +114,8 @@ class LocalFileChangeTrackerTest : public testing::Test {
change_tracker()->GetAllChangedURLs(urls);
}
content::BrowserTaskEnvironment task_environment_;
base::ScopedTempDir base_dir_;
content::BrowserTaskEnvironment task_environment_;
std::unique_ptr<leveldb::Env> in_memory_env_;
CannedSyncableFileSystem file_system_;
......
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