mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
[System] Added support for display of regression images on top of each other in regression report
Use a slider concept (using CSS) to switch between generated and base image
This commit is contained in:
parent
f7d5d92029
commit
5fb04e9526
@ -1757,6 +1757,19 @@ void RiaApplication::runRegressionTest(const QString& testRootPath)
|
|||||||
|
|
||||||
RiaImageCompareReporter imageCompareReporter;
|
RiaImageCompareReporter imageCompareReporter;
|
||||||
|
|
||||||
|
// Minor workaround
|
||||||
|
// Use registry to define if interactive diff images should be created
|
||||||
|
// Defined by user in RiaRegressionTest
|
||||||
|
{
|
||||||
|
QSettings settings;
|
||||||
|
|
||||||
|
bool useInteractiveDiff = settings.value("showInteractiveDiffImages").toBool();
|
||||||
|
if (useInteractiveDiff)
|
||||||
|
{
|
||||||
|
imageCompareReporter.showInteractiveOnly();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
for (int dirIdx = 0; dirIdx < folderList.size(); ++dirIdx)
|
for (int dirIdx = 0; dirIdx < folderList.size(); ++dirIdx)
|
||||||
{
|
{
|
||||||
QDir testCaseFolder(folderList[dirIdx].filePath());
|
QDir testCaseFolder(folderList[dirIdx].filePath());
|
||||||
|
@ -23,6 +23,9 @@
|
|||||||
|
|
||||||
RiaImageCompareReporter::RiaImageCompareReporter(void)
|
RiaImageCompareReporter::RiaImageCompareReporter(void)
|
||||||
{
|
{
|
||||||
|
m_showOriginal = true;
|
||||||
|
m_showGenerated = true;
|
||||||
|
m_showInteractiveDiff = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -68,6 +71,12 @@ void RiaImageCompareReporter::generateHTMLReport(const std::string& fileName)
|
|||||||
html += "<html>\n";
|
html += "<html>\n";
|
||||||
html += "<head>\n";
|
html += "<head>\n";
|
||||||
html += "<title>Regression-Test Report</title>\n";
|
html += "<title>Regression-Test Report</title>\n";
|
||||||
|
|
||||||
|
if (m_showInteractiveDiff)
|
||||||
|
{
|
||||||
|
html += cssString();
|
||||||
|
}
|
||||||
|
|
||||||
html += "</head>\n";
|
html += "</head>\n";
|
||||||
html += "\n";
|
html += "\n";
|
||||||
html += "<body>\n";
|
html += "<body>\n";
|
||||||
@ -93,8 +102,21 @@ void RiaImageCompareReporter::generateHTMLReport(const std::string& fileName)
|
|||||||
html += " </tr>\n";
|
html += " </tr>\n";
|
||||||
|
|
||||||
html += " <tr>\n";
|
html += " <tr>\n";
|
||||||
html += " <td> <img src=\"" + baseImageFolder + "/" + baseImageNames[fIdx] + "\" width=\"100%\" alt=\"" + baseImageFolder + "/" + baseImageNames[fIdx] + "\" > </td>\n";
|
if (m_showOriginal)
|
||||||
html += " <td> <img src=\"" + genImageFolder + "/" + baseImageNames[fIdx] + "\" width=\"100%\" alt=\"" + genImageFolder + "/" + baseImageNames[fIdx] + "\" > </td>\n";
|
{
|
||||||
|
html += " <td> <img src=\"" + baseImageFolder + "/" + baseImageNames[fIdx] + "\" width=\"100%\" alt=\"" + baseImageFolder + "/" + baseImageNames[fIdx] + "\" > </td>\n";
|
||||||
|
}
|
||||||
|
|
||||||
|
if (m_showGenerated)
|
||||||
|
{
|
||||||
|
html += " <td> <img src=\"" + genImageFolder + "/" + baseImageNames[fIdx] + "\" width=\"100%\" alt=\"" + genImageFolder + "/" + baseImageNames[fIdx] + "\" > </td>\n";
|
||||||
|
}
|
||||||
|
|
||||||
|
if (m_showInteractiveDiff)
|
||||||
|
{
|
||||||
|
html += " <td> <div class = \"image-slider\"> <div> <img src=\"" + baseImageFolder + "/" + baseImageNames[fIdx] + "\" > </div> <img src = \"" + genImageFolder + "/" + baseImageNames[fIdx] + "\" > </div> </td>\n";
|
||||||
|
}
|
||||||
|
|
||||||
html += " <td> <img src=\"" + diffImageFolder + "/" + baseImageNames[fIdx] + "\" width=\"100%\" alt=\"" + diffImageFolder + "/" + baseImageNames[fIdx] + "\" > </td>\n";
|
html += " <td> <img src=\"" + diffImageFolder + "/" + baseImageNames[fIdx] + "\" width=\"100%\" alt=\"" + diffImageFolder + "/" + baseImageNames[fIdx] + "\" > </td>\n";
|
||||||
html += " </tr>\n";
|
html += " </tr>\n";
|
||||||
|
|
||||||
@ -110,6 +132,16 @@ void RiaImageCompareReporter::generateHTMLReport(const std::string& fileName)
|
|||||||
output << html;
|
output << html;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
///
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
void RiaImageCompareReporter::showInteractiveOnly()
|
||||||
|
{
|
||||||
|
m_showOriginal = false;
|
||||||
|
m_showGenerated = false;
|
||||||
|
m_showInteractiveDiff = true;
|
||||||
|
}
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
/// Retuns the names of the *.png files in a directory. The names are without path, but with extention
|
/// Retuns the names of the *.png files in a directory. The names are without path, but with extention
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
@ -133,3 +165,51 @@ std::vector<std::string> RiaImageCompareReporter::getPngFilesInDirectory(const s
|
|||||||
|
|
||||||
return fileNames;
|
return fileNames;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
///
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
std::string RiaImageCompareReporter::cssString() const
|
||||||
|
{
|
||||||
|
std::string html;
|
||||||
|
|
||||||
|
html += "<style media=\"screen\" type=\"text/css\">";
|
||||||
|
|
||||||
|
html += "";
|
||||||
|
html += ".image-slider {";
|
||||||
|
html += "position:relative;";
|
||||||
|
html += "display: inline-block;";
|
||||||
|
html += "line-height: 0;";
|
||||||
|
html += "}";
|
||||||
|
|
||||||
|
html += ".image-slider > div {";
|
||||||
|
html += "position: absolute;";
|
||||||
|
html += "top: 0; bottom: 0; left: 0;";
|
||||||
|
html += "width: 25px;";
|
||||||
|
html += "max-width: 100%;";
|
||||||
|
html += "overflow: hidden;";
|
||||||
|
html += "resize: horizontal;";
|
||||||
|
html += "}";
|
||||||
|
|
||||||
|
html += ".image-slider > div:before {";
|
||||||
|
html += "content: '';";
|
||||||
|
html += "position: absolute;";
|
||||||
|
html += "right: 0; bottom: 0;";
|
||||||
|
html += "width: 23px; height: 23px;";
|
||||||
|
html += "padding: 5px;";
|
||||||
|
html += "background: linear-gradient(-45deg, gray 50%, transparent 0);";
|
||||||
|
html += "background-clip: content-box;";
|
||||||
|
html += "cursor: ew-resize;";
|
||||||
|
html += "-webkit-filter: drop-shadow(0 0 6px black);";
|
||||||
|
html += "filter: drop-shadow(0 0 6px black);";
|
||||||
|
html += "}";
|
||||||
|
|
||||||
|
html += ".image-slider img {";
|
||||||
|
html += "user-select: none;";
|
||||||
|
html += "max-width: 1000px;";
|
||||||
|
html += "}";
|
||||||
|
|
||||||
|
html += "</style>";
|
||||||
|
|
||||||
|
return html;
|
||||||
|
}
|
||||||
|
@ -30,10 +30,14 @@ public:
|
|||||||
void addImageDirectoryComparisonSet(const std::string& title, const std::string& baseImageDir, const std::string& newImagesDir, const std::string& diffImagesDir );
|
void addImageDirectoryComparisonSet(const std::string& title, const std::string& baseImageDir, const std::string& newImagesDir, const std::string& diffImagesDir );
|
||||||
void generateHTMLReport(const std::string& filenName);
|
void generateHTMLReport(const std::string& filenName);
|
||||||
|
|
||||||
|
void showInteractiveOnly();
|
||||||
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
static std::vector<std::string> getPngFilesInDirectory(const std::string& searchPath);
|
static std::vector<std::string> getPngFilesInDirectory(const std::string& searchPath);
|
||||||
|
std::string cssString() const;
|
||||||
|
|
||||||
|
private:
|
||||||
struct DirSet
|
struct DirSet
|
||||||
{
|
{
|
||||||
DirSet(const std::string& title, const std::string& baseImageDir, const std::string& newImagesDir, const std::string& diffImagesDir )
|
DirSet(const std::string& title, const std::string& baseImageDir, const std::string& newImagesDir, const std::string& diffImagesDir )
|
||||||
@ -50,5 +54,9 @@ private:
|
|||||||
};
|
};
|
||||||
|
|
||||||
std::vector<DirSet> m_directorySets;
|
std::vector<DirSet> m_directorySets;
|
||||||
|
|
||||||
|
bool m_showOriginal;
|
||||||
|
bool m_showGenerated;
|
||||||
|
bool m_showInteractiveDiff;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -32,6 +32,8 @@ RiaRegressionTest::RiaRegressionTest(void)
|
|||||||
|
|
||||||
CAF_PDM_InitFieldNoDefault(®ressionTestFolder, "regressionTestFolder", "Regression Test Folder", "", "", "");
|
CAF_PDM_InitFieldNoDefault(®ressionTestFolder, "regressionTestFolder", "Regression Test Folder", "", "", "");
|
||||||
regressionTestFolder.uiCapability()->setUiEditorTypeName(caf::PdmUiFilePathEditor::uiEditorTypeName());
|
regressionTestFolder.uiCapability()->setUiEditorTypeName(caf::PdmUiFilePathEditor::uiEditorTypeName());
|
||||||
|
|
||||||
|
CAF_PDM_InitField(&showInteractiveDiffImages, "showInteractiveDiffImages", false, "Interactive diff images", "", "", "");
|
||||||
}
|
}
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
@ -35,6 +35,7 @@ public:
|
|||||||
public:
|
public:
|
||||||
caf::PdmField<QString> applicationWorkingFolder;
|
caf::PdmField<QString> applicationWorkingFolder;
|
||||||
caf::PdmField<QString> regressionTestFolder;
|
caf::PdmField<QString> regressionTestFolder;
|
||||||
|
caf::PdmField<bool> showInteractiveDiffImages;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual void defineEditorAttribute(const caf::PdmFieldHandle* field, QString uiConfigName, caf::PdmUiEditorAttribute* attribute);
|
virtual void defineEditorAttribute(const caf::PdmFieldHandle* field, QString uiConfigName, caf::PdmUiEditorAttribute* attribute);
|
||||||
|
Loading…
Reference in New Issue
Block a user