Merge "C# CustomView Implementation (C++ wrappers, manual bindings, C# wrappers)...
[platform/core/uifw/dali-toolkit.git] / automated-tests / src / dali-toolkit / dali-toolkit-test-utils / test-trace-call-stack.h
index 32375a6..c3f3358 100644 (file)
@@ -1,8 +1,8 @@
-#ifndef __TEST_TRACE_CALL_STACK_H__
-#define __TEST_TRACE_CALL_STACK_H__
+#ifndef TEST_TRACE_CALL_STACK_H
+#define TEST_TRACE_CALL_STACK_H
 
 /*
- * Copyright (c) 2014 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2016 Samsung Electronics Co., Ltd.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -21,6 +21,7 @@
 #include <string>
 #include <vector>
 #include <map>
+#include <sstream>
 
 namespace Dali
 {
@@ -34,6 +35,7 @@ std::string ToString(float x);
 class TraceCallStack
 {
 public:
+
   /// Typedef for passing and storing named parameters
   typedef std::map< std::string, std::string > NamedParams;
 
@@ -77,6 +79,14 @@ public:
   bool FindMethod(std::string method) const;
 
   /**
+   * Search for a method in the stack and return its parameters if found
+   * @param[in] method The name of the method
+   * @param[out] params of the method
+   * @return true if the method was in the stack
+   */
+  bool FindMethodAndGetParameters(std::string method, std::string& params ) 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
@@ -100,6 +110,19 @@ public:
   bool FindMethodAndParams(std::string method, const NamedParams& params) const;
 
   /**
+   * Search for a method in the stack with the given parameter list.
+   * The search is done from a given index.
+   * This allows the order of methods and parameters to be checked.
+   * @param[in] method The name of the method
+   * @param[in] params A comma separated list of parameter values
+   * @param[in/out] startIndex The method index to start looking from.
+   *                This is updated if a method is found so subsequent
+   *                calls can search for methods occuring after this one.
+   * @return True if the method was in the stack
+   */
+  bool FindMethodAndParamsFromStartIndex( std::string method, std::string params, size_t& startIndex ) 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
@@ -128,6 +151,23 @@ public:
    */
   void Reset();
 
+  /**
+   * Method to display contents of the TraceCallStack.
+   * @return A string containing a list of function calls and parameters (may contain newline characters)
+   */
+  std::string GetTraceString()
+  {
+    std::stringstream traceStream;
+    int functionCount = mCallStack.size();
+    for( int i = 0; i < functionCount; ++i )
+    {
+      Dali::TraceCallStack::FunctionCall functionCall = mCallStack[ i ];
+      traceStream << "StackTrace: Index:" << i << ",  Function:" << functionCall.method << ",  ParamList:" << functionCall.paramList << std::endl;
+    }
+
+    return traceStream.str();
+  }
+
 private:
   bool mTraceActive; ///< True if the trace is active
 
@@ -151,4 +191,4 @@ private:
 
 } // namespace dali
 
-#endif //__TEST_TRACE_CALL_STACK_H__
+#endif // TEST_TRACE_CALL_STACK_H