From e3f2e46c5c880268d52dae3b0d25645a848a57da Mon Sep 17 00:00:00 2001 From: David Steele Date: Fri, 5 Mar 2021 13:51:27 +0000 Subject: [PATCH] Syncing Test harness update for Sampler Change-Id: I8b3e9b4d8a8642fe145bc5639a547f12ae26abf6 --- .../dali-toolkit-test-utils/test-gl-abstraction.h | 12 ++--- .../test-trace-call-stack.cpp | 54 +++++++++++++++++++++- .../test-trace-call-stack.h | 12 ++++- 3 files changed, 67 insertions(+), 11 deletions(-) diff --git a/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/test-gl-abstraction.h b/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/test-gl-abstraction.h index 18fbbf1..1d93731 100644 --- a/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/test-gl-abstraction.h +++ b/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/test-gl-abstraction.h @@ -1181,16 +1181,10 @@ public: 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); } diff --git a/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/test-trace-call-stack.cpp b/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/test-trace-call-stack.cpp index 1a0ab3a..7f2de63 100644 --- a/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/test-trace-call-stack.cpp +++ b/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/test-trace-call-stack.cpp @@ -16,9 +16,9 @@ */ #include "test-trace-call-stack.h" - #include #include +#include "dali-test-suite-utils.h" namespace Dali { @@ -255,6 +255,45 @@ int TraceCallStack::FindIndexFromMethodAndParams(std::string method, const Trace 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(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 @@ -274,4 +313,17 @@ void TraceCallStack::Reset() 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 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 b7d9e46..7631630 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 @@ -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 @@ -238,6 +240,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 +277,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; -- 2.7.4