From 7992682fcb9fd2582ca1b69e7733a07a090364b9 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Mon, 18 Dec 2017 07:10:05 +0100 Subject: [PATCH] AppFwk : Add date and version info to field/object keyword extraction --- .../ListKeywordsForObjectsAndFields-Test.cpp | 45 +++++++++++++++++-- 1 file changed, 41 insertions(+), 4 deletions(-) diff --git a/ApplicationCode/UnitTests/ListKeywordsForObjectsAndFields-Test.cpp b/ApplicationCode/UnitTests/ListKeywordsForObjectsAndFields-Test.cpp index 74fb0f9e4b..58f3d21b1f 100644 --- a/ApplicationCode/UnitTests/ListKeywordsForObjectsAndFields-Test.cpp +++ b/ApplicationCode/UnitTests/ListKeywordsForObjectsAndFields-Test.cpp @@ -1,8 +1,12 @@ #include "gtest/gtest.h" +#include "RiaVersionInfo.h" + +#include "cafClassTypeName.h" #include "cafPdmDefaultObjectFactory.h" #include "cafPdmObjectHandle.h" +#include #include #include @@ -20,6 +24,24 @@ void writeTextToFile(const QString& filePath, const QString& text) } } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QString versionHeaderText() +{ + QString text; + + QDateTime dt = QDateTime::currentDateTime(); + + text += QString("// ResInsight version string : %1\n").arg(STRPRODUCTVER); + text += QString("// Report generated : %1\n").arg(QDateTime::currentDateTime().toString()); + text += "//\n"; + text += "//\n"; + text += "\n"; + + return text; +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -30,6 +52,8 @@ TEST(ListKeywords, ListAllObjectKeywords) QString textString; QTextStream stream(&textString); + textString = versionHeaderText(); + std::vector classKeywords = instance->classKeywords(); for (auto keyword : classKeywords) { @@ -37,7 +61,7 @@ TEST(ListKeywords, ListAllObjectKeywords) } QString filePath = "c:/temp/ri-objectKeywords.txt"; - // writeTextToFile(filePath, textString); + //writeTextToFile(filePath, textString); } //-------------------------------------------------------------------------------------------------- @@ -50,13 +74,26 @@ TEST(ListKeywords, ListAllObjectKeywordsAndFieldKeywords) QString textString; QTextStream stream(&textString); + bool includeClassName = true; + + textString = versionHeaderText(); + std::vector classKeywords = instance->classKeywords(); for (auto keyword : classKeywords) { - stream << keyword << "\n"; - caf::PdmObjectHandle* myClass = instance->create(keyword); + stream << keyword; + + if (includeClassName) + { + QString className = qStringTypeName(*myClass); + + stream << " - " << className; + } + + stream << "\n"; + std::vector fields; myClass->fields(fields); @@ -71,5 +108,5 @@ TEST(ListKeywords, ListAllObjectKeywordsAndFieldKeywords) } QString filePath = "c:/temp/ri-fieldKeywords.txt"; - // writeTextToFile(filePath, textString); + //writeTextToFile(filePath, textString); }