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

Unified Diff: metrics_library_test.cc

Issue 6094010: Add support for user actions to the metrics library and the metrics clients. (Closed) Base URL: ssh://git@gitrw.chromium.org:9222/metrics.git@master
Patch Set: 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 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();
« 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