mirror of
https://github.com/OpenFOAM/ThirdParty-6.git
synced 2025-12-08 06:57:43 +00:00
ParaView-5.0.1: Added the source-tree to ThirdParty-dev and patched as described in the README file
Resolves bug-report http://bugs.openfoam.org/view.php?id=2098
This commit is contained in:
59
ParaView-5.0.1/ThirdParty/QtTesting/vtkqttesting/Testing/Cpp/CMakeLists.txt
vendored
Normal file
59
ParaView-5.0.1/ThirdParty/QtTesting/vtkqttesting/Testing/Cpp/CMakeLists.txt
vendored
Normal file
@ -0,0 +1,59 @@
|
||||
include(../CMake/qtTestingMacroGenerateMocs.cmake)
|
||||
|
||||
set(KIT ${PROJECT_NAME})
|
||||
|
||||
set(TEST_SOURCES
|
||||
pqEventPlayerTest.cpp
|
||||
pqEventRecorderTest.cpp
|
||||
pqEventTranslatorTest.cpp
|
||||
pqDoubleSpinBoxEventPlayerTest.cpp
|
||||
pqDoubleSpinBoxEventTranslatorTest.cpp
|
||||
pqSpinBoxEventPlayerTest.cpp
|
||||
pqSpinBoxEventTranslatorTest.cpp
|
||||
pqTestUtilityTest.cpp
|
||||
)
|
||||
|
||||
set(TEST_MOC_HEADERS
|
||||
pqTest.h
|
||||
)
|
||||
|
||||
create_test_sourcelist(Tests ${KIT}CppTests.cxx
|
||||
${TEST_SOURCES}
|
||||
)
|
||||
|
||||
set(TestsToRun ${Tests})
|
||||
remove(TestsToRun ${KIT}CppTests.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} ${QT_QTTEST_LIBRARY})
|
||||
set_target_properties(${KIT}CppTests PROPERTIES
|
||||
COMPILE_FLAGS "${Qt5Test_EXECUTABLE_COMPILE_FLAGS}")
|
||||
|
||||
macro(SIMPLE_TEST testname)
|
||||
add_test(NAME ${testname} COMMAND $<TARGET_FILE:${KIT}CppTests> ${testname} ${ARGN})
|
||||
endmacro()
|
||||
|
||||
#
|
||||
# Add Tests
|
||||
#
|
||||
SIMPLE_TEST( pqEventPlayerTest )
|
||||
SIMPLE_TEST( pqEventRecorderTest )
|
||||
SIMPLE_TEST( pqDoubleSpinBoxEventPlayerTest )
|
||||
SIMPLE_TEST( pqDoubleSpinBoxEventTranslatorTest )
|
||||
SIMPLE_TEST( pqSpinBoxEventPlayerTest )
|
||||
SIMPLE_TEST( pqSpinBoxEventTranslatorTest )
|
||||
SIMPLE_TEST( pqEventTranslatorTest )
|
||||
SIMPLE_TEST( pqTestUtilityTest )
|
||||
131
ParaView-5.0.1/ThirdParty/QtTesting/vtkqttesting/Testing/Cpp/pqDoubleSpinBoxEventPlayerTest.cpp
vendored
Normal file
131
ParaView-5.0.1/ThirdParty/QtTesting/vtkqttesting/Testing/Cpp/pqDoubleSpinBoxEventPlayerTest.cpp
vendored
Normal file
@ -0,0 +1,131 @@
|
||||
/*=========================================================================
|
||||
|
||||
Program: ParaView
|
||||
|
||||
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.
|
||||
|
||||
=========================================================================*/
|
||||
|
||||
// Qt includes
|
||||
#include <QApplication>
|
||||
#include <QDoubleSpinBox>
|
||||
#include <QStyle>
|
||||
#include <QtTest/QtTest>
|
||||
|
||||
// QtTesting includes
|
||||
#include "pqTestUtility.h"
|
||||
|
||||
#include "pqTest.h"
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
class pqDoubleSpinBoxEventPlayerTester: public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
private Q_SLOTS:
|
||||
|
||||
void initTestCase();
|
||||
void init();
|
||||
void cleanup();
|
||||
void cleanupTestCase();
|
||||
|
||||
void testPlayBackCommandSetDouble();
|
||||
void testPlayBackCommandSetDouble_data();
|
||||
|
||||
private:
|
||||
QDoubleSpinBox* DoubleSpinBox;
|
||||
|
||||
pqTestUtility* TestUtility;
|
||||
};
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
void pqDoubleSpinBoxEventPlayerTester::initTestCase()
|
||||
{
|
||||
this->TestUtility = new pqTestUtility();
|
||||
this->TestUtility->addEventObserver("xml", new pqDummyEventObserver);
|
||||
this->TestUtility->addEventSource("xml", new pqDummyEventSource());
|
||||
|
||||
this->DoubleSpinBox = 0;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
void pqDoubleSpinBoxEventPlayerTester::init()
|
||||
{
|
||||
// Init the QSpinBox
|
||||
this->DoubleSpinBox = new QDoubleSpinBox();
|
||||
this->DoubleSpinBox->setObjectName("doubleSpinBoxTest");
|
||||
this->DoubleSpinBox->setMinimum(-99.99);
|
||||
this->DoubleSpinBox->setValue(0);
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
void pqDoubleSpinBoxEventPlayerTester::cleanup()
|
||||
{
|
||||
delete this->DoubleSpinBox;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
void pqDoubleSpinBoxEventPlayerTester::cleanupTestCase()
|
||||
{
|
||||
delete this->TestUtility;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
void pqDoubleSpinBoxEventPlayerTester::testPlayBackCommandSetDouble()
|
||||
{
|
||||
QFETCH(double, value);
|
||||
QFETCH(double, result);
|
||||
QFETCH(int, count);
|
||||
|
||||
QSignalSpy spy(this->DoubleSpinBox, SIGNAL(valueChanged(double)));
|
||||
|
||||
bool error;
|
||||
this->TestUtility->eventPlayer()->playEvent(
|
||||
QString("doubleSpinBoxTest"), QString("set_double"),
|
||||
QString::number(value), error);
|
||||
|
||||
QCOMPARE(this->DoubleSpinBox->value(), result);
|
||||
QCOMPARE(spy.count(), count);
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
void pqDoubleSpinBoxEventPlayerTester::testPlayBackCommandSetDouble_data()
|
||||
{
|
||||
QTest::addColumn<double>("value");
|
||||
QTest::addColumn<double>("result");
|
||||
QTest::addColumn<int>("count");
|
||||
|
||||
QTest::newRow("negative") << -10.5 << -10.5 << 1;
|
||||
QTest::newRow("positive") << 33.25 << 33.25 << 1;
|
||||
QTest::newRow("negativeoutside") << -200.00 << -99.99 << 1;
|
||||
QTest::newRow("positiveoutside") << 200.00 << 99.99 << 1;
|
||||
QTest::newRow("negativeboundary") << -99.99 << -99.99 << 1;
|
||||
QTest::newRow("positiveboundary") << 99.99 << 99.99 << 1;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
CTK_TEST_MAIN( pqDoubleSpinBoxEventPlayerTest )
|
||||
#include "moc_pqDoubleSpinBoxEventPlayerTest.cpp"
|
||||
299
ParaView-5.0.1/ThirdParty/QtTesting/vtkqttesting/Testing/Cpp/pqDoubleSpinBoxEventTranslatorTest.cpp
vendored
Normal file
299
ParaView-5.0.1/ThirdParty/QtTesting/vtkqttesting/Testing/Cpp/pqDoubleSpinBoxEventTranslatorTest.cpp
vendored
Normal file
@ -0,0 +1,299 @@
|
||||
/*=========================================================================
|
||||
|
||||
Program: ParaView
|
||||
|
||||
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.
|
||||
|
||||
=========================================================================*/
|
||||
|
||||
// Qt includes
|
||||
#include <QApplication>
|
||||
#include <QDoubleSpinBox>
|
||||
#include <QStyle>
|
||||
#include <QtTest/QtTest>
|
||||
|
||||
// QtTesting includes
|
||||
#include "pqTestUtility.h"
|
||||
|
||||
#include "pqTest.h"
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
class pqDoubleSpinBoxEventTranslatorTester: public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
private Q_SLOTS:
|
||||
|
||||
void initTestCase();
|
||||
void init();
|
||||
void cleanup();
|
||||
void cleanupTestCase();
|
||||
|
||||
void testRecordLeftMouseClick();
|
||||
void testRecordLeftMouseClick_data();
|
||||
|
||||
void testRecordRightMouseClick();
|
||||
void testRecordRightMouseClick_data();
|
||||
|
||||
void testRecordMiddleMouseClick();
|
||||
void testRecordMiddleMouseClick_data();
|
||||
|
||||
void testRecordKeyBoardClick();
|
||||
void testRecordKeyBoardClick_data();
|
||||
|
||||
void testRecordComplexClick();
|
||||
|
||||
private:
|
||||
QDoubleSpinBox* DoubleSpinBox;
|
||||
|
||||
pqTestUtility* TestUtility;
|
||||
pqDummyEventObserver* EventObserver;
|
||||
};
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
void pqDoubleSpinBoxEventTranslatorTester::initTestCase()
|
||||
{
|
||||
this->TestUtility = new pqTestUtility();
|
||||
this->EventObserver = new pqDummyEventObserver();
|
||||
this->TestUtility->addEventObserver("xml", this->EventObserver);
|
||||
this->TestUtility->addEventSource("xml", new pqDummyEventSource());
|
||||
|
||||
this->DoubleSpinBox = 0;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
void pqDoubleSpinBoxEventTranslatorTester::init()
|
||||
{
|
||||
// Init the DoubleSpinBox
|
||||
this->DoubleSpinBox = new QDoubleSpinBox();
|
||||
this->DoubleSpinBox->setObjectName("doubleSpinBoxTest");
|
||||
this->DoubleSpinBox->setMinimum(-100);
|
||||
this->DoubleSpinBox->setSingleStep(0.25);
|
||||
|
||||
// Start to record events
|
||||
this->TestUtility->recordTestsBySuffix("xml");
|
||||
|
||||
// Fire the event "enter" to connect DoubleSpinBox signals to the translator slots
|
||||
QEvent enter(QEvent::Enter);
|
||||
qApp->notify(this->DoubleSpinBox, &enter);
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
void pqDoubleSpinBoxEventTranslatorTester::cleanup()
|
||||
{
|
||||
this->TestUtility->stopRecords(0);
|
||||
delete this->DoubleSpinBox;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
void pqDoubleSpinBoxEventTranslatorTester::cleanupTestCase()
|
||||
{
|
||||
this->EventObserver = 0;
|
||||
|
||||
delete this->TestUtility;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
void pqDoubleSpinBoxEventTranslatorTester::testRecordLeftMouseClick()
|
||||
{
|
||||
QFETCH(int, X);
|
||||
QFETCH(int, Y);
|
||||
QFETCH(QString, recordEmitted);
|
||||
|
||||
QTest::mouseClick(this->DoubleSpinBox, Qt::LeftButton, Qt::NoModifier, QPoint(X,Y));
|
||||
QCOMPARE(this->EventObserver->Text, recordEmitted);
|
||||
|
||||
this->EventObserver->Text = QString();
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
void pqDoubleSpinBoxEventTranslatorTester::testRecordLeftMouseClick_data()
|
||||
{
|
||||
QDoubleSpinBox doubleSpinBox;
|
||||
|
||||
QTest::addColumn<int>("X");
|
||||
QTest::addColumn<int>("Y");
|
||||
QTest::addColumn<QString>("recordEmitted");
|
||||
|
||||
QSize size = doubleSpinBox.size();
|
||||
int frameWidth =
|
||||
doubleSpinBox.style()->pixelMetric(QStyle::PM_SpinBoxFrameWidth) + 1;
|
||||
|
||||
QTest::newRow("0,0") << 0 << 0 << QString();
|
||||
QTest::newRow("invalid") << - size.rwidth()<< 0 << QString();
|
||||
QTest::newRow("middle") << size.rwidth()/2 << size.rheight()/2 << QString();
|
||||
QTest::newRow("arrow up") << size.rwidth()- frameWidth
|
||||
<< frameWidth
|
||||
<< QString("doubleSpinBoxTest, set_double, 0.25#");
|
||||
QTest::newRow("arrow down") << size.rwidth()- frameWidth
|
||||
<< size.rheight() - frameWidth
|
||||
<< QString("doubleSpinBoxTest, set_double, -0.25#");
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
void pqDoubleSpinBoxEventTranslatorTester::testRecordRightMouseClick()
|
||||
{
|
||||
QFETCH(int, X);
|
||||
QFETCH(int, Y);
|
||||
QFETCH(QString, recordEmitted);
|
||||
|
||||
QTest::mouseClick(this->DoubleSpinBox, Qt::RightButton, Qt::NoModifier, QPoint(X,Y));
|
||||
QCOMPARE(this->EventObserver->Text, recordEmitted);
|
||||
|
||||
this->EventObserver->Text = QString();
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
void pqDoubleSpinBoxEventTranslatorTester::testRecordRightMouseClick_data()
|
||||
{
|
||||
QDoubleSpinBox doubleSpinBox;
|
||||
|
||||
QTest::addColumn<int>("X");
|
||||
QTest::addColumn<int>("Y");
|
||||
QTest::addColumn<QString>("recordEmitted");
|
||||
|
||||
QSize size = doubleSpinBox.size();
|
||||
int frameWidth =
|
||||
doubleSpinBox.style()->pixelMetric(QStyle::PM_SpinBoxFrameWidth) + 1;
|
||||
|
||||
QTest::newRow("0,0") << 0 << 0 << QString();
|
||||
QTest::newRow("invalid") << - size.rwidth()<< 0 << QString();
|
||||
QTest::newRow("middle") << size.rwidth()/2 << size.rheight()/2 << QString();
|
||||
QTest::newRow("arrow up") << size.rwidth()- frameWidth
|
||||
<< frameWidth
|
||||
<< QString();
|
||||
QTest::newRow("arrow down") << size.rwidth()- frameWidth
|
||||
<< size.rheight() - frameWidth
|
||||
<< QString();
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
void pqDoubleSpinBoxEventTranslatorTester::testRecordMiddleMouseClick()
|
||||
{
|
||||
QFETCH(int, X);
|
||||
QFETCH(int, Y);
|
||||
QFETCH(QString, recordEmitted);
|
||||
|
||||
QTest::mouseClick(this->DoubleSpinBox, Qt::MiddleButton,
|
||||
Qt::NoModifier, QPoint(X,Y));
|
||||
QCOMPARE(this->EventObserver->Text, recordEmitted);
|
||||
|
||||
this->EventObserver->Text = QString();
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
void pqDoubleSpinBoxEventTranslatorTester::testRecordMiddleMouseClick_data()
|
||||
{
|
||||
this->testRecordRightMouseClick_data();
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
void pqDoubleSpinBoxEventTranslatorTester::testRecordKeyBoardClick()
|
||||
{
|
||||
QFETCH(QString, number);
|
||||
QFETCH(QString, recordEmitted);
|
||||
this->DoubleSpinBox->clear();
|
||||
|
||||
QTest::keyClicks(this->DoubleSpinBox, number);
|
||||
QCOMPARE(this->EventObserver->Text, recordEmitted);
|
||||
|
||||
this->EventObserver->Text = QString();
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
void pqDoubleSpinBoxEventTranslatorTester::testRecordKeyBoardClick_data()
|
||||
{
|
||||
QTest::addColumn<QString>("number");
|
||||
QTest::addColumn<QString>("recordEmitted");
|
||||
|
||||
QTest::newRow("33.5") << QString::number(33.5)
|
||||
<< QString("%1#%2#%3#")
|
||||
.arg(QString("doubleSpinBoxTest, set_double, 3"),
|
||||
QString("doubleSpinBoxTest, set_double, 33"),
|
||||
QString("doubleSpinBoxTest, set_double, 33.5"));
|
||||
QTest::newRow("-5.23") << QString::number(-5.23)
|
||||
<< QString("%1#%2#%3#")
|
||||
.arg(QString("doubleSpinBoxTest, set_double, -5"),
|
||||
QString("doubleSpinBoxTest, set_double, -5.2"),
|
||||
QString("doubleSpinBoxTest, set_double, -5.23"));
|
||||
QTest::newRow("aa") << QString("aa")
|
||||
<< QString();
|
||||
QTest::newRow("2.aa") << QString("2.aa")
|
||||
<< QString("doubleSpinBoxTest, set_double, 2#");
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
void pqDoubleSpinBoxEventTranslatorTester::testRecordComplexClick()
|
||||
{
|
||||
QSize size = this->DoubleSpinBox->size();
|
||||
int frameWidth =
|
||||
this->DoubleSpinBox->style()->pixelMetric(QStyle::PM_SpinBoxFrameWidth) + 1;
|
||||
|
||||
QString recordExpected;
|
||||
|
||||
this->DoubleSpinBox->clear();
|
||||
QTest::keyClicks(this->DoubleSpinBox, QString::number(-5.25));
|
||||
recordExpected.append(QString("doubleSpinBoxTest, set_double, -5#"));
|
||||
recordExpected.append(QString("doubleSpinBoxTest, set_double, -5.2#"));
|
||||
recordExpected.append(QString("doubleSpinBoxTest, set_double, -5.25#"));
|
||||
|
||||
QTest::mouseClick(this->DoubleSpinBox, Qt::LeftButton, Qt::NoModifier,
|
||||
QPoint(size.rwidth()- frameWidth , size.rheight() - frameWidth));
|
||||
recordExpected.append(QString("doubleSpinBoxTest, set_double, -5.5#"));
|
||||
|
||||
QTest::mouseClick(this->DoubleSpinBox, Qt::LeftButton, Qt::NoModifier,
|
||||
QPoint(size.rwidth()- frameWidth , size.rheight() - frameWidth));
|
||||
recordExpected.append(QString("doubleSpinBoxTest, set_double, -5.75#"));
|
||||
|
||||
QTest::mouseClick(this->DoubleSpinBox, Qt::LeftButton, Qt::NoModifier,
|
||||
QPoint(size.rwidth()- frameWidth , frameWidth));
|
||||
recordExpected.append(QString("doubleSpinBoxTest, set_double, -5.5#"));
|
||||
|
||||
QTest::mouseClick(this->DoubleSpinBox, Qt::LeftButton, Qt::NoModifier,
|
||||
QPoint(size.rwidth()- frameWidth , frameWidth));
|
||||
recordExpected.append(QString("doubleSpinBoxTest, set_double, -5.25#"));
|
||||
|
||||
QTest::mouseClick(this->DoubleSpinBox, Qt::LeftButton, Qt::NoModifier,
|
||||
QPoint(size.rwidth()- frameWidth , frameWidth));
|
||||
recordExpected.append(QString("doubleSpinBoxTest, set_double, -5#"));
|
||||
|
||||
QTest::mouseClick(this->DoubleSpinBox, Qt::LeftButton, Qt::NoModifier,
|
||||
QPoint(size.rwidth()- frameWidth , frameWidth));
|
||||
recordExpected.append(QString("doubleSpinBoxTest, set_double, -4.75#"));
|
||||
|
||||
QTest::mouseClick(this->DoubleSpinBox, Qt::LeftButton, Qt::NoModifier,
|
||||
QPoint(size.rwidth()- frameWidth , frameWidth));
|
||||
recordExpected.append(QString("doubleSpinBoxTest, set_double, -4.5#"));
|
||||
|
||||
QTest::keyClicks(this->DoubleSpinBox, QString::number(0));
|
||||
recordExpected.append(QString("doubleSpinBoxTest, set_double, 0#"));
|
||||
|
||||
QCOMPARE(this->EventObserver->Text, recordExpected);
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
CTK_TEST_MAIN( pqDoubleSpinBoxEventTranslatorTest )
|
||||
#include "moc_pqDoubleSpinBoxEventTranslatorTest.cpp"
|
||||
221
ParaView-5.0.1/ThirdParty/QtTesting/vtkqttesting/Testing/Cpp/pqEventPlayerTest.cpp
vendored
Normal file
221
ParaView-5.0.1/ThirdParty/QtTesting/vtkqttesting/Testing/Cpp/pqEventPlayerTest.cpp
vendored
Normal file
@ -0,0 +1,221 @@
|
||||
/*=========================================================================
|
||||
|
||||
Program: ParaView
|
||||
Module: pqEventPlayer.h
|
||||
|
||||
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.
|
||||
|
||||
=========================================================================*/
|
||||
|
||||
// Qt includes
|
||||
#include <QApplication>
|
||||
|
||||
// QtTesting includes
|
||||
#include "pqCommentEventPlayer.h"
|
||||
#include "pqEventPlayer.h"
|
||||
#include "pqTestUtility.h"
|
||||
#include "pqTreeViewEventPlayer.h"
|
||||
|
||||
#include "pqTest.h"
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
class pqEventPlayerTester: public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
private Q_SLOTS:
|
||||
|
||||
void testDefaults();
|
||||
|
||||
void testAddWidgetEventPlayer();
|
||||
void testAddWidgetEventPlayer_data();
|
||||
|
||||
void testRemoveWidgetEventPlayer();
|
||||
void testRemoveWidgetEventPlayer_data();
|
||||
|
||||
void testGetWidgetEventPlayer();
|
||||
|
||||
void testAddDefaultWidgetEventPlayers();
|
||||
void testAddDefaultWidgetEventPlayers_data();
|
||||
};
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
void pqEventPlayerTester::testDefaults()
|
||||
{
|
||||
pqEventPlayer eventPlayer;
|
||||
|
||||
QCOMPARE(eventPlayer.players().count(), 0);
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
void pqEventPlayerTester::testAddWidgetEventPlayer()
|
||||
{
|
||||
pqEventPlayer eventPlayer;
|
||||
|
||||
QFETCH(QObject*, widget1);
|
||||
QFETCH(int, newCount1);
|
||||
QFETCH(QObject*, widget2);
|
||||
QFETCH(int, newCount2);
|
||||
|
||||
// When we add the widgetEventPlayer into the eventPlayer, it is automaticaly
|
||||
// reparented to the eventPlayer. So its deletion would be automatic.
|
||||
eventPlayer.addWidgetEventPlayer(qobject_cast<pqWidgetEventPlayer*>(widget1));
|
||||
QCOMPARE(eventPlayer.players().count(), newCount1);
|
||||
|
||||
eventPlayer.addWidgetEventPlayer(qobject_cast<pqWidgetEventPlayer*>(widget2));
|
||||
QCOMPARE(eventPlayer.players().count(), newCount2);
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
void pqEventPlayerTester::testAddWidgetEventPlayer_data()
|
||||
{
|
||||
QTest::addColumn<QObject*>("widget1");
|
||||
QTest::addColumn<int>("newCount1");
|
||||
QTest::addColumn<QObject*>("widget2");
|
||||
QTest::addColumn<int>("newCount2");
|
||||
|
||||
pqWidgetEventPlayer* nullWidget = NULL;
|
||||
QTest::newRow("empty_empty")
|
||||
<< qobject_cast<QObject*>(nullWidget) << 0
|
||||
<< qobject_cast<QObject*>(nullWidget) << 0;
|
||||
QTest::newRow("empty_pqComment")
|
||||
<< qobject_cast<QObject*>(nullWidget) << 0
|
||||
<< qobject_cast<QObject*>(new pqCommentEventPlayer(0)) << 1;
|
||||
QTest::newRow("pqComment_pqComment")
|
||||
<< qobject_cast<QObject*>(new pqCommentEventPlayer(0)) << 1
|
||||
<< qobject_cast<QObject*>(new pqCommentEventPlayer(0)) << 1;
|
||||
QTest::newRow("pqComment_pqTreeView")
|
||||
<< qobject_cast<QObject*>(new pqCommentEventPlayer(0)) << 1
|
||||
<< qobject_cast<QObject*>(new pqTreeViewEventPlayer()) << 2;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
void pqEventPlayerTester::testRemoveWidgetEventPlayer()
|
||||
{
|
||||
pqEventPlayer eventPlayer;
|
||||
|
||||
QFETCH(QString, nameToRemove);
|
||||
QFETCH(bool, firstResult);
|
||||
QFETCH(bool, secondResult);
|
||||
QFETCH(int, newCount);
|
||||
QFETCH(bool, thirdResult);
|
||||
|
||||
QCOMPARE(eventPlayer.removeWidgetEventPlayer(nameToRemove),
|
||||
firstResult);
|
||||
|
||||
// When we add the widgetEventPlayer into the eventPlayer, it is automaticaly
|
||||
// reparented to the eventPlayer. So its deletion would be automatic.
|
||||
pqCommentEventPlayer* commentPlayer = new pqCommentEventPlayer(0);
|
||||
eventPlayer.addWidgetEventPlayer(commentPlayer);
|
||||
|
||||
QCOMPARE(eventPlayer.players().count(), 1);
|
||||
QCOMPARE(eventPlayer.removeWidgetEventPlayer(nameToRemove),
|
||||
secondResult);
|
||||
QCOMPARE(eventPlayer.players().count(), newCount);
|
||||
QCOMPARE(eventPlayer.removeWidgetEventPlayer(nameToRemove),
|
||||
thirdResult);
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
void pqEventPlayerTester::testRemoveWidgetEventPlayer_data()
|
||||
{
|
||||
QTest::addColumn<QString>("nameToRemove");
|
||||
QTest::addColumn<bool>("firstResult");
|
||||
QTest::addColumn<bool>("secondResult");
|
||||
QTest::addColumn<int>("newCount");
|
||||
QTest::addColumn<bool>("thirdResult");
|
||||
|
||||
QTest::newRow("empty") << "" << false << false << 1 << false;
|
||||
QTest::newRow("wrong") << "pqTreeViewEventPlayer" << false << false << 1 << false;
|
||||
QTest::newRow("right") << "pqCommentEventPlayer" << false << true << 0 << false;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
void pqEventPlayerTester::testGetWidgetEventPlayer()
|
||||
{
|
||||
pqEventPlayer eventPlayer;
|
||||
|
||||
pqWidgetEventPlayer* nullWidget = NULL;
|
||||
QCOMPARE(eventPlayer.getWidgetEventPlayer(0),
|
||||
nullWidget);
|
||||
QCOMPARE(eventPlayer.getWidgetEventPlayer("pqCommentEventPlayer"),
|
||||
nullWidget);
|
||||
|
||||
// When we add the widgetEventPlayer into the eventPlayer, it is automaticaly
|
||||
// reparented to the eventPlayer. So its deletion would be automatic.
|
||||
pqCommentEventPlayer* comment = new pqCommentEventPlayer(0);
|
||||
eventPlayer.addWidgetEventPlayer(comment);
|
||||
|
||||
QCOMPARE(eventPlayer.getWidgetEventPlayer(0),
|
||||
nullWidget);
|
||||
QCOMPARE(eventPlayer.getWidgetEventPlayer("pqTreeViewEventPlayer"),
|
||||
nullWidget);
|
||||
QCOMPARE(eventPlayer.getWidgetEventPlayer("pqCommentEventPlayer"),
|
||||
comment);
|
||||
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
void pqEventPlayerTester::testAddDefaultWidgetEventPlayers()
|
||||
{
|
||||
pqEventPlayer eventPlayer;
|
||||
pqTestUtility testUtility;
|
||||
|
||||
eventPlayer.addDefaultWidgetEventPlayers(&testUtility);
|
||||
QList<pqWidgetEventPlayer*> players = eventPlayer.players();
|
||||
|
||||
QFETCH(QString, widgetEventPlayerName);
|
||||
QFETCH(int, index);
|
||||
|
||||
QCOMPARE(QString(players.at(index)->metaObject()->className()),
|
||||
widgetEventPlayerName);
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
void pqEventPlayerTester::testAddDefaultWidgetEventPlayers_data()
|
||||
{
|
||||
QTest::addColumn<int>("index");
|
||||
QTest::addColumn<QString>("widgetEventPlayerName");
|
||||
|
||||
QTest::newRow("0") << 0 << "pqNativeFileDialogEventPlayer";
|
||||
QTest::newRow("1") << 1 << "pq3DViewEventPlayer";
|
||||
QTest::newRow("2") << 2 << "pqAbstractMiscellaneousEventPlayer";
|
||||
QTest::newRow("3") << 3 << "pqTreeViewEventPlayer";
|
||||
QTest::newRow("4") << 4 << "pqTabBarEventPlayer";
|
||||
QTest::newRow("5") << 5 << "pqAbstractStringEventPlayer";
|
||||
QTest::newRow("6") << 6 << "pqAbstractItemViewEventPlayer";
|
||||
QTest::newRow("7") << 7 << "pqAbstractIntEventPlayer";
|
||||
QTest::newRow("8") << 8 << "pqAbstractDoubleEventPlayer";
|
||||
QTest::newRow("9") << 9 << "pqAbstractBooleanEventPlayer";
|
||||
QTest::newRow("10") << 10 << "pqAbstractActivateEventPlayer";
|
||||
QTest::newRow("11") << 11 << "pqBasicWidgetEventPlayer";
|
||||
QTest::newRow("12") << 12 << "pqCommentEventPlayer";
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
CTK_TEST_MAIN(pqEventPlayerTest)
|
||||
#include "moc_pqEventPlayerTest.cpp"
|
||||
|
||||
210
ParaView-5.0.1/ThirdParty/QtTesting/vtkqttesting/Testing/Cpp/pqEventRecorderTest.cpp
vendored
Normal file
210
ParaView-5.0.1/ThirdParty/QtTesting/vtkqttesting/Testing/Cpp/pqEventRecorderTest.cpp
vendored
Normal file
@ -0,0 +1,210 @@
|
||||
/*=========================================================================
|
||||
|
||||
Program: ParaView
|
||||
|
||||
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.
|
||||
|
||||
=========================================================================*/
|
||||
|
||||
// Qt includes
|
||||
#include <QApplication>
|
||||
|
||||
// QtTesting includes
|
||||
#include "pqEventObserver.h"
|
||||
#include "pqEventRecorder.h"
|
||||
#include "pqTestUtility.h"
|
||||
|
||||
#include "pqTest.h"
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
class pqEventRecorderTester: public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
private Q_SLOTS:
|
||||
|
||||
void testDefaults();
|
||||
|
||||
void testSetFile();
|
||||
|
||||
void testSetObserver();
|
||||
void testSetTranslator();
|
||||
|
||||
void testSetContiniousFlush();
|
||||
void testSetContiniousFlush_data();
|
||||
|
||||
void testRecordEvents();
|
||||
void testRecordEvents_data();
|
||||
};
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
void pqEventRecorderTester::testDefaults()
|
||||
{
|
||||
pqEventRecorder eventRecorder;
|
||||
|
||||
QIODevice* nullDevice = 0;
|
||||
pqEventObserver* nullObserver = 0;
|
||||
pqEventTranslator* nullTranslator = 0;
|
||||
|
||||
QCOMPARE(eventRecorder.isRecording(), false);
|
||||
QCOMPARE(eventRecorder.file(), nullDevice);
|
||||
QCOMPARE(eventRecorder.observer(), nullObserver);
|
||||
QCOMPARE(eventRecorder.translator(), nullTranslator);
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
void pqEventRecorderTester::testSetFile()
|
||||
{
|
||||
pqEventRecorder recorder;
|
||||
|
||||
QFile file;
|
||||
recorder.setFile(&file);
|
||||
QCOMPARE(recorder.file(), &file);
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
void pqEventRecorderTester::testSetObserver()
|
||||
{
|
||||
pqEventRecorder recorder;
|
||||
|
||||
pqDummyEventObserver observer;
|
||||
recorder.setObserver(&observer);
|
||||
QCOMPARE(recorder.observer(), &observer);
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
void pqEventRecorderTester::testSetTranslator()
|
||||
{
|
||||
pqEventRecorder recorder;
|
||||
|
||||
pqEventTranslator translator;
|
||||
recorder.setTranslator(&translator);
|
||||
QCOMPARE(recorder.translator(), &translator);
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
void pqEventRecorderTester::testSetContiniousFlush()
|
||||
{
|
||||
pqEventRecorder recorder;
|
||||
|
||||
QFETCH(bool, activeObserver);
|
||||
QFETCH(bool, first);
|
||||
QFETCH(bool, firstResult);
|
||||
QFETCH(bool, second);
|
||||
QFETCH(bool, secondResult);
|
||||
|
||||
recorder.setObserver(activeObserver ? new pqDummyEventObserver() : 0);
|
||||
recorder.setContinuousFlush(first);
|
||||
QCOMPARE(recorder.continuousFlush(), firstResult);
|
||||
recorder.setContinuousFlush(second);
|
||||
QCOMPARE(recorder.continuousFlush(), secondResult);
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
void pqEventRecorderTester::testSetContiniousFlush_data()
|
||||
{
|
||||
QTest::addColumn<bool>("activeObserver");
|
||||
QTest::addColumn<bool>("first");
|
||||
QTest::addColumn<bool>("firstResult");
|
||||
QTest::addColumn<bool>("second");
|
||||
QTest::addColumn<bool>("secondResult");
|
||||
|
||||
QTest::newRow("1") << false << false << false << false << false;
|
||||
QTest::newRow("2") << false << false << false << true << false;
|
||||
QTest::newRow("3") << false << true << false << false << false;
|
||||
QTest::newRow("4") << false << true << false << true << false;
|
||||
|
||||
QTest::newRow("5") << true << false << false << false << false;
|
||||
QTest::newRow("6") << true << false << false << true << true;
|
||||
QTest::newRow("7") << true << true << true << false << false;
|
||||
QTest::newRow("8") << true << true << true << true << true;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
void pqEventRecorderTester::testRecordEvents()
|
||||
{
|
||||
pqEventRecorder recorder;
|
||||
|
||||
QFETCH(QObject*, ioDevice);
|
||||
QFETCH(QObject*, activeObserver);
|
||||
QFETCH(QObject*, activeTranslator);
|
||||
QFETCH(bool, continuousFlush);
|
||||
QFETCH(bool, started);
|
||||
QFETCH(bool, flushing);
|
||||
|
||||
recorder.recordEvents(qobject_cast<pqEventTranslator*>(activeTranslator),
|
||||
qobject_cast<pqEventObserver*>(activeObserver),
|
||||
qobject_cast<QFile*>(ioDevice),
|
||||
continuousFlush);
|
||||
|
||||
QCOMPARE(recorder.isRecording(), started);
|
||||
QCOMPARE(recorder.continuousFlush(), flushing);
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
void pqEventRecorderTester::testRecordEvents_data()
|
||||
{
|
||||
QTest::addColumn<QObject*>("ioDevice");
|
||||
QTest::addColumn<QObject*>("activeObserver");
|
||||
QTest::addColumn<QObject*>("activeTranslator");
|
||||
QTest::addColumn<bool>("continuousFlush");
|
||||
QTest::addColumn<bool>("started");
|
||||
QTest::addColumn<bool>("flushing");
|
||||
|
||||
QFile* nullFile = 0;
|
||||
QFile* file = new QFile;
|
||||
|
||||
pqEventObserver* nullObserver = 0;
|
||||
pqDummyEventObserver* observer = new pqDummyEventObserver;
|
||||
|
||||
pqEventTranslator* nullTranslator = 0;
|
||||
pqEventTranslator* translator = new pqEventTranslator;
|
||||
|
||||
QTest::newRow("1") << qobject_cast<QObject*>(nullFile)
|
||||
<< qobject_cast<QObject*>(nullObserver )
|
||||
<< qobject_cast<QObject*>(nullTranslator)
|
||||
<< false << false << false;
|
||||
QTest::newRow("2") << qobject_cast<QObject*>(nullFile)
|
||||
<< qobject_cast<QObject*>(nullObserver )
|
||||
<< qobject_cast<QObject*>(translator)
|
||||
<< false << false << false;
|
||||
QTest::newRow("3") << qobject_cast<QObject*>(nullFile)
|
||||
<< qobject_cast<QObject*>(observer )
|
||||
<< qobject_cast<QObject*>(translator)
|
||||
<< false << false << false;
|
||||
QTest::newRow("4") << qobject_cast<QObject*>(file)
|
||||
<< qobject_cast<QObject*>(observer)
|
||||
<< qobject_cast<QObject*>(translator)
|
||||
<< false << true << false;
|
||||
QTest::newRow("4") << qobject_cast<QObject*>(file)
|
||||
<< qobject_cast<QObject*>(observer)
|
||||
<< qobject_cast<QObject*>(translator)
|
||||
<< true << true << true;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
CTK_TEST_MAIN(pqEventRecorderTest)
|
||||
#include "moc_pqEventRecorderTest.cpp"
|
||||
220
ParaView-5.0.1/ThirdParty/QtTesting/vtkqttesting/Testing/Cpp/pqEventTranslatorTest.cpp
vendored
Normal file
220
ParaView-5.0.1/ThirdParty/QtTesting/vtkqttesting/Testing/Cpp/pqEventTranslatorTest.cpp
vendored
Normal file
@ -0,0 +1,220 @@
|
||||
/*=========================================================================
|
||||
|
||||
Program: ParaView
|
||||
Module: pqEventPlayer.h
|
||||
|
||||
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.
|
||||
|
||||
=========================================================================*/
|
||||
|
||||
// Qt includes
|
||||
#include <QApplication>
|
||||
|
||||
// QtTesting includes
|
||||
#include "pqEventTranslator.h"
|
||||
#include "pqSpinBoxEventTranslator.h"
|
||||
#include "pqTestUtility.h"
|
||||
#include "pqTreeViewEventTranslator.h"
|
||||
|
||||
#include "pqTest.h"
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
class pqEventTranslatorTester : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
private Q_SLOTS:
|
||||
|
||||
void testDefaults();
|
||||
|
||||
void testAddWidgetEventTranslator();
|
||||
void testAddWidgetEventTranslator_data();
|
||||
|
||||
void testRemoveWidgetEventTranslator();
|
||||
void testRemoveWidgetEventTranslator_data();
|
||||
|
||||
void testGetWidgetEventTranslator();
|
||||
|
||||
void testAddDefaultWidgetEventTranslators();
|
||||
void testAddDefaultWidgetEventTranslators_data();
|
||||
};
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
void pqEventTranslatorTester::testDefaults()
|
||||
{
|
||||
pqEventTranslator eventTranslator;
|
||||
|
||||
QCOMPARE(eventTranslator.translators().count(), 0);
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
void pqEventTranslatorTester::testAddWidgetEventTranslator()
|
||||
{
|
||||
pqEventTranslator eventTranslator;
|
||||
|
||||
QFETCH(QObject*, widget1);
|
||||
QFETCH(int, newCount1);
|
||||
QFETCH(QObject*, widget2);
|
||||
QFETCH(int, newCount2);
|
||||
|
||||
// When we add the widgetEventPlayer into the eventPlayer, it is automaticaly
|
||||
// reparented to the eventPlayer. So its deletion would be automatic.
|
||||
eventTranslator.addWidgetEventTranslator(
|
||||
dynamic_cast<pqWidgetEventTranslator*>(widget1));
|
||||
QCOMPARE(eventTranslator.translators().count(), newCount1);
|
||||
|
||||
eventTranslator.addWidgetEventTranslator(
|
||||
dynamic_cast<pqWidgetEventTranslator*>(widget2));
|
||||
QCOMPARE(eventTranslator.translators().count(), newCount2);
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
void pqEventTranslatorTester::testAddWidgetEventTranslator_data()
|
||||
{
|
||||
QTest::addColumn<QObject*>("widget1");
|
||||
QTest::addColumn<int>("newCount1");
|
||||
QTest::addColumn<QObject*>("widget2");
|
||||
QTest::addColumn<int>("newCount2");
|
||||
|
||||
pqWidgetEventTranslator* nullWidget = NULL;
|
||||
QTest::newRow("empty_empty")
|
||||
<< qobject_cast<QObject*>(nullWidget) << 0
|
||||
<< qobject_cast<QObject*>(nullWidget) << 0;
|
||||
QTest::newRow("empty_pqSpinBox")
|
||||
<< qobject_cast<QObject*>(nullWidget) << 0
|
||||
<< qobject_cast<QObject*>(new pqSpinBoxEventTranslator()) << 1;
|
||||
QTest::newRow("pqSpinBox_pqSpinBox")
|
||||
<< qobject_cast<QObject*>(new pqSpinBoxEventTranslator()) << 1
|
||||
<< qobject_cast<QObject*>(new pqSpinBoxEventTranslator()) << 1;
|
||||
QTest::newRow("pqSpinBox_pqTreeView")
|
||||
<< qobject_cast<QObject*>(new pqSpinBoxEventTranslator()) << 1
|
||||
<< qobject_cast<QObject*>(new pqTreeViewEventTranslator()) << 2;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
void pqEventTranslatorTester::testRemoveWidgetEventTranslator()
|
||||
{
|
||||
pqEventTranslator eventTranslator;
|
||||
|
||||
QFETCH(QString, nameToRemove);
|
||||
QFETCH(bool, firstResult);
|
||||
QFETCH(bool, secondResult);
|
||||
QFETCH(int, newCount);
|
||||
QFETCH(bool, thirdResult);
|
||||
|
||||
QCOMPARE(eventTranslator.removeWidgetEventTranslator(nameToRemove),
|
||||
firstResult);
|
||||
|
||||
// When we add the widgetEventPlayer into the eventPlayer, it is automaticaly
|
||||
// reparented to the eventPlayer. So its deletion would be automatic.
|
||||
pqTreeViewEventTranslator* treeView = new pqTreeViewEventTranslator();
|
||||
eventTranslator.addWidgetEventTranslator(treeView);
|
||||
|
||||
QCOMPARE(eventTranslator.translators().count(), 1);
|
||||
QCOMPARE(eventTranslator.removeWidgetEventTranslator(nameToRemove),
|
||||
secondResult);
|
||||
QCOMPARE(eventTranslator.translators().count(), newCount);
|
||||
QCOMPARE(eventTranslator.removeWidgetEventTranslator(nameToRemove),
|
||||
thirdResult);
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
void pqEventTranslatorTester::testRemoveWidgetEventTranslator_data()
|
||||
{
|
||||
QTest::addColumn<QString>("nameToRemove");
|
||||
QTest::addColumn<bool>("firstResult");
|
||||
QTest::addColumn<bool>("secondResult");
|
||||
QTest::addColumn<int>("newCount");
|
||||
QTest::addColumn<bool>("thirdResult");
|
||||
|
||||
QTest::newRow("empty") << "" << false << false << 1 << false;
|
||||
QTest::newRow("wrong") << "pqSpinBoxEventTranslator" << false << false << 1 << false;
|
||||
QTest::newRow("right") << "pqTreeViewEventTranslator" << false << true << 0 << false;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
void pqEventTranslatorTester::testGetWidgetEventTranslator()
|
||||
{
|
||||
pqEventTranslator eventTranslator;
|
||||
|
||||
pqSpinBoxEventTranslator* nullWidget = NULL;
|
||||
QCOMPARE(eventTranslator.getWidgetEventTranslator(0),
|
||||
nullWidget);
|
||||
QCOMPARE(eventTranslator.getWidgetEventTranslator("pqSpinBoxEventTranslator"),
|
||||
nullWidget);
|
||||
|
||||
// When we add the widgetEventPlayer into the eventPlayer, it is automaticaly
|
||||
// reparented to the eventPlayer. So its deletion would be automatic.
|
||||
pqSpinBoxEventTranslator* spinBox = new pqSpinBoxEventTranslator();
|
||||
eventTranslator.addWidgetEventTranslator(spinBox);
|
||||
|
||||
QCOMPARE(eventTranslator.getWidgetEventTranslator(0),
|
||||
nullWidget);
|
||||
QCOMPARE(eventTranslator.getWidgetEventTranslator("pqTreeViewEventTranslator"),
|
||||
nullWidget);
|
||||
QCOMPARE(eventTranslator.getWidgetEventTranslator("pqSpinBoxEventTranslator"),
|
||||
spinBox);
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
void pqEventTranslatorTester::testAddDefaultWidgetEventTranslators()
|
||||
{
|
||||
pqEventTranslator eventTranslator;
|
||||
pqTestUtility testUtility;
|
||||
eventTranslator.addDefaultWidgetEventTranslators(&testUtility);
|
||||
QList<pqWidgetEventTranslator*> translators = eventTranslator.translators();
|
||||
|
||||
QFETCH(int, index);
|
||||
QFETCH(QString, widgetEventTranslatorName);
|
||||
|
||||
QCOMPARE(QString(translators.at(index)->metaObject()->className()),
|
||||
widgetEventTranslatorName);
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
void pqEventTranslatorTester::testAddDefaultWidgetEventTranslators_data()
|
||||
{
|
||||
QTest::addColumn<int>("index");
|
||||
QTest::addColumn<QString>("widgetEventTranslatorName");
|
||||
|
||||
QTest::newRow("0") << 0 << "pqNativeFileDialogEventTranslator";
|
||||
QTest::newRow("1") << 1 << "pq3DViewEventTranslator";
|
||||
QTest::newRow("2") << 2 << "pqTreeViewEventTranslator";
|
||||
QTest::newRow("3") << 3 << "pqTabBarEventTranslator";
|
||||
QTest::newRow("4") << 4 << "pqSpinBoxEventTranslator";
|
||||
QTest::newRow("5") << 5 << "pqMenuEventTranslator";
|
||||
QTest::newRow("6") << 6 << "pqLineEditEventTranslator";
|
||||
QTest::newRow("7") << 7 << "pqDoubleSpinBoxEventTranslator";
|
||||
QTest::newRow("8") << 8 << "pqComboBoxEventTranslator";
|
||||
QTest::newRow("9") << 9 << "pqAbstractSliderEventTranslator";
|
||||
QTest::newRow("10") << 10 << "pqAbstractItemViewEventTranslator";
|
||||
QTest::newRow("11") << 11 << "pqAbstractButtonEventTranslator";
|
||||
QTest::newRow("12") << 12 << "pqBasicWidgetEventTranslator";
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
CTK_TEST_MAIN(pqEventTranslatorTest)
|
||||
#include "moc_pqEventTranslatorTest.cpp"
|
||||
128
ParaView-5.0.1/ThirdParty/QtTesting/vtkqttesting/Testing/Cpp/pqSpinBoxEventPlayerTest.cpp
vendored
Normal file
128
ParaView-5.0.1/ThirdParty/QtTesting/vtkqttesting/Testing/Cpp/pqSpinBoxEventPlayerTest.cpp
vendored
Normal file
@ -0,0 +1,128 @@
|
||||
/*=========================================================================
|
||||
|
||||
Program: ParaView
|
||||
|
||||
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.
|
||||
|
||||
=========================================================================*/
|
||||
|
||||
// Qt includes
|
||||
#include <QApplication>
|
||||
#include <QSpinBox>
|
||||
#include <QtTest/QtTest>
|
||||
|
||||
// QtTesting includes
|
||||
#include "pqTestUtility.h"
|
||||
|
||||
#include "pqTest.h"
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
class pqSpinBoxEventPlayerTester: public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
private Q_SLOTS:
|
||||
|
||||
void initTestCase();
|
||||
void init();
|
||||
void cleanup();
|
||||
void cleanupTestCase();
|
||||
|
||||
void testPlayBackCommandSetInt();
|
||||
void testPlayBackCommandSetInt_data();
|
||||
|
||||
private:
|
||||
QSpinBox* SpinBox;
|
||||
|
||||
pqTestUtility* TestUtility;
|
||||
};
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
void pqSpinBoxEventPlayerTester::initTestCase()
|
||||
{
|
||||
this->TestUtility = new pqTestUtility();
|
||||
this->TestUtility->addEventObserver("xml", new pqDummyEventObserver);
|
||||
this->TestUtility->addEventSource("xml", new pqDummyEventSource());
|
||||
|
||||
this->SpinBox = 0;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
void pqSpinBoxEventPlayerTester::init()
|
||||
{
|
||||
// Init the QSpinBox
|
||||
this->SpinBox = new QSpinBox();
|
||||
this->SpinBox->setObjectName("spinBoxTest");
|
||||
this->SpinBox->setMinimum(-99);
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
void pqSpinBoxEventPlayerTester::cleanup()
|
||||
{
|
||||
delete this->SpinBox;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
void pqSpinBoxEventPlayerTester::cleanupTestCase()
|
||||
{
|
||||
delete this->TestUtility;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
void pqSpinBoxEventPlayerTester::testPlayBackCommandSetInt()
|
||||
{
|
||||
QFETCH(int, value);
|
||||
QFETCH(int, result);
|
||||
QFETCH(int, count);
|
||||
|
||||
QSignalSpy spy(this->SpinBox, SIGNAL(valueChanged(int)));
|
||||
|
||||
bool error;
|
||||
this->TestUtility->eventPlayer()->playEvent(
|
||||
QString("spinBoxTest"), QString("set_int"), QString::number(value), error);
|
||||
|
||||
QCOMPARE(this->SpinBox->value(), result);
|
||||
QCOMPARE(spy.count(), count);
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
void pqSpinBoxEventPlayerTester::testPlayBackCommandSetInt_data()
|
||||
{
|
||||
QTest::addColumn<int>("value");
|
||||
QTest::addColumn<int>("result");
|
||||
QTest::addColumn<int>("count");
|
||||
|
||||
QTest::newRow("positive") << 10 << 10 << 1;
|
||||
QTest::newRow("negative") << -33 << -33 << 1;
|
||||
QTest::newRow("negativeoutside") << -200 << -99 << 1;
|
||||
QTest::newRow("positiveoutside") << 200 << 99 << 1;
|
||||
QTest::newRow("negativeboundary") << -99 << -99 << 1;
|
||||
QTest::newRow("positiveboundary") << 99 << 99 << 1;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
CTK_TEST_MAIN( pqSpinBoxEventPlayerTest )
|
||||
#include "moc_pqSpinBoxEventPlayerTest.cpp"
|
||||
286
ParaView-5.0.1/ThirdParty/QtTesting/vtkqttesting/Testing/Cpp/pqSpinBoxEventTranslatorTest.cpp
vendored
Normal file
286
ParaView-5.0.1/ThirdParty/QtTesting/vtkqttesting/Testing/Cpp/pqSpinBoxEventTranslatorTest.cpp
vendored
Normal file
@ -0,0 +1,286 @@
|
||||
/*=========================================================================
|
||||
|
||||
Program: ParaView
|
||||
|
||||
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.
|
||||
|
||||
=========================================================================*/
|
||||
|
||||
// Qt includes
|
||||
#include <QApplication>
|
||||
#include <QSpinBox>
|
||||
#include <QStyle>
|
||||
#include <QtTest/QtTest>
|
||||
|
||||
// QtTesting includes
|
||||
#include "pqTestUtility.h"
|
||||
|
||||
#include "pqTest.h"
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
class pqSpinBoxEventTranslatorTester: public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
private Q_SLOTS:
|
||||
|
||||
void initTestCase();
|
||||
void init();
|
||||
void cleanup();
|
||||
void cleanupTestCase();
|
||||
|
||||
void testRecordLeftMouseClick();
|
||||
void testRecordLeftMouseClick_data();
|
||||
|
||||
void testRecordRightMouseClick();
|
||||
void testRecordRightMouseClick_data();
|
||||
|
||||
void testRecordMiddleMouseClick();
|
||||
void testRecordMiddleMouseClick_data();
|
||||
|
||||
void testRecordKeyBoardClick();
|
||||
void testRecordKeyBoardClick_data();
|
||||
|
||||
void testRecordComplexClick();
|
||||
|
||||
private:
|
||||
QSpinBox* SpinBox;
|
||||
|
||||
pqTestUtility* TestUtility;
|
||||
pqDummyEventObserver* EventObserver;
|
||||
};
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
void pqSpinBoxEventTranslatorTester::initTestCase()
|
||||
{
|
||||
this->TestUtility = new pqTestUtility();
|
||||
this->EventObserver = new pqDummyEventObserver();
|
||||
this->TestUtility->addEventObserver("xml", this->EventObserver);
|
||||
this->TestUtility->addEventSource("xml", new pqDummyEventSource());
|
||||
|
||||
this->SpinBox = 0;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
void pqSpinBoxEventTranslatorTester::init()
|
||||
{
|
||||
// Init SpinBox
|
||||
this->SpinBox = new QSpinBox();
|
||||
this->SpinBox->setObjectName("spinBoxTest");
|
||||
this->SpinBox->setMinimum(-100);
|
||||
|
||||
// Start to record events
|
||||
this->TestUtility->recordTestsBySuffix("xml");
|
||||
|
||||
// Fire the event "enter" to connect spinbox signals to the translator slots
|
||||
QEvent enter(QEvent::Enter);
|
||||
qApp->notify(this->SpinBox, &enter);
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
void pqSpinBoxEventTranslatorTester::cleanup()
|
||||
{
|
||||
this->TestUtility->stopRecords(0);
|
||||
delete this->SpinBox;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
void pqSpinBoxEventTranslatorTester::cleanupTestCase()
|
||||
{
|
||||
this->EventObserver = 0;
|
||||
delete this->TestUtility;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
void pqSpinBoxEventTranslatorTester::testRecordLeftMouseClick()
|
||||
{
|
||||
QFETCH(int, X);
|
||||
QFETCH(int, Y);
|
||||
QFETCH(QString, recordEmitted);
|
||||
|
||||
QTest::mouseClick(this->SpinBox, Qt::LeftButton, Qt::NoModifier, QPoint(X,Y));
|
||||
QCOMPARE(this->EventObserver->Text, recordEmitted);
|
||||
|
||||
this->EventObserver->Text = QString();
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
void pqSpinBoxEventTranslatorTester::testRecordLeftMouseClick_data()
|
||||
{
|
||||
QSpinBox spinBox;
|
||||
|
||||
QTest::addColumn<int>("X");
|
||||
QTest::addColumn<int>("Y");
|
||||
QTest::addColumn<QString>("recordEmitted");
|
||||
|
||||
QSize size = spinBox.size();
|
||||
int frameWidth =
|
||||
spinBox.style()->pixelMetric(QStyle::PM_SpinBoxFrameWidth) + 1;
|
||||
|
||||
QTest::newRow("0,0") << 0 << 0 << QString();
|
||||
QTest::newRow("invalid") << - size.rwidth() << frameWidth << QString();
|
||||
QTest::newRow("middle") << size.rwidth() / 2 << size.rheight() / 2
|
||||
<< QString();
|
||||
QTest::newRow("arrow up") << size.rwidth()- frameWidth
|
||||
<< frameWidth
|
||||
<< QString("spinBoxTest, set_int, 1#");
|
||||
QTest::newRow("arrow down") << size.rwidth() - frameWidth
|
||||
<< size.rheight() - frameWidth
|
||||
<< QString("spinBoxTest, set_int, -1#");
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
void pqSpinBoxEventTranslatorTester::testRecordRightMouseClick()
|
||||
{
|
||||
QFETCH(int, X);
|
||||
QFETCH(int, Y);
|
||||
QFETCH(QString, recordEmitted);
|
||||
|
||||
QTest::mouseClick(this->SpinBox, Qt::RightButton, Qt::NoModifier, QPoint(X,Y));
|
||||
QCOMPARE(this->EventObserver->Text, recordEmitted);
|
||||
|
||||
this->EventObserver->Text = QString();
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
void pqSpinBoxEventTranslatorTester::testRecordRightMouseClick_data()
|
||||
{
|
||||
QSpinBox spinBox;
|
||||
|
||||
QTest::addColumn<int>("X");
|
||||
QTest::addColumn<int>("Y");
|
||||
QTest::addColumn<QString>("recordEmitted");
|
||||
|
||||
QSize size = spinBox.size();
|
||||
int frameWidth =
|
||||
spinBox.style()->pixelMetric(QStyle::PM_SpinBoxFrameWidth) + 1;
|
||||
|
||||
QTest::newRow("0,0") << 0 << 0 << QString();
|
||||
QTest::newRow("invalid") << - size.rwidth() << frameWidth << QString();
|
||||
QTest::newRow("middle") << size.rwidth() / 2 << size.rheight() / 2
|
||||
<< QString();
|
||||
QTest::newRow("arrow down") << size.rwidth() - frameWidth
|
||||
<< size.rheight() - frameWidth
|
||||
<< QString();
|
||||
QTest::newRow("arrow up") << size.rwidth() - frameWidth
|
||||
<< frameWidth
|
||||
<< QString();
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
void pqSpinBoxEventTranslatorTester::testRecordMiddleMouseClick()
|
||||
{
|
||||
QFETCH(int, X);
|
||||
QFETCH(int, Y);
|
||||
QFETCH(QString, recordEmitted);
|
||||
|
||||
QTest::mouseClick(this->SpinBox, Qt::MiddleButton, Qt::NoModifier, QPoint(X,Y));
|
||||
QCOMPARE(this->EventObserver->Text, recordEmitted);
|
||||
|
||||
this->EventObserver->Text = QString();
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
void pqSpinBoxEventTranslatorTester::testRecordMiddleMouseClick_data()
|
||||
{
|
||||
this->testRecordRightMouseClick_data();
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
void pqSpinBoxEventTranslatorTester::testRecordKeyBoardClick()
|
||||
{
|
||||
QFETCH(QString, number);
|
||||
QFETCH(QString, recordEmitted);
|
||||
this->SpinBox->clear();
|
||||
|
||||
QTest::keyClicks(this->SpinBox, number);
|
||||
QCOMPARE(this->EventObserver->Text, recordEmitted);
|
||||
|
||||
this->EventObserver->Text = QString();
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
void pqSpinBoxEventTranslatorTester::testRecordKeyBoardClick_data()
|
||||
{
|
||||
QTest::addColumn<QString>("number");
|
||||
QTest::addColumn<QString>("recordEmitted");
|
||||
|
||||
QTest::newRow("invalid") << QString("aa") << QString();
|
||||
QTest::newRow("valid & invalid") << QString("2.aa") << QString("spinBoxTest, set_int, 2#");
|
||||
QTest::newRow("valid positif") << QString::number(33) << QString("spinBoxTest, set_int, 3#spinBoxTest, set_int, 33#");
|
||||
QTest::newRow("valid negatif") << QString::number(-5) << QString("spinBoxTest, set_int, -5#");
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
void pqSpinBoxEventTranslatorTester::testRecordComplexClick()
|
||||
{
|
||||
QSize size = this->SpinBox->size();
|
||||
int frameWidth =
|
||||
this->SpinBox->style()->pixelMetric(QStyle::PM_SpinBoxFrameWidth) + 1;
|
||||
|
||||
QString recordExpected;
|
||||
|
||||
QTest::keyClicks(this->SpinBox, "10");
|
||||
recordExpected.append(QString("spinBoxTest, set_int, 1#"));
|
||||
recordExpected.append(QString("spinBoxTest, set_int, 10#"));
|
||||
|
||||
QTest::mouseClick(this->SpinBox, Qt::LeftButton, Qt::NoModifier,
|
||||
QPoint(size.rwidth()- frameWidth , size.rheight() - frameWidth));
|
||||
recordExpected.append(QString("spinBoxTest, set_int, 9#"));
|
||||
|
||||
QTest::mouseClick(this->SpinBox, Qt::LeftButton, Qt::NoModifier,
|
||||
QPoint(size.rwidth()- frameWidth , size.rheight() - frameWidth));
|
||||
recordExpected.append(QString("spinBoxTest, set_int, 8#"));
|
||||
|
||||
QTest::mouseClick(this->SpinBox, Qt::LeftButton, Qt::NoModifier,
|
||||
QPoint(size.rwidth()- frameWidth , frameWidth));
|
||||
recordExpected.append(QString("spinBoxTest, set_int, 9#"));
|
||||
|
||||
QTest::mouseClick(this->SpinBox, Qt::LeftButton, Qt::NoModifier,
|
||||
QPoint(size.rwidth()- frameWidth , frameWidth));
|
||||
recordExpected.append(QString("spinBoxTest, set_int, 10#"));
|
||||
|
||||
QTest::mouseClick(this->SpinBox, Qt::LeftButton, Qt::NoModifier,
|
||||
QPoint(size.rwidth()- frameWidth , frameWidth));
|
||||
recordExpected.append(QString("spinBoxTest, set_int, 11#"));
|
||||
|
||||
QTest::mouseClick(this->SpinBox, Qt::LeftButton, Qt::NoModifier,
|
||||
QPoint(size.rwidth()- frameWidth , frameWidth));
|
||||
recordExpected.append(QString("spinBoxTest, set_int, 12#"));
|
||||
|
||||
QTest::mouseClick(this->SpinBox, Qt::LeftButton, Qt::NoModifier,
|
||||
QPoint(size.rwidth()- frameWidth , frameWidth));
|
||||
recordExpected.append(QString("spinBoxTest, set_int, 13#"));
|
||||
|
||||
QTest::keyClicks(this->SpinBox, "0");
|
||||
recordExpected.append(QString("spinBoxTest, set_int, 0#"));
|
||||
|
||||
QCOMPARE(this->EventObserver->Text, recordExpected);
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
CTK_TEST_MAIN( pqSpinBoxEventTranslatorTest )
|
||||
#include "moc_pqSpinBoxEventTranslatorTest.cpp"
|
||||
189
ParaView-5.0.1/ThirdParty/QtTesting/vtkqttesting/Testing/Cpp/pqTest.h
vendored
Normal file
189
ParaView-5.0.1/ThirdParty/QtTesting/vtkqttesting/Testing/Cpp/pqTest.h
vendored
Normal file
@ -0,0 +1,189 @@
|
||||
/*=========================================================================
|
||||
|
||||
Library: CTK
|
||||
|
||||
Copyright (c) Kitware Inc.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0.txt
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
|
||||
=========================================================================*/
|
||||
/*=========================================================================
|
||||
|
||||
Program: ParaView
|
||||
|
||||
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.
|
||||
|
||||
=========================================================================*/
|
||||
|
||||
// Qt includes
|
||||
#include <QtTest/QtTest>
|
||||
|
||||
// QtTesting includes
|
||||
#include "pqEventObserver.h"
|
||||
#include "pqEventSource.h"
|
||||
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// Dumy pqEventObserver
|
||||
|
||||
class pqDummyEventObserver : public pqEventObserver
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
pqDummyEventObserver(QObject* p = 0) : pqEventObserver(p) {}
|
||||
~pqDummyEventObserver() {}
|
||||
|
||||
virtual void setStream(QTextStream* /*stream*/)
|
||||
{
|
||||
}
|
||||
|
||||
QString Text;
|
||||
|
||||
public slots:
|
||||
virtual void onRecordEvent(const QString& widget,
|
||||
const QString& command,
|
||||
const QString& arguments)
|
||||
{
|
||||
this->Text.append(QString("%1, %2, %3#").arg(widget,
|
||||
command,
|
||||
arguments));
|
||||
}
|
||||
};
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// Dumy eventSource
|
||||
|
||||
class pqDummyEventSource : public pqEventSource
|
||||
{
|
||||
typedef pqEventSource Superclass;
|
||||
|
||||
public:
|
||||
pqDummyEventSource(QObject* p = 0): Superclass(p) {}
|
||||
~pqDummyEventSource() {}
|
||||
|
||||
protected:
|
||||
virtual void setContent(const QString& /*xmlfilename*/)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
int getNextEvent(QString& /*widget*/,
|
||||
QString& /*command*/,
|
||||
QString& /*arguments*/)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
};
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// MACRO
|
||||
|
||||
#define CTK_TEST_NOOP_MAIN(TestObject) \
|
||||
int TestObject(int argc, char *argv[]) \
|
||||
{ \
|
||||
QObject tc; \
|
||||
return QTest::qExec(&tc, argc, argv); \
|
||||
}
|
||||
|
||||
#ifdef QT_GUI_LIB
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
#define CTK_TEST_MAIN(TestObject) \
|
||||
int TestObject(int argc, char *argv[]) \
|
||||
{ \
|
||||
QApplication app(argc, argv); \
|
||||
TestObject##er tc; \
|
||||
return QTest::qExec(&tc, argc, argv); \
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
#define CTK_TEST_MAIN(TestObject) \
|
||||
int TestObject(int argc, char *argv[]) \
|
||||
{ \
|
||||
QCoreApplication app(argc, argv); \
|
||||
QTEST_DISABLE_KEYPAD_NAVIGATION \
|
||||
TestObject##er tc; \
|
||||
return QTest::qExec(&tc, argc, argv); \
|
||||
}
|
||||
|
||||
#endif // QT_GUI_LIB
|
||||
|
||||
namespace ctkTest
|
||||
{
|
||||
static void mouseEvent(QTest::MouseAction action, QWidget *widget, Qt::MouseButton button,
|
||||
Qt::KeyboardModifiers stateKey, QPoint pos, int delay=-1)
|
||||
{
|
||||
if (action != QTest::MouseMove)
|
||||
{
|
||||
QTest::mouseEvent(action, widget, button, stateKey, pos, delay);
|
||||
return;
|
||||
}
|
||||
QTEST_ASSERT(widget);
|
||||
//extern int Q_TESTLIB_EXPORT defaultMouseDelay();
|
||||
//if (delay == -1 || delay < defaultMouseDelay())
|
||||
// delay = defaultMouseDelay();
|
||||
if (delay > 0)
|
||||
QTest::qWait(delay);
|
||||
|
||||
if (pos.isNull())
|
||||
pos = widget->rect().center();
|
||||
|
||||
QTEST_ASSERT(button == Qt::NoButton || button & Qt::MouseButtonMask);
|
||||
QTEST_ASSERT(stateKey == 0 || stateKey & Qt::KeyboardModifierMask);
|
||||
|
||||
stateKey &= static_cast<unsigned int>(Qt::KeyboardModifierMask);
|
||||
|
||||
QMouseEvent me(QEvent::User, QPoint(), Qt::LeftButton, button, stateKey);
|
||||
|
||||
me = QMouseEvent(QEvent::MouseMove, pos, widget->mapToGlobal(pos), button, button, stateKey);
|
||||
QSpontaneKeyEvent::setSpontaneous(&me);
|
||||
if (!qApp->notify(widget, &me))
|
||||
{
|
||||
static const char *mouseActionNames[] =
|
||||
{ "MousePress", "MouseRelease", "MouseClick", "MouseDClick", "MouseMove" };
|
||||
QString warning = QString::fromLatin1("Mouse event \"%1\" not accepted by receiving widget");
|
||||
QTest::qWarn(warning.arg(QString::fromLatin1(mouseActionNames[static_cast<int>(action)])).toLatin1().data());
|
||||
}
|
||||
}
|
||||
|
||||
inline void mouseMove(QWidget *widget, Qt::MouseButton button, Qt::KeyboardModifiers stateKey = 0,
|
||||
QPoint pos = QPoint(), int delay=-1)
|
||||
{ ctkTest::mouseEvent(QTest::MouseMove, widget, button, stateKey, pos, delay); }
|
||||
|
||||
}
|
||||
441
ParaView-5.0.1/ThirdParty/QtTesting/vtkqttesting/Testing/Cpp/pqTestUtilityTest.cpp
vendored
Normal file
441
ParaView-5.0.1/ThirdParty/QtTesting/vtkqttesting/Testing/Cpp/pqTestUtilityTest.cpp
vendored
Normal file
@ -0,0 +1,441 @@
|
||||
/*=========================================================================
|
||||
|
||||
Program: ParaView
|
||||
Module: pqEventPlayer.h
|
||||
|
||||
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.
|
||||
|
||||
=========================================================================*/
|
||||
|
||||
// Qt includes
|
||||
#include <QLineEdit>
|
||||
#include <QMap>
|
||||
|
||||
// QtTesting includes
|
||||
#include "pqEventObserver.h"
|
||||
#include "pqEventSource.h"
|
||||
#include "pqTestUtility.h"
|
||||
|
||||
#include "pqTest.h"
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
class pqTestUtilityTester : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
private Q_SLOTS:
|
||||
|
||||
void testDefaults();
|
||||
|
||||
void testAddEventSource();
|
||||
void testAddEventSource_data();
|
||||
|
||||
void testAddEventObserver();
|
||||
void testAddEventObserver_data();
|
||||
|
||||
void testAddObjectStateProperty();
|
||||
void testAddObjectStateProperty_data();
|
||||
|
||||
// void testRemoveObjectStateProperty();
|
||||
// void testRemoveObjectStateProperty_data();
|
||||
|
||||
void testAddDataDirectory();
|
||||
void testAddDataDirectory_data();
|
||||
|
||||
void testRemoveDataDirectory();
|
||||
void testRemoveDataDirectory_data();
|
||||
|
||||
void testConvertToDataDirectory();
|
||||
void testConvertToDataDirectory_data();
|
||||
|
||||
void testConvertFromDataDirectory();
|
||||
void testConvertFromDataDirectory_data();
|
||||
};
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
void pqTestUtilityTester::testDefaults()
|
||||
{
|
||||
pqTestUtility testUtility;
|
||||
|
||||
QCOMPARE(testUtility.playingTest(), false);
|
||||
QCOMPARE(testUtility.eventSources().count(), 0);
|
||||
QCOMPARE(testUtility.eventObservers().count(), 0);
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
void pqTestUtilityTester::testAddEventSource()
|
||||
{
|
||||
pqTestUtility testUtility;
|
||||
|
||||
QFETCH(QString, extension1);
|
||||
QFETCH(QObject*, source1);
|
||||
QFETCH(int, newCount1);
|
||||
QFETCH(QString, extension2);
|
||||
QFETCH(QObject*, source2);
|
||||
QFETCH(int, newCount2);
|
||||
|
||||
testUtility.addEventSource(extension1, dynamic_cast<pqEventSource*>(source1));
|
||||
QCOMPARE(testUtility.eventSources().count(), newCount1);
|
||||
testUtility.addEventSource(extension2, dynamic_cast<pqEventSource*>(source2));
|
||||
QCOMPARE(testUtility.eventSources().count(), newCount2);
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
void pqTestUtilityTester::testAddEventSource_data()
|
||||
{
|
||||
QTest::addColumn<QString>("extension1");
|
||||
QTest::addColumn<QObject*>("source1");
|
||||
QTest::addColumn<int>("newCount1");
|
||||
QTest::addColumn<QString>("extension2");
|
||||
QTest::addColumn<QObject*>("source2");
|
||||
QTest::addColumn<int>("newCount2");
|
||||
|
||||
pqDummyEventSource* nullSource = NULL;
|
||||
pqDummyEventSource* dummySource1 = new pqDummyEventSource();
|
||||
pqDummyEventSource* dummySource2 = new pqDummyEventSource();
|
||||
pqDummyEventSource* dummySource3 = new pqDummyEventSource();
|
||||
pqDummyEventSource* dummySource4 = new pqDummyEventSource();
|
||||
pqDummyEventSource* dummySource5 = new pqDummyEventSource();
|
||||
QTest::newRow("null") << QString("")
|
||||
<< qobject_cast<QObject*>(nullSource) << 0
|
||||
<< QString("null")
|
||||
<< qobject_cast<QObject*>(nullSource) << 0;
|
||||
QTest::newRow("same") << QString("py")
|
||||
<< qobject_cast<QObject*>(dummySource1) << 1
|
||||
<< QString("py")
|
||||
<< qobject_cast<QObject*>(dummySource1) << 1;
|
||||
QTest::newRow("same") << QString("py")
|
||||
<< qobject_cast<QObject*>(dummySource2) << 1
|
||||
<< QString("py")
|
||||
<< qobject_cast<QObject*>(dummySource3) << 1;
|
||||
QTest::newRow("diff") << QString("py")
|
||||
<< qobject_cast<QObject*>(dummySource4) << 1
|
||||
<< QString("xml")
|
||||
<< qobject_cast<QObject*>(dummySource5) << 2;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
void pqTestUtilityTester::testAddEventObserver()
|
||||
{
|
||||
pqTestUtility testUtility;
|
||||
|
||||
QFETCH(QString, extension1);
|
||||
QFETCH(QObject*, observer1);
|
||||
QFETCH(int, newCount1);
|
||||
QFETCH(QString, extension2);
|
||||
QFETCH(QObject*, observer2);
|
||||
QFETCH(int, newCount2);
|
||||
|
||||
testUtility.addEventObserver(extension1, dynamic_cast<pqEventObserver*>(observer1));
|
||||
QCOMPARE(testUtility.eventObservers().count(), newCount1);
|
||||
testUtility.addEventObserver(extension2, dynamic_cast<pqEventObserver*>(observer2));
|
||||
QCOMPARE(testUtility.eventObservers().count(), newCount2);
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
void pqTestUtilityTester::testAddEventObserver_data()
|
||||
{
|
||||
QTest::addColumn<QString>("extension1");
|
||||
QTest::addColumn<QObject*>("observer1");
|
||||
QTest::addColumn<int>("newCount1");
|
||||
QTest::addColumn<QString>("extension2");
|
||||
QTest::addColumn<QObject*>("observer2");
|
||||
QTest::addColumn<int>("newCount2");
|
||||
|
||||
pqDummyEventObserver* nullObserver = NULL;
|
||||
pqDummyEventObserver* dummyObserver1 = new pqDummyEventObserver();
|
||||
pqDummyEventObserver* dummyObserver2 = new pqDummyEventObserver();
|
||||
pqDummyEventObserver* dummyObserver3 = new pqDummyEventObserver();
|
||||
pqDummyEventObserver* dummyObserver4 = new pqDummyEventObserver();
|
||||
pqDummyEventObserver* dummyObserver5 = new pqDummyEventObserver();
|
||||
QTest::newRow("null") << QString("")
|
||||
<< qobject_cast<QObject*>(nullObserver) << 0
|
||||
<< QString("null")
|
||||
<< qobject_cast<QObject*>(nullObserver) << 0;
|
||||
QTest::newRow("all_same") << QString("py")
|
||||
<< qobject_cast<QObject*>(dummyObserver1) << 1
|
||||
<< QString("py")
|
||||
<< qobject_cast<QObject*>(dummyObserver1) << 1;
|
||||
QTest::newRow("only_same_key") << QString("py")
|
||||
<< qobject_cast<QObject*>(dummyObserver2) << 1
|
||||
<< QString("py")
|
||||
<< qobject_cast<QObject*>(dummyObserver3) << 1;
|
||||
QTest::newRow("diff") << QString("py")
|
||||
<< qobject_cast<QObject*>(dummyObserver4) << 1
|
||||
<< QString("xml")
|
||||
<< qobject_cast<QObject*>(dummyObserver5) << 2;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
void pqTestUtilityTester::testAddObjectStateProperty()
|
||||
{
|
||||
pqTestUtility testUtility;
|
||||
|
||||
QFETCH(QObject*, object1);
|
||||
QFETCH(QString, property1);
|
||||
QFETCH(int, objectCount1);
|
||||
QFETCH(int, propertyCount1);
|
||||
QFETCH(QObject*, object2);
|
||||
QFETCH(QString, property2);
|
||||
QFETCH(int, objectCount2);
|
||||
QFETCH(int, propertyCount2);
|
||||
|
||||
testUtility.addObjectStateProperty(object1, property1);
|
||||
int nbObject = testUtility.objectStateProperty().count();
|
||||
QCOMPARE(nbObject, objectCount1);
|
||||
if (nbObject > 0)
|
||||
{
|
||||
int nbProperty1 = 0;
|
||||
foreach (QStringList list, testUtility.objectStateProperty().values())
|
||||
{
|
||||
nbProperty1 += list.count();
|
||||
}
|
||||
QCOMPARE(nbProperty1, propertyCount1);
|
||||
}
|
||||
testUtility.addObjectStateProperty(object2, property2);
|
||||
nbObject = testUtility.objectStateProperty().count();
|
||||
QCOMPARE(nbObject, objectCount2);
|
||||
if (nbObject > 0)
|
||||
{
|
||||
int nbProperty2 = 0;
|
||||
foreach (QStringList list, testUtility.objectStateProperty().values())
|
||||
{
|
||||
nbProperty2 += list.count();
|
||||
}
|
||||
QCOMPARE(nbProperty2, propertyCount2);
|
||||
}
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
void pqTestUtilityTester::testAddObjectStateProperty_data()
|
||||
{
|
||||
QTest::addColumn<QObject*>("object1");
|
||||
QTest::addColumn<QString>("property1");
|
||||
QTest::addColumn<int>("objectCount1");
|
||||
QTest::addColumn<int>("propertyCount1");
|
||||
QTest::addColumn<QObject*>("object2");
|
||||
QTest::addColumn<QString>("property2");
|
||||
QTest::addColumn<int>("objectCount2");
|
||||
QTest::addColumn<int>("propertyCount2");
|
||||
|
||||
QObject* nullObject = NULL;
|
||||
QLineEdit* lineEdit1 = new QLineEdit();
|
||||
QLineEdit* lineEdit2 = new QLineEdit();
|
||||
QLineEdit* lineEdit3 = new QLineEdit();
|
||||
QLineEdit* lineEdit4 = new QLineEdit();
|
||||
QLineEdit* lineEdit5 = new QLineEdit();
|
||||
|
||||
QTest::newRow("objectNull") << nullObject
|
||||
<< QString("") << 0 << 0
|
||||
<< nullObject
|
||||
<< QString("maxLength") << 0 << 0;
|
||||
QTest::newRow("wrongProperty") << qobject_cast<QObject*>(lineEdit1)
|
||||
<< QString("") << 0 << 0
|
||||
<< qobject_cast<QObject*>(lineEdit1)
|
||||
<< QString("wrongProperty") << 0 << 0;
|
||||
QTest::newRow("sameProperty") << qobject_cast<QObject*>(lineEdit2)
|
||||
<< QString("maxLength") << 1 << 1
|
||||
<< qobject_cast<QObject*>(lineEdit2)
|
||||
<< QString("maxLength") << 1 << 1;
|
||||
QTest::newRow("diffProperty") << qobject_cast<QObject*>(lineEdit3)
|
||||
<< QString("maxLength") << 1 << 1
|
||||
<< qobject_cast<QObject*>(lineEdit3)
|
||||
<< QString("readOnly") << 1 << 2;
|
||||
QTest::newRow("diffObject") << qobject_cast<QObject*>(lineEdit4)
|
||||
<< QString("maxLength") << 1 << 1
|
||||
<< qobject_cast<QObject*>(lineEdit5)
|
||||
<< QString("maxLength") << 2 << 2;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
void pqTestUtilityTester::testAddDataDirectory()
|
||||
{
|
||||
pqTestUtility testUtility;
|
||||
|
||||
QFETCH(QString, label1);
|
||||
QFETCH(QString, path1);
|
||||
QFETCH(int, result1);
|
||||
QFETCH(QString, label2);
|
||||
QFETCH(QString, path2);
|
||||
QFETCH(int, result2);
|
||||
|
||||
testUtility.addDataDirectory(label1, QDir(path1));
|
||||
QCOMPARE(testUtility.dataDirectory().count(), result1);
|
||||
|
||||
testUtility.addDataDirectory(label2, QDir(path2));
|
||||
QCOMPARE(testUtility.dataDirectory().count(), result2);
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
void pqTestUtilityTester::testAddDataDirectory_data()
|
||||
{
|
||||
QTest::addColumn<QString>("label1");
|
||||
QTest::addColumn<QString>("path1");
|
||||
QTest::addColumn<int>("result1");
|
||||
QTest::addColumn<QString>("label2");
|
||||
QTest::addColumn<QString>("path2");
|
||||
QTest::addColumn<int>("result2");
|
||||
|
||||
QTest::newRow("empty") << QString() << QString() << 0
|
||||
<< QString("label") << QString("") << 0 ;
|
||||
QTest::newRow("allSame") << QString("TEMPLATE") << QString("/home/") << 1
|
||||
<< QString("TEMPLATE") << QString("/home/") << 1;
|
||||
QTest::newRow("sameLabel") << QString("TEMPLATE") << QString("/home/") << 1
|
||||
<< QString("TEMPLATE") << QString("/home/BenLg") << 1;
|
||||
QTest::newRow("samePath") << QString("TEMPLATE") << QString("/home/") << 1
|
||||
<< QString("TEMP") << QString("/home/") << 2;
|
||||
QTest::newRow("diff") << QString("TEMPLATE") << QString("/home/") << 1
|
||||
<< QString("TEMP") << QString("/home/BenLg") << 2;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
void pqTestUtilityTester::testRemoveDataDirectory()
|
||||
{
|
||||
pqTestUtility testUtility;
|
||||
|
||||
QFETCH(QString, label);
|
||||
QFETCH(bool, result);
|
||||
|
||||
testUtility.addDataDirectory(QString("TEMPLATE"), QDir("/home"));
|
||||
QCOMPARE(testUtility.removeDataDirectory(label), result);
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
void pqTestUtilityTester::testRemoveDataDirectory_data()
|
||||
{
|
||||
QTest::addColumn<QString>("label");
|
||||
QTest::addColumn<bool>("result");
|
||||
|
||||
QTest::newRow("empty") << QString() << false;
|
||||
QTest::newRow("wrong") << QString("TEMP") << false;
|
||||
QTest::newRow("right") << QString("TEMPLATE") << true;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
void pqTestUtilityTester::testConvertToDataDirectory()
|
||||
{
|
||||
pqTestUtility testUtility;
|
||||
|
||||
QFETCH(QString, label1);
|
||||
QFETCH(QString, dir1);
|
||||
QFETCH(QString, label2);
|
||||
QFETCH(QString, dir2);
|
||||
|
||||
testUtility.addDataDirectory(QString(label1), QDir(dir1));
|
||||
testUtility.addDataDirectory(QString(label2), QDir(dir2));
|
||||
|
||||
QFETCH(QString, path);
|
||||
QFETCH(QString, result);
|
||||
|
||||
QString convertPath = testUtility.convertToDataDirectory(path);
|
||||
QCOMPARE(convertPath, result);
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
void pqTestUtilityTester::testConvertToDataDirectory_data()
|
||||
{
|
||||
QTest::addColumn<QString>("label1");
|
||||
QTest::addColumn<QString>("dir1");
|
||||
QTest::addColumn<QString>("label2");
|
||||
QTest::addColumn<QString>("dir2");
|
||||
QTest::addColumn<QString>("path");
|
||||
QTest::addColumn<QString>("result");
|
||||
|
||||
QTest::newRow("0") << "ROOT" << "/home/BenLg"
|
||||
<< "ROOTDATA" << "/home/BenLg/data"
|
||||
<< QString()
|
||||
<< QString();
|
||||
QTest::newRow("1") << "ROOT" << "/home/BenLg"
|
||||
<< "ROOTDATA" << "/home/BenLg/data"
|
||||
<< QString("/home") << QString("/home");
|
||||
QTest::newRow("2") << "ROOT" << "/home/BenLg"
|
||||
<< "ROOTDATA" << "/home/BenLg/data"
|
||||
<< QString("/home/toto/")
|
||||
<< QString("/home/toto/");
|
||||
QTest::newRow("3") << "ROOT" << "/home/BenLg"
|
||||
<< "ROOTDATA" << "/home/BenLg/data"
|
||||
<< QString("/home/BenLg")
|
||||
<< QString("${ROOT}/");
|
||||
QTest::newRow("3") << "ROOT" << "/home/BenLg"
|
||||
<< "ROOTDATA" << "/home/BenLg/data"
|
||||
<< QString("/home/BenLg/toto")
|
||||
<< QString("${ROOT}/toto");
|
||||
QTest::newRow("4") << "ROOT" << "/home/BenLg"
|
||||
<< "ROOTDATA" << "/home/BenLg/data"
|
||||
<< QString("/home/BenLg/data/toto")
|
||||
<< QString("${ROOTDATA}/toto");
|
||||
|
||||
// Same test as the previous one but we inverse the two dataDirectories
|
||||
// to be sure that our function chosse the right one.
|
||||
QTest::newRow("5") << "ROOTDATA" << "/home/BenLg/data"
|
||||
<< "ROOT" << "/home/BenLg"
|
||||
<< QString("/home/BenLg/data/toto")
|
||||
<< QString("${ROOTDATA}/toto");
|
||||
QTest::newRow("6") << "ROOT" << "/home/BenLg"
|
||||
<< "ROOTDATA" << "/home/BenLg/data"
|
||||
<< QString("/usr/toto/home/BenLg/toto")
|
||||
<< QString("/usr/toto/home/BenLg/toto");
|
||||
QTest::newRow("7") << "ROOT" << "/home/BenLg"
|
||||
<< "ROOTDATA" << "/home/BenLg/data"
|
||||
<< QString("/usr/home/BenLg/data/toto")
|
||||
<< QString("/usr/home/BenLg/data/toto");
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
void pqTestUtilityTester::testConvertFromDataDirectory()
|
||||
{
|
||||
pqTestUtility testUtility;
|
||||
|
||||
testUtility.addDataDirectory(QString("ROOT"), QDir("/home/BenLg"));
|
||||
testUtility.addDataDirectory(QString("ROOTDATA"), QDir("/home/BenLg/data"));
|
||||
|
||||
QFETCH(QString, path);
|
||||
QFETCH(QString, result);
|
||||
|
||||
QString convertPath = testUtility.convertFromDataDirectory(path);
|
||||
QCOMPARE(convertPath, result);
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
void pqTestUtilityTester::testConvertFromDataDirectory_data()
|
||||
{
|
||||
QTest::addColumn<QString>("path");
|
||||
QTest::addColumn<QString>("result");
|
||||
|
||||
QTest::newRow("0") << QString("") << QString();
|
||||
QTest::newRow("1") << QString("/home/guest/data") << QString("/home/guest/data");
|
||||
QTest::newRow("2") << QString("${WRONG}/home") << QString("${WRONG}/home");
|
||||
QTest::newRow("3") << QString("${ROOT}") << QString("/home/BenLg");
|
||||
QTest::newRow("4") << QString("${ROOT}/Doc/bin") << QString("/home/BenLg/Doc/bin");
|
||||
QTest::newRow("5") << QString("${ROOTDATA}") << QString("/home/BenLg/data");
|
||||
QTest::newRow("6") << QString("${ROOTDATA}/Ex1/Patient0")
|
||||
<< QString("/home/BenLg/data/Ex1/Patient0");
|
||||
}
|
||||
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
CTK_TEST_MAIN( pqTestUtilityTest )
|
||||
#include "moc_pqTestUtilityTest.cpp"
|
||||
Reference in New Issue
Block a user