summaryrefslogtreecommitdiffstats
path: root/plugins/contacts/symbian/contactsmodel/tsrc/t_utils.h
blob: bf7bffa46821582ced88d9e03980b669929a0dad (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
/*
* Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
* Contact: http://www.qt-project.org/legal
* This component and the accompanying materials are made available
* under the terms of "Eclipse Public License v1.0"
* which accompanies this distribution, and is available
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
*
* Initial Contributors:
* Nokia Corporation - initial contribution.
*
* Contributors:
*
* Description: 
*
*/


#ifndef __T_UTILS_H__
#define __T_UTILS_H__

#include <cntdb.h>
#include <cntitem.h>
#include <cntfield.h>
#include <cntfldst.h>
#include <s32mem.h>
#include <hal.h>

class RTest;

enum TVCardStoreType
	{
	KVCardStoreTypeBuf,
	KVCardStoreTypeFile,
	};

class CVCardTestStore : public CBase
	{
public:
	IMPORT_C ~CVCardTestStore();
	IMPORT_C static CVCardTestStore* NewLC(TVCardStoreType aType, RFs *aFs, TInt aFileNum);
	IMPORT_C static CVCardTestStore* NewL(TVCardStoreType aType, RFs *aFs, TInt aFileNum);
	inline void SetStreamId(TStreamId aStreamId) {iStreamId=aStreamId;};
	inline TStreamId StreamId() const {return(iStreamId);};
	IMPORT_C CStreamStore *Store() const;
#ifdef __EABI__
       /** Cause vtable & typeinfo to be exported */
       CVCardTestStore() {}
#endif

private:
	IMPORT_C void ConstructL(TVCardStoreType aType, RFs *aFs, TInt aFileNum);
private:
	TStreamId iStreamId;
	TVCardStoreType iType;
	CBufStore *iBufStore;
	CFileStore *iFileStore;
	};
	
	
/** Holds results from performance profiling.
Same data members as deprecated TProfile class in e32debug.h */
class TCntProfile
    {
public:
    TInt iTime;
    TInt iCount;
    };


class CCntTest : public CBase
	{
public:
	IMPORT_C void ConstructL(RTest &aTest, const TDesC &aDatabaseName);
	IMPORT_C void EndTestLib(TInt aErr);
	inline RFs &Fs() {return(iFs);};
	CContactDatabase* Db() {return(iDb);};
	IMPORT_C CContactDatabase* CreateDatabaseL();
	IMPORT_C CContactDatabase* OpenDatabaseL();
	IMPORT_C void SelectDriveL();
	IMPORT_C void CloseDatabase();
	IMPORT_C void DeleteDatabaseL();
	IMPORT_C void DeleteAllTemplateFieldsL();
	IMPORT_C void TestField(CContactItemField &aField,TStorageType aType,TFieldType aFieldType,TUid aMapping);
	IMPORT_C void AdjustContactAccessCountL(TContactItemId aItemId, TInt aCount);
	IMPORT_C void TestAccessCount(TContactItemId aItemId, TInt aCount);
	IMPORT_C TBool CompareFields(CContactItemField &aField1, CContactItemField &aField2);
	IMPORT_C void CheckDeletedContact(TContactItemId aDeleteId);
	IMPORT_C void CheckContactDoesNotExist(TContactItemId aNotExistId);
	IMPORT_C void DeleteContact(TContactItemId aDeleteMe);
	IMPORT_C HBufC *ContactUidLC(TContactItemId aId, TInt64 aMachineId);
	IMPORT_C CVCardTestStore* ExportContactsLC(const CContactIdArray *aIds, TUint aFormatFlags, TVCardStoreType aType=KVCardStoreTypeBuf, TInt aFileNum=0);
	IMPORT_C CVCardTestStore* ExportContactLC(TContactItemId aId, TUint aFormatFlags, TVCardStoreType aType=KVCardStoreTypeBuf, TInt aFileNum=0);
	IMPORT_C void ImportContacts1by1L(CVCardTestStore* aStore, TUint aFormatFlags);
	IMPORT_C CArrayPtr<CContactItem>* ImportContactsL(CVCardTestStore* aStore, TUint aFormatFlags);
	IMPORT_C CArrayPtr<CContactItem>* ImportContactsLC(CVCardTestStore* aStore, TUint aFormatFlags);
	IMPORT_C void PrintfNewline() const;
	IMPORT_C TBool LockServerSessionExists(TBool aPause=EFalse) const;
	IMPORT_C TInt LockServerProcessCount(TBool aPause=EFalse, TBool aDisplayCount=EFalse, TBool aDisplayList=EFalse) const;
	IMPORT_C void TestLockServerExists() const;
	IMPORT_C void TestNoLockServer() const;
	IMPORT_C void TestLockServerCloses() const;
	inline const TFileName& DatabaseName() const {return(iDatabaseName);};
	/**	Profiling APIs */
    IMPORT_C static TInt ProfileResult(TCntProfile* aProfile,TInt aStart,TInt aCount);
    IMPORT_C static TInt ProfileReset(TInt aStart,TInt aCount);
    IMPORT_C static TInt ProfileStart(TInt aProfile);
    IMPORT_C static TInt ProfileEnd(TInt aProfile);

#ifdef __EABI__
       /** Cause vtable & typeinfo to be exported */
    IMPORT_C CCntTest() {}
#endif
private:

	IMPORT_C ~CCntTest();
private:
	CContactDatabase* iDb;
	TFileName iDatabaseName;
	RFs iFs;
    CTrapCleanup* iCleanup;
	RTest *iTest;
	TBool iIsTopLevel;

	};

struct TCntProfileTls
	{
	TTime iTime;
	TCntProfile iProfile;
	};


IMPORT_C TPtrC FieldText(CContactItem& aItem,TUid aType);
IMPORT_C void SetNameL(CContactItem& aItem,TUid aFieldType,TUid aMapping,const TDesC& aName, TBool aAddEntry);
IMPORT_C void AddFieldL(CContactItemFieldSet* aFieldSet, TStorageType aType,TFieldType aFieldType,TUid aMapping);
IMPORT_C void AddFieldL(CContactItem* aItem, TStorageType aType,TFieldType aFieldType,TUid aMapping);
IMPORT_C void InsertFieldL(CContactItem& aItem, TInt aPos, TStorageType aType,TFieldType aFieldType,TUid aMapping);
IMPORT_C void InsertFieldL(CContactItem& aItem, TInt aPos, TStorageType aType,TFieldType aFieldType,TUid aMapping, const TDesC& aText);
IMPORT_C TContactItemId AddContactL(CContactDatabase* aDb, TFieldType aFieldType,TUid aMapping, const TDesC &aText);
IMPORT_C void SetUserFlags(CContactItemFieldSet& aFieldSet, TUint aFlags, TInt aIndex);
IMPORT_C void SetUserFlags(CContactItemFieldSet& aFieldSet, TUint aFlags);
IMPORT_C void SetUserFlags(CContactItem* aItem, TUint aFlags, TInt aIndex);
IMPORT_C void SetUserFlags(CContactItem* aItem, TUint aFlags);
IMPORT_C CVCardTestStore* ExportContactsL(CContactDatabase* aDb, const CContactIdArray *aIds, TUint aFormatFlags, TVCardStoreType aType, RFs *aFs, TInt aFileNum);
IMPORT_C CArrayPtr<CContactItem>* ImportContactsL(CContactDatabase* aDb, CVCardTestStore* aStore, TUint aFormatFlags);
IMPORT_C void CleanUpResetAndDestroy(TAny *aArray);
IMPORT_C TBool CompareItemField(const CContactItemField &aItemField1, const CContactItemField &aItemField2, TBool aCheckStorage);
IMPORT_C TBool CompareItemFields(CContactItem *aItem1, CContactItem *aItem2, TBool aCheckStorage=ETrue, TBool aTemplateLabelRemoved=EFalse);
IMPORT_C TBool TestGroupStateL(CContactDatabase* aDb, TInt aGroupCount, TInt aGroupEntryCount);
IMPORT_C HBufC* GetFullDbName(const TDesC& aDbName);
IMPORT_C TBool DbShouldBeInDamagedState(CContactDatabase* aDb); 
IMPORT_C CContactItem* ReadContactFromDamagedDbLC(CContactDatabase* aDb, TContactItemId aContactId);

/** A simple timer primarily for use in the T_PERFORMANCE test.
    Used as an alternative for the CntProfile timing stuff.
    Uses User::NTickCount as opposed to TTime.
*/
class TCntPerfTimer
	{
public:
	IMPORT_C TCntPerfTimer();
	IMPORT_C void StartTimer();
	IMPORT_C void StopTimer();
	IMPORT_C void ResetTimer();
	IMPORT_C TUint Result();
private:
	TUint iTickCount1;
	TUint iTickCount2;
	};

#endif