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