19
|
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 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 TCOMPLUGIN_H
|
|
22 |
#define TCOMPLUGIN_H
|
|
23 |
|
|
24 |
// INCLUDES
|
|
25 |
#include <StifLogger.h>
|
|
26 |
#include <TestScripterInternal.h>
|
|
27 |
#include <StifTestModule.h>
|
|
28 |
|
|
29 |
#include "serviceerrno.h"
|
|
30 |
|
|
31 |
#include <LiwCommon.h>
|
|
32 |
#include <LiwBufferExtension.h>
|
|
33 |
#include <LiwServiceHandler.h>
|
|
34 |
|
|
35 |
#include <MVPbkContactStoreListObserver.h>
|
|
36 |
#include <MVPbkContactObserver.h>
|
|
37 |
#include <MVPbkContactFindObserver.h>
|
|
38 |
#include <MVPbkSingleContactOperationObserver.h>
|
|
39 |
#include <MVPbkBatchOperationObserver.h>
|
|
40 |
#include <MVPbkStoreContact.h>
|
|
41 |
|
|
42 |
class CVPbkContactManager;
|
|
43 |
class MVPbkContactStoreList;
|
|
44 |
class MVPbkStoreContact;
|
|
45 |
class MVPbkContactOperationBase;
|
|
46 |
|
|
47 |
class CVPbkContactLinkArray;
|
|
48 |
_LIT( KContactsUTLogPath, "\\logs\\testframework\\ContactsUT\\" );
|
|
49 |
// Log file
|
|
50 |
_LIT( KContactsUTLogFile, "ContactsUT.txt" );
|
|
51 |
|
|
52 |
/**
|
|
53 |
* CTestProvider test class for STIF Test Framework TestScripter.
|
|
54 |
* ?other_description_lines
|
|
55 |
*
|
|
56 |
* @lib ?library
|
|
57 |
* @since ?Series60_version
|
|
58 |
*/
|
|
59 |
NONSHARABLE_CLASS(CTestProvider) :public CScriptBase,public MLiwNotifyCallback,
|
|
60 |
public MVPbkContactStoreListObserver,
|
|
61 |
public MVPbkContactObserver,
|
|
62 |
public MVPbkContactFindObserver,
|
|
63 |
public MVPbkSingleContactOperationObserver,
|
|
64 |
public MVPbkBatchOperationObserver
|
|
65 |
{
|
|
66 |
enum TTestCase
|
|
67 |
{
|
|
68 |
EGetAllContacts = 0,
|
|
69 |
EGetContactSearch,
|
|
70 |
EGetGroup,
|
|
71 |
EGetDatabase,
|
|
72 |
EAddContact,
|
|
73 |
EDeleteContact,
|
|
74 |
EDeleteVerify,
|
|
75 |
EAddGroup,
|
|
76 |
EOrganizeAddcntid,
|
|
77 |
EOrganizeAdd,
|
|
78 |
EOrganizeDelete,
|
|
79 |
EImportVcard,
|
|
80 |
EExportVcard,
|
|
81 |
EVerifyGroupAdd,
|
|
82 |
EVerifyImport,
|
|
83 |
EVerifyOrganizeDelete,
|
|
84 |
EModifyContact,
|
|
85 |
EModifyContactComplete,
|
|
86 |
EModifyContactVerify
|
|
87 |
};
|
|
88 |
public: // Constructors and destructor
|
|
89 |
|
|
90 |
/**
|
|
91 |
* Two-phased constructor.
|
|
92 |
*/
|
|
93 |
static CTestProvider* NewL( CTestModuleIf& aTestModuleIf );
|
|
94 |
|
|
95 |
/**
|
|
96 |
* Destructor.
|
|
97 |
*/
|
|
98 |
virtual ~CTestProvider();
|
|
99 |
|
|
100 |
public: // New functions
|
|
101 |
|
|
102 |
/**
|
|
103 |
* ?member_description.
|
|
104 |
* @since ?Series60_version
|
|
105 |
* @param ?arg1 ?description
|
|
106 |
* @return ?description
|
|
107 |
*/
|
|
108 |
//?type ?member_function( ?type ?arg1 );
|
|
109 |
|
|
110 |
public: // Functions from base classes
|
|
111 |
|
|
112 |
/**
|
|
113 |
* From CScriptBase Runs a script line.
|
|
114 |
* @since ?Series60_version
|
|
115 |
* @param aItem Script line containing method name and parameters
|
|
116 |
* @return Symbian OS error code
|
|
117 |
*/
|
|
118 |
virtual TInt RunMethodL( CStifItemParser& aItem );
|
|
119 |
void LoadService();
|
|
120 |
|
|
121 |
protected: // New functions
|
|
122 |
|
|
123 |
/**
|
|
124 |
* ?member_description.
|
|
125 |
* @since ?Series60_version
|
|
126 |
* @param ?arg1 ?description
|
|
127 |
* @return ?description
|
|
128 |
*/
|
|
129 |
//?type ?member_function( ?type ?arg1 );
|
|
130 |
|
|
131 |
protected: // Functions from base classes
|
|
132 |
|
|
133 |
/**
|
|
134 |
* From ?base_class ?member_description
|
|
135 |
*/
|
|
136 |
//?type ?member_function();
|
|
137 |
|
|
138 |
private:
|
|
139 |
TInt HandleNotifyL( TInt aCmdId,
|
|
140 |
TInt aEventId,
|
|
141 |
CLiwGenericParamList& aEventParamList,
|
|
142 |
const CLiwGenericParamList& aInParamList );
|
|
143 |
/**
|
|
144 |
* C++ default constructor.
|
|
145 |
*/
|
|
146 |
CTestProvider( CTestModuleIf& aTestModuleIf );
|
|
147 |
|
|
148 |
|
|
149 |
/**
|
|
150 |
* By default Symbian 2nd phase constructor is private.
|
|
151 |
*/
|
|
152 |
void ConstructL();
|
|
153 |
|
|
154 |
// Prohibit copy constructor if not deriving from CBase.
|
|
155 |
// ?classname( const ?classname& );
|
|
156 |
// Prohibit assigment operator if not deriving from CBase.
|
|
157 |
// ?classname& operator=( const ?classname& );
|
|
158 |
|
|
159 |
/**
|
|
160 |
* Frees all resources allocated from test methods.
|
|
161 |
* @since ?Series60_version
|
|
162 |
*/
|
|
163 |
void Delete();
|
|
164 |
/**
|
|
165 |
* From CScriptBase Runs a script line.
|
|
166 |
* @since ?Series60_version
|
|
167 |
* @param aItem Script line containing method name and parameters
|
|
168 |
* @return Symbian OS error code
|
|
169 |
*/
|
|
170 |
virtual void HandleError( const TInt& aError,TInt aTransId );
|
|
171 |
|
|
172 |
|
|
173 |
/*
|
|
174 |
* Called when creating a new contact or retrieving a contact is successful
|
|
175 |
*/
|
|
176 |
virtual void HandleRetrieveContact( MVPbkStoreContact* aStoreContact, TInt aTransId );
|
|
177 |
|
|
178 |
//MVPbkContactStoreListObserver
|
|
179 |
/**
|
|
180 |
* Called when the opening process is complete.
|
|
181 |
*
|
|
182 |
* Before this all stores have sent StoreReady or StoreUnavailable
|
|
183 |
* event. The client can not trust that all stores are available
|
|
184 |
* for use when this is called.
|
|
185 |
*/
|
|
186 |
virtual void OpenComplete();
|
|
187 |
|
|
188 |
/**
|
|
189 |
* Called when a contact store is ready to use.
|
|
190 |
*
|
|
191 |
* @param aContactStore The store that is ready.
|
|
192 |
*/
|
|
193 |
virtual void StoreReady(MVPbkContactStore& aContactStore);
|
|
194 |
|
|
195 |
/**
|
|
196 |
* Called when a contact store becomes unavailable.
|
|
197 |
*
|
|
198 |
* Client may inspect the reason of the unavailability and decide
|
|
199 |
* whether or not it will keep the store opened (ie. listen to
|
|
200 |
* the store events).
|
|
201 |
*
|
|
202 |
* @param aContactStore The store that became unavailable.
|
|
203 |
* @param aReason The reason why the store is unavailable.
|
|
204 |
* This is one of the system wide error codes.
|
|
205 |
*/
|
|
206 |
virtual void StoreUnavailable(MVPbkContactStore& aContactStore,
|
|
207 |
TInt aReason);
|
|
208 |
|
|
209 |
/**
|
|
210 |
* Called when changes occur in the contact store.
|
|
211 |
*
|
|
212 |
* @see TVPbkContactStoreEvent
|
|
213 |
* @param aContactStore A store whose event it is.
|
|
214 |
* @param aStoreEvent The event that has occurred.
|
|
215 |
*/
|
|
216 |
virtual void HandleStoreEventL(
|
|
217 |
MVPbkContactStore& aContactStore,
|
|
218 |
TVPbkContactStoreEvent aStoreEvent);
|
|
219 |
|
|
220 |
//MVPbkContactObserver
|
|
221 |
/**
|
|
222 |
* Called when a contact operation has succesfully completed.
|
|
223 |
*
|
|
224 |
* NOTE: If you use Cleanupstack for MVPbkStoreContact use
|
|
225 |
* MVPbkStoreContact::PushL or CleanupDeletePushL from e32base.h.
|
|
226 |
* (Do Not Use CleanupStack::PushL(TAny*) because then the virtual
|
|
227 |
* destructor of the M-class won't be called when the object
|
|
228 |
* is deleted).
|
|
229 |
*
|
|
230 |
* @param aResult The result of the operation. The client takes
|
|
231 |
* the ownership of the iStoreContact immediately
|
|
232 |
* if set in aResult.
|
|
233 |
*/
|
|
234 |
virtual void ContactOperationCompleted(TContactOpResult aResult);
|
|
235 |
|
|
236 |
/**
|
|
237 |
* Called when a contact operation has failed.
|
|
238 |
*
|
|
239 |
* @param aOpCode The operation that failed.
|
|
240 |
* @param aErrorCode System error code of the failure.
|
|
241 |
* KErrAccessDenied when EContactCommit
|
|
242 |
* means that contact hasn't been locked.
|
|
243 |
* @param aErrorNotified ETrue if the implementation has already
|
|
244 |
* notified user about the error,
|
|
245 |
* EFalse otherwise.
|
|
246 |
*/
|
|
247 |
virtual void ContactOperationFailed
|
|
248 |
(TContactOp aOpCode, TInt aErrorCode, TBool aErrorNotified);
|
|
249 |
|
|
250 |
//MVPbkContactFindObserver
|
|
251 |
/**
|
|
252 |
* Called when find is complete. Caller takes ownership of the results
|
|
253 |
* In case of an error during find, the aResults may contain only
|
|
254 |
* partial results of the find
|
|
255 |
*
|
|
256 |
* @param aResults Array of contact links that matched the find
|
|
257 |
* Callee must take ownership of this object in
|
|
258 |
* the start of the function, ie. in case the
|
|
259 |
* function leaves the results must be destroyed.
|
|
260 |
* The find operation can be destroyed at the end
|
|
261 |
* of this callback.
|
|
262 |
*/
|
|
263 |
virtual void FindCompleteL( MVPbkContactLinkArray* aResults );
|
|
264 |
|
|
265 |
/**
|
|
266 |
* Called in case the find fails for some reason. The find operation
|
|
267 |
* can be destroyed at the end of this callback.
|
|
268 |
*
|
|
269 |
* @param aError One of the system wide error codes.
|
|
270 |
* KErrNotReady if store is not ready (not open or unavailable)
|
|
271 |
*/
|
|
272 |
virtual void FindFailed( TInt aError );
|
|
273 |
|
|
274 |
|
|
275 |
//MVPbkSingleContactOperationObserver
|
|
276 |
/**
|
|
277 |
* Called when the operation is completed.
|
|
278 |
*
|
|
279 |
* A client has the operation as a member and it can delete the operation
|
|
280 |
* instance in this function call. If the implementation of the store
|
|
281 |
* calls the function from the operation instance it must not handle
|
|
282 |
* any member data after calling it.
|
|
283 |
*
|
|
284 |
* @param aOperation The completed operation.
|
|
285 |
* @param aContact The contact returned by the operation.
|
|
286 |
* A client must take the ownership immediately.
|
|
287 |
*
|
|
288 |
* NOTE:
|
|
289 |
* If you use CleanupStack for MVPbkStoreContact
|
|
290 |
* Use MVPbkStoreContact::PushL or
|
|
291 |
* CleanupDeletePushL from e32base.h.
|
|
292 |
* (Do Not Use CleanupStack::PushL(TAny*) because
|
|
293 |
* then the virtual destructor of the M-class
|
|
294 |
* won't be called when the object is deleted).
|
|
295 |
*/
|
|
296 |
virtual void VPbkSingleContactOperationComplete(
|
|
297 |
MVPbkContactOperationBase& aOperation,
|
|
298 |
MVPbkStoreContact* aContact );
|
|
299 |
|
|
300 |
/**
|
|
301 |
* Called if the operation fails.
|
|
302 |
*
|
|
303 |
* A client has the operation as a member and it can delete the operation
|
|
304 |
* instance in this function call. If the implementation of the store
|
|
305 |
* calls the function from the operation instance it must not handle
|
|
306 |
* any member data after calling it.
|
|
307 |
*
|
|
308 |
* @param aOperation The failed operation.
|
|
309 |
* @param aError An error code of the failure.
|
|
310 |
*/
|
|
311 |
virtual void VPbkSingleContactOperationFailed(
|
|
312 |
MVPbkContactOperationBase& aOperation,
|
|
313 |
TInt aError );
|
|
314 |
|
|
315 |
//MVPbkBatchOperationObserver
|
|
316 |
/**
|
|
317 |
* Called when one step of the operation is completed.
|
|
318 |
*
|
|
319 |
* @param aOperation Operation whose step has completed
|
|
320 |
* @param aStepSize Size of the performed step
|
|
321 |
*/
|
|
322 |
virtual void StepComplete(
|
|
323 |
MVPbkContactOperationBase& aOperation,
|
|
324 |
TInt aStepSize );
|
|
325 |
|
|
326 |
/**
|
|
327 |
* Called when one step of the operation fails.
|
|
328 |
*
|
|
329 |
* @param aOperation Operation whose step has failed
|
|
330 |
* @param aStepSize Size of the performed step
|
|
331 |
* @param aError Error that occured
|
|
332 |
* @return ETrue if the batch operation should continue,
|
|
333 |
* EFalse otherwise
|
|
334 |
* NOTE! If returning ETrue the operation can NOT be deleted.
|
|
335 |
* Operation should be deleted in OperationCompleted()
|
|
336 |
* function.
|
|
337 |
* If returning EFalse the operation can be deleted
|
|
338 |
* safely.
|
|
339 |
*/
|
|
340 |
virtual TBool StepFailed(
|
|
341 |
MVPbkContactOperationBase& aOperation,
|
|
342 |
TInt aStepSize, TInt aError );
|
|
343 |
|
|
344 |
/**
|
|
345 |
* Called when operation is completed.
|
|
346 |
* This is called when all steps are executed. If EFalse is returned
|
|
347 |
* in StepFailed() call this function is NOT called.
|
|
348 |
*
|
|
349 |
* @param aOperation the completed operation
|
|
350 |
*/
|
|
351 |
virtual void OperationComplete(
|
|
352 |
MVPbkContactOperationBase& aOperation );
|
|
353 |
|
|
354 |
/**
|
|
355 |
* Test methods are listed below.
|
|
356 |
*/
|
|
357 |
/**
|
|
358 |
* Example test method.
|
|
359 |
* @since ?Series60_version
|
|
360 |
* @param aItem Script line containing parameters.
|
|
361 |
* @return Symbian OS error code.
|
|
362 |
*/
|
|
363 |
virtual TInt GetContactALL(CStifItemParser &aItem );
|
|
364 |
virtual TInt GetContactSearch(CStifItemParser &aItem );
|
|
365 |
virtual TInt GetGroup(CStifItemParser& aItem) ;
|
|
366 |
virtual TInt GetDatabase(CStifItemParser& aItem) ;
|
|
367 |
virtual TInt AddContact(CStifItemParser& aItem) ;
|
|
368 |
virtual TInt DeleteContact(CStifItemParser& aItem) ;
|
|
369 |
virtual TInt AddGroup(CStifItemParser& aItem) ;
|
|
370 |
virtual TInt OrganiseAdd(CStifItemParser& aItem) ;
|
|
371 |
virtual TInt OrganiseDelete(CStifItemParser& aItem);
|
|
372 |
virtual TInt ModifyContact(CStifItemParser& aItem);
|
|
373 |
virtual TInt ModifyGroup(CStifItemParser& aItem);
|
|
374 |
virtual TInt GetContactALLPosBased(CStifItemParser& aItem);
|
|
375 |
virtual TInt GetContactSearchPosBased(CStifItemParser& aItem);
|
|
376 |
virtual TInt GetGroupPosBased(CStifItemParser& aItem);
|
|
377 |
virtual TInt GetDatabasePosBased(CStifItemParser& /*aItem*/) ;
|
|
378 |
virtual TInt AddContactPosBased(CStifItemParser& /*aItem*/) ;
|
|
379 |
virtual TInt AddGroupPosBased(CStifItemParser& /*aItem*/) ;
|
|
380 |
virtual TInt DeleteContactPosBased(CStifItemParser& /*aItem*/) ;
|
|
381 |
virtual TInt OrganiseAddPosBased(CStifItemParser& /*aItem*/) ;
|
|
382 |
virtual TInt OrganiseDeletePosbased(CStifItemParser& /*aItem*/) ;
|
|
383 |
virtual TInt ModifyContactPosBased(CStifItemParser& /*aItem*/) ;
|
|
384 |
virtual TInt ModifyGroupPosBased(CStifItemParser& /*aItem*/) ;
|
|
385 |
virtual TInt ExportL(CStifItemParser& /*aItem*/) ;
|
|
386 |
virtual TInt ImportL(CStifItemParser& /*aItem*/) ;
|
|
387 |
virtual TInt ExportPosBased(CStifItemParser& /*aItem*/) ;
|
|
388 |
virtual TInt ImportPosBased(CStifItemParser& /*aItem*/) ;
|
|
389 |
virtual TInt CancelGetList(CStifItemParser& /*aItem*/) ;
|
|
390 |
virtual TInt CancelAddContact(CStifItemParser& /*aItem*/) ;
|
|
391 |
virtual TInt CancelOrganiseAdd(CStifItemParser& /*aItem*/) ;
|
|
392 |
virtual TInt CancelDeleteContact(CStifItemParser& /*aItem*/) ;
|
|
393 |
virtual TInt CancelExportL(CStifItemParser& /*aItem*/) ;
|
|
394 |
virtual TInt CancelImportL(CStifItemParser& /*aItem*/) ;
|
|
395 |
|
|
396 |
|
|
397 |
void AddOneContactL(const TDesC& aName);
|
|
398 |
void AddOneGroupL(const TDesC& aName);
|
|
399 |
public: // Data
|
|
400 |
// ?one_line_short_description_of_data
|
|
401 |
//?data_declaration;
|
|
402 |
|
|
403 |
protected: // Data
|
|
404 |
// ?one_line_short_description_of_data
|
|
405 |
//?data_declaration;
|
|
406 |
|
|
407 |
private: // Data
|
|
408 |
|
|
409 |
// ?one_line_short_description_of_data
|
|
410 |
//?data_declaration;
|
|
411 |
TInt CTestGetLocation() ;
|
|
412 |
|
|
413 |
// Reserved pointer for future extension
|
|
414 |
//TAny* iReserved;
|
|
415 |
|
|
416 |
public: // Friend classes
|
|
417 |
//?friend_class_declaration;
|
|
418 |
protected: // Friend classes
|
|
419 |
//?friend_class_declaration;
|
|
420 |
private: // Friend classes
|
|
421 |
//?friend_class_declaration;
|
|
422 |
|
|
423 |
CLiwServiceHandler* iServiceHandler;
|
|
424 |
MLiwInterface* iIface;
|
|
425 |
CLiwCriteriaItem* iCriteria;
|
|
426 |
RCriteriaArray iCriteriaArray;
|
|
427 |
//CLiwMap* iMap;
|
|
428 |
CLiwGenericParamList* iInparams;
|
|
429 |
CLiwGenericParamList* iOutparams;
|
|
430 |
|
|
431 |
CLiwGenericParamList* inList;
|
|
432 |
CLiwGenericParamList* outList;
|
|
433 |
TInt iErr;
|
|
434 |
TTestCase iCase;
|
|
435 |
TInt iResult;
|
|
436 |
TInt iIndex;
|
|
437 |
RFs iFSession;
|
|
438 |
RFile iFileHandle;
|
|
439 |
TInt32 iTransid;
|
|
440 |
HBufC* iCntID;
|
|
441 |
TPtrC iGrpID;
|
|
442 |
RPointerArray<TDesC> iIdArrayList;
|
|
443 |
|
|
444 |
CVPbkContactManager* iContactManager;
|
|
445 |
MVPbkContactStoreList* iStores;
|
|
446 |
MVPbkContactStore* iStore;
|
|
447 |
MVPbkStoreContact* iStoreContact;
|
|
448 |
MVPbkContactGroup* iGroup;
|
|
449 |
MVPbkContactLinkArray* iFindResults;
|
|
450 |
MVPbkContactLink* iContactResult;
|
|
451 |
MVPbkContactOperationBase* iOp;
|
|
452 |
CVPbkContactLinkArray* iContactToDelete;
|
|
453 |
HBufC8* iBuffer;
|
|
454 |
TInt iOperation;
|
|
455 |
TInt iCancelled;;
|
|
456 |
|
|
457 |
};
|
|
458 |
|
|
459 |
|
|
460 |
|
|
461 |
|
|
462 |
#endif // TCOMPLUGIN_H
|
|
463 |
|
|
464 |
// End of File
|