Commit e670772f authored by Timothy M. Shead's avatar Timothy M. Shead

ENH: Test cases can by recorded to the filesystem in XML format

STYLE: Yet another round of style updates, undoing some mistakes
parent 023a1b70
......@@ -6,6 +6,11 @@ PROJECT(QtTesting)
FIND_PACKAGE(Qt4)
INCLUDE(${QT_USE_FILE})
INCLUDE_DIRECTORIES(
${QtTesting_BINARY_DIR}
${QtTesting_SOURCE_DIR}
)
QT4_WRAP_CPP(MOC_BUILT_SOURCES
pqAbstractSliderEventTranslator.h
pqCheckBoxEventTranslator.h
......@@ -18,10 +23,15 @@ QT4_WRAP_CPP(MOC_BUILT_SOURCES
pqMenuEventTranslator.h
pqMenuEventTranslatorAdaptor.h
pqPushButtonEventTranslator.h
pqRecordEventsDialog.h
pqSpinBoxEventTranslator.h
pqWidgetEventTranslator.h
)
QT4_WRAP_UI(UI_BUILT_SOURCES
pqRecordEventsDialog.ui
)
ADD_LIBRARY(QtTesting
pqAbstractActivateEventPlayer.cxx
pqAbstractActivateEventPlayer.h
......@@ -57,11 +67,14 @@ ADD_LIBRARY(QtTesting
pqMenuEventTranslatorAdaptor.h
pqPushButtonEventTranslator.cxx
pqPushButtonEventTranslator.h
pqRecordEventsDialog.cxx
pqRecordEventsDialog.h
pqSpinBoxEventTranslator.cxx
pqSpinBoxEventTranslator.h
pqWidgetEventPlayer.h
pqWidgetEventTranslator.h
${MOC_BUILT_SOURCES}
${UI_BUILT_SOURCES}
)
TARGET_LINK_LIBRARIES(QtTesting
......
......@@ -13,7 +13,7 @@
#include <QEvent>
pqAbstractSliderEventTranslator::pqAbstractSliderEventTranslator() :
currentObject(0)
CurrentObject(0)
{
}
......@@ -26,12 +26,12 @@ bool pqAbstractSliderEventTranslator::translateEvent(QObject* Object, QEvent* Ev
switch(Event->type())
{
case QEvent::Enter:
this->currentObject = Object;
this->CurrentObject = Object;
connect(object, SIGNAL(valueChanged(int)), this, SLOT(onValueChanged(int)));
break;
case QEvent::Leave:
disconnect(Object, 0, this, 0);
this->currentObject = 0;
this->CurrentObject = 0;
break;
}
......@@ -40,5 +40,5 @@ bool pqAbstractSliderEventTranslator::translateEvent(QObject* Object, QEvent* Ev
void pqAbstractSliderEventTranslator::onValueChanged(int Value)
{
emit recordEvent(this->currentObject, "set_int", QString().setNum(Value));
emit recordEvent(this->CurrentObject, "set_int", QString().setNum(Value));
}
......@@ -27,7 +27,7 @@ private:
pqAbstractSliderEventTranslator(const pqAbstractSliderEventTranslator&);
pqAbstractSliderEventTranslator& operator=(const pqAbstractSliderEventTranslator&);
QObject* currentObject;
QObject* CurrentObject;
private slots:
void onValueChanged(int);
......
......@@ -13,7 +13,7 @@
#include <QEvent>
pqCheckBoxEventTranslator::pqCheckBoxEventTranslator() :
currentObject(0)
CurrentObject(0)
{
}
......@@ -26,12 +26,12 @@ bool pqCheckBoxEventTranslator::translateEvent(QObject* Object, QEvent* Event)
switch(Event->type())
{
case QEvent::Enter:
this->currentObject = Object;
this->CurrentObject = Object;
connect(object, SIGNAL(stateChanged(int)), this, SLOT(onStateChanged(int)));
break;
case QEvent::Leave:
disconnect(Object, 0, this, 0);
this->currentObject = 0;
this->CurrentObject = 0;
break;
}
......@@ -40,5 +40,5 @@ bool pqCheckBoxEventTranslator::translateEvent(QObject* Object, QEvent* Event)
void pqCheckBoxEventTranslator::onStateChanged(int State)
{
emit recordEvent(this->currentObject, "set_boolean", State ? "true" : "false");
emit recordEvent(this->CurrentObject, "set_boolean", State ? "true" : "false");
}
......@@ -27,7 +27,7 @@ private:
pqCheckBoxEventTranslator(const pqCheckBoxEventTranslator&);
pqCheckBoxEventTranslator& operator=(const pqCheckBoxEventTranslator&);
QObject* currentObject;
QObject* CurrentObject;
private slots:
void onStateChanged(int);
......
......@@ -13,7 +13,7 @@
#include <QEvent>
pqComboBoxEventTranslator::pqComboBoxEventTranslator() :
currentObject(0)
CurrentObject(0)
{
}
......@@ -26,14 +26,14 @@ bool pqComboBoxEventTranslator::translateEvent(QObject* Object, QEvent* Event)
switch(Event->type())
{
case QEvent::Enter:
if(this->currentObject != Object)
if(this->CurrentObject != Object)
{
if(this->currentObject)
if(this->CurrentObject)
{
disconnect(this->currentObject, 0, this, 0);
disconnect(this->CurrentObject, 0, this, 0);
}
this->currentObject = Object;
this->CurrentObject = Object;
connect(object, SIGNAL(destroyed(QObject*)), this, SLOT(onDestroyed(QObject*)));
connect(object, SIGNAL(activated(const QString&)), this, SLOT(onStateChanged(const QString&)));
connect(object, SIGNAL(editTextChanged(const QString&)), this, SLOT(onStateChanged(const QString&)));
......@@ -46,10 +46,10 @@ bool pqComboBoxEventTranslator::translateEvent(QObject* Object, QEvent* Event)
void pqComboBoxEventTranslator::onDestroyed(QObject* Object)
{
this->currentObject = 0;
this->CurrentObject = 0;
}
void pqComboBoxEventTranslator::onStateChanged(const QString& State)
{
emit recordEvent(this->currentObject, "set_string", State);
emit recordEvent(this->CurrentObject, "set_string", State);
}
......@@ -27,7 +27,7 @@ private:
pqComboBoxEventTranslator(const pqComboBoxEventTranslator&);
pqComboBoxEventTranslator& operator=(const pqComboBoxEventTranslator&);
QObject* currentObject;
QObject* CurrentObject;
private slots:
void onDestroyed(QObject*);
......
......@@ -13,7 +13,7 @@
#include <QEvent>
pqDoubleSpinBoxEventTranslator::pqDoubleSpinBoxEventTranslator() :
currentObject(0)
CurrentObject(0)
{
}
......@@ -26,12 +26,12 @@ bool pqDoubleSpinBoxEventTranslator::translateEvent(QObject* Object, QEvent* Eve
switch(Event->type())
{
case QEvent::Enter:
this->currentObject = Object;
this->CurrentObject = Object;
connect(object, SIGNAL(valueChanged(double)), this, SLOT(onValueChanged(double)));
break;
case QEvent::Leave:
disconnect(Object, 0, this, 0);
this->currentObject = 0;
this->CurrentObject = 0;
break;
}
......@@ -40,5 +40,5 @@ bool pqDoubleSpinBoxEventTranslator::translateEvent(QObject* Object, QEvent* Eve
void pqDoubleSpinBoxEventTranslator::onValueChanged(double Value)
{
emit recordEvent(this->currentObject, "set_double", QString().setNum(Value));
emit recordEvent(this->CurrentObject, "set_double", QString().setNum(Value));
}
......@@ -27,7 +27,7 @@ private:
pqDoubleSpinBoxEventTranslator(const pqDoubleSpinBoxEventTranslator&);
pqDoubleSpinBoxEventTranslator& operator=(const pqDoubleSpinBoxEventTranslator&);
QObject* currentObject;
QObject* CurrentObject;
private slots:
void onValueChanged(double);
......
......@@ -13,6 +13,13 @@
void pqEventObserverStdout::onRecordEvent(const QString& Widget, const QString& Command, const QString& Arguments)
{
cout << "event: " << Widget.toAscii().data() << " " << Command.toAscii().data() << " " << Arguments.toAscii().data() << endl;
cout
<< "event: "
<< Widget.toAscii().data()
<< " "
<< Command.toAscii().data()
<< " "
<< Arguments.toAscii().data()
<< endl;
}
......@@ -9,21 +9,21 @@
#include "pqEventObserverXML.h"
pqEventObserverXML::pqEventObserverXML(ostream& Stream) :
stream(Stream)
pqEventObserverXML::pqEventObserverXML(ostream& stream) :
Stream(stream)
{
this->stream << "<?xml version=\"1.0\" ?>\n";
this->stream << "<pqevents>\n";
this->Stream << "<?xml version=\"1.0\" ?>\n";
this->Stream << "<pqevents>\n";
}
pqEventObserverXML::~pqEventObserverXML()
{
this->stream << "</pqevents>\n";
this->Stream << "</pqevents>\n";
}
void pqEventObserverXML::onRecordEvent(const QString& Widget, const QString& Command, const QString& Arguments)
{
this->stream
this->Stream
<< "\t<pqevent><widget>"
<< Widget.toAscii().data()
<< "</widget><command>"
......
......@@ -28,7 +28,7 @@ public slots:
private:
/// Stores a stream that will be used to store the XML output
ostream& stream;
ostream& Stream;
};
#endif // !_pqEventObserverXML_h
......
......@@ -39,15 +39,15 @@ QObject* pqFindObjectByName(QObject& Object, const QString& Name)
} // namespace
pqEventPlayer::pqEventPlayer(QObject& RootObject) :
root_object(RootObject)
pqEventPlayer::pqEventPlayer(QObject& root) :
RootObject(root)
{
}
pqEventPlayer::~pqEventPlayer()
{
for(int i = 0; i != this->players.size(); ++i)
delete this->players[i];
for(int i = 0; i != this->Players.size(); ++i)
delete this->Players[i];
}
void pqEventPlayer::addDefaultWidgetEventPlayers()
......@@ -63,19 +63,19 @@ void pqEventPlayer::addWidgetEventPlayer(pqWidgetEventPlayer* Player)
{
if(Player)
{
this->players.push_back(Player);
this->Players.push_back(Player);
}
}
bool pqEventPlayer::playEvent(const QString& Object, const QString& Command, const QString& Arguments)
{
QObject* object = pqFindObjectByName(root_object, Object);
QObject* object = pqFindObjectByName(RootObject, Object);
if(!object)
return false;
for(int i = 0; i != this->players.size(); ++i)
for(int i = 0; i != this->Players.size(); ++i)
{
if(this->players[i]->playEvent(object, Command, Arguments))
if(this->Players[i]->playEvent(object, Command, Arguments))
return true;
}
......
......@@ -36,9 +36,9 @@ private:
pqEventPlayer& operator=(const pqEventPlayer&);
/// Stores the working set of widget players
QVector<pqWidgetEventPlayer*> players;
QVector<pqWidgetEventPlayer*> Players;
/// Stores the root of the Qt object hierarchy
QObject& root_object;
QObject& RootObject;
};
#endif // !_pqEventPlayer_h
......
......@@ -30,8 +30,8 @@ pqEventTranslator::~pqEventTranslator()
{
QCoreApplication::instance()->removeEventFilter(this);
for(int i = 0; i != this->translators.size(); ++i)
delete this->translators[i];
for(int i = 0; i != this->Translators.size(); ++i)
delete this->Translators[i];
}
void pqEventTranslator::addDefaultWidgetEventTranslators()
......@@ -50,7 +50,7 @@ void pqEventTranslator::addWidgetEventTranslator(pqWidgetEventTranslator* Transl
{
if(Translator)
{
this->translators.push_back(Translator);
this->Translators.push_back(Translator);
QObject::connect(
Translator,
......@@ -62,9 +62,9 @@ void pqEventTranslator::addWidgetEventTranslator(pqWidgetEventTranslator* Transl
bool pqEventTranslator::eventFilter(QObject* Object, QEvent* Event)
{
for(int i = 0; i != this->translators.size(); ++i)
for(int i = 0; i != this->Translators.size(); ++i)
{
if(this->translators[i]->translateEvent(Object, Event))
if(this->Translators[i]->translateEvent(Object, Event))
return false;
}
......
......@@ -41,7 +41,7 @@ private:
bool eventFilter(QObject* Object, QEvent* Event);
/// Stores the working set of widget translators
QVector<pqWidgetEventTranslator*> translators;
QVector<pqWidgetEventTranslator*> Translators;
private slots:
void onRecordEvent(QObject* Object, const QString& Command, const QString& Arguments);
......
......@@ -13,7 +13,7 @@
#include <QEvent>
pqLineEditEventTranslator::pqLineEditEventTranslator() :
currentObject(0)
CurrentObject(0)
{
}
......@@ -26,12 +26,12 @@ bool pqLineEditEventTranslator::translateEvent(QObject* Object, QEvent* Event)
switch(Event->type())
{
case QEvent::Enter:
this->currentObject = Object;
this->CurrentObject = Object;
connect(object, SIGNAL(textEdited(const QString&)), this, SLOT(onStateChanged(const QString&)));
break;
case QEvent::Leave:
disconnect(Object, 0, this, 0);
this->currentObject = 0;
this->CurrentObject = 0;
break;
}
......@@ -40,5 +40,5 @@ bool pqLineEditEventTranslator::translateEvent(QObject* Object, QEvent* Event)
void pqLineEditEventTranslator::onStateChanged(const QString& State)
{
emit recordEvent(this->currentObject, "set_string", State);
emit recordEvent(this->CurrentObject, "set_string", State);
}
......@@ -27,7 +27,7 @@ private:
pqLineEditEventTranslator(const pqLineEditEventTranslator&);
pqLineEditEventTranslator& operator=(const pqLineEditEventTranslator&);
QObject* currentObject;
QObject* CurrentObject;
private slots:
void onStateChanged(const QString&);
......
......@@ -36,7 +36,7 @@ bool pqMenuEventTranslator::translateEvent(QObject* Object, QEvent* Event)
for(int i = 0; i != actions.size(); ++i)
{
pqMenuEventTranslatorAdaptor* const adaptor = new pqMenuEventTranslatorAdaptor(actions[i]);
this->actions.push_back(adaptor);
this->Actions.push_back(adaptor);
QObject::connect(
adaptor,
SIGNAL(recordEvent(QObject*, const QString&, const QString&)),
......@@ -55,10 +55,9 @@ bool pqMenuEventTranslator::translateEvent(QObject* Object, QEvent* Event)
void pqMenuEventTranslator::clearActions()
{
for(int i = 0; i != this->actions.size(); ++i)
delete this->actions[i];
this->actions.clear();
for(int i = 0; i != this->Actions.size(); ++i)
delete this->Actions[i];
this->Actions.clear();
}
void pqMenuEventTranslator::onRecordEvent(QObject* Object, const QString& Command, const QString& Arguments)
......
......@@ -32,7 +32,7 @@ private:
void clearActions();
QList<pqMenuEventTranslatorAdaptor*> actions;
QList<pqMenuEventTranslatorAdaptor*> Actions;
private slots:
void onRecordEvent(QObject*, const QString&, const QString&);
......
......@@ -11,13 +11,13 @@
#include <QAction>
pqMenuEventTranslatorAdaptor::pqMenuEventTranslatorAdaptor(QAction* Action) :
action(Action)
pqMenuEventTranslatorAdaptor::pqMenuEventTranslatorAdaptor(QAction* action) :
Action(action)
{
QObject::connect(action, SIGNAL(triggered(bool)), this, SLOT(onTriggered(bool)));
}
void pqMenuEventTranslatorAdaptor::onTriggered(bool)
{
recordEvent(action, "activate", "");
recordEvent(Action, "activate", "");
}
......@@ -29,7 +29,7 @@ private:
pqMenuEventTranslatorAdaptor(const pqMenuEventTranslatorAdaptor&);
pqMenuEventTranslatorAdaptor& operator=(const pqMenuEventTranslatorAdaptor&);
QAction* const action;
QAction* const Action;
private slots:
void onTriggered(bool);
......
......@@ -13,7 +13,7 @@
#include <QEvent>
pqPushButtonEventTranslator::pqPushButtonEventTranslator() :
currentObject(0)
CurrentObject(0)
{
}
......@@ -26,12 +26,12 @@ bool pqPushButtonEventTranslator::translateEvent(QObject* Object, QEvent* Event)
switch(Event->type())
{
case QEvent::Enter:
this->currentObject = Object;
this->CurrentObject = Object;
connect(object, SIGNAL(clicked(bool)), this, SLOT(onClicked(bool)));
break;
case QEvent::Leave:
disconnect(Object, 0, this, 0);
this->currentObject = 0;
this->CurrentObject = 0;
break;
}
......@@ -40,5 +40,5 @@ bool pqPushButtonEventTranslator::translateEvent(QObject* Object, QEvent* Event)
void pqPushButtonEventTranslator::onClicked(bool)
{
emit recordEvent(this->currentObject, "activate", "");
emit recordEvent(this->CurrentObject, "activate", "");
}
......@@ -27,7 +27,7 @@ private:
pqPushButtonEventTranslator(const pqPushButtonEventTranslator&);
pqPushButtonEventTranslator& operator=(const pqPushButtonEventTranslator&);
QObject* currentObject;
QObject* CurrentObject;
private slots:
void onClicked(bool);
......
/*
* Copyright 2004 Sandia Corporation.
* Under the terms of Contract DE-AC04-94AL85000, there is a non-exclusive
* license for use of this work by or on behalf of the
* U.S. Government. Redistribution and use in source and binary forms, with
* or without modification, are permitted provided that this Notice and any
* statement of authorship are reproduced on all copies.
*/
#include "pqRecordEventsDialog.h"
#include "pqEventObserverXML.h"
#include "pqEventTranslator.h"
#include <QPushButton>
#include <QTimer>
#include <vtkIOStream.h>
class pqRecordEventsDialog::pqImplementation
{
public:
pqImplementation(const QString& Path) :
file(Path.toAscii().data()),
observer(file)
{
translator.addDefaultWidgetEventTranslators();
QObject::connect(
&translator,
SIGNAL(recordEvent(const QString&, const QString&, const QString&)),
&observer,
SLOT(onRecordEvent(const QString&, const QString&, const QString&)));
}
private:
ofstream file;
pqEventTranslator translator;
pqEventObserverXML observer;
};
pqRecordEventsDialog::pqRecordEventsDialog(const QString& Path, QWidget* Parent) :
QDialog(Parent),
Implementation(new pqImplementation(Path))
{
this->Ui.setupUi(this);
this->Ui.label->setText(QString(tr("Recording User Input to %1")).arg(Path));
this->setWindowTitle(tr("Recording User Input"));
this->setObjectName("RecordEventsDialog");
}
pqRecordEventsDialog::~pqRecordEventsDialog()
{
delete Implementation;
}
void pqRecordEventsDialog::accept()
{
QDialog::accept();
QTimer::singleShot(0, this, SLOT(onAutoDelete()));
}
void pqRecordEventsDialog::reject()
{
QDialog::reject();
QTimer::singleShot(0, this, SLOT(onAutoDelete()));
}
void pqRecordEventsDialog::onAutoDelete()
{
delete this;
}
/*
* Copyright 2004 Sandia Corporation.
* Under the terms of Contract DE-AC04-94AL85000, there is a non-exclusive
* license for use of this work by or on behalf of the
* U.S. Government. Redistribution and use in source and binary forms, with
* or without modification, are permitted provided that this Notice and any
* statement of authorship are reproduced on all copies.
*/
#ifndef _pqRecordEventsDialog_h
#define _pqRecordEventsDialog_h
#include "ui_pqRecordEventsDialog.h"
class pqRecordEventsDialog :
public QDialog
{
Q_OBJECT
public:
pqRecordEventsDialog(const QString& Path, QWidget* Parent);
private:
pqRecordEventsDialog(const pqRecordEventsDialog&);
pqRecordEventsDialog& operator=(const pqRecordEventsDialog&);
~pqRecordEventsDialog();
class pqImplementation;
pqImplementation* const Implementation;
Ui::pqRecordEventsDialog Ui;
private slots:
void accept();
void reject();
void onAutoDelete();
};
#endif // !_pqRecordEventsDialog_h
<ui version="4.0" >
<author></author>
<comment></comment>
<exportmacro></exportmacro>
<class>pqRecordEventsDialog</class>
<widget class="QDialog" name="pqRecordEventsDialog" >
<property name="geometry" >
<rect>
<x>0</x>
<y>0</y>
<width>366</width>
<height>76</height>
</rect>
</property>
<property name="windowTitle" >
<string>Dialog</string>
</property>
<layout class="QVBoxLayout" >
<property name="margin" >
<number>8</number>
</property>
<property name="spacing" >
<number>6</number>
</property>
<item>
<widget class="QLabel" name="label" >
<property name="sizePolicy" >
<sizepolicy>
<hsizetype>5</hsizetype>
<vsizetype>3</vsizetype>
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text" >
<string>Recording User Events to /home/tshead/test_cases/foo</string>
</property>
<property name="alignment" >
<set>Qt::AlignHCenter</set>
</property>
</widget>
</item>
<item>
<layout class="QHBoxLayout" >
<property name="margin" >
<number>0</number>
</property>
<property name="spacing" >
<number>6</number>
</property>
<item>
<spacer>
<property name="orientation" >
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" >
<size>
<width>131</width>
<height>31</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QPushButton" name="stopButton" >
<property name="text" >
<string>Stop Recording</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
<pixmapfunction></pixmapfunction>
<resources/>
<connections>
<connection>
<sender>stopButton</sender>
<signal>clicked()</signal>
<receiver>pqRecordEventsDialog</receiver>
<slot>accept()</slot>
<hints>
<hint type="sourcelabel" >
<x>313</x>
<y>46</y>
</hint>
<hint type="destinationlabel" >
<x>84</x>
<y>36</y>
</hint>
</hints>
</connection>
</connections>
</ui>
......@@ -13,7 +13,7 @@
#include <QEvent>
pqSpinBoxEventTranslator::pqSpinBoxEventTranslator() :
currentObject(0)
CurrentObject(0)
{
}
......@@ -26,12 +26,12 @@ bool pqSpinBoxEventTranslator::translateEvent(QObject* Object, QEvent* Event)
switch(Event->type())
{
case QEvent::Enter:
this->currentObject = Object;
this->CurrentObject = Object;
connect(object, SIGNAL(valueChanged(int)), this, SLOT(onValueChanged(int)));
break;
case QEvent::Leave:
disconnect(Object, 0, this, 0);
this->currentObject = 0;
this->CurrentObject = 0;
break;
}