MITK-IGT
IGT Extension of MITK
Loading...
Searching...
No Matches
mitkClaronToolTest.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#include "mitkClaronTool.h"
14#include "mitkTestingMacros.h"
15
24{
25public:
31 itkCloneMacro(Self)
32protected:
33 ClaronToolTestClass() : mitk::ClaronTool()
34 {
35 }
36};
37
41int mitkClaronToolTest(int /* argc */, char* /*argv*/[])
42{
43 // always start with this!
44 MITK_TEST_BEGIN("ClaronTool")
45 {
46 // let's create an object of our class
47 mitk::ClaronTool::Pointer myClaronTool = ClaronToolTestClass::New().GetPointer();
48
49 // first test: did this work?
50 // using MITK_TEST_CONDITION_REQUIRED makes the test stop after failure, since
51 // it makes no sense to continue without an object.
52 MITK_TEST_CONDITION_REQUIRED(myClaronTool.IsNotNull(),"Testing instantiation:")
53
54 mitk::Point3D pos;
55 pos[0] = 10;
56 pos[1] = 20;
57 pos[2] = 30;
58 myClaronTool->SetPosition(pos);
59 mitk::Point3D testPos;
60 myClaronTool->GetPosition(testPos);
61 MITK_TEST_CONDITION((testPos==pos),"Testing position update:")
62
63 mitk::Quaternion orientation(10,20,30,40);
64 myClaronTool->SetOrientation(orientation);
65 mitk::Quaternion testOri;
66 myClaronTool->GetOrientation(testOri);
67 MITK_TEST_CONDITION((testOri==orientation),"Testing orientation update:")
68
69 std::string name = "//testfilename";
70 std::string name1 = "/testfilename";
71 std::string name2 = "testfilename";
72 MITK_TEST_CONDITION(myClaronTool->LoadFile(name) == true ,"Test LoadFile() with valid windows file name")
73 MITK_TEST_CONDITION(myClaronTool->LoadFile(name1) == true ,"Test LoadFile() with valid Linux file name")
74 MITK_TEST_CONDITION(myClaronTool->LoadFile(name2) == false, "Test LoadFile() with invalid file name")
75 MITK_TEST_CONDITION(myClaronTool->GetCalibrationName() == name2 ,"Test GetCalibrationName() after setting with LoadFile()")
76 myClaronTool->SetCalibrationName(name);
77 MITK_TEST_CONDITION(myClaronTool->GetCalibrationName() == name ,"Test GetCalibrationName() after setting with SetCalibrationName()")
78
79 myClaronTool->LoadFile(name);
80 MITK_TEST_CONDITION(myClaronTool->GetFile() == name ,"Testing GetFile() after setting file name with LoadFile()");
81 MITK_TEST_CONDITION(myClaronTool->LoadFile(nullptr) == false ,"Test LoadFile() with nullptr as parameter.")
82 MITK_TEST_CONDITION(myClaronTool->LoadFile(std::string("")) == false ,"Test LoadFile() with empty string as parameter.")
83
84 myClaronTool->SetToolHandle(011022);
85 MITK_TEST_CONDITION(myClaronTool->GetToolHandle() == 011022 ,"Test SetToolHandle() and GetToolHandle().")
86
87 }
88 // always end with this!
89 MITK_TEST_END()
90}
91
mitkClassMacro(ClaronToolTestClass, ClaronTool)
itkFactorylessNewMacro(Self) itkCloneMacro(Self) protected
An object of this class represents a MicronTracker 2 tool. A tool has to be added to a tracking devic...
itkCloneMacro(Self) ClaronTool()
int mitkClaronToolTest(int, char *[])
IGT Exceptions.