AppFwk : Add date and version info to field/object keyword extraction

This commit is contained in:
Magne Sjaastad 2017-12-18 07:10:05 +01:00
parent d15808efe6
commit 7992682fcb

View File

@ -1,8 +1,12 @@
#include "gtest/gtest.h"
#include "RiaVersionInfo.h"
#include "cafClassTypeName.h"
#include "cafPdmDefaultObjectFactory.h"
#include "cafPdmObjectHandle.h"
#include <QDateTime>
#include <QFile>
#include <QTextStream>
@ -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<QString> 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<QString> 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<caf::PdmFieldHandle*> fields;
myClass->fields(fields);
@ -71,5 +108,5 @@ TEST(ListKeywords, ListAllObjectKeywordsAndFieldKeywords)
}
QString filePath = "c:/temp/ri-fieldKeywords.txt";
// writeTextToFile(filePath, textString);
//writeTextToFile(filePath, textString);
}