| Index: sql/connection_unittest.cc
|
| diff --git a/sql/connection_unittest.cc b/sql/connection_unittest.cc
|
| index d933a6dab6e6d7cb9a3aca7c88a5d6e26f17daba..9cd7094783c5675ad267f7ebb7a8b3348b2d7bbc 100644
|
| --- a/sql/connection_unittest.cc
|
| +++ b/sql/connection_unittest.cc
|
| @@ -1387,4 +1387,38 @@ TEST_F(SQLConnectionTest, OnMemoryDump) {
|
| EXPECT_GE(pmd.allocator_dumps().size(), 1u);
|
| }
|
|
|
| +TEST_F(SQLConnectionTest, ShouldUploadDump) {
|
| + base::FilePath breadcrumb_path(
|
| + db_path().DirName().Append(FILE_PATH_LITERAL("sqlite-diag")));
|
| +
|
| + // No stale diagnostic store.
|
| + ASSERT_TRUE(!base::PathExists(breadcrumb_path));
|
| +
|
| + // The histogram tag is required to enable diagnostic features.
|
| + EXPECT_FALSE(db().ShouldUploadDiagnosticDump());
|
| + EXPECT_TRUE(!base::PathExists(breadcrumb_path));
|
| +
|
| + db().Close();
|
| + db().set_histogram_tag("Test");
|
| + ASSERT_TRUE(db().Open(db_path()));
|
| +
|
| + // Should signal upload only once.
|
| + EXPECT_TRUE(db().ShouldUploadDiagnosticDump());
|
| + EXPECT_TRUE(base::PathExists(breadcrumb_path));
|
| + EXPECT_FALSE(db().ShouldUploadDiagnosticDump());
|
| +
|
| + // Changing the histogram tag should allow new upload to succeed.
|
| + db().Close();
|
| + db().set_histogram_tag("NewTest");
|
| + ASSERT_TRUE(db().Open(db_path()));
|
| + EXPECT_TRUE(db().ShouldUploadDiagnosticDump());
|
| + EXPECT_FALSE(db().ShouldUploadDiagnosticDump());
|
| +
|
| + // Old tag is still prevented.
|
| + db().Close();
|
| + db().set_histogram_tag("Test");
|
| + ASSERT_TRUE(db().Open(db_path()));
|
| + EXPECT_FALSE(db().ShouldUploadDiagnosticDump());
|
| +}
|
| +
|
| } // namespace
|
|
|