|
1 /* |
|
2 * Copyright (c) 2005-2006 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: Parent class of classes testing GetSuplInfoL |
|
15 * |
|
16 */ |
|
17 |
|
18 #include <epos_comasuplposhandlerbase.h> |
|
19 #include <epos_comasuplpossessionbase.h> |
|
20 #include <epos_comasuplinforequestlist.h> |
|
21 #include <epos_comasuplinforequestlist.h> |
|
22 #include <epos_comasuplreqasstdata.h> |
|
23 #include <epos_comasuplsetcapabilities.h> |
|
24 #include <epos_comasuplposition.h> |
|
25 #include <epos_comasuplpospayload.h> |
|
26 #include <epos_comasuplvelocity.h> |
|
27 #include <epos_eomasuplposerrors.h> |
|
28 |
|
29 #include "epos_comasuplgetsuplinfomanager.h" |
|
30 #include "epos_comasuplpostesterlogger.h" |
|
31 |
|
32 |
|
33 _LIT8(KValueofSetCapCount, "Info: Resetting number of SetCapability objects\ |
|
34 in request list to "); |
|
35 |
|
36 _LIT8(KValueOfReqAsstDataCount, "Info: Resetting number of Request \ |
|
37 Assistance Data objects in request list to "); |
|
38 |
|
39 _LIT8(KValueOfPositionCount, "Info: Resetting number of Position objects \ |
|
40 in request list to "); |
|
41 |
|
42 _LIT8(KValueOfVelocityCount, "Info: Resetting number of Velocity objects \ |
|
43 in request list to "); |
|
44 |
|
45 _LIT8(KValueOfPayloadCount, "Info: Resetting number of Payload objects in \ |
|
46 request list to "); |
|
47 |
|
48 |
|
49 |
|
50 // --------------------------------------------------------------------------- |
|
51 // Destructor |
|
52 // --------------------------------------------------------------------------- |
|
53 // |
|
54 COMASuplGetSuplInfoManager::~COMASuplGetSuplInfoManager() |
|
55 { |
|
56 delete iSessionBase; |
|
57 if(iCreatedTypeSeq) |
|
58 { |
|
59 for(TInt counter = 0; counter < iCreatedTypeSeq->Count(); counter++) |
|
60 { |
|
61 iCreatedTypeSeq->Delete(counter); |
|
62 } |
|
63 } |
|
64 delete iCreatedTypeSeq; |
|
65 delete iRequestList; |
|
66 } |
|
67 // ----------------------------------------------------------------------------- |
|
68 // Constructor |
|
69 // ----------------------------------------------------------------------------- |
|
70 // |
|
71 COMASuplGetSuplInfoManager::COMASuplGetSuplInfoManager( |
|
72 COMASuplPosHandlerBase& aPosHandler |
|
73 , COMASuplPosTesterCategory* aCallBack ) |
|
74 :COMASuplPosTesterCategory( aCallBack ) |
|
75 , iPosHandler(aPosHandler) |
|
76 , iRequestID(-1) |
|
77 |
|
78 { |
|
79 } |
|
80 |
|
81 // ----------------------------------------------------------------------------- |
|
82 // COMASuplGetSuplInfoManager::CreateRequestListL |
|
83 // (other items were commented in a header). |
|
84 // ----------------------------------------------------------------------------- |
|
85 // |
|
86 COMASuplInfoRequestList& COMASuplGetSuplInfoManager::CreateRequestListL( |
|
87 TInt aSetCapReqCount |
|
88 , TInt aReqAsstDataCount |
|
89 , TInt aPositionCount |
|
90 , TInt aVelocityCount |
|
91 , TInt aPayLoadCount) |
|
92 { |
|
93 TInt counter = 0; |
|
94 ValidateAndSetArguments(aSetCapReqCount, aReqAsstDataCount |
|
95 , aPositionCount, aVelocityCount, aPayLoadCount); |
|
96 |
|
97 TInt arraySize = aSetCapReqCount + aReqAsstDataCount + aPositionCount |
|
98 + aVelocityCount + aPayLoadCount; |
|
99 if(arraySize <= 0) |
|
100 { |
|
101 User::Leave(KErrUnderflow); |
|
102 } |
|
103 ResetLists(); |
|
104 |
|
105 iCreatedTypeSeq = new(ELeave)CArrayFixFlat< TInt >(arraySize); |
|
106 iRequestList = COMASuplInfoRequestList::NewL(); |
|
107 iCreatedTypeSeq->SetReserveL(arraySize); |
|
108 for( ; counter < aSetCapReqCount; counter++ ) |
|
109 { |
|
110 COMASuplInfoRequest* request = COMASuplSETCapabilities::NewL(); |
|
111 iCreatedTypeSeq->AppendL(COMASuplInfoRequest::EOMASuplSETCapabilities); |
|
112 iRequestList->Append( request ); |
|
113 } |
|
114 |
|
115 for( counter = 0; counter < aReqAsstDataCount; counter++ ) |
|
116 { |
|
117 COMASuplInfoRequest* request = COMASuplReqAsstData::NewL(); |
|
118 iCreatedTypeSeq->AppendL(COMASuplInfoRequest::EOMASuplReqAsstData); |
|
119 iRequestList->Append( request ); |
|
120 } |
|
121 |
|
122 for( counter = 0; counter < aPositionCount; counter++ ) |
|
123 { |
|
124 COMASuplInfoRequest* request = COMASuplPosition::NewL(); |
|
125 iCreatedTypeSeq->AppendL(COMASuplInfoRequest::EOMASuplPosition); |
|
126 iRequestList->Append( request ); |
|
127 } |
|
128 |
|
129 for( counter = 0; counter < aVelocityCount; counter++ ) |
|
130 { |
|
131 COMASuplInfoRequest* request = COMASuplVelocity::NewL(); |
|
132 iCreatedTypeSeq->AppendL(COMASuplInfoRequest::EOMASuplVelocity); |
|
133 iRequestList->Append( request ); |
|
134 } |
|
135 |
|
136 for( counter = 0; counter < aPayLoadCount; counter++ ) |
|
137 { |
|
138 COMASuplInfoRequest* request = COMASuplPosPayload::NewL(); |
|
139 iCreatedTypeSeq->AppendL(COMASuplInfoRequest::EOMASuplPosPayload); |
|
140 iRequestList->Append( request ); |
|
141 } |
|
142 |
|
143 return *iRequestList; |
|
144 } |
|
145 |
|
146 // ----------------------------------------------------------------------------- |
|
147 // COMASuplGetSuplInfoManager::CreateRequestListL |
|
148 // (other items were commented in a header). |
|
149 // ----------------------------------------------------------------------------- |
|
150 // |
|
151 COMASuplInfoRequestList& COMASuplGetSuplInfoManager::CreateRequestListL() |
|
152 { |
|
153 return CreateRequestListL(iSetCapReqCount, iReqAsstDataCount |
|
154 , iPositionCount, iVelocityCount, iPayLoadCount); |
|
155 } |
|
156 |
|
157 // ----------------------------------------------------------------------------- |
|
158 // COMASuplGetSuplInfoManager::ValidateAndSetArguments |
|
159 // (other items were commented in a header). |
|
160 // ----------------------------------------------------------------------------- |
|
161 // |
|
162 void COMASuplGetSuplInfoManager::ValidateAndSetArguments( |
|
163 TInt& aSetCapReqCount |
|
164 , TInt& aReqAsstDataCount |
|
165 , TInt& aPositionCount |
|
166 , TInt& aVelocityCount |
|
167 , TInt& aPayLoadCount ) |
|
168 { |
|
169 //validate aSetCapReqCount |
|
170 ValidateAndSetArguments(aSetCapReqCount, KValueofSetCapCount |
|
171 , iSetCapReqCount); |
|
172 |
|
173 //validate aReqAsstDataCount |
|
174 ValidateAndSetArguments(aReqAsstDataCount, KValueOfReqAsstDataCount |
|
175 , iReqAsstDataCount); |
|
176 |
|
177 //validate aPositionCount |
|
178 ValidateAndSetArguments(aPositionCount,KValueOfPositionCount |
|
179 , iPositionCount); |
|
180 |
|
181 //validate aVelocityCount |
|
182 ValidateAndSetArguments(aVelocityCount, KValueOfVelocityCount |
|
183 , iVelocityCount); |
|
184 |
|
185 //validate aPayLoadCount |
|
186 ValidateAndSetArguments(aPayLoadCount, KValueOfPayloadCount |
|
187 , iPayLoadCount); |
|
188 } |
|
189 |
|
190 // ----------------------------------------------------------------------------- |
|
191 // COMASuplGetSuplInfoManager::ValidateAndSetArguments |
|
192 // (other items were commented in a header). |
|
193 // ----------------------------------------------------------------------------- |
|
194 // |
|
195 void COMASuplGetSuplInfoManager::ValidateAndSetArguments( |
|
196 TInt& aObjCount |
|
197 , const TDesC8& aMsg |
|
198 , TInt& aForNextReq) |
|
199 { |
|
200 if(aObjCount > 1) |
|
201 { |
|
202 iInfo++; |
|
203 aObjCount = 1; |
|
204 iLogger->WriteStatus(aMsg, aObjCount, iTestNo, &KNULL()); |
|
205 } |
|
206 else if(aObjCount < 0) |
|
207 { |
|
208 aObjCount = 0; |
|
209 iInfo++; |
|
210 iLogger->WriteStatus(aMsg, aObjCount, iTestNo, &KNULL()); |
|
211 } |
|
212 else |
|
213 { |
|
214 //Do nothing |
|
215 } |
|
216 aForNextReq = aObjCount; |
|
217 } |
|
218 |
|
219 // ----------------------------------------------------------------------------- |
|
220 // COMASuplGetSuplInfoManager::ResetLists |
|
221 // (other items were commented in a header). |
|
222 // ----------------------------------------------------------------------------- |
|
223 // |
|
224 void COMASuplGetSuplInfoManager::ResetLists() |
|
225 { |
|
226 if(iRequestList) |
|
227 { |
|
228 delete iRequestList; |
|
229 } |
|
230 iRequestList = NULL; |
|
231 if(iCreatedTypeSeq) |
|
232 { |
|
233 delete iCreatedTypeSeq; |
|
234 } |
|
235 iCreatedTypeSeq = NULL; |
|
236 } |
|
237 |
|
238 // ----------------------------------------------------------------------------- |
|
239 // COMASuplGetSuplInfoManager::MatchLists |
|
240 // (other items were commented in a header). |
|
241 // ----------------------------------------------------------------------------- |
|
242 // |
|
243 TBool COMASuplGetSuplInfoManager::MatchLists(TInt& aDiffIndex) |
|
244 { |
|
245 if(iCreatedTypeSeq->Count() != iRequestList->GetCount()) |
|
246 { |
|
247 aDiffIndex = 0; |
|
248 return EFalse; |
|
249 } |
|
250 |
|
251 for(TInt count = 0; count < iCreatedTypeSeq->Count(); count++) |
|
252 { |
|
253 TInt typeSeq = iCreatedTypeSeq->At(count); |
|
254 TInt reqEltType = iRequestList->GetElement(count)->Type(); |
|
255 if(typeSeq != reqEltType) |
|
256 { |
|
257 aDiffIndex = count; |
|
258 return EFalse; |
|
259 } |
|
260 } |
|
261 |
|
262 return ETrue; |
|
263 } |