Index: metrics_library_test.cc |
diff --git a/metrics_library_test.cc b/metrics_library_test.cc |
index 0cd695b1d0e411f3cc391239903c808fffbfa8f7..3e49f6925035ef3a7dcdd6af868e2f10394a2e7c 100644 |
--- a/metrics_library_test.cc |
+++ b/metrics_library_test.cc |
@@ -214,6 +214,23 @@ TEST_F(MetricsLibraryTest, SendToUMANotEnabled) { |
EXPECT_FALSE(file_util::PathExists(kTestUMAEventsFile)); |
} |
+TEST_F(MetricsLibraryTest, SendUserActionToUMA) { |
+ char buf[100]; |
+ const int kLen = 30; |
+ EXPECT_TRUE(lib_.SendUserActionToUMA("SomeKeyPressed")); |
+ EXPECT_EQ(kLen, file_util::ReadFile(kTestUMAEventsFile, buf, 100)); |
+ |
+ char exp[kLen]; |
+ sprintf(exp, "%c%c%c%cuseraction%cSomeKeyPressed", kLen, 0, 0, 0, 0); |
+ EXPECT_EQ(0, memcmp(exp, buf, kLen)); |
+} |
+ |
+TEST_F(MetricsLibraryTest, SendUserActionToUMANotEnabled) { |
+ SetMetricsEnabled(false); |
+ EXPECT_TRUE(lib_.SendUserActionToUMA("SomeOtherKeyPressed")); |
+ EXPECT_FALSE(file_util::PathExists(kTestUMAEventsFile)); |
+} |
+ |
class CMetricsLibraryTest : public testing::Test { |
protected: |
virtual void SetUp() { |
@@ -268,6 +285,17 @@ TEST_F(CMetricsLibraryTest, SendToUMA) { |
EXPECT_EQ(0, memcmp(exp, buf, kLen)); |
} |
+TEST_F(CMetricsLibraryTest, SendUserActionToUMA) { |
+ char buf[100]; |
+ const int kLen = 30; |
+ EXPECT_TRUE(CMetricsLibrarySendUserActionToUMA(lib_, "SomeKeyPressed")); |
+ EXPECT_EQ(kLen, file_util::ReadFile(kTestUMAEventsFile, buf, 100)); |
+ |
+ char exp[kLen]; |
+ sprintf(exp, "%c%c%c%cuseraction%cSomeKeyPressed", kLen, 0, 0, 0, 0); |
+ EXPECT_EQ(0, memcmp(exp, buf, kLen)); |
+} |
+ |
int main(int argc, char** argv) { |
testing::InitGoogleTest(&argc, argv); |
return RUN_ALL_TESTS(); |