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