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

Unified Diff: base/test/user_action_tester.cc

Issue 1073613002: Added test support to observe and verify UMA user actions during tests. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Addressed mark@'s comments from patch set 2. Created 5 years, 8 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 | « base/test/user_action_tester.h ('k') | base/test/user_action_tester_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/test/user_action_tester.cc
diff --git a/base/test/user_action_tester.cc b/base/test/user_action_tester.cc
new file mode 100644
index 0000000000000000000000000000000000000000..578d8bbee13e1c62c9b0fac8d8a275e97f072b50
--- /dev/null
+++ b/base/test/user_action_tester.cc
@@ -0,0 +1,36 @@
+// Copyright 2015 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "base/test/user_action_tester.h"
+
+#include "base/bind.h"
+#include "base/bind_helpers.h"
+#include "base/metrics/user_metrics.h"
Mark Mentovai 2015/04/13 20:08:37 Me too.
+
+namespace base {
+
+UserActionTester::UserActionTester()
+ : action_callback_(
+ base::Bind(&UserActionTester::OnUserAction, base::Unretained(this))) {
+ base::AddActionCallback(action_callback_);
+}
+
+UserActionTester::~UserActionTester() {
+ base::RemoveActionCallback(action_callback_);
+}
+
+int UserActionTester::GetActionCount(const std::string& user_action) const {
+ UserActionCountMap::const_iterator iter = count_map_.find(user_action);
+ return iter == count_map_.end() ? 0 : iter->second;
+}
+
+void UserActionTester::ResetCounts() {
+ count_map_.clear();
+}
+
+void UserActionTester::OnUserAction(const std::string& user_action) {
+ ++(count_map_[user_action]);
+}
+
+} // namespace base
« no previous file with comments | « base/test/user_action_tester.h ('k') | base/test/user_action_tester_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698