Skip to content

Commit

Permalink
adjustments to make weird timings due to validation tools work
Browse files Browse the repository at this point in the history
  • Loading branch information
kaa-ching committed Aug 19, 2015
1 parent 1a245e1 commit 7a260d0
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 5 deletions.
32 changes: 27 additions & 5 deletions src/view/RegressionTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,16 @@
#include <QEvent>
#include <QKeyEvent>

#if 1
/// for use with automated testing within Valgrid or Pareon Verify
const qreal theTestMultiplier = 3.0;
const qreal theTestAddition = 0.2;
#else
/// for use without any tools
const qreal theTestMultiplier = 1.0;
const qreal theTestAddition = 0.0;
#endif

RegressionTest::RegressionTest(MainWindow *parent) :
QObject(parent),
theIsWon(false),
Expand All @@ -48,17 +58,23 @@ void RegressionTest::startRegressionRun(void)
void RegressionTest::slot_Fail()
{
DEBUG1("AUTOMATED TESTING, slot_Fail--------------------------");
Q_ASSERT(theIsFail==false);
theIsFail = true;
slotRegressionProgress();
if (theWantWonFail)
{
theWantWonFail = false;
slotRegressionProgress();
}
}

void RegressionTest::slot_Won()
{
DEBUG1("AUTOMATED TESTING, slot_Won--------------------------");
Q_ASSERT(!theIsWon);
theIsWon = true;
slotRegressionProgress();
if (theWantWonFail)
{
theWantWonFail = false;
slotRegressionProgress();
}
}

void RegressionTest::slotRegressionProgress(void)
Expand Down Expand Up @@ -92,11 +108,13 @@ void RegressionTest::slotRegressionProgress(void)
myNextDelay= myLevelDurationSeconds*1000;
theIsWon = false;
theIsFail = false;
theWantWonFail = true;
// Registering for fail event (and success event!) was already done in resizinggraphicsview
myNextState = LEVELFAILED;
break;
}
case LEVELFAILED: // Check for "not success" (i.e. death or timeout)
theWantWonFail = false;
theRegressionTimer.stop();
Q_ASSERT(theIsWon==false);
myNextDelay= 800;
Expand All @@ -107,6 +125,7 @@ void RegressionTest::slotRegressionProgress(void)
break;
case STOPANDRESETLEVEL: // Reset after timeout
{
theWantWonFail = false;
QKeyEvent* myEvent1Ptr = new QKeyEvent ( QEvent::KeyPress, Qt::Key_Space, Qt::NoModifier);
QCoreApplication::postEvent (theMainWindowPtr, myEvent1Ptr);
QKeyEvent* myEvent2Ptr = new QKeyEvent ( QEvent::KeyRelease, Qt::Key_Space, Qt::NoModifier);
Expand Down Expand Up @@ -138,6 +157,7 @@ void RegressionTest::slotRegressionProgress(void)
break;
case STARTLEVELTOWIN: // Start Level, expect success
{
theWantWonFail = true;
QKeyEvent* myEvent1Ptr = new QKeyEvent ( QEvent::KeyPress, Qt::Key_Space, Qt::NoModifier);
QCoreApplication::postEvent (theMainWindowPtr, myEvent1Ptr);
QKeyEvent* myEvent2Ptr = new QKeyEvent ( QEvent::KeyRelease, Qt::Key_Space, Qt::NoModifier);
Expand All @@ -150,10 +170,12 @@ void RegressionTest::slotRegressionProgress(void)
break;
}
case LEVELWON: // Check for success
theWantWonFail = false;
theRegressionTimer.stop();
// TODO: implement
break;
case NEXTLEVEL: // Continue with next item in test
theWantWonFail = false;
// TODO: implement
break;
default:
Expand All @@ -165,5 +187,5 @@ void RegressionTest::slotRegressionProgress(void)
Q_ASSERT(myNextState != START);
theState = myNextState;
Q_ASSERT(myNextDelay!=0);
theRegressionTimer.start(myNextDelay);
theRegressionTimer.start(myNextDelay*theTestMultiplier+theTestAddition);
}
2 changes: 2 additions & 0 deletions src/view/RegressionTest.h
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,8 @@ private slots:

bool theIsWon;
bool theIsFail;
bool theWantWonFail; /// true if slot_Won or slot_Fail should work...

int theLevelIndex;
QStringList theLevels;
MainWindow* theMainWindowPtr;
Expand Down

0 comments on commit 7a260d0

Please sign in to comment.