// Qt includes #include // CTKTesting includes #include "ctkQtTestingUtility.h" #include // for pqEventTypes @CTK_ADD_HEADER_EVENT_PLAYERS@ @CTK_ADD_HEADER_EVENT_TRANSLATORS@ //----------------------------------------------------------------------------- ctkQtTestingUtility::ctkQtTestingUtility(QObject* p) : Superclass(p) { this->addDefaultCTKWidgetEventTranslatorsToTranslator(this); this->addDefaultCTKWidgetEventPlayersToPlayer(this); } //----------------------------------------------------------------------------- ctkQtTestingUtility::~ctkQtTestingUtility() { } //----------------------------------------------------------------------------- void ctkQtTestingUtility::addDefaultCTKWidgetEventTranslatorsToTranslator(pqTestUtility* util) { Q_UNUSED(util); @CTK_ADD_WIDGET_EVENT_TRANSLATORS@ pqWidgetEventTranslator* translator = this->eventTranslator()->getWidgetEventTranslator( QLatin1String("pqNativeFileDialogEventTranslator")); if (translator) { this->eventTranslator()->removeWidgetEventTranslator( QLatin1String("pqNativeFileDialogEventTranslator")); delete translator; } } //----------------------------------------------------------------------------- void ctkQtTestingUtility::addDefaultCTKWidgetEventPlayersToPlayer(pqTestUtility* util) { Q_UNUSED(util); @CTK_ADD_WIDGET_EVENT_PLAYERS@ pqWidgetEventPlayer* player = this->eventPlayer()->getWidgetEventPlayer( QLatin1String("pqNativeFileDialogEventPlayer")); if (player) { this->eventPlayer()->removeWidgetEventPlayer( QLatin1String("pqNativeFileDialogEventPlayer")); delete player; } } //----------------------------------------------------------------------------- void ctkQtTestingUtility::addTranslator(pqWidgetEventTranslator* translator) { if(translator) { this->eventTranslator()->addWidgetEventTranslator(translator); } } //----------------------------------------------------------------------------- void ctkQtTestingUtility::addPlayer(pqWidgetEventPlayer* player) { if(player) { this->eventPlayer()->addWidgetEventPlayer(player); } } //----------------------------------------------------------------------------- QString ctkQtTestingUtility::eventTypeToString(int eventType) { switch (eventType) { case pqEventTypes::ACTION_EVENT: return QString("action"); case pqEventTypes::CHECK_EVENT: return QString("check"); default: return QString("unknown"); } } //----------------------------------------------------------------------------- int ctkQtTestingUtility::eventTypeFromString(const QString& eventTypeStr) { if (!eventTypeStr.compare("action", Qt::CaseInsensitive)) { return pqEventTypes::ACTION_EVENT; } else if (!eventTypeStr.compare("check", Qt::CaseInsensitive)) { return pqEventTypes::CHECK_EVENT; } else { // unknown event type name return -1; } }