Use UintToString() for unsigned values.
[chromium-blink-merge.git] / base / test / user_action_tester.cc
blob3fdab121b4756f23be40a5b903a8825f69b01f12
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"
7 #include "base/bind.h"
8 #include "base/bind_helpers.h"
10 namespace base {
12 UserActionTester::UserActionTester()
13 : action_callback_(
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() {
28 count_map_.clear();
31 void UserActionTester::OnUserAction(const std::string& user_action) {
32 ++(count_map_[user_action]);
35 } // namespace base