author | Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com> |
Tue, 24 Nov 2009 08:56:33 +0200 | |
changeset 33 | 50974a8b132e |
parent 22 | fc9cf246af83 |
permissions | -rw-r--r-- |
19 | 1 |
/* |
2 |
* Copyright (c) 2002 - 2007 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 the License "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: ?Description |
|
15 |
* |
|
16 |
*/ |
|
17 |
||
18 |
||
19 |
||
20 |
||
21 |
#ifndef CONTACTSUT_H |
|
22 |
#define CONTACTSUT_H |
|
23 |
||
24 |
// INCLUDES |
|
25 |
#include <StifLogger.h> |
|
26 |
#include <TestScripterInternal.h> |
|
27 |
#include <StifTestModule.h> |
|
28 |
#include <f32file.h> |
|
29 |
||
30 |
#include <MVPbkContactStoreListObserver.h> |
|
31 |
#include <MVPbkContactObserver.h> |
|
32 |
#include <MVPbkContactFindObserver.h> |
|
33 |
#include <MVPbkSingleContactOperationObserver.h> |
|
34 |
#include <MVPbkBatchOperationObserver.h> |
|
33
50974a8b132e
Revision: 200945
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
35 |
#include <s32mem.h> |
50974a8b132e
Revision: 200945
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
36 |
#include <s32file.h> |
19 | 37 |
|
38 |
#include "contactcallback.h" |
|
39 |
||
40 |
// Logging path |
|
41 |
_LIT( KContactsUTLogPath, "\\logs\\testframework\\ContactsUT\\" ); |
|
42 |
// Log file |
|
43 |
_LIT( KContactsUTLogFile, "ContactsUT.txt" ); |
|
44 |
||
45 |
// CONSTANTS |
|
46 |
||
47 |
||
48 |
||
49 |
// FORWARD DECLARATIONS |
|
50 |
class CContactsUT; |
|
51 |
class CVPbkContactManager; |
|
52 |
class MVPbkContactStoreList; |
|
53 |
class MVPbkStoreContact; |
|
54 |
class MVPbkContactOperationBase; |
|
55 |
class CVPbkContactLinkArray; |
|
56 |
class CVPbkVCardEng; |
|
57 |
class CContactService; |
|
58 |
class CSingleContact; |
|
59 |
// CLASS DECLARATION |
|
60 |
||
61 |
/** |
|
62 |
* CContactsUT test class for STIF Test Framework TestScripter. |
|
63 |
* ?other_description_lines |
|
64 |
* |
|
65 |
* @lib ?library |
|
66 |
* @since ?Series60_version |
|
67 |
*/ |
|
68 |
NONSHARABLE_CLASS(CContactsUT) : public CScriptBase, |
|
69 |
public MContactCallback, |
|
70 |
public MVPbkContactStoreListObserver, |
|
71 |
public MVPbkContactObserver, |
|
72 |
public MVPbkContactFindObserver, |
|
73 |
public MVPbkSingleContactOperationObserver, |
|
74 |
public MVPbkBatchOperationObserver |
|
75 |
||
76 |
{ |
|
77 |
public: |
|
78 |
enum TOperation |
|
79 |
{ |
|
80 |
ENone, |
|
81 |
EContact, |
|
82 |
EGroup, |
|
83 |
EVCard, |
|
84 |
EVCardEx, |
|
85 |
EGetContact, |
|
86 |
EGetGroup, |
|
87 |
EGetDatabase, |
|
88 |
EGetContactDelete |
|
89 |
}; |
|
90 |
public: // Constructors and destructor |
|
91 |
||
92 |
/** |
|
93 |
* Two-phased constructor. |
|
94 |
*/ |
|
95 |
static CContactsUT* NewL( CTestModuleIf& aTestModuleIf ); |
|
96 |
||
97 |
/** |
|
98 |
* Destructor. |
|
99 |
*/ |
|
100 |
virtual ~CContactsUT(); |
|
101 |
||
102 |
public: // New functions |
|
103 |
||
104 |
/** |
|
105 |
* ?member_description. |
|
106 |
* @since ?Series60_version |
|
107 |
* @param ?arg1 ?description |
|
108 |
* @return ?description |
|
109 |
*/ |
|
110 |
//?type ?member_function( ?type ?arg1 ); |
|
111 |
||
112 |
public: // Functions from base classes |
|
113 |
||
114 |
/** |
|
115 |
* From CScriptBase Runs a script line. |
|
116 |
* @since ?Series60_version |
|
117 |
* @param aItem Script line containing method name and parameters |
|
118 |
* @return Symbian OS error code |
|
119 |
*/ |
|
120 |
virtual TInt RunMethodL( CStifItemParser& aItem ); |
|
121 |
||
122 |
/** |
|
123 |
* From CScriptBase Runs a script line. |
|
124 |
* @since ?Series60_version |
|
125 |
* @param aItem Script line containing method name and parameters |
|
126 |
* @return Symbian OS error code |
|
127 |
*/ |
|
128 |
virtual void HandleReturnValue( TOperationEvent aEvent, const TInt& aError, TInt aTransId ); |
|
129 |
||
130 |
/* |
|
131 |
*Called after GetList async call is complete |
|
132 |
*/ |
|
133 |
virtual void HandleReturnIter( const TInt& aError, CContactIter* aIter, TInt aTransId ); |
|
134 |
||
22
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
135 |
virtual void HandleReturnId( const TInt& aError, HBufC8* acntId, TInt aTransId ); |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
136 |
|
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
137 |
virtual void HandleReturnArray(const TInt& aError, RPointerArray<HBufC8>& aArray, TInt aTransId ); |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
19
diff
changeset
|
138 |
|
19 | 139 |
/* |
140 |
* Called when creating a new contact or retrieving a contact is successful |
|
141 |
*/ |
|
142 |
virtual void HandleRetrieveContact( MVPbkStoreContact* aStoreContact, TInt aTransId ); |
|
143 |
||
144 |
/** |
|
145 |
* Called when the opening process is complete. |
|
146 |
* |
|
147 |
* Before this all stores have sent StoreReady or StoreUnavailable |
|
148 |
* event. The client can not trust that all stores are available |
|
149 |
* for use when this is called. |
|
150 |
*/ |
|
151 |
virtual void OpenComplete(); |
|
152 |
||
153 |
/** |
|
154 |
* Called when a contact store is ready to use. |
|
155 |
* |
|
156 |
* @param aContactStore The store that is ready. |
|
157 |
*/ |
|
158 |
virtual void StoreReady(MVPbkContactStore& aContactStore); |
|
159 |
||
160 |
/** |
|
161 |
* Called when a contact store becomes unavailable. |
|
162 |
* |
|
163 |
* Client may inspect the reason of the unavailability and decide |
|
164 |
* whether or not it will keep the store opened (ie. listen to |
|
165 |
* the store events). |
|
166 |
* |
|
167 |
* @param aContactStore The store that became unavailable. |
|
168 |
* @param aReason The reason why the store is unavailable. |
|
169 |
* This is one of the system wide error codes. |
|
170 |
*/ |
|
171 |
virtual void StoreUnavailable(MVPbkContactStore& aContactStore, |
|
172 |
TInt aReason); |
|
173 |
||
174 |
/** |
|
175 |
* Called when changes occur in the contact store. |
|
176 |
* |
|
177 |
* @see TVPbkContactStoreEvent |
|
178 |
* @param aContactStore A store whose event it is. |
|
179 |
* @param aStoreEvent The event that has occurred. |
|
180 |
*/ |
|
181 |
virtual void HandleStoreEventL( |
|
182 |
MVPbkContactStore& aContactStore, |
|
183 |
TVPbkContactStoreEvent aStoreEvent); |
|
184 |
||
185 |
/** |
|
186 |
* Called when a contact operation has succesfully completed. |
|
187 |
* |
|
188 |
* NOTE: If you use Cleanupstack for MVPbkStoreContact use |
|
189 |
* MVPbkStoreContact::PushL or CleanupDeletePushL from e32base.h. |
|
190 |
* (Do Not Use CleanupStack::PushL(TAny*) because then the virtual |
|
191 |
* destructor of the M-class won't be called when the object |
|
192 |
* is deleted). |
|
193 |
* |
|
194 |
* @param aResult The result of the operation. The client takes |
|
195 |
* the ownership of the iStoreContact immediately |
|
196 |
* if set in aResult. |
|
197 |
*/ |
|
198 |
virtual void ContactOperationCompleted(TContactOpResult aResult); |
|
199 |
||
200 |
/** |
|
201 |
* Called when a contact operation has failed. |
|
202 |
* |
|
203 |
* @param aOpCode The operation that failed. |
|
204 |
* @param aErrorCode System error code of the failure. |
|
205 |
* KErrAccessDenied when EContactCommit |
|
206 |
* means that contact hasn't been locked. |
|
207 |
* @param aErrorNotified ETrue if the implementation has already |
|
208 |
* notified user about the error, |
|
209 |
* EFalse otherwise. |
|
210 |
*/ |
|
211 |
virtual void ContactOperationFailed |
|
212 |
(TContactOp aOpCode, TInt aErrorCode, TBool aErrorNotified); |
|
213 |
||
214 |
/** |
|
215 |
* Called when find is complete. Caller takes ownership of the results |
|
216 |
* In case of an error during find, the aResults may contain only |
|
217 |
* partial results of the find |
|
218 |
* |
|
219 |
* @param aResults Array of contact links that matched the find |
|
220 |
* Callee must take ownership of this object in |
|
221 |
* the start of the function, ie. in case the |
|
222 |
* function leaves the results must be destroyed. |
|
223 |
* The find operation can be destroyed at the end |
|
224 |
* of this callback. |
|
225 |
*/ |
|
226 |
virtual void FindCompleteL( MVPbkContactLinkArray* aResults ); |
|
227 |
||
228 |
/** |
|
229 |
* Called in case the find fails for some reason. The find operation |
|
230 |
* can be destroyed at the end of this callback. |
|
231 |
* |
|
232 |
* @param aError One of the system wide error codes. |
|
233 |
* KErrNotReady if store is not ready (not open or unavailable) |
|
234 |
*/ |
|
235 |
virtual void FindFailed( TInt aError ); |
|
236 |
||
237 |
/** |
|
238 |
* Called when the operation is completed. |
|
239 |
* |
|
240 |
* A client has the operation as a member and it can delete the operation |
|
241 |
* instance in this function call. If the implementation of the store |
|
242 |
* calls the function from the operation instance it must not handle |
|
243 |
* any member data after calling it. |
|
244 |
* |
|
245 |
* @param aOperation The completed operation. |
|
246 |
* @param aContact The contact returned by the operation. |
|
247 |
* A client must take the ownership immediately. |
|
248 |
* |
|
249 |
* NOTE: |
|
250 |
* If you use CleanupStack for MVPbkStoreContact |
|
251 |
* Use MVPbkStoreContact::PushL or |
|
252 |
* CleanupDeletePushL from e32base.h. |
|
253 |
* (Do Not Use CleanupStack::PushL(TAny*) because |
|
254 |
* then the virtual destructor of the M-class |
|
255 |
* won't be called when the object is deleted). |
|
256 |
*/ |
|
257 |
virtual void VPbkSingleContactOperationComplete( |
|
258 |
MVPbkContactOperationBase& aOperation, |
|
259 |
MVPbkStoreContact* aContact ); |
|
260 |
||
261 |
/** |
|
262 |
* Called if the operation fails. |
|
263 |
* |
|
264 |
* A client has the operation as a member and it can delete the operation |
|
265 |
* instance in this function call. If the implementation of the store |
|
266 |
* calls the function from the operation instance it must not handle |
|
267 |
* any member data after calling it. |
|
268 |
* |
|
269 |
* @param aOperation The failed operation. |
|
270 |
* @param aError An error code of the failure. |
|
271 |
*/ |
|
272 |
virtual void VPbkSingleContactOperationFailed( |
|
273 |
MVPbkContactOperationBase& aOperation, |
|
274 |
TInt aError ); |
|
275 |
||
276 |
/** |
|
277 |
* Called when one step of the operation is completed. |
|
278 |
* |
|
279 |
* @param aOperation Operation whose step has completed |
|
280 |
* @param aStepSize Size of the performed step |
|
281 |
*/ |
|
282 |
virtual void StepComplete( |
|
283 |
MVPbkContactOperationBase& aOperation, |
|
284 |
TInt aStepSize ); |
|
285 |
||
286 |
/** |
|
287 |
* Called when one step of the operation fails. |
|
288 |
* |
|
289 |
* @param aOperation Operation whose step has failed |
|
290 |
* @param aStepSize Size of the performed step |
|
291 |
* @param aError Error that occured |
|
292 |
* @return ETrue if the batch operation should continue, |
|
293 |
* EFalse otherwise |
|
294 |
* NOTE! If returning ETrue the operation can NOT be deleted. |
|
295 |
* Operation should be deleted in OperationCompleted() |
|
296 |
* function. |
|
297 |
* If returning EFalse the operation can be deleted |
|
298 |
* safely. |
|
299 |
*/ |
|
300 |
virtual TBool StepFailed( |
|
301 |
MVPbkContactOperationBase& aOperation, |
|
302 |
TInt aStepSize, TInt aError ); |
|
303 |
||
304 |
/** |
|
305 |
* Called when operation is completed. |
|
306 |
* This is called when all steps are executed. If EFalse is returned |
|
307 |
* in StepFailed() call this function is NOT called. |
|
308 |
* |
|
309 |
* @param aOperation the completed operation |
|
310 |
*/ |
|
311 |
virtual void OperationComplete( |
|
312 |
MVPbkContactOperationBase& aOperation ); |
|
313 |
||
314 |
||
315 |
protected: // New functions |
|
316 |
||
317 |
/** |
|
318 |
* ?member_description. |
|
319 |
* @since ?Series60_version |
|
320 |
* @param ?arg1 ?description |
|
321 |
* @return ?description |
|
322 |
*/ |
|
323 |
//?type ?member_function( ?type ?arg1 ); |
|
324 |
||
325 |
protected: // Functions from base classes |
|
326 |
||
327 |
/** |
|
328 |
* From ?base_class ?member_description |
|
329 |
*/ |
|
330 |
//?type ?member_function(); |
|
331 |
||
332 |
private: |
|
333 |
||
334 |
/** |
|
335 |
* C++ default constructor. |
|
336 |
*/ |
|
337 |
CContactsUT( CTestModuleIf& aTestModuleIf ); |
|
338 |
||
339 |
/** |
|
340 |
* By default Symbian 2nd phase constructor is private. |
|
341 |
*/ |
|
342 |
void ConstructL(); |
|
343 |
||
344 |
// Prohibit copy constructor if not deriving from CBase. |
|
345 |
// ?classname( const ?classname& ); |
|
346 |
// Prohibit assigment operator if not deriving from CBase. |
|
347 |
// ?classname& operator=( const ?classname& ); |
|
348 |
||
349 |
/** |
|
350 |
* Frees all resources allocated from test methods. |
|
351 |
* @since ?Series60_version |
|
352 |
*/ |
|
353 |
void Delete(); |
|
354 |
||
355 |
/** |
|
356 |
* Test methods are listed below. |
|
357 |
*/ |
|
358 |
void DeleteAllL(); |
|
359 |
void AddOneContactL(TDesC& aName); |
|
360 |
void CheckContactsL(TInt& aCount,RPointerArray<TDesC8>& aIdArray); |
|
361 |
||
362 |
||
363 |
/** |
|
364 |
* Example test method. |
|
365 |
* @since ?Series60_version |
|
366 |
* @param aItem Script line containing parameters. |
|
367 |
* @return Symbian OS error code. |
|
368 |
*/ |
|
369 |
//ADD NEW METHOD DEC HERE |
|
370 |
virtual TInt AddContactSAPIL( CStifItemParser& aItem ); |
|
371 |
virtual TInt DeleteContactSAPIL( CStifItemParser& aItem ); |
|
372 |
virtual TInt ModifyContactSAPIL( CStifItemParser& aItem ); |
|
373 |
virtual TInt ImportContactSAPIL( CStifItemParser& aItem ); |
|
374 |
virtual TInt ExportContactSAPIL( CStifItemParser& aItem ); |
|
375 |
||
376 |
virtual TInt GetListDeleteContactL( CStifItemParser& aItem ); |
|
377 |
virtual TInt AddContactGetListL( CStifItemParser& aItem ); |
|
378 |
virtual TInt GetGroupsL( CStifItemParser& aItem ); |
|
379 |
virtual TInt GetContactsL( CStifItemParser& aItem ); |
|
380 |
virtual TInt GetDatabaseL( CStifItemParser& aItem ); |
|
381 |
virtual TInt AddL( CStifItemParser& aItem ); |
|
382 |
virtual TInt AddGroupL( CStifItemParser& aItem ); |
|
383 |
virtual TInt DeleteContactL( CStifItemParser& aItem ); |
|
384 |
virtual TInt DeleteGroupL( CStifItemParser& aItem ); |
|
385 |
virtual TInt ModifyL( CStifItemParser& aItem ); |
|
386 |
virtual TInt ModifyGroupL( CStifItemParser& aItem ); |
|
387 |
virtual TInt OrganiseAddL( CStifItemParser& aItem ); |
|
388 |
virtual TInt OrganiseDeleteL( CStifItemParser& aItem ); |
|
389 |
virtual TInt ImportL( CStifItemParser& aItem ); |
|
390 |
virtual TInt ExportL( CStifItemParser& aItem ); |
|
391 |
||
392 |
private: // Data |
|
393 |
TInt iErr; |
|
394 |
CVPbkContactManager* iContactManager; |
|
395 |
RFs iRfs; |
|
396 |
MVPbkContactStoreList* iStores; |
|
397 |
MVPbkContactStore* iStore; |
|
398 |
MVPbkStoreContact* iStoreContact; |
|
399 |
MVPbkContactGroup* iGroup; |
|
400 |
MVPbkContactLinkArray* iFindResults; |
|
401 |
MVPbkContactLink* iResult; |
|
402 |
MVPbkContactOperationBase* iOp; |
|
403 |
CVPbkContactLinkArray* iContactToDelete; |
|
404 |
CVPbkVCardEng* iVCardEngine; |
|
405 |
RDesWriteStream iDestStream; |
|
406 |
RFileReadStream iSource; |
|
407 |
HBufC8* iBuffer; |
|
408 |
TInt iOperation; |
|
409 |
CContactService* iServiceHandle; |
|
410 |
CSingleContact* iSingleContact; |
|
411 |
||
412 |
}; |
|
413 |
||
414 |
#endif // CONTACTSUT_H |
|
415 |
||
416 |
// End of File |