diff --git a/Modules/IGT/Testing/files.cmake b/Modules/IGT/Testing/files.cmake index 49ace7a3f2..e7cc9d5d74 100644 --- a/Modules/IGT/Testing/files.cmake +++ b/Modules/IGT/Testing/files.cmake @@ -1,74 +1,74 @@ set(MODULE_TESTS # IMPORTANT: If you plan to deactivate / comment out a test please write a bug number to the commented out line of code. # # Example: #mitkMyTest #this test is commented out because of bug 12345 # # It is important that the bug is open and that the test will be activated again before the bug is closed. This assures that # no test is forgotten after it was commented out. If there is no bug for your current problem, please add a new one and # mark it as critical. ################## ON THE FENCE TESTS ################################################# # none ################## DISABLED TESTS ##################################################### ################# RUNNING TESTS ####################################################### mitkCameraVisualizationTest.cpp mitkClaronInterfaceTest.cpp mitkClaronToolTest.cpp mitkClaronTrackingDeviceTest.cpp mitkNavigationDataDisplacementFilterTest.cpp mitkNavigationDataLandmarkTransformFilterTest.cpp mitkNavigationDataObjectVisualizationFilterTest.cpp mitkNavigationDataSetTest.cpp mitkNavigationDataTest.cpp mitkNavigationDataRecorderTest.cpp mitkNavigationDataReferenceTransformFilterTest.cpp mitkNavigationDataSequentialPlayerTest.cpp mitkNavigationDataSetReaderWriterXMLTest.cpp mitkNavigationDataSetReaderWriterCSVTest.cpp mitkNavigationDataSourceTest.cpp mitkNavigationDataToMessageFilterTest.cpp mitkNavigationDataToNavigationDataFilterTest.cpp mitkNavigationDataToPointSetFilterTest.cpp mitkNavigationDataToIGTLMessageFilterTest.cpp mitkNavigationDataTransformFilterTest.cpp mitkNDIPassiveToolTest.cpp mitkNDIProtocolTest.cpp mitkNDITrackingDeviceTest.cpp mitkTimeStampTest.cpp mitkTrackingVolumeGeneratorTest.cpp mitkTrackingDeviceTest.cpp mitkTrackingToolTest.cpp mitkVirtualTrackingDeviceTest.cpp # mitkNavigationDataPlayerTest.cpp # random fails see bug 16485. # We decided to won't fix because of complete restructuring via bug 15959. mitkTrackingDeviceSourceTest.cpp mitkTrackingDeviceSourceConfiguratorTest.cpp mitkNavigationDataEvaluationFilterTest.cpp mitkTrackingTypesTest.cpp mitkOpenIGTLinkTrackingDeviceTest.cpp # ------------------ Navigation Tool Management Tests ------------------- mitkNavigationToolStorageDeserializerTest.cpp # Activated experimentally on dart clients, see task T17303 for details. mitkNavigationToolStorageTest.cpp mitkNavigationToolTest.cpp # ----------------------------------------------------------------------- ) set(MODULE_CUSTOM_TESTS mitkNDIAuroraHardwareTest.cpp mitkNDIPolarisHardwareTest.cpp mitkClaronTrackingDeviceHardwareTest.cpp mitkNavigationToolReaderAndWriterTest.cpp #deactivated because of bug 18835 mitkNavigationToolStorageSerializerAndDeserializerIntegrationTest.cpp # This test was disabled because of bug 17181. mitkNavigationToolStorageSerializerTest.cpp # This test was disabled because of bug 18671 - #mitkPolhemusTrackingDeviceHardwareTest.cpp ) if(MITK_USE_POLHEMUS_TRACKER) set(MODULE_CUSTOM_TESTS ${MODULE_CUSTOM_TESTS} mitkPolhemusTrackingDeviceHardwareTest.cpp + mitkPolhemusToolTest.cpp ) endif(MITK_USE_POLHEMUS_TRACKER) diff --git a/Modules/IGT/Testing/mitkPolhemusToolTest.cpp b/Modules/IGT/Testing/mitkPolhemusToolTest.cpp new file mode 100644 index 0000000000..25f2e3ba02 --- /dev/null +++ b/Modules/IGT/Testing/mitkPolhemusToolTest.cpp @@ -0,0 +1,103 @@ +/*=================================================================== + +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" + +#include "mitkPolhemusTool.h" +#include "mitkPolhemusTrackingDevice.h" + +// VTK includes +#include + +class mitkPolhemusToolTestSuite : public mitk::TestFixture +{ + CPPUNIT_TEST_SUITE(mitkPolhemusToolTestSuite); + + MITK_TEST(DefaultConstructor); + MITK_TEST(GetToolPort_SetToolPortTwo_ReturnsToolPortTwo); + MITK_TEST(GetDistortionLevel_SetLevelZero_ReturnsNoDistortion); + MITK_TEST(GetDistortionLevel_SetLevelOne_ReturnsMinorDistortion); + MITK_TEST(GetDistortionLevel_SetLevelTwo_ReturnsSignificantDistortion); + MITK_TEST(GetDistortionLevel_SetLevelInvalidNegative_ReturnsUndefined); + MITK_TEST(GetDistortionLevel_SetLevelInvalidPositive_ReturnsUndefined); + + CPPUNIT_TEST_SUITE_END(); + +private: + mitk::PolhemusTrackingDevice::Pointer m_Device; + mitk::PolhemusTool::Pointer m_Tool; + +public: + void setUp() override + { + m_Device = mitk::PolhemusTrackingDevice::New(); + m_Device->AddTool("Sensor-1", 1); + m_Tool = dynamic_cast(m_Device->GetTool(0)); + } + + void tearDown() override + { + m_Tool = nullptr; + m_Device = nullptr; + } + + void DefaultConstructor() + { + CPPUNIT_ASSERT_EQUAL(1, m_Tool->GetToolPort()); + CPPUNIT_ASSERT_EQUAL(mitk::PolhemusTool::DistortionLevel::UNDEFINED, m_Tool->GetDistortionLevel()); + } + + void GetToolPort_SetToolPortTwo_ReturnsToolPortTwo() + { + m_Tool->SetToolPort(2); + CPPUNIT_ASSERT_EQUAL(2, m_Tool->GetToolPort()); + } + + void GetDistortionLevel_SetLevelZero_ReturnsNoDistortion() + { + m_Tool->SetDistortionLevel(0); + CPPUNIT_ASSERT_EQUAL(mitk::PolhemusTool::DistortionLevel::NO_DISTORTION, m_Tool->GetDistortionLevel()); + } + + void GetDistortionLevel_SetLevelOne_ReturnsMinorDistortion() + { + m_Tool->SetDistortionLevel(1); + CPPUNIT_ASSERT_EQUAL(mitk::PolhemusTool::DistortionLevel::MINOR_DISTORTION, m_Tool->GetDistortionLevel()); + } + + void GetDistortionLevel_SetLevelTwo_ReturnsSignificantDistortion() + { + m_Tool->SetDistortionLevel(2); + CPPUNIT_ASSERT_EQUAL(mitk::PolhemusTool::DistortionLevel::SIGNIFICANT_DISTORTION, m_Tool->GetDistortionLevel()); + } + + void GetDistortionLevel_SetLevelInvalidNegative_ReturnsUndefined() + { + m_Tool->SetDistortionLevel(-1); + CPPUNIT_ASSERT_EQUAL(mitk::PolhemusTool::DistortionLevel::UNDEFINED, m_Tool->GetDistortionLevel()); + } + + void GetDistortionLevel_SetLevelInvalidPositive_ReturnsUndefined() + { + m_Tool->SetDistortionLevel(3); + CPPUNIT_ASSERT_EQUAL(mitk::PolhemusTool::DistortionLevel::UNDEFINED, m_Tool->GetDistortionLevel()); + } + +}; + +MITK_TEST_SUITE_REGISTRATION(mitkPolhemusTool) diff --git a/Modules/IGT/Testing/mitkPolhemusTrackingDeviceHardwareTest.cpp b/Modules/IGT/Testing/mitkPolhemusTrackingDeviceHardwareTest.cpp index 1a8328106c..52d525c2b3 100644 --- a/Modules/IGT/Testing/mitkPolhemusTrackingDeviceHardwareTest.cpp +++ b/Modules/IGT/Testing/mitkPolhemusTrackingDeviceHardwareTest.cpp @@ -1,65 +1,65 @@ /*=================================================================== 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. ===================================================================*/ #include "mitkPolhemusInterface.h" #include "mitkTestingMacros.h" #include "mitkStandardFileLocations.h" #include // Testing #include "mitkTestingMacros.h" #include "mitkTestFixture.h" class mitkPolhemusTrackingDeviceHardwareTestSuite : public mitk::TestFixture { CPPUNIT_TEST_SUITE(mitkPolhemusTrackingDeviceHardwareTestSuite); // Test the append method MITK_TEST(testInterface); CPPUNIT_TEST_SUITE_END(); public: void setUp() override { } void tearDown() override { } void testInterface() { mitk::PolhemusInterface::Pointer myInterface = mitk::PolhemusInterface::New(); CPPUNIT_ASSERT_MESSAGE("Testing connection.", myInterface->Connect()); CPPUNIT_ASSERT_MESSAGE("Start tracking.", myInterface->StartTracking()); CPPUNIT_ASSERT_MESSAGE("Tracking 20 frames ...", true); for (int i = 0; i < 20; i++) { std::vector lastFrame = myInterface->GetLastFrame(); MITK_INFO << "Frame " << i; for (size_t j = 0; j < lastFrame.size(); j++) { - MITK_INFO << "[" << j << "]" << " Pos:" << lastFrame.at(j).pos << " Rot:" << lastFrame.at(j).rot; + MITK_INFO << "[" << j << "]" << " Pos: " << lastFrame.at(j).pos << " Rot: " << lastFrame.at(j).rot << " DistortionLevel: " << lastFrame.at(j).distortionLevel; } } } }; MITK_TEST_SUITE_REGISTRATION(mitkPolhemusTrackingDeviceHardware)