Commit 48e950d1 authored by Maciej Pawlowski's avatar Maciej Pawlowski Committed by Commit Bot

Fix another memory leak in StrikeDatabaseIntegratorTestStrikeDatabaseTest

The destructor of UniqueProtoDatabase posts deletion of the underlying
LevelDB to a task runner via DeleteSoon. In order to not leak it, we
need to run the message loop at the end of the test.

Bug: 968053
Change-Id: I1ab5289fc7c63713fcce958a3191297f3b8b8cf1
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1634875Reviewed-by: default avatarJared Saul <jsaul@google.com>
Commit-Queue: Maciej Pawlowski <mpawlowski@opera.com>
Cr-Commit-Position: refs/heads/master@{#664673}
parent cd0990b6
...@@ -38,23 +38,23 @@ class StrikeDatabaseIntegratorTestStrikeDatabaseTest : public ::testing::Test { ...@@ -38,23 +38,23 @@ class StrikeDatabaseIntegratorTestStrikeDatabaseTest : public ::testing::Test {
strike_database_service_.get()); strike_database_service_.get());
} }
void TearDown() override {
// The destruction of |strike_database_service_|'s components is posted
// to a task runner, requires running the loop to complete.
strike_database_.reset();
strike_database_service_.reset();
scoped_task_environment_.RunUntilIdle();
}
protected: protected:
base::HistogramTester* GetHistogramTester() { return &histogram_tester_; } base::HistogramTester* GetHistogramTester() { return &histogram_tester_; }
base::test::ScopedTaskEnvironment scoped_task_environment_; base::test::ScopedTaskEnvironment scoped_task_environment_;
std::unique_ptr<leveldb_proto::ProtoDatabaseProvider> db_provider_;
base::ScopedTempDir temp_dir_; base::ScopedTempDir temp_dir_;
std::unique_ptr<leveldb_proto::ProtoDatabaseProvider> db_provider_;
std::unique_ptr<StrikeDatabase> strike_database_service_; std::unique_ptr<StrikeDatabase> strike_database_service_;
std::unique_ptr<StrikeDatabaseIntegratorTestStrikeDatabase> strike_database_; std::unique_ptr<StrikeDatabaseIntegratorTestStrikeDatabase> strike_database_;
private: private:
leveldb_proto::ProtoDatabaseProvider* GetDBProvider() {
EXPECT_TRUE(temp_dir_.CreateUniqueTempDir());
db_provider_ = std::make_unique<leveldb_proto::ProtoDatabaseProvider>(
temp_dir_.GetPath());
return db_provider_.get();
}
base::HistogramTester histogram_tester_; base::HistogramTester histogram_tester_;
}; };
......
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