out << std::hex << target << ", " << pname << ", " << param;
std::string params = out.str();
- out.str("");
- out << std::hex << target;
TraceCallStack::NamedParams namedParams;
- namedParams["target"] << out.str();
- out.str("");
- out << std::hex << pname;
- namedParams["pname"] << out.str();
- out.str("");
- out << std::hex << param;
- namedParams["param"] << out.str();
+ namedParams["target"] << std::hex << target;
+ namedParams["pname"] << std::hex << pname;
+ namedParams["param"] << param;
mTexParameterTrace.PushCall("TexParameteri", params, namedParams);
}
*/
#include "test-trace-call-stack.h"
-
#include <iostream>
#include <sstream>
+#include "dali-test-suite-utils.h"
namespace Dali
{
return index;
}
+const TraceCallStack::NamedParams* TraceCallStack::FindLastMatch(std::string method, const TraceCallStack::NamedParams& params) const
+{
+ int index = -1;
+
+ if(mCallStack.size() > 0)
+ {
+ for(index = static_cast<int>(mCallStack.size() - 1); index >= 0; --index)
+ {
+ if(0 == mCallStack[index].method.compare(method))
+ {
+ // Test each of the passed in parameters:
+ bool match = true;
+
+ for(auto iter = params.mParams.begin(); iter != params.mParams.end(); ++iter)
+ {
+ auto paramIter = mCallStack[index].namedParams.find(iter->parameterName);
+ std::string value = paramIter->value.str();
+ std::string iValue = iter->value.str();
+
+ if(paramIter == mCallStack[index].namedParams.end() || value.compare(iValue))
+ {
+ match = false;
+ break;
+ }
+ }
+ if(match == true)
+ {
+ break;
+ }
+ }
+ }
+ }
+ if(index >= 0)
+ {
+ return &mCallStack[index].namedParams;
+ }
+ return nullptr;
+}
+
/**
* Test if the given method and parameters are at a given index in the stack
* @param[in] index Index in the call stack
mCallStack.clear();
}
+bool TraceCallStack::NamedParams::NameValue::operator==(int match) const
+{
+ std::ostringstream matchStr;
+ matchStr << match;
+ std::string valueStr = value.str();
+ bool retval = !valueStr.compare(matchStr.str());
+ if(!retval)
+ {
+ tet_printf("Comparing parameter \"%s\": %s with %s failed\n", parameterName.c_str(), value.str().c_str(), matchStr.str().c_str());
+ }
+ return retval;
+}
+
} // namespace Dali
{
return !parameterName.compare(rhs.parameterName) && !value.str().compare(rhs.value.str());
}
+
+ bool operator==(int match) const;
};
auto find(const std::string& param) const
*/
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
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;