[dali_2.3.21] Merge branch 'devel/master'
[platform/core/uifw/dali-toolkit.git] / automated-tests / src / dali-toolkit / dali-toolkit-test-utils / test-trace-call-stack.h
index b7d9e46..c2d0a49 100644 (file)
@@ -2,7 +2,7 @@
 #define TEST_TRACE_CALL_STACK_H
 
 /*
- * Copyright (c) 2021 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2022 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.
@@ -73,6 +73,8 @@ public:
       {
         return !parameterName.compare(rhs.parameterName) && !value.str().compare(rhs.value.str());
       }
+
+      bool operator==(int match) const;
     };
 
     auto find(const std::string& param) const
@@ -119,6 +121,25 @@ public:
       }
     }
 
+    const std::ostringstream& operator[](std::string name) const
+    {
+      static std::ostringstream empty;
+      auto                      iter = mParams.begin();
+      for(; iter != mParams.end(); ++iter)
+      {
+        if(!iter->parameterName.compare(name))
+        {
+          break;
+        }
+      }
+
+      if(iter != mParams.end())
+      {
+        return iter->value;
+      }
+      return empty;
+    }
+
     std::string str() const
     {
       std::ostringstream out;
@@ -186,6 +207,14 @@ public:
   bool FindMethodAndGetParameters(std::string method, std::string& params) 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, NamedParams& 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
@@ -238,6 +267,14 @@ public:
   int FindIndexFromMethodAndParams(std::string method, const NamedParams& params) const;
 
   /**
+   * Search for the most recent occurrence of the method with the given (partial) parameters.
+   * @param[in] method The name of the method
+   * @param[in] params A map of named parameter values to match
+   * @return The full named parameters of the matching call.
+   */
+  const NamedParams* FindLastMatch(std::string method, const TraceCallStack::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
@@ -267,7 +304,7 @@ public:
     return traceStream.str();
   }
 
-private:
+public:
   bool        mTraceActive{false}; ///< True if the trace is active
   bool        mLogging{false};     ///< True if the trace is logged to stdout
   std::string mPrefix;