Chromium Code Reviews| Index: components/leveldb_proto/proto_database_impl_unittest.cc |
| diff --git a/components/leveldb_proto/proto_database_impl_unittest.cc b/components/leveldb_proto/proto_database_impl_unittest.cc |
| index 648b2e20509719c609ce6e2d792d3ddf6c6cd952..de9144620ff2892fb18f5c4776709b582ddaaad3 100644 |
| --- a/components/leveldb_proto/proto_database_impl_unittest.cc |
| +++ b/components/leveldb_proto/proto_database_impl_unittest.cc |
| @@ -17,6 +17,7 @@ |
| #include "base/memory/ptr_util.h" |
| #include "base/run_loop.h" |
| #include "base/threading/thread.h" |
| +#include "base/trace_event/process_memory_dump.h" |
| #include "components/leveldb_proto/leveldb_database.h" |
| #include "components/leveldb_proto/testing/proto/test.pb.h" |
| #include "testing/gmock/include/gmock/gmock.h" |
| @@ -487,6 +488,8 @@ TEST(ProtoDatabaseImplThreadingTest, TestDBDestroy) { |
| // entries. If |close_after_save| is true, the database will be closed after |
| // saving and then re-opened to ensure that the data is properly persisted. |
| void TestLevelDBSaveAndLoad(bool close_after_save) { |
| + base::MessageLoop main_loop; |
| + |
| ScopedTempDir temp_dir; |
| ASSERT_TRUE(temp_dir.CreateUniqueTempDir()); |
| @@ -549,6 +552,8 @@ TEST(ProtoDatabaseImplLevelDBTest, TestDBInitFail) { |
| } |
| TEST(ProtoDatabaseImplLevelDBTest, TestMemoryDatabase) { |
| + base::MessageLoop main_loop; |
| + |
| std::unique_ptr<LevelDB> db(new LevelDB(kTestLevelDBClientName)); |
| std::vector<std::string> load_entries; |
| @@ -569,4 +574,27 @@ TEST(ProtoDatabaseImplLevelDBTest, TestMemoryDatabase) { |
| EXPECT_EQ(1u, second_load_entries.size()); |
| } |
| +TEST(ProtoDatabaseImplLevelDBTest, TestOnMemoryDump) { |
|
nyquist
2016/09/23 15:57:32
TestOnMemoryDumpEmitsData
ssid
2016/09/26 18:13:37
Done.
|
| + base::MessageLoop main_loop; |
| + std::unique_ptr<LevelDB> db(new LevelDB(kTestLevelDBClientName)); |
| + std::vector<std::string> load_entries; |
| + ASSERT_TRUE(db->Init(base::FilePath())); |
| + KeyValueVector save_entries(1, std::make_pair("foo", "bar")); |
| + KeyVector remove_keys; |
| + ASSERT_TRUE(db->Save(save_entries, remove_keys)); |
| + |
| + base::trace_event::MemoryDumpArgs dump_args = { |
| + base::trace_event::MemoryDumpLevelOfDetail::DETAILED}; |
| + std::unique_ptr<base::trace_event::ProcessMemoryDump> process_memory_dump( |
| + new base::trace_event::ProcessMemoryDump(nullptr, dump_args)); |
| + db->OnMemoryDump(dump_args, process_memory_dump.get()); |
| + |
| + const auto& allocator_dumps = process_memory_dump->allocator_dumps(); |
| + EXPECT_EQ(2u, allocator_dumps.size()); |
| + for (const auto& dump : allocator_dumps) { |
| + ASSERT_TRUE(dump.first.find("leveldb/leveldb_proto/") == 0 || |
| + dump.first.find("malloc/allocated_objects/") == 0); |
| + } |
| +} |
| + |
| } // namespace leveldb_proto |