|
1 /* |
|
2 * Copyright (c) 2002 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: This module contains the implementation of CIMApiTest class |
|
15 member functions that does the actual tests. |
|
16 * |
|
17 * |
|
18 */ |
|
19 |
|
20 |
|
21 |
|
22 // INCLUDE FILES |
|
23 #include <e32math.h> |
|
24 #include "IMApiTest.h" |
|
25 |
|
26 // EXTERNAL DATA STRUCTURES |
|
27 // None |
|
28 |
|
29 // EXTERNAL FUNCTION PROTOTYPES |
|
30 // None |
|
31 |
|
32 // CONSTANTS |
|
33 // None |
|
34 |
|
35 // MACROS |
|
36 // None |
|
37 |
|
38 // LOCAL CONSTANTS AND MACROS |
|
39 // None |
|
40 |
|
41 // MODULE DATA STRUCTURES |
|
42 // None |
|
43 |
|
44 // LOCAL FUNCTION PROTOTYPES |
|
45 // None |
|
46 |
|
47 // FORWARD DECLARATIONS |
|
48 // None |
|
49 |
|
50 // ==================== LOCAL FUNCTIONS ======================================= |
|
51 |
|
52 /* |
|
53 ------------------------------------------------------------------------------- |
|
54 |
|
55 DESCRIPTION |
|
56 |
|
57 This module contains the implementation of CIMApiTest class |
|
58 member functions that does the actual tests. |
|
59 |
|
60 ------------------------------------------------------------------------------- |
|
61 */ |
|
62 |
|
63 // ============================ MEMBER FUNCTIONS =============================== |
|
64 |
|
65 /* |
|
66 ------------------------------------------------------------------------------- |
|
67 |
|
68 Class: CIMApiTest |
|
69 |
|
70 Method: Case |
|
71 |
|
72 Description: Returns a test case by number. |
|
73 |
|
74 This function contains an array of all available test cases |
|
75 i.e pair of case name and test function. If case specified by parameter |
|
76 aCaseNumber is found from array, then that item is returned. |
|
77 |
|
78 The reason for this rather complicated function is to specify all the |
|
79 test cases only in one place. It is not necessary to understand how |
|
80 function pointers to class member functions works when adding new test |
|
81 cases. See function body for instructions how to add new test case. |
|
82 |
|
83 Parameters: const TInt aCaseNumber :in: Test case number |
|
84 |
|
85 Return Values: const TCaseInfo Struct containing case name & function |
|
86 |
|
87 Errors/Exceptions: None |
|
88 |
|
89 Status: Proposal |
|
90 |
|
91 ------------------------------------------------------------------------------- |
|
92 */ |
|
93 const TCaseInfo CIMApiTest::Case ( |
|
94 const TInt aCaseNumber ) const |
|
95 { |
|
96 |
|
97 /* |
|
98 * To add new test cases, implement new test case function and add new |
|
99 * line to KCases array specify the name of the case and the function |
|
100 * doing the test case |
|
101 * In practice, do following |
|
102 * |
|
103 * 1) Make copy of existing test case function and change its name |
|
104 * and functionality. Note that the function must be added to |
|
105 * OOMHard.cpp file and to OOMHard.h |
|
106 * header file. |
|
107 * |
|
108 * 2) Add entry to following KCases array either by using: |
|
109 * |
|
110 * 2.1: FUNCENTRY or ENTRY macro |
|
111 * ENTRY macro takes two parameters: test case name and test case |
|
112 * function name. |
|
113 * |
|
114 * FUNCENTRY macro takes only test case function name as a parameter and |
|
115 * uses that as a test case name and test case function name. |
|
116 * |
|
117 * Or |
|
118 * |
|
119 * 2.2: OOM_FUNCENTRY or OOM_ENTRY macro. Note that these macros are used |
|
120 * only with OOM (Out-Of-Memory) testing! |
|
121 * |
|
122 * OOM_ENTRY macro takes five parameters: test case name, test case |
|
123 * function name, TBool which specifies is method supposed to be run using |
|
124 * OOM conditions, TInt value for first heap memory allocation failure and |
|
125 * TInt value for last heap memory allocation failure. |
|
126 * |
|
127 * OOM_FUNCENTRY macro takes test case function name as a parameter and uses |
|
128 * that as a test case name, TBool which specifies is method supposed to be |
|
129 * run using OOM conditions, TInt value for first heap memory allocation |
|
130 * failure and TInt value for last heap memory allocation failure. |
|
131 */ |
|
132 |
|
133 static TCaseInfoInternal const KCases[] = |
|
134 { |
|
135 // To add new test cases, add new items to this array |
|
136 |
|
137 // NOTE: When compiled to GCCE, there must be Classname:: |
|
138 // declaration in front of the method name, e.g. |
|
139 // CIMApiTest::PrintTest. Otherwise the compiler |
|
140 // gives errors. |
|
141 |
|
142 ENTRY( "Invalid Login", CIMApiTest::InvalidLoginL ), |
|
143 ENTRY( "Login", CIMApiTest::LoginL ), |
|
144 ENTRY( "Send P To P ValidUserID", CIMApiTest::SendPToPValidUserIDL ), |
|
145 ENTRY( "Send P To P ValidTvoUserID", CIMApiTest::SendPToPValidTwoUserIDL ), |
|
146 ENTRY( "Send P To P ValidContact", CIMApiTest::SendPToPValidContactL ), |
|
147 ENTRY( "Send P To P ValidTwoContact", CIMApiTest::SendPToPValidTwoContactL ), |
|
148 ENTRY( "Send P To P ContactContentType", CIMApiTest::SendPToPContactContentTypeL ), |
|
149 ENTRY( "Send P To P UserIDContentType", CIMApiTest::SendPToPUserIDContentTypeL ), |
|
150 ENTRY( "Logout", CIMApiTest::LogoutL ), |
|
151 ENTRY( "Cancel Login", CIMApiTest::CancelLoginL ), |
|
152 }; |
|
153 |
|
154 // Verify that case number is valid |
|
155 if ( ( TUint ) aCaseNumber >= sizeof( KCases ) / |
|
156 sizeof( TCaseInfoInternal ) ) |
|
157 { |
|
158 |
|
159 // Invalid case, construct empty object |
|
160 TCaseInfo null( ( const TText* ) L"" ); |
|
161 null.iMethod = NULL; |
|
162 null.iIsOOMTest = EFalse; |
|
163 null.iFirstMemoryAllocation = 0; |
|
164 null.iLastMemoryAllocation = 0; |
|
165 return null; |
|
166 |
|
167 } |
|
168 |
|
169 // Construct TCaseInfo object and return it |
|
170 TCaseInfo tmp ( KCases[ aCaseNumber ].iCaseName ); |
|
171 tmp.iMethod = KCases[ aCaseNumber ].iMethod; |
|
172 tmp.iIsOOMTest = KCases[ aCaseNumber ].iIsOOMTest; |
|
173 tmp.iFirstMemoryAllocation = KCases[ aCaseNumber ].iFirstMemoryAllocation; |
|
174 tmp.iLastMemoryAllocation = KCases[ aCaseNumber ].iLastMemoryAllocation; |
|
175 return tmp; |
|
176 |
|
177 } |
|
178 |
|
179 TInt CIMApiTest::InvalidLoginL( TTestResult& aResult ) |
|
180 { |
|
181 iRunner->StartRunL( InvalidLogin ); |
|
182 // Sets test case result and description(Maximum size is KStifMaxResultDes) |
|
183 _LIT( KDescription, "LoginL Passed" ); |
|
184 aResult.SetResult( KErrNone, KDescription ); |
|
185 // Case was executed |
|
186 return KErrNone; |
|
187 |
|
188 } |
|
189 |
|
190 TInt CIMApiTest::LoginL( TTestResult& aResult ) |
|
191 { |
|
192 iRunner->StartRunL( Login ); |
|
193 // Sets test case result and description(Maximum size is KStifMaxResultDes) |
|
194 _LIT( KDescription, "LoginL Passed" ); |
|
195 aResult.SetResult( KErrNone, KDescription ); |
|
196 // Case was executed |
|
197 return KErrNone; |
|
198 } |
|
199 |
|
200 |
|
201 TInt CIMApiTest::SendPToPValidUserIDL( TTestResult& aResult ) |
|
202 { |
|
203 iRunner->StartRunL( SendMessageValidUserId ); |
|
204 // Sets test case result and description(Maximum size is KStifMaxResultDes) |
|
205 _LIT( KDescription, "SendPToPValidUserIDL Passed" ); |
|
206 aResult.SetResult( KErrNone, KDescription ); |
|
207 // Case was executed |
|
208 return KErrNone; |
|
209 } |
|
210 |
|
211 |
|
212 TInt CIMApiTest::SendPToPValidTwoUserIDL( TTestResult& aResult ) |
|
213 { |
|
214 iRunner->StartRunL( SendMessageValidTwoUserId ); |
|
215 // Sets test case result and description(Maximum size is KStifMaxResultDes) |
|
216 _LIT( KDescription, "SendPToPValidTwoUserIDL Passed" ); |
|
217 aResult.SetResult( KErrNone, KDescription ); |
|
218 // Case was executed |
|
219 return KErrNone; |
|
220 } |
|
221 |
|
222 |
|
223 TInt CIMApiTest::SendPToPValidContactL( TTestResult& aResult ) |
|
224 { |
|
225 iRunner->StartRunL( SendMessageValidContact ); |
|
226 // Sets test case result and description(Maximum size is KStifMaxResultDes) |
|
227 _LIT( KDescription, "SendPToPValidContactL Passed" ); |
|
228 aResult.SetResult( KErrNone, KDescription ); |
|
229 // Case was executed |
|
230 return KErrNone; |
|
231 } |
|
232 |
|
233 |
|
234 TInt CIMApiTest::SendPToPValidTwoContactL( TTestResult& aResult ) |
|
235 { |
|
236 iRunner->StartRunL( SendMessageValidTwoContact ); |
|
237 // Sets test case result and description(Maximum size is KStifMaxResultDes) |
|
238 _LIT( KDescription, "SendPToPValidTwoContactL Passed" ); |
|
239 aResult.SetResult( KErrNone, KDescription ); |
|
240 // Case was executed |
|
241 return KErrNone; |
|
242 } |
|
243 |
|
244 TInt CIMApiTest::SendPToPContactContentTypeL( TTestResult& aResult ) |
|
245 { |
|
246 iRunner->StartRunL( SendPToPContactContentType ); |
|
247 // Sets test case result and description(Maximum size is KStifMaxResultDes) |
|
248 _LIT( KDescription, "SendPToPContactContentTypeL Passed" ); |
|
249 aResult.SetResult( KErrNone, KDescription ); |
|
250 // Case was executed |
|
251 return KErrNone; |
|
252 } |
|
253 |
|
254 TInt CIMApiTest::SendPToPUserIDContentTypeL( TTestResult& aResult ) |
|
255 { |
|
256 iRunner->StartRunL( SendPToPUserIDContentType ); |
|
257 // Sets test case result and description(Maximum size is KStifMaxResultDes) |
|
258 _LIT( KDescription, "SendPToPUserIDContentTypeL Passed" ); |
|
259 aResult.SetResult( KErrNone, KDescription ); |
|
260 // Case was executed |
|
261 return KErrNone; |
|
262 } |
|
263 |
|
264 TInt CIMApiTest::LogoutL( TTestResult& aResult ) |
|
265 { |
|
266 iRunner->StartRunL( Logout ); |
|
267 // Sets test case result and description(Maximum size is KStifMaxResultDes) |
|
268 _LIT( KDescription, "LogoutL Passed" ); |
|
269 aResult.SetResult( KErrNone, KDescription ); |
|
270 // Case was executed |
|
271 return KErrNone; |
|
272 } |
|
273 |
|
274 |
|
275 TInt CIMApiTest::CancelLoginL( TTestResult& aResult ) |
|
276 { |
|
277 iRunner->StartRunL( CancelLogin ); |
|
278 // Sets test case result and description(Maximum size is KStifMaxResultDes) |
|
279 _LIT( KDescription, "CancelLoginL Passed" ); |
|
280 aResult.SetResult( KErrNone, KDescription ); |
|
281 // Case was executed |
|
282 return KErrNone; |
|
283 } |
|
284 |
|
285 // End of File |