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

Unified Diff: metrics_library_test.cc

Issue 6211001: metrics: Send ability to notify chrome of system crashes (Closed) Base URL: ssh://git@gitrw.chromium.org:9222/metrics.git@master
Patch Set: respond to review Created 9 years, 11 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
« no previous file with comments | « metrics_library.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: metrics_library_test.cc
diff --git a/metrics_library_test.cc b/metrics_library_test.cc
index 3e49f6925035ef3a7dcdd6af868e2f10394a2e7c..762be4a79f3959c7221b0d737d34a55812d6fd58 100644
--- a/metrics_library_test.cc
+++ b/metrics_library_test.cc
@@ -231,6 +231,23 @@ TEST_F(MetricsLibraryTest, SendUserActionToUMANotEnabled) {
EXPECT_FALSE(file_util::PathExists(kTestUMAEventsFile));
}
+TEST_F(MetricsLibraryTest, SendCrashToUMAEnabled) {
+ EXPECT_TRUE(lib_.SendCrashToUMA("kernel"));
+ char exp[100];
+ int len = sprintf(exp, "%c%c%c%ccrash%ckernel",
+ 0, 0, 0, 0, 0) + 1;
+ exp[0] = len;
+ char buf[100];
+ EXPECT_EQ(len, file_util::ReadFile(kTestUMAEventsFile, buf, 100));
+ EXPECT_EQ(0, memcmp(exp, buf, len));
+}
+
+TEST_F(MetricsLibraryTest, SendCrashToUMANotEnabled) {
+ SetMetricsEnabled(false);
+ EXPECT_TRUE(lib_.SendCrashToUMA("kernel"));
+ EXPECT_FALSE(file_util::PathExists(kTestUMAEventsFile));
+}
+
class CMetricsLibraryTest : public testing::Test {
protected:
virtual void SetUp() {
@@ -296,6 +313,17 @@ TEST_F(CMetricsLibraryTest, SendUserActionToUMA) {
EXPECT_EQ(0, memcmp(exp, buf, kLen));
}
+TEST_F(CMetricsLibraryTest, SendCrashToUMA) {
+ char buf[100];
+ char exp[100];
+ int len = sprintf(exp, "%c%c%c%ccrash%cuser", 0, 0, 0, 0, 0) + 1;
+ exp[0] = len;
+ EXPECT_TRUE(CMetricsLibrarySendCrashToUMA(lib_, "user"));
+ EXPECT_EQ(len, file_util::ReadFile(kTestUMAEventsFile, buf, 100));
+
+ EXPECT_EQ(0, memcmp(exp, buf, len));
+}
+
int main(int argc, char** argv) {
testing::InitGoogleTest(&argc, argv);
return RUN_ALL_TESTS();
« no previous file with comments | « metrics_library.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698