|
1 /** |
|
2 * Copyright (c) 2006-2009 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 "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: |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 /** |
|
21 @file |
|
22 @publishedAll |
|
23 @released |
|
24 */ |
|
25 #ifndef __CNT_BASE_STEP_H__ |
|
26 #define __CNT_BASE_STEP_H__ |
|
27 |
|
28 #include <test/testexecutestepbase.h> |
|
29 #include <cntdb.h> |
|
30 #include <cntitem.h> |
|
31 #include "CntPerfServer.h" |
|
32 #include "RCntList.h" |
|
33 |
|
34 namespace TestConstants |
|
35 { |
|
36 //strings to use for labels/values |
|
37 _LIT(KLongString, "longstartkla sjd324flk jsak ldjflk asjdfka lsj34fdlkj salalk fjkajsdf lska1djfl ksajflkasldjlongend"); |
|
38 _LIT(KShortString, "a"); |
|
39 _LIT(KMediumString, "ajkldjKJIlk30aksdjjfei"); |
|
40 |
|
41 _LIT(KTime,"22000101:235959.999999");// time to use for datetime storage |
|
42 static const TContactItemId KContactId = 1;//contact id to use for agent storage |
|
43 static const TTime KDateTime(KTime); |
|
44 static const TInt KAltUID = 1900; |
|
45 static const TInt KInitialUID = 1100; |
|
46 } |
|
47 |
|
48 #define CLEAR(x) { delete x; x = NULL; } |
|
49 |
|
50 //necessary, so that __FILE__ macro is executed |
|
51 #define FILE(file) _S(file) |
|
52 |
|
53 #define STRINGCOMPARE( compareLeft, compareOperation, compareRight, iteration, subiteration )\ |
|
54 StringComparisonTestPrint(compareLeft, _S(#compareOperation), compareRight,\ |
|
55 (compareLeft compareOperation compareRight), iteration, subiteration, __LINE__, FILE(__FILE__)) |
|
56 |
|
57 #define INTCOMPARE( compareLeft, compareOperation, compareRight, iteration, subiteration )\ |
|
58 IntegerComparisonTestPrint(compareLeft, _S(#compareOperation), compareRight,\ |
|
59 (compareLeft compareOperation compareRight), iteration, subiteration, __LINE__, FILE(__FILE__)) |
|
60 |
|
61 #define SINGLECOMPARE( compareOperation, iteration, subiteration )\ |
|
62 IntegerComparisonTestPrint(ETrue, _S(#compareOperation), ETrue,\ |
|
63 (compareOperation), iteration, subiteration, __LINE__, FILE(__FILE__)) |
|
64 |
|
65 class CCntBaseStep : public CTestStep |
|
66 { |
|
67 public: |
|
68 CCntBaseStep(const TInt aContacts):iContacts(aContacts), iParent(NULL) |
|
69 { |
|
70 } |
|
71 CCntBaseStep(const TInt aContacts, CCntPerfServer &aParent):iContacts(aContacts), iParent(&aParent) |
|
72 { |
|
73 } |
|
74 virtual ~CCntBaseStep(); |
|
75 virtual TVerdict doTestStepPreambleL(); |
|
76 virtual TVerdict doTestStepPostambleL(); |
|
77 |
|
78 protected: |
|
79 void AddUIDsL(CContactItemFieldSet &aFields, const TInt32 aFieldType) const; |
|
80 TBool CheckUIDsL(const CContactItemFieldSet &aFields, const TInt32 aFieldType) const; |
|
81 void SetLabelL( CContactItemFieldSet &aFields, const TInt aPos, |
|
82 const TDesC &aLabel) const; |
|
83 void AddNewFieldL( CContactItemFieldSet &aFields,const TDesC& aLabel, |
|
84 const TFieldType aFieldType, const TBool aEmpty=EFalse) const; |
|
85 TBool CheckNewFieldL( const CContactItemFieldSet &aFields, const TInt aPos, |
|
86 const TFieldType aFieldType, const TBool aEmpty=EFalse) const; |
|
87 void SetFieldL( CContactItemFieldSet &aFields,const TInt aPos, |
|
88 const TDesC &aText) const; |
|
89 TBool CompareFieldsL( const CContactItemFieldSet &aFields, const TInt aPos, |
|
90 const TDesC &aText) const; |
|
91 void SetContactFieldsL(CContactItem &aContact) const; |
|
92 void SetContactFieldsL(CContactItem &aContact, const TInt aCount) const; |
|
93 TBool CheckContactFieldsL(const CContactItem &aContact) const; |
|
94 void SetContactLabelsL(CContactItem &aContact) const; |
|
95 TBool CheckContactLabelsL(const CContactItem &aContact); |
|
96 virtual void InitializeL(); |
|
97 virtual void Cleanup(); |
|
98 virtual void PreTestL() =0; |
|
99 static TInt CountEmpty(const CContactItemFieldSet &aFields); |
|
100 void PrintCurrentContactL(const CContactItem &aContact) const; |
|
101 void PrintCurrentContactL(const TContactItemId aCid) const; |
|
102 TInt CountHiddenFields(const CContactItemFieldSet &aFields) const; |
|
103 void OpenL( const TContactItemId aCid, const CContactItemViewDef &aView, |
|
104 const TBool aDefault=EFalse); |
|
105 void CommitL(); |
|
106 void ReadL( const TContactItemId aCid, const CContactItemViewDef &aView, |
|
107 const TBool aDefault=EFalse); |
|
108 void ReadMinimalL( const TContactItemId aCid, const CContactItemViewDef &aView, |
|
109 const CContactItemViewDef &aDefView, const TBool aDefault=EFalse); |
|
110 void Close(); |
|
111 void AddEmptyContactsL(const TInt aNumber); |
|
112 void MissngTestPanic() const; |
|
113 void WaitForServerToExitL(); |
|
114 |
|
115 TBool StringComparisonTestPrint( const TDesC &aCompareL, |
|
116 const TText *aCompareOperator, |
|
117 const TDesC &aCompareR, |
|
118 const TBool aResult, |
|
119 const TInt aIteration, |
|
120 const TInt aSubIteration, |
|
121 const TInt aLine, |
|
122 const TText *aFile); |
|
123 |
|
124 TBool IntegerComparisonTestPrint( const TInt aCompareL, |
|
125 const TText *aCompareOperator, |
|
126 const TInt aCompareR, |
|
127 const TBool aResult, |
|
128 const TInt aIteration, |
|
129 const TInt aSubIteration, |
|
130 const TInt aLine, |
|
131 const TText *aFile); |
|
132 |
|
133 private: |
|
134 TBool CompareLabels(const CContactItemFieldSet &aFields, const TInt aPos, |
|
135 const TDesC &aLabel); |
|
136 void GetExistingUIDsL(RArray<TInt32> &aArray) const; |
|
137 CContactItemViewDef *CopyViewL(const CContactItemViewDef &aView); |
|
138 void CloseProcessL(const TDesC& aProcessName, const TInt aIteration); |
|
139 |
|
140 |
|
141 protected: |
|
142 TInt iContacts; |
|
143 CContactDatabase *iContactsDatabase; |
|
144 CContactItemViewDef *iViewAll; |
|
145 RArray<TInt32> *iExistingUidsArray; |
|
146 CContactItem *iContactItem; |
|
147 CContactItemFieldSet *iFields; |
|
148 RCntList *iIterate; |
|
149 CCntPerfServer *iParent; |
|
150 CContactTemplate *iTemplate; |
|
151 |
|
152 }; |
|
153 #endif |