X-Git-Url: http://review.tizen.org/git/?p=platform%2Fcore%2Fuifw%2Fdali-toolkit.git;a=blobdiff_plain;f=automated-tests%2Fsrc%2Fdali-toolkit%2Fdali-toolkit-test-utils%2Ftest-trace-call-stack.h;h=32375a682b23aaf1d6b5a3d1c4e20bd8b5cf9753;hp=3dd6065fc92f48a69c0c689ffeaddcb09cd2121d;hb=c125573992c196f15ece50589ae80efed63c8870;hpb=d5e3ed5f5b1c8fdba3ae97ead8729620f54b3836 diff --git a/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/test-trace-call-stack.h b/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/test-trace-call-stack.h index 3dd6065..32375a6 100644 --- a/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/test-trace-call-stack.h +++ b/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/test-trace-call-stack.h @@ -20,9 +20,13 @@ #include #include +#include namespace Dali { +std::string ToString(int x); +std::string ToString(unsigned int x); +std::string ToString(float x); /** * Helper class to track method calls in the abstraction and search for them in test cases @@ -30,6 +34,9 @@ namespace Dali class TraceCallStack { public: + /// Typedef for passing and storing named parameters + typedef std::map< std::string, std::string > NamedParams; + /** * Constructor */ @@ -45,6 +52,8 @@ public: */ void Enable(bool enable); + bool IsEnabled(); + /** * Push a call onto the stack if the trace is active * @param[in] method The name of the method @@ -52,6 +61,13 @@ public: */ void PushCall(std::string method, std::string params); + /** + * Push a call onto the stack if the trace is active + * @param[in] method The name of the method + * @param[in] params A comma separated list of parameter values + * @param[in] altParams A map of named parameter values + */ + void PushCall(std::string method, std::string params, const NamedParams& altParams); /** * Search for a method in the stack @@ -61,6 +77,13 @@ public: bool FindMethod(std::string method) const; /** + * Count how many times a method was called + * @param[in] method The name of the method + * @return The number of times it was called + */ + int CountMethod(std::string method) const; + + /** * Search for a method in the stack with the given parameter list * @param[in] method The name of the method * @param[in] params A comma separated list of parameter values @@ -69,6 +92,30 @@ public: bool FindMethodAndParams(std::string method, std::string params) const; /** + * Search for a method in the stack with the given parameter list + * @param[in] method The name of the method + * @param[in] params A map of named parameters to test for + * @return true if the method was in the stack + */ + bool FindMethodAndParams(std::string method, const NamedParams& params) const; + + /** + * Search for a method in the stack with the given parameter list + * @param[in] method The name of the method + * @param[in] params A comma separated list of parameter values + * @return index in the stack where the method was found or -1 otherwise + */ + int FindIndexFromMethodAndParams(std::string method, std::string params) const; + + /** + * Search for a method in the stack with the given parameter list + * @param[in] method The name of the method + * @param[in] params A map of named parameter values to match + * @return index in the stack where the method was found or -1 otherwise + */ + int FindIndexFromMethodAndParams(std::string method, const NamedParams& params) const; + + /** * Test if the given method and parameters are at a given index in the stack * @param[in] index Index in the call stack * @param[in] method Name of method to test @@ -81,15 +128,25 @@ public: */ void Reset(); - /** - * Get the call stack - * @return The call stack object (Vector of vector[2] of method/paramlist strings) - */ - inline const std::vector< std::vector< std::string > >& GetCallStack() { return mCallStack; } - private: bool mTraceActive; ///< True if the trace is active - std::vector< std::vector< std::string > > mCallStack; ///< The call stack + + struct FunctionCall + { + std::string method; + std::string paramList; + NamedParams namedParams; + FunctionCall( const std::string& aMethod, const std::string& aParamList ) + : method( aMethod ), paramList( aParamList ) + { + } + FunctionCall( const std::string& aMethod, const std::string& aParamList, const NamedParams& altParams ) + : method( aMethod ), paramList( aParamList ), namedParams( altParams ) + { + } + }; + + std::vector< FunctionCall > mCallStack; ///< The call stack }; } // namespace dali