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 |