...
 
Commits (33)
---
# This configuration requires clang-format 3.8 or higher.
BasedOnStyle: Mozilla
AlignAfterOpenBracket: DontAlign
AlignOperands: false
AlwaysBreakAfterReturnType: None
AlwaysBreakAfterDefinitionReturnType: None
BreakBeforeBraces: Allman
ColumnLimit: 100
Standard: Cpp03
...
.git* export-ignore
.hooks* export-ignore
*.sh crlf=input
*.sh.in crlf=input
# Custom attribute to mark sources as using our C code style.
[attr]our-c-style whitespace=tab-in-indent,-blank-at-eol format.clang-format
*.c our-c-style
*.h our-c-style
*.cpp our-c-style
*.cxx our-c-style
*.hxx our-c-style
*.txx our-c-style
*.mm our-c-style
*.txt whitespace=tab-in-indent,-blank-at-eol
*.cmake whitespace=tab-in-indent,-blank-at-eol
*.md whitespace=tab-in-indent conflict-marker-size=30
CMAKE_MINIMUM_REQUIRED(VERSION 2.8.12)
if (NOT CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR)
CMAKE_MINIMUM_REQUIRED(VERSION 3.3)
endif ()
PROJECT(QtTesting)
IF(NOT DEFINED QtTesting_QT_VERSION)
SET(QtTesting_QT_VERSION "4" CACHE STRING "Expected Qt version")
MARK_AS_ADVANCED(QtTesting_QT_VERSION)
SET_PROPERTY(CACHE QtTesting_QT_VERSION PROPERTY STRINGS 4 5)
ENDIF()
IF(NOT (QtTesting_QT_VERSION VERSION_EQUAL "4" OR
QtTesting_QT_VERSION VERSION_EQUAL "5"))
message(FATAL_ERROR "Expected value for QtTesting_QT_VERSION is either '4' or '5'")
ENDIF()
set(qt_imported_targets)
IF(QtTesting_QT_VERSION VERSION_GREATER "4")
FIND_PACKAGE(Qt5 REQUIRED COMPONENTS Core Widgets)
SET(qt_imported_targets Qt5::Core Qt5::Widgets)
ELSE()
FIND_PACKAGE(Qt4 REQUIRED COMPONENTS QtGui)
SET(qt_imported_targets Qt4::QtCore Qt4::QtGui)
ENDIF()
vtk_module_find_package(
PACKAGE Qt5
COMPONENTS Core Widgets)
IF(NOT DEFINED QT_TESTING_WITH_PYTHON)
OPTION(QT_TESTING_WITH_PYTHON "Enable Qt Testing with Python" OFF)
......@@ -46,10 +33,20 @@ IF(NOT DEFINED QT_TESTING_EVENT_PLAYBACK_DELAY)
MARK_AS_ADVANCED(QT_TESTING_EVENT_PLAYBACK_DELAY)
ENDIF()
IF(NOT QT_TESTING_INSTALL_EXPORT_NAME)
IF(NOT DEFINED QT_TESTING_INSTALL_EXPORT_NAME)
SET(QT_TESTING_INSTALL_EXPORT_NAME QtTestingTargets)
ENDIF()
# One can define QT_TESTING_CUSTOM_LIBRARY_PREFIX and/or
# QT_TESTING_CUSTOM_LIBRARY_SUFFIX to add prefix/suffix to libraries
# generated by thus project. Default is empty.
if(NOT DEFINED QT_TESTING_CUSTOM_LIBRARY_SUFFIX)
set(QT_TESTING_CUSTOM_LIBRARY_SUFFIX)
endif()
if(NOT DEFINED QT_TESTING_CUSTOM_LIBRARY_PREFIX)
set(QT_TESTING_CUSTOM_LIBRARY_PREFIX)
endif()
IF(QT_TESTING_WITH_PYTHON)
IF(NOT PythonLibs_FOUND)
......@@ -71,10 +68,6 @@ IF(QT_TESTING_WITH_PYTHON)
INCLUDE_DIRECTORIES(
${PYTHON_INCLUDE_PATH}
)
SET(PYTHON_MOCS
pqPythonEventObserver.h
pqPythonEventSource.h
)
SET(PYTHON_SRCS
pqPythonEventObserver.cxx
pqPythonEventObserver.h
......@@ -83,103 +76,18 @@ IF(QT_TESTING_WITH_PYTHON)
)
ENDIF(QT_TESTING_WITH_PYTHON)
INCLUDE_DIRECTORIES(
${QtTesting_BINARY_DIR}
${QtTesting_SOURCE_DIR}
)
# Reduce the number of dirs that get included on moc command line
# since it causes issues on Windows 2000.
GET_DIRECTORY_PROPERTY(include_dirs_tmp INCLUDE_DIRECTORIES)
SET_DIRECTORY_PROPERTIES(PROPERTIES INCLUDE_DIRECTORIES "${MOC_INCLUDE_DIRS}")
set(CMAKE_AUTOMOC 1)
set(CMAKE_AUTOUIC 1)
set(CMAKE_AUTORCC 1)
SET(MOC_SRCS
pq3DViewEventPlayer.h
pq3DViewEventTranslator.h
pqAbstractActivateEventPlayer.h
pqAbstractBooleanEventPlayer.h
pqAbstractButtonEventTranslator.h
pqAbstractDoubleEventPlayer.h
pqAbstractIntEventPlayer.h
pqAbstractItemViewEventPlayer.h
pqAbstractItemViewEventPlayerBase.h
pqAbstractItemViewEventTranslator.h
pqAbstractItemViewEventTranslatorBase.h
pqAbstractMiscellaneousEventPlayer.h
pqAbstractSliderEventTranslator.h
pqAbstractStringEventPlayer.h
pqBasicWidgetEventPlayer.h
pqBasicWidgetEventTranslator.h
pqCheckEventOverlay.h
pqComboBoxEventTranslator.h
pqComboBoxEventPlayer.h
pqCommentEventPlayer.h
pqDoubleSpinBoxEventTranslator.h
pqEventComment.h
pqEventDispatcher.h
pqEventObserver.h
pqEventPlayer.h
pqEventRecorder.h
pqEventSource.h
pqEventTranslator.h
pqLineEditEventTranslator.h
pqListViewEventPlayer.h
pqListViewEventTranslator.h
pqMenuEventTranslator.h
pqNativeFileDialogEventPlayer.h
pqNativeFileDialogEventTranslator.h
pqPlayBackEventsDialog.h
pqRecordEventsDialog.h
pqSpinBoxEventTranslator.h
pqStdoutEventObserver.h
pqTabBarEventPlayer.h
pqTabBarEventTranslator.h
pqTableViewEventPlayer.h
pqTableViewEventTranslator.h
pqTestUtility.h
pqThreadedEventSource.h
pqTimer.h
pqTreeViewEventPlayer.h
pqTreeViewEventTranslator.h
pqWidgetEventPlayer.h
pqWidgetEventTranslator.h
set(UI_SRCS
pqPlayBackEventsDialog.ui
pqRecordEventsDialog.ui
)
IF(QtTesting_QT_VERSION VERSION_GREATER "4")
QT5_WRAP_CPP(MOC_BUILT_SOURCES
${MOC_SRCS}
${PYTHON_MOCS}
)
ELSE()
QT4_WRAP_CPP(MOC_BUILT_SOURCES
${MOC_SRCS}
${PYTHON_MOCS}
)
ENDIF()
SET_DIRECTORY_PROPERTIES(PROPERTIES INCLUDE_DIRECTORIES "${include_dirs_tmp}")
IF(QtTesting_QT_VERSION VERSION_GREATER "4")
QT5_WRAP_UI(UI_BUILT_SOURCES
pqPlayBackEventsDialog.ui
pqRecordEventsDialog.ui
)
ELSE()
QT4_WRAP_UI(UI_BUILT_SOURCES
pqPlayBackEventsDialog.ui
pqRecordEventsDialog.ui
)
ENDIF()
IF(QtTesting_QT_VERSION VERSION_GREATER "4")
QT5_ADD_RESOURCES(QRC_BUILT_SOURCES
Resources/QtTesting.qrc
)
ELSE()
QT4_ADD_RESOURCES(QRC_BUILT_SOURCES
Resources/QtTesting.qrc
)
ENDIF()
set(RC_SRCS
Resources/QtTesting.qrc
)
SET(QtTesting_SOURCES
pq3DViewEventPlayer.cxx
......@@ -289,21 +197,28 @@ SET(QtTesting_DEVEL_HEADERS
${QtTesting_BINARY_DIR}/QtTestingConfigure.h
)
ADD_LIBRARY(QtTesting
${QtTesting_SOURCES}
${MOC_BUILT_SOURCES}
${UI_BUILT_SOURCES}
${QRC_BUILT_SOURCES}
${PYTHON_SRCS}
vtk_module_add_module(vtkqttesting
SOURCES ${QtTesting_SOURCES}
${UI_SRCS}
${RC_SRCS}
${PYTHON_SRCS}
HEADERS ${QtTesting_DEVEL_HEADERS}
HEADERS_SUBDIR "vtkqttesting"
)
SOURCE_GROUP("Generated" FILES
${MOC_BUILT_SOURCES}
${UI_BUILT_SOURCES}
)
TARGET_LINK_LIBRARIES(QtTesting
${qt_imported_targets}
target_include_directories(vtkqttesting
PUBLIC
"$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>"
"$<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}>"
"$<INSTALL_INTERFACE:${_vtk_build_HEADERS_DESTINATION}/vtkqttesting>")
if (FALSE) # XXX(kitware): ParaView does this already.
# Set library name to include custom prefixes/suffixes.
set_property(TARGET QtTesting
PROPERTY OUTPUT_NAME ${QT_TESTING_CUSTOM_LIBRARY_PREFIX}QtTesting${QT_TESTING_CUSTOM_LIBRARY_SUFFIX})
endif ()
TARGET_LINK_LIBRARIES(vtkqttesting
PUBLIC Qt5::Core Qt5::Widgets
)
IF(QT_TESTING_WITH_PYTHON)
......@@ -317,20 +232,33 @@ SET(QTTESTING_BUILD_SHARED_LIBS ${BUILD_SHARED_LIBS})
CONFIGURE_FILE(${QtTesting_SOURCE_DIR}/QtTestingConfigure.h.in
${QtTesting_BINARY_DIR}/QtTestingConfigure.h)
INSTALL(TARGETS QtTesting
EXPORT ${QT_TESTING_INSTALL_EXPORT_NAME}
RUNTIME DESTINATION ${QtTesting_INSTALL_BIN_DIR} COMPONENT Runtime
LIBRARY DESTINATION ${QtTesting_INSTALL_LIB_DIR} COMPONENT Runtime
ARCHIVE DESTINATION ${QtTesting_INSTALL_LIB_DIR} COMPONENT Development)
add_subdirectory(Examples)
include(CTest)
IF(BUILD_TESTING)
add_subdirectory(Testing)
ENDIF()
if (QT_TESTING_INSTALL_EXPORT_NAME)
INSTALL(TARGETS QtTesting
EXPORT ${QT_TESTING_INSTALL_EXPORT_NAME}
RUNTIME DESTINATION ${QtTesting_INSTALL_BIN_DIR} COMPONENT Runtime
LIBRARY DESTINATION ${QtTesting_INSTALL_LIB_DIR} COMPONENT Runtime
ARCHIVE DESTINATION ${QtTesting_INSTALL_LIB_DIR} COMPONENT Development)
endif ()
if (NOT DEFINED QtTesting_ENABLE_EXAMPLES)
option(QtTesting_ENABLE_EXAMPLES "Enable Qt Testing examples" ON)
endif ()
if (QtTesting_ENABLE_EXAMPLES)
add_subdirectory(Examples)
endif ()
if (NOT DEFINED QtTesting_ENABLE_TESTING)
option(QtTesting_ENABLE_TESTING "Enable Qt Testing tests" ON)
endif ()
if (QtTesting_ENABLE_TESTING)
include(CTest)
IF(BUILD_TESTING)
add_subdirectory(Testing)
ENDIF()
endif ()
if (QT_TESTING_INSTALL_EXPORT_NAME)
export(TARGETS QtTesting FILE ${QtTesting_BINARY_DIR}/QtTestingExports.cmake)
# Set up the build export configuration
......@@ -362,17 +290,20 @@ configure_file(
"${QtTesting_EXPORT_INSTALL_FILE}"
@ONLY
)
endif ()
IF(NOT QtTesting_INSTALL_NO_DEVELOPMENT)
install( FILES ${QtTesting_DEVEL_HEADERS}
DESTINATION ${QtTesting_INSTALL_INCLUDE_DIR}
)
# Configure the CMake EXPORT file during installation
install( FILES ${QtTesting_BINARY_DIR}/CMakeFiles/QtTestingConfig.cmake
DESTINATION ${QtTesting_INSTALL_CMAKE_DIR}
)
install( EXPORT ${QT_TESTING_INSTALL_EXPORT_NAME}
DESTINATION ${QtTesting_INSTALL_CMAKE_DIR}
)
if (QT_TESTING_INSTALL_EXPORT_NAME)
# Configure the CMake EXPORT file during installation
install( FILES ${QtTesting_BINARY_DIR}/CMakeFiles/QtTestingConfig.cmake
DESTINATION ${QtTesting_INSTALL_CMAKE_DIR}
)
install( EXPORT ${QT_TESTING_INSTALL_EXPORT_NAME}
DESTINATION ${QtTesting_INSTALL_CMAKE_DIR}
)
endif ()
ENDIF()
......@@ -9,28 +9,10 @@ SET (SOURCE_FILES
TestingDemo.h
)
SET (MOC_FILES
TestingDemo.h
)
INCLUDE_DIRECTORIES(${CMAKE_CURRENT_BINARY_DIR})
IF(QtTesting_QT_VERSION VERSION_GREATER "4")
QT5_WRAP_UI (EXAMPLE_UI_BUILT_SOURCES ${UI_FILES})
QT5_WRAP_CPP(EXAMPLE_MOC_BUILT_SOURCES ${MOC_FILES})
ELSE()
QT4_WRAP_UI (EXAMPLE_UI_BUILT_SOURCES ${UI_FILES})
QT4_WRAP_CPP(EXAMPLE_MOC_BUILT_SOURCES ${MOC_FILES})
ENDIF()
add_executable (TestingDemo
${SOURCE_FILES}
${EXAMPLE_UI_BUILT_SOURCES}
${EXAMPLE_MOC_BUILT_SOURCES}
${UI_FILES}
)
target_link_libraries(TestingDemo
QtTesting)
set_target_properties(TestingDemo PROPERTIES
COMPILE_FLAGS "${Qt5Widgets_EXECUTABLE_COMPILE_FLAGS}")
PRIVATE QtTesting)
......@@ -28,13 +28,13 @@ public:
this->XMLStream = NULL;
}
~XMLEventObserver()
~XMLEventObserver() override
{
delete this->XMLStream;
}
protected:
virtual void setStream(QTextStream* stream)
void setStream(QTextStream* stream) override
{
if (this->XMLStream)
{
......@@ -58,8 +58,8 @@ protected:
}
}
virtual void onRecordEvent(const QString& widget, const QString& command,
const QString& arguments, const int& eventType)
void onRecordEvent(const QString& widget, const QString& command,
const QString& arguments, const int& eventType) override
{
if(this->XMLStream)
{
......@@ -86,10 +86,10 @@ class XMLEventSource : public pqEventSource
public:
XMLEventSource(QObject* p): Superclass(p) { this->XMLStream = NULL;}
~XMLEventSource() { delete this->XMLStream; }
~XMLEventSource() override { delete this->XMLStream; }
protected:
virtual void setContent(const QString& xmlfilename)
void setContent(const QString& xmlfilename) override
{
delete this->XMLStream;
this->XMLStream = NULL;
......@@ -125,7 +125,7 @@ protected:
}
int getNextEvent(QString& widget, QString& command, QString&
arguments,int& eventType)
arguments,int& eventType) override
{
if (this->XMLStream->atEnd())
{
......
......@@ -9,7 +9,7 @@ class TestingDemo : public QMainWindow
Q_OBJECT
public:
TestingDemo();
~TestingDemo();
~TestingDemo() override;
protected slots:
void record();
void play();
......
Copyright (c) 2005-2008 Sandia Corporation, Kitware Inc.
All rights reserved.
ParaView is a free software; you can redistribute it and/or modify it
under the terms of the ParaView license version 1.2.
See License_v1.2.txt for the full ParaView license.
A copy of this license can be obtained by contacting
Kitware Inc.
28 Corporate Drive
Clifton Park, NY 12065
USA
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
......@@ -7,7 +7,7 @@
All rights reserved.
ParaView is a free software; you can redistribute it and/or modify it
under the terms of the ParaView license version 1.2.
under the terms of the ParaView license version 1.2.
See License_v1.2.txt for the full ParaView license.
A copy of this license can be obtained by contacting
......@@ -36,21 +36,21 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include "QtTestingConfigure.h"
#if defined(QTTESTING_BUILD_SHARED_LIBS)
# if defined(QtTesting_EXPORTS)
# if defined(WIN32)
# define QTTESTING_EXPORT __declspec(dllexport)
# elif defined(__GNUC__) && __GNUC__ >= 4
# define QTTESTING_EXPORT __attribute__ ((visibility("default")))
# endif
# else
# if defined(WIN32)
# define QTTESTING_EXPORT __declspec(dllimport)
# endif
# endif
#if defined(QtTesting_EXPORTS)
#if defined(WIN32)
#define QTTESTING_EXPORT __declspec(dllexport)
#elif defined(__GNUC__) && __GNUC__ >= 4
#define QTTESTING_EXPORT __attribute__((visibility("default")))
#endif
#else
#if defined(WIN32)
#define QTTESTING_EXPORT __declspec(dllimport)
#endif
#endif
#endif
#ifndef QTTESTING_EXPORT
# define QTTESTING_EXPORT
#define QTTESTING_EXPORT
#endif
#endif // !_QtTestingExport_h
if(NOT CMAKE_Cxx_Fortran_COMPILER_ID STREQUAL "Intel")
if(NOT CMAKE_CXX_COMPILER_ID STREQUAL "Intel")
# QtTest fails to compile on ICC. Hence we don't add these tests on
# Intel compilers.
add_subdirectory(Cpp)
......
include(../CMake/qtTestingMacroGenerateMocs.cmake)
IF(QtTesting_QT_VERSION VERSION_GREATER "4")
FIND_PACKAGE(Qt5 REQUIRED QUIET COMPONENTS Test)
SET(TEST_LIBRARIES Qt5::Test)
ELSE()
FIND_PACKAGE(Qt4 REQUIRED QUIET COMPONENTS QtTest)
SET(TEST_LIBRARIES Qt4::QtTest)
ENDIF()
set(KIT ${PROJECT_NAME})
FIND_PACKAGE(Qt5 REQUIRED QUIET COMPONENTS Test)
set(TEST_SOURCES
pqAbstractButtonEventTranslatorTest.cpp
......@@ -22,37 +12,23 @@ set(TEST_SOURCES
pqTestUtilityTest.cpp
)
set(TEST_MOC_HEADERS
pqTest.h
)
create_test_sourcelist(Tests ${KIT}CppTests.cxx
create_test_sourcelist(Tests QtTestingCppTests.cxx
${TEST_SOURCES}
)
set(TestsToRun ${Tests})
remove(TestsToRun ${KIT}CppTests.cxx)
remove(TestsToRun QtTestingCppTests.cxx)
include_directories(
${CMAKE_CURRENT_BINARY_DIR}
${CMAKE_CURRENT_SOURCE_DIR}
)
if(QtTesting_QT_VERSION VERSION_GREATER "4")
QT5_GENERATE_MOCS(${TEST_SOURCES})
QT5_WRAP_CPP( TEST_MOC_SRCS ${TEST_MOC_HEADERS} )
else()
QT4_GENERATE_MOCS(${TEST_SOURCES})
QT4_WRAP_CPP( TEST_MOC_SRCS ${TEST_MOC_HEADERS} )
endif()
add_executable(${KIT}CppTests ${Tests} ${TEST_MOC_SRCS})
target_link_libraries(${KIT}CppTests ${PROJECT_NAME} ${TEST_LIBRARIES})
set_target_properties(${KIT}CppTests PROPERTIES
COMPILE_FLAGS "${Qt5Test_EXECUTABLE_COMPILE_FLAGS}")
add_executable(QtTestingCppTests ${Tests} ${TEST_SOURCES})
target_link_libraries(QtTestingCppTests ${PROJECT_NAME} Qt5::Test)
macro(SIMPLE_TEST testname)
add_test(NAME ${testname} COMMAND $<TARGET_FILE:${KIT}CppTests> ${testname} ${ARGN})
add_test(NAME ${testname} COMMAND QtTestingCppTests ${testname} ${ARGN})
endmacro()
#
......
......@@ -238,15 +238,15 @@ void pqDoubleSpinBoxEventTranslatorTester::testRecordKeyBoardClick_data()
QString("doubleSpinBoxTest, set_double, 3"),
QString("doubleSpinBoxTest, set_double, 33"),
QString("doubleSpinBoxTest, set_double, 33"),
QString("doubleSpinBoxTest, key, 46"),
QString("doubleSpinBoxTest, set_double, 33"), // corresponds to "."
QString("doubleSpinBoxTest, set_double, 33.5"),
QString("doubleSpinBoxTest, set_double, 33.5"));
QTest::newRow("-5.23") << QString::number(-5.23)
<< QString("%1#%2#%3#%4#%5#%6#%7#%8#")
.arg(QString("doubleSpinBoxTest, key, 45"),
.arg(QString("doubleSpinBoxTest, set_double, 0"), // corresponds to "-"
QString("doubleSpinBoxTest, set_double, -5"),
QString("doubleSpinBoxTest, set_double, -5"),
QString("doubleSpinBoxTest, key, 46"),
QString("doubleSpinBoxTest, set_double, -5"), // corresponds to "."
QString("doubleSpinBoxTest, set_double, -5.2"),
QString("doubleSpinBoxTest, set_double, -5.2"),
QString("doubleSpinBoxTest, set_double, -5.23"),
......@@ -264,10 +264,10 @@ void pqDoubleSpinBoxEventTranslatorTester::testRecordComplexClick()
this->DoubleSpinBox->clear();
QTest::keyClicks(this->DoubleSpinBox, QString::number(-5.25));
recordExpected.append(QString("doubleSpinBoxTest, key, 45#"));
recordExpected.append(QString("doubleSpinBoxTest, set_double, 0#")); // corresponds to "-"
recordExpected.append(QString("doubleSpinBoxTest, set_double, -5#"));
recordExpected.append(QString("doubleSpinBoxTest, set_double, -5#"));
recordExpected.append(QString("doubleSpinBoxTest, key, 46#"));
recordExpected.append(QString("doubleSpinBoxTest, set_double, -5#")); // corresponds to "."
recordExpected.append(QString("doubleSpinBoxTest, set_double, -5.2#"));
recordExpected.append(QString("doubleSpinBoxTest, set_double, -5.2#"));
recordExpected.append(QString("doubleSpinBoxTest, set_double, -5.25#"));
......
......@@ -239,7 +239,7 @@ void pqSpinBoxEventTranslatorTester::testRecordKeyBoardClick_data()
QString("spinBoxTest, set_int, 33"));
QTest::newRow("-5") << QString::number(-5)
<< QString("%1#%2#%3#")
.arg(QString("spinBoxTest, key, 45"),
.arg(QString("spinBoxTest, set_int, 0"), // corresponds to "-"
QString("spinBoxTest, set_int, -5"),
QString("spinBoxTest, set_int, -5"));
}
......
......@@ -11,10 +11,12 @@ class TemplateEventPlayer :
public pqWidgetEventPlayer
{
Q_OBJECT
typedef pqWidgetEventPlayer Superclass;
public:
TemplateEventPlayer(QObject* parent = 0);
using Superclass::playEvent;
bool playEvent(QObject *Object, const QString &Command, const QString &Arguments, bool &Error);
private:
......
......@@ -12,6 +12,7 @@ class TemplateEventTranslator :
public:
TemplateEventTranslator(QObject* parent = 0);
using Superclass::translateEvent;
virtual bool translateEvent(QObject *Object, QEvent *Event, bool &Error);
private slots:
......
......@@ -35,46 +35,45 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include <QApplication>
#include <QKeyEvent>
#include <QMouseEvent>
#include <QtDebug>
#include <QRegExp>
#include <QWidget>
#include <QtDebug>
pq3DViewEventPlayer::pq3DViewEventPlayer(const QByteArray& classname, QObject * p)
: pqWidgetEventPlayer(p), mClassType(classname)
pq3DViewEventPlayer::pq3DViewEventPlayer(const QByteArray& classname, QObject* p)
: pqWidgetEventPlayer(p)
, mClassType(classname)
{
}
bool pq3DViewEventPlayer::playEvent(QObject* Object,
const QString& Command,
const QString& Arguments,
bool& Error)
bool pq3DViewEventPlayer::playEvent(
QObject* Object, const QString& Command, const QString& Arguments, bool& Error)
{
QWidget* widget = qobject_cast<QWidget*>(Object);
if(widget && Object->inherits(mClassType.data()))
QWidget* widget = qobject_cast<QWidget*>(Object);
if (widget && Object->inherits(mClassType.data()))
{
if (Command == "mousePress" || Command == "mouseRelease" || Command == "mouseMove")
{
QRegExp mouseRegExp("\\(([^,]*),([^,]*),([^,]),([^,]),([^,]*)\\)");
if (mouseRegExp.indexIn(Arguments) != -1)
{
if (Command == "mousePress" || Command=="mouseRelease" || Command=="mouseMove")
{
QRegExp mouseRegExp("\\(([^,]*),([^,]*),([^,]),([^,]),([^,]*)\\)");
if (mouseRegExp.indexIn(Arguments)!= -1)
{
QVariant v = mouseRegExp.cap(1);
int x = static_cast<int>(v.toDouble() * widget->size().width());
v = mouseRegExp.cap(2);
int y = static_cast<int>(v.toDouble() * widget->size().height());
v = mouseRegExp.cap(3);
Qt::MouseButton button = static_cast<Qt::MouseButton>(v.toInt());
v = mouseRegExp.cap(4);
Qt::MouseButtons buttons = static_cast<Qt::MouseButton>(v.toInt());
v = mouseRegExp.cap(5);
Qt::KeyboardModifiers keym = static_cast<Qt::KeyboardModifier>(v.toInt());
QEvent::Type type = (Command == "mousePress")? QEvent::MouseButtonPress :
((Command=="mouseMove")? QEvent::MouseMove : QEvent::MouseButtonRelease);
QMouseEvent e(type, QPoint(x,y), button, buttons, keym);
qApp->notify(Object, &e);
}
return true;
}
QVariant v = mouseRegExp.cap(1);
int x = static_cast<int>(v.toDouble() * widget->size().width());
v = mouseRegExp.cap(2);
int y = static_cast<int>(v.toDouble() * widget->size().height());
v = mouseRegExp.cap(3);
Qt::MouseButton button = static_cast<Qt::MouseButton>(v.toInt());
v = mouseRegExp.cap(4);
Qt::MouseButtons buttons = static_cast<Qt::MouseButton>(v.toInt());
v = mouseRegExp.cap(5);
Qt::KeyboardModifiers keym = static_cast<Qt::KeyboardModifier>(v.toInt());
QEvent::Type type = (Command == "mousePress")
? QEvent::MouseButtonPress
: ((Command == "mouseMove") ? QEvent::MouseMove : QEvent::MouseButtonRelease);
QMouseEvent e(type, QPoint(x, y), button, buttons, keym);
qApp->notify(Object, &e);
}
return this->Superclass::playEvent(Object, Command, Arguments, Error);
return true;
}
}
return this->Superclass::playEvent(Object, Command, Arguments, Error);
}
......@@ -36,13 +36,13 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include "pqWidgetEventPlayer.h"
/**
Concrete implementation of pqWidgetEventPlayer that handles playback of "activate" events for 3d views.
Concrete implementation of pqWidgetEventPlayer that handles playback of "activate" events for 3d
views.
It is not registered by default, and user can register with their own 3d view type.
\sa pqEventPlayer
*/
class QTTESTING_EXPORT pq3DViewEventPlayer :
public pqWidgetEventPlayer
class QTTESTING_EXPORT pq3DViewEventPlayer : public pqWidgetEventPlayer
{
Q_OBJECT
typedef pqWidgetEventPlayer Superclass;
......@@ -50,13 +50,14 @@ class QTTESTING_EXPORT pq3DViewEventPlayer :
public:
pq3DViewEventPlayer(const QByteArray& classname, QObject* p = 0);
bool playEvent(QObject* Object, const QString& Command, const QString& Arguments, bool& Error);
using Superclass::playEvent;
bool playEvent(
QObject* Object, const QString& Command, const QString& Arguments, bool& Error) override;
protected:
QByteArray mClassType;
private:
pq3DViewEventPlayer(const pq3DViewEventPlayer&);
pq3DViewEventPlayer& operator=(const pq3DViewEventPlayer&);
};
......
......@@ -33,14 +33,15 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include "pq3DViewEventTranslator.h"
#include <QEvent>
#include <QMouseEvent>
#include <QKeyEvent>
#include <QMouseEvent>
#include <QWidget>
pq3DViewEventTranslator::pq3DViewEventTranslator(const QByteArray& classname, QObject* p)
: pqWidgetEventTranslator(p), mClassType(classname),
lastMoveEvent(QEvent::MouseButtonPress, QPoint(), Qt::MouseButton(),
Qt::MouseButtons(), Qt::KeyboardModifiers())
: pqWidgetEventTranslator(p)
, mClassType(classname)
, lastMoveEvent(QEvent::MouseButtonPress, QPoint(), Qt::MouseButton(), Qt::MouseButtons(),
Qt::KeyboardModifiers())
{
}
......@@ -48,128 +49,125 @@ pq3DViewEventTranslator::~pq3DViewEventTranslator()
{
}
bool pq3DViewEventTranslator::translateEvent(QObject* Object, QEvent* Event,
bool& Error)
bool pq3DViewEventTranslator::translateEvent(QObject* Object, QEvent* Event, bool& Error)
{
QWidget* widget = qobject_cast<QWidget*>(Object);
if(!widget || !Object->inherits(mClassType.data()))
{
if (!widget || !Object->inherits(mClassType.data()))
{
return false;
}
}
switch(Event->type())
{
switch (Event->type())
{
case QEvent::ContextMenu:
{
{
return true;
break;
}
}
case QEvent::MouseButtonPress:
{
{
QMouseEvent* mouseEvent = dynamic_cast<QMouseEvent*>(Event);
if (mouseEvent)
{
{
QSize size = widget->size();
double normalized_x = mouseEvent->x()/static_cast<double>(size.width());
double normalized_y = mouseEvent->y()/static_cast<double>(size.height());
double normalized_x = mouseEvent->x() / static_cast<double>(size.width());
double normalized_y = mouseEvent->y() / static_cast<double>(size.height());
int button = mouseEvent->button();
int buttons = mouseEvent->buttons();
int modifiers = mouseEvent->modifiers();
emit recordEvent(Object, "mousePress", QString("(%1,%2,%3,%4,%5)")
.arg(normalized_x)
.arg(normalized_y)
.arg(button)
.arg(buttons)
.arg(modifiers));
}
.arg(normalized_x)
.arg(normalized_y)
.arg(button)
.arg(buttons)
.arg(modifiers));
}
// reset lastMoveEvent
QMouseEvent e(QEvent::MouseButtonPress, QPoint(), Qt::MouseButton(),
Qt::MouseButtons(), Qt::KeyboardModifiers());
QMouseEvent e(QEvent::MouseButtonPress, QPoint(), Qt::MouseButton(), Qt::MouseButtons(),
Qt::KeyboardModifiers());
lastMoveEvent = e;
return true;
break;
}
}
case QEvent::MouseMove:
{
{
QMouseEvent* mouseEvent = dynamic_cast<QMouseEvent*>(Event);
if (mouseEvent)
{
{
QMouseEvent e(QEvent::MouseMove, QPoint(mouseEvent->x(), mouseEvent->y()),
mouseEvent->button(), mouseEvent->buttons(),
mouseEvent->modifiers());
mouseEvent->button(), mouseEvent->buttons(), mouseEvent->modifiers());
lastMoveEvent = e;
}
}
return true;
break;
}
}
case QEvent::MouseButtonRelease:
{
{
QMouseEvent* mouseEvent = dynamic_cast<QMouseEvent*>(Event);
if (mouseEvent)
{
{
QSize size = widget->size();
// record last move event if it is valid
if(lastMoveEvent.type() == QEvent::MouseMove)
{
double normalized_x = lastMoveEvent.x()/static_cast<double>(size.width());
double normalized_y = lastMoveEvent.y()/static_cast<double>(size.height());
if (lastMoveEvent.type() == QEvent::MouseMove)
{
double normalized_x = lastMoveEvent.x() / static_cast<double>(size.width());
double normalized_y = lastMoveEvent.y() / static_cast<double>(size.height());
int button = lastMoveEvent.button();
int buttons = lastMoveEvent.buttons();
int modifiers = lastMoveEvent.modifiers();
emit recordEvent(Object, "mouseMove", QString("(%1,%2,%3,%4,%5)")
.arg(normalized_x)
.arg(normalized_y)
.arg(button)
.arg(buttons)
.arg(modifiers));
}
.arg(normalized_x)
.arg(normalized_y)
.arg(button)
.arg(buttons)
.arg(modifiers));
}
double normalized_x = mouseEvent->x()/static_cast<double>(size.width());
double normalized_y = mouseEvent->y()/static_cast<double>(size.height());
double normalized_x = mouseEvent->x() / static_cast<double>(size.width());
double normalized_y = mouseEvent->y() / static_cast<double>(size.height());
int button = mouseEvent->button();
int buttons = mouseEvent->buttons();
int modifiers = mouseEvent->modifiers();
emit recordEvent(Object, "mouseRelease", QString("(%1,%2,%3,%4,%5)")
.arg(normalized_x)
.arg(normalized_y)
.arg(button)
.arg(buttons)
.arg(modifiers));
}
.arg(normalized_x)
.arg(normalized_y)
.arg(button)
.arg(buttons)
.arg(modifiers));
}
return true;
break;
}
}
case QEvent::KeyPress:
case QEvent::KeyRelease:
{
{
QKeyEvent* ke = static_cast<QKeyEvent*>(Event);
QString data =QString("%1:%2:%3:%4:%5:%6")
.arg(ke->type())
.arg(ke->key())
.arg(static_cast<int>(ke->modifiers()))
.arg(ke->text())
.arg(ke->isAutoRepeat())
.arg(ke->count());
QString data = QString("%1:%2:%3:%4:%5:%6")
.arg(ke->type())
.arg(ke->key())
.arg(static_cast<int>(ke->modifiers()))
.arg(ke->text())
.arg(ke->isAutoRepeat())
.arg(ke->count());
emit recordEvent(Object, "keyEvent", data);
return true;
break;
}
}
default:
{
{
break;
}
}
}
return this->Superclass::translateEvent(Object, Event, Error);
}
......@@ -42,17 +42,17 @@ Translates low-level Qt events into high-level ParaView events that can be recor
\sa pqEventTranslator
*/
class QTTESTING_EXPORT pq3DViewEventTranslator :
public pqWidgetEventTranslator
class QTTESTING_EXPORT pq3DViewEventTranslator : public pqWidgetEventTranslator
{
Q_OBJECT
typedef pqWidgetEventTranslator Superclass;
public:
pq3DViewEventTranslator(const QByteArray& classname, QObject* p=0);
~pq3DViewEventTranslator();
pq3DViewEventTranslator(const QByteArray& classname, QObject* p = 0);
~pq3DViewEventTranslator() override;
virtual bool translateEvent(QObject* Object, QEvent* Event, bool& Error);
using Superclass::translateEvent;
bool translateEvent(QObject* Object, QEvent* Event, bool& Error) override;
protected:
QByteArray mClassType;
......@@ -61,7 +61,6 @@ protected:
private:
pq3DViewEventTranslator(const pq3DViewEventTranslator&);
pq3DViewEventTranslator& operator=(const pq3DViewEventTranslator&);
};
#endif // !_pq3DViewEventTranslator_h
......@@ -38,85 +38,82 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include <QMenu>
#include <QMenuBar>
#include <QPushButton>
#include <QtDebug>
#include <QToolButton>
#include <QtDebug>
#include "pqEventDispatcher.h"
pqAbstractActivateEventPlayer::pqAbstractActivateEventPlayer(QObject * p)
pqAbstractActivateEventPlayer::pqAbstractActivateEventPlayer(QObject* p)
: pqWidgetEventPlayer(p)
{
}
bool pqAbstractActivateEventPlayer::playEvent(QObject* Object,
const QString& Command,
const QString& Arguments,
bool& Error)
bool pqAbstractActivateEventPlayer::playEvent(
QObject* Object, const QString& Command, const QString& Arguments, bool& Error)
{
if(Command != "activate" && Command != "longActivate")
return false;
if (Command != "activate" && Command != "longActivate")
return false;
if (QMenuBar* const menu_bar = qobject_cast<QMenuBar*>(Object))
{
if (QMenuBar* const menu_bar = qobject_cast<QMenuBar*>(Object))
{
QAction* action = findAction(menu_bar, Arguments);
if (action)
{
{
menu_bar->setActiveAction(action);
return true;
}
}
qCritical() << "couldn't find action " << Arguments;
Error = true;
return true;
}
}
if(QMenu* const object = qobject_cast<QMenu*>(Object))
{
if (QMenu* const object = qobject_cast<QMenu*>(Object))
{
QAction* action = findAction(object, Arguments);
if(!action)
{
if (!action)
{
qCritical() << "couldn't find action " << Arguments;
Error = true;
return true;
}
}
// get a list of menus that must be navigated to
// click on the action
QObjectList menus;
for(QObject* p = object;
qobject_cast<QMenu*>(p) || qobject_cast<QMenuBar*>(p);
p = p->parent())
{
for (QObject* p = object; qobject_cast<QMenu*>(p) || qobject_cast<QMenuBar*>(p);
p = p->parent())
{
menus.push_front(p);
}
}
// unfold menus to make action visible
int i;
int numMenus = menus.size() - 1;
for(i=0; i < numMenus; ++i)
{
for (i = 0; i < numMenus; ++i)
{
QObject* p = menus[i];
QMenu* next = qobject_cast<QMenu*>(menus[i+1]);
if(QMenuBar* menu_bar = qobject_cast<QMenuBar*>(p))
{
QMenu* next = qobject_cast<QMenu*>(menus[i + 1]);
if (QMenuBar* menu_bar = qobject_cast<QMenuBar*>(p))
{
menu_bar->setActiveAction(next->menuAction());
int max_wait = 0;
while(!next->isVisible() && (++max_wait) <= 2)
{
while (!next->isVisible() && (++max_wait) <= 2)
{
pqEventDispatcher::processEventsAndWait(100);
}
}
else if(QMenu* menu = qobject_cast<QMenu*>(p))
{
}
else if (QMenu* menu = qobject_cast<QMenu*>(p))
{
menu->setActiveAction(next->menuAction());
int max_wait = 0;
while(!next->isVisible() && (++max_wait) <= 2)
{
while (!next->isVisible() && (++max_wait) <= 2)
{
pqEventDispatcher::processEventsAndWait(100);
}
}
}
}
// set active action, will cause scrollable menus to scroll
// to make action visible
......@@ -129,35 +126,35 @@ bool pqAbstractActivateEventPlayer::playEvent(QObject* Object,
qApp->notify(object, &keyDown);
qApp->notify(object, &keyUp);
//QApplication::processEvents();
// QApplication::processEvents();
return true;
}
}
if(QAbstractButton* const object = qobject_cast<QAbstractButton*>(Object))
{
if (QAbstractButton* const object = qobject_cast<QAbstractButton*>(Object))
{
if (Command == "activate")
{
{
object->click();
//QApplication::processEvents();
// QApplication::processEvents();
return true;
}
if(Command == "longActivate")
{
}
if (Command == "longActivate")
{
QToolButton* tButton = qobject_cast<QToolButton*>(Object);
if(tButton)
{
if (tButton)
{
tButton->showMenu();
return true;
}
}
}
}
if (QAction* const action = qobject_cast<QAction*>(Object))
{
{
action->activate(QAction::Trigger);
//QApplication::processEvents();
// QApplication::processEvents();
return true;
}
}
qCritical() << "calling activate on unhandled type " << Object;
Error = true;
......@@ -168,26 +165,26 @@ QAction* pqAbstractActivateEventPlayer::findAction(QMenuBar* p, const QString& n
{
QList<QAction*> actions = p->actions();
QAction* action = NULL;
foreach(QAction* a, actions)
foreach (QAction* a, actions)
{
if (a->menu()->objectName() == name)
{
if(a->menu()->objectName() == name)
{
action = a;
break;
}
}
}
if(!action)
if (!action)
{
foreach (QAction* a, actions)
{
foreach(QAction* a, actions)
if (a->text() == name)
{
if(a->text() == name)
{
action = a;
break;
}
}
}
}
return action;
}
......@@ -196,26 +193,26 @@ QAction* pqAbstractActivateEventPlayer::findAction(QMenu* p, const QString& name
{
QList<QAction*> actions = p->actions();
QAction* action = NULL;
foreach(QAction* a, actions)
foreach (QAction* a, actions)
{
if (a->objectName() == name)
{
if(a->objectName() == name)
{
action = a;
break;
}
}
}
if(!action)
if (!action)
{
foreach (QAction* a, actions)
{
foreach(QAction* a, actions)
if (a->text() == name)
{
if(a->text() == name)
{
action = a;
break;
}
}
}
}
return action;
}
......@@ -7,7 +7,7 @@
All rights reserved.
ParaView is a free software; you can redistribute it and/or modify it
under the terms of the ParaView license version 1.2.
under the terms of the ParaView license version 1.2.
See License_v1.2.txt for the full ParaView license.
A copy of this license can be obtained by contacting
......@@ -39,22 +39,24 @@ class QMenuBar;
class QMenu;
/**
Concrete implementation of pqWidgetEventPlayer that handles playback of "activate" events for buttons and menus.
Concrete implementation of pqWidgetEventPlayer that handles playback of "activate" events for
buttons and menus.
\sa pqEventPlayer
*/
class QTTESTING_EXPORT pqAbstractActivateEventPlayer :
public pqWidgetEventPlayer
class QTTESTING_EXPORT pqAbstractActivateEventPlayer : public pqWidgetEventPlayer
{
Q_OBJECT
typedef pqWidgetEventPlayer Superclass;
public:
pqAbstractActivateEventPlayer(QObject* p = 0);
bool playEvent(QObject* Object, const QString& Command, const QString& Arguments, bool& Error);
using Superclass::playEvent;
bool playEvent(
QObject* Object, const QString& Command, const QString& Arguments, bool& Error) override;
private:
QAction* findAction(QMenu* p, const QString& name);
QAction* findAction(QMenuBar* p, const QString& name);
......@@ -63,4 +65,3 @@ private:
};
#endif // !_pqAbstractActivateEventPlayer_h
......@@ -7,7 +7,7 @@
All rights reserved.
ParaView is a free software; you can redistribute it and/or modify it
under the terms of the ParaView license version 1.2.
under the terms of the ParaView license version 1.2.
See License_v1.2.txt for the full ParaView license.
A copy of this license can be obtained by contacting
......@@ -33,48 +33,48 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include "pqAbstractBooleanEventPlayer.h"
#include <QAbstractButton>
#include <QAction>
#include <QGroupBox>
#include <QtDebug>
#include <QAction>
pqAbstractBooleanEventPlayer::pqAbstractBooleanEventPlayer(QObject* p)
: pqWidgetEventPlayer(p)
{
}
bool pqAbstractBooleanEventPlayer::playEvent(QObject* Object, const QString& Command, const QString& Arguments, bool& Error)
bool pqAbstractBooleanEventPlayer::playEvent(
QObject* Object, const QString& Command, const QString& Arguments, bool& Error)
{
if(Command != "set_boolean")
if (Command != "set_boolean")
return false;
const bool value = Arguments == "true" ? true : false;
if(QAbstractButton* const object = qobject_cast<QAbstractButton*>(Object))
{
if(value != object->isChecked())
if (QAbstractButton* const object = qobject_cast<QAbstractButton*>(Object))
{
if (value != object->isChecked())
object->click();
return true;
}
}
if (QAction* const action = qobject_cast<QAction*>(Object))
{
{
if (action->isChecked() != value)
{
{
action->trigger();
}
return true;
}
return true;
}
if ( QGroupBox* const object = qobject_cast<QGroupBox*>(Object))
if (QGroupBox* const object = qobject_cast<QGroupBox*>(Object))
{
if (value != object->isChecked())
{
if ( value != object->isChecked() )
{
object->setChecked( value );
}
return true;
object->setChecked(value);
}
return true;
}
qCritical() << "calling set_boolean on unhandled type " << Object;
Error = true;
return true;
}
......@@ -7,7 +7,7 @@
All rights reserved.
ParaView is a free software; you can redistribute it and/or modify it
under the terms of the ParaView license version 1.2.
under the terms of the ParaView license version 1.2.
See License_v1.2.txt for the full ParaView license.
A copy of this license can be obtained by contacting
......@@ -36,19 +36,22 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include "pqWidgetEventPlayer.h"
/**
Concrete implementation of pqWidgetEventPlayer that translates high-level ParaView events into low-level Qt events.
Concrete implementation of pqWidgetEventPlayer that translates high-level ParaView events into
low-level Qt events.
\sa pqEventPlayer
*/
class QTTESTING_EXPORT pqAbstractBooleanEventPlayer :
public pqWidgetEventPlayer
class QTTESTING_EXPORT pqAbstractBooleanEventPlayer : public pqWidgetEventPlayer
{
Q_OBJECT
typedef pqWidgetEventPlayer Superclass;