|
1 /** |
|
2 * Copyright (c) 2008-2009 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: |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 /** |
|
21 @file lcfsbucommondefinitions.h |
|
22 @internalTechnology |
|
23 */ |
|
24 #ifndef _LCF_SBU_COMMON_DEFINITIONS_H_ |
|
25 #define _LCF_SBU_COMMON_DEFINITIONS_H_ |
|
26 |
|
27 |
|
28 /////////////////////////////////////////////////////// |
|
29 // |
|
30 // Constants |
|
31 // |
|
32 /////////////////////////////////////////////////////// |
|
33 |
|
34 |
|
35 #define DUMMY_REQUESTOR_TYPE_ACCEPTED1 (CRequestor::ERequestorService) |
|
36 #define DUMMY_REQUESTOR_FORMAT_ACCEPTED1 (CRequestor::EFormatApplication) |
|
37 #define DUMMY_REQUESTOR_NAME_ACCEPTED1 (_L("TestService")) |
|
38 |
|
39 #define DUMMY_REQUESTOR_TYPE_ACCEPTED2 (CRequestor::ERequestorContact) |
|
40 #define DUMMY_REQUESTOR_FORMAT_ACCEPTED2 (CRequestor::EFormatTelephone) |
|
41 #define DUMMY_REQUESTOR_NAME_ACCEPTED2 (_L("+123121234567")) |
|
42 |
|
43 |
|
44 |
|
45 const TInt KDefaultTestTimeout = 5*1000*1000; //5 seconds should be more than enough. |
|
46 |
|
47 //0.00001; |
|
48 #define KErrorToleranceValue KMinTReal64 |
|
49 |
|
50 _LIT(KNoClientFault, "Kill"); |
|
51 |
|
52 |
|
53 /////////////////////////////////////////////////////// |
|
54 // |
|
55 // Other text |
|
56 // |
|
57 /////////////////////////////////////////////////////// |
|
58 |
|
59 // Indicate not yet implemented |
|
60 _LIT(KNotImplemented, "Not yet implemented"); |
|
61 |
|
62 _LIT(KBadDiagVerifEventNum, "Wrong number of Verification events in Notifier"); |
|
63 _LIT(KBadDiagNotifEventNum, "Wrong number of Notification events in Notifier"); |
|
64 |
|
65 #define CHECK_EQUAL_(_expected, _actual) \ |
|
66 ERROR(_expected != _actual, "Equal check failed") |
|
67 |
|
68 #define CHECK(_condition) ERROR(!(_condition), "Check failed") |
|
69 |
|
70 |
|
71 #define CHECK_REAL_EQUAL_TOL(aExpected, aActual, aTolerance) \ |
|
72 FAIL(Math::IsNaN(aActual) || Math::IsNaN(aExpected), "One or two of compared values is NaN!") \ |
|
73 CHECK(Abs(aActual - aExpected) < aTolerance) |
|
74 |
|
75 #define CHECK_REAL_EQUAL(aExpected, aActual) \ |
|
76 CHECK_REAL_EQUAL_TOL(aExpected, aActual, KErrorToleranceValue) |
|
77 |
|
78 #define CHECK_PANIC(aCondition) \ |
|
79 if (!(aCondition)) CheckPanic(__FILE__, __LINE__); |
|
80 |
|
81 #define DO_PANIC_TEST_L(aThreadFunction, aExpectedExitCat, aExpectedExitReason, aTimeoutValue) \ |
|
82 DO_PANIC_TEST_L_PTR(aThreadFunction, aExpectedExitCat, aExpectedExitReason, aTimeoutValue, NULL) |
|
83 |
|
84 #define DO_PANIC_TEST_L_PTR(aThreadFunction, aExpectedExitCat, aExpectedExitReason, \ |
|
85 aTimeoutValue, aAnyPtr) \ |
|
86 { \ |
|
87 TExitCategoryName exitName = TPtrC(aExpectedExitCat).Left(KMaxExitCategoryName); \ |
|
88 DoPanicTestL(aThreadFunction, exitName, aExpectedExitReason, aTimeoutValue, aAnyPtr); \ |
|
89 } |
|
90 |
|
91 /////////////////////////////////////////////////////// |
|
92 // |
|
93 // Here are macros for error logging |
|
94 // Those imply that are called from within of |
|
95 // TEF class's function (they use (INFO/ERR)PRINTF member) |
|
96 // |
|
97 /////////////////////////////////////////////////////// |
|
98 |
|
99 // LEAVES with _error_ if _condition_ is true |
|
100 #define FAIL(condition, error) \ |
|
101 if (condition) { \ |
|
102 errStr.Format(_L("%s (line %d)"), _S(error), __LINE__); \ |
|
103 ERR_PRINTF1(errStr); \ |
|
104 SetTestStepResult(EFail); \ |
|
105 } |
|
106 |
|
107 |
|
108 // Must be included in the begining of function definitions |
|
109 // in order to use following ("ERROR") macros |
|
110 // (The string buffer needs to be defined once, otherwise, |
|
111 // in case when a lot of errors are checked, stack may be |
|
112 // overflown, and copilation will fail) |
|
113 #define DECLARE_ERROR_STR TBuf<160> errStr; |
|
114 #define DECLARE_MESSAGE_STR TBuf<160> message; |
|
115 |
|
116 #define DECLARE_ERROR_LOGGING DECLARE_ERROR_STR DECLARE_MESSAGE_STR |
|
117 |
|
118 #define START_ERROR_LOGGING iErrorCounter = 0; |
|
119 |
|
120 // Logs a message, which is defined as "..." constant |
|
121 #define LOG(msg) \ |
|
122 { \ |
|
123 errStr.Format(_L("%s (line %d)"), _S(msg), __LINE__); \ |
|
124 INFO_PRINTF1(errStr); \ |
|
125 } |
|
126 #define LOG_DES(msg_des) \ |
|
127 { \ |
|
128 errStr.Format(_L("%S (line %d)"), &msg_des, __LINE__); \ |
|
129 INFO_PRINTF1(errStr); \ |
|
130 } |
|
131 |
|
132 #define LOG_IIF(condition, msg1, msg2) \ |
|
133 if (condition) LOG(msg1) else LOG(msg2) |
|
134 |
|
135 // Logs an error, which is defined as "..." constant |
|
136 #define ERR(error) \ |
|
137 { \ |
|
138 errStr.Format(_L("%s (line %d)"), _S(error), __LINE__); \ |
|
139 ERR_PRINTF1(errStr); \ |
|
140 SetTestStepResult(EFail); \ |
|
141 } |
|
142 #define ERR_DES(error) \ |
|
143 { \ |
|
144 errStr.Format(_L("%S (line %d)"), &error, __LINE__); \ |
|
145 ERR_PRINTF1(errStr); \ |
|
146 SetTestStepResult(EFail); \ |
|
147 } |
|
148 |
|
149 // Logs an _error_ if _condition_ is true |
|
150 #define ERROR(condition, error) \ |
|
151 if (condition) ERR(error) |
|
152 |
|
153 // Logs an error, which defined as descriptor |
|
154 #define ERROR_DES(condition, error_des) \ |
|
155 if (condition) ERR_DES(error_des) |
|
156 |
|
157 #define ERROR_1(condition, msg_fmt_des, param1) \ |
|
158 message.Format(msg_fmt_des, param1); \ |
|
159 ERROR_DES(condition, message); |
|
160 |
|
161 #define ERROR_2(condition, msg_fmt_des, param1, param2) \ |
|
162 message.Format(msg_fmt_des, param1, param2); \ |
|
163 ERROR_DES(condition, message); |
|
164 |
|
165 #define ERROR_3(condition, msg_fmt_des, param1, param2, param3) \ |
|
166 message.Format(msg_fmt_des, param1, param2, param3); \ |
|
167 ERROR_DES(condition, message); |
|
168 |
|
169 #define IF_ERROR(error_code, msg) \ |
|
170 { TInt32 _err = error_code; \ |
|
171 ERROR_2(_err != KErrNone, _L("%s (error=%d)"), _S(msg), _err); } |
|
172 |
|
173 #define IF_ERROR_DES(error_code, msg_des) \ |
|
174 { TInt32 _err = error_code; \ |
|
175 ERROR_2(_err != KErrNone, _L("%S (error=%d)"), &msg_des, _err); } |
|
176 |
|
177 #define CHECK_EQUAL(_actual, _expected, _msg) \ |
|
178 ERROR_3(_actual != _expected, _L("%s (actual=%d, expected=%d)"), _S(_msg), _actual, _expected); |
|
179 |
|
180 #define CHECK_EQUAL_DES(_actual, _expected, _msg_des) \ |
|
181 ERROR_3(_actual != _expected, _L("%S (actual=%d, expected=%d)"), &_msg_des, _actual, _expected); |
|
182 |
|
183 |
|
184 #endif // _LCF_SBU_COMMON_DEFINITIONS_H_ |