748
|
1 |
// Copyright (c) 2001-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 the License "Symbian Foundation License v1.0"
|
|
5 |
// which accompanies this distribution, and is available
|
|
6 |
// at the URL "http://www.symbianfoundation.org/legal/sfl-v10.html".
|
|
7 |
//
|
|
8 |
// Initial Contributors:
|
|
9 |
// Nokia Corporation - initial contribution.
|
|
10 |
//
|
|
11 |
// Contributors:
|
|
12 |
//
|
|
13 |
// Description:
|
|
14 |
//
|
|
15 |
|
|
16 |
|
|
17 |
|
|
18 |
// INCLUDES
|
|
19 |
#include "ctlbsclientpostp261.h"
|
|
20 |
#include <s32strm.h>
|
|
21 |
#include <s32mem.h>
|
|
22 |
|
|
23 |
// CONSTANTS
|
|
24 |
|
|
25 |
// LOCAL FUNCTIONS
|
|
26 |
void CleanOp(TAny* aAnArray)
|
|
27 |
{
|
|
28 |
// Cleanup function the requestor stack
|
|
29 |
RRequestorStack* theStack = reinterpret_cast <RRequestorStack*> (aAnArray);
|
|
30 |
theStack->ResetAndDestroy();
|
|
31 |
}
|
|
32 |
|
|
33 |
// ================= MEMBER FUNCTIONS =======================
|
|
34 |
|
|
35 |
|
|
36 |
// ---------------------------------------------------------
|
|
37 |
// Constructor.
|
|
38 |
// ---------------------------------------------------------
|
|
39 |
CT_LbsClientPosTp261::CT_LbsClientPosTp261(CT_LbsServer& aParent): CT_LbsPortedStepBase(aParent)
|
|
40 |
{
|
|
41 |
_LIT(KTestName,"Tp261 - RequestorStack Externalize/Internalize");
|
|
42 |
SetTestStepName(KTestName);
|
|
43 |
}
|
|
44 |
|
|
45 |
// ---------------------------------------------------------
|
|
46 |
// Destructor.
|
|
47 |
// ---------------------------------------------------------
|
|
48 |
CT_LbsClientPosTp261::~CT_LbsClientPosTp261()
|
|
49 |
{
|
|
50 |
}
|
|
51 |
|
|
52 |
// ---------------------------------------------------------
|
|
53 |
// CT_LbsClientPosTp261::CloseTest
|
|
54 |
//
|
|
55 |
// (other items were commented in a header).
|
|
56 |
// ---------------------------------------------------------
|
|
57 |
//
|
|
58 |
void CT_LbsClientPosTp261::CloseTest()
|
|
59 |
{
|
|
60 |
ClosePositioner();
|
|
61 |
Disconnect();
|
|
62 |
}
|
|
63 |
|
|
64 |
// ---------------------------------------------------------
|
|
65 |
// CT_LbsClientPosTp261::StartL
|
|
66 |
//
|
|
67 |
// (other items were commented in a header).
|
|
68 |
// ---------------------------------------------------------
|
|
69 |
//
|
|
70 |
void CT_LbsClientPosTp261::StartL()
|
|
71 |
{
|
|
72 |
_LIT(KService1, "Service1");
|
|
73 |
_LIT(KService2, "Service2");
|
|
74 |
_LIT(KService3, "Service3");
|
|
75 |
|
|
76 |
_LIT(KContact1, "Contact1");
|
|
77 |
_LIT(KContact2, "Contact2");
|
|
78 |
_LIT(KContact3, "Contact3");
|
|
79 |
|
|
80 |
CRequestor* serviceId1 =
|
|
81 |
CRequestor::NewL(CRequestor::ERequestorService, CRequestor::EFormatApplication,
|
|
82 |
KService1);
|
|
83 |
|
|
84 |
CRequestor* serviceId2 =
|
|
85 |
CRequestor::NewL(CRequestor::ERequestorService, CRequestor::EFormatApplication,
|
|
86 |
KService2);
|
|
87 |
|
|
88 |
CRequestor* serviceId3 =
|
|
89 |
CRequestor::NewL(CRequestor::ERequestorService, CRequestor::EFormatApplication,
|
|
90 |
KService3);
|
|
91 |
|
|
92 |
CRequestor* contactId1 =
|
|
93 |
CRequestor::NewL(CRequestor::ERequestorContact, CRequestor::EFormatTelephone,
|
|
94 |
KContact1);
|
|
95 |
|
|
96 |
CRequestor* contactId2 =
|
|
97 |
CRequestor::NewL(CRequestor::ERequestorContact, CRequestor::EFormatUrl,
|
|
98 |
KContact2);
|
|
99 |
|
|
100 |
CRequestor* contactId3 =
|
|
101 |
CRequestor::NewL(CRequestor::ERequestorContact, CRequestor::EFormatMail,
|
|
102 |
KContact3);
|
|
103 |
|
|
104 |
RRequestorStack stack = RRequestorStack();
|
|
105 |
CleanupStack::PushL(TCleanupItem(CleanOp ,&stack));
|
|
106 |
|
|
107 |
CleanupStack::PushL(serviceId1);
|
|
108 |
CleanupStack::PushL(serviceId2);
|
|
109 |
CleanupStack::PushL(serviceId3);
|
|
110 |
CleanupStack::PushL(contactId1);
|
|
111 |
CleanupStack::PushL(contactId2);
|
|
112 |
CleanupStack::PushL(contactId3);
|
|
113 |
|
|
114 |
ConnectL();
|
|
115 |
OpenPositioner();
|
|
116 |
|
|
117 |
stack.Append(serviceId1);
|
|
118 |
stack.Append(contactId1);
|
|
119 |
stack.Append(contactId2);
|
|
120 |
stack.Append(serviceId2);
|
|
121 |
stack.Append(contactId3);
|
|
122 |
stack.Append(serviceId3);
|
|
123 |
|
|
124 |
CleanupStack::Pop(contactId3);
|
|
125 |
CleanupStack::Pop(contactId2);
|
|
126 |
CleanupStack::Pop(contactId1);
|
|
127 |
CleanupStack::Pop(serviceId3);
|
|
128 |
CleanupStack::Pop(serviceId2);
|
|
129 |
CleanupStack::Pop(serviceId1);
|
|
130 |
|
|
131 |
TInt err = iPositioner.SetRequestor(stack);
|
|
132 |
if (err != KErrNone)
|
|
133 |
{
|
|
134 |
_LIT(KErrorAndLeave, "Problems setting requestorstack");
|
|
135 |
LogErrorAndLeaveL(KErrorAndLeave);
|
|
136 |
}
|
|
137 |
|
|
138 |
const TInt KPosBufFlatExpandSize = 100;
|
|
139 |
|
|
140 |
//ExternalizeL
|
|
141 |
CBufFlat* bufFlat = CBufFlat::NewL(KPosBufFlatExpandSize);
|
|
142 |
CleanupStack::PushL(bufFlat);
|
|
143 |
|
|
144 |
RBufWriteStream stream(*bufFlat);
|
|
145 |
CleanupClosePushL(stream);
|
|
146 |
stack.ExternalizeL(stream);
|
|
147 |
|
|
148 |
TPtr8 dataPtr((TUint8*)NULL, 0);
|
|
149 |
dataPtr.Set(bufFlat->Ptr(0));
|
|
150 |
|
|
151 |
CleanupStack::PopAndDestroy(&stream);
|
|
152 |
|
|
153 |
HBufC8* tempBuf = HBufC8::NewLC(bufFlat->Size());
|
|
154 |
TPtr8 ptr = tempBuf->Des();
|
|
155 |
ptr = dataPtr;
|
|
156 |
|
|
157 |
//Internalize
|
|
158 |
bufFlat->InsertL(0, ptr);
|
|
159 |
|
|
160 |
RBufReadStream rstream(*bufFlat);
|
|
161 |
CleanupClosePushL(rstream);
|
|
162 |
|
|
163 |
RRequestorStack stack2 = RRequestorStack();
|
|
164 |
CleanupStack::PushL(TCleanupItem(CleanOp ,&stack2));
|
|
165 |
|
|
166 |
stack2.InternalizeL(rstream);
|
|
167 |
|
|
168 |
// Verify the requestor stack
|
|
169 |
VerifyRequestorStackL(stack2);
|
|
170 |
_LIT(KResult, "The RequestorStack is correct after Externalize/Internalize");
|
|
171 |
INFO_PRINTF1(KResult);
|
|
172 |
|
|
173 |
CleanupStack::PopAndDestroy(1); // CleanupOp stack2
|
|
174 |
|
|
175 |
CleanupStack::PopAndDestroy(&rstream);
|
|
176 |
CleanupStack::PopAndDestroy(tempBuf);
|
|
177 |
CleanupStack::PopAndDestroy(bufFlat);
|
|
178 |
CleanupStack::PopAndDestroy(1); // CleanupOp stack1
|
|
179 |
|
|
180 |
ClosePositioner();
|
|
181 |
Disconnect();
|
|
182 |
}
|
|
183 |
|
|
184 |
// ---------------------------------------------------------
|
|
185 |
// CT_LbsClientPosTp261::VerifyRequestorStackL
|
|
186 |
//
|
|
187 |
// (other items were commented in a header).
|
|
188 |
// ---------------------------------------------------------
|
|
189 |
//
|
|
190 |
void CT_LbsClientPosTp261::VerifyRequestorStackL(RRequestorStack& aStack)
|
|
191 |
{
|
|
192 |
TInt count = aStack.Count();
|
|
193 |
|
|
194 |
_LIT(KService1, "Service1");
|
|
195 |
_LIT(KService2, "Service2");
|
|
196 |
_LIT(KService3, "Service3");
|
|
197 |
|
|
198 |
_LIT(KContact1, "Contact1");
|
|
199 |
_LIT(KContact2, "Contact2");
|
|
200 |
_LIT(KContact3, "Contact3");
|
|
201 |
|
|
202 |
// Hardcoded number of requestors
|
|
203 |
if (count != 6)
|
|
204 |
{
|
|
205 |
_LIT(KErrorAndLeave, "Wrong number of requestors in the stack");
|
|
206 |
LogErrorAndLeaveL(KErrorAndLeave);
|
|
207 |
}
|
|
208 |
|
|
209 |
if (aStack[0]->RequestorType() != CRequestor::ERequestorService
|
|
210 |
|| aStack[0]->RequestorFormat() != CRequestor::EFormatApplication
|
|
211 |
|| aStack[0]->RequestorData() != KService1)
|
|
212 |
{
|
|
213 |
_LIT(KErrorAndLeave, "Wrong requestor(1) in stack");
|
|
214 |
LogErrorAndLeaveL(KErrorAndLeave);
|
|
215 |
}
|
|
216 |
|
|
217 |
if (aStack[1]->RequestorType() != CRequestor::ERequestorContact
|
|
218 |
|| aStack[1]->RequestorFormat() != CRequestor::EFormatTelephone
|
|
219 |
|| aStack[1]->RequestorData() != KContact1)
|
|
220 |
{
|
|
221 |
_LIT(KErrorAndLeave, "Wrong requestor(2) in stack");
|
|
222 |
LogErrorAndLeaveL(KErrorAndLeave);
|
|
223 |
}
|
|
224 |
|
|
225 |
if (aStack[2]->RequestorType() != CRequestor::ERequestorContact
|
|
226 |
|| aStack[2]->RequestorFormat() != CRequestor::EFormatUrl
|
|
227 |
|| aStack[2]->RequestorData() != KContact2)
|
|
228 |
{
|
|
229 |
_LIT(KErrorAndLeave, "Wrong requestor(3) in stack");
|
|
230 |
LogErrorAndLeaveL(KErrorAndLeave);
|
|
231 |
}
|
|
232 |
|
|
233 |
if (aStack[3]->RequestorType() != CRequestor::ERequestorService
|
|
234 |
|| aStack[3]->RequestorFormat() != CRequestor::EFormatApplication
|
|
235 |
|| aStack[3]->RequestorData() != KService2)
|
|
236 |
{
|
|
237 |
_LIT(KErrorAndLeave, "Wrong requestor(4) in stack");
|
|
238 |
LogErrorAndLeaveL(KErrorAndLeave);
|
|
239 |
}
|
|
240 |
|
|
241 |
if (aStack[4]->RequestorType() != CRequestor::ERequestorContact
|
|
242 |
|| aStack[4]->RequestorFormat() != CRequestor::EFormatMail
|
|
243 |
|| aStack[4]->RequestorData() != KContact3)
|
|
244 |
{
|
|
245 |
_LIT(KErrorAndLeave, "Wrong requestor(5) in stack");
|
|
246 |
LogErrorAndLeaveL(KErrorAndLeave);
|
|
247 |
}
|
|
248 |
|
|
249 |
if (aStack[5]->RequestorType() != CRequestor::ERequestorService
|
|
250 |
|| aStack[5]->RequestorFormat() != CRequestor::EFormatApplication
|
|
251 |
|| aStack[5]->RequestorData() != KService3)
|
|
252 |
{
|
|
253 |
_LIT(KErrorAndLeave, "Wrong requestor(6) in stack");
|
|
254 |
LogErrorAndLeaveL(KErrorAndLeave);
|
|
255 |
}
|
|
256 |
}
|