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(); |