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

Unified Diff: base/test/user_action_tester.cc

Issue 1124763003: Update from https://crrev.com/327068 (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: update nacl, buildtools, fix display_change_notifier_unittest Created 5 years, 7 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
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..3fdab121b4756f23be40a5b903a8825f69b01f12
--- /dev/null
+++ b/base/test/user_action_tester.cc
@@ -0,0 +1,35 @@
+// 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"
+
+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

Powered by Google App Engine
This is Rietveld 408576698