Updated test files to match dali-core Pipeline VtxFmt
[platform/core/uifw/dali-toolkit.git] / automated-tests / src / dali-toolkit / dali-toolkit-test-utils / test-trace-call-stack.cpp
index 9fde7c4..9e4efe8 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2020 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2021 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.
@@ -17,6 +17,7 @@
 
 #include "test-trace-call-stack.h"
 
+#include <iostream>
 #include <sstream>
 
 namespace Dali
@@ -45,8 +46,17 @@ std::string ToString(float x)
 /**
  * Constructor
  */
-TraceCallStack::TraceCallStack()
-: mTraceActive(false)
+TraceCallStack::TraceCallStack(std::string prefix)
+: mTraceActive(false),
+  mLogging(false),
+  mPrefix(prefix)
+{
+}
+
+TraceCallStack::TraceCallStack(bool logging, std::string prefix)
+: mTraceActive(false),
+  mLogging(logging),
+  mPrefix(prefix)
 {
 }
 
@@ -70,6 +80,11 @@ bool TraceCallStack::IsEnabled()
   return mTraceActive;
 }
 
+void TraceCallStack::EnableLogging(bool enablelogging)
+{
+  mLogging = enablelogging;
+}
+
 /**
  * Push a call onto the stack if the trace is active
  * @param[in] method The name of the method
@@ -82,6 +97,10 @@ void TraceCallStack::PushCall(std::string method, std::string params)
     FunctionCall stackFrame(method, params);
     mCallStack.push_back(stackFrame);
   }
+  if(mLogging)
+  {
+    fprintf(stderr, "%s%s(%s)\n", mPrefix.c_str(), method.c_str(), params.c_str());
+  }
 }
 
 void TraceCallStack::PushCall(std::string method, std::string params, const TraceCallStack::NamedParams& altParams)
@@ -91,6 +110,10 @@ void TraceCallStack::PushCall(std::string method, std::string params, const Trac
     FunctionCall stackFrame(method, params, altParams);
     mCallStack.push_back(stackFrame);
   }
+  if(mLogging)
+  {
+    fprintf(stderr, "%s%s(%s)\n", mPrefix.c_str(), method.c_str(), params.c_str());
+  }
 }
 
 /**
@@ -109,6 +132,10 @@ bool TraceCallStack::FindMethod(std::string method) const
       break;
     }
   }
+  if(!found)
+  {
+    fprintf(stderr, "Search for %s failed\n", method.c_str());
+  }
   return found;
 }
 
@@ -124,6 +151,10 @@ bool TraceCallStack::FindMethodAndGetParameters(std::string method, std::string&
       break;
     }
   }
+  if(!found)
+  {
+    fprintf(stderr, "Search for %s(%s) failed\n", method.c_str(), params.c_str());
+  }
   return found;
 }
 
@@ -186,6 +217,10 @@ int32_t TraceCallStack::FindIndexFromMethodAndParams(std::string method, std::st
       break;
     }
   }
+  if(index == -1)
+  {
+    fprintf(stderr, "Search for %s(%s) failed\n", method.c_str(), params.c_str());
+  }
   return index;
 }
 
@@ -198,10 +233,14 @@ int TraceCallStack::FindIndexFromMethodAndParams(std::string method, const Trace
     {
       // Test each of the passed in parameters:
       bool match = true;
-      for(NamedParams::const_iterator iter = params.begin(); iter != params.end(); ++iter)
+
+      for(auto iter = params.mParams.begin(); iter != params.mParams.end(); ++iter)
       {
-        NamedParams::const_iterator paramIter = mCallStack[i].namedParams.find(iter->first);
-        if(paramIter == params.end() || paramIter->second.compare(iter->second) != 0)
+        auto        paramIter = mCallStack[i].namedParams.find(iter->parameterName);
+        std::string value     = paramIter->value.str();
+        std::string iValue    = iter->value.str();
+
+        if(paramIter == mCallStack[i].namedParams.end() || value.compare(iValue))
         {
           match = false;
           break;
@@ -214,6 +253,12 @@ int TraceCallStack::FindIndexFromMethodAndParams(std::string method, const Trace
       }
     }
   }
+
+  if(index == -1)
+  {
+    fprintf(stderr, "Search for %s(%s) failed\n", method.c_str(), params.str().c_str());
+  }
+
   return index;
 }