Skip to content

Commit

Permalink
Showing 4,020 changed files with 19,745 additions and 176,705 deletions.
The diff you're trying to view is too large. We only load the first 3000 changed files.
190 changes: 144 additions & 46 deletions ApplicationCode/Application/RiaApplication.cpp
Original file line number Diff line number Diff line change
@@ -145,7 +145,7 @@ namespace RegTestNames
const QString generatedFolderName = "RegTestGeneratedImages";
const QString diffFolderName = "RegTestDiffImages";
const QString baseFolderName = "RegTestBaseImages";
const QString testProjectName = "RegressionTest.rip";
const QString testProjectName = "RegressionTest";
const QString testFolderFilter = "TestCase*";
const QString imageCompareExeName = "compare";
const QString reportFileName = "ResInsightRegressionTestReport.html";
@@ -350,7 +350,7 @@ bool RiaApplication::loadProject(const QString& projectFileName, ProjectLoadActi
// Open the project file and read the serialized data.
// Will initialize itself.

if (!QFile::exists(projectFileName))
if (!caf::Utils::fileExists(projectFileName))
{
RiaLogging::info(QString("File does not exist : '%1'").arg(projectFileName));
return false;
@@ -718,7 +718,7 @@ bool RiaApplication::saveProject()
{
CVF_ASSERT(m_project.notNull());

if (!QFile::exists(m_project->fileName()))
if (!caf::Utils::fileExists(m_project->fileName()))
{
return saveProjectPromptForFileName();
}
@@ -944,7 +944,7 @@ QString RiaApplication::createAbsolutePathFromProjectRelativePath(QString projec
//--------------------------------------------------------------------------------------------------
bool RiaApplication::openEclipseCaseFromFile(const QString& fileName)
{
if (!QFile::exists(fileName)) return false;
if (!caf::Utils::fileExists(fileName)) return false;

QFileInfo gridFileName(fileName);
QString caseName = gridFileName.completeBaseName();
@@ -1138,7 +1138,7 @@ bool RiaApplication::openInputEclipseCaseFromFileNames(const QStringList& fileNa
//--------------------------------------------------------------------------------------------------
bool RiaApplication::openOdbCaseFromFile(const QString& fileName)
{
if (!QFile::exists(fileName)) return false;
if (!caf::Utils::fileExists(fileName)) return false;

QFileInfo gridFileName(fileName);
QString caseName = gridFileName.completeBaseName();
@@ -1424,7 +1424,8 @@ bool RiaApplication::parseArguments()
std::vector<QString> gridFiles = readFileListFromTextFile(gridListFile);
runMultiCaseSnapshots(projectFileName, gridFiles, "multiCaseSnapshots");

closeProject();
closeAllWindows();
processEvents();

return false;
}
@@ -1503,14 +1504,14 @@ bool RiaApplication::parseArguments()
foreach (QString caseName, caseNames)
{
QString caseFileNameWithExt = caseName + ".EGRID";
if (QFile::exists(caseFileNameWithExt))
if (!caf::Utils::fileExists(caseFileNameWithExt))
{
openEclipseCaseFromFile(caseFileNameWithExt);
}
else
{
caseFileNameWithExt = caseName + ".GRID";
if (QFile::exists(caseFileNameWithExt))
if (!caf::Utils::fileExists(caseFileNameWithExt))
{
openEclipseCaseFromFile(caseFileNameWithExt);
}
@@ -1577,7 +1578,8 @@ bool RiaApplication::parseArguments()
}
}

closeProject();
closeAllWindows();
processEvents();
}

// Returning false will exit the application
@@ -1733,6 +1735,24 @@ RimViewWindow* RiaApplication::activeViewWindow()
return viewWindow;
}

//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RiaApplication::isMain3dWindowVisible() const
{
return RiuMainWindow::instance()->isVisible();
}

//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RiaApplication::isMainPlotWindowVisible() const
{
if (!m_mainPlotWindow) return false;

return m_mainPlotWindow->isVisible();
}

//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
@@ -2140,7 +2160,7 @@ void RiaApplication::setLastUsedDialogDirectory(const QString& dialogName, const
//--------------------------------------------------------------------------------------------------
bool RiaApplication::openFile(const QString& fileName)
{
if (!QFile::exists(fileName)) return false;
if (!caf::Utils::fileExists(fileName)) return false;

bool loadingSucceded = false;

@@ -2284,6 +2304,18 @@ void removeDirectoryWithContent(QDir dirToDelete )
dirToDelete.rmdir(".");
}

//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void logInfoTextWithTimeInSeconds(const QTime& time, const QString& msg)
{
double timeRunning = time.elapsed() / 1000.0;

QString timeText = QString("(%1 s) ").arg(timeRunning, 0, 'f', 1);

RiaLogging::info(timeText + msg);
}

//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
@@ -2340,6 +2372,11 @@ void RiaApplication::runRegressionTest(const QString& testRootPath)
}
}

QTime timeStamp;
timeStamp.start();

logInfoTextWithTimeInSeconds(timeStamp, "Starting regression tests\n");

for (int dirIdx = 0; dirIdx < folderList.size(); ++dirIdx)
{
QDir testCaseFolder(folderList[dirIdx].filePath());
@@ -2361,49 +2398,103 @@ void RiaApplication::runRegressionTest(const QString& testRootPath)
for (int dirIdx = 0; dirIdx < folderList.size(); ++dirIdx)
{
QDir testCaseFolder(folderList[dirIdx].filePath());
if (testCaseFolder.exists(regTestProjectName))

QString projectFileName;

if (testCaseFolder.exists(regTestProjectName + ".rip"))
{
projectFileName = regTestProjectName + ".rip";
}

if (testCaseFolder.exists(regTestProjectName + ".rsp"))
{
loadProject(testCaseFolder.filePath(regTestProjectName));

// Wait until all command objects have completed
while (!m_commandQueueLock.tryLock())
{
processEvents();
}
m_commandQueueLock.unlock();

regressionTestConfigureProject();

QString fullPathGeneratedFolder = testCaseFolder.absoluteFilePath(generatedFolderName);
saveSnapshotForAllViews(fullPathGeneratedFolder);

RicSnapshotAllPlotsToFileFeature::exportSnapshotOfAllPlotsIntoFolder(fullPathGeneratedFolder);

QDir baseDir(testCaseFolder.filePath(baseFolderName));
QDir genDir(testCaseFolder.filePath(generatedFolderName));
QDir diffDir(testCaseFolder.filePath(diffFolderName));
if (!diffDir.exists()) testCaseFolder.mkdir(diffFolderName);
baseDir.setFilter(QDir::Files);
QStringList baseImageFileNames = baseDir.entryList();

for (int fIdx = 0; fIdx < baseImageFileNames.size(); ++fIdx)
{
QString fileName = baseImageFileNames[fIdx];
RiaImageFileCompare imgComparator(RegTestNames::imageCompareExeName);
bool ok = imgComparator.runComparison(genDir.filePath(fileName), baseDir.filePath(fileName), diffDir.filePath(fileName));
if (!ok)
{
projectFileName = regTestProjectName + ".rsp";
}

if (!projectFileName.isEmpty())
{
logInfoTextWithTimeInSeconds(timeStamp, "Initializing test :" + testCaseFolder.absolutePath());

loadProject(testCaseFolder.filePath(projectFileName));

// Wait until all command objects have completed
while (!m_commandQueueLock.tryLock())
{
processEvents();
}
m_commandQueueLock.unlock();

regressionTestConfigureProject();

resizeMaximizedPlotWindows();

QString fullPathGeneratedFolder = testCaseFolder.absoluteFilePath(generatedFolderName);
saveSnapshotForAllViews(fullPathGeneratedFolder);

RicSnapshotAllPlotsToFileFeature::exportSnapshotOfAllPlotsIntoFolder(fullPathGeneratedFolder);

QDir baseDir(testCaseFolder.filePath(baseFolderName));
QDir genDir(testCaseFolder.filePath(generatedFolderName));
QDir diffDir(testCaseFolder.filePath(diffFolderName));
if (!diffDir.exists()) testCaseFolder.mkdir(diffFolderName);
baseDir.setFilter(QDir::Files);
QStringList baseImageFileNames = baseDir.entryList();

for (int fIdx = 0; fIdx < baseImageFileNames.size(); ++fIdx)
{
QString fileName = baseImageFileNames[fIdx];
RiaImageFileCompare imgComparator(RegTestNames::imageCompareExeName);
bool ok = imgComparator.runComparison(genDir.filePath(fileName), baseDir.filePath(fileName), diffDir.filePath(fileName));
if (!ok)
{
qDebug() << "Error comparing :" << imgComparator.errorMessage() << "\n" << imgComparator.errorDetails();
}
}
}
}

closeProject();
closeProject();

logInfoTextWithTimeInSeconds(timeStamp, "Completed test :" + testCaseFolder.absolutePath());
}
}

RiaLogging::info("\n");
logInfoTextWithTimeInSeconds(timeStamp, "Completed regression tests");

m_runningRegressionTests = false;
}

//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RiaApplication::resizeMaximizedPlotWindows()
{
std::vector<RimViewWindow*> viewWindows;
m_project->mainPlotCollection()->descendantsIncludingThisOfType(viewWindows);

for (auto viewWindow : viewWindows)
{
if (viewWindow->isMdiWindow())
{
RimMdiWindowGeometry wndGeo = viewWindow->mdiWindowGeometry();
if (wndGeo.isMaximized)
{
QWidget* viewWidget = viewWindow->viewWidget();

if (viewWidget)
{
QMdiSubWindow* mdiWindow = m_mainPlotWindow->findMdiSubWindow(viewWidget);
if (mdiWindow)
{
mdiWindow->showNormal();

viewWidget->resize(RiaApplication::regressionDefaultImageSize());
}
}
}
}
}
}

//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
@@ -2798,7 +2889,6 @@ void RiaApplication::executeRegressionTests(const QString& regressionTestPath)
}
}


//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
@@ -2833,8 +2923,16 @@ void RiaApplication::regressionTestConfigureProject()
}

// This size is set to match the regression test reference images
riv->viewer()->setFixedSize(1000, 745);
riv->viewer()->setFixedSize(RiaApplication::regressionDefaultImageSize());
}
}
}
}

//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
QSize RiaApplication::regressionDefaultImageSize()
{
return QSize(1000, 745);
}
10 changes: 8 additions & 2 deletions ApplicationCode/Application/RiaApplication.h
Original file line number Diff line number Diff line change
@@ -137,8 +137,6 @@ class RiaApplication : public QApplication
void saveSnapshotForAllViews(const QString& snapshotFolderName);
void runMultiCaseSnapshots(const QString& templateProjectFileName, std::vector<QString> gridFileNames, const QString& snapshotFolderName);
void runRegressionTest(const QString& testRootPath);
void updateRegressionTest(const QString& testRootPath );
void regressionTestConfigureProject();

void processNonGuiEvents();

@@ -187,6 +185,9 @@ class RiaApplication : public QApplication

static RimViewWindow* activeViewWindow();

bool isMain3dWindowVisible() const;
bool isMainPlotWindowVisible() const;

bool tryCloseMainWindow();
bool tryClosePlotWindow();

@@ -215,6 +216,11 @@ class RiaApplication : public QApplication

void storeTreeViewState();

void resizeMaximizedPlotWindows();
void updateRegressionTest(const QString& testRootPath);
void regressionTestConfigureProject();
static QSize regressionDefaultImageSize();

private slots:
void slotWorkerProcessFinished(int exitCode, QProcess::ExitStatus exitStatus);
void slotUpdateScheduledDisplayModels();
Loading
Oops, something went wrong.

0 comments on commit a45aee0

Please sign in to comment.