Medical Imaging Interaction Toolkit  2016.11.0
Medical Imaging Interaction Toolkit
mitkLoggingAdapterTest.cpp
Go to the documentation of this file.
1 /*===================================================================
2 
3 The Medical Imaging Interaction Toolkit (MITK)
4 
5 Copyright (c) German Cancer Research Center,
6 Division of Medical and Biological Informatics.
7 All rights reserved.
8 
9 This software is distributed WITHOUT ANY WARRANTY; without
10 even the implied warranty of MERCHANTABILITY or FITNESS FOR
11 A PARTICULAR PURPOSE.
12 
13 See LICENSE.txt or http://www.mitk.org for details.
14 
15 ===================================================================*/
16 
17 #include "mitkTestingMacros.h"
18 #include <mitkCommon.h>
19 #include <mitkItkLoggingAdapter.h>
20 #include <mitkVtkLoggingAdapter.h>
21 
22 class ItkLoggingTestClass : public itk::Object
23 {
24 public:
25  mitkClassMacroItkParent(ItkLoggingTestClass, itk::Object);
26  itkFactorylessNewMacro(Self) itkCloneMacro(Self)
27 
28  void TestItkWarningMessage()
29  {
30  itkWarningMacro("Test ITK Warning message");
31  }
32 };
33 
35 class LoggingAdapterTestClass
36 {
37 public:
38  static void TestVtkLoggingWithoutAdapter()
39  {
41  << "Testing vtk logging without adapter class: a separate window should open and display the logging messages.")
42  vtkOutputWindow::GetInstance()->DisplayText("Test VTK InfoMessage");
43  vtkOutputWindow::GetInstance()->DisplayDebugText("Test Vtk Debug Message");
44  vtkOutputWindow::GetInstance()->DisplayGenericWarningText("Test Vtk Generic Warning Message");
45  vtkOutputWindow::GetInstance()->DisplayWarningText("Test Vtk Warning Message");
46  vtkOutputWindow::GetInstance()->DisplayErrorText("Test Vtk Error Message");
47  MITK_TEST_CONDITION_REQUIRED(true, "Testing if Vtk logging without adapter runs without errors.");
48  }
49  static void TestVtkLoggingWithAdapter()
50  {
52  << "Testing vtk logging with adapter class: Vtk logging messages should be logged as MITK logging messages.")
53  mitk::VtkLoggingAdapter::Initialize();
54  vtkOutputWindow::GetInstance()->DisplayText("Test Vtk Info Message");
55  vtkOutputWindow::GetInstance()->DisplayDebugText("Test Vtk Debug Message");
56  vtkOutputWindow::GetInstance()->DisplayGenericWarningText("Test Vtk Generic Warning Message");
57  vtkOutputWindow::GetInstance()->DisplayWarningText("Test Vtk Warning Message");
58  vtkOutputWindow::GetInstance()->DisplayErrorText("Test Vtk Error Message");
59  MITK_TEST_CONDITION_REQUIRED(true, "Testing if Vtk logging with MITK logging adapter runs without errors.");
60  }
61 
62  static void TestItkLoggingWithoutAdapter()
63  {
65  myItkLogger->TestItkWarningMessage();
66  }
67 
68  static void TestItkLoggingWithAdapter()
69  {
72  myItkLogger->TestItkWarningMessage();
73  }
74 };
75 
76 int mitkLoggingAdapterTest(int /*argc*/, char * /*argv*/ [])
77 {
78  MITK_TEST_BEGIN("LoggingAdapters: VTK, ITK");
79  LoggingAdapterTestClass::TestVtkLoggingWithoutAdapter();
80  LoggingAdapterTestClass::TestVtkLoggingWithAdapter();
81  LoggingAdapterTestClass::TestItkLoggingWithoutAdapter();
82  LoggingAdapterTestClass::TestItkLoggingWithAdapter();
83  MITK_TEST_END();
84 }
itk::SmartPointer< Self > Pointer
#define MITK_TEST_CONDITION_REQUIRED(COND, MSG)
int mitkLoggingAdapterTest(int, char *[])
DataCollection - Class to facilitate loading/accessing structured data.
section GeneralTestsDeprecatedOldTestingStyle Deprecated macros All tests with MITK_TEST_BEGIN()
#define MITK_TEST_OUTPUT(x)
Output some text.
#define mitkClassMacroItkParent(className, SuperClassName)
Definition: mitkCommon.h:53
static void Initialize()
Initializes the logging adapter. Itk logging messages are redirected to MITK logging afterwards...
and MITK_TEST_END()
static itkEventMacro(BoundingShapeInteractionEvent, itk::AnyEvent) class MITKBOUNDINGSHAPE_EXPORT BoundingShapeInteractor Pointer New()
Basic interaction methods for mitk::GeometryData.