Commit 023a1b70 authored by Timothy M. Shead's avatar Timothy M. Shead Committed by Brad King

ENH: Moved Qt testing-related code into separate QtTesting library

This commit was manufactured as the start of QtTesting when splitting
its history out from the ParaView Qt/Testing directory.  The content
came from ParaView commit c1620c50ee6410c491651f8618c0d21cb3796368.
parents
CMAKE_MINIMUM_REQUIRED(VERSION 2.2)
PROJECT(QtTesting)
FIND_PACKAGE(Qt4)
INCLUDE(${QT_USE_FILE})
QT4_WRAP_CPP(MOC_BUILT_SOURCES
pqAbstractSliderEventTranslator.h
pqCheckBoxEventTranslator.h
pqComboBoxEventTranslator.h
pqDoubleSpinBoxEventTranslator.h
pqEventObserverStdout.h
pqEventObserverXML.h
pqEventTranslator.h
pqLineEditEventTranslator.h
pqMenuEventTranslator.h
pqMenuEventTranslatorAdaptor.h
pqPushButtonEventTranslator.h
pqSpinBoxEventTranslator.h
pqWidgetEventTranslator.h
)
ADD_LIBRARY(QtTesting
pqAbstractActivateEventPlayer.cxx
pqAbstractActivateEventPlayer.h
pqAbstractBooleanEventPlayer.cxx
pqAbstractBooleanEventPlayer.h
pqAbstractDoubleEventPlayer.cxx
pqAbstractDoubleEventPlayer.h
pqAbstractIntEventPlayer.cxx
pqAbstractIntEventPlayer.h
pqAbstractSliderEventTranslator.cxx
pqAbstractSliderEventTranslator.h
pqAbstractStringEventPlayer.cxx
pqAbstractStringEventPlayer.h
pqCheckBoxEventTranslator.cxx
pqCheckBoxEventTranslator.h
pqComboBoxEventTranslator.cxx
pqComboBoxEventTranslator.h
pqDoubleSpinBoxEventTranslator.cxx
pqDoubleSpinBoxEventTranslator.h
pqEventObserverStdout.cxx
pqEventObserverStdout.h
pqEventObserverXML.cxx
pqEventObserverXML.h
pqEventPlayer.cxx
pqEventPlayer.h
pqEventTranslator.cxx
pqEventTranslator.h
pqLineEditEventTranslator.cxx
pqLineEditEventTranslator.h
pqMenuEventTranslator.cxx
pqMenuEventTranslator.h
pqMenuEventTranslatorAdaptor.cxx
pqMenuEventTranslatorAdaptor.h
pqPushButtonEventTranslator.cxx
pqPushButtonEventTranslator.h
pqSpinBoxEventTranslator.cxx
pqSpinBoxEventTranslator.h
pqWidgetEventPlayer.h
pqWidgetEventTranslator.h
${MOC_BUILT_SOURCES}
)
TARGET_LINK_LIBRARIES(QtTesting
${QT_LIBRARIES}
${JPEG_LIBRARY}
${PNG_LIBRARY}
${FREETYPE_LIBRARY}
)
/*
* 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 "pqAbstractActivateEventPlayer.h"
#include <QAction>
#include <QPushButton>
pqAbstractActivateEventPlayer::pqAbstractActivateEventPlayer()
{
}
bool pqAbstractActivateEventPlayer::playEvent(QObject* Object, const QString& Command, const QString& Arguments)
{
if(Command != "activate")
return false;
if(QAction* const object = qobject_cast<QAction*>(Object))
{
object->activate(QAction::Trigger);
return true;
}
if(QPushButton* const object = qobject_cast<QPushButton*>(Object))
{
object->click();
return true;
}
return false;
}
/*
* 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 _pqAbstractActivateEventPlayer_h
#define _pqAbstractActivateEventPlayer_h
#include "pqWidgetEventPlayer.h"
/// Translates high-level ParaQ events into low-level Qt action events
class pqAbstractActivateEventPlayer :
public pqWidgetEventPlayer
{
public:
pqAbstractActivateEventPlayer();
bool playEvent(QObject* Object, const QString& Command, const QString& Arguments);
private:
pqAbstractActivateEventPlayer(const pqAbstractActivateEventPlayer&);
pqAbstractActivateEventPlayer& operator=(const pqAbstractActivateEventPlayer&);
};
#endif // !_pqAbstractActivateEventPlayer_h
/*
* 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 "pqAbstractBooleanEventPlayer.h"
#include <QCheckBox>
pqAbstractBooleanEventPlayer::pqAbstractBooleanEventPlayer()
{
}
bool pqAbstractBooleanEventPlayer::playEvent(QObject* Object, const QString& Command, const QString& Arguments)
{
if(Command != "set_boolean")
return false;
const bool value = Arguments == "true" ? true : false;
if(QCheckBox* const object = qobject_cast<QCheckBox*>(Object))
{
if(value != object->isChecked())
object->setChecked(value);
return true;
}
return false;
}
/*
* 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 _pqAbstractBooleanEventPlayer_h
#define _pqAbstractBooleanEventPlayer_h
#include "pqWidgetEventPlayer.h"
/// Translates high-level ParaQ events into low-level Qt action events
class pqAbstractBooleanEventPlayer :
public pqWidgetEventPlayer
{
public:
pqAbstractBooleanEventPlayer();
bool playEvent(QObject* Object, const QString& Command, const QString& Arguments);
private:
pqAbstractBooleanEventPlayer(const pqAbstractBooleanEventPlayer&);
pqAbstractBooleanEventPlayer& operator=(const pqAbstractBooleanEventPlayer&);
};
#endif // !_pqAbstractBooleanEventPlayer_h
/*
* 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 "pqAbstractDoubleEventPlayer.h"
#include <QDoubleSpinBox>
pqAbstractDoubleEventPlayer::pqAbstractDoubleEventPlayer()
{
}
bool pqAbstractDoubleEventPlayer::playEvent(QObject* Object, const QString& Command, const QString& Arguments)
{
if(Command != "set_double")
return false;
const double value = Arguments.toDouble();
if(QDoubleSpinBox* const object = qobject_cast<QDoubleSpinBox*>(Object))
{
object->setValue(value);
return true;
}
return false;
}
/*
* 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 _pqAbstractDoubleEventPlayer_h
#define _pqAbstractDoubleEventPlayer_h
#include "pqWidgetEventPlayer.h"
/// Translates high-level ParaQ events into low-level Qt slider events
class pqAbstractDoubleEventPlayer :
public pqWidgetEventPlayer
{
public:
pqAbstractDoubleEventPlayer();
bool playEvent(QObject* Object, const QString& Command, const QString& Arguments);
private:
pqAbstractDoubleEventPlayer(const pqAbstractDoubleEventPlayer&);
pqAbstractDoubleEventPlayer& operator=(const pqAbstractDoubleEventPlayer&);
};
#endif // !_pqAbstractDoubleEventPlayer_h
/*
* 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 "pqAbstractIntEventPlayer.h"
#include <QAbstractSlider>
#include <QSpinBox>
pqAbstractIntEventPlayer::pqAbstractIntEventPlayer()
{
}
bool pqAbstractIntEventPlayer::playEvent(QObject* Object, const QString& Command, const QString& Arguments)
{
if(Command != "set_int")
return false;
const int value = Arguments.toInt();
if(QAbstractSlider* const object = qobject_cast<QAbstractSlider*>(Object))
{
object->setValue(value);
return true;
}
if(QSpinBox* const object = qobject_cast<QSpinBox*>(Object))
{
object->setValue(value);
return true;
}
return false;
}
/*
* 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 _pqAbstractIntEventPlayer_h
#define _pqAbstractIntEventPlayer_h
#include "pqWidgetEventPlayer.h"
/// Translates high-level ParaQ events into low-level Qt slider events
class pqAbstractIntEventPlayer :
public pqWidgetEventPlayer
{
public:
pqAbstractIntEventPlayer();
bool playEvent(QObject* Object, const QString& Command, const QString& Arguments);
private:
pqAbstractIntEventPlayer(const pqAbstractIntEventPlayer&);
pqAbstractIntEventPlayer& operator=(const pqAbstractIntEventPlayer&);
};
#endif // !_pqAbstractIntEventPlayer_h
/*
* 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 "pqAbstractSliderEventTranslator.h"
#include <QAbstractSlider>
#include <QEvent>
pqAbstractSliderEventTranslator::pqAbstractSliderEventTranslator() :
currentObject(0)
{
}
bool pqAbstractSliderEventTranslator::translateEvent(QObject* Object, QEvent* Event)
{
QAbstractSlider* const object = qobject_cast<QAbstractSlider*>(Object);
if(!object)
return false;
switch(Event->type())
{
case QEvent::Enter:
this->currentObject = Object;
connect(object, SIGNAL(valueChanged(int)), this, SLOT(onValueChanged(int)));
break;
case QEvent::Leave:
disconnect(Object, 0, this, 0);
this->currentObject = 0;
break;
}
return true;
}
void pqAbstractSliderEventTranslator::onValueChanged(int Value)
{
emit recordEvent(this->currentObject, "set_int", QString().setNum(Value));
}
/*
* 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 _pqAbstractSliderEventTranslator_h
#define _pqAbstractSliderEventTranslator_h
#include "pqWidgetEventTranslator.h"
/// Translates low-level Qt slider events into high-level ParaQ events that can be recorded as test cases
class pqAbstractSliderEventTranslator :
public pqWidgetEventTranslator
{
Q_OBJECT
public:
pqAbstractSliderEventTranslator();
virtual bool translateEvent(QObject* Object, QEvent* Event);
private:
pqAbstractSliderEventTranslator(const pqAbstractSliderEventTranslator&);
pqAbstractSliderEventTranslator& operator=(const pqAbstractSliderEventTranslator&);
QObject* currentObject;
private slots:
void onValueChanged(int);
};
#endif // !_pqAbstractSliderEventTranslator_h
/*
* 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 "pqAbstractStringEventPlayer.h"
#include <QComboBox>
#include <QLineEdit>
pqAbstractStringEventPlayer::pqAbstractStringEventPlayer()
{
}
bool pqAbstractStringEventPlayer::playEvent(QObject* Object, const QString& Command, const QString& Arguments)
{
if(Command != "set_string")
return false;
const QString value = Arguments;
if(QComboBox* const object = qobject_cast<QComboBox*>(Object))
{
object->setEditText(value);
return true;
}
if(QLineEdit* const object = qobject_cast<QLineEdit*>(Object))
{
object->setText(value);
return true;
}
return false;
}
/*
* 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 _pqAbstractStringEventPlayer_h
#define _pqAbstractStringEventPlayer_h
#include "pqWidgetEventPlayer.h"
/// Translates high-level ParaQ events into low-level Qt slider events
class pqAbstractStringEventPlayer :
public pqWidgetEventPlayer
{
public:
pqAbstractStringEventPlayer();
bool playEvent(QObject* Object, const QString& Command, const QString& Arguments);
private:
pqAbstractStringEventPlayer(const pqAbstractStringEventPlayer&);
pqAbstractStringEventPlayer& operator=(const pqAbstractStringEventPlayer&);
};
#endif // !_pqAbstractStringEventPlayer_h
/*
* 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 "pqCheckBoxEventTranslator.h"
#include <QCheckBox>
#include <QEvent>
pqCheckBoxEventTranslator::pqCheckBoxEventTranslator() :
currentObject(0)
{
}
bool pqCheckBoxEventTranslator::translateEvent(QObject* Object, QEvent* Event)
{
QCheckBox* const object = qobject_cast<QCheckBox*>(Object);
if(!object)
return false;
switch(Event->type())
{
case QEvent::Enter:
this->currentObject = Object;
connect(object, SIGNAL(stateChanged(int)), this, SLOT(onStateChanged(int)));
break;
case QEvent::Leave:
disconnect(Object, 0, this, 0);
this->currentObject = 0;
break;
}
return true;
}
void pqCheckBoxEventTranslator::onStateChanged(int State)
{
emit recordEvent(this->currentObject, "set_boolean", State ? "true" : "false");
}
/*
* 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 _pqCheckBoxEventTranslator_h
#define _pqCheckBoxEventTranslator_h
#include "pqWidgetEventTranslator.h"
/// Translates low-level Qt checkbox events into high-level ParaQ events that can be recorded as test cases
class pqCheckBoxEventTranslator :
public pqWidgetEventTranslator
{
Q_OBJECT
public:
pqCheckBoxEventTranslator();
virtual bool translateEvent(QObject* Object, QEvent* Event);
private:
pqCheckBoxEventTranslator(const pqCheckBoxEventTranslator&);
pqCheckBoxEventTranslator& operator=(const pqCheckBoxEventTranslator&);
QObject* currentObject;
private slots:
void onStateChanged(int);
};
#endif // !_pqCheckBoxEventTranslator_h
/*
* 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 "pqComboBoxEventTranslator.h"
#include <QComboBox>
#include <QEvent>
pqComboBoxEventTranslator::pqComboBoxEventTranslator() :
currentObject(0)
{
}
bool pqComboBoxEventTranslator::translateEvent(QObject* Object, QEvent* Event)
{
QComboBox* const object = qobject_cast<QComboBox*>(Object);
if(!object)
return false;
switch(Event->type())
{
case QEvent::Enter:
if(this->currentObject != Object)
{
if(this->currentObject)
{
disconnect(this->currentObject, 0, this, 0);
}
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&)));
}
break;
}
return true;
}
void pqComboBoxEventTranslator::onDestroyed(QObject* Object)
{
this->currentObject = 0;
}
void pqComboBoxEventTranslator::onStateChanged(const QString& State)
{
emit recordEvent(this->currentObject, "set_string", State);
}
/*
* 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 _pqComboBoxEventTranslator_h
#define _pqComboBoxEventTranslator_h
#include "pqWidgetEventTranslator.h"
/// Translates low-level Qt checkbox events into high-level ParaQ events that can be recorded as test cases
class pqComboBoxEventTranslator :
public pqWidgetEventTranslator
{
Q_OBJECT
public:
pqComboBoxEventTranslator();
virtual bool translateEvent(QObject* Object, QEvent* Event);
private:
pqComboBoxEventTranslator(const pqComboBoxEventTranslator&);
pqComboBoxEventTranslator& operator=(const pqComboBoxEventTranslator&);
QObject* currentObject;
private slots:
void onDestroyed(QObject*);
void onStateChanged(const QString&);
};
#endif // !_pqComboBoxEventTranslator_h
/*
* 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 "pqDoubleSpinBoxEventTranslator.h"
#include <QDoubleSpinBox>
#include <QEvent>
pqDoubleSpinBoxEventTranslator::pqDoubleSpinBoxEventTranslator() :
currentObject(0)
{
}
bool pqDoubleSpinBoxEventTranslator::translateEvent(QObject* Object, QEvent* Event)
{
QDoubleSpinBox* const object = qobject_cast<QDoubleSpinBox*>(Object);
if(!object)
return false;
switch(Event->type())
{
case QEvent::Enter:
this->currentObject = Object;
connect(object, SIGNAL(valueChanged(double)), this, SLOT(onValueChanged(double)));
break;
case QEvent::Leave:
disconnect(Object, 0, this, 0);
this->currentObject = 0;
break;
}
return true;
}
void pqDoubleSpinBoxEventTranslator::onValueChanged(double Value)
{
emit recordEvent(this->currentObject, "set_double", QString().setNum(Value));
}
/*
* 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.
*/