1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "base/test/user_action_tester.h"
8 #include "base/bind_helpers.h"
12 UserActionTester::UserActionTester()
14 base::Bind(&UserActionTester::OnUserAction
, base::Unretained(this))) {
15 base::AddActionCallback(action_callback_
);
18 UserActionTester::~UserActionTester() {
19 base::RemoveActionCallback(action_callback_
);
22 int UserActionTester::GetActionCount(const std::string
& user_action
) const {
23 UserActionCountMap::const_iterator iter
= count_map_
.find(user_action
);
24 return iter
== count_map_
.end() ? 0 : iter
->second
;
27 void UserActionTester::ResetCounts() {
31 void UserActionTester::OnUserAction(const std::string
& user_action
) {
32 ++(count_map_
[user_action
]);