Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1299)

Unified Diff: components/leveldb_proto/proto_database_impl_unittest.cc

Issue 2340983002: [tracing] Memory dump provider for leveldb_proto (Closed)
Patch Set: Fix test name and IOS build. Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « components/leveldb_proto/leveldb_database.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 c3dc76b4ce9ef6d245ee62841f81f68ca6fcab16..035707aa4697e401bc0d198ae77128a0b93253d4 100644
--- a/components/leveldb_proto/proto_database_impl_unittest.cc
+++ b/components/leveldb_proto/proto_database_impl_unittest.cc
@@ -17,6 +17,8 @@
#include "base/memory/ptr_util.h"
#include "base/run_loop.h"
#include "base/threading/thread.h"
+#include "base/trace_event/memory_dump_manager.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 +489,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 +553,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 +575,31 @@ TEST(ProtoDatabaseImplLevelDBTest, TestMemoryDatabase) {
EXPECT_EQ(1u, second_load_entries.size());
}
+TEST(ProtoDatabaseImplLevelDBTest, TestOnMemoryDumpEmitsData) {
+ 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();
+ const char* system_allocator_pool_name =
+ base::trace_event::MemoryDumpManager::GetInstance()
+ ->system_allocator_pool_name();
+ size_t expected_dump_count = system_allocator_pool_name ? 2 : 1;
+ EXPECT_EQ(expected_dump_count, allocator_dumps.size());
+ for (const auto& dump : allocator_dumps) {
+ ASSERT_TRUE(dump.first.find("leveldb/leveldb_proto/") == 0 ||
+ dump.first.find(system_allocator_pool_name) == 0);
+ }
+}
+
} // namespace leveldb_proto
« no previous file with comments | « components/leveldb_proto/leveldb_database.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698