Chromium Code Reviews| 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 #ifndef BASE_TEST_USER_ACTION_TESTER_H_ | |
| 6 #define BASE_TEST_USER_ACTION_TESTER_H_ | |
| 7 | |
| 8 #include <map> | |
| 9 #include <string> | |
| 10 | |
| 11 #include "base/metrics/user_metrics.h" | |
| 12 | |
| 13 namespace base { | |
| 14 | |
| 15 // This class observes and collects user action notifications that are sent | |
| 16 // by the tests, so that they can be examined afterwards for correctness. | |
| 17 class UserActionTester { | |
| 18 public: | |
| 19 UserActionTester(); | |
| 20 virtual ~UserActionTester(); | |
|
Ilya Sherman
2015/04/08 20:49:19
nit: Does this really need to be virtual? That is
bruthig
2015/04/09 23:17:52
Done.
| |
| 21 | |
| 22 // Returns the number of times the given |user_action| occurred. | |
| 23 int GetActionCount(const std::string& user_action) const; | |
| 24 | |
| 25 // Resets all user action counts to 0. | |
| 26 void ResetCounts(); | |
| 27 | |
| 28 // A wrapper for the OnUserAction function that is accessible for tests of the | |
| 29 // UserActionTester. | |
| 30 void OnUserAction_for_test(const std::string& user_action); | |
| 31 | |
| 32 private: | |
| 33 typedef std::map<std::string, int> UserActionCountMap; | |
| 34 | |
| 35 // The callback that is notified when a user actions occurs. | |
| 36 void OnUserAction(const std::string& user_action); | |
| 37 | |
| 38 // A map that tracks the number of times a user action has occurred. | |
| 39 UserActionCountMap count_map_; | |
| 40 | |
| 41 // The callback that is added to the global action callback list. | |
| 42 base::ActionCallback action_callback_; | |
| 43 | |
| 44 DISALLOW_COPY_AND_ASSIGN(UserActionTester); | |
| 45 }; | |
| 46 | |
| 47 } // namespace base | |
| 48 | |
| 49 #endif // BASE_TEST_USER_ACTION_TESTER_H_ | |
| OLD | NEW |