projects
/
platform
/
core
/
uifw
/
dali-toolkit.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Updated test files to match dali-core
[platform/core/uifw/dali-toolkit.git]
/
automated-tests
/
src
/
dali-toolkit
/
dali-toolkit-test-utils
/
test-trace-call-stack.cpp
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
f57dc50
..
dd063ed
100644
(file)
--- 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
@@
-1,5
+1,5
@@
/*
/*
- * Copyright (c) 20
17
Samsung Electronics Co., Ltd.
+ * Copyright (c) 20
21
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.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@
-16,11
+16,12
@@
*/
#include "test-trace-call-stack.h"
*/
#include "test-trace-call-stack.h"
+
+#include <iostream>
#include <sstream>
namespace Dali
{
#include <sstream>
namespace Dali
{
-
std::string ToString(int x)
{
std::stringstream out;
std::string ToString(int x)
{
std::stringstream out;
@@
-45,19
+46,36
@@
std::string ToString(float x)
/**
* Constructor
*/
/**
* Constructor
*/
-TraceCallStack::TraceCallStack() : mTraceActive(false) { }
+TraceCallStack::TraceCallStack(std::string prefix)
+: mTraceActive(false),
+ mPrefix(prefix)
+{
+}
/**
* Destructor
*/
/**
* Destructor
*/
-TraceCallStack::~TraceCallStack() { }
+TraceCallStack::~TraceCallStack()
+{
+}
/**
* Turn on / off tracing
*/
/**
* Turn on / off tracing
*/
-void TraceCallStack::Enable(bool enable) { mTraceActive = enable; }
+void TraceCallStack::Enable(bool enable)
+{
+ mTraceActive = enable;
+}
+
+bool TraceCallStack::IsEnabled()
+{
+ return mTraceActive;
+}
-bool TraceCallStack::IsEnabled() { return mTraceActive; }
+void TraceCallStack::EnableLogging(bool enablelogging)
+{
+ mLogging = enablelogging;
+}
/**
* Push a call onto the stack if the trace is active
/**
* Push a call onto the stack if the trace is active
@@
-69,7
+87,11
@@
void TraceCallStack::PushCall(std::string method, std::string params)
if(mTraceActive)
{
FunctionCall stackFrame(method, params);
if(mTraceActive)
{
FunctionCall stackFrame(method, params);
- mCallStack.push_back( stackFrame );
+ mCallStack.push_back(stackFrame);
+ }
+ if(mLogging)
+ {
+ fprintf(stderr, "%s%s(%s)\n", mPrefix.c_str(), method.c_str(), params.c_str());
}
}
}
}
@@
-78,7
+100,11
@@
void TraceCallStack::PushCall(std::string method, std::string params, const Trac
if(mTraceActive)
{
FunctionCall stackFrame(method, params, altParams);
if(mTraceActive)
{
FunctionCall stackFrame(method, params, altParams);
- mCallStack.push_back( stackFrame );
+ mCallStack.push_back(stackFrame);
+ }
+ if(mLogging)
+ {
+ fprintf(stderr, "%s%s(%s)\n", mPrefix.c_str(), method.c_str(), params.c_str());
}
}
}
}
@@
-90,38
+116,46
@@
void TraceCallStack::PushCall(std::string method, std::string params, const Trac
bool TraceCallStack::FindMethod(std::string method) const
{
bool found = false;
bool TraceCallStack::FindMethod(std::string method) const
{
bool found = false;
- for(
size_t i=0; i < mCallStack.size(); i++
)
+ for(
size_t i = 0; i < mCallStack.size(); i++
)
{
{
- if(
0 == mCallStack[i].method.compare(method)
)
+ if(
0 == mCallStack[i].method.compare(method)
)
{
found = true;
break;
}
}
{
found = true;
break;
}
}
+ if(!found)
+ {
+ fprintf(stderr, "Search for %s failed\n", method.c_str());
+ }
return found;
}
return found;
}
-bool TraceCallStack::FindMethodAndGetParameters(std::string method, std::string& params
) const
+bool TraceCallStack::FindMethodAndGetParameters(std::string method, std::string& params) const
{
bool found = false;
{
bool found = false;
- for(
size_t i=0; i < mCallStack.size(); i++
)
+ for(
size_t i = 0; i < mCallStack.size(); i++
)
{
{
- if(
0 == mCallStack[i].method.compare(method)
)
+ if(
0 == mCallStack[i].method.compare(method)
)
{
{
- found = true;
+ found
= true;
params = mCallStack[i].paramList;
break;
}
}
params = mCallStack[i].paramList;
break;
}
}
+ if(!found)
+ {
+ fprintf(stderr, "Search for %s(%s) failed\n", method.c_str(), params.c_str());
+ }
return found;
}
int TraceCallStack::CountMethod(std::string method) const
{
int numCalls = 0;
return found;
}
int TraceCallStack::CountMethod(std::string method) const
{
int numCalls = 0;
- for(
size_t i=0; i < mCallStack.size(); i++
)
+ for(
size_t i = 0; i < mCallStack.size(); i++
)
{
{
- if(
0 == mCallStack[i].method.compare(method)
)
+ if(
0 == mCallStack[i].method.compare(method)
)
{
numCalls++;
}
{
numCalls++;
}
@@
-137,19
+171,19
@@
int TraceCallStack::CountMethod(std::string method) const
*/
bool TraceCallStack::FindMethodAndParams(std::string method, std::string params) const
{
*/
bool TraceCallStack::FindMethodAndParams(std::string method, std::string params) const
{
- return FindIndexFromMethodAndParams(
method, params
) > -1;
+ return FindIndexFromMethodAndParams(
method, params
) > -1;
}
bool TraceCallStack::FindMethodAndParams(std::string method, const NamedParams& params) const
{
}
bool TraceCallStack::FindMethodAndParams(std::string method, const NamedParams& params) const
{
- return FindIndexFromMethodAndParams(
method, params
) > -1;
+ return FindIndexFromMethodAndParams(
method, params
) > -1;
}
}
-bool TraceCallStack::FindMethodAndParamsFromStartIndex(
std::string method, std::string params, size_t& startIndex
) const
+bool TraceCallStack::FindMethodAndParamsFromStartIndex(
std::string method, std::string params, size_t& startIndex
) const
{
{
- for(
size_t i = startIndex; i < mCallStack.size(); ++i
)
+ for(
size_t i = startIndex; i < mCallStack.size(); ++i
)
{
{
- if(
( mCallStack[i].method.compare( method ) == 0 ) && ( mCallStack[i].paramList.compare( params ) == 0 )
)
+ if(
(mCallStack[i].method.compare(method) == 0) && (mCallStack[i].paramList.compare(params) == 0)
)
{
startIndex = i;
return true;
{
startIndex = i;
return true;
@@
-164,14
+198,14
@@
bool TraceCallStack::FindMethodAndParamsFromStartIndex( std::string method, std:
* @param[in] params A comma separated list of parameter values
* @return index in the stack where the method was found or -1 otherwise
*/
* @param[in] params A comma separated list of parameter values
* @return index in the stack where the method was found or -1 otherwise
*/
-int TraceCallStack::FindIndexFromMethodAndParams(std::string method, std::string params) const
+int
32_t
TraceCallStack::FindIndexFromMethodAndParams(std::string method, std::string params) const
{
{
- int index = -1;
- for(
size_t i=0; i < mCallStack.size(); i++
)
+ int
32_t
index = -1;
+ for(
size_t i = 0; i < mCallStack.size(); i++
)
{
{
- if(
0 == mCallStack[i].method.compare(method) && 0 == mCallStack[i].paramList.compare(params)
)
+ if(
0 == mCallStack[i].method.compare(method) && 0 == mCallStack[i].paramList.compare(params)
)
{
{
- index =
i
;
+ index =
static_cast<int32_t>(i)
;
break;
}
}
break;
}
}
@@
-180,25
+214,25
@@
int TraceCallStack::FindIndexFromMethodAndParams(std::string method, std::string
int TraceCallStack::FindIndexFromMethodAndParams(std::string method, const TraceCallStack::NamedParams& params) const
{
int TraceCallStack::FindIndexFromMethodAndParams(std::string method, const TraceCallStack::NamedParams& params) const
{
- int index = -1;
- for(
size_t i=0; i < mCallStack.size(); i++
)
+ int
32_t
index = -1;
+ for(
size_t i = 0; i < mCallStack.size(); i++
)
{
{
- if(
0 == mCallStack[i].method.compare(method)
)
+ if(
0 == mCallStack[i].method.compare(method)
)
{
// Test each of the passed in parameters:
bool match = true;
{
// Test each of the passed in parameters:
bool match = true;
- for(
NamedParams::const_iterator iter = params.begin() ; iter != params.end() ; ++iter
)
+ for(
NamedParams::const_iterator iter = params.begin(); iter != params.end(); ++iter
)
{
NamedParams::const_iterator paramIter = mCallStack[i].namedParams.find(iter->first);
{
NamedParams::const_iterator paramIter = mCallStack[i].namedParams.find(iter->first);
- if(
paramIter == params.end() || paramIter->second.compare(iter->second) != 0
)
+ if(
paramIter == params.end() || paramIter->second.compare(iter->second) != 0
)
{
match = false;
break;
}
}
{
match = false;
break;
}
}
- if(
match == true
)
+ if(
match == true
)
{
{
- index =
i
;
+ index =
static_cast<int32_t>(i)
;
break;
}
}
break;
}
}
@@
-206,7
+240,6
@@
int TraceCallStack::FindIndexFromMethodAndParams(std::string method, const Trace
return index;
}
return index;
}
-
/**
* Test if the given method and parameters are at a given index in the stack
* @param[in] index Index in the call stack
/**
* Test if the given method and parameters are at a given index in the stack
* @param[in] index Index in the call stack
@@
-215,7
+248,7
@@
int TraceCallStack::FindIndexFromMethodAndParams(std::string method, const Trace
*/
bool TraceCallStack::TestMethodAndParams(int index, std::string method, std::string params) const
{
*/
bool TraceCallStack::TestMethodAndParams(int index, std::string method, std::string params) const
{
- return (
0 == mCallStack[index].method.compare(method) && 0 == mCallStack[index].paramList.compare(params)
);
+ return (
0 == mCallStack[index].method.compare(method) && 0 == mCallStack[index].paramList.compare(params)
);
}
/**
}
/**
@@
-226,5
+259,4
@@
void TraceCallStack::Reset()
mCallStack.clear();
}
mCallStack.clear();
}
-
} // namespace Dali
} // namespace Dali