From ac768fdcffd2c3a93bfa4ce8f5f8f6344c610894 Mon Sep 17 00:00:00 2001 From: azv Date: Mon, 17 Dec 2018 08:46:16 +0300 Subject: [PATCH] [Code coverage Config]: Exclude GUI oriented code, improve coverage quality for Config_Prop --- src/Config/Config_Common.cpp | 11 ++++------- src/Config/Config_ModuleReader.cpp | 2 ++ src/Config/Test/TestConfig.py | 12 ++++++++++++ 3 files changed, 18 insertions(+), 7 deletions(-) diff --git a/src/Config/Config_Common.cpp b/src/Config/Config_Common.cpp index c83a33079..319cb724c 100644 --- a/src/Config/Config_Common.cpp +++ b/src/Config/Config_Common.cpp @@ -94,6 +94,7 @@ bool isWidgetNode(xmlNodePtr theNode) return !isNode(theNode, NODE_SOURCE, NODE_VALIDATOR, NULL); } +// LCOV_EXCL_START // widget api? bool isCaseNode(xmlNodePtr theNode) { @@ -103,6 +104,7 @@ bool isCaseNode(xmlNodePtr theNode) return isNode(theNode, WDG_OPTIONALBOX, WDG_SWITCH_CASE, WDG_TOOLBOX_BOX, WDG_RADIOBOX_ITEM, NULL); } +// LCOV_EXCL_STOP bool hasChild(xmlNodePtr theNode) { @@ -251,6 +253,7 @@ std::string getProperty(xmlNodePtr theNode, const char* thePropName) return result; } +// LCOV_EXCL_START std::string getContent(xmlNodePtr theNode) { std::string result = ""; @@ -261,6 +264,7 @@ std::string getContent(xmlNodePtr theNode) xmlFree(aContent); return result; } +// LCOV_EXCL_STOP std::string getNormalizedProperty(xmlNodePtr theNode, const char* thePropName) { @@ -279,13 +283,6 @@ bool getBooleanAttribute(xmlNodePtr theNode, const char* theAttributeName, bool return result; } -CONFIG_EXPORT std::string normalize(const char* theString) -{ - if (!theString) - return std::string(); - return normalize(std::string(theString)); -} - CONFIG_EXPORT std::string normalize(const std::string& theString) { std::string result = theString; diff --git a/src/Config/Config_ModuleReader.cpp b/src/Config/Config_ModuleReader.cpp index d38885a64..ddcdab38f 100644 --- a/src/Config/Config_ModuleReader.cpp +++ b/src/Config/Config_ModuleReader.cpp @@ -240,6 +240,7 @@ void Config_ModuleReader::loadLibrary(const std::string& theLibName) void* aModLib = dlopen( aFileName.c_str(), RTLD_LAZY | RTLD_GLOBAL ); #endif if(!aModLib && theLibName != "DFBrowser") { // don't show error for internal debugging tool +// LCOV_EXCL_START std::string anErrorMsg = "Failed to load " + aFileName; #ifdef WIN32 DWORD dwLastError = ::GetLastError(); @@ -257,6 +258,7 @@ void Config_ModuleReader::loadLibrary(const std::string& theLibName) #endif std::cerr << anErrorMsg << std::endl; Events_InfoMessage("Config_ModuleReader", anErrorMsg).send(); +// LCOV_EXCL_STOP } } diff --git a/src/Config/Test/TestConfig.py b/src/Config/Test/TestConfig.py index a98d534fc..40b65ded2 100644 --- a/src/Config/Test/TestConfig.py +++ b/src/Config/Test/TestConfig.py @@ -40,3 +40,15 @@ assert(len(Config_PropManager().color("TestSection", "PropColor")) == 3) # check sections and properties are not empty assert(len(Config_PropManager().getSections()) > 0) assert(len(Config_PropManager().getProperties()) > 0) + +# verify the property +prop = Config_PropManager().findProp("TestSection", "PropDouble") +assert(prop is not None) +prop.setTitle("PropTitle") +assert(prop.title() == "PropTitle") +prop.setMin("0") +assert(prop.min() == "0") +prop.setMax("100") +assert(prop.max() == "100") +prop.setType(Config_Prop.String) +assert(prop.type() == Config_Prop.String) -- 2.39.2