Skip to content

Commit

Permalink
Re #5170. Enable MantidQwtMatrixWorkspaceDataTest on Windows.
Browse files Browse the repository at this point in the history
There were two failures:
(a) One related to MantidQwtMatrixWorkspaceData (and its IMDWorkspace cousin)
    being QObjects. I could see no reason why they needed to be QObjects,
    so they aren't any more.
(b) The other failure required the suppression of a compiler-generated
    assignment operator for MantidQwtWorkspaceData.

I also thinned out the (unnecessary) dependencies of the MantidQtAPI test package.
  • Loading branch information
RussellTaylor committed May 4, 2012
1 parent 1a1499f commit 069affa
Show file tree
Hide file tree
Showing 7 changed files with 39 additions and 61 deletions.
35 changes: 9 additions & 26 deletions Code/Mantid/MantidQt/API/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,6 @@ set ( MOC_FILES
inc/MantidQtAPI/GenericDialog.h
inc/MantidQtAPI/ManageUserDirectories.h
inc/MantidQtAPI/MantidDialog.h
inc/MantidQtAPI/MantidQwtIMDWorkspaceData.h
inc/MantidQtAPI/MantidQwtMatrixWorkspaceData.h
inc/MantidQtAPI/MantidWidget.h
inc/MantidQtAPI/OptionsPropertyWidget.h
inc/MantidQtAPI/PropertyWidget.h
Expand All @@ -58,6 +56,8 @@ set ( INC_FILES
inc/MantidQtAPI/InterfaceFactory.h
inc/MantidQtAPI/InterfaceManager.h
inc/MantidQtAPI/MantidColorMap.h
inc/MantidQtAPI/MantidQwtIMDWorkspaceData.h
inc/MantidQtAPI/MantidQwtMatrixWorkspaceData.h
inc/MantidQtAPI/MantidQwtWorkspaceData.h
inc/MantidQtAPI/PropertyWidgetFactory.h
)
Expand All @@ -68,15 +68,9 @@ set ( UI_FILES

set( TEST_FILES
test/MantidColorMapTest.h
test/MantidQwtMatrixWorkspaceDataTest.h
)

# FIXME: The following test(s) only work on Linux, for some reason.
if ( NOT WIN32 )
set( TEST_FILES ${TEST_FILES}
test/MantidQwtMatrixWorkspaceDataTest.h
)
endif ()

include_directories ( inc )
include_directories ( ../MantidWidgets/inc )
include_directories ( ../MantidWidgets )
Expand Down Expand Up @@ -104,31 +98,20 @@ target_link_libraries ( MantidQtAPI ${CORE_MANTIDLIBS} ${QT_LIBRARIES} ${QWT_LIB
###########################################################################

if ( CXXTEST_FOUND )
if ( GMOCK_FOUND AND GTEST_FOUND )
# Make the rest of the tests
include_directories ( ../../Framework/CurveFitting/inc
../../Framework/DataHandling/inc
../../Framework/Nexus/inc
../../Framework/TestHelpers/inc
../../Framework/MDEvents/inc
../../Framework/DataObjects/inc
${QWT_INCLUDE_DIR} ${QT_INCLUDE_DIR} )
include_directories ( ../../Framework/TestHelpers/inc
../../Framework/DataObjects/inc )

# This variable is used within the cxxtest_add_test macro to build these helper classes into the test executable.
# It will go out of scope at the end of this file so doesn't need un-setting
set ( TESTHELPER_SRCS ../../Framework/TestHelpers/src/ComponentCreationHelper.cpp
../../Framework/TestHelpers/src/WorkspaceCreationHelper.cpp
../../Framework/TestHelpers/src/SANSInstrumentCreationHelper.cpp
../../Framework/TestHelpers/src/MDEventsTestHelper.cpp )
set ( TESTHELPER_SRCS ../../Framework/TestHelpers/src/ComponentCreationHelper.cpp
../../Framework/TestHelpers/src/WorkspaceCreationHelper.cpp )

cxxtest_add_test ( MantidQtAPITest ${TEST_FILES} ${GMOCK_TEST_FILES} )
target_link_libraries( MantidQtAPITest MantidQtAPI MDEvents DataHandling
${GMOCK_LIBRARIES} ${GTEST_LIBRARIES} ${QWT_LIBRARIES} ${QT_LIBRARIES})
cxxtest_add_test ( MantidQtAPITest ${TEST_FILES} )
target_link_libraries( MantidQtAPITest MantidQtAPI DataObjects)
add_dependencies( GUITests MantidQtAPITest )

# Add to the 'UnitTests' group in VS
set_property( TARGET MantidQtAPITest PROPERTY FOLDER "UnitTests" )
endif ()
endif ()

###########################################################################
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,18 +16,15 @@
* It implements the QwtData interface.
*
*/
class EXPORT_OPT_MANTIDQT_API MantidQwtIMDWorkspaceData: public QObject, public MantidQwtWorkspaceData
class EXPORT_OPT_MANTIDQT_API MantidQwtIMDWorkspaceData : public MantidQwtWorkspaceData
{

public:

/// For PlotAxisChoice, auto-determine it
static const int PlotAuto = -2;
/// For PlotAxisChoice, distance from start of line
static const int PlotDistance = -1;

Q_OBJECT
public:
MantidQwtIMDWorkspaceData(Mantid::API::IMDWorkspace_const_sptr workspace, const bool logScale,
Mantid::Kernel::VMD start = Mantid::Kernel::VMD(), Mantid::Kernel::VMD end = Mantid::Kernel::VMD(),
Mantid::API::MDNormalization normalize = Mantid::API::NoNormalization,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,8 @@
//=================================================================================================
/** This class implements QwtData with direct access to a spectrum in a MatrixWorkspace.
*/
class EXPORT_OPT_MANTIDQT_API MantidQwtMatrixWorkspaceData: public QObject, public MantidQwtWorkspaceData
class EXPORT_OPT_MANTIDQT_API MantidQwtMatrixWorkspaceData : public MantidQwtWorkspaceData
{
Q_OBJECT
public:
MantidQwtMatrixWorkspaceData(Mantid::API::MatrixWorkspace_const_sptr workspace, int specIndex, const bool logScale, bool distr = false);
MantidQwtMatrixWorkspaceData(const MantidQwtMatrixWorkspaceData& data);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ class EXPORT_OPT_MANTIDQT_API MantidQwtWorkspaceData:public QwtData
virtual size_t esize() const = 0;
virtual double e(size_t i)const = 0;
virtual double ex(size_t i)const = 0;
protected:
// Assignment operator (virtualized).
MantidQwtWorkspaceData& operator=(const MantidQwtWorkspaceData&);
};

#endif
20 changes: 9 additions & 11 deletions Code/Mantid/MantidQt/API/src/MantidQwtIMDWorkspaceData.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,16 +33,15 @@ MantidQwtIMDWorkspaceData::MantidQwtIMDWorkspaceData(Mantid::API::IMDWorkspace_c
Mantid::Kernel::VMD start, Mantid::Kernel::VMD end,
Mantid::API::MDNormalization normalize,
bool isDistribution)
: QObject(),
m_workspace(workspace),
m_logScale(logScale), m_minPositive(0),
m_preview(false),
m_start(start),
m_end(end),
m_normalization(normalize),
m_isDistribution(isDistribution),
m_transform(NULL),
m_plotAxis(PlotDistance), m_currentPlotAxis(PlotDistance)
: m_workspace(workspace),
m_logScale(logScale), m_minPositive(0),
m_preview(false),
m_start(start),
m_end(end),
m_normalization(normalize),
m_isDistribution(isDistribution),
m_transform(NULL),
m_plotAxis(PlotDistance), m_currentPlotAxis(PlotDistance)
{
if (start.getNumDims() == 1 && end.getNumDims() == 1)
{
Expand Down Expand Up @@ -87,7 +86,6 @@ MantidQwtIMDWorkspaceData::MantidQwtIMDWorkspaceData(Mantid::API::IMDWorkspace_c
//-----------------------------------------------------------------------------
/// Copy constructor
MantidQwtIMDWorkspaceData::MantidQwtIMDWorkspaceData(const MantidQwtIMDWorkspaceData& data)
: QObject()
{
this->operator =(data);
}
Expand Down
22 changes: 10 additions & 12 deletions Code/Mantid/MantidQt/API/src/MantidQwtMatrixWorkspaceData.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,20 @@

/// Constructor
MantidQwtMatrixWorkspaceData::MantidQwtMatrixWorkspaceData(Mantid::API::MatrixWorkspace_const_sptr workspace,int specIndex, const bool logScale, bool distr)
: QObject(),
m_workspace(workspace),
m_spec(specIndex),
m_X(workspace->readX(specIndex)),
m_Y(workspace->readY(specIndex)),
m_E(workspace->readE(specIndex)),
m_isHistogram(workspace->isHistogramData()),
m_binCentres(false),
m_logScale(logScale),
m_minPositive(0),
m_isDistribution(distr)
: m_workspace(workspace),
m_spec(specIndex),
m_X(workspace->readX(specIndex)),
m_Y(workspace->readY(specIndex)),
m_E(workspace->readE(specIndex)),
m_isHistogram(workspace->isHistogramData()),
m_binCentres(false),
m_logScale(logScale),
m_minPositive(0),
m_isDistribution(distr)
{}

/// Copy constructor
MantidQwtMatrixWorkspaceData::MantidQwtMatrixWorkspaceData(const MantidQwtMatrixWorkspaceData& data)
: QObject()
{
this->operator =(data);
}
Expand Down
12 changes: 6 additions & 6 deletions Code/Mantid/MantidQt/API/test/MantidQwtMatrixWorkspaceDataTest.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,12 +54,12 @@ class MantidQwtMatrixWorkspaceDataTest : public CxxTest::TestSuite
checkHistogramData(data2, 2.0);
}

// void test_assigmentOperator()
// {
// MantidQwtMatrixWorkspaceData data1(ws, 1, false, false);
// MantidQwtMatrixWorkspaceData data2 = data1;
// checkHistogramData(data2, 1.0);
// }
void test_assigmentOperator()
{
MantidQwtMatrixWorkspaceData data1(ws, 1, false, false);
MantidQwtMatrixWorkspaceData data2 = data1;
checkHistogramData(data2, 1.0);
}

void test_copy()
{
Expand Down

0 comments on commit 069affa

Please sign in to comment.