51
|
1 |
/*
|
|
2 |
* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies).
|
|
3 |
* All rights reserved.
|
|
4 |
* This component and the accompanying materials are made available
|
|
5 |
* under the terms of "Eclipse Public License v1.0"
|
|
6 |
* which accompanies this distribution, and is available
|
|
7 |
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
|
8 |
*
|
|
9 |
* Initial Contributors:
|
|
10 |
* Nokia Corporation - initial contribution.
|
|
11 |
*
|
|
12 |
* Contributors:
|
|
13 |
*
|
|
14 |
* Description: XIMP Framework Test Code
|
|
15 |
*
|
|
16 |
*/
|
|
17 |
|
|
18 |
#ifndef EUNITTOOLS_H
|
|
19 |
#define EUNITTOOLS_H
|
|
20 |
|
|
21 |
#include <e32std.h>
|
|
22 |
|
|
23 |
#include <platform/digia/eunit/eunitmacros.h>
|
|
24 |
#include <platform/digia/eunit/teunitassertioninfo.h>
|
|
25 |
|
|
26 |
#include <platform/digia/eunit/ceunittestsuiteclass.h>
|
|
27 |
#include <platform/digia/eunit/EUnitDecorators.h>
|
|
28 |
|
|
29 |
|
|
30 |
#include "cglobalwaitingnote.h"
|
|
31 |
|
|
32 |
|
|
33 |
|
|
34 |
// -----------------------------------------------------------------------------
|
|
35 |
// ASSERTION HELPER
|
|
36 |
// Leaves if the provided error code is decorator error.
|
|
37 |
// -----------------------------------------------------------------------------
|
|
38 |
//
|
|
39 |
#define LEAVE_IF_DECORATOR_ERROR( aErr ) \
|
|
40 |
{ \
|
|
41 |
if( aErr == KErrNoMemory ) \
|
|
42 |
{ \
|
|
43 |
User::Leave( KErrNoMemory ); \
|
|
44 |
} \
|
|
45 |
}
|
|
46 |
|
|
47 |
|
|
48 |
|
|
49 |
// -----------------------------------------------------------------------------
|
|
50 |
// ASSERTION HELPER
|
|
51 |
// Returns from current function if the provided error code is decorator error.
|
|
52 |
// -----------------------------------------------------------------------------
|
|
53 |
//
|
|
54 |
#define RETURN_IF_DECORATOR_ERROR( aErr ) \
|
|
55 |
{ \
|
|
56 |
if( aErr == KErrNoMemory ) \
|
|
57 |
{ \
|
|
58 |
return KErrNoMemory; \
|
|
59 |
} \
|
|
60 |
}
|
|
61 |
|
|
62 |
|
|
63 |
|
|
64 |
// -----------------------------------------------------------------------------
|
|
65 |
// MEMORY LEAK TRACKING HELPER
|
|
66 |
// Performs __UHEAP_MARK and shows visual notify.
|
|
67 |
// (Visual notify gives time to reset HookLogger heap checks.)
|
|
68 |
// -----------------------------------------------------------------------------
|
|
69 |
//
|
|
70 |
#define __UHEAP_MARK_WITH_VISUAL_NOTIFY \
|
|
71 |
{ \
|
|
72 |
__UHEAP_MARK; \
|
|
73 |
EUnitTools::NotifyFromTestEnterL(); \
|
|
74 |
}
|
|
75 |
|
|
76 |
|
|
77 |
// -----------------------------------------------------------------------------
|
|
78 |
// MEMORY LEAK TRACKING HELPER
|
|
79 |
// Performs __UHEAP_MARKEND with JIT debugger on.
|
|
80 |
// -----------------------------------------------------------------------------
|
|
81 |
//
|
|
82 |
#define __UHEAP_MARKEND_WITH_DEBUGGER \
|
|
83 |
{ \
|
|
84 |
TBool __justInTime = User::JustInTime(); \
|
|
85 |
User::SetJustInTime( ETrue ); \
|
|
86 |
__UHEAP_MARKEND; \
|
|
87 |
User::SetJustInTime( __justInTime ); \
|
|
88 |
}
|
|
89 |
|
|
90 |
|
|
91 |
|
|
92 |
|
|
93 |
|
|
94 |
// -----------------------------------------------------------------------------
|
|
95 |
// TEST CASE DECLARATION
|
|
96 |
// Defines not decorated test case.
|
|
97 |
// -----------------------------------------------------------------------------
|
|
98 |
//
|
|
99 |
#define PRFW_NOT_DECORATED_TEST( aDescription, aClass, aMethods, aCategory, aSetupMethod, aTestMethod, aTeardownMethod )\
|
|
100 |
EUNIT_NOT_DECORATED_TEST( aDescription, aClass, aMethods, aCategory, aSetupMethod, aTestMethod, aTeardownMethod )
|
|
101 |
|
|
102 |
// -----------------------------------------------------------------------------
|
|
103 |
// TEST CASE DECLARATION
|
|
104 |
// Defines decorated test case.
|
|
105 |
// -----------------------------------------------------------------------------
|
|
106 |
//
|
|
107 |
#define PRFW_DECORATED_TEST( aDescription, aClass, aMethods, aCategory, aSetupMethod, aTestMethod, aTeardownMethod )\
|
|
108 |
EUNIT_TEST( aDescription, aClass, aMethods, aCategory, aSetupMethod, aTestMethod, aTeardownMethod )
|
|
109 |
|
|
110 |
#define PRFW_ASSERT_DESC( aCondition, aDescription ) \
|
|
111 |
if ( aCondition ) { } else { \
|
|
112 |
TEUnitAssertionInfo __eunit_assert_info = { \
|
|
113 |
__EUNIT_INTERNAL_ASSERT_BASE( aCondition, aDescription ), \
|
|
114 |
NULL }; \
|
|
115 |
EUnit::AssertionFailedL( __eunit_assert_info ); }
|
|
116 |
|
|
117 |
|
|
118 |
/**
|
|
119 |
* Collection of EUnit Tools
|
|
120 |
*/
|
|
121 |
class EUnitTools
|
|
122 |
{
|
|
123 |
public:
|
|
124 |
static inline void NotifyFromTestEnterL();
|
|
125 |
|
|
126 |
};
|
|
127 |
|
|
128 |
|
|
129 |
|
|
130 |
inline void EUnitTools::NotifyFromTestEnterL()
|
|
131 |
{
|
|
132 |
__UHEAP_MARK;
|
|
133 |
|
|
134 |
TInt decoratorfailCount = -1;
|
|
135 |
CEUnitTestCaseDecorator* decorator = CEUnitTestCaseDecorator::ActiveTestCaseDecorator( KNullDesC ); //Any decorator
|
|
136 |
if( decorator )
|
|
137 |
{
|
|
138 |
decorator->GetParameter( _L("ErrorCount"), //Run loop counter value
|
|
139 |
decoratorfailCount );
|
|
140 |
}
|
|
141 |
|
|
142 |
if( !decorator ||
|
|
143 |
( decoratorfailCount == 1 ) )
|
|
144 |
{
|
|
145 |
EUNIT_DISABLE_ANY_DECORATOR;
|
|
146 |
|
|
147 |
TFileName processImage = RProcess().FileName();
|
|
148 |
TBuf<350> msg;
|
|
149 |
msg.Append( _L("Entering to test case. Test process:") );
|
|
150 |
msg.Append( processImage );
|
|
151 |
|
|
152 |
CGlobalWaitingNote::ShowMsgL( msg, 15000000, 15 ); //15 seconds, 1 second steps
|
|
153 |
|
|
154 |
EUNIT_ENABLE_ANY_DECORATOR;
|
|
155 |
}
|
|
156 |
}
|
|
157 |
|
|
158 |
|
|
159 |
|
|
160 |
#endif // EUNITTOOLS_H
|
|
161 |
|
|
162 |
|
|
163 |
|
|
164 |
// end of file
|
|
165 |
|
|
166 |
|
|
167 |
|
|
168 |
|