blob: 6929639c7e95e241cee7c808df3d3d5443551485 [file] [log] [blame]
ssid9f8022f2015-10-12 17:49:031// Copyright 2015 The Chromium Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5#include "sql/sql_memory_dump_provider.h"
6
Victor Costan49a903a2021-05-07 22:21:007#include "base/files/scoped_temp_dir.h"
8#include "base/trace_event/memory_dump_request_args.h"
ssid9f8022f2015-10-12 17:49:039#include "base/trace_event/process_memory_dump.h"
Victor Costan49a903a2021-05-07 22:21:0010#include "sql/database.h"
ssid9f8022f2015-10-12 17:49:0311#include "testing/gtest/include/gtest/gtest.h"
12
Victor Costan49a903a2021-05-07 22:21:0013namespace sql {
14
ssid9f8022f2015-10-12 17:49:0315namespace {
Victor Costan49a903a2021-05-07 22:21:0016
17class SQLMemoryDumpProviderTest : public testing::Test {
18 public:
19 ~SQLMemoryDumpProviderTest() override = default;
20
21 void SetUp() override {
22 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir());
23 ASSERT_TRUE(db_.Open(
24 temp_dir_.GetPath().AppendASCII("memory_dump_provider_test.sqlite")));
25
26 ASSERT_TRUE(db_.Execute("CREATE TABLE foo (a, b)"));
27 }
28
29 protected:
30 base::ScopedTempDir temp_dir_;
31 Database db_;
32};
ssid9f8022f2015-10-12 17:49:0333
34TEST_F(SQLMemoryDumpProviderTest, OnMemoryDump) {
ssid9f8022f2015-10-12 17:49:0335 base::trace_event::MemoryDumpArgs args = {
36 base::trace_event::MemoryDumpLevelOfDetail::DETAILED};
erikchenf62ea042018-05-25 21:30:5737 base::trace_event::ProcessMemoryDump pmd(args);
Victor Costan49a903a2021-05-07 22:21:0038 ASSERT_TRUE(SqlMemoryDumpProvider::GetInstance()->OnMemoryDump(args, &pmd));
ssid9f8022f2015-10-12 17:49:0339 ASSERT_TRUE(pmd.GetAllocatorDump("sqlite"));
40}
Victor Costan49a903a2021-05-07 22:21:0041
42} // namespace
43
44} // namespace sql