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 "mitkDataNodeFactory.h"
00019 #include "mitkTestingMacros.h"
00020
00021 #include "mitkProperties.h"
00022
00023 #include <itksys/SystemTools.hxx>
00024 #include <itksys/Directory.hxx>
00033 int mitkDataNodeFactoryTest(int, char* argv[])
00034 {
00035
00036 MITK_TEST_BEGIN("DataNodeFactory")
00037
00038 mitk::DataNodeFactory::Pointer factory = mitk::DataNodeFactory::New();
00039 MITK_TEST_OUTPUT(<< "Loading file: " << argv[1]);
00040
00041 factory->SetFileName( argv[1] );
00042 MITK_TEST_CONDITION_REQUIRED(strcmp(factory->GetFileName(),argv[1])==0,"Test for Set/GetFileName()");
00043
00044 factory->Update();
00045 MITK_TEST_CONDITION_REQUIRED(factory->GetNumberOfOutputs() > 0, "file loaded");
00046
00047 MITK_TEST_OUTPUT(<< "Test function SetDefaultCommonProperties()");
00048 mitk::DataNode::Pointer node = factory->GetOutput( 0 );
00049 factory->SetDefaultCommonProperties(node);
00050
00051 std::string filePath = itksys::SystemTools::GetFilenamePath(factory->GetFileName());
00052 mitk::StringProperty::Pointer pathProp = dynamic_cast<mitk::StringProperty*>(node->GetProperty(mitk::StringProperty::PATH));
00053
00054 MITK_TEST_CONDITION_REQUIRED(strcmp(pathProp->GetValue(),filePath.c_str())==0,"Test for file path");
00055
00056 std::string fileName = factory->GetFileName();
00057 std::string fileExtension = itksys::SystemTools::GetFilenameExtension(fileName);
00058 if (fileName.substr(fileName.size()-3) == ".gz")
00059 fileName = fileName.substr( 0, fileName.length()-3 );
00060 fileName = fileName.substr(0,fileName.length()-fileExtension.length());
00061 fileName = fileName.substr(filePath.length()+1, fileName.length());
00062 mitk::StringProperty::Pointer nameProp = dynamic_cast<mitk::StringProperty*>(node->GetProperty("name"));
00063 MITK_TEST_CONDITION_REQUIRED(strcmp(nameProp->GetValue(),fileName.c_str())==0,"Test for file name");
00064
00065 mitk::BoolProperty::Pointer visibleProp = dynamic_cast<mitk::BoolProperty*>(node->GetProperty("visible"));
00066 MITK_TEST_CONDITION_REQUIRED(visibleProp->GetValue()==true,"Test for visibility");
00067
00068 MITK_TEST_END()
00069 }