Merge branch 'master' into tizen
[platform/core/uifw/dali-toolkit.git] / automated-tests / src / dali-toolkit / dali-toolkit-test-utils / test-trace-call-stack.h
1 #ifndef __TEST_TRACE_CALL_STACK_H__
2 #define __TEST_TRACE_CALL_STACK_H__
3
4 //
5 // Copyright (c) 2014 Samsung Electronics Co., Ltd.
6 //
7 // Licensed under the Flora License, Version 1.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
10 //
11 //     http://floralicense.org/license/
12 //
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.
18 //
19
20 #include <string>
21 #include <vector>
22
23 namespace Dali
24 {
25
26 /**
27  * Helper class to track method calls in the abstraction and search for them in test cases
28  */
29 class TraceCallStack
30 {
31 public:
32   /**
33    * Constructor
34    */
35   TraceCallStack();
36
37   /**
38    * Destructor
39    */
40   ~TraceCallStack();
41
42   /**
43    * Turn on / off tracing
44    */
45   void Enable(bool enable);
46
47   /**
48    * Push a call onto the stack if the trace is active
49    * @param[in] method The name of the method
50    * @param[in] params A comma separated list of parameter values
51    */
52   void PushCall(std::string method, std::string params);
53
54
55   /**
56    * Search for a method in the stack
57    * @param[in] method The name of the method
58    * @return true if the method was in the stack
59    */
60   bool FindMethod(std::string method) const;
61
62   /**
63    * Search for a method in the stack with the given parameter list
64    * @param[in] method The name of the method
65    * @param[in] params A comma separated list of parameter values
66    * @return true if the method was in the stack
67    */
68   bool FindMethodAndParams(std::string method, std::string params) const;
69
70   /**
71    * Test if the given method and parameters are at a given index in the stack
72    * @param[in] index Index in the call stack
73    * @param[in] method Name of method to test
74    * @param[in] params A comma separated list of parameter values to test
75    */
76   bool TestMethodAndParams(int index, std::string method, std::string params) const;
77
78   /**
79    * Reset the call stack
80    */
81   void Reset();
82
83   /**
84    * Get the call stack
85    * @return The call stack object (Vector of vector[2] of method/paramlist strings)
86    */
87   inline const std::vector< std::vector< std::string > >& GetCallStack() { return mCallStack; }
88
89 private:
90   bool mTraceActive; ///< True if the trace is active
91   std::vector< std::vector< std::string > > mCallStack; ///< The call stack
92 };
93
94 } // namespace dali
95
96 #endif //__TEST_TRACE_CALL_STACK_H__