|
1 // Copyright (c) 1997-2009 Nokia Corporation and/or its subsidiary(-ies). |
|
2 // All rights reserved. |
|
3 // This component and the accompanying materials are made available |
|
4 // under the terms of "Eclipse Public License v1.0" |
|
5 // which accompanies this distribution, and is available |
|
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
7 // |
|
8 // Initial Contributors: |
|
9 // Nokia Corporation - initial contribution. |
|
10 // |
|
11 // Contributors: |
|
12 // |
|
13 // Description: |
|
14 // |
|
15 |
|
16 #ifndef __T_UTILS_H__ |
|
17 #define __T_UTILS_H__ |
|
18 |
|
19 #include <cntdb.h> |
|
20 #include <cntitem.h> |
|
21 #include <cntfield.h> |
|
22 #include <cntfldst.h> |
|
23 #include <s32mem.h> |
|
24 #include <hal.h> |
|
25 |
|
26 class RTest; |
|
27 |
|
28 enum TVCardStoreType |
|
29 { |
|
30 KVCardStoreTypeBuf, |
|
31 KVCardStoreTypeFile, |
|
32 }; |
|
33 |
|
34 class CVCardTestStore : public CBase |
|
35 { |
|
36 public: |
|
37 IMPORT_C ~CVCardTestStore(); |
|
38 IMPORT_C static CVCardTestStore* NewLC(TVCardStoreType aType, RFs *aFs, TInt aFileNum); |
|
39 IMPORT_C static CVCardTestStore* NewL(TVCardStoreType aType, RFs *aFs, TInt aFileNum); |
|
40 inline void SetStreamId(TStreamId aStreamId) {iStreamId=aStreamId;}; |
|
41 inline TStreamId StreamId() const {return(iStreamId);}; |
|
42 IMPORT_C CStreamStore *Store() const; |
|
43 #ifdef __EABI__ |
|
44 /** Cause vtable & typeinfo to be exported */ |
|
45 CVCardTestStore() {} |
|
46 #endif |
|
47 |
|
48 private: |
|
49 IMPORT_C void ConstructL(TVCardStoreType aType, RFs *aFs, TInt aFileNum); |
|
50 private: |
|
51 TStreamId iStreamId; |
|
52 TVCardStoreType iType; |
|
53 CBufStore *iBufStore; |
|
54 CFileStore *iFileStore; |
|
55 }; |
|
56 |
|
57 |
|
58 /** Holds results from performance profiling. |
|
59 Same data members as deprecated TProfile class in e32debug.h */ |
|
60 class TCntProfile |
|
61 { |
|
62 public: |
|
63 TInt iTime; |
|
64 TInt iCount; |
|
65 }; |
|
66 |
|
67 |
|
68 class CCntTest : public CBase |
|
69 { |
|
70 public: |
|
71 IMPORT_C void ConstructL(RTest &aTest, const TDesC &aDatabaseName); |
|
72 IMPORT_C void EndTestLib(TInt aErr); |
|
73 inline RFs &Fs() {return(iFs);}; |
|
74 CContactDatabase* Db() {return(iDb);}; |
|
75 IMPORT_C CContactDatabase* CreateDatabaseL(); |
|
76 IMPORT_C CContactDatabase* OpenDatabaseL(); |
|
77 IMPORT_C void SelectDriveL(); |
|
78 IMPORT_C void CloseDatabase(); |
|
79 IMPORT_C void DeleteDatabaseL(); |
|
80 IMPORT_C void DeleteAllTemplateFieldsL(); |
|
81 IMPORT_C void TestField(CContactItemField &aField,TStorageType aType,TFieldType aFieldType,TUid aMapping); |
|
82 IMPORT_C void AdjustContactAccessCountL(TContactItemId aItemId, TInt aCount); |
|
83 IMPORT_C void TestAccessCount(TContactItemId aItemId, TInt aCount); |
|
84 IMPORT_C TBool CompareFields(CContactItemField &aField1, CContactItemField &aField2); |
|
85 IMPORT_C void CheckDeletedContact(TContactItemId aDeleteId); |
|
86 IMPORT_C void CheckContactDoesNotExist(TContactItemId aNotExistId); |
|
87 IMPORT_C void DeleteContact(TContactItemId aDeleteMe); |
|
88 IMPORT_C HBufC *ContactUidLC(TContactItemId aId, TInt64 aMachineId); |
|
89 IMPORT_C CVCardTestStore* ExportContactsLC(const CContactIdArray *aIds, TUint aFormatFlags, TVCardStoreType aType=KVCardStoreTypeBuf, TInt aFileNum=0); |
|
90 IMPORT_C CVCardTestStore* ExportContactLC(TContactItemId aId, TUint aFormatFlags, TVCardStoreType aType=KVCardStoreTypeBuf, TInt aFileNum=0); |
|
91 IMPORT_C void ImportContacts1by1L(CVCardTestStore* aStore, TUint aFormatFlags); |
|
92 IMPORT_C CArrayPtr<CContactItem>* ImportContactsL(CVCardTestStore* aStore, TUint aFormatFlags); |
|
93 IMPORT_C CArrayPtr<CContactItem>* ImportContactsLC(CVCardTestStore* aStore, TUint aFormatFlags); |
|
94 IMPORT_C void PrintfNewline() const; |
|
95 IMPORT_C TBool LockServerSessionExists(TBool aPause=EFalse) const; |
|
96 IMPORT_C TInt LockServerProcessCount(TBool aPause=EFalse, TBool aDisplayCount=EFalse, TBool aDisplayList=EFalse) const; |
|
97 IMPORT_C void TestLockServerExists() const; |
|
98 IMPORT_C void TestNoLockServer() const; |
|
99 IMPORT_C void TestLockServerCloses() const; |
|
100 inline const TFileName& DatabaseName() const {return(iDatabaseName);}; |
|
101 /** Profiling APIs */ |
|
102 IMPORT_C static TInt ProfileResult(TCntProfile* aProfile,TInt aStart,TInt aCount); |
|
103 IMPORT_C static TInt ProfileReset(TInt aStart,TInt aCount); |
|
104 IMPORT_C static TInt ProfileStart(TInt aProfile); |
|
105 IMPORT_C static TInt ProfileEnd(TInt aProfile); |
|
106 |
|
107 #ifdef __EABI__ |
|
108 /** Cause vtable & typeinfo to be exported */ |
|
109 IMPORT_C CCntTest() {} |
|
110 #endif |
|
111 private: |
|
112 |
|
113 IMPORT_C ~CCntTest(); |
|
114 private: |
|
115 CContactDatabase* iDb; |
|
116 TFileName iDatabaseName; |
|
117 RFs iFs; |
|
118 CTrapCleanup* iCleanup; |
|
119 RTest *iTest; |
|
120 TBool iIsTopLevel; |
|
121 |
|
122 }; |
|
123 |
|
124 struct TCntProfileTls |
|
125 { |
|
126 TTime iTime; |
|
127 TCntProfile iProfile; |
|
128 }; |
|
129 |
|
130 |
|
131 IMPORT_C TPtrC FieldText(CContactItem& aItem,TUid aType); |
|
132 IMPORT_C void SetNameL(CContactItem& aItem,TUid aFieldType,TUid aMapping,const TDesC& aName, TBool aAddEntry); |
|
133 IMPORT_C void AddFieldL(CContactItemFieldSet* aFieldSet, TStorageType aType,TFieldType aFieldType,TUid aMapping); |
|
134 IMPORT_C void AddFieldL(CContactItem* aItem, TStorageType aType,TFieldType aFieldType,TUid aMapping); |
|
135 IMPORT_C void InsertFieldL(CContactItem& aItem, TInt aPos, TStorageType aType,TFieldType aFieldType,TUid aMapping); |
|
136 IMPORT_C void InsertFieldL(CContactItem& aItem, TInt aPos, TStorageType aType,TFieldType aFieldType,TUid aMapping, const TDesC& aText); |
|
137 IMPORT_C TContactItemId AddContactL(CContactDatabase* aDb, TFieldType aFieldType,TUid aMapping, const TDesC &aText); |
|
138 IMPORT_C void SetUserFlags(CContactItemFieldSet& aFieldSet, TUint aFlags, TInt aIndex); |
|
139 IMPORT_C void SetUserFlags(CContactItemFieldSet& aFieldSet, TUint aFlags); |
|
140 IMPORT_C void SetUserFlags(CContactItem* aItem, TUint aFlags, TInt aIndex); |
|
141 IMPORT_C void SetUserFlags(CContactItem* aItem, TUint aFlags); |
|
142 IMPORT_C CVCardTestStore* ExportContactsL(CContactDatabase* aDb, const CContactIdArray *aIds, TUint aFormatFlags, TVCardStoreType aType, RFs *aFs, TInt aFileNum); |
|
143 IMPORT_C CArrayPtr<CContactItem>* ImportContactsL(CContactDatabase* aDb, CVCardTestStore* aStore, TUint aFormatFlags); |
|
144 IMPORT_C void CleanUpResetAndDestroy(TAny *aArray); |
|
145 IMPORT_C TBool CompareItemField(const CContactItemField &aItemField1, const CContactItemField &aItemField2, TBool aCheckStorage); |
|
146 IMPORT_C TBool CompareItemFields(CContactItem *aItem1, CContactItem *aItem2, TBool aCheckStorage=ETrue, TBool aTemplateLabelRemoved=EFalse); |
|
147 IMPORT_C TBool TestGroupStateL(CContactDatabase* aDb, TInt aGroupCount, TInt aGroupEntryCount); |
|
148 IMPORT_C HBufC* GetFullDbName(const TDesC& aDbName); |
|
149 IMPORT_C TBool DbShouldBeInDamagedState(CContactDatabase* aDb); |
|
150 IMPORT_C CContactItem* ReadContactFromDamagedDbLC(CContactDatabase* aDb, TContactItemId aContactId); |
|
151 |
|
152 /** A simple timer primarily for use in the T_PERFORMANCE test. |
|
153 Used as an alternative for the CntProfile timing stuff. |
|
154 Uses User::NTickCount as opposed to TTime. |
|
155 */ |
|
156 class TCntPerfTimer |
|
157 { |
|
158 public: |
|
159 IMPORT_C TCntPerfTimer(); |
|
160 IMPORT_C void StartTimer(); |
|
161 IMPORT_C void StopTimer(); |
|
162 IMPORT_C void ResetTimer(); |
|
163 IMPORT_C TUint Result(); |
|
164 private: |
|
165 TUint iTickCount1; |
|
166 TUint iTickCount2; |
|
167 }; |
|
168 |
|
169 #endif |