OLD | NEW |
(Empty) | |
| 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. |
| 4 |
| 5 #include "base/test/user_action_tester.h" |
| 6 |
| 7 #include "base/bind.h" |
| 8 #include "base/bind_helpers.h" |
| 9 |
| 10 namespace base { |
| 11 |
| 12 UserActionTester::UserActionTester() |
| 13 : action_callback_( |
| 14 base::Bind(&UserActionTester::OnUserAction, base::Unretained(this))) { |
| 15 base::AddActionCallback(action_callback_); |
| 16 } |
| 17 |
| 18 UserActionTester::~UserActionTester() { |
| 19 base::RemoveActionCallback(action_callback_); |
| 20 } |
| 21 |
| 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; |
| 25 } |
| 26 |
| 27 void UserActionTester::ResetCounts() { |
| 28 count_map_.clear(); |
| 29 } |
| 30 |
| 31 void UserActionTester::OnUserAction(const std::string& user_action) { |
| 32 ++(count_map_[user_action]); |
| 33 } |
| 34 |
| 35 } // namespace base |
OLD | NEW |