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 "base/bind.h" | 5 #include "base/bind.h" |
6 #include "base/files/file_util.h" | 6 #include "base/files/file_util.h" |
7 #include "base/files/memory_mapped_file.h" | 7 #include "base/files/memory_mapped_file.h" |
8 #include "base/files/scoped_file.h" | 8 #include "base/files/scoped_file.h" |
9 #include "base/files/scoped_temp_dir.h" | 9 #include "base/files/scoped_temp_dir.h" |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
(...skipping 1369 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1380 #endif | 1380 #endif |
1381 | 1381 |
1382 TEST_F(SQLConnectionTest, OnMemoryDump) { | 1382 TEST_F(SQLConnectionTest, OnMemoryDump) { |
1383 base::trace_event::ProcessMemoryDump pmd(nullptr); | 1383 base::trace_event::ProcessMemoryDump pmd(nullptr); |
1384 base::trace_event::MemoryDumpArgs args = { | 1384 base::trace_event::MemoryDumpArgs args = { |
1385 base::trace_event::MemoryDumpLevelOfDetail::DETAILED}; | 1385 base::trace_event::MemoryDumpLevelOfDetail::DETAILED}; |
1386 ASSERT_TRUE(db().OnMemoryDump(args, &pmd)); | 1386 ASSERT_TRUE(db().OnMemoryDump(args, &pmd)); |
1387 EXPECT_GE(pmd.allocator_dumps().size(), 1u); | 1387 EXPECT_GE(pmd.allocator_dumps().size(), 1u); |
1388 } | 1388 } |
1389 | 1389 |
| 1390 TEST_F(SQLConnectionTest, ShouldUploadDump) { |
| 1391 base::FilePath breadcrumb_path( |
| 1392 db_path().DirName().Append(FILE_PATH_LITERAL("sqlite-diag"))); |
| 1393 |
| 1394 // No stale diagnostic store. |
| 1395 ASSERT_TRUE(!base::PathExists(breadcrumb_path)); |
| 1396 |
| 1397 // The histogram tag is required to enable diagnostic features. |
| 1398 EXPECT_FALSE(db().ShouldUploadDiagnosticDump()); |
| 1399 EXPECT_TRUE(!base::PathExists(breadcrumb_path)); |
| 1400 |
| 1401 db().Close(); |
| 1402 db().set_histogram_tag("Test"); |
| 1403 ASSERT_TRUE(db().Open(db_path())); |
| 1404 |
| 1405 // Should signal upload only once. |
| 1406 EXPECT_TRUE(db().ShouldUploadDiagnosticDump()); |
| 1407 EXPECT_TRUE(base::PathExists(breadcrumb_path)); |
| 1408 EXPECT_FALSE(db().ShouldUploadDiagnosticDump()); |
| 1409 |
| 1410 // Changing the histogram tag should allow new upload to succeed. |
| 1411 db().Close(); |
| 1412 db().set_histogram_tag("NewTest"); |
| 1413 ASSERT_TRUE(db().Open(db_path())); |
| 1414 EXPECT_TRUE(db().ShouldUploadDiagnosticDump()); |
| 1415 EXPECT_FALSE(db().ShouldUploadDiagnosticDump()); |
| 1416 |
| 1417 // Old tag is still prevented. |
| 1418 db().Close(); |
| 1419 db().set_histogram_tag("Test"); |
| 1420 ASSERT_TRUE(db().Open(db_path())); |
| 1421 EXPECT_FALSE(db().ShouldUploadDiagnosticDump()); |
| 1422 } |
| 1423 |
1390 } // namespace | 1424 } // namespace |
OLD | NEW |