24 #include <vtkDebugLeaks.h> 32 std::string
GetName()
const {
return m_Name; }
34 explicit TestPropertyExtension(
const std::string &name) : m_Name(name) {}
35 ~TestPropertyExtension()
override {}
41 CPPUNIT_TEST_SUITE(mitkPropertyExtensionsTestSuite);
42 MITK_TEST(GetPropertyExtensionService_Success);
44 MITK_TEST(GetOverwrittenExtension_Success);
45 MITK_TEST(GetPropertyExtensionRestricted_Success);
46 CPPUNIT_TEST_SUITE_END();
56 m_PropertyExtensions->
AddExtension(
"propertyName1", TestPropertyExtension::New(
"extension1a").GetPointer());
57 m_PropertyExtensions->
AddExtension(
"propertyName1", TestPropertyExtension::New(
"extension1b").GetPointer());
62 m_PropertyExtensions =
nullptr;
65 void GetPropertyExtensionService_Success()
67 CPPUNIT_ASSERT_MESSAGE(
"Get property extensions service", m_PropertyExtensions !=
nullptr);
70 void GetPropertyExtension_Success()
73 dynamic_cast<TestPropertyExtension *
>(m_PropertyExtensions->
GetExtension(
"propertyName1").GetPointer());
75 CPPUNIT_ASSERT_MESSAGE(
"Get extension of \"propertyName1\"",
76 extension1.IsNotNull() && extension1->GetName() ==
"extension1a");
79 void GetOverwrittenExtension_Success()
81 m_PropertyExtensions->
AddExtension(
"propertyName1", TestPropertyExtension::New(
"extension1b").GetPointer(),
"",
true);
82 m_Extension1 =
dynamic_cast<TestPropertyExtension *
>(m_PropertyExtensions->
GetExtension(
"propertyName1").GetPointer());
83 CPPUNIT_ASSERT_MESSAGE(
"Get overwritten extension of \"propertyName1\"",
84 m_Extension1.IsNotNull() && m_Extension1->GetName() ==
"extension1b");
87 void GetPropertyExtensionRestricted_Success()
89 m_PropertyExtensions->
AddExtension(
"propertyName1", TestPropertyExtension::New(
"extension1c").GetPointer(),
"className");
91 dynamic_cast<TestPropertyExtension *
>(m_PropertyExtensions->
GetExtension(
"propertyName1",
"className").GetPointer());
92 m_Extension1 =
dynamic_cast<TestPropertyExtension *
>(m_PropertyExtensions->
GetExtension(
"propertyName1").GetPointer());
94 CPPUNIT_ASSERT_MESSAGE(
"Get extension of \"propertyName1\" restricted to \"className\"",
95 m_Extension1.IsNotNull() && m_Extension1->GetName() ==
"extension1b" && extension2.IsNotNull() &&
96 extension2->GetName() ==
"extension1c");
MITK_TEST_SUITE_REGISTRATION(mitkImageToItk)
#define mitkNewMacro1Param(classname, type)
static IPropertyExtensions * GetPropertyExtensions(us::ModuleContext *context=us::GetModuleContext())
Get an IPropertyExtensions instance.
#define MITK_TEST(TESTMETHOD)
Adds a test to the current test suite.
virtual PropertyExtension::Pointer GetExtension(const std::string &propertyName, const std::string &className="")=0
Get the extension of a specific property.
Interface of property extensions service.
#define mitkClassMacro(className, SuperClassName)
Test fixture for parameterized tests.
Base class for all property extensions.
static std::string GetName(std::string fileName, std::string suffix)
virtual bool AddExtension(const std::string &propertyName, PropertyExtension::Pointer extension, const std::string &className="", bool overwrite=false)=0
Add an extension to a specific property.