OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include <stddef.h> | 5 #include <stddef.h> |
6 #include <stdint.h> | 6 #include <stdint.h> |
7 | 7 |
8 #include "base/bind.h" | 8 #include "base/bind.h" |
9 #include "base/files/file_util.h" | 9 #include "base/files/file_util.h" |
10 #include "base/files/scoped_file.h" | 10 #include "base/files/scoped_file.h" |
11 #include "base/files/scoped_temp_dir.h" | 11 #include "base/files/scoped_temp_dir.h" |
12 #include "base/logging.h" | 12 #include "base/logging.h" |
13 #include "base/macros.h" | 13 #include "base/macros.h" |
14 #include "base/metrics/statistics_recorder.h" | 14 #include "base/metrics/statistics_recorder.h" |
15 #include "base/test/histogram_tester.h" | 15 #include "base/test/histogram_tester.h" |
16 #include "base/trace_event/process_memory_dump.h" | 16 #include "base/trace_event/process_memory_dump.h" |
17 #include "sql/connection.h" | 17 #include "sql/connection.h" |
| 18 #include "sql/connection_memory_dump_provider.h" |
18 #include "sql/correct_sql_test_base.h" | 19 #include "sql/correct_sql_test_base.h" |
19 #include "sql/meta_table.h" | 20 #include "sql/meta_table.h" |
20 #include "sql/statement.h" | 21 #include "sql/statement.h" |
21 #include "sql/test/error_callback_support.h" | 22 #include "sql/test/error_callback_support.h" |
22 #include "sql/test/scoped_error_ignorer.h" | 23 #include "sql/test/scoped_error_ignorer.h" |
23 #include "sql/test/test_helpers.h" | 24 #include "sql/test/test_helpers.h" |
24 #include "testing/gtest/include/gtest/gtest.h" | 25 #include "testing/gtest/include/gtest/gtest.h" |
25 #include "third_party/sqlite/sqlite3.h" | 26 #include "third_party/sqlite/sqlite3.h" |
26 | 27 |
27 namespace sql { | 28 namespace sql { |
(...skipping 1273 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1301 EXPECT_EQ(101, samples->sum()); | 1302 EXPECT_EQ(101, samples->sum()); |
1302 | 1303 |
1303 samples = tester.GetHistogramSamplesSinceCreation(kAutoCommitTime); | 1304 samples = tester.GetHistogramSamplesSinceCreation(kAutoCommitTime); |
1304 EXPECT_EQ(0, samples->sum()); | 1305 EXPECT_EQ(0, samples->sum()); |
1305 } | 1306 } |
1306 | 1307 |
1307 TEST_F(SQLConnectionTest, OnMemoryDump) { | 1308 TEST_F(SQLConnectionTest, OnMemoryDump) { |
1308 base::trace_event::ProcessMemoryDump pmd(nullptr); | 1309 base::trace_event::ProcessMemoryDump pmd(nullptr); |
1309 base::trace_event::MemoryDumpArgs args = { | 1310 base::trace_event::MemoryDumpArgs args = { |
1310 base::trace_event::MemoryDumpLevelOfDetail::DETAILED}; | 1311 base::trace_event::MemoryDumpLevelOfDetail::DETAILED}; |
1311 ASSERT_TRUE(db().OnMemoryDump(args, &pmd)); | 1312 ASSERT_TRUE(db().memory_dump_provider_->OnMemoryDump(args, &pmd)); |
1312 EXPECT_GE(pmd.allocator_dumps().size(), 1u); | 1313 EXPECT_GE(pmd.allocator_dumps().size(), 1u); |
1313 } | 1314 } |
1314 | 1315 |
1315 // Test that the functions to collect diagnostic data run to completion, without | 1316 // Test that the functions to collect diagnostic data run to completion, without |
1316 // worrying too much about what they generate (since that will change). | 1317 // worrying too much about what they generate (since that will change). |
1317 TEST_F(SQLConnectionTest, CollectDiagnosticInfo) { | 1318 TEST_F(SQLConnectionTest, CollectDiagnosticInfo) { |
1318 // NOTE(shess): Mojo doesn't support everything CollectCorruptionInfo() uses, | 1319 // NOTE(shess): Mojo doesn't support everything CollectCorruptionInfo() uses, |
1319 // but it's not really clear if adding support would be useful. | 1320 // but it's not really clear if adding support would be useful. |
1320 #if !defined(MOJO_APPTEST_IMPL) | 1321 #if !defined(MOJO_APPTEST_IMPL) |
1321 const std::string corruption_info = db().CollectCorruptionInfo(); | 1322 const std::string corruption_info = db().CollectCorruptionInfo(); |
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1466 // With no key, map everything and create the key. | 1467 // With no key, map everything and create the key. |
1467 // TODO(shess): This really should be "maps everything after validating it", | 1468 // TODO(shess): This really should be "maps everything after validating it", |
1468 // but that is more complicated to structure. | 1469 // but that is more complicated to structure. |
1469 ASSERT_GT(db().GetAppropriateMmapSize(), kMmapAlot); | 1470 ASSERT_GT(db().GetAppropriateMmapSize(), kMmapAlot); |
1470 ASSERT_TRUE(MetaTable::GetMmapStatus(&db(), &mmap_status)); | 1471 ASSERT_TRUE(MetaTable::GetMmapStatus(&db(), &mmap_status)); |
1471 ASSERT_EQ(MetaTable::kMmapSuccess, mmap_status); | 1472 ASSERT_EQ(MetaTable::kMmapSuccess, mmap_status); |
1472 } | 1473 } |
1473 #endif | 1474 #endif |
1474 | 1475 |
1475 } // namespace sql | 1476 } // namespace sql |
OLD | NEW |