forked from Slicer/SlicerGitSVNArchive
-
Notifications
You must be signed in to change notification settings - Fork 2
/
vtkMRMLCoreTestingUtilities.h
153 lines (115 loc) · 4.93 KB
/
vtkMRMLCoreTestingUtilities.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
/*==============================================================================
Program: 3D Slicer
Copyright (c) Kitware Inc.
See COPYRIGHT.txt
or http://www.slicer.org/copyright/copyright.txt for details.
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
This file was originally developed by Jean-Christophe Fillion-Robin, Kitware Inc.
and was partially funded by NIH grant 1U24CA194354-01
==============================================================================*/
#ifndef __vtkMRMLCoreTestingUtilities_h
#define __vtkMRMLCoreTestingUtilities_h
// MRML/Core includes
#include <vtkMRML.h>
// VTK includes
#include <vtkCallbackCommand.h>
// STD includes
#include <sstream>
#include <vector>
#include <map>
class vtkMRMLNode;
class vtkMRMLScene;
class vtkMRMLDisplayableNode;
class vtkMRMLDisplayNode;
class vtkMRMLStorableNode;
class vtkMRMLStorageNode;
class vtkMRMLTransformableNode;
class vtkMRMLTransformNode;
/// This module provides functions to facilitate writing tests.
///
/// Usually these test methods are used by single-line convenience macros
/// defined in vtkMRMLCoreTestingMacros.h.
namespace vtkMRMLCoreTestingUtilities
{
VTK_MRML_EXPORT
bool CheckNodeInSceneByID(int line, vtkMRMLScene* scene,
const char* nodeID, vtkMRMLNode* expected);
VTK_MRML_EXPORT
bool CheckNodeIdAndName(int line, vtkMRMLNode* node,
const char* expectedID, const char* expectedName);
template<typename Type>
std::string ToString(Type value);
/// Test basic VTK object methods (print, superclass, etc.)
VTK_MRML_EXPORT
int ExerciseBasicObjectMethods(vtkObject* object);
/// Tests all basic MRML methods available for the current class.
/// Internally it calls ExerciseBasicObjectMethods, ExerciseBasicMRMLMethods,
/// ExerciseBasicTransformableMRMLMethods, ExerciseBasicStorableMRMLMethods, etc.
VTK_MRML_EXPORT
int ExerciseAllBasicMRMLMethods(vtkMRMLNode* object);
/// Slicer Libs/MRML/vtkMRMLNode exercises
VTK_MRML_EXPORT
int ExerciseBasicMRMLMethods(vtkMRMLNode* node);
/// For testing nodes in Libs/MRML that are storable. Calls the basic
/// mrml methods macro first.
VTK_MRML_EXPORT
int ExerciseBasicStorableMRMLMethods(vtkMRMLStorableNode* node);
/// For testing nodes in Libs/MRML that are transformable. Calls the basic
/// storable mrml methods macro first.
VTK_MRML_EXPORT
int ExerciseBasicTransformableMRMLMethods(vtkMRMLTransformableNode* node);
/// For testing nodes in Libs/MRML that are displayable. Calls the basic
/// transformable mrml methods macro first.
VTK_MRML_EXPORT
int ExerciseBasicDisplayableMRMLMethods(vtkMRMLDisplayableNode* node);
/// For testing nodes in Libs/MRML that are subclasses of the display node. Calls the basic
/// mrml methods macro first.
VTK_MRML_EXPORT
int ExerciseBasicDisplayMRMLMethods(vtkMRMLDisplayNode* node);
/// For testing nodes in Libs/MRML that are subclasses of the storage node. Calls the basic
/// mrml methods macro first.
VTK_MRML_EXPORT
int ExerciseBasicStorageMRMLMethods(vtkMRMLStorageNode* node);
/// For testing nodes in Libs/MRML that are transform nodes. Calls the basic
/// storable mrml methods macro first.
VTK_MRML_EXPORT
int ExerciseBasicTransformMRMLMethods(vtkMRMLTransformNode* node);
/// Test scene loading and import with a custom scene.
/// This is a utility function because scene import of custom MRML nodes cannot be tested
/// in the base MRML library.
/// If inputScene is provided then that scene will be used for testing scene loading. It is
/// needed when custom node registration is necessary in the scene.
VTK_MRML_EXPORT
int ExerciseSceneLoadingMethods(const char * sceneFilePath, vtkMRMLScene* inputScene = NULL);
//---------------------------------------------------------------------------
class VTK_MRML_EXPORT vtkMRMLNodeCallback : public vtkCallbackCommand
{
public:
static vtkMRMLNodeCallback *New() {return new vtkMRMLNodeCallback;}
void PrintSelf(ostream& os, vtkIndent indent);
virtual void Execute(vtkObject* caller, unsigned long eid, void *callData);
virtual void ResetNumberOfEvents();
void SetMRMLNode(vtkMRMLNode*);
std::string GetErrorString();
/// Returns EXIT_SUCCESS if string is empty, EXIT_FAILURE if string is non-empty
int CheckStatus();
int GetNumberOfModified();
int GetNumberOfEvents(unsigned long event);
int GetTotalNumberOfEvents();
std::vector<unsigned long> GetReceivedEvents();
protected:
vtkMRMLNodeCallback();
~vtkMRMLNodeCallback();
void SetErrorString(const char* error);
void SetErrorString(int line, const char* error);
vtkMRMLNode* Node;
std::string ErrorString;
std::map<unsigned long, unsigned int> ReceivedEvents;
};
} // namespace vtkMRMLCoreTestingUtilities
#include "vtkMRMLCoreTestingUtilities.txx"
#endif