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

Unified Diff: sql/connection_unittest.cc

Issue 1393393007: [sql] Track uploads of diagnostic data to prevent duplication. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: missing FILE_PATH_LITERAL Created 5 years, 2 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
« sql/connection.cc ('K') | « sql/connection.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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
« sql/connection.cc ('K') | « sql/connection.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698