diff --git a/Modules/Chart/CMakeLists.txt b/Modules/Chart/CMakeLists.txt index ef1102c255..112d8e7ecd 100644 --- a/Modules/Chart/CMakeLists.txt +++ b/Modules/Chart/CMakeLists.txt @@ -1,9 +1,11 @@ SET (CHART_QT_MINIMUM_VERSION 5.10.0) IF (Qt5WebEngineWidgets_VERSION VERSION_LESS CHART_QT_MINIMUM_VERSION) MESSAGE(AUTHOR_WARNING "MitkChart module requires at least ${CHART_QT_MINIMUM_VERSION}. Install this Qt version or above if you want to use MitkChart with full functionality.") ENDIF() MITK_CREATE_MODULE( DEPENDS MitkCore - PACKAGE_DEPENDS PRIVATE Qt5|WebEngineWidgets + PACKAGE_DEPENDS PUBLIC Qt5|WebEngineWidgets ) + +add_subdirectory(test) \ No newline at end of file diff --git a/Modules/Chart/test/CMakeLists.txt b/Modules/Chart/test/CMakeLists.txt new file mode 100644 index 0000000000..153cd81e2e --- /dev/null +++ b/Modules/Chart/test/CMakeLists.txt @@ -0,0 +1 @@ +MITK_CREATE_MODULE_TESTS() diff --git a/Modules/Chart/test/files.cmake b/Modules/Chart/test/files.cmake new file mode 100644 index 0000000000..d7046f87fc --- /dev/null +++ b/Modules/Chart/test/files.cmake @@ -0,0 +1,6 @@ +set(MODULE_TESTS + mitkChartWidgetTest.cpp +) + +SET(MODULE_CUSTOM_TESTS +) diff --git a/Modules/Chart/test/mitkChartWidgetTest.cpp b/Modules/Chart/test/mitkChartWidgetTest.cpp new file mode 100644 index 0000000000..d58dca9f35 --- /dev/null +++ b/Modules/Chart/test/mitkChartWidgetTest.cpp @@ -0,0 +1,91 @@ +/*=================================================================== + +The Medical Imaging Interaction Toolkit (MITK) + +Copyright (c) German Cancer Research Center, +Division of Medical and Biological Informatics. +All rights reserved. + +This software is distributed WITHOUT ANY WARRANTY; without +even the implied warranty of MERCHANTABILITY or FITNESS FOR +A PARTICULAR PURPOSE. + +See LICENSE.txt or http://www.mitk.org for details. + +===================================================================*/ + +// Testing +#include "mitkTestFixture.h" +#include "mitkTestingMacros.h" + +// qt includes +#include + +// std includes +#include + + +// MITK includes +#include "QmitkChartWidget.h" + + + +class mitkChartWidgetTestSuite : public mitk::TestFixture +{ + CPPUNIT_TEST_SUITE(mitkChartWidgetTestSuite); + + // Test the dicom property parsing + MITK_TEST(AddOnce_Test_Success); + MITK_TEST(RemoveNonexistingData_Success); + MITK_TEST(RemoveData_Success); + CPPUNIT_TEST_SUITE_END(); + +private: + + std::vector data1D; + std::string label; + +public: + + void setUp() override + { + data1D = { 2, 4, 7, 8, 21, 5, 12, 65, 41, 9 }; + label = "testLabel"; + + int argc = 1; + char* argv[] = { "AppName" }; + if (QApplication::instance() == nullptr) + { + new QApplication(argc, argv); + } + } + + void tearDown() override + { + } + + void AddOnce_Test_Success() + { + QmitkChartWidget widget; + + CPPUNIT_ASSERT_NO_THROW_MESSAGE("Adding data caused an exception", widget.AddData1D(data1D, label)); + + //TODO Check internals + } + + void RemoveNonexistingData_Success() + { + QmitkChartWidget widget; + + CPPUNIT_ASSERT_THROW_MESSAGE("Removin nonexistend label did not throw exception", widget.RemoveData(label), std::invalid_argument); + } + void RemoveData_Success() + { + QmitkChartWidget widget; + widget.AddData1D(data1D, label); + + CPPUNIT_ASSERT_NO_THROW_MESSAGE("Removin nonexistend label did not throw exception", widget.RemoveData(label)); + } +}; + +MITK_TEST_SUITE_REGISTRATION(mitkChartWidget) \ No newline at end of file