|
1 /** |
|
2 * Copyright (c) 2007-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 #ifndef __TEST_CONTACTVIEW_UNDERLYING_VIEW_UPDATE_H__ |
|
21 #define __TEST_CONTACTVIEW_UNDERLYING_VIEW_UPDATE_H__ |
|
22 |
|
23 // System Includes |
|
24 #include <test/testexecutestepbase.h> |
|
25 #include <cntdb.h> |
|
26 #include <cntitem.h> |
|
27 #include <cntviewbase.h> |
|
28 #include <cntfldst.h> |
|
29 #include <cntfilt.h> |
|
30 #include <e32math.h> |
|
31 |
|
32 // User Includes |
|
33 #include "ContactUtilitiesCollection.h" |
|
34 #include "ClientServer.h" |
|
35 #include "TestContactViewDatabaseUtilitiesStep.h" |
|
36 |
|
37 // Literals used |
|
38 _LIT(KTestContactViewUnderLyingViewUpdateStep, "TestContactViewUnderLyingViewUpdateStep"); |
|
39 _LIT(KLocalViewString, "Local View"); |
|
40 _LIT(KRemoteViewString, "Remote View"); |
|
41 _LIT(KNamedRemoteViewString, "Named Remote View"); |
|
42 _LIT(KGroupViewString, "Group View"); |
|
43 _LIT(KFindViewString, "Find View"); |
|
44 _LIT(KFilteredViewString, "Filtered View"); |
|
45 _LIT(KConcatenatedViewString, "ConcatenatedV iew"); |
|
46 _LIT(KSubViewString, "Sub View"); |
|
47 |
|
48 |
|
49 /** |
|
50 * This class facilitates construction of contact view validation objects, used for verifying the |
|
51 * behaviour of contact views when the underlying database is updated. |
|
52 */ |
|
53 class TViewData |
|
54 { |
|
55 public: |
|
56 enum TContactViewType |
|
57 { |
|
58 ELocalView, |
|
59 ERemoteView, |
|
60 ENamedRemoteView, |
|
61 EFilteredView, |
|
62 EFindView, |
|
63 EGroupView, |
|
64 ESubView, |
|
65 EConcatenatedView, |
|
66 }; |
|
67 |
|
68 void SetViewType(const TPtrC& aViewTypeString); |
|
69 void SetViewType(TViewData::TContactViewType aViewType); |
|
70 void SetViewIndex(TInt aViewIndex); |
|
71 TInt ViewIndex(); |
|
72 TPtrC ViewTypeInStringFormat(); |
|
73 TViewData::TContactViewType ViewType(); |
|
74 TViewData::TContactViewType ConvertViewType(const TPtrC& aViewTypeString); |
|
75 void ConvertViewTypeToString(TViewData::TContactViewType aViewType, TDes& aViewTypeInString); |
|
76 |
|
77 private: |
|
78 TViewData::TContactViewType iViewType; |
|
79 TBuf<SharedConstants::KMaxViewTypeLength> iViewTypeInStringFormat; |
|
80 TInt iViewIndex; |
|
81 }; |
|
82 |
|
83 /** |
|
84 * Sets the view type information based on data available in string format |
|
85 * @param aViewTypeString - view type information in string format |
|
86 */ |
|
87 inline void TViewData::SetViewType(const TPtrC& aViewTypeString) |
|
88 { |
|
89 iViewTypeInStringFormat.Copy(aViewTypeString); |
|
90 iViewType = ConvertViewType(aViewTypeString); |
|
91 } |
|
92 |
|
93 /** |
|
94 * Sets the view type information based on data available in TViewData::TContactViewType format |
|
95 * @param aViewType - view type in TViewData::TContactViewType format |
|
96 */ |
|
97 inline void TViewData::SetViewType(TViewData::TContactViewType aViewType) |
|
98 { |
|
99 iViewType = aViewType; |
|
100 ConvertViewTypeToString(aViewType, iViewTypeInStringFormat); |
|
101 } |
|
102 |
|
103 /** |
|
104 * Sets the view index of the TViewData object |
|
105 * @param aViewIndex - view index |
|
106 */ |
|
107 inline void TViewData::SetViewIndex(TInt aViewIndex) |
|
108 { |
|
109 iViewIndex = aViewIndex; |
|
110 } |
|
111 |
|
112 /** |
|
113 * returns the view index of the TViewData object |
|
114 * @return TInt - view index |
|
115 */ |
|
116 inline TInt TViewData::ViewIndex() |
|
117 { |
|
118 return iViewIndex; |
|
119 } |
|
120 |
|
121 /** |
|
122 * returns the view type information of the TViewData Object in String format |
|
123 * @return TPtrC - pointer to view type information of the TViewData Object |
|
124 */ |
|
125 inline TPtrC TViewData::ViewTypeInStringFormat() |
|
126 { |
|
127 return iViewTypeInStringFormat; |
|
128 } |
|
129 |
|
130 /** |
|
131 * returns the view type information of the TViewData Object in TViewData::TContactViewType format |
|
132 * @return TViewData::TContactViewType - Object of type TViewData::TContactViewType |
|
133 */ |
|
134 inline TViewData::TContactViewType TViewData::ViewType() |
|
135 { |
|
136 return iViewType; |
|
137 } |
|
138 |
|
139 /** |
|
140 * This class extends TViewData, adds support by storing information about number of contacts to be removed. |
|
141 */ |
|
142 class TViewModificationData : public TViewData |
|
143 { |
|
144 public: |
|
145 void SetNumberOfContactsToBeRemoved(const TInt aCount); |
|
146 TInt NumberOfContactsToBeRemoved(); |
|
147 |
|
148 private: |
|
149 TInt iNumOfContactsToBeRemoved; |
|
150 |
|
151 }; |
|
152 |
|
153 |
|
154 // Sets the desired number of contacts to be removed |
|
155 |
|
156 /** |
|
157 * Sets the desired number of contacts to be removed |
|
158 * @param TInt - number of contacts to be removed |
|
159 */ |
|
160 inline void TViewModificationData::SetNumberOfContactsToBeRemoved(const TInt aCount) |
|
161 { |
|
162 iNumOfContactsToBeRemoved = aCount; |
|
163 } |
|
164 |
|
165 /** |
|
166 * Returns the number of contacts to be removed |
|
167 * @return TInt - number of contacts to be removed |
|
168 */ |
|
169 inline TInt TViewModificationData::NumberOfContactsToBeRemoved() |
|
170 { |
|
171 return iNumOfContactsToBeRemoved; |
|
172 } |
|
173 |
|
174 /** |
|
175 * This class extends TViewData, adds support by storing information about expected view count after view update. |
|
176 */ |
|
177 class TViewValidationData : public TViewData |
|
178 { |
|
179 public: |
|
180 void SetExpectedViewCount(const TInt aCount); |
|
181 TInt ExpectedViewCount(); |
|
182 |
|
183 private: |
|
184 TInt iNumOfContactsAfterViewUpdate; |
|
185 }; |
|
186 |
|
187 |
|
188 |
|
189 /** |
|
190 * Sets the desired number expected contacts |
|
191 * @param TInt - number of contacts to be removed |
|
192 */ |
|
193 inline void TViewValidationData::SetExpectedViewCount(const TInt aCount) |
|
194 { |
|
195 iNumOfContactsAfterViewUpdate = aCount; |
|
196 } |
|
197 |
|
198 /** |
|
199 * Returns the number of contacts expected after view update |
|
200 * @return TInt - number of contacts expected after view update |
|
201 */inline TInt TViewValidationData::ExpectedViewCount() |
|
202 { |
|
203 return iNumOfContactsAfterViewUpdate; |
|
204 } |
|
205 |
|
206 |
|
207 /** |
|
208 * This test step should Update of base views and validating the view update in |
|
209 * the dependant views and view notifications |
|
210 */ |
|
211 class CTestContactViewUnderlyingViewUpdateStep : public CTestContactViewDatabaseUtilitiesStep |
|
212 { |
|
213 public: |
|
214 CTestContactViewUnderlyingViewUpdateStep(); |
|
215 |
|
216 TVerdict doTestStepPreambleL(); |
|
217 TVerdict doTestStepL(); |
|
218 |
|
219 void ReadIniAndConstructViewUpdateObjectsL(); |
|
220 void ReadIniAndConstructViewValidationObjectsL(); |
|
221 void RemoveContactsFromTheUnderLyingViewsL(); |
|
222 void ValidateViewCountL(); |
|
223 void ListenForViewEventsAndValidateL(); |
|
224 |
|
225 private: |
|
226 CActiveScheduler* iScheduler; |
|
227 RArray<TViewModificationData> iViewUpdateArray; |
|
228 RArray<TViewValidationData> iViewValidationArray; |
|
229 }; |
|
230 |
|
231 #endif |