InDesign SDK
20.5
InDesign SDK
Documentation
Bosses
Sample plug-ins
Class Index
All
Classes
Namespaces
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Groups
Pages
CUnitTest.h
1
//========================================================================================
2
//
3
// $File$
4
//
5
// Owner: Jesse Jones (jejones)
6
//
7
// $Author$
8
//
9
// $DateTime$
10
//
11
// $Revision$
12
//
13
// $Change$
14
//
15
// Copyright 1997-2010 Adobe Systems Incorporated. All rights reserved.
16
//
17
// NOTICE: Adobe permits you to use, modify, and distribute this file in accordance
18
// with the terms of the Adobe license agreement accompanying it. If you have received
19
// this file from a source other than Adobe, then your use, modification, or
20
// distribution of it requires the prior written permission of Adobe.
21
//
22
//
23
// Purpose: Adds a menu to the Test menu so that individual classes can be tested.
24
//
25
// Usage: Subclass CUnitTest, override OnTest, and create a static object in one of your
26
// cpp files (it's important to create a static object so that UnitTestList can figure
27
// out when your plugin must be loaded). The test will be automatically added to the unit
28
// test menu.
29
//
30
//========================================================================================
31
32
#ifndef __CUNITTEST__
33
#define __CUNITTEST__
34
35
#ifdef DEBUG
36
37
#include "PMTypes.h"
38
39
40
class
IPlugIn
;
41
42
43
// Instead of calling ASSERT or ASSERT_MSG your unit test should use this macro.
44
// This allows us to maintain statistics on how many tests failed and gives us
45
// more control over what we break into the debugger for.
46
#define TEST(p) !(p) ? this->DoTestFailed(#p, __FILE__, __LINE__) : (void) 0
47
48
49
// If you want to put your unit test in its own file you'll need to ensure that it
50
// isn't deadstripped. You can do this by using the DEFINE_UNIT_TEST in the unit test
51
// file and REFERENCE_UNIT_TEST in your plugin's MWHacks file.
52
#define DEFINE_UNIT_TEST(Class) \
53
void Reference##Class(); \
54
void Reference##Class() { \
55
Class test; \
56
}
57
58
#define REFERENCE_UNIT_TEST(Class) \
59
void Reference##Class(); \
60
Reference##Class()
61
62
63
// ===================================================================================
64
// class CUnitTest
65
// ===================================================================================
66
class
CUnitTest {
67
68
//-----------------------------------
69
// Initialization/Destruction
70
//
71
public
:
72
virtual
~CUnitTest();
73
74
CUnitTest(
const
char
* name,
PluginID
id
, bool16 isObsolete = kTrue);
75
76
private
:
77
CUnitTest(
const
CUnitTest& rhs);
78
79
CUnitTest& operator=(
const
CUnitTest& rhs);
80
81
//-----------------------------------
82
// API
83
//
84
public
:
85
virtual
void
RunTest();
86
virtual
void
RunMinimalTest();
87
// Test that gets run as part of minimal. By default, same as RunTest.
88
89
const
char
* GetName()
const
{
return
fName;}
90
91
PluginID
GetPlugin()
const
{
return
fPlugin;}
92
93
protected
:
94
virtual
void
OnTest() = 0;
95
// This will normally be the only function you override.
96
97
//-----------------------------------
98
// Internal API
99
//
100
protected
:
101
virtual
void
DoTestFailed(
const
char
* message,
const
char
* file, int32 line)
const
;
102
103
//-----------------------------------
104
// Member Data
105
//
106
private
:
107
const
char
* fName;
108
PluginID
fPlugin;
109
};
110
111
112
113
#endif // DEBUG
114
#endif // __CUNITTEST__
tmpdoxygeninput
CUnitTest.h
Generated on Sat Jul 19 2025 02:54:11 for InDesign SDK by
1.8.3.1