Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018 #include "mitkNavigationDataRecorder.h"
00019 #include "mitkNavigationData.h"
00020
00021 #include "mitkTestingMacros.h"
00022
00023 #include <iostream>
00024 #include <sstream>
00025
00029 int mitkNavigationDataRecorderTest(int , char* [])
00030 {
00031 MITK_TEST_BEGIN("NavigationDataRecorder");
00032 std::string tmp = "";
00033 std::ostringstream* stream = new std::ostringstream( std::ostringstream::trunc );
00034 stream->setf( std::ios::fixed, std::ios::floatfield );
00035
00036
00037 mitk::NavigationDataRecorder::Pointer recorder = mitk::NavigationDataRecorder::New();
00038
00039
00040
00041
00042 MITK_TEST_CONDITION_REQUIRED(recorder.IsNotNull(), "Testing instantiation");
00043
00044 MITK_TEST_CONDITION(recorder->GetInputs().size() == 0, "testing initial number of inputs");
00045 MITK_TEST_CONDITION(recorder->GetOutputs().size() == 0, "testing initial number of outputs");
00046
00047 mitk::NavigationData::Pointer naviData = mitk::NavigationData::New();
00048 recorder->AddNavigationData( naviData );
00049
00050
00051 recorder->StartRecording( stream );
00052 for ( unsigned int i=0; i<5; i++ )
00053 {
00054 mitk::Point3D pnt;
00055 pnt[0] = i + 1;
00056 pnt[1] = i + 1/2;
00057 pnt[2] = i +1*3;
00058
00059
00060 naviData->SetPosition(pnt);
00061
00062 recorder->Update();
00063
00064
00065
00066 }
00067
00068 recorder->StopRecording();
00069
00070 std::string str = stream->str();
00071 int pos = str.find( "ToolCount=" );
00072 std::string sub = stream->str().substr(pos+11, 1);
00073 MITK_TEST_CONDITION( sub.compare("1") == 0, "check if number of inputs is correct by stringstream");
00074
00075 pos = str.find( "X=" );
00076 sub = stream->str().substr(pos+3, 1);
00077 MITK_TEST_CONDITION( sub.compare("1") == 0, "check if the X coordinate is correct");
00078
00079
00080 pos = str.find( "Y=" );
00081 sub = stream->str().substr(pos+3, 1);
00082 MITK_TEST_CONDITION( sub.compare("0") == 0, "check if the Y coordinate is correct");
00083
00084
00085 pos = str.find( "Z=" );
00086 sub = stream->str().substr(pos+3, 1);
00087 MITK_TEST_CONDITION( sub.compare("3") == 0, "check if the Z coordinate is correct");
00088
00089
00090 recorder->SetFileName("blablabla");
00091 const char* string = recorder->GetFileName();
00092 MITK_TEST_CONDITION( strcmp(string, "blablabla") == 0, "check if set- and getName-methods work");
00093
00094
00095 MITK_TEST_END();
00096 }