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