1 #ifndef __TEST_TRACE_CALL_STACK_H__
2 #define __TEST_TRACE_CALL_STACK_H__
5 * Copyright (c) 2014 Samsung Electronics Co., Ltd.
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
28 * Helper class to track method calls in the abstraction and search for them in test cases
44 * Turn on / off tracing
46 void Enable(bool enable);
51 * Push a call onto the stack if the trace is active
52 * @param[in] method The name of the method
53 * @param[in] params A comma separated list of parameter values
55 void PushCall(std::string method, std::string params);
59 * Search for a method in the stack
60 * @param[in] method The name of the method
61 * @return true if the method was in the stack
63 bool FindMethod(std::string method) const;
66 * Count how many times a method was called
67 * @param[in] method The name of the method
68 * @return The number of times it was called
70 int CountMethod(std::string method) const;
73 * Search for a method in the stack with the given parameter list
74 * @param[in] method The name of the method
75 * @param[in] params A comma separated list of parameter values
76 * @return true if the method was in the stack
78 bool FindMethodAndParams(std::string method, std::string params) const;
81 * Search for a method in the stack with the given parameter list
82 * @param[in] method The name of the method
83 * @param[in] params A comma separated list of parameter values
84 * @return index in the stack where the method was found or -1 otherwise
86 int FindIndexFromMethodAndParams(std::string method, std::string params) const;
89 * Test if the given method and parameters are at a given index in the stack
90 * @param[in] index Index in the call stack
91 * @param[in] method Name of method to test
92 * @param[in] params A comma separated list of parameter values to test
94 bool TestMethodAndParams(int index, std::string method, std::string params) const;
97 * Reset the call stack
103 * @return The call stack object (Vector of vector[2] of method/paramlist strings)
105 inline const std::vector< std::vector< std::string > >& GetCallStack() { return mCallStack; }
108 bool mTraceActive; ///< True if the trace is active
109 std::vector< std::vector< std::string > > mCallStack; ///< The call stack
114 #endif //__TEST_TRACE_CALL_STACK_H__