MITK-IGT
IGT Extension of MITK
Loading...
Searching...
No Matches
mitkPolhemusToolTest.cpp
Go to the documentation of this file.
1/*============================================================================
2
3The Medical Imaging Interaction Toolkit (MITK)
4
5Copyright (c) German Cancer Research Center (DKFZ)
6All rights reserved.
7
8Use of this source code is governed by a 3-clause BSD license that can be
9found in the LICENSE file.
10
11============================================================================*/
12
13// Testing
14#include "mitkTestFixture.h"
15#include "mitkTestingMacros.h"
16
17#include "mitkPolhemusTool.h"
19
20// VTK includes
21#include <vtkDebugLeaks.h>
22
23class mitkPolhemusToolTestSuite : public mitk::TestFixture
24{
25 CPPUNIT_TEST_SUITE(mitkPolhemusToolTestSuite);
26
27 MITK_TEST(DefaultConstructor);
34
35 CPPUNIT_TEST_SUITE_END();
36
37private:
38 mitk::PolhemusTrackingDevice::Pointer m_Device;
39 mitk::PolhemusTool::Pointer m_Tool;
40
41public:
42 void setUp() override
43 {
44 m_Device = mitk::PolhemusTrackingDevice::New();
45 m_Device->AddTool("Sensor-1", 1);
46 m_Tool = dynamic_cast<mitk::PolhemusTool*>(m_Device->GetTool(0));
47 }
48
49 void tearDown() override
50 {
51 m_Tool = nullptr;
52 m_Device = nullptr;
53 }
54
56 {
57 CPPUNIT_ASSERT_EQUAL(1, m_Tool->GetToolPort());
58 CPPUNIT_ASSERT_EQUAL(mitk::PolhemusTool::DistortionLevel::UNDEFINED, m_Tool->GetDistortionLevel());
59 }
60
62 {
63 m_Tool->SetToolPort(2);
64 CPPUNIT_ASSERT_EQUAL(2, m_Tool->GetToolPort());
65 }
66
68 {
69 m_Tool->SetDistortionLevel(0);
70 CPPUNIT_ASSERT_EQUAL(mitk::PolhemusTool::DistortionLevel::NO_DISTORTION, m_Tool->GetDistortionLevel());
71 }
72
74 {
75 m_Tool->SetDistortionLevel(1);
76 CPPUNIT_ASSERT_EQUAL(mitk::PolhemusTool::DistortionLevel::MINOR_DISTORTION, m_Tool->GetDistortionLevel());
77 }
78
80 {
81 m_Tool->SetDistortionLevel(2);
82 CPPUNIT_ASSERT_EQUAL(mitk::PolhemusTool::DistortionLevel::SIGNIFICANT_DISTORTION, m_Tool->GetDistortionLevel());
83 }
84
86 {
87 m_Tool->SetDistortionLevel(-1);
88 CPPUNIT_ASSERT_EQUAL(mitk::PolhemusTool::DistortionLevel::UNDEFINED, m_Tool->GetDistortionLevel());
89 }
90
92 {
93 m_Tool->SetDistortionLevel(3);
94 CPPUNIT_ASSERT_EQUAL(mitk::PolhemusTool::DistortionLevel::UNDEFINED, m_Tool->GetDistortionLevel());
95 }
96
97};
98
99MITK_TEST_SUITE_REGISTRATION(mitkPolhemusTool)
void GetDistortionLevel_SetLevelInvalidPositive_ReturnsUndefined()
void GetDistortionLevel_SetLevelInvalidNegative_ReturnsUndefined()
void GetDistortionLevel_SetLevelTwo_ReturnsSignificantDistortion()
An object of this class represents a tool of a Polhemus tracking device. A tool has to be added to a ...
@ UNDEFINED
Distortion level is not determined.
@ SIGNIFICANT_DISTORTION
System operational with a poor magnetic signal.
@ NO_DISTORTION
System operational with a good quality magnetic signal.
@ MINOR_DISTORTION
System operational with a marginal magnetic signal.