Updates will be applied April 15th at 12pm EDT (UTC-0400). GitLab could be a little slow between 12 - 12:45pm EDT.

Commit d20436ef authored by Benjamin Long's avatar Benjamin Long

Add generic function to record/restore property for QObject

parent 2e720a59
...@@ -82,7 +82,7 @@ public: ...@@ -82,7 +82,7 @@ public:
~XMLEventSource() { delete this->XMLStream; } ~XMLEventSource() { delete this->XMLStream; }
protected: protected:
virtual void setContent(const QString& xmlfilename) virtual bool setContent(const QString& xmlfilename)
{ {
delete this->XMLStream; delete this->XMLStream;
this->XMLStream = NULL; this->XMLStream = NULL;
...@@ -91,7 +91,7 @@ protected: ...@@ -91,7 +91,7 @@ protected:
if (!xml.open(QIODevice::ReadOnly)) if (!xml.open(QIODevice::ReadOnly))
{ {
qDebug() << "Failed to load " << xmlfilename; qDebug() << "Failed to load " << xmlfilename;
return; return false;
} }
QByteArray data = xml.readAll(); QByteArray data = xml.readAll();
this->XMLStream = new QXmlStreamReader(data); this->XMLStream = new QXmlStreamReader(data);
...@@ -114,6 +114,7 @@ protected: ...@@ -114,6 +114,7 @@ protected:
{ {
qDebug() << "Invalid xml" << endl; qDebug() << "Invalid xml" << endl;
} }
return true;
} }
int getNextEvent(QString& widget, QString& command, QString& int getNextEvent(QString& widget, QString& command, QString&
......
...@@ -58,7 +58,7 @@ public: ...@@ -58,7 +58,7 @@ public:
/** Set the filename for contents. /** Set the filename for contents.
Returns true for valid file, false for invalid file */ Returns true for valid file, false for invalid file */
virtual void setContent(const QString& filename) = 0; virtual bool setContent(const QString& filename) = 0;
/** tell the source to stop feeding in events */ /** tell the source to stop feeding in events */
virtual void stop() {} virtual void stop() {}
......
...@@ -174,7 +174,14 @@ bool pqTestUtility::playTests(const QStringList& filenames) ...@@ -174,7 +174,14 @@ bool pqTestUtility::playTests(const QStringList& filenames)
iter = this->EventSources.find(suffix); iter = this->EventSources.find(suffix);
if(info.isReadable() && iter != this->EventSources.end()) if(info.isReadable() && iter != this->EventSources.end())
{ {
iter.value()->setContent(filename); if(!iter.value()->setContent(filename))
{
return false;
}
// QEventLoop loop;
// QTimer::singleShot(100, &loop, SLOT(quit()));
// loop.exec();
QApplication::processEvents();
if (!this->Dispatcher.playEvents(*iter.value(), this->Player)) if (!this->Dispatcher.playEvents(*iter.value(), this->Player))
{ {
// dispatcher returned failure, don't continue with rest of the tests // dispatcher returned failure, don't continue with rest of the tests
...@@ -233,6 +240,17 @@ void pqTestUtility::recordTests(const QString& filename) ...@@ -233,6 +240,17 @@ void pqTestUtility::recordTests(const QString& filename)
dialog->show(); dialog->show();
} }
// ----------------------------------------------------------------------------
void pqTestUtility::addObjectStateProperty(QObject* object, const QString& property)
{
this->ObjectStateProperty[object] = property;
}
// ----------------------------------------------------------------------------
QMap<QObject*, QString> pqTestUtility::objectStateProperty() const
{
return this->ObjectStateProperty;
}
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
void pqTestUtility::addDataDirectory(const QString& label, const QDir& path) void pqTestUtility::addDataDirectory(const QString& label, const QDir& path)
{ {
......
...@@ -93,6 +93,10 @@ public: ...@@ -93,6 +93,10 @@ public:
/// start the recording of tests to a file /// start the recording of tests to a file
Q_INVOKABLE void recordTests(const QString& filename); Q_INVOKABLE void recordTests(const QString& filename);
/// Add custom object properties, which will be saved during the recording
/// and restored before the playback
void addObjectStateProperty(QObject* object, const QString& property);
QMap<QObject*, QString> objectStateProperty() const;
/// add a directory for recording/playback of file dialogs /// add a directory for recording/playback of file dialogs
void addDataDirectory(const QString& label, const QDir& path); void addDataDirectory(const QString& label, const QDir& path);
...@@ -125,7 +129,8 @@ protected: ...@@ -125,7 +129,8 @@ protected:
QMap<QString, pqEventSource*> EventSources; QMap<QString, pqEventSource*> EventSources;
QMap<QString, pqEventObserver*> EventObservers; QMap<QString, pqEventObserver*> EventObservers;
QMap<QString, QDir> DataDirectories; QMap<QString, QDir> DataDirectories;
QMap<QObject*, QString> ObjectStateProperty;
}; };
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment