sl@0
|
1 |
/*
|
sl@0
|
2 |
* Copyright (c) 2003-2009 Nokia Corporation and/or its subsidiary(-ies).
|
sl@0
|
3 |
* All rights reserved.
|
sl@0
|
4 |
* This component and the accompanying materials are made available
|
sl@0
|
5 |
* under the terms of the License "Eclipse Public License v1.0"
|
sl@0
|
6 |
* which accompanies this distribution, and is available
|
sl@0
|
7 |
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
sl@0
|
8 |
*
|
sl@0
|
9 |
* Initial Contributors:
|
sl@0
|
10 |
* Nokia Corporation - initial contribution.
|
sl@0
|
11 |
*
|
sl@0
|
12 |
* Contributors:
|
sl@0
|
13 |
*
|
sl@0
|
14 |
* Description:
|
sl@0
|
15 |
*
|
sl@0
|
16 |
*/
|
sl@0
|
17 |
|
sl@0
|
18 |
|
sl@0
|
19 |
#include <test/testexecutelog.h>
|
sl@0
|
20 |
#include <caf/content.h>
|
sl@0
|
21 |
#include <caf/data.h>
|
sl@0
|
22 |
#include <caf/attribute.h>
|
sl@0
|
23 |
#include "cafserver.h"
|
sl@0
|
24 |
#include "bitset.h"
|
sl@0
|
25 |
#include "Consumerstep.h"
|
sl@0
|
26 |
#include "attributeset.h"
|
sl@0
|
27 |
#include "stringattributeset.h"
|
sl@0
|
28 |
#include <caf/virtualpath.h>
|
sl@0
|
29 |
#include <e32hal.h>
|
sl@0
|
30 |
#include <hal.h>
|
sl@0
|
31 |
|
sl@0
|
32 |
using namespace ContentAccess;
|
sl@0
|
33 |
|
sl@0
|
34 |
const TInt KCafTestMaxDataTypeLength = 255;
|
sl@0
|
35 |
const TInt KCafTestSecToMS = 1000;
|
sl@0
|
36 |
|
sl@0
|
37 |
_LIT(KCDataThreadSemaphore, "CData_Thread_Test");
|
sl@0
|
38 |
|
sl@0
|
39 |
/*
|
sl@0
|
40 |
* Step1 compares an agent 'size' call with that obtained by RFile
|
sl@0
|
41 |
*
|
sl@0
|
42 |
*/
|
sl@0
|
43 |
|
sl@0
|
44 |
CCAFSizeStep::~CCAFSizeStep()
|
sl@0
|
45 |
{
|
sl@0
|
46 |
}
|
sl@0
|
47 |
|
sl@0
|
48 |
CCAFSizeStep::CCAFSizeStep(CCAFServer& aParent)
|
sl@0
|
49 |
: iParent(aParent)
|
sl@0
|
50 |
{
|
sl@0
|
51 |
SetTestStepName(KCAFSizeStep);
|
sl@0
|
52 |
}
|
sl@0
|
53 |
|
sl@0
|
54 |
TVerdict CCAFSizeStep::doTestStepL()
|
sl@0
|
55 |
{
|
sl@0
|
56 |
__UHEAP_MARK;
|
sl@0
|
57 |
|
sl@0
|
58 |
SetTestStepResult(EInconclusive);
|
sl@0
|
59 |
|
sl@0
|
60 |
INFO_PRINTF1(_L("Basic Open Content Test"));
|
sl@0
|
61 |
|
sl@0
|
62 |
TPtrC uri1;
|
sl@0
|
63 |
TPtrC uri2;
|
sl@0
|
64 |
GetStringFromConfig(ConfigSection(),_L("URI1"),uri1);
|
sl@0
|
65 |
GetStringFromConfig(ConfigSection(),_L("URI2"),uri2);
|
sl@0
|
66 |
|
sl@0
|
67 |
INFO_PRINTF2(_L("Creating CContent object with uri: %S"), &uri1);
|
sl@0
|
68 |
CContent* content = CContent::NewLC(uri1);
|
sl@0
|
69 |
INFO_PRINTF1(_L("Creating CData object from content"));
|
sl@0
|
70 |
|
sl@0
|
71 |
CData* data = content->OpenContentL(EPeek);
|
sl@0
|
72 |
CleanupStack::PushL(data);
|
sl@0
|
73 |
|
sl@0
|
74 |
TInt size = 0;
|
sl@0
|
75 |
data->DataSizeL(size);
|
sl@0
|
76 |
INFO_PRINTF2(_L("Size of content from caf CContent::OpenContentL(): %d"),size);
|
sl@0
|
77 |
CleanupStack::PopAndDestroy(data);
|
sl@0
|
78 |
CleanupStack::PopAndDestroy(content);
|
sl@0
|
79 |
|
sl@0
|
80 |
INFO_PRINTF2(_L("Creating CData object with uri: %S"), &uri1);
|
sl@0
|
81 |
TInt size1 = 0;
|
sl@0
|
82 |
|
sl@0
|
83 |
TBool withoutIntent;
|
sl@0
|
84 |
if (!GetBoolFromConfig(ConfigSection(),_L("WITHOUTINTENT"),withoutIntent))
|
sl@0
|
85 |
{
|
sl@0
|
86 |
INFO_PRINTF1(_L("With Intent"));
|
sl@0
|
87 |
data = CData::NewL(TVirtualPathPtr(uri1), EPeek, EContentShareReadOnly);
|
sl@0
|
88 |
}
|
sl@0
|
89 |
else
|
sl@0
|
90 |
{
|
sl@0
|
91 |
INFO_PRINTF1(_L("Without Intent"));
|
sl@0
|
92 |
data = CData::NewL(TVirtualPathPtr(uri1), EContentShareReadOnly);
|
sl@0
|
93 |
data->SetProperty(EAgentPropertyAgentUI, 0);
|
sl@0
|
94 |
User::LeaveIfError(data->EvaluateIntent(EPeek));
|
sl@0
|
95 |
}
|
sl@0
|
96 |
|
sl@0
|
97 |
CleanupStack::PushL(data);
|
sl@0
|
98 |
data->DataSizeL(size1);
|
sl@0
|
99 |
INFO_PRINTF2(_L("Size of content from caf CData::NewL(): %d"),size1);
|
sl@0
|
100 |
CleanupStack::PopAndDestroy(data);
|
sl@0
|
101 |
|
sl@0
|
102 |
INFO_PRINTF2(_L("Opening standard RFile interface with uri: %S"),&uri2);
|
sl@0
|
103 |
RFile file;
|
sl@0
|
104 |
User::LeaveIfError(file.Open(iParent.Fs(), uri2, EFileRead));
|
sl@0
|
105 |
|
sl@0
|
106 |
TInt size2;
|
sl@0
|
107 |
file.Size(size2);
|
sl@0
|
108 |
file.Close();
|
sl@0
|
109 |
|
sl@0
|
110 |
INFO_PRINTF2(_L("Size of content from f32: %d"),size2);
|
sl@0
|
111 |
|
sl@0
|
112 |
if(size == size2 && size == size1)
|
sl@0
|
113 |
{
|
sl@0
|
114 |
SetTestStepResult(EPass);
|
sl@0
|
115 |
}
|
sl@0
|
116 |
else
|
sl@0
|
117 |
{
|
sl@0
|
118 |
SetTestStepResult(EFail);
|
sl@0
|
119 |
}
|
sl@0
|
120 |
|
sl@0
|
121 |
__UHEAP_MARKEND;
|
sl@0
|
122 |
return TestStepResult();
|
sl@0
|
123 |
}
|
sl@0
|
124 |
|
sl@0
|
125 |
#ifdef SYMBIAN_ENABLE_64_BIT_FILE_SERVER_API
|
sl@0
|
126 |
/*
|
sl@0
|
127 |
* This is the 64bit version of CCAFSizeStep
|
sl@0
|
128 |
*/
|
sl@0
|
129 |
|
sl@0
|
130 |
CCAFSizeStep64::~CCAFSizeStep64()
|
sl@0
|
131 |
{
|
sl@0
|
132 |
}
|
sl@0
|
133 |
|
sl@0
|
134 |
CCAFSizeStep64::CCAFSizeStep64(CCAFServer& aParent)
|
sl@0
|
135 |
: iParent(aParent)
|
sl@0
|
136 |
{
|
sl@0
|
137 |
SetTestStepName(KCAFSizeStep);
|
sl@0
|
138 |
}
|
sl@0
|
139 |
|
sl@0
|
140 |
TVerdict CCAFSizeStep64::doTestStepL()
|
sl@0
|
141 |
{
|
sl@0
|
142 |
__UHEAP_MARK;
|
sl@0
|
143 |
|
sl@0
|
144 |
SetTestStepResult(EInconclusive);
|
sl@0
|
145 |
|
sl@0
|
146 |
INFO_PRINTF1(_L("Basic Open Content Test"));
|
sl@0
|
147 |
|
sl@0
|
148 |
TPtrC uri1;
|
sl@0
|
149 |
TPtrC uri2;
|
sl@0
|
150 |
GetStringFromConfig(ConfigSection(),_L("URI1"),uri1);
|
sl@0
|
151 |
GetStringFromConfig(ConfigSection(),_L("URI2"),uri2);
|
sl@0
|
152 |
|
sl@0
|
153 |
INFO_PRINTF2(_L("Creating CContent object with uri: %S"), &uri1);
|
sl@0
|
154 |
CContent* content = CContent::NewLC(uri1);
|
sl@0
|
155 |
INFO_PRINTF1(_L("Creating CData object from content"));
|
sl@0
|
156 |
|
sl@0
|
157 |
CData* data = content->OpenContentL(EPeek);
|
sl@0
|
158 |
CleanupStack::PushL(data);
|
sl@0
|
159 |
|
sl@0
|
160 |
TInt64 size = 0;
|
sl@0
|
161 |
data->DataSize64L(size);
|
sl@0
|
162 |
INFO_PRINTF2(_L("Size of content from caf CContent::OpenContentL(): %Ld"),size);
|
sl@0
|
163 |
CleanupStack::PopAndDestroy(data);
|
sl@0
|
164 |
CleanupStack::PopAndDestroy(content);
|
sl@0
|
165 |
|
sl@0
|
166 |
INFO_PRINTF2(_L("Creating CData object with uri: %S"), &uri1);
|
sl@0
|
167 |
TInt64 size1 = 0;
|
sl@0
|
168 |
|
sl@0
|
169 |
TBool withoutIntent;
|
sl@0
|
170 |
if (!GetBoolFromConfig(ConfigSection(),_L("WITHOUTINTENT"),withoutIntent))
|
sl@0
|
171 |
{
|
sl@0
|
172 |
INFO_PRINTF1(_L("With Intent"));
|
sl@0
|
173 |
data = CData::NewL(TVirtualPathPtr(uri1), EPeek, EContentShareReadOnly);
|
sl@0
|
174 |
}
|
sl@0
|
175 |
else
|
sl@0
|
176 |
{
|
sl@0
|
177 |
INFO_PRINTF1(_L("Without Intent"));
|
sl@0
|
178 |
data = CData::NewL(TVirtualPathPtr(uri1), EContentShareReadOnly);
|
sl@0
|
179 |
data->SetProperty(EAgentPropertyAgentUI, 0);
|
sl@0
|
180 |
User::LeaveIfError(data->EvaluateIntent(EPeek));
|
sl@0
|
181 |
}
|
sl@0
|
182 |
|
sl@0
|
183 |
CleanupStack::PushL(data);
|
sl@0
|
184 |
data->DataSize64L(size1);
|
sl@0
|
185 |
INFO_PRINTF2(_L("Size of content from caf CData::NewL(): %Ld"),size1);
|
sl@0
|
186 |
CleanupStack::PopAndDestroy(data);
|
sl@0
|
187 |
|
sl@0
|
188 |
INFO_PRINTF2(_L("Opening standard RFile interface with uri: %S"),&uri2);
|
sl@0
|
189 |
RFile64 file;
|
sl@0
|
190 |
User::LeaveIfError(file.Open(iParent.Fs(), uri2, EFileRead));
|
sl@0
|
191 |
|
sl@0
|
192 |
TInt64 size2;
|
sl@0
|
193 |
file.Size(size2);
|
sl@0
|
194 |
file.Close();
|
sl@0
|
195 |
|
sl@0
|
196 |
INFO_PRINTF2(_L("Size of content from f32: %Ld"),size2);
|
sl@0
|
197 |
|
sl@0
|
198 |
if(size == size2 && size == size1)
|
sl@0
|
199 |
{
|
sl@0
|
200 |
SetTestStepResult(EPass);
|
sl@0
|
201 |
}
|
sl@0
|
202 |
else
|
sl@0
|
203 |
{
|
sl@0
|
204 |
SetTestStepResult(EFail);
|
sl@0
|
205 |
}
|
sl@0
|
206 |
|
sl@0
|
207 |
__UHEAP_MARKEND;
|
sl@0
|
208 |
return TestStepResult();
|
sl@0
|
209 |
}
|
sl@0
|
210 |
#endif // SYMBIAN_ENABLE_64_BIT_FILE_SERVER_API
|
sl@0
|
211 |
|
sl@0
|
212 |
/*
|
sl@0
|
213 |
* This step compares a seek and read using CAF with that using RFile
|
sl@0
|
214 |
*
|
sl@0
|
215 |
*/
|
sl@0
|
216 |
|
sl@0
|
217 |
CCAFSeekReadStep::~CCAFSeekReadStep()
|
sl@0
|
218 |
{
|
sl@0
|
219 |
}
|
sl@0
|
220 |
|
sl@0
|
221 |
CCAFSeekReadStep::CCAFSeekReadStep(CCAFServer& aParent)
|
sl@0
|
222 |
: iParent(aParent)
|
sl@0
|
223 |
{
|
sl@0
|
224 |
SetTestStepName(KCAFSeekReadStep);
|
sl@0
|
225 |
}
|
sl@0
|
226 |
|
sl@0
|
227 |
void CCAFSeekReadStep::StandardCheckReturnValue(TInt aReturnValue)
|
sl@0
|
228 |
{
|
sl@0
|
229 |
if (aReturnValue != KErrNone)
|
sl@0
|
230 |
{
|
sl@0
|
231 |
INFO_PRINTF2(_L("ERROR Unexpected return value: %d"),aReturnValue);
|
sl@0
|
232 |
SetTestStepResult(EFail);
|
sl@0
|
233 |
}
|
sl@0
|
234 |
}
|
sl@0
|
235 |
TVerdict CCAFSeekReadStep::doTestStepL()
|
sl@0
|
236 |
{
|
sl@0
|
237 |
SetTestStepResult(EInconclusive);
|
sl@0
|
238 |
|
sl@0
|
239 |
TBuf8<2> buf1;
|
sl@0
|
240 |
TBuf8<2> buf2;
|
sl@0
|
241 |
TRequestStatus status;
|
sl@0
|
242 |
|
sl@0
|
243 |
__UHEAP_MARK;
|
sl@0
|
244 |
INFO_PRINTF1(_L("Basic Open Content Test"));
|
sl@0
|
245 |
|
sl@0
|
246 |
TPtrC uri1;
|
sl@0
|
247 |
TPtrC uri2;
|
sl@0
|
248 |
GetStringFromConfig(ConfigSection(),_L("URI1"),uri1);
|
sl@0
|
249 |
GetStringFromConfig(ConfigSection(),_L("URI2"),uri2);
|
sl@0
|
250 |
|
sl@0
|
251 |
INFO_PRINTF2(_L("Creating content object with uri: %S"), &uri1);
|
sl@0
|
252 |
CContent* content = CContent::NewLC(uri1);
|
sl@0
|
253 |
|
sl@0
|
254 |
INFO_PRINTF1(_L("Creating data object from content"));
|
sl@0
|
255 |
CData* data = content->OpenContentL(EPeek);
|
sl@0
|
256 |
|
sl@0
|
257 |
// don't need CContent any more
|
sl@0
|
258 |
CleanupStack::PopAndDestroy(content);
|
sl@0
|
259 |
CleanupStack::PushL(data);
|
sl@0
|
260 |
|
sl@0
|
261 |
// Now, open the same file using RFile
|
sl@0
|
262 |
RFile file;
|
sl@0
|
263 |
INFO_PRINTF2(_L("Opening standard RFile interface with uri: %S"),&uri2);
|
sl@0
|
264 |
User::LeaveIfError(file.Open(iParent.Fs(), uri2, EFileRead | EFileShareReadersOnly));
|
sl@0
|
265 |
CleanupClosePushL(file);
|
sl@0
|
266 |
|
sl@0
|
267 |
TInt size = 0;
|
sl@0
|
268 |
file.Size(size);
|
sl@0
|
269 |
INFO_PRINTF2(_L("Size of content from f32: %d"),size);
|
sl@0
|
270 |
|
sl@0
|
271 |
// Seek and read from start using both CAF and RFile
|
sl@0
|
272 |
TInt pos1 = size/4;
|
sl@0
|
273 |
data->Seek(ESeekStart, pos1);
|
sl@0
|
274 |
TInt pos2 = size/4;
|
sl@0
|
275 |
file.Seek(ESeekStart, pos2);
|
sl@0
|
276 |
data->Read(buf1);
|
sl@0
|
277 |
file.Read(buf2);
|
sl@0
|
278 |
INFO_PRINTF2(_L("Position from ESeekStart test using CData: %d"), pos1);
|
sl@0
|
279 |
INFO_PRINTF2(_L("Position from ESeekStart test using RFile: %d"), pos2);
|
sl@0
|
280 |
if (buf1 != buf2 || pos1 != pos2 || pos1 != size/4)
|
sl@0
|
281 |
{
|
sl@0
|
282 |
INFO_PRINTF1(_L("ERROR buffers or position do not match"));
|
sl@0
|
283 |
SetTestStepResult(EFail);
|
sl@0
|
284 |
}
|
sl@0
|
285 |
|
sl@0
|
286 |
// set the location within the file then retrieve the current location within the file
|
sl@0
|
287 |
pos1=0;
|
sl@0
|
288 |
pos2=0;
|
sl@0
|
289 |
data->Seek(ESeekCurrent, pos1);
|
sl@0
|
290 |
file.Seek(ESeekCurrent, pos2);
|
sl@0
|
291 |
|
sl@0
|
292 |
INFO_PRINTF2(_L("Current position using CData: %d"), pos1);
|
sl@0
|
293 |
INFO_PRINTF2(_L("Current position using RFile: %d"), pos2);
|
sl@0
|
294 |
|
sl@0
|
295 |
if(pos1 != pos2 || pos1 != (size/4 + buf1.Length()))
|
sl@0
|
296 |
{
|
sl@0
|
297 |
INFO_PRINTF1(_L("ERROR buffers or position do not match"));
|
sl@0
|
298 |
SetTestStepResult(EFail);
|
sl@0
|
299 |
}
|
sl@0
|
300 |
|
sl@0
|
301 |
// Seek and read from current using both CAF and RFile
|
sl@0
|
302 |
pos1 = size/4;
|
sl@0
|
303 |
data->Seek(ESeekCurrent, pos1);
|
sl@0
|
304 |
pos2 = size/4;
|
sl@0
|
305 |
file.Seek(ESeekCurrent, pos2);
|
sl@0
|
306 |
data->Read(buf1);
|
sl@0
|
307 |
file.Read(buf2);
|
sl@0
|
308 |
INFO_PRINTF2(_L("Position from ESeekCurrent test using CData: %d"), pos1);
|
sl@0
|
309 |
INFO_PRINTF2(_L("Position from ESeekCurrent test using RFile: %d"), pos2);
|
sl@0
|
310 |
if (buf1 != buf2 || pos1 != pos2 || pos1 != (size/2 + buf1.Length()))
|
sl@0
|
311 |
{
|
sl@0
|
312 |
INFO_PRINTF1(_L("ERROR buffers or position do not match"));
|
sl@0
|
313 |
SetTestStepResult(EFail);
|
sl@0
|
314 |
}
|
sl@0
|
315 |
|
sl@0
|
316 |
// Seek and read from end using both CAF and RFile
|
sl@0
|
317 |
pos1 = -size/4;
|
sl@0
|
318 |
data->Seek(ESeekEnd, pos1);
|
sl@0
|
319 |
pos2 = -size/4;
|
sl@0
|
320 |
file.Seek(ESeekEnd, pos2);
|
sl@0
|
321 |
data->Read(buf1);
|
sl@0
|
322 |
file.Read(buf2);
|
sl@0
|
323 |
INFO_PRINTF2(_L("Position from ESeekEnd test using CData: %d"), pos1);
|
sl@0
|
324 |
INFO_PRINTF2(_L("Position from ESeekEnd test using RFile: %d"), pos2);
|
sl@0
|
325 |
if (buf1 != buf2 || pos1 != pos2 || pos1 != (size - size/4))
|
sl@0
|
326 |
{
|
sl@0
|
327 |
INFO_PRINTF1(_L("ERROR buffers or position do not match"));
|
sl@0
|
328 |
SetTestStepResult(EFail);
|
sl@0
|
329 |
}
|
sl@0
|
330 |
|
sl@0
|
331 |
// Test other overloaded forms of CData::Read
|
sl@0
|
332 |
|
sl@0
|
333 |
// Read only 1 byte using both CAF and RFile
|
sl@0
|
334 |
pos1 = size/4;
|
sl@0
|
335 |
data->Seek(ESeekStart, pos1);
|
sl@0
|
336 |
pos2 = size/4;
|
sl@0
|
337 |
file.Seek(ESeekStart, pos2);
|
sl@0
|
338 |
data->Read(buf1,1);
|
sl@0
|
339 |
file.Read(buf2,1);
|
sl@0
|
340 |
INFO_PRINTF2(_L("Data Length from CData::Read(TDesC& ,TInt Length) : %d"), buf1.Length());
|
sl@0
|
341 |
INFO_PRINTF2(_L("Data Length from RFile::Read(TDesC& , TInt Length): %d"), buf2.Length());
|
sl@0
|
342 |
|
sl@0
|
343 |
pos1=0;
|
sl@0
|
344 |
pos2=0;
|
sl@0
|
345 |
data->Seek(ESeekCurrent, pos1);
|
sl@0
|
346 |
file.Seek(ESeekCurrent,pos2);
|
sl@0
|
347 |
if (buf1 != buf2 || pos1 != pos2 || buf1.Length() != buf2.Length())
|
sl@0
|
348 |
{
|
sl@0
|
349 |
INFO_PRINTF1(_L("ERROR buffers or position do not match"));
|
sl@0
|
350 |
SetTestStepResult(EFail);
|
sl@0
|
351 |
}
|
sl@0
|
352 |
|
sl@0
|
353 |
// Read asynchronously using both CAF and RFile
|
sl@0
|
354 |
INFO_PRINTF1(_L("Asynchronous read from CAF and RFile"));
|
sl@0
|
355 |
pos1 = size/4;
|
sl@0
|
356 |
data->Seek(ESeekStart, pos1);
|
sl@0
|
357 |
pos2 = size/4;
|
sl@0
|
358 |
file.Seek(ESeekStart, pos2);
|
sl@0
|
359 |
status = KRequestPending;
|
sl@0
|
360 |
data->Read(buf1,status);
|
sl@0
|
361 |
User::WaitForRequest(status);
|
sl@0
|
362 |
status = KRequestPending;
|
sl@0
|
363 |
file.Read(buf2,status);
|
sl@0
|
364 |
User::WaitForRequest(status);
|
sl@0
|
365 |
INFO_PRINTF2(_L("Data length from CData::Read(TDesC& ,TRequestStatus& aStatus): %d"), buf1.Length());
|
sl@0
|
366 |
INFO_PRINTF2(_L("Data length from RFile::Read(TDesC& , TRequestStatus& aStatus): %d"), buf2.Length());
|
sl@0
|
367 |
|
sl@0
|
368 |
pos1=0;
|
sl@0
|
369 |
pos2=0;
|
sl@0
|
370 |
data->Seek(ESeekCurrent, pos1);
|
sl@0
|
371 |
file.Seek(ESeekCurrent,pos2);
|
sl@0
|
372 |
if (buf1 != buf2 || pos1 != pos2 || buf1.Length() != buf2.Length())
|
sl@0
|
373 |
{
|
sl@0
|
374 |
INFO_PRINTF1(_L("ERROR buffers or position do not match"));
|
sl@0
|
375 |
SetTestStepResult(EFail);
|
sl@0
|
376 |
}
|
sl@0
|
377 |
|
sl@0
|
378 |
// Read only 1 byte asynchronously using both CAF and RFile
|
sl@0
|
379 |
INFO_PRINTF1(_L("Asynchronous read of 1 byte from CAF and RFile"));
|
sl@0
|
380 |
pos1 = size/4;
|
sl@0
|
381 |
data->Seek(ESeekStart, pos1);
|
sl@0
|
382 |
pos2 = size/4;
|
sl@0
|
383 |
file.Seek(ESeekStart, pos2);
|
sl@0
|
384 |
status = KRequestPending;
|
sl@0
|
385 |
data->Read(buf1,1,status);
|
sl@0
|
386 |
User::WaitForRequest(status);
|
sl@0
|
387 |
status = KRequestPending;
|
sl@0
|
388 |
file.Read(buf2,1, status);
|
sl@0
|
389 |
User::WaitForRequest(status);
|
sl@0
|
390 |
INFO_PRINTF2(_L("Data Length from CData::Read(TDesC& ,TInt Length, TRequestStatus aStatus) : %d"), buf1.Length());
|
sl@0
|
391 |
INFO_PRINTF2(_L("Data Length from RFile::Read(TDesC& , TInt Length, TRequestStatus aStatus): %d"), buf2.Length());
|
sl@0
|
392 |
|
sl@0
|
393 |
pos1=0;
|
sl@0
|
394 |
pos2=0;
|
sl@0
|
395 |
data->Seek(ESeekCurrent, pos1);
|
sl@0
|
396 |
file.Seek(ESeekCurrent,pos2);
|
sl@0
|
397 |
if (buf1 != buf2 || pos1 != pos2 || buf1.Length() != buf2.Length())
|
sl@0
|
398 |
{
|
sl@0
|
399 |
INFO_PRINTF1(_L("ERROR buffers or position do not match"));
|
sl@0
|
400 |
SetTestStepResult(EFail);
|
sl@0
|
401 |
}
|
sl@0
|
402 |
|
sl@0
|
403 |
// read past EOF
|
sl@0
|
404 |
pos1 = size+1;
|
sl@0
|
405 |
pos2 = size+1;
|
sl@0
|
406 |
data->Seek(ESeekStart, pos1);
|
sl@0
|
407 |
file.Seek(ESeekStart, pos2);
|
sl@0
|
408 |
data->Read(buf1);
|
sl@0
|
409 |
file.Read(buf2);
|
sl@0
|
410 |
|
sl@0
|
411 |
if(buf1.Length() != 0 || buf1.Length() != 0)
|
sl@0
|
412 |
{
|
sl@0
|
413 |
INFO_PRINTF1(_L("ERROR data read past EOF"));
|
sl@0
|
414 |
SetTestStepResult(EFail);
|
sl@0
|
415 |
}
|
sl@0
|
416 |
|
sl@0
|
417 |
|
sl@0
|
418 |
// Read asynchronously supplying an offset using both CAF and RFile
|
sl@0
|
419 |
TInt err;
|
sl@0
|
420 |
INFO_PRINTF1(_L("Asynchronous read of 1 byte from CAF and RFile supplying an offset within the file"));
|
sl@0
|
421 |
pos1 = size/4;
|
sl@0
|
422 |
pos2 = size/4;
|
sl@0
|
423 |
status = KRequestPending;
|
sl@0
|
424 |
err = data->Read(pos1,buf1,1,status);
|
sl@0
|
425 |
|
sl@0
|
426 |
StandardCheckReturnValue(err);
|
sl@0
|
427 |
|
sl@0
|
428 |
User::WaitForRequest(status);
|
sl@0
|
429 |
status = KRequestPending;
|
sl@0
|
430 |
file.Read(pos2, buf2,1, status);
|
sl@0
|
431 |
User::WaitForRequest(status);
|
sl@0
|
432 |
INFO_PRINTF2(_L("Data Length from CData::Read(TInt aPos, TDesC& , TInt Length, TRequestStatus aStatus) : %d"), buf1.Length());
|
sl@0
|
433 |
INFO_PRINTF2(_L("Data Length from RFile::Read(TInt aPos, TDesC& , TInt Length, TRequestStatus aStatus): %d"), buf2.Length());
|
sl@0
|
434 |
|
sl@0
|
435 |
pos1=0;
|
sl@0
|
436 |
pos2=0;
|
sl@0
|
437 |
data->Seek(ESeekCurrent, pos1);
|
sl@0
|
438 |
file.Seek(ESeekCurrent,pos2);
|
sl@0
|
439 |
if (buf1 !=buf2 || pos1 != pos2 || buf1.Length() != buf2.Length())
|
sl@0
|
440 |
{
|
sl@0
|
441 |
INFO_PRINTF1(_L("ERROR buffers or position do not match"));
|
sl@0
|
442 |
SetTestStepResult(EFail);
|
sl@0
|
443 |
}
|
sl@0
|
444 |
|
sl@0
|
445 |
// Check asynchronous cancellation
|
sl@0
|
446 |
err = 0;
|
sl@0
|
447 |
INFO_PRINTF1(_L("Asynchronous read cancellation using both CAF and RFile with an offset within the file"));
|
sl@0
|
448 |
pos1 = size/4;
|
sl@0
|
449 |
pos2 = size/4;
|
sl@0
|
450 |
status = KRequestPending;
|
sl@0
|
451 |
err = data->Read(pos1,buf1,1,status);
|
sl@0
|
452 |
StandardCheckReturnValue(err);
|
sl@0
|
453 |
data->ReadCancel(status);
|
sl@0
|
454 |
User::WaitForRequest(status);
|
sl@0
|
455 |
TRequestStatus status2(KRequestPending);
|
sl@0
|
456 |
file.Read(pos2, buf2,1, status2);
|
sl@0
|
457 |
file.ReadCancel();
|
sl@0
|
458 |
User::WaitForRequest(status2);
|
sl@0
|
459 |
INFO_PRINTF3(_L("Data Length from CData::Read(TInt aPos, TDesC& , TInt Length, TRequestStatus aStatus) : %d, status is %d"), buf1.Length(), status.Int());
|
sl@0
|
460 |
INFO_PRINTF3(_L("Data Length from RFile::Read(TInt aPos, TDesC& , TInt Length, TRequestStatus aStatus): %d, status is %d"), buf2.Length(), status2.Int());
|
sl@0
|
461 |
if (status.Int() != status2.Int() || buf1 !=buf2 || pos1 != pos2 || buf1.Length() != buf2.Length())
|
sl@0
|
462 |
{
|
sl@0
|
463 |
INFO_PRINTF1(_L("ERROR status, buffers or position do not match"));
|
sl@0
|
464 |
SetTestStepResult(EFail);
|
sl@0
|
465 |
}
|
sl@0
|
466 |
|
sl@0
|
467 |
// read past EOF
|
sl@0
|
468 |
pos1 = size+1;
|
sl@0
|
469 |
pos2 = size+1;
|
sl@0
|
470 |
status = KRequestPending;
|
sl@0
|
471 |
data->Read(pos1,buf1,1,status);
|
sl@0
|
472 |
StandardCheckReturnValue(err);
|
sl@0
|
473 |
User::WaitForRequest(status);
|
sl@0
|
474 |
status = KRequestPending;
|
sl@0
|
475 |
file.Read(pos2,buf2,1,status);
|
sl@0
|
476 |
User::WaitForRequest(status);
|
sl@0
|
477 |
|
sl@0
|
478 |
if(buf1.Length() != 0 || buf1.Length() != 0)
|
sl@0
|
479 |
{
|
sl@0
|
480 |
INFO_PRINTF1(_L("ERROR data read past EOF"));
|
sl@0
|
481 |
SetTestStepResult(EFail);
|
sl@0
|
482 |
}
|
sl@0
|
483 |
|
sl@0
|
484 |
// read over the length of the buffer
|
sl@0
|
485 |
INFO_PRINTF1(_L("Asynchronous read of 5 bytes from CAF and RFile supplying an offset within the file"));
|
sl@0
|
486 |
pos1 = size/4;
|
sl@0
|
487 |
pos2 = size/4;
|
sl@0
|
488 |
status = KRequestPending;
|
sl@0
|
489 |
err = data->Read(pos1,buf1,5,status);
|
sl@0
|
490 |
StandardCheckReturnValue(err);
|
sl@0
|
491 |
User::WaitForRequest(status);
|
sl@0
|
492 |
if(status.Int()!=KErrOverflow)
|
sl@0
|
493 |
{
|
sl@0
|
494 |
INFO_PRINTF2(_L("ERROR Unexpected status returned: %d"),status.Int());
|
sl@0
|
495 |
SetTestStepResult(EFail);
|
sl@0
|
496 |
}
|
sl@0
|
497 |
status = KRequestPending;
|
sl@0
|
498 |
file.Read(pos2, buf2,5, status);
|
sl@0
|
499 |
User::WaitForRequest(status);
|
sl@0
|
500 |
INFO_PRINTF2(_L("Data Length from CData::Read(TInt aPos, TDesC& , TInt Length, TRequestStatus aStatus) : %d"), buf1.Length());
|
sl@0
|
501 |
INFO_PRINTF2(_L("Data Length from RFile::Read(TInt aPos, TDesC& , TInt Length, TRequestStatus aStatus): %d"), buf2.Length());
|
sl@0
|
502 |
|
sl@0
|
503 |
if (buf1 !=buf2 || buf1.Length() != buf2.Length())
|
sl@0
|
504 |
{
|
sl@0
|
505 |
INFO_PRINTF1(_L("ERROR buffers or position do not match"));
|
sl@0
|
506 |
SetTestStepResult(EFail);
|
sl@0
|
507 |
}
|
sl@0
|
508 |
// read negative position this should return KErrArgument, dont supply -ve pos to RFile as will panic test
|
sl@0
|
509 |
INFO_PRINTF1(_L("Asynchronous read from CAF supplying a negative offset within the file"));
|
sl@0
|
510 |
pos1 = -1;
|
sl@0
|
511 |
status = KRequestPending;
|
sl@0
|
512 |
err = data->Read(pos1,buf1,5,status);
|
sl@0
|
513 |
if(err!=KErrArgument)
|
sl@0
|
514 |
{
|
sl@0
|
515 |
INFO_PRINTF2(_L("ERROR Unexpected return value: %d"),err);
|
sl@0
|
516 |
SetTestStepResult(EFail);
|
sl@0
|
517 |
}
|
sl@0
|
518 |
|
sl@0
|
519 |
// Read asynchronously supplying an offset of 0 and a length greater than size of file using both CAF and RFile
|
sl@0
|
520 |
INFO_PRINTF1(_L("Asynchronous read of length greater than size of file from CAF and RFile supplying an offset of 0 within the file"));
|
sl@0
|
521 |
TBuf8<256> buf3;
|
sl@0
|
522 |
TBuf8<256> buf4;
|
sl@0
|
523 |
pos1 = 0;
|
sl@0
|
524 |
pos2 = 0;
|
sl@0
|
525 |
status = KRequestPending;
|
sl@0
|
526 |
err = data->Read(pos1,buf3,size+1,status);
|
sl@0
|
527 |
StandardCheckReturnValue(err);
|
sl@0
|
528 |
User::WaitForRequest(status);
|
sl@0
|
529 |
status = KRequestPending;
|
sl@0
|
530 |
file.Read(pos2, buf4,size+1, status);
|
sl@0
|
531 |
User::WaitForRequest(status);
|
sl@0
|
532 |
INFO_PRINTF2(_L("Data Length from CData::Read(TInt aPos, TDesC& , TInt Length, TRequestStatus aStatus) : %d"), buf3.Size());
|
sl@0
|
533 |
INFO_PRINTF2(_L("Data Length from RFile::Read(TInt aPos, TDesC& , TInt Length, TRequestStatus aStatus): %d"), buf4.Size());
|
sl@0
|
534 |
|
sl@0
|
535 |
pos1=0;
|
sl@0
|
536 |
pos2=0;
|
sl@0
|
537 |
data->Seek(ESeekCurrent, pos1);
|
sl@0
|
538 |
file.Seek(ESeekCurrent,pos2);
|
sl@0
|
539 |
if (buf3 != buf4 || pos1 != pos2 || buf3.Length() != buf4.Length() || pos1 != size ||
|
sl@0
|
540 |
pos2 != size || buf3.Size() != pos1 || buf4.Size() != pos2)
|
sl@0
|
541 |
{
|
sl@0
|
542 |
INFO_PRINTF1(_L("ERROR buffers or position do not match"));
|
sl@0
|
543 |
SetTestStepResult(EFail);
|
sl@0
|
544 |
}
|
sl@0
|
545 |
|
sl@0
|
546 |
// Read asynchronously supplying an offset of size/4 and a length greater than size of file using both CAF and RFile
|
sl@0
|
547 |
INFO_PRINTF1(_L("Asynchronous read of length greater than size of file from CAF and RFile supplying an offset within the file"));
|
sl@0
|
548 |
pos1 = size/4;
|
sl@0
|
549 |
pos2 = size/4;
|
sl@0
|
550 |
status = KRequestPending;
|
sl@0
|
551 |
err = data->Read(pos1,buf3,size+1,status);
|
sl@0
|
552 |
StandardCheckReturnValue(err);
|
sl@0
|
553 |
User::WaitForRequest(status);
|
sl@0
|
554 |
status = KRequestPending;
|
sl@0
|
555 |
file.Read(pos2, buf4,size+1, status);
|
sl@0
|
556 |
User::WaitForRequest(status);
|
sl@0
|
557 |
INFO_PRINTF2(_L("Data Length from CData::Read(TInt aPos, TDesC& , TInt Length, TRequestStatus aStatus) : %d"), buf3.Size());
|
sl@0
|
558 |
INFO_PRINTF2(_L("Data Length from RFile::Read(TInt aPos, TDesC& , TInt Length, TRequestStatus aStatus): %d"), buf4.Size());
|
sl@0
|
559 |
|
sl@0
|
560 |
pos1=0;
|
sl@0
|
561 |
pos2=0;
|
sl@0
|
562 |
data->Seek(ESeekCurrent, pos1);
|
sl@0
|
563 |
file.Seek(ESeekCurrent,pos2);
|
sl@0
|
564 |
if (buf3 != buf4 || pos1 != pos2 || buf3.Size() != buf4.Size() || pos1 != size || pos2 != size)
|
sl@0
|
565 |
{
|
sl@0
|
566 |
INFO_PRINTF1(_L("ERROR buffers or position do not match"));
|
sl@0
|
567 |
SetTestStepResult(EFail);
|
sl@0
|
568 |
}
|
sl@0
|
569 |
|
sl@0
|
570 |
CleanupStack::PopAndDestroy(2, data);
|
sl@0
|
571 |
|
sl@0
|
572 |
__UHEAP_MARKEND;
|
sl@0
|
573 |
|
sl@0
|
574 |
if (TestStepResult() != EFail)
|
sl@0
|
575 |
{
|
sl@0
|
576 |
SetTestStepResult(EPass);
|
sl@0
|
577 |
}
|
sl@0
|
578 |
|
sl@0
|
579 |
return TestStepResult();
|
sl@0
|
580 |
}
|
sl@0
|
581 |
|
sl@0
|
582 |
|
sl@0
|
583 |
#ifdef SYMBIAN_ENABLE_64_BIT_FILE_SERVER_API
|
sl@0
|
584 |
/*
|
sl@0
|
585 |
* This is the 64bit version of CCAFSeekReadStep.
|
sl@0
|
586 |
*/
|
sl@0
|
587 |
|
sl@0
|
588 |
CCAFSeekReadStep64::~CCAFSeekReadStep64()
|
sl@0
|
589 |
{
|
sl@0
|
590 |
}
|
sl@0
|
591 |
|
sl@0
|
592 |
CCAFSeekReadStep64::CCAFSeekReadStep64(CCAFServer& aParent)
|
sl@0
|
593 |
: iParent(aParent)
|
sl@0
|
594 |
{
|
sl@0
|
595 |
SetTestStepName(KCAFSeekReadStep);
|
sl@0
|
596 |
}
|
sl@0
|
597 |
|
sl@0
|
598 |
void CCAFSeekReadStep64::StandardCheckReturnValue(TInt aReturnValue)
|
sl@0
|
599 |
{
|
sl@0
|
600 |
if (aReturnValue != KErrNone)
|
sl@0
|
601 |
{
|
sl@0
|
602 |
INFO_PRINTF2(_L("ERROR Unexpected return value: %d"),aReturnValue);
|
sl@0
|
603 |
SetTestStepResult(EFail);
|
sl@0
|
604 |
}
|
sl@0
|
605 |
}
|
sl@0
|
606 |
TVerdict CCAFSeekReadStep64::doTestStepL()
|
sl@0
|
607 |
{
|
sl@0
|
608 |
SetTestStepResult(EInconclusive);
|
sl@0
|
609 |
|
sl@0
|
610 |
TBuf8<2> buf1;
|
sl@0
|
611 |
TBuf8<2> buf2;
|
sl@0
|
612 |
TRequestStatus status;
|
sl@0
|
613 |
|
sl@0
|
614 |
__UHEAP_MARK;
|
sl@0
|
615 |
INFO_PRINTF1(_L("Basic Open Content Test"));
|
sl@0
|
616 |
|
sl@0
|
617 |
TPtrC uri1;
|
sl@0
|
618 |
TPtrC uri2;
|
sl@0
|
619 |
GetStringFromConfig(ConfigSection(),_L("URI1"),uri1);
|
sl@0
|
620 |
GetStringFromConfig(ConfigSection(),_L("URI2"),uri2);
|
sl@0
|
621 |
|
sl@0
|
622 |
INFO_PRINTF2(_L("Creating content object with uri: %S"), &uri1);
|
sl@0
|
623 |
CContent* content = CContent::NewLC(uri1);
|
sl@0
|
624 |
|
sl@0
|
625 |
INFO_PRINTF1(_L("Creating data object from content"));
|
sl@0
|
626 |
CData* data = content->OpenContentL(EPeek);
|
sl@0
|
627 |
|
sl@0
|
628 |
// don't need CContent any more
|
sl@0
|
629 |
CleanupStack::PopAndDestroy(content);
|
sl@0
|
630 |
CleanupStack::PushL(data);
|
sl@0
|
631 |
|
sl@0
|
632 |
// Now, open the same file using RFile
|
sl@0
|
633 |
RFile64 file;
|
sl@0
|
634 |
INFO_PRINTF2(_L("Opening standard RFile interface with uri: %S"),&uri2);
|
sl@0
|
635 |
User::LeaveIfError(file.Open(iParent.Fs(), uri2, EFileRead | EFileShareReadersOnly));
|
sl@0
|
636 |
CleanupClosePushL(file);
|
sl@0
|
637 |
|
sl@0
|
638 |
TInt64 size = 0;
|
sl@0
|
639 |
file.Size(size);
|
sl@0
|
640 |
INFO_PRINTF2(_L("Size of content from f32: %Ld"),size);
|
sl@0
|
641 |
|
sl@0
|
642 |
// Seek and read from start using both CAF and RFile
|
sl@0
|
643 |
TInt64 pos1 = size/4;
|
sl@0
|
644 |
data->Seek64(ESeekStart, pos1);
|
sl@0
|
645 |
//pos2 needs to be modified to TInt64 when file server supports 64bit
|
sl@0
|
646 |
TInt64 pos2 = size/4;
|
sl@0
|
647 |
file.Seek(ESeekStart, pos2);
|
sl@0
|
648 |
data->Read(buf1);
|
sl@0
|
649 |
file.Read(buf2);
|
sl@0
|
650 |
INFO_PRINTF2(_L("Position from ESeekStart test using CData: %Ld"), pos1);
|
sl@0
|
651 |
INFO_PRINTF2(_L("Position from ESeekStart test using RFile: %Ld"), pos2);
|
sl@0
|
652 |
if (buf1 != buf2 || pos1 != pos2 || pos1 != size/4)
|
sl@0
|
653 |
{
|
sl@0
|
654 |
INFO_PRINTF1(_L("ERROR buffers or position do not match"));
|
sl@0
|
655 |
SetTestStepResult(EFail);
|
sl@0
|
656 |
}
|
sl@0
|
657 |
|
sl@0
|
658 |
// set the location within the file then retrieve the current location within the file
|
sl@0
|
659 |
pos1=0;
|
sl@0
|
660 |
pos2=0;
|
sl@0
|
661 |
data->Seek64(ESeekCurrent, pos1);
|
sl@0
|
662 |
file.Seek(ESeekCurrent, pos2);
|
sl@0
|
663 |
|
sl@0
|
664 |
INFO_PRINTF2(_L("Current position using CData: %Ld"), pos1);
|
sl@0
|
665 |
INFO_PRINTF2(_L("Current position using RFile: %Ld"), pos2);
|
sl@0
|
666 |
|
sl@0
|
667 |
if(pos1 != pos2 || pos1 != (size/4 + buf1.Length()))
|
sl@0
|
668 |
{
|
sl@0
|
669 |
INFO_PRINTF1(_L("ERROR buffers or position do not match"));
|
sl@0
|
670 |
SetTestStepResult(EFail);
|
sl@0
|
671 |
}
|
sl@0
|
672 |
|
sl@0
|
673 |
// Seek and read from current using both CAF and RFile
|
sl@0
|
674 |
pos1 = size/4;
|
sl@0
|
675 |
data->Seek64(ESeekCurrent, pos1);
|
sl@0
|
676 |
pos2 = size/4;
|
sl@0
|
677 |
file.Seek(ESeekCurrent, pos2);
|
sl@0
|
678 |
data->Read(buf1);
|
sl@0
|
679 |
file.Read(buf2);
|
sl@0
|
680 |
INFO_PRINTF2(_L("Position from ESeekCurrent test using CData: %Ld"), pos1);
|
sl@0
|
681 |
INFO_PRINTF2(_L("Position from ESeekCurrent test using RFile: %Ld"), pos2);
|
sl@0
|
682 |
if (buf1 != buf2 || pos1 != pos2 || pos1 != (size/2 + buf1.Length()))
|
sl@0
|
683 |
{
|
sl@0
|
684 |
INFO_PRINTF1(_L("ERROR buffers or position do not match"));
|
sl@0
|
685 |
SetTestStepResult(EFail);
|
sl@0
|
686 |
}
|
sl@0
|
687 |
|
sl@0
|
688 |
// Seek and read from end using both CAF and RFile
|
sl@0
|
689 |
pos1 = -size/4;
|
sl@0
|
690 |
data->Seek64(ESeekEnd, pos1);
|
sl@0
|
691 |
pos2 = -size/4;
|
sl@0
|
692 |
file.Seek(ESeekEnd, pos2);
|
sl@0
|
693 |
data->Read(buf1);
|
sl@0
|
694 |
file.Read(buf2);
|
sl@0
|
695 |
INFO_PRINTF2(_L("Position from ESeekEnd test using CData: %Ld"), pos1);
|
sl@0
|
696 |
INFO_PRINTF2(_L("Position from ESeekEnd test using RFile: %Ld"), pos2);
|
sl@0
|
697 |
if (buf1 != buf2 || pos1 != pos2 || pos1 != (size - size/4))
|
sl@0
|
698 |
{
|
sl@0
|
699 |
INFO_PRINTF1(_L("ERROR buffers or position do not match"));
|
sl@0
|
700 |
SetTestStepResult(EFail);
|
sl@0
|
701 |
}
|
sl@0
|
702 |
|
sl@0
|
703 |
// Test other overloaded forms of CData::Read
|
sl@0
|
704 |
|
sl@0
|
705 |
// Read only 1 byte using both CAF and RFile
|
sl@0
|
706 |
pos1 = size/4;
|
sl@0
|
707 |
data->Seek64(ESeekStart, pos1);
|
sl@0
|
708 |
pos2 = size/4;
|
sl@0
|
709 |
file.Seek(ESeekStart, pos2);
|
sl@0
|
710 |
data->Read(buf1,1);
|
sl@0
|
711 |
file.Read(buf2,1);
|
sl@0
|
712 |
INFO_PRINTF2(_L("Data Length from CData::Read(TDesC& ,TInt Length) : %d"), buf1.Length());
|
sl@0
|
713 |
INFO_PRINTF2(_L("Data Length from RFile::Read(TDesC& , TInt Length): %d"), buf2.Length());
|
sl@0
|
714 |
|
sl@0
|
715 |
pos1=0;
|
sl@0
|
716 |
pos2=0;
|
sl@0
|
717 |
data->Seek64(ESeekCurrent, pos1);
|
sl@0
|
718 |
file.Seek(ESeekCurrent,pos2);
|
sl@0
|
719 |
if (buf1 != buf2 || pos1 != pos2 || buf1.Length() != buf2.Length())
|
sl@0
|
720 |
{
|
sl@0
|
721 |
INFO_PRINTF1(_L("ERROR buffers or position do not match"));
|
sl@0
|
722 |
SetTestStepResult(EFail);
|
sl@0
|
723 |
}
|
sl@0
|
724 |
|
sl@0
|
725 |
// Read asynchronously using both CAF and RFile
|
sl@0
|
726 |
INFO_PRINTF1(_L("Asynchronous read from CAF and RFile"));
|
sl@0
|
727 |
pos1 = size/4;
|
sl@0
|
728 |
data->Seek64(ESeekStart, pos1);
|
sl@0
|
729 |
pos2 = size/4;
|
sl@0
|
730 |
file.Seek(ESeekStart, pos2);
|
sl@0
|
731 |
status = KRequestPending;
|
sl@0
|
732 |
data->Read(buf1,status);
|
sl@0
|
733 |
User::WaitForRequest(status);
|
sl@0
|
734 |
status = KRequestPending;
|
sl@0
|
735 |
file.Read(buf2,status);
|
sl@0
|
736 |
User::WaitForRequest(status);
|
sl@0
|
737 |
INFO_PRINTF2(_L("Data length from CData::Read(TDesC& ,TRequestStatus& aStatus): %d"), buf1.Length());
|
sl@0
|
738 |
INFO_PRINTF2(_L("Data length from RFile::Read(TDesC& , TRequestStatus& aStatus): %d"), buf2.Length());
|
sl@0
|
739 |
|
sl@0
|
740 |
pos1=0;
|
sl@0
|
741 |
pos2=0;
|
sl@0
|
742 |
data->Seek64(ESeekCurrent, pos1);
|
sl@0
|
743 |
file.Seek(ESeekCurrent,pos2);
|
sl@0
|
744 |
if (buf1 != buf2 || pos1 != pos2 || buf1.Length() != buf2.Length())
|
sl@0
|
745 |
{
|
sl@0
|
746 |
INFO_PRINTF1(_L("ERROR buffers or position do not match"));
|
sl@0
|
747 |
SetTestStepResult(EFail);
|
sl@0
|
748 |
}
|
sl@0
|
749 |
|
sl@0
|
750 |
// Read only 1 byte asynchronously using both CAF and RFile
|
sl@0
|
751 |
INFO_PRINTF1(_L("Asynchronous read of 1 byte from CAF and RFile"));
|
sl@0
|
752 |
pos1 = size/4;
|
sl@0
|
753 |
data->Seek64(ESeekStart, pos1);
|
sl@0
|
754 |
pos2 = size/4;
|
sl@0
|
755 |
file.Seek(ESeekStart, pos2);
|
sl@0
|
756 |
status = KRequestPending;
|
sl@0
|
757 |
data->Read(buf1,1,status);
|
sl@0
|
758 |
User::WaitForRequest(status);
|
sl@0
|
759 |
status = KRequestPending;
|
sl@0
|
760 |
file.Read(buf2,1, status);
|
sl@0
|
761 |
User::WaitForRequest(status);
|
sl@0
|
762 |
INFO_PRINTF2(_L("Data Length from CData::Read(TDesC& ,TInt Length, TRequestStatus aStatus) : %d"), buf1.Length());
|
sl@0
|
763 |
INFO_PRINTF2(_L("Data Length from RFile::Read(TDesC& , TInt Length, TRequestStatus aStatus): %d"), buf2.Length());
|
sl@0
|
764 |
|
sl@0
|
765 |
pos1=0;
|
sl@0
|
766 |
pos2=0;
|
sl@0
|
767 |
data->Seek64(ESeekCurrent, pos1);
|
sl@0
|
768 |
file.Seek(ESeekCurrent,pos2);
|
sl@0
|
769 |
if (buf1 != buf2 || pos1 != pos2 || buf1.Length() != buf2.Length())
|
sl@0
|
770 |
{
|
sl@0
|
771 |
INFO_PRINTF1(_L("ERROR buffers or position do not match"));
|
sl@0
|
772 |
SetTestStepResult(EFail);
|
sl@0
|
773 |
}
|
sl@0
|
774 |
|
sl@0
|
775 |
// read past EOF
|
sl@0
|
776 |
pos1 = size+1;
|
sl@0
|
777 |
pos2 = size+1;
|
sl@0
|
778 |
data->Seek64(ESeekStart, pos1);
|
sl@0
|
779 |
file.Seek(ESeekStart, pos2);
|
sl@0
|
780 |
data->Read(buf1);
|
sl@0
|
781 |
file.Read(buf2);
|
sl@0
|
782 |
|
sl@0
|
783 |
if(buf1.Length() != 0 || buf1.Length() != 0)
|
sl@0
|
784 |
{
|
sl@0
|
785 |
INFO_PRINTF1(_L("ERROR data read past EOF"));
|
sl@0
|
786 |
SetTestStepResult(EFail);
|
sl@0
|
787 |
}
|
sl@0
|
788 |
|
sl@0
|
789 |
|
sl@0
|
790 |
// Read asynchronously supplying an offset using both CAF and RFile
|
sl@0
|
791 |
TInt err;
|
sl@0
|
792 |
INFO_PRINTF1(_L("Asynchronous read of 1 byte from CAF and RFile supplying an offset within the file"));
|
sl@0
|
793 |
pos1 = size/4;
|
sl@0
|
794 |
pos2 = size/4;
|
sl@0
|
795 |
status = KRequestPending;
|
sl@0
|
796 |
err = data->Read(pos1,buf1,1,status);
|
sl@0
|
797 |
|
sl@0
|
798 |
StandardCheckReturnValue(err);
|
sl@0
|
799 |
|
sl@0
|
800 |
User::WaitForRequest(status);
|
sl@0
|
801 |
status = KRequestPending;
|
sl@0
|
802 |
file.Read(pos2, buf2,1, status);
|
sl@0
|
803 |
User::WaitForRequest(status);
|
sl@0
|
804 |
INFO_PRINTF2(_L("Data Length from CData::Read(TInt64 aPos, TDesC& , TInt Length, TRequestStatus aStatus) : %d"), buf1.Length());
|
sl@0
|
805 |
INFO_PRINTF2(_L("Data Length from RFile::Read(TInt64 aPos, TDesC& , TInt Length, TRequestStatus aStatus): %d"), buf2.Length());
|
sl@0
|
806 |
|
sl@0
|
807 |
pos1=0;
|
sl@0
|
808 |
pos2=0;
|
sl@0
|
809 |
data->Seek64(ESeekCurrent, pos1);
|
sl@0
|
810 |
file.Seek(ESeekCurrent,pos2);
|
sl@0
|
811 |
if (buf1 !=buf2 || pos1 != pos2 || buf1.Length() != buf2.Length())
|
sl@0
|
812 |
{
|
sl@0
|
813 |
INFO_PRINTF1(_L("ERROR buffers or position do not match"));
|
sl@0
|
814 |
SetTestStepResult(EFail);
|
sl@0
|
815 |
}
|
sl@0
|
816 |
|
sl@0
|
817 |
// Check asynchronous cancellation
|
sl@0
|
818 |
err = 0;
|
sl@0
|
819 |
INFO_PRINTF1(_L("Asynchronous read cancellation using both CAF and RFile with an offset within the file"));
|
sl@0
|
820 |
pos1 = size/4;
|
sl@0
|
821 |
pos2 = size/4;
|
sl@0
|
822 |
status = KRequestPending;
|
sl@0
|
823 |
err = data->Read(pos1,buf1,1,status);
|
sl@0
|
824 |
StandardCheckReturnValue(err);
|
sl@0
|
825 |
data->ReadCancel(status);
|
sl@0
|
826 |
User::WaitForRequest(status);
|
sl@0
|
827 |
TRequestStatus status2(KRequestPending);
|
sl@0
|
828 |
file.Read(pos2, buf2,1, status2);
|
sl@0
|
829 |
file.ReadCancel();
|
sl@0
|
830 |
User::WaitForRequest(status2);
|
sl@0
|
831 |
INFO_PRINTF3(_L("Data Length from CData::Read(TInt64 aPos, TDesC& , TInt Length, TRequestStatus aStatus) : %d, status is %d"), buf1.Length(), status.Int());
|
sl@0
|
832 |
INFO_PRINTF3(_L("Data Length from RFile::Read(TInt64 aPos, TDesC& , TInt Length, TRequestStatus aStatus): %d, status is %d"), buf2.Length(), status2.Int());
|
sl@0
|
833 |
if (status.Int() != status2.Int() || buf1 !=buf2 || pos1 != pos2 || buf1.Length() != buf2.Length())
|
sl@0
|
834 |
{
|
sl@0
|
835 |
INFO_PRINTF1(_L("ERROR status, buffers or position do not match"));
|
sl@0
|
836 |
SetTestStepResult(EFail);
|
sl@0
|
837 |
}
|
sl@0
|
838 |
|
sl@0
|
839 |
// read past EOF
|
sl@0
|
840 |
pos1 = size+1;
|
sl@0
|
841 |
pos2 = size+1;
|
sl@0
|
842 |
status = KRequestPending;
|
sl@0
|
843 |
data->Read(pos1,buf1,1,status);
|
sl@0
|
844 |
StandardCheckReturnValue(err);
|
sl@0
|
845 |
User::WaitForRequest(status);
|
sl@0
|
846 |
status = KRequestPending;
|
sl@0
|
847 |
file.Read(pos2,buf2,1,status);
|
sl@0
|
848 |
User::WaitForRequest(status);
|
sl@0
|
849 |
|
sl@0
|
850 |
if(buf1.Length() != 0 || buf1.Length() != 0)
|
sl@0
|
851 |
{
|
sl@0
|
852 |
INFO_PRINTF1(_L("ERROR data read past EOF"));
|
sl@0
|
853 |
SetTestStepResult(EFail);
|
sl@0
|
854 |
}
|
sl@0
|
855 |
|
sl@0
|
856 |
// read over the length of the buffer
|
sl@0
|
857 |
INFO_PRINTF1(_L("Asynchronous read of 5 bytes from CAF and RFile supplying an offset within the file"));
|
sl@0
|
858 |
pos1 = size/4;
|
sl@0
|
859 |
pos2 = size/4;
|
sl@0
|
860 |
status = KRequestPending;
|
sl@0
|
861 |
err = data->Read(pos1,buf1,5,status);
|
sl@0
|
862 |
StandardCheckReturnValue(err);
|
sl@0
|
863 |
User::WaitForRequest(status);
|
sl@0
|
864 |
if(status.Int()!=KErrOverflow)
|
sl@0
|
865 |
{
|
sl@0
|
866 |
INFO_PRINTF2(_L("ERROR Unexpected status returned: %d"),status.Int());
|
sl@0
|
867 |
SetTestStepResult(EFail);
|
sl@0
|
868 |
}
|
sl@0
|
869 |
status = KRequestPending;
|
sl@0
|
870 |
file.Read(pos2, buf2,5, status);
|
sl@0
|
871 |
User::WaitForRequest(status);
|
sl@0
|
872 |
INFO_PRINTF2(_L("Data Length from CData::Read(TInt64 aPos, TDesC& , TInt Length, TRequestStatus aStatus) : %d"), buf1.Length());
|
sl@0
|
873 |
INFO_PRINTF2(_L("Data Length from RFile::Read(TInt64 aPos, TDesC& , TInt Length, TRequestStatus aStatus): %d"), buf2.Length());
|
sl@0
|
874 |
|
sl@0
|
875 |
if (buf1 !=buf2 || buf1.Length() != buf2.Length())
|
sl@0
|
876 |
{
|
sl@0
|
877 |
INFO_PRINTF1(_L("ERROR buffers or position do not match"));
|
sl@0
|
878 |
SetTestStepResult(EFail);
|
sl@0
|
879 |
}
|
sl@0
|
880 |
// read negative position this should return KErrArgument, dont supply -ve pos to RFile as will panic test
|
sl@0
|
881 |
INFO_PRINTF1(_L("Asynchronous read from CAF supplying a negative offset within the file"));
|
sl@0
|
882 |
pos1 = -1;
|
sl@0
|
883 |
status = KRequestPending;
|
sl@0
|
884 |
err = data->Read(pos1,buf1,5,status);
|
sl@0
|
885 |
if(err!=KErrArgument)
|
sl@0
|
886 |
{
|
sl@0
|
887 |
INFO_PRINTF2(_L("ERROR Unexpected return value: %d"),err);
|
sl@0
|
888 |
SetTestStepResult(EFail);
|
sl@0
|
889 |
}
|
sl@0
|
890 |
|
sl@0
|
891 |
// Read asynchronously supplying an offset of 0 and a length greater than size of file using both CAF and RFile
|
sl@0
|
892 |
INFO_PRINTF1(_L("Asynchronous read of length greater than size of file from CAF and RFile supplying an offset of 0 within the file"));
|
sl@0
|
893 |
TBuf8<256> buf3;
|
sl@0
|
894 |
TBuf8<256> buf4;
|
sl@0
|
895 |
pos1 = 0;
|
sl@0
|
896 |
pos2 = 0;
|
sl@0
|
897 |
status = KRequestPending;
|
sl@0
|
898 |
err = data->Read(pos1,buf3,size+1,status);
|
sl@0
|
899 |
StandardCheckReturnValue(err);
|
sl@0
|
900 |
User::WaitForRequest(status);
|
sl@0
|
901 |
status = KRequestPending;
|
sl@0
|
902 |
file.Read(pos2, buf4,size+1, status);
|
sl@0
|
903 |
User::WaitForRequest(status);
|
sl@0
|
904 |
INFO_PRINTF2(_L("Data Length from CData::Read(TInt64 aPos, TDesC& , TInt Length, TRequestStatus aStatus) : %d"), buf3.Size());
|
sl@0
|
905 |
INFO_PRINTF2(_L("Data Length from RFile::Read(TInt64 aPos, TDesC& , TInt Length, TRequestStatus aStatus): %d"), buf4.Size());
|
sl@0
|
906 |
|
sl@0
|
907 |
pos1=0;
|
sl@0
|
908 |
pos2=0;
|
sl@0
|
909 |
data->Seek64(ESeekCurrent, pos1);
|
sl@0
|
910 |
file.Seek(ESeekCurrent,pos2);
|
sl@0
|
911 |
if (buf3 != buf4 || pos1 != pos2 || buf3.Length() != buf4.Length() || pos1 != size ||
|
sl@0
|
912 |
pos2 != size || buf3.Size() != pos1 || buf4.Size() != pos2)
|
sl@0
|
913 |
{
|
sl@0
|
914 |
INFO_PRINTF1(_L("ERROR buffers or position do not match"));
|
sl@0
|
915 |
SetTestStepResult(EFail);
|
sl@0
|
916 |
}
|
sl@0
|
917 |
|
sl@0
|
918 |
// Read asynchronously supplying an offset of size/4 and a length greater than size of file using both CAF and RFile
|
sl@0
|
919 |
INFO_PRINTF1(_L("Asynchronous read of length greater than size of file from CAF and RFile supplying an offset within the file"));
|
sl@0
|
920 |
pos1 = size/4;
|
sl@0
|
921 |
pos2 = size/4;
|
sl@0
|
922 |
status = KRequestPending;
|
sl@0
|
923 |
err = data->Read(pos1,buf3,size+1,status);
|
sl@0
|
924 |
StandardCheckReturnValue(err);
|
sl@0
|
925 |
User::WaitForRequest(status);
|
sl@0
|
926 |
status = KRequestPending;
|
sl@0
|
927 |
file.Read(pos2, buf4,size+1, status);
|
sl@0
|
928 |
User::WaitForRequest(status);
|
sl@0
|
929 |
INFO_PRINTF2(_L("Data Length from CData::Read(TInt64 aPos, TDesC& , TInt Length, TRequestStatus aStatus) : %d"), buf3.Size());
|
sl@0
|
930 |
INFO_PRINTF2(_L("Data Length from RFile::Read(TInt64 aPos, TDesC& , TInt Length, TRequestStatus aStatus): %d"), buf4.Size());
|
sl@0
|
931 |
|
sl@0
|
932 |
pos1=0;
|
sl@0
|
933 |
pos2=0;
|
sl@0
|
934 |
data->Seek64(ESeekCurrent, pos1);
|
sl@0
|
935 |
file.Seek(ESeekCurrent,pos2);
|
sl@0
|
936 |
if (buf3 != buf4 || pos1 != pos2 || buf3.Size() != buf4.Size() || pos1 != size || pos2 != size)
|
sl@0
|
937 |
{
|
sl@0
|
938 |
INFO_PRINTF1(_L("ERROR buffers or position do not match"));
|
sl@0
|
939 |
SetTestStepResult(EFail);
|
sl@0
|
940 |
}
|
sl@0
|
941 |
|
sl@0
|
942 |
CleanupStack::PopAndDestroy(2, data);
|
sl@0
|
943 |
|
sl@0
|
944 |
__UHEAP_MARKEND;
|
sl@0
|
945 |
|
sl@0
|
946 |
if (TestStepResult() != EFail)
|
sl@0
|
947 |
{
|
sl@0
|
948 |
SetTestStepResult(EPass);
|
sl@0
|
949 |
}
|
sl@0
|
950 |
|
sl@0
|
951 |
return TestStepResult();
|
sl@0
|
952 |
}
|
sl@0
|
953 |
|
sl@0
|
954 |
#endif // SYMBIAN_ENABLE_64_BIT_FILE_SERVER_API
|
sl@0
|
955 |
/*
|
sl@0
|
956 |
* This step retrieves the attributes of a file using the CAF framework
|
sl@0
|
957 |
*
|
sl@0
|
958 |
*/
|
sl@0
|
959 |
|
sl@0
|
960 |
CCAFAttributesStep::~CCAFAttributesStep()
|
sl@0
|
961 |
{
|
sl@0
|
962 |
}
|
sl@0
|
963 |
|
sl@0
|
964 |
CCAFAttributesStep::CCAFAttributesStep(CCAFServer& aParent) : iParent(aParent)
|
sl@0
|
965 |
{
|
sl@0
|
966 |
SetTestStepName(KCAFAttributesStep);
|
sl@0
|
967 |
}
|
sl@0
|
968 |
|
sl@0
|
969 |
|
sl@0
|
970 |
TVerdict CCAFAttributesStep::doTestStepL()
|
sl@0
|
971 |
{
|
sl@0
|
972 |
CContent *content;
|
sl@0
|
973 |
CAttribute *attrs;
|
sl@0
|
974 |
TPtrC fileName;
|
sl@0
|
975 |
TBool Protected;
|
sl@0
|
976 |
TBool Forwardable;
|
sl@0
|
977 |
|
sl@0
|
978 |
|
sl@0
|
979 |
TBool Value;
|
sl@0
|
980 |
|
sl@0
|
981 |
SetTestStepResult(EFail);
|
sl@0
|
982 |
|
sl@0
|
983 |
GetStringFromConfig(ConfigSection(),_L("filename"),fileName);
|
sl@0
|
984 |
GetBoolFromConfig(ConfigSection(),_L("Protected"),Protected);
|
sl@0
|
985 |
GetBoolFromConfig(ConfigSection(),_L("Forwardable"),Forwardable);
|
sl@0
|
986 |
|
sl@0
|
987 |
|
sl@0
|
988 |
INFO_PRINTF2(_L("Check attributes of file: %S"), &fileName);
|
sl@0
|
989 |
|
sl@0
|
990 |
__UHEAP_MARK;
|
sl@0
|
991 |
|
sl@0
|
992 |
// Open a file and retrieve the attributes
|
sl@0
|
993 |
content = CContent::NewLC(fileName);
|
sl@0
|
994 |
attrs = content->NewAttributeL(ETrue);
|
sl@0
|
995 |
CleanupStack::PushL(attrs);
|
sl@0
|
996 |
|
sl@0
|
997 |
// Assume all the attributes are what we expect them to be
|
sl@0
|
998 |
SetTestStepResult(EPass);
|
sl@0
|
999 |
|
sl@0
|
1000 |
Value = attrs->ResponseSet().IsSet(EIsProtected);
|
sl@0
|
1001 |
if(Value != Protected)
|
sl@0
|
1002 |
{
|
sl@0
|
1003 |
SetTestStepResult(EFail);
|
sl@0
|
1004 |
Protected ? INFO_PRINTF1(_L("File is Protected")) : INFO_PRINTF1(_L("File is not Protected"));
|
sl@0
|
1005 |
}
|
sl@0
|
1006 |
|
sl@0
|
1007 |
Value = attrs->ResponseSet().IsSet(EIsForwardable);
|
sl@0
|
1008 |
if(Value != Forwardable)
|
sl@0
|
1009 |
{
|
sl@0
|
1010 |
SetTestStepResult(EFail);
|
sl@0
|
1011 |
Forwardable ? INFO_PRINTF1(_L("File is Forwardable")) : INFO_PRINTF1(_L("File is not Forwardable"));
|
sl@0
|
1012 |
}
|
sl@0
|
1013 |
|
sl@0
|
1014 |
CleanupStack::PopAndDestroy(2, content);
|
sl@0
|
1015 |
|
sl@0
|
1016 |
__UHEAP_MARKEND;
|
sl@0
|
1017 |
return TestStepResult();
|
sl@0
|
1018 |
}
|
sl@0
|
1019 |
|
sl@0
|
1020 |
|
sl@0
|
1021 |
/*
|
sl@0
|
1022 |
* This step retrieves the string attributes of a file using the CAF framework
|
sl@0
|
1023 |
*
|
sl@0
|
1024 |
*/
|
sl@0
|
1025 |
|
sl@0
|
1026 |
CCAFStringAttributesStep::~CCAFStringAttributesStep()
|
sl@0
|
1027 |
{
|
sl@0
|
1028 |
}
|
sl@0
|
1029 |
|
sl@0
|
1030 |
CCAFStringAttributesStep::CCAFStringAttributesStep(CCAFServer& aParent) : iParent(aParent)
|
sl@0
|
1031 |
{
|
sl@0
|
1032 |
SetTestStepName(KCAFStringAttributesStep);
|
sl@0
|
1033 |
}
|
sl@0
|
1034 |
|
sl@0
|
1035 |
|
sl@0
|
1036 |
TVerdict CCAFStringAttributesStep::doTestStepL()
|
sl@0
|
1037 |
{
|
sl@0
|
1038 |
TInt expectedResult;
|
sl@0
|
1039 |
TInt attribute;
|
sl@0
|
1040 |
TPtrC expectedValue;
|
sl@0
|
1041 |
TBuf <256> value; //this will be used to test KErrOverFlow when transactionid is 257char long.
|
sl@0
|
1042 |
TInt result = KErrNone;
|
sl@0
|
1043 |
TPtrC uri;
|
sl@0
|
1044 |
TPtrC uniqueId;
|
sl@0
|
1045 |
|
sl@0
|
1046 |
SetTestStepResult(EPass);
|
sl@0
|
1047 |
|
sl@0
|
1048 |
GetIntFromConfig(ConfigSection(),_L("stringattribute"),attribute);
|
sl@0
|
1049 |
GetStringFromConfig(ConfigSection(),_L("uri"),uri);
|
sl@0
|
1050 |
GetStringFromConfig(ConfigSection(),_L("uniqueid"),uniqueId);
|
sl@0
|
1051 |
GetStringFromConfig(ConfigSection(),_L("value"),expectedValue);
|
sl@0
|
1052 |
GetIntFromConfig(ConfigSection(),_L("result"),expectedResult);
|
sl@0
|
1053 |
|
sl@0
|
1054 |
__UHEAP_MARK;
|
sl@0
|
1055 |
CContent *content = CContent::NewLC(uri);
|
sl@0
|
1056 |
CData *data = content->OpenContentL(EPeek, uniqueId);
|
sl@0
|
1057 |
result = data->GetStringAttribute(attribute, value);
|
sl@0
|
1058 |
delete data;
|
sl@0
|
1059 |
if(result != expectedResult)
|
sl@0
|
1060 |
{
|
sl@0
|
1061 |
SetTestStepResult(EFail);
|
sl@0
|
1062 |
INFO_PRINTF3(_L("CData::GetStringAttribute() Expected result: %d, actual result: %d"), expectedResult, result);
|
sl@0
|
1063 |
}
|
sl@0
|
1064 |
if(value != expectedValue)
|
sl@0
|
1065 |
{
|
sl@0
|
1066 |
SetTestStepResult(EFail);
|
sl@0
|
1067 |
INFO_PRINTF3(_L("CData::GetStringAttribute() Expected value: %S, actual result: %S"), &expectedValue, &value);
|
sl@0
|
1068 |
}
|
sl@0
|
1069 |
|
sl@0
|
1070 |
CleanupStack::PopAndDestroy(content);
|
sl@0
|
1071 |
|
sl@0
|
1072 |
__UHEAP_MARKEND;
|
sl@0
|
1073 |
return TestStepResult();
|
sl@0
|
1074 |
|
sl@0
|
1075 |
}
|
sl@0
|
1076 |
|
sl@0
|
1077 |
|
sl@0
|
1078 |
|
sl@0
|
1079 |
|
sl@0
|
1080 |
/*
|
sl@0
|
1081 |
* Step reads from a CData from multiple threads
|
sl@0
|
1082 |
*
|
sl@0
|
1083 |
*/
|
sl@0
|
1084 |
|
sl@0
|
1085 |
CCAFMultiThreadCDataStep::~CCAFMultiThreadCDataStep()
|
sl@0
|
1086 |
{
|
sl@0
|
1087 |
}
|
sl@0
|
1088 |
|
sl@0
|
1089 |
CCAFMultiThreadCDataStep::CCAFMultiThreadCDataStep(CCAFServer& aParent)
|
sl@0
|
1090 |
: iParent(aParent)
|
sl@0
|
1091 |
{
|
sl@0
|
1092 |
SetTestStepName(KCAFMultiThreadCDataStep);
|
sl@0
|
1093 |
}
|
sl@0
|
1094 |
|
sl@0
|
1095 |
TVerdict CCAFMultiThreadCDataStep::doTestStepL()
|
sl@0
|
1096 |
{
|
sl@0
|
1097 |
TBuf8<2> buf;
|
sl@0
|
1098 |
|
sl@0
|
1099 |
__UHEAP_MARK;
|
sl@0
|
1100 |
_LIT(KCDataThread,"CData_Thread");
|
sl@0
|
1101 |
|
sl@0
|
1102 |
SetTestStepResult(EInconclusive);
|
sl@0
|
1103 |
|
sl@0
|
1104 |
INFO_PRINTF1(_L("Multi Thread CData Test"));
|
sl@0
|
1105 |
|
sl@0
|
1106 |
TPtrC uri;
|
sl@0
|
1107 |
GetStringFromConfig(ConfigSection(),_L("URI"),uri);
|
sl@0
|
1108 |
|
sl@0
|
1109 |
INFO_PRINTF1(_L("Creating data object from content"));
|
sl@0
|
1110 |
CContent* content = CContent::NewLC(uri);
|
sl@0
|
1111 |
CData* data = content->OpenContentL(EPeek);
|
sl@0
|
1112 |
CleanupStack::PushL(data);
|
sl@0
|
1113 |
|
sl@0
|
1114 |
TInt size, pos;
|
sl@0
|
1115 |
|
sl@0
|
1116 |
// Create a mutex for communication between our thread and the new thread
|
sl@0
|
1117 |
RSemaphore threadSemaphore;
|
sl@0
|
1118 |
threadSemaphore.CreateGlobal(KCDataThreadSemaphore(), 1, EOwnerProcess);
|
sl@0
|
1119 |
threadSemaphore.Wait();
|
sl@0
|
1120 |
|
sl@0
|
1121 |
// fire up a new thread, stack size and heap size 8k, might need to be bigger in the future
|
sl@0
|
1122 |
RThread readerThread;
|
sl@0
|
1123 |
User::LeaveIfError(readerThread.Create(KCDataThread(),CCAFMultiThreadCDataStep::ReaderThreadEntry,8192, KMinHeapSize, 8192, (TAny *) data, EOwnerProcess));
|
sl@0
|
1124 |
|
sl@0
|
1125 |
// request notification of thread completion
|
sl@0
|
1126 |
TRequestStatus stat;
|
sl@0
|
1127 |
readerThread.Logon(stat);
|
sl@0
|
1128 |
readerThread.Resume();
|
sl@0
|
1129 |
|
sl@0
|
1130 |
data->DataSizeL(size);
|
sl@0
|
1131 |
pos = size/2;
|
sl@0
|
1132 |
data->Seek(ESeekStart,pos);
|
sl@0
|
1133 |
data->Read(buf);
|
sl@0
|
1134 |
|
sl@0
|
1135 |
threadSemaphore.Wait(); // wait for thread function to run and signal the semaphore
|
sl@0
|
1136 |
threadSemaphore.Signal(); // finished with semaphore
|
sl@0
|
1137 |
threadSemaphore.Close(); // so close
|
sl@0
|
1138 |
|
sl@0
|
1139 |
User::WaitForRequest(stat); // wait for thread to finish
|
sl@0
|
1140 |
TInt error=(readerThread.ExitType()==EExitPanic) ? KErrGeneral : stat.Int();
|
sl@0
|
1141 |
User::LeaveIfError(error);
|
sl@0
|
1142 |
readerThread.Close(); // close the thread
|
sl@0
|
1143 |
|
sl@0
|
1144 |
CleanupStack::PopAndDestroy(data);
|
sl@0
|
1145 |
CleanupStack::PopAndDestroy(content);
|
sl@0
|
1146 |
|
sl@0
|
1147 |
__UHEAP_MARKEND;
|
sl@0
|
1148 |
|
sl@0
|
1149 |
SetTestStepResult(EPass);
|
sl@0
|
1150 |
return TestStepResult();
|
sl@0
|
1151 |
}
|
sl@0
|
1152 |
|
sl@0
|
1153 |
TInt CCAFMultiThreadCDataStep::ReaderThreadEntry(TAny *aPtr)
|
sl@0
|
1154 |
{
|
sl@0
|
1155 |
TBuf8 <2> buf;
|
sl@0
|
1156 |
CData *data = reinterpret_cast <CData *> (aPtr);
|
sl@0
|
1157 |
|
sl@0
|
1158 |
// create a trap handler
|
sl@0
|
1159 |
CTrapCleanup* cleanup = CTrapCleanup::New();
|
sl@0
|
1160 |
|
sl@0
|
1161 |
RSemaphore threadSemaphore;
|
sl@0
|
1162 |
threadSemaphore.OpenGlobal(KCDataThreadSemaphore() ,EOwnerProcess);
|
sl@0
|
1163 |
|
sl@0
|
1164 |
data->Read(buf);
|
sl@0
|
1165 |
threadSemaphore.Signal(); // allow original thread to continue
|
sl@0
|
1166 |
threadSemaphore.Close();
|
sl@0
|
1167 |
|
sl@0
|
1168 |
delete cleanup;
|
sl@0
|
1169 |
return KErrNone;
|
sl@0
|
1170 |
}
|
sl@0
|
1171 |
|
sl@0
|
1172 |
|
sl@0
|
1173 |
/*
|
sl@0
|
1174 |
* Obtains the mime type from a CData
|
sl@0
|
1175 |
*
|
sl@0
|
1176 |
*/
|
sl@0
|
1177 |
|
sl@0
|
1178 |
CCAFMimeTypeCDataStep::~CCAFMimeTypeCDataStep()
|
sl@0
|
1179 |
{
|
sl@0
|
1180 |
}
|
sl@0
|
1181 |
|
sl@0
|
1182 |
CCAFMimeTypeCDataStep::CCAFMimeTypeCDataStep(CCAFServer& aParent)
|
sl@0
|
1183 |
: iParent(aParent)
|
sl@0
|
1184 |
{
|
sl@0
|
1185 |
SetTestStepName(KCAFMimeTypeCDataStep);
|
sl@0
|
1186 |
}
|
sl@0
|
1187 |
|
sl@0
|
1188 |
TVerdict CCAFMimeTypeCDataStep::doTestStepL()
|
sl@0
|
1189 |
{
|
sl@0
|
1190 |
__UHEAP_MARK;
|
sl@0
|
1191 |
|
sl@0
|
1192 |
|
sl@0
|
1193 |
SetTestStepResult(EFail);
|
sl@0
|
1194 |
|
sl@0
|
1195 |
INFO_PRINTF1(_L("CData MimeType Test"));
|
sl@0
|
1196 |
|
sl@0
|
1197 |
TPtrC uri;
|
sl@0
|
1198 |
TPtrC expectedMimeType;
|
sl@0
|
1199 |
TBool mimeTypeKnown=EFalse;
|
sl@0
|
1200 |
|
sl@0
|
1201 |
// Load INI parameters
|
sl@0
|
1202 |
GetStringFromConfig(ConfigSection(),_L("URI"),uri);
|
sl@0
|
1203 |
GetStringFromConfig(ConfigSection(),_L("ContentMimeType"),expectedMimeType);
|
sl@0
|
1204 |
GetBoolFromConfig(ConfigSection(),_L("Known"),mimeTypeKnown);
|
sl@0
|
1205 |
|
sl@0
|
1206 |
// convert to Des8
|
sl@0
|
1207 |
HBufC8 *expected = ConvertDes16toHBufC8LC(expectedMimeType);
|
sl@0
|
1208 |
|
sl@0
|
1209 |
// Create CContent and CData
|
sl@0
|
1210 |
INFO_PRINTF1(_L("Creating data object from content"));
|
sl@0
|
1211 |
CContent* content = CContent::NewLC(uri);
|
sl@0
|
1212 |
CData* data = content->OpenContentL(EPeek);
|
sl@0
|
1213 |
CleanupStack::PushL(data);
|
sl@0
|
1214 |
|
sl@0
|
1215 |
// Get mime type from CData
|
sl@0
|
1216 |
INFO_PRINTF1(_L("Checking mime type"));
|
sl@0
|
1217 |
HBufC8 *buffer = HBufC8::NewLC(KCafTestMaxDataTypeLength);
|
sl@0
|
1218 |
TPtr8 ptr = buffer->Des();
|
sl@0
|
1219 |
TBool r = data->GetMimeTypeL(ptr);
|
sl@0
|
1220 |
|
sl@0
|
1221 |
// check if result matches expected result
|
sl@0
|
1222 |
if(r == mimeTypeKnown && *buffer == *expected)
|
sl@0
|
1223 |
{
|
sl@0
|
1224 |
SetTestStepResult(EPass);
|
sl@0
|
1225 |
}
|
sl@0
|
1226 |
|
sl@0
|
1227 |
CleanupStack::PopAndDestroy(4,expected);
|
sl@0
|
1228 |
__UHEAP_MARKEND;
|
sl@0
|
1229 |
return TestStepResult();
|
sl@0
|
1230 |
}
|
sl@0
|
1231 |
|
sl@0
|
1232 |
/*
|
sl@0
|
1233 |
* This step tests file sharing modes
|
sl@0
|
1234 |
*
|
sl@0
|
1235 |
*/
|
sl@0
|
1236 |
|
sl@0
|
1237 |
CCAFShareModeStep::~CCAFShareModeStep()
|
sl@0
|
1238 |
{
|
sl@0
|
1239 |
}
|
sl@0
|
1240 |
|
sl@0
|
1241 |
CCAFShareModeStep::CCAFShareModeStep(CCAFServer& aParent) : iParent(aParent)
|
sl@0
|
1242 |
{
|
sl@0
|
1243 |
SetTestStepName(KCAFShareModeStep);
|
sl@0
|
1244 |
}
|
sl@0
|
1245 |
|
sl@0
|
1246 |
|
sl@0
|
1247 |
TVerdict CCAFShareModeStep::doTestStepL()
|
sl@0
|
1248 |
{
|
sl@0
|
1249 |
TVerdict verdict = EFail;
|
sl@0
|
1250 |
TRAPD(err, verdict = doShareModeStepL());
|
sl@0
|
1251 |
if(err != KErrNone)
|
sl@0
|
1252 |
{
|
sl@0
|
1253 |
if(err != KErrInUse)
|
sl@0
|
1254 |
{
|
sl@0
|
1255 |
User::Leave(err);
|
sl@0
|
1256 |
}
|
sl@0
|
1257 |
else
|
sl@0
|
1258 |
{
|
sl@0
|
1259 |
User::Leave(KErrGeneral);
|
sl@0
|
1260 |
}
|
sl@0
|
1261 |
}
|
sl@0
|
1262 |
return verdict;
|
sl@0
|
1263 |
}
|
sl@0
|
1264 |
|
sl@0
|
1265 |
TVerdict CCAFShareModeStep::doShareModeStepL()
|
sl@0
|
1266 |
{
|
sl@0
|
1267 |
CAttribute *attr = NULL;
|
sl@0
|
1268 |
RFile file;
|
sl@0
|
1269 |
RFs fs;
|
sl@0
|
1270 |
TPtrC fileName;
|
sl@0
|
1271 |
TInt err = 0;
|
sl@0
|
1272 |
|
sl@0
|
1273 |
SetTestStepResult(EPass);
|
sl@0
|
1274 |
|
sl@0
|
1275 |
GetStringFromConfig(ConfigSection(),_L("FileName"),fileName);
|
sl@0
|
1276 |
|
sl@0
|
1277 |
// This function works if I step through everything but fails
|
sl@0
|
1278 |
// when run or step over the TRAP
|
sl@0
|
1279 |
// User::Leave(KErrGeneral);
|
sl@0
|
1280 |
|
sl@0
|
1281 |
|
sl@0
|
1282 |
__UHEAP_MARK;
|
sl@0
|
1283 |
|
sl@0
|
1284 |
INFO_PRINTF2(_L("Creating Content object for file: %S"), &fileName);
|
sl@0
|
1285 |
CContent* content= CContent::NewL(fileName);
|
sl@0
|
1286 |
CData *data = NULL;
|
sl@0
|
1287 |
|
sl@0
|
1288 |
fs.Connect();
|
sl@0
|
1289 |
CleanupClosePushL(fs);
|
sl@0
|
1290 |
|
sl@0
|
1291 |
|
sl@0
|
1292 |
INFO_PRINTF1(_L("Testing EContentShareReadOnly"));
|
sl@0
|
1293 |
User::LeaveIfError(file.Open(fs, fileName, EFileShareReadersOnly | EFileRead | EFileStream));
|
sl@0
|
1294 |
CleanupClosePushL(file);
|
sl@0
|
1295 |
data = content->OpenContentL(EPeek);
|
sl@0
|
1296 |
delete data;
|
sl@0
|
1297 |
data = NULL;
|
sl@0
|
1298 |
data = content->OpenContentL(EPeek, EContentShareReadOnly);
|
sl@0
|
1299 |
delete data;
|
sl@0
|
1300 |
data = NULL;
|
sl@0
|
1301 |
TRAP(err, data = content->OpenContentL(EPeek, EContentShareReadWrite));
|
sl@0
|
1302 |
delete data;
|
sl@0
|
1303 |
data = NULL;
|
sl@0
|
1304 |
|
sl@0
|
1305 |
// We can open read-write because CAF never writes.
|
sl@0
|
1306 |
|
sl@0
|
1307 |
if(err != KErrNone)
|
sl@0
|
1308 |
{
|
sl@0
|
1309 |
SetTestStepResult(EFail);
|
sl@0
|
1310 |
}
|
sl@0
|
1311 |
|
sl@0
|
1312 |
// However, exclusive mode should be impossible.
|
sl@0
|
1313 |
|
sl@0
|
1314 |
TRAP(err, data = content->OpenContentL(EPeek, EContentShareExclusive));
|
sl@0
|
1315 |
delete data;
|
sl@0
|
1316 |
data = NULL;
|
sl@0
|
1317 |
if(err != KErrInUse)
|
sl@0
|
1318 |
{
|
sl@0
|
1319 |
SetTestStepResult(EFail);
|
sl@0
|
1320 |
}
|
sl@0
|
1321 |
CleanupStack::PopAndDestroy(&file);
|
sl@0
|
1322 |
delete content;
|
sl@0
|
1323 |
|
sl@0
|
1324 |
|
sl@0
|
1325 |
INFO_PRINTF1(_L("Testing EContentShareReadWrite"));
|
sl@0
|
1326 |
content = CContent::NewL(fileName, EContentShareReadWrite);
|
sl@0
|
1327 |
User::LeaveIfError(file.Open(fs, fileName, EFileShareReadersOrWriters | EFileRead | EFileStream));
|
sl@0
|
1328 |
CleanupClosePushL(file);
|
sl@0
|
1329 |
data = content->OpenContentL(EPeek, EContentShareReadWrite);
|
sl@0
|
1330 |
delete data;
|
sl@0
|
1331 |
data = NULL;
|
sl@0
|
1332 |
|
sl@0
|
1333 |
// We should be able to open read-only
|
sl@0
|
1334 |
|
sl@0
|
1335 |
TRAP(err, data = content->OpenContentL(EPeek, EContentShareReadOnly));
|
sl@0
|
1336 |
delete data;
|
sl@0
|
1337 |
data = NULL;
|
sl@0
|
1338 |
if(err != KErrNone)
|
sl@0
|
1339 |
{
|
sl@0
|
1340 |
SetTestStepResult(EFail);
|
sl@0
|
1341 |
}
|
sl@0
|
1342 |
|
sl@0
|
1343 |
// but not share exclusive
|
sl@0
|
1344 |
|
sl@0
|
1345 |
TRAP(err, data = content->OpenContentL(EPeek, EContentShareExclusive));
|
sl@0
|
1346 |
delete data;
|
sl@0
|
1347 |
data = NULL;
|
sl@0
|
1348 |
if(err != KErrInUse)
|
sl@0
|
1349 |
{
|
sl@0
|
1350 |
SetTestStepResult(EFail);
|
sl@0
|
1351 |
}
|
sl@0
|
1352 |
CleanupStack::PopAndDestroy(&file);
|
sl@0
|
1353 |
|
sl@0
|
1354 |
|
sl@0
|
1355 |
// Reopen the file with write attributes, and make sure ReadOnly becomes impossible
|
sl@0
|
1356 |
User::LeaveIfError(file.Open(fs, fileName, EFileShareReadersOrWriters | EFileRead | EFileWrite | EFileStream));
|
sl@0
|
1357 |
CleanupClosePushL(file);
|
sl@0
|
1358 |
|
sl@0
|
1359 |
TRAP(err, data = content->OpenContentL(EPeek, EContentShareReadOnly));
|
sl@0
|
1360 |
delete data;
|
sl@0
|
1361 |
data = NULL;
|
sl@0
|
1362 |
if(err != KErrInUse)
|
sl@0
|
1363 |
{
|
sl@0
|
1364 |
SetTestStepResult(EFail);
|
sl@0
|
1365 |
}
|
sl@0
|
1366 |
|
sl@0
|
1367 |
CleanupStack::PopAndDestroy(&file);
|
sl@0
|
1368 |
delete content;
|
sl@0
|
1369 |
|
sl@0
|
1370 |
|
sl@0
|
1371 |
INFO_PRINTF1(_L("Testing EContentShareExclusive"));
|
sl@0
|
1372 |
User::LeaveIfError(file.Open(fs, fileName, EFileShareExclusive | EFileRead | EFileStream));
|
sl@0
|
1373 |
CleanupClosePushL(file);
|
sl@0
|
1374 |
TRAP(err, data = CData::NewL(TVirtualPathPtr(fileName), EPeek, EContentShareReadOnly));
|
sl@0
|
1375 |
delete data;
|
sl@0
|
1376 |
data = NULL;
|
sl@0
|
1377 |
if(err != KErrInUse)
|
sl@0
|
1378 |
{
|
sl@0
|
1379 |
SetTestStepResult(EFail);
|
sl@0
|
1380 |
}
|
sl@0
|
1381 |
TRAP(err, data = CData::NewL(TVirtualPathPtr(fileName), EPeek, EContentShareReadWrite));
|
sl@0
|
1382 |
delete data;
|
sl@0
|
1383 |
data = NULL;
|
sl@0
|
1384 |
if(err != KErrInUse)
|
sl@0
|
1385 |
{
|
sl@0
|
1386 |
SetTestStepResult(EFail);
|
sl@0
|
1387 |
}
|
sl@0
|
1388 |
TRAP(err, data = CData::NewL(TVirtualPathPtr(fileName), EPeek, EContentShareExclusive));
|
sl@0
|
1389 |
delete data;
|
sl@0
|
1390 |
data = NULL;
|
sl@0
|
1391 |
if(err != KErrInUse)
|
sl@0
|
1392 |
{
|
sl@0
|
1393 |
SetTestStepResult(EFail);
|
sl@0
|
1394 |
}
|
sl@0
|
1395 |
CleanupStack::PopAndDestroy(&file);
|
sl@0
|
1396 |
|
sl@0
|
1397 |
INFO_PRINTF1(_L("Testing CContent::NewAttributeL"));
|
sl@0
|
1398 |
content = CContent::NewL(fileName, EContentShareReadWrite);
|
sl@0
|
1399 |
User::LeaveIfError(file.Open(fs, fileName, EFileShareAny | EFileRead | EFileStream));
|
sl@0
|
1400 |
CleanupClosePushL(file);
|
sl@0
|
1401 |
attr = content->NewAttributeL(ETrue,EContentShareReadWrite);
|
sl@0
|
1402 |
delete attr;
|
sl@0
|
1403 |
attr = NULL;
|
sl@0
|
1404 |
TRAP(err, attr = content->NewAttributeL(ETrue));
|
sl@0
|
1405 |
delete attr;
|
sl@0
|
1406 |
attr = NULL;
|
sl@0
|
1407 |
if(err != KErrInUse)
|
sl@0
|
1408 |
{
|
sl@0
|
1409 |
SetTestStepResult(EFail);
|
sl@0
|
1410 |
}
|
sl@0
|
1411 |
CleanupStack::PopAndDestroy(2, &fs); // fs, file
|
sl@0
|
1412 |
delete content;
|
sl@0
|
1413 |
|
sl@0
|
1414 |
__UHEAP_MARKEND;
|
sl@0
|
1415 |
return TestStepResult();
|
sl@0
|
1416 |
}
|
sl@0
|
1417 |
|
sl@0
|
1418 |
CCAFHandleSizeStep::CCAFHandleSizeStep(CCAFServer& aParent)
|
sl@0
|
1419 |
:iParent(aParent)
|
sl@0
|
1420 |
{
|
sl@0
|
1421 |
SetTestStepName(KCAFHandleSizeStep);
|
sl@0
|
1422 |
}
|
sl@0
|
1423 |
|
sl@0
|
1424 |
CCAFHandleSizeStep::~CCAFHandleSizeStep()
|
sl@0
|
1425 |
{
|
sl@0
|
1426 |
|
sl@0
|
1427 |
|
sl@0
|
1428 |
}
|
sl@0
|
1429 |
|
sl@0
|
1430 |
TVerdict CCAFHandleSizeStep::doTestStepL()
|
sl@0
|
1431 |
{
|
sl@0
|
1432 |
__UHEAP_MARK;
|
sl@0
|
1433 |
|
sl@0
|
1434 |
SetTestStepResult(EInconclusive);
|
sl@0
|
1435 |
|
sl@0
|
1436 |
INFO_PRINTF1(_L("Basic Open Content Test"));
|
sl@0
|
1437 |
|
sl@0
|
1438 |
TPtrC uri1;
|
sl@0
|
1439 |
TPtrC uri2;
|
sl@0
|
1440 |
GetStringFromConfig(ConfigSection(),_L("URI1"),uri1);
|
sl@0
|
1441 |
GetStringFromConfig(ConfigSection(),_L("URI2"),uri2);
|
sl@0
|
1442 |
|
sl@0
|
1443 |
INFO_PRINTF2(_L("Creating content object with uri: %S"), &uri1);
|
sl@0
|
1444 |
|
sl@0
|
1445 |
RFile file1;
|
sl@0
|
1446 |
User::LeaveIfError(file1.Open(iParent.Fs(), uri1, EFileRead));
|
sl@0
|
1447 |
CleanupClosePushL(file1);
|
sl@0
|
1448 |
|
sl@0
|
1449 |
CContent* content = CContent::NewLC(file1);
|
sl@0
|
1450 |
|
sl@0
|
1451 |
INFO_PRINTF1(_L("Creating data object from content"));
|
sl@0
|
1452 |
|
sl@0
|
1453 |
CData* data = content->OpenContentL(EPeek);
|
sl@0
|
1454 |
CleanupStack::PushL(data);
|
sl@0
|
1455 |
|
sl@0
|
1456 |
TInt size = 0;
|
sl@0
|
1457 |
data->DataSizeL(size);
|
sl@0
|
1458 |
INFO_PRINTF2(_L("Size of content from caf: %d"),size);
|
sl@0
|
1459 |
CleanupStack::PopAndDestroy(data);
|
sl@0
|
1460 |
CleanupStack::PopAndDestroy(content);
|
sl@0
|
1461 |
|
sl@0
|
1462 |
TInt pos = 0;
|
sl@0
|
1463 |
file1.Seek(ESeekStart, pos);
|
sl@0
|
1464 |
|
sl@0
|
1465 |
INFO_PRINTF2(_L("Creating CData object with uri: %S"), &uri1);
|
sl@0
|
1466 |
TInt size1 = 0;
|
sl@0
|
1467 |
data = CData::NewL(file1, KDefaultContentObject(), EPeek);
|
sl@0
|
1468 |
CleanupStack::PushL(data);
|
sl@0
|
1469 |
data->DataSizeL(size1);
|
sl@0
|
1470 |
INFO_PRINTF2(_L("Size of content from caf CData::NewL(): %d"),size1);
|
sl@0
|
1471 |
CleanupStack::PopAndDestroy(data);
|
sl@0
|
1472 |
CleanupStack::PopAndDestroy(&file1);
|
sl@0
|
1473 |
|
sl@0
|
1474 |
INFO_PRINTF2(_L("Opening standard RFile interface with uri: %S"),&uri2);
|
sl@0
|
1475 |
RFile file2;
|
sl@0
|
1476 |
User::LeaveIfError(file2.Open(iParent.Fs(), uri2, EFileRead));
|
sl@0
|
1477 |
|
sl@0
|
1478 |
TInt size2;
|
sl@0
|
1479 |
file2.Size(size2);
|
sl@0
|
1480 |
file2.Close();
|
sl@0
|
1481 |
|
sl@0
|
1482 |
INFO_PRINTF2(_L("Size of content from f32: %d"),size2);
|
sl@0
|
1483 |
|
sl@0
|
1484 |
if(size == size2 && size1 == size2)
|
sl@0
|
1485 |
{
|
sl@0
|
1486 |
SetTestStepResult(EPass);
|
sl@0
|
1487 |
}
|
sl@0
|
1488 |
else
|
sl@0
|
1489 |
{
|
sl@0
|
1490 |
SetTestStepResult(EFail);
|
sl@0
|
1491 |
}
|
sl@0
|
1492 |
|
sl@0
|
1493 |
__UHEAP_MARKEND;
|
sl@0
|
1494 |
return TestStepResult();
|
sl@0
|
1495 |
}
|
sl@0
|
1496 |
|
sl@0
|
1497 |
|
sl@0
|
1498 |
CCAFHandleSeekReadStep::~CCAFHandleSeekReadStep()
|
sl@0
|
1499 |
{
|
sl@0
|
1500 |
|
sl@0
|
1501 |
}
|
sl@0
|
1502 |
|
sl@0
|
1503 |
CCAFHandleSeekReadStep::CCAFHandleSeekReadStep(CCAFServer& aParent)
|
sl@0
|
1504 |
: iParent(aParent)
|
sl@0
|
1505 |
{
|
sl@0
|
1506 |
SetTestStepName(KCAFHandleSeekReadStep);
|
sl@0
|
1507 |
}
|
sl@0
|
1508 |
|
sl@0
|
1509 |
TVerdict CCAFHandleSeekReadStep::doTestStepL()
|
sl@0
|
1510 |
{
|
sl@0
|
1511 |
SetTestStepResult(EInconclusive);
|
sl@0
|
1512 |
|
sl@0
|
1513 |
TBuf8<2> buf1;
|
sl@0
|
1514 |
TBuf8<2> buf2;
|
sl@0
|
1515 |
TRequestStatus status;
|
sl@0
|
1516 |
|
sl@0
|
1517 |
__UHEAP_MARK;
|
sl@0
|
1518 |
INFO_PRINTF1(_L("Basic Open Content Test"));
|
sl@0
|
1519 |
|
sl@0
|
1520 |
TPtrC uri1;
|
sl@0
|
1521 |
TPtrC uri2;
|
sl@0
|
1522 |
GetStringFromConfig(ConfigSection(),_L("URI1"),uri1);
|
sl@0
|
1523 |
GetStringFromConfig(ConfigSection(),_L("URI2"),uri2);
|
sl@0
|
1524 |
|
sl@0
|
1525 |
INFO_PRINTF2(_L("Creating content object with uri: %S"), &uri1);
|
sl@0
|
1526 |
RFile file1;
|
sl@0
|
1527 |
User::LeaveIfError(file1.Open(iParent.Fs(), uri1, EFileRead | EFileShareReadersOnly));
|
sl@0
|
1528 |
CleanupClosePushL(file1);
|
sl@0
|
1529 |
CContent* content = CContent::NewLC(file1);
|
sl@0
|
1530 |
|
sl@0
|
1531 |
INFO_PRINTF1(_L("Creating data object from content"));
|
sl@0
|
1532 |
CData* data = content->OpenContentL(EPeek);
|
sl@0
|
1533 |
CleanupStack::PushL(data);
|
sl@0
|
1534 |
|
sl@0
|
1535 |
// Now, open the same file using RFile
|
sl@0
|
1536 |
RFile file2;
|
sl@0
|
1537 |
INFO_PRINTF2(_L("Opening standard RFile interface with uri: %S"),&uri2);
|
sl@0
|
1538 |
//User::LeaveIfError(file2.Open(iParent.Fs(), uri2, EFileRead | EFileShareReadersOnly));
|
sl@0
|
1539 |
TInt res = file2.Open(iParent.Fs(), uri2, EFileRead | EFileShareReadersOnly);
|
sl@0
|
1540 |
CleanupClosePushL(file2);
|
sl@0
|
1541 |
|
sl@0
|
1542 |
TInt size = 0;
|
sl@0
|
1543 |
file2.Size(size);
|
sl@0
|
1544 |
INFO_PRINTF2(_L("Size of content from f32: %d"),size);
|
sl@0
|
1545 |
|
sl@0
|
1546 |
// Seek and read from start using both CAF and RFile
|
sl@0
|
1547 |
TInt pos1 = size/4;
|
sl@0
|
1548 |
data->Seek(ESeekStart, pos1);
|
sl@0
|
1549 |
TInt pos2 = size/4;
|
sl@0
|
1550 |
file2.Seek(ESeekStart, pos2);
|
sl@0
|
1551 |
data->Read(buf1);
|
sl@0
|
1552 |
file2.Read(buf2);
|
sl@0
|
1553 |
INFO_PRINTF2(_L("Position from ESeekStart test using CData: %d"), pos1);
|
sl@0
|
1554 |
INFO_PRINTF2(_L("Position from ESeekStart test using RFile: %d"), pos2);
|
sl@0
|
1555 |
if (buf1 != buf2 || pos1 != pos2 || pos1 != size/4)
|
sl@0
|
1556 |
{
|
sl@0
|
1557 |
INFO_PRINTF1(_L("ERROR buffers or position do not match"));
|
sl@0
|
1558 |
SetTestStepResult(EFail);
|
sl@0
|
1559 |
}
|
sl@0
|
1560 |
|
sl@0
|
1561 |
// set the location within the file then retrieve the current location within the file
|
sl@0
|
1562 |
pos1=0;
|
sl@0
|
1563 |
pos2=0;
|
sl@0
|
1564 |
data->Seek(ESeekCurrent, pos1);
|
sl@0
|
1565 |
file2.Seek(ESeekCurrent, pos2);
|
sl@0
|
1566 |
|
sl@0
|
1567 |
INFO_PRINTF2(_L("Current position using CData: %d"), pos1);
|
sl@0
|
1568 |
INFO_PRINTF2(_L("Current position using RFile: %d"), pos2);
|
sl@0
|
1569 |
|
sl@0
|
1570 |
if(pos1 != pos2 || pos1 != (size/4 + buf1.Length()))
|
sl@0
|
1571 |
{
|
sl@0
|
1572 |
INFO_PRINTF1(_L("ERROR buffers or position do not match"));
|
sl@0
|
1573 |
SetTestStepResult(EFail);
|
sl@0
|
1574 |
}
|
sl@0
|
1575 |
|
sl@0
|
1576 |
// Seek and read from current using both CAF and RFile
|
sl@0
|
1577 |
pos1 = size/4;
|
sl@0
|
1578 |
data->Seek(ESeekCurrent, pos1);
|
sl@0
|
1579 |
pos2 = size/4;
|
sl@0
|
1580 |
file2.Seek(ESeekCurrent, pos2);
|
sl@0
|
1581 |
data->Read(buf1);
|
sl@0
|
1582 |
file2.Read(buf2);
|
sl@0
|
1583 |
INFO_PRINTF2(_L("Position from ESeekCurrent test using CData: %d"), pos1);
|
sl@0
|
1584 |
INFO_PRINTF2(_L("Position from ESeekCurrent test using RFile: %d"), pos2);
|
sl@0
|
1585 |
if (buf1 != buf2 || pos1 != pos2 || pos1 != (size/2 + buf1.Length()))
|
sl@0
|
1586 |
{
|
sl@0
|
1587 |
INFO_PRINTF1(_L("ERROR buffers or position do not match"));
|
sl@0
|
1588 |
SetTestStepResult(EFail);
|
sl@0
|
1589 |
}
|
sl@0
|
1590 |
|
sl@0
|
1591 |
// Seek and read from end using both CAF and RFile
|
sl@0
|
1592 |
pos1 = -size/4;
|
sl@0
|
1593 |
data->Seek(ESeekEnd, pos1);
|
sl@0
|
1594 |
pos2 = -size/4;
|
sl@0
|
1595 |
file2.Seek(ESeekEnd, pos2);
|
sl@0
|
1596 |
data->Read(buf1);
|
sl@0
|
1597 |
file2.Read(buf2);
|
sl@0
|
1598 |
INFO_PRINTF2(_L("Position from ESeekEnd test using CData: %d"), pos1);
|
sl@0
|
1599 |
INFO_PRINTF2(_L("Position from ESeekEnd test using RFile: %d"), pos2);
|
sl@0
|
1600 |
if (buf1 != buf2 || pos1 != pos2 || pos1 != (size - size/4))
|
sl@0
|
1601 |
{
|
sl@0
|
1602 |
INFO_PRINTF1(_L("ERROR buffers or position do not match"));
|
sl@0
|
1603 |
SetTestStepResult(EFail);
|
sl@0
|
1604 |
}
|
sl@0
|
1605 |
|
sl@0
|
1606 |
// Test other overloaded forms of CData::Read
|
sl@0
|
1607 |
|
sl@0
|
1608 |
// Read only 1 byte using both CAF and RFile
|
sl@0
|
1609 |
pos1 = size/4;
|
sl@0
|
1610 |
data->Seek(ESeekStart, pos1);
|
sl@0
|
1611 |
pos2 = size/4;
|
sl@0
|
1612 |
file2.Seek(ESeekStart, pos2);
|
sl@0
|
1613 |
data->Read(buf1,1);
|
sl@0
|
1614 |
file2.Read(buf2,1);
|
sl@0
|
1615 |
INFO_PRINTF2(_L("Data Length from CData::Read(TDesC& ,TInt Length) : %d"), buf1.Length());
|
sl@0
|
1616 |
INFO_PRINTF2(_L("Data Length from RFile::Read(TDesC& , TInt Length): %d"), buf2.Length());
|
sl@0
|
1617 |
|
sl@0
|
1618 |
pos1=0;
|
sl@0
|
1619 |
pos2=0;
|
sl@0
|
1620 |
data->Seek(ESeekCurrent, pos1);
|
sl@0
|
1621 |
file2.Seek(ESeekCurrent,pos2);
|
sl@0
|
1622 |
if (buf1 != buf2 || pos1 != pos2 || buf1.Length() != buf2.Length())
|
sl@0
|
1623 |
{
|
sl@0
|
1624 |
INFO_PRINTF1(_L("ERROR buffers or position do not match"));
|
sl@0
|
1625 |
SetTestStepResult(EFail);
|
sl@0
|
1626 |
}
|
sl@0
|
1627 |
|
sl@0
|
1628 |
// Read asynchronously using both CAF and RFile
|
sl@0
|
1629 |
INFO_PRINTF1(_L("Asynchronous read from CAF and RFile"));
|
sl@0
|
1630 |
pos1 = size/4;
|
sl@0
|
1631 |
data->Seek(ESeekStart, pos1);
|
sl@0
|
1632 |
pos2 = size/4;
|
sl@0
|
1633 |
file2.Seek(ESeekStart, pos2);
|
sl@0
|
1634 |
status = KRequestPending;
|
sl@0
|
1635 |
data->Read(buf1,status);
|
sl@0
|
1636 |
User::WaitForRequest(status);
|
sl@0
|
1637 |
status = KRequestPending;
|
sl@0
|
1638 |
file2.Read(buf2,status);
|
sl@0
|
1639 |
User::WaitForRequest(status);
|
sl@0
|
1640 |
INFO_PRINTF2(_L("Data length from CData::Read(TDesC& ,TRequestStatus& aStatus): %d"), buf1.Length());
|
sl@0
|
1641 |
INFO_PRINTF2(_L("Data length from RFile::Read(TDesC& , TRequestStatus& aStatus): %d"), buf2.Length());
|
sl@0
|
1642 |
|
sl@0
|
1643 |
pos1=0;
|
sl@0
|
1644 |
pos2=0;
|
sl@0
|
1645 |
data->Seek(ESeekCurrent, pos1);
|
sl@0
|
1646 |
file2.Seek(ESeekCurrent,pos2);
|
sl@0
|
1647 |
if (buf1 != buf2 || pos1 != pos2 || buf1.Length() != buf2.Length())
|
sl@0
|
1648 |
{
|
sl@0
|
1649 |
INFO_PRINTF1(_L("ERROR buffers or position do not match"));
|
sl@0
|
1650 |
SetTestStepResult(EFail);
|
sl@0
|
1651 |
}
|
sl@0
|
1652 |
|
sl@0
|
1653 |
// Read only 1 byte asynchronously using both CAF and RFile
|
sl@0
|
1654 |
INFO_PRINTF1(_L("Asynchronous read of 1 byte from CAF and RFile"));
|
sl@0
|
1655 |
pos1 = size/4;
|
sl@0
|
1656 |
data->Seek(ESeekStart, pos1);
|
sl@0
|
1657 |
pos2 = size/4;
|
sl@0
|
1658 |
file2.Seek(ESeekStart, pos2);
|
sl@0
|
1659 |
status = KRequestPending;
|
sl@0
|
1660 |
data->Read(buf1,1,status);
|
sl@0
|
1661 |
User::WaitForRequest(status);
|
sl@0
|
1662 |
status = KRequestPending;
|
sl@0
|
1663 |
file2.Read(buf2,1, status);
|
sl@0
|
1664 |
User::WaitForRequest(status);
|
sl@0
|
1665 |
INFO_PRINTF2(_L("Data Length from CData::Read(TDesC& ,TInt Length, TRequestStatus aStatus) : %d"), buf1.Length());
|
sl@0
|
1666 |
INFO_PRINTF2(_L("Data Length from RFile::Read(TDesC& , TInt Length, TRequestStatus aStatus): %d"), buf2.Length());
|
sl@0
|
1667 |
|
sl@0
|
1668 |
pos1=0;
|
sl@0
|
1669 |
pos2=0;
|
sl@0
|
1670 |
data->Seek(ESeekCurrent, pos1);
|
sl@0
|
1671 |
file2.Seek(ESeekCurrent,pos2);
|
sl@0
|
1672 |
if (buf1 != buf2 || pos1 != pos2 || buf1.Length() != buf2.Length())
|
sl@0
|
1673 |
{
|
sl@0
|
1674 |
INFO_PRINTF1(_L("ERROR buffers or position do not match"));
|
sl@0
|
1675 |
SetTestStepResult(EFail);
|
sl@0
|
1676 |
}
|
sl@0
|
1677 |
|
sl@0
|
1678 |
// read past EOF
|
sl@0
|
1679 |
pos1 = size+1;
|
sl@0
|
1680 |
pos2 = size+1;
|
sl@0
|
1681 |
data->Seek(ESeekStart, pos1);
|
sl@0
|
1682 |
file2.Seek(ESeekStart, pos2);
|
sl@0
|
1683 |
data->Read(buf1);
|
sl@0
|
1684 |
file2.Read(buf2);
|
sl@0
|
1685 |
|
sl@0
|
1686 |
if(buf1.Length() != 0 || buf1.Length() != 0)
|
sl@0
|
1687 |
{
|
sl@0
|
1688 |
INFO_PRINTF1(_L("ERROR data read past EOF"));
|
sl@0
|
1689 |
SetTestStepResult(EFail);
|
sl@0
|
1690 |
}
|
sl@0
|
1691 |
|
sl@0
|
1692 |
CleanupStack::PopAndDestroy(4);
|
sl@0
|
1693 |
|
sl@0
|
1694 |
__UHEAP_MARKEND;
|
sl@0
|
1695 |
|
sl@0
|
1696 |
if (TestStepResult() != EFail)
|
sl@0
|
1697 |
{
|
sl@0
|
1698 |
SetTestStepResult(EPass);
|
sl@0
|
1699 |
}
|
sl@0
|
1700 |
|
sl@0
|
1701 |
return TestStepResult();
|
sl@0
|
1702 |
}
|
sl@0
|
1703 |
|
sl@0
|
1704 |
/*
|
sl@0
|
1705 |
* Step reads from a CData from multiple threads using RFile handle
|
sl@0
|
1706 |
*
|
sl@0
|
1707 |
*/
|
sl@0
|
1708 |
|
sl@0
|
1709 |
CCAFHandleMultiThreadCDataStep::~CCAFHandleMultiThreadCDataStep()
|
sl@0
|
1710 |
{
|
sl@0
|
1711 |
|
sl@0
|
1712 |
}
|
sl@0
|
1713 |
|
sl@0
|
1714 |
CCAFHandleMultiThreadCDataStep::CCAFHandleMultiThreadCDataStep(CCAFServer& aParent)
|
sl@0
|
1715 |
:iParent(aParent)
|
sl@0
|
1716 |
{
|
sl@0
|
1717 |
|
sl@0
|
1718 |
SetTestStepName(KCAFHandleMultiThreadCDataStep);
|
sl@0
|
1719 |
}
|
sl@0
|
1720 |
|
sl@0
|
1721 |
TVerdict CCAFHandleMultiThreadCDataStep::doTestStepL()
|
sl@0
|
1722 |
{
|
sl@0
|
1723 |
TBuf8<2> buf;
|
sl@0
|
1724 |
|
sl@0
|
1725 |
__UHEAP_MARK;
|
sl@0
|
1726 |
_LIT(KCDataThread,"CData_Thread");
|
sl@0
|
1727 |
|
sl@0
|
1728 |
SetTestStepResult(EInconclusive);
|
sl@0
|
1729 |
|
sl@0
|
1730 |
INFO_PRINTF1(_L("Multi Thread CData Test using RFile Handle"));
|
sl@0
|
1731 |
|
sl@0
|
1732 |
TPtrC uri;
|
sl@0
|
1733 |
GetStringFromConfig(ConfigSection(),_L("URI"),uri);
|
sl@0
|
1734 |
|
sl@0
|
1735 |
INFO_PRINTF1(_L("Creating data object from content"));
|
sl@0
|
1736 |
RFile file;
|
sl@0
|
1737 |
User::LeaveIfError(file.Open(iParent.Fs(), uri, EFileRead));
|
sl@0
|
1738 |
|
sl@0
|
1739 |
CleanupClosePushL(file);
|
sl@0
|
1740 |
|
sl@0
|
1741 |
CContent* content = CContent::NewLC(file);
|
sl@0
|
1742 |
CData* data = content->OpenContentL(EPeek);
|
sl@0
|
1743 |
CleanupStack::PushL(data);
|
sl@0
|
1744 |
|
sl@0
|
1745 |
TInt size, pos;
|
sl@0
|
1746 |
|
sl@0
|
1747 |
// Create a mutex for communication between our thread and the new thread
|
sl@0
|
1748 |
RSemaphore threadSemaphore;
|
sl@0
|
1749 |
threadSemaphore.CreateGlobal(KCDataThreadSemaphore(), 1, EOwnerProcess);
|
sl@0
|
1750 |
threadSemaphore.Wait();
|
sl@0
|
1751 |
|
sl@0
|
1752 |
// fire up a new thread, stack size and heap size 8k, might need to be bigger in the future
|
sl@0
|
1753 |
RThread readerThread;
|
sl@0
|
1754 |
User::LeaveIfError(readerThread.Create(KCDataThread(),CCAFMultiThreadCDataStep::ReaderThreadEntry,8192, KMinHeapSize, 8192, (TAny *) data, EOwnerProcess));
|
sl@0
|
1755 |
|
sl@0
|
1756 |
// request notification of thread completion
|
sl@0
|
1757 |
TRequestStatus stat;
|
sl@0
|
1758 |
readerThread.Logon(stat);
|
sl@0
|
1759 |
readerThread.Resume();
|
sl@0
|
1760 |
|
sl@0
|
1761 |
|
sl@0
|
1762 |
data->DataSizeL(size);
|
sl@0
|
1763 |
pos = size/2;
|
sl@0
|
1764 |
data->Seek(ESeekStart,pos);
|
sl@0
|
1765 |
data->Read(buf);
|
sl@0
|
1766 |
|
sl@0
|
1767 |
threadSemaphore.Wait(); // wait for thread function to run and signal the semaphore
|
sl@0
|
1768 |
threadSemaphore.Signal(); // finished with semaphore
|
sl@0
|
1769 |
threadSemaphore.Close(); // so close
|
sl@0
|
1770 |
|
sl@0
|
1771 |
User::WaitForRequest(stat); // wait for thread to finish
|
sl@0
|
1772 |
TInt error=(readerThread.ExitType()==EExitPanic) ? KErrGeneral : stat.Int();
|
sl@0
|
1773 |
User::LeaveIfError(error);
|
sl@0
|
1774 |
readerThread.Close(); // close the thread
|
sl@0
|
1775 |
|
sl@0
|
1776 |
CleanupStack::PopAndDestroy(data);
|
sl@0
|
1777 |
CleanupStack::PopAndDestroy(content);
|
sl@0
|
1778 |
CleanupStack::PopAndDestroy(&file); //file
|
sl@0
|
1779 |
|
sl@0
|
1780 |
|
sl@0
|
1781 |
__UHEAP_MARKEND;
|
sl@0
|
1782 |
|
sl@0
|
1783 |
SetTestStepResult(EPass);
|
sl@0
|
1784 |
return TestStepResult();
|
sl@0
|
1785 |
}
|
sl@0
|
1786 |
|
sl@0
|
1787 |
TInt CCAFHandleMultiThreadCDataStep::ReaderThreadEntry(TAny *aPtr)
|
sl@0
|
1788 |
{
|
sl@0
|
1789 |
TBuf8 <2> buf;
|
sl@0
|
1790 |
CData *data = reinterpret_cast <CData *> (aPtr);
|
sl@0
|
1791 |
|
sl@0
|
1792 |
// create a trap handler
|
sl@0
|
1793 |
CTrapCleanup* cleanup = CTrapCleanup::New();
|
sl@0
|
1794 |
|
sl@0
|
1795 |
RSemaphore threadSemaphore;
|
sl@0
|
1796 |
threadSemaphore.OpenGlobal(KCDataThreadSemaphore() ,EOwnerProcess);
|
sl@0
|
1797 |
|
sl@0
|
1798 |
data->Read(buf);
|
sl@0
|
1799 |
threadSemaphore.Signal(); // allow original thread to continue
|
sl@0
|
1800 |
threadSemaphore.Close();
|
sl@0
|
1801 |
|
sl@0
|
1802 |
delete cleanup;
|
sl@0
|
1803 |
return KErrNone;
|
sl@0
|
1804 |
}
|
sl@0
|
1805 |
|
sl@0
|
1806 |
/*
|
sl@0
|
1807 |
* Data attribute step
|
sl@0
|
1808 |
*
|
sl@0
|
1809 |
*/
|
sl@0
|
1810 |
|
sl@0
|
1811 |
CCAFDataAttributeStep::~CCAFDataAttributeStep()
|
sl@0
|
1812 |
{
|
sl@0
|
1813 |
}
|
sl@0
|
1814 |
|
sl@0
|
1815 |
CCAFDataAttributeStep::CCAFDataAttributeStep(CCAFServer& aParent) : iParent(aParent)
|
sl@0
|
1816 |
{
|
sl@0
|
1817 |
SetTestStepName(KCAFDataAttributeStep);
|
sl@0
|
1818 |
}
|
sl@0
|
1819 |
|
sl@0
|
1820 |
TVerdict CCAFDataAttributeStep::doTestStepL()
|
sl@0
|
1821 |
{
|
sl@0
|
1822 |
#ifdef SYMBIAN_ENABLE_SDP_WMDRM_SUPPORT
|
sl@0
|
1823 |
TBool wmdrmFlag = EFalse;
|
sl@0
|
1824 |
GetBoolFromConfig(ConfigSection(),_L("wmdrmEnabled"), wmdrmFlag);
|
sl@0
|
1825 |
|
sl@0
|
1826 |
if(wmdrmFlag)
|
sl@0
|
1827 |
{
|
sl@0
|
1828 |
TVerdict verdict = doWmdrmTestStepL();
|
sl@0
|
1829 |
return verdict;
|
sl@0
|
1830 |
}
|
sl@0
|
1831 |
#endif //SYMBIAN_ENABLE_SDP_WMDRM_SUPPORT
|
sl@0
|
1832 |
|
sl@0
|
1833 |
TInt attribute;
|
sl@0
|
1834 |
TInt value = KErrNone;
|
sl@0
|
1835 |
TInt expectedValue = KErrNone;
|
sl@0
|
1836 |
TPtrC uri;
|
sl@0
|
1837 |
TPtrC uniqueId;
|
sl@0
|
1838 |
|
sl@0
|
1839 |
SetTestStepResult(EPass);
|
sl@0
|
1840 |
|
sl@0
|
1841 |
GetIntFromConfig(ConfigSection(),_L("attribute"),attribute);
|
sl@0
|
1842 |
GetStringFromConfig(ConfigSection(),_L("uri"),uri);
|
sl@0
|
1843 |
GetStringFromConfig(ConfigSection(),_L("uniqueid"),uniqueId);
|
sl@0
|
1844 |
GetIntFromConfig(ConfigSection(),_L("value"),expectedValue);
|
sl@0
|
1845 |
|
sl@0
|
1846 |
__UHEAP_MARK;
|
sl@0
|
1847 |
CContent *content = CContent::NewLC(uri);
|
sl@0
|
1848 |
CData *data = content->OpenContentL(EPeek, uniqueId);
|
sl@0
|
1849 |
User::LeaveIfError(data->GetAttribute(attribute, value));
|
sl@0
|
1850 |
delete data;
|
sl@0
|
1851 |
if(expectedValue != value)
|
sl@0
|
1852 |
{
|
sl@0
|
1853 |
SetTestStepResult(EFail);
|
sl@0
|
1854 |
INFO_PRINTF3(_L("CData::GetAttribute() Expected value: %d, actual value: %d"), expectedValue, value);
|
sl@0
|
1855 |
}
|
sl@0
|
1856 |
|
sl@0
|
1857 |
CleanupStack::PopAndDestroy(content);
|
sl@0
|
1858 |
__UHEAP_MARKEND;
|
sl@0
|
1859 |
return TestStepResult();
|
sl@0
|
1860 |
}
|
sl@0
|
1861 |
|
sl@0
|
1862 |
/*
|
sl@0
|
1863 |
* Data attributeset step
|
sl@0
|
1864 |
*
|
sl@0
|
1865 |
*/
|
sl@0
|
1866 |
|
sl@0
|
1867 |
CCAFDataAttributeSetStep::~CCAFDataAttributeSetStep()
|
sl@0
|
1868 |
{
|
sl@0
|
1869 |
}
|
sl@0
|
1870 |
|
sl@0
|
1871 |
CCAFDataAttributeSetStep::CCAFDataAttributeSetStep(CCAFServer& aParent) : iParent(aParent)
|
sl@0
|
1872 |
{
|
sl@0
|
1873 |
SetTestStepName(KCAFDataAttributeSetStep);
|
sl@0
|
1874 |
}
|
sl@0
|
1875 |
|
sl@0
|
1876 |
TVerdict CCAFDataAttributeSetStep::doTestStepL()
|
sl@0
|
1877 |
{
|
sl@0
|
1878 |
#ifdef SYMBIAN_ENABLE_SDP_WMDRM_SUPPORT
|
sl@0
|
1879 |
TBool wmdrmFlag = EFalse;
|
sl@0
|
1880 |
GetBoolFromConfig(ConfigSection(),_L("wmdrmEnabled"), wmdrmFlag);
|
sl@0
|
1881 |
|
sl@0
|
1882 |
if(wmdrmFlag)
|
sl@0
|
1883 |
{
|
sl@0
|
1884 |
TVerdict verdict = doWmdrmTestStepL();
|
sl@0
|
1885 |
return verdict;
|
sl@0
|
1886 |
}
|
sl@0
|
1887 |
#endif //SYMBIAN_ENABLE_SDP_WMDRM_SUPPORT
|
sl@0
|
1888 |
|
sl@0
|
1889 |
TInt expectedValue1;
|
sl@0
|
1890 |
TInt expectedValue2;
|
sl@0
|
1891 |
TInt value1;
|
sl@0
|
1892 |
TInt value2;
|
sl@0
|
1893 |
TInt attribute1;
|
sl@0
|
1894 |
TInt attribute2;
|
sl@0
|
1895 |
TInt result = KErrNone;
|
sl@0
|
1896 |
TPtrC uri;
|
sl@0
|
1897 |
TPtrC uniqueId;
|
sl@0
|
1898 |
|
sl@0
|
1899 |
SetTestStepResult(EPass);
|
sl@0
|
1900 |
|
sl@0
|
1901 |
GetStringFromConfig(ConfigSection(),_L("uri"),uri);
|
sl@0
|
1902 |
GetStringFromConfig(ConfigSection(),_L("uniqueid"),uniqueId);
|
sl@0
|
1903 |
GetIntFromConfig(ConfigSection(),_L("attribute1"),attribute1);
|
sl@0
|
1904 |
GetIntFromConfig(ConfigSection(),_L("attribute2"),attribute2);
|
sl@0
|
1905 |
GetIntFromConfig(ConfigSection(),_L("value1"),expectedValue1);
|
sl@0
|
1906 |
GetIntFromConfig(ConfigSection(),_L("value2"),expectedValue2);
|
sl@0
|
1907 |
|
sl@0
|
1908 |
__UHEAP_MARK;
|
sl@0
|
1909 |
CContent *content = CContent::NewLC(uri);
|
sl@0
|
1910 |
RAttributeSet attributeSet;
|
sl@0
|
1911 |
CleanupClosePushL(attributeSet);
|
sl@0
|
1912 |
attributeSet.AddL(attribute1);
|
sl@0
|
1913 |
attributeSet.AddL(attribute2);
|
sl@0
|
1914 |
|
sl@0
|
1915 |
CData *data = content->OpenContentL(EPeek, uniqueId);
|
sl@0
|
1916 |
result = data->GetAttributeSet(attributeSet);
|
sl@0
|
1917 |
delete data;
|
sl@0
|
1918 |
if(result != KErrNone)
|
sl@0
|
1919 |
{
|
sl@0
|
1920 |
SetTestStepResult(EFail);
|
sl@0
|
1921 |
INFO_PRINTF1(_L("CData::GetAttribute() failed"));
|
sl@0
|
1922 |
}
|
sl@0
|
1923 |
User::LeaveIfError(attributeSet.GetValue(attribute1, value1));
|
sl@0
|
1924 |
User::LeaveIfError(attributeSet.GetValue(attribute2, value2));
|
sl@0
|
1925 |
if(value1 != expectedValue1 || value2 != expectedValue2 || attributeSet.Count() != 2)
|
sl@0
|
1926 |
{
|
sl@0
|
1927 |
SetTestStepResult(EFail);
|
sl@0
|
1928 |
INFO_PRINTF1(_L("CData::GetAttributeSet() values don't match expected values"));
|
sl@0
|
1929 |
}
|
sl@0
|
1930 |
CleanupStack::PopAndDestroy(&attributeSet);
|
sl@0
|
1931 |
CleanupStack::PopAndDestroy(content);
|
sl@0
|
1932 |
|
sl@0
|
1933 |
__UHEAP_MARKEND;
|
sl@0
|
1934 |
return TestStepResult();
|
sl@0
|
1935 |
}
|
sl@0
|
1936 |
|
sl@0
|
1937 |
|
sl@0
|
1938 |
/*
|
sl@0
|
1939 |
* Data string attribute step
|
sl@0
|
1940 |
*
|
sl@0
|
1941 |
*/
|
sl@0
|
1942 |
|
sl@0
|
1943 |
CCAFDataStringAttributeStep::~CCAFDataStringAttributeStep()
|
sl@0
|
1944 |
{
|
sl@0
|
1945 |
}
|
sl@0
|
1946 |
|
sl@0
|
1947 |
CCAFDataStringAttributeStep::CCAFDataStringAttributeStep(CCAFServer& aParent) : iParent(aParent)
|
sl@0
|
1948 |
{
|
sl@0
|
1949 |
SetTestStepName(KCAFDataStringAttributeStep);
|
sl@0
|
1950 |
}
|
sl@0
|
1951 |
|
sl@0
|
1952 |
TVerdict CCAFDataStringAttributeStep::doTestStepL()
|
sl@0
|
1953 |
{
|
sl@0
|
1954 |
#ifdef SYMBIAN_ENABLE_SDP_WMDRM_SUPPORT
|
sl@0
|
1955 |
TBool wmdrmFlag = EFalse;
|
sl@0
|
1956 |
GetBoolFromConfig(ConfigSection(),_L("wmdrmEnabled"), wmdrmFlag);
|
sl@0
|
1957 |
|
sl@0
|
1958 |
if(wmdrmFlag)
|
sl@0
|
1959 |
{
|
sl@0
|
1960 |
TVerdict verdict = doWmdrmTestStepL();
|
sl@0
|
1961 |
return verdict;
|
sl@0
|
1962 |
}
|
sl@0
|
1963 |
#endif //SYMBIAN_ENABLE_SDP_WMDRM_SUPPORT
|
sl@0
|
1964 |
|
sl@0
|
1965 |
TInt expectedResult;
|
sl@0
|
1966 |
TInt attribute;
|
sl@0
|
1967 |
TPtrC expectedValue;
|
sl@0
|
1968 |
TBuf <200> value;
|
sl@0
|
1969 |
TInt result = KErrNone;
|
sl@0
|
1970 |
TPtrC uri;
|
sl@0
|
1971 |
TPtrC uniqueId;
|
sl@0
|
1972 |
|
sl@0
|
1973 |
SetTestStepResult(EPass);
|
sl@0
|
1974 |
|
sl@0
|
1975 |
GetIntFromConfig(ConfigSection(),_L("attribute"),attribute);
|
sl@0
|
1976 |
GetStringFromConfig(ConfigSection(),_L("uri"),uri);
|
sl@0
|
1977 |
GetStringFromConfig(ConfigSection(),_L("uniqueid"),uniqueId);
|
sl@0
|
1978 |
GetStringFromConfig(ConfigSection(),_L("value"),expectedValue);
|
sl@0
|
1979 |
GetIntFromConfig(ConfigSection(),_L("result"),expectedResult);
|
sl@0
|
1980 |
|
sl@0
|
1981 |
__UHEAP_MARK;
|
sl@0
|
1982 |
CContent *content = CContent::NewLC(uri);
|
sl@0
|
1983 |
CData *data = content->OpenContentL(EPeek, uniqueId);
|
sl@0
|
1984 |
result = data->GetStringAttribute(attribute, value);
|
sl@0
|
1985 |
delete data;
|
sl@0
|
1986 |
if(result != expectedResult)
|
sl@0
|
1987 |
{
|
sl@0
|
1988 |
SetTestStepResult(EFail);
|
sl@0
|
1989 |
INFO_PRINTF3(_L("CData::GetStringAttribute() Expected result: %d, actual result: %d"), expectedResult, result);
|
sl@0
|
1990 |
}
|
sl@0
|
1991 |
if(value != expectedValue)
|
sl@0
|
1992 |
{
|
sl@0
|
1993 |
SetTestStepResult(EFail);
|
sl@0
|
1994 |
INFO_PRINTF3(_L("CData::GetStringAttribute() Expected value: %S, actual result: %S"), &expectedValue, &value);
|
sl@0
|
1995 |
}
|
sl@0
|
1996 |
|
sl@0
|
1997 |
CleanupStack::PopAndDestroy(content);
|
sl@0
|
1998 |
|
sl@0
|
1999 |
__UHEAP_MARKEND;
|
sl@0
|
2000 |
return TestStepResult();
|
sl@0
|
2001 |
}
|
sl@0
|
2002 |
|
sl@0
|
2003 |
/*
|
sl@0
|
2004 |
* Data StringAttributeSet step
|
sl@0
|
2005 |
*
|
sl@0
|
2006 |
*/
|
sl@0
|
2007 |
|
sl@0
|
2008 |
CCAFDataStringAttributeSetStep::~CCAFDataStringAttributeSetStep()
|
sl@0
|
2009 |
{
|
sl@0
|
2010 |
}
|
sl@0
|
2011 |
|
sl@0
|
2012 |
CCAFDataStringAttributeSetStep::CCAFDataStringAttributeSetStep(CCAFServer& aParent) : iParent(aParent)
|
sl@0
|
2013 |
{
|
sl@0
|
2014 |
SetTestStepName(KCAFDataStringAttributeSetStep);
|
sl@0
|
2015 |
}
|
sl@0
|
2016 |
|
sl@0
|
2017 |
TVerdict CCAFDataStringAttributeSetStep::doTestStepL()
|
sl@0
|
2018 |
{
|
sl@0
|
2019 |
#ifdef SYMBIAN_ENABLE_SDP_WMDRM_SUPPORT
|
sl@0
|
2020 |
TBool wmdrmFlag = EFalse;
|
sl@0
|
2021 |
GetBoolFromConfig(ConfigSection(),_L("wmdrmEnabled"), wmdrmFlag);
|
sl@0
|
2022 |
|
sl@0
|
2023 |
if(wmdrmFlag)
|
sl@0
|
2024 |
{
|
sl@0
|
2025 |
TVerdict verdict = doWmdrmTestStepL();
|
sl@0
|
2026 |
return verdict;
|
sl@0
|
2027 |
}
|
sl@0
|
2028 |
#endif //SYMBIAN_ENABLE_SDP_WMDRM_SUPPORT
|
sl@0
|
2029 |
|
sl@0
|
2030 |
TPtrC expectedValue1;
|
sl@0
|
2031 |
TPtrC expectedValue2;
|
sl@0
|
2032 |
TBuf <200> value1;
|
sl@0
|
2033 |
TBuf <200> value2;
|
sl@0
|
2034 |
TInt attribute1;
|
sl@0
|
2035 |
TInt attribute2;
|
sl@0
|
2036 |
TInt result = KErrNone;
|
sl@0
|
2037 |
TInt result1;
|
sl@0
|
2038 |
TInt result2;
|
sl@0
|
2039 |
TPtrC uri;
|
sl@0
|
2040 |
TPtrC uniqueId;
|
sl@0
|
2041 |
|
sl@0
|
2042 |
SetTestStepResult(EPass);
|
sl@0
|
2043 |
|
sl@0
|
2044 |
GetStringFromConfig(ConfigSection(),_L("uri"),uri);
|
sl@0
|
2045 |
GetStringFromConfig(ConfigSection(),_L("uniqueid"),uniqueId);
|
sl@0
|
2046 |
GetIntFromConfig(ConfigSection(),_L("attribute1"),attribute1);
|
sl@0
|
2047 |
GetIntFromConfig(ConfigSection(),_L("attribute2"),attribute2);
|
sl@0
|
2048 |
GetStringFromConfig(ConfigSection(),_L("value1"),expectedValue1);
|
sl@0
|
2049 |
GetStringFromConfig(ConfigSection(),_L("value2"),expectedValue2);
|
sl@0
|
2050 |
GetIntFromConfig(ConfigSection(),_L("result1"),result1);
|
sl@0
|
2051 |
GetIntFromConfig(ConfigSection(),_L("result2"),result2);
|
sl@0
|
2052 |
|
sl@0
|
2053 |
__UHEAP_MARK;
|
sl@0
|
2054 |
CContent *content = CContent::NewLC(uri);
|
sl@0
|
2055 |
RStringAttributeSet attributeSet;
|
sl@0
|
2056 |
CleanupClosePushL(attributeSet);
|
sl@0
|
2057 |
attributeSet.AddL(attribute1);
|
sl@0
|
2058 |
attributeSet.AddL(attribute2);
|
sl@0
|
2059 |
|
sl@0
|
2060 |
CData *data = content->OpenContentL(EPeek, uniqueId);
|
sl@0
|
2061 |
result = data->GetStringAttributeSet(attributeSet);
|
sl@0
|
2062 |
delete data;
|
sl@0
|
2063 |
if(result != KErrNone)
|
sl@0
|
2064 |
{
|
sl@0
|
2065 |
SetTestStepResult(EFail);
|
sl@0
|
2066 |
INFO_PRINTF1(_L("CData::GetAttribute() failed"));
|
sl@0
|
2067 |
}
|
sl@0
|
2068 |
if(result1 != attributeSet.GetValue(attribute1, value1))
|
sl@0
|
2069 |
{
|
sl@0
|
2070 |
INFO_PRINTF1(_L("RStringAttributeSet::GetValue failed"));
|
sl@0
|
2071 |
}
|
sl@0
|
2072 |
if(result2 != attributeSet.GetValue(attribute2, value2))
|
sl@0
|
2073 |
{
|
sl@0
|
2074 |
INFO_PRINTF1(_L("RStringAttributeSet::GetValue failed"));
|
sl@0
|
2075 |
}
|
sl@0
|
2076 |
if( value1 != expectedValue1 || value2 != expectedValue2 || attributeSet.Count() != 2)
|
sl@0
|
2077 |
{
|
sl@0
|
2078 |
SetTestStepResult(EFail);
|
sl@0
|
2079 |
INFO_PRINTF1(_L("CData::GetAttributeSet() values don't match expected values"));
|
sl@0
|
2080 |
}
|
sl@0
|
2081 |
CleanupStack::PopAndDestroy(&attributeSet);
|
sl@0
|
2082 |
CleanupStack::PopAndDestroy(content);
|
sl@0
|
2083 |
|
sl@0
|
2084 |
|
sl@0
|
2085 |
__UHEAP_MARKEND;
|
sl@0
|
2086 |
return TestStepResult();
|
sl@0
|
2087 |
}
|
sl@0
|
2088 |
|
sl@0
|
2089 |
|
sl@0
|
2090 |
CCAFExecuteIntentStep::~CCAFExecuteIntentStep()
|
sl@0
|
2091 |
{
|
sl@0
|
2092 |
}
|
sl@0
|
2093 |
|
sl@0
|
2094 |
CCAFExecuteIntentStep::CCAFExecuteIntentStep(CCAFServer& aParent)
|
sl@0
|
2095 |
: iParent(aParent)
|
sl@0
|
2096 |
{
|
sl@0
|
2097 |
SetTestStepName(KCAFSizeStep);
|
sl@0
|
2098 |
}
|
sl@0
|
2099 |
|
sl@0
|
2100 |
TVerdict CCAFExecuteIntentStep::doTestStepL()
|
sl@0
|
2101 |
{
|
sl@0
|
2102 |
__UHEAP_MARK;
|
sl@0
|
2103 |
|
sl@0
|
2104 |
SetTestStepResult(EInconclusive);
|
sl@0
|
2105 |
|
sl@0
|
2106 |
INFO_PRINTF1(_L("Execute Intent Test"));
|
sl@0
|
2107 |
|
sl@0
|
2108 |
TPtrC fileName;
|
sl@0
|
2109 |
TPtrC uniqueId;
|
sl@0
|
2110 |
TInt intent = EPeek;
|
sl@0
|
2111 |
TInt expectedResult = KErrNone;
|
sl@0
|
2112 |
|
sl@0
|
2113 |
GetStringFromConfig(ConfigSection(),_L("FileName"),fileName);
|
sl@0
|
2114 |
GetStringFromConfig(ConfigSection(),_L("UniqueId"),uniqueId);
|
sl@0
|
2115 |
GetIntFromConfig(ConfigSection(),_L("Intent"),intent);
|
sl@0
|
2116 |
GetIntFromConfig(ConfigSection(),_L("ExpectedResult"),expectedResult);
|
sl@0
|
2117 |
|
sl@0
|
2118 |
INFO_PRINTF3(_L("Creating CData object with filename: %S, UniqueId: %S"), &fileName, &uniqueId);
|
sl@0
|
2119 |
|
sl@0
|
2120 |
CData* data = NULL;
|
sl@0
|
2121 |
|
sl@0
|
2122 |
TRAPD(err, data = CData::NewL(TVirtualPathPtr(fileName, uniqueId),static_cast<TIntent>(intent), EContentShareReadOnly));
|
sl@0
|
2123 |
|
sl@0
|
2124 |
if(err != expectedResult)
|
sl@0
|
2125 |
{
|
sl@0
|
2126 |
INFO_PRINTF2(_L("Unexpected result, EvaluateIntent() returned %d"), err);
|
sl@0
|
2127 |
}
|
sl@0
|
2128 |
else
|
sl@0
|
2129 |
{
|
sl@0
|
2130 |
SetTestStepResult(EPass);
|
sl@0
|
2131 |
if(err == KErrNone)
|
sl@0
|
2132 |
{
|
sl@0
|
2133 |
err = data->ExecuteIntent(static_cast<TIntent>(intent));
|
sl@0
|
2134 |
if(err == KErrNone)
|
sl@0
|
2135 |
{
|
sl@0
|
2136 |
TBuf8 <128> buffer;
|
sl@0
|
2137 |
TInt length = 128;
|
sl@0
|
2138 |
|
sl@0
|
2139 |
// read the entire content object
|
sl@0
|
2140 |
while(err == KErrNone && length > 0)
|
sl@0
|
2141 |
{
|
sl@0
|
2142 |
err = data->Read(buffer);
|
sl@0
|
2143 |
length = buffer.Length();
|
sl@0
|
2144 |
}
|
sl@0
|
2145 |
if(err != KErrEof && err != KErrNone)
|
sl@0
|
2146 |
{
|
sl@0
|
2147 |
INFO_PRINTF2(_L("Unexpected error while reading content object: %d"), err);
|
sl@0
|
2148 |
SetTestStepResult(EFail);
|
sl@0
|
2149 |
}
|
sl@0
|
2150 |
}
|
sl@0
|
2151 |
else
|
sl@0
|
2152 |
{
|
sl@0
|
2153 |
INFO_PRINTF2(_L("Unexpected error, EvaluteIntent succeeded but ExecuteIntent failed with error: %d"), err);
|
sl@0
|
2154 |
SetTestStepResult(EFail);
|
sl@0
|
2155 |
}
|
sl@0
|
2156 |
}
|
sl@0
|
2157 |
}
|
sl@0
|
2158 |
|
sl@0
|
2159 |
delete data;
|
sl@0
|
2160 |
|
sl@0
|
2161 |
__UHEAP_MARKEND;
|
sl@0
|
2162 |
return TestStepResult();
|
sl@0
|
2163 |
}
|
sl@0
|
2164 |
|
sl@0
|
2165 |
/*
|
sl@0
|
2166 |
* DRM File Open Performance Test Step
|
sl@0
|
2167 |
*
|
sl@0
|
2168 |
*/
|
sl@0
|
2169 |
|
sl@0
|
2170 |
CCAFDRMFileOpenPerformanceTest::~CCAFDRMFileOpenPerformanceTest()
|
sl@0
|
2171 |
{
|
sl@0
|
2172 |
iIterationSum = 0;
|
sl@0
|
2173 |
}
|
sl@0
|
2174 |
|
sl@0
|
2175 |
CCAFDRMFileOpenPerformanceTest::CCAFDRMFileOpenPerformanceTest(CCAFServer& aParent) : iParent(aParent)
|
sl@0
|
2176 |
{
|
sl@0
|
2177 |
SetTestStepName(KCAFDRMFileOpenPerformanceStep);
|
sl@0
|
2178 |
}
|
sl@0
|
2179 |
|
sl@0
|
2180 |
TVerdict CCAFDRMFileOpenPerformanceTest::doTestStepL()
|
sl@0
|
2181 |
{
|
sl@0
|
2182 |
__UHEAP_MARK;
|
sl@0
|
2183 |
|
sl@0
|
2184 |
INFO_PRINTF1(_L("DRM File Open Performance Test"));
|
sl@0
|
2185 |
|
sl@0
|
2186 |
TPtrC inputFileName;
|
sl@0
|
2187 |
TInt maxValue = 0 ,iterCount = 0;
|
sl@0
|
2188 |
|
sl@0
|
2189 |
GetStringFromConfig(ConfigSection(),_L("FileName"),inputFileName);
|
sl@0
|
2190 |
GetIntFromConfig(ConfigSection(),_L("IterationCount"),iterCount);
|
sl@0
|
2191 |
GetIntFromConfig(ConfigSection(),_L("MaxTimeLimitInMS"),maxValue);
|
sl@0
|
2192 |
|
sl@0
|
2193 |
iIterationSum=0;
|
sl@0
|
2194 |
// iterated iterCount times to get the average time taken to open the file.
|
sl@0
|
2195 |
for (TInt i = 0; i < iterCount; ++i)
|
sl@0
|
2196 |
{
|
sl@0
|
2197 |
OpenAndReadFileContentL(inputFileName);
|
sl@0
|
2198 |
}
|
sl@0
|
2199 |
|
sl@0
|
2200 |
TInt tickPeriod;
|
sl@0
|
2201 |
HAL::Get(HAL::ENanoTickPeriod, tickPeriod);
|
sl@0
|
2202 |
TInt nTickPeriodMS = tickPeriod / KCafTestSecToMS;
|
sl@0
|
2203 |
|
sl@0
|
2204 |
TInt avgTimeForFileOpen = (iIterationSum * nTickPeriodMS) / iterCount;
|
sl@0
|
2205 |
if((avgTimeForFileOpen > maxValue))
|
sl@0
|
2206 |
{
|
sl@0
|
2207 |
INFO_PRINTF1(_L("Performance Test failed."));
|
sl@0
|
2208 |
SetTestStepResult(EFail);
|
sl@0
|
2209 |
}
|
sl@0
|
2210 |
|
sl@0
|
2211 |
INFO_PRINTF2(_L("Expected maximum time to open DRM file in millisecs is : %d"), maxValue);
|
sl@0
|
2212 |
INFO_PRINTF2(_L("Obtained time in millisecs is: %d"), avgTimeForFileOpen);
|
sl@0
|
2213 |
|
sl@0
|
2214 |
__UHEAP_MARKEND;
|
sl@0
|
2215 |
|
sl@0
|
2216 |
return TestStepResult();
|
sl@0
|
2217 |
}
|
sl@0
|
2218 |
|
sl@0
|
2219 |
void CCAFDRMFileOpenPerformanceTest::OpenAndReadFileContentL(const TDesC& aFileName)
|
sl@0
|
2220 |
{
|
sl@0
|
2221 |
TPtrC uniqueIdentifier;
|
sl@0
|
2222 |
|
sl@0
|
2223 |
GetStringFromConfig(ConfigSection(),_L("UniqueId"),uniqueIdentifier);
|
sl@0
|
2224 |
CContent *content = CContent::NewLC(aFileName);
|
sl@0
|
2225 |
CData *data = NULL;
|
sl@0
|
2226 |
TUint32 tickCounterValBeforeFileOpen, tickCounterValAfterFileOpen;
|
sl@0
|
2227 |
if(uniqueIdentifier.Length() > 0)
|
sl@0
|
2228 |
{
|
sl@0
|
2229 |
tickCounterValBeforeFileOpen = User::NTickCount();
|
sl@0
|
2230 |
data = content->OpenContentL(EPeek,uniqueIdentifier);
|
sl@0
|
2231 |
tickCounterValAfterFileOpen = User::NTickCount();
|
sl@0
|
2232 |
}
|
sl@0
|
2233 |
else
|
sl@0
|
2234 |
{
|
sl@0
|
2235 |
tickCounterValBeforeFileOpen = User::NTickCount();
|
sl@0
|
2236 |
data = content->OpenContentL(EPeek);
|
sl@0
|
2237 |
tickCounterValAfterFileOpen = User::NTickCount();
|
sl@0
|
2238 |
}
|
sl@0
|
2239 |
delete data;
|
sl@0
|
2240 |
// finished with Data object
|
sl@0
|
2241 |
CleanupStack::PopAndDestroy(content);
|
sl@0
|
2242 |
iIterationSum += tickCounterValAfterFileOpen - tickCounterValBeforeFileOpen;
|
sl@0
|
2243 |
}
|
sl@0
|
2244 |
|
sl@0
|
2245 |
#ifdef SYMBIAN_ENABLE_SDP_WMDRM_SUPPORT
|
sl@0
|
2246 |
|
sl@0
|
2247 |
CWmdrmCAFContentStep::~CWmdrmCAFContentStep()
|
sl@0
|
2248 |
{
|
sl@0
|
2249 |
}
|
sl@0
|
2250 |
|
sl@0
|
2251 |
CWmdrmCAFContentStep::CWmdrmCAFContentStep()
|
sl@0
|
2252 |
{
|
sl@0
|
2253 |
SetTestStepName(KWmdrmCAFContentStep);
|
sl@0
|
2254 |
}
|
sl@0
|
2255 |
|
sl@0
|
2256 |
|
sl@0
|
2257 |
TVerdict CWmdrmCAFContentStep::doTestStepL()
|
sl@0
|
2258 |
{
|
sl@0
|
2259 |
SetTestStepResult(EFail);
|
sl@0
|
2260 |
|
sl@0
|
2261 |
TBool protectedVal;
|
sl@0
|
2262 |
GetBoolFromConfig(ConfigSection(),_L("attribValue1"), protectedVal);
|
sl@0
|
2263 |
TBool forwardable;
|
sl@0
|
2264 |
GetBoolFromConfig(ConfigSection(),_L("attribValue2"), forwardable);
|
sl@0
|
2265 |
|
sl@0
|
2266 |
TBool headerDataPresent = ETrue;
|
sl@0
|
2267 |
GetBoolFromConfig(ConfigSection(),_L("headerDataFlag"), headerDataPresent);
|
sl@0
|
2268 |
|
sl@0
|
2269 |
INFO_PRINTF1(_L("Verify CContent APIs for WMDRM content"));
|
sl@0
|
2270 |
|
sl@0
|
2271 |
__UHEAP_MARK;
|
sl@0
|
2272 |
|
sl@0
|
2273 |
CContent* content = NULL;
|
sl@0
|
2274 |
|
sl@0
|
2275 |
// this condition verifies that CContent construction leaves with KErrMissingWmdrmHeaderData,
|
sl@0
|
2276 |
// when no header data is provided.
|
sl@0
|
2277 |
if(!headerDataPresent)
|
sl@0
|
2278 |
{
|
sl@0
|
2279 |
content = CContent::NewL(KNullDesC8());
|
sl@0
|
2280 |
return EPass;
|
sl@0
|
2281 |
}
|
sl@0
|
2282 |
|
sl@0
|
2283 |
// create a dummy header data.
|
sl@0
|
2284 |
HBufC8* headerData = CreateWmdrmHeaderLC();
|
sl@0
|
2285 |
|
sl@0
|
2286 |
// Open a file and retrieve the attributes.
|
sl@0
|
2287 |
// If headerDataPresent is false, the code will never reach here.s
|
sl@0
|
2288 |
content = CContent::NewL(*headerData);
|
sl@0
|
2289 |
CleanupStack::PushL(content);
|
sl@0
|
2290 |
CAttribute* attrs = content->NewAttributeL(ETrue);
|
sl@0
|
2291 |
CleanupStack::PushL(attrs);
|
sl@0
|
2292 |
|
sl@0
|
2293 |
TBool value1 = attrs->ResponseSet().IsSet(EIsProtected);
|
sl@0
|
2294 |
TBool value2 = attrs->ResponseSet().IsSet(EIsForwardable);
|
sl@0
|
2295 |
if(value1 == protectedVal && value2 == forwardable)
|
sl@0
|
2296 |
{
|
sl@0
|
2297 |
SetTestStepResult(EPass);
|
sl@0
|
2298 |
}
|
sl@0
|
2299 |
|
sl@0
|
2300 |
CleanupStack::PopAndDestroy(3, headerData);
|
sl@0
|
2301 |
|
sl@0
|
2302 |
__UHEAP_MARKEND;
|
sl@0
|
2303 |
return TestStepResult();
|
sl@0
|
2304 |
}
|
sl@0
|
2305 |
|
sl@0
|
2306 |
|
sl@0
|
2307 |
CWmdrmCAFDataStep::~CWmdrmCAFDataStep()
|
sl@0
|
2308 |
{
|
sl@0
|
2309 |
}
|
sl@0
|
2310 |
|
sl@0
|
2311 |
CWmdrmCAFDataStep::CWmdrmCAFDataStep()
|
sl@0
|
2312 |
{
|
sl@0
|
2313 |
SetTestStepName(KWmdrmCAFDataStep);
|
sl@0
|
2314 |
}
|
sl@0
|
2315 |
|
sl@0
|
2316 |
TVerdict CWmdrmCAFDataStep::doTestStepL()
|
sl@0
|
2317 |
{
|
sl@0
|
2318 |
SetTestStepResult(EFail);
|
sl@0
|
2319 |
|
sl@0
|
2320 |
TInt attribute;
|
sl@0
|
2321 |
TInt expectedValue = KErrNone;
|
sl@0
|
2322 |
|
sl@0
|
2323 |
GetIntFromConfig(ConfigSection(),_L("attribute"), attribute);
|
sl@0
|
2324 |
GetIntFromConfig(ConfigSection(),_L("value"), expectedValue);
|
sl@0
|
2325 |
|
sl@0
|
2326 |
__UHEAP_MARK;
|
sl@0
|
2327 |
|
sl@0
|
2328 |
HBufC8* headerData = CreateWmdrmHeaderLC();
|
sl@0
|
2329 |
|
sl@0
|
2330 |
CContent *content = CContent::NewLC(*headerData);
|
sl@0
|
2331 |
CData *data = content->OpenContentL(EPeek);
|
sl@0
|
2332 |
TInt value = KErrNone;
|
sl@0
|
2333 |
User::LeaveIfError(data->GetAttribute(attribute, value));
|
sl@0
|
2334 |
delete data;
|
sl@0
|
2335 |
|
sl@0
|
2336 |
if(expectedValue == value)
|
sl@0
|
2337 |
{
|
sl@0
|
2338 |
SetTestStepResult(EPass);
|
sl@0
|
2339 |
}
|
sl@0
|
2340 |
else
|
sl@0
|
2341 |
{
|
sl@0
|
2342 |
INFO_PRINTF3(_L("CData::GetAttribute() Expected value: %d, actual value: %d"), expectedValue, value);
|
sl@0
|
2343 |
}
|
sl@0
|
2344 |
|
sl@0
|
2345 |
CleanupStack::PopAndDestroy(2, headerData);
|
sl@0
|
2346 |
__UHEAP_MARKEND;
|
sl@0
|
2347 |
|
sl@0
|
2348 |
return TestStepResult();
|
sl@0
|
2349 |
}
|
sl@0
|
2350 |
|
sl@0
|
2351 |
|
sl@0
|
2352 |
CWmdrmCAFReadStep::~CWmdrmCAFReadStep()
|
sl@0
|
2353 |
{
|
sl@0
|
2354 |
}
|
sl@0
|
2355 |
|
sl@0
|
2356 |
CWmdrmCAFReadStep::CWmdrmCAFReadStep()
|
sl@0
|
2357 |
{
|
sl@0
|
2358 |
SetTestStepName(KWmdrmCAFReadStep);
|
sl@0
|
2359 |
}
|
sl@0
|
2360 |
|
sl@0
|
2361 |
|
sl@0
|
2362 |
TVerdict CWmdrmCAFReadStep::doTestStepL()
|
sl@0
|
2363 |
{
|
sl@0
|
2364 |
SetTestStepResult(EFail);
|
sl@0
|
2365 |
|
sl@0
|
2366 |
TBool synchronous = EFalse;
|
sl@0
|
2367 |
GetBoolFromConfig(ConfigSection(),_L("synchronous"), synchronous);
|
sl@0
|
2368 |
TBool intent = EFalse;
|
sl@0
|
2369 |
GetBoolFromConfig(ConfigSection(),_L("intent"), intent);
|
sl@0
|
2370 |
TPtrC inputPacket;
|
sl@0
|
2371 |
GetStringFromConfig(ConfigSection(),_L("inputPacket"), inputPacket);
|
sl@0
|
2372 |
TPtrC expectedOutput;
|
sl@0
|
2373 |
GetStringFromConfig(ConfigSection(),_L("outputPacket"), expectedOutput);
|
sl@0
|
2374 |
|
sl@0
|
2375 |
__UHEAP_MARK;
|
sl@0
|
2376 |
TPtrC header;
|
sl@0
|
2377 |
HBufC8* headerData = NULL;
|
sl@0
|
2378 |
|
sl@0
|
2379 |
if(GetStringFromConfig(ConfigSection(),_L("header"), header))
|
sl@0
|
2380 |
{
|
sl@0
|
2381 |
headerData = ConvertDes16toHBufC8LC(header);
|
sl@0
|
2382 |
}
|
sl@0
|
2383 |
else
|
sl@0
|
2384 |
{
|
sl@0
|
2385 |
headerData = CreateWmdrmHeaderLC();
|
sl@0
|
2386 |
}
|
sl@0
|
2387 |
|
sl@0
|
2388 |
TInt result = 0;
|
sl@0
|
2389 |
if(!synchronous)
|
sl@0
|
2390 |
{
|
sl@0
|
2391 |
result = TestAsynchronousReadL(*headerData, intent, inputPacket, expectedOutput);
|
sl@0
|
2392 |
}
|
sl@0
|
2393 |
else
|
sl@0
|
2394 |
{
|
sl@0
|
2395 |
result = TestSynchronousReadL(*headerData, intent, inputPacket, expectedOutput);
|
sl@0
|
2396 |
}
|
sl@0
|
2397 |
|
sl@0
|
2398 |
if(result == KErrNone)
|
sl@0
|
2399 |
{
|
sl@0
|
2400 |
SetTestStepResult(EPass);
|
sl@0
|
2401 |
}
|
sl@0
|
2402 |
|
sl@0
|
2403 |
CleanupStack::PopAndDestroy(headerData);
|
sl@0
|
2404 |
__UHEAP_MARKEND;
|
sl@0
|
2405 |
|
sl@0
|
2406 |
return TestStepResult();
|
sl@0
|
2407 |
}
|
sl@0
|
2408 |
|
sl@0
|
2409 |
TInt CWmdrmCAFReadStep::TestSynchronousReadL(const TDesC8& aHeaderData, TBool aIntent, TDesC& aInputPacket, TDesC& aExpectedOutput)
|
sl@0
|
2410 |
{
|
sl@0
|
2411 |
__UHEAP_MARK;
|
sl@0
|
2412 |
CData* data = NULL;
|
sl@0
|
2413 |
TInt returnVal = KErrGeneral;
|
sl@0
|
2414 |
|
sl@0
|
2415 |
if(aIntent)
|
sl@0
|
2416 |
{
|
sl@0
|
2417 |
data = CData::NewL(aHeaderData, EPeek);
|
sl@0
|
2418 |
}
|
sl@0
|
2419 |
else
|
sl@0
|
2420 |
{
|
sl@0
|
2421 |
data = CData::NewL(aHeaderData);
|
sl@0
|
2422 |
}
|
sl@0
|
2423 |
|
sl@0
|
2424 |
CleanupStack::PushL(data);
|
sl@0
|
2425 |
|
sl@0
|
2426 |
if(aInputPacket.Length() <= 0)
|
sl@0
|
2427 |
{
|
sl@0
|
2428 |
// dummy output buffer.This loop essentially tests the error condition KErrInsufficientDataPacketLength.
|
sl@0
|
2429 |
TBuf8<2> outputBuffer;
|
sl@0
|
2430 |
User::LeaveIfError(data->Read(KNullDesC8(), outputBuffer));
|
sl@0
|
2431 |
}
|
sl@0
|
2432 |
|
sl@0
|
2433 |
else
|
sl@0
|
2434 |
{
|
sl@0
|
2435 |
HBufC8* inputPacket = ConvertDes16toHBufC8LC(aInputPacket);
|
sl@0
|
2436 |
HBufC8* outputPacket = HBufC8::NewLC(aInputPacket.Length());
|
sl@0
|
2437 |
TPtr8 outputPacketPtr = outputPacket->Des();
|
sl@0
|
2438 |
|
sl@0
|
2439 |
User::LeaveIfError(data->Read(*inputPacket, outputPacketPtr));
|
sl@0
|
2440 |
HBufC8* expectedOutput = ConvertDes16toHBufC8LC(aExpectedOutput);
|
sl@0
|
2441 |
if(expectedOutput->Compare(*outputPacket) == KErrNone)
|
sl@0
|
2442 |
{
|
sl@0
|
2443 |
returnVal = KErrNone;
|
sl@0
|
2444 |
}
|
sl@0
|
2445 |
|
sl@0
|
2446 |
CleanupStack::PopAndDestroy(3, inputPacket);
|
sl@0
|
2447 |
}
|
sl@0
|
2448 |
|
sl@0
|
2449 |
CleanupStack::PopAndDestroy(data);
|
sl@0
|
2450 |
__UHEAP_MARKEND;
|
sl@0
|
2451 |
|
sl@0
|
2452 |
return returnVal;
|
sl@0
|
2453 |
}
|
sl@0
|
2454 |
|
sl@0
|
2455 |
TInt CWmdrmCAFReadStep::TestAsynchronousReadL(const TDesC8& aHeaderData, TBool aIntent, TDesC& aInputPacket, TDesC& aExpectedOutput)
|
sl@0
|
2456 |
{
|
sl@0
|
2457 |
__UHEAP_MARK;
|
sl@0
|
2458 |
CData* data = NULL;
|
sl@0
|
2459 |
TInt returnVal = KErrGeneral;
|
sl@0
|
2460 |
|
sl@0
|
2461 |
if(aIntent)
|
sl@0
|
2462 |
{
|
sl@0
|
2463 |
data = CData::NewL(aHeaderData, EPeek);
|
sl@0
|
2464 |
}
|
sl@0
|
2465 |
else
|
sl@0
|
2466 |
{
|
sl@0
|
2467 |
data = CData::NewL(aHeaderData);
|
sl@0
|
2468 |
}
|
sl@0
|
2469 |
|
sl@0
|
2470 |
CleanupStack::PushL(data);
|
sl@0
|
2471 |
|
sl@0
|
2472 |
if(aInputPacket.Length() <= 0)
|
sl@0
|
2473 |
{
|
sl@0
|
2474 |
TBuf8<2> outputBuffer;
|
sl@0
|
2475 |
User::LeaveIfError(data->Read(KNullDesC8(), outputBuffer));
|
sl@0
|
2476 |
}
|
sl@0
|
2477 |
|
sl@0
|
2478 |
else
|
sl@0
|
2479 |
{
|
sl@0
|
2480 |
HBufC8* inputPacket = ConvertDes16toHBufC8LC(aInputPacket);
|
sl@0
|
2481 |
HBufC8* outputPacket = HBufC8::NewLC(aInputPacket.Length());
|
sl@0
|
2482 |
TPtr8 outputPacketPtr = outputPacket->Des();
|
sl@0
|
2483 |
|
sl@0
|
2484 |
TRequestStatus status;
|
sl@0
|
2485 |
data->Read(*inputPacket, outputPacketPtr, status);
|
sl@0
|
2486 |
User::WaitForRequest(status);
|
sl@0
|
2487 |
|
sl@0
|
2488 |
if(status.Int() != KErrNone)
|
sl@0
|
2489 |
{
|
sl@0
|
2490 |
CleanupStack::PopAndDestroy(3, data);
|
sl@0
|
2491 |
return status.Int();
|
sl@0
|
2492 |
}
|
sl@0
|
2493 |
|
sl@0
|
2494 |
HBufC8* expectedOutput = ConvertDes16toHBufC8LC(aExpectedOutput);
|
sl@0
|
2495 |
if(expectedOutput->Compare(*outputPacket) == KErrNone)
|
sl@0
|
2496 |
{
|
sl@0
|
2497 |
returnVal = KErrNone;
|
sl@0
|
2498 |
}
|
sl@0
|
2499 |
|
sl@0
|
2500 |
CleanupStack::PopAndDestroy(3, inputPacket);
|
sl@0
|
2501 |
}
|
sl@0
|
2502 |
|
sl@0
|
2503 |
CleanupStack::PopAndDestroy(data);
|
sl@0
|
2504 |
__UHEAP_MARKEND;
|
sl@0
|
2505 |
|
sl@0
|
2506 |
return returnVal;
|
sl@0
|
2507 |
}
|
sl@0
|
2508 |
|
sl@0
|
2509 |
TVerdict CCAFDataAttributeStep::doWmdrmTestStepL()
|
sl@0
|
2510 |
{
|
sl@0
|
2511 |
SetTestStepResult(EFail);
|
sl@0
|
2512 |
|
sl@0
|
2513 |
TInt attribVal;
|
sl@0
|
2514 |
GetIntFromConfig(ConfigSection(),_L("attribute"), attribVal);
|
sl@0
|
2515 |
|
sl@0
|
2516 |
TInt expectedValue;
|
sl@0
|
2517 |
GetIntFromConfig(ConfigSection(),_L("value"), expectedValue);
|
sl@0
|
2518 |
|
sl@0
|
2519 |
__UHEAP_MARK;
|
sl@0
|
2520 |
TPtrC header;
|
sl@0
|
2521 |
HBufC8* headerData = NULL;
|
sl@0
|
2522 |
|
sl@0
|
2523 |
if(GetStringFromConfig(ConfigSection(),_L("header"), header))
|
sl@0
|
2524 |
{
|
sl@0
|
2525 |
headerData = ConvertDes16toHBufC8LC(header);
|
sl@0
|
2526 |
}
|
sl@0
|
2527 |
else
|
sl@0
|
2528 |
{
|
sl@0
|
2529 |
headerData = CreateWmdrmHeaderLC();
|
sl@0
|
2530 |
}
|
sl@0
|
2531 |
|
sl@0
|
2532 |
CContent *content = CContent::NewLC(*headerData);
|
sl@0
|
2533 |
CData *data = content->OpenContentL(EPeek);
|
sl@0
|
2534 |
TInt value;
|
sl@0
|
2535 |
User::LeaveIfError(data->GetAttribute(attribVal, value));
|
sl@0
|
2536 |
delete data;
|
sl@0
|
2537 |
|
sl@0
|
2538 |
if(expectedValue == value)
|
sl@0
|
2539 |
{
|
sl@0
|
2540 |
SetTestStepResult(EPass);
|
sl@0
|
2541 |
}
|
sl@0
|
2542 |
else
|
sl@0
|
2543 |
{
|
sl@0
|
2544 |
INFO_PRINTF3(_L("CData::GetAttribute() Expected value: %d, actual value: %d"), expectedValue, value);
|
sl@0
|
2545 |
}
|
sl@0
|
2546 |
|
sl@0
|
2547 |
CleanupStack::PopAndDestroy(2, headerData);
|
sl@0
|
2548 |
__UHEAP_MARKEND;
|
sl@0
|
2549 |
|
sl@0
|
2550 |
return TestStepResult();
|
sl@0
|
2551 |
}
|
sl@0
|
2552 |
|
sl@0
|
2553 |
|
sl@0
|
2554 |
TVerdict CCAFDataAttributeSetStep::doWmdrmTestStepL()
|
sl@0
|
2555 |
{
|
sl@0
|
2556 |
SetTestStepResult(EFail);
|
sl@0
|
2557 |
|
sl@0
|
2558 |
TInt attribute1;
|
sl@0
|
2559 |
GetIntFromConfig(ConfigSection(),_L("attribute1"),attribute1);
|
sl@0
|
2560 |
|
sl@0
|
2561 |
TInt attribute2;
|
sl@0
|
2562 |
GetIntFromConfig(ConfigSection(),_L("attribute2"),attribute2);
|
sl@0
|
2563 |
|
sl@0
|
2564 |
TInt expectedValue1;
|
sl@0
|
2565 |
GetIntFromConfig(ConfigSection(),_L("value1"),expectedValue1);
|
sl@0
|
2566 |
|
sl@0
|
2567 |
TInt expectedValue2;
|
sl@0
|
2568 |
GetIntFromConfig(ConfigSection(),_L("value2"),expectedValue2);
|
sl@0
|
2569 |
|
sl@0
|
2570 |
__UHEAP_MARK;
|
sl@0
|
2571 |
|
sl@0
|
2572 |
TPtrC header;
|
sl@0
|
2573 |
HBufC8* headerData = NULL;
|
sl@0
|
2574 |
|
sl@0
|
2575 |
if(GetStringFromConfig(ConfigSection(),_L("header"), header))
|
sl@0
|
2576 |
{
|
sl@0
|
2577 |
headerData = ConvertDes16toHBufC8LC(header);
|
sl@0
|
2578 |
}
|
sl@0
|
2579 |
else
|
sl@0
|
2580 |
{
|
sl@0
|
2581 |
headerData = CreateWmdrmHeaderLC();
|
sl@0
|
2582 |
}
|
sl@0
|
2583 |
|
sl@0
|
2584 |
CContent *content = CContent::NewLC(*headerData);
|
sl@0
|
2585 |
CData *data = content->OpenContentL(EPeek);
|
sl@0
|
2586 |
|
sl@0
|
2587 |
RAttributeSet attributeSet;
|
sl@0
|
2588 |
CleanupClosePushL(attributeSet);
|
sl@0
|
2589 |
attributeSet.AddL(attribute1);
|
sl@0
|
2590 |
attributeSet.AddL(attribute2);
|
sl@0
|
2591 |
|
sl@0
|
2592 |
TInt result = data->GetAttributeSet(attributeSet);
|
sl@0
|
2593 |
delete data;
|
sl@0
|
2594 |
|
sl@0
|
2595 |
if(result == KErrNone)
|
sl@0
|
2596 |
{
|
sl@0
|
2597 |
TInt value1;
|
sl@0
|
2598 |
User::LeaveIfError(attributeSet.GetValue(attribute1, value1));
|
sl@0
|
2599 |
|
sl@0
|
2600 |
TInt value2;
|
sl@0
|
2601 |
User::LeaveIfError(attributeSet.GetValue(attribute2, value2));
|
sl@0
|
2602 |
|
sl@0
|
2603 |
if(expectedValue1 == value1 && expectedValue2 == value2 && attributeSet.Count() == 2)
|
sl@0
|
2604 |
{
|
sl@0
|
2605 |
SetTestStepResult(EPass);
|
sl@0
|
2606 |
}
|
sl@0
|
2607 |
else
|
sl@0
|
2608 |
{
|
sl@0
|
2609 |
INFO_PRINTF1(_L("CData::GetAttributeSet() values don't match expected values"));
|
sl@0
|
2610 |
}
|
sl@0
|
2611 |
}
|
sl@0
|
2612 |
|
sl@0
|
2613 |
else
|
sl@0
|
2614 |
{
|
sl@0
|
2615 |
INFO_PRINTF1(_L("CData::GetAttributeSet() failed"));
|
sl@0
|
2616 |
}
|
sl@0
|
2617 |
|
sl@0
|
2618 |
CleanupStack::PopAndDestroy(3, headerData);
|
sl@0
|
2619 |
|
sl@0
|
2620 |
__UHEAP_MARKEND;
|
sl@0
|
2621 |
|
sl@0
|
2622 |
return TestStepResult();
|
sl@0
|
2623 |
}
|
sl@0
|
2624 |
|
sl@0
|
2625 |
|
sl@0
|
2626 |
TVerdict CCAFDataStringAttributeStep::doWmdrmTestStepL()
|
sl@0
|
2627 |
{
|
sl@0
|
2628 |
SetTestStepResult(EFail);
|
sl@0
|
2629 |
|
sl@0
|
2630 |
TInt attribVal;
|
sl@0
|
2631 |
GetIntFromConfig(ConfigSection(),_L("attribute"),attribVal);
|
sl@0
|
2632 |
|
sl@0
|
2633 |
TPtrC expectedValue;
|
sl@0
|
2634 |
GetStringFromConfig(ConfigSection(),_L("value"),expectedValue);
|
sl@0
|
2635 |
|
sl@0
|
2636 |
TInt expectedResult;
|
sl@0
|
2637 |
GetIntFromConfig(ConfigSection(),_L("result"),expectedResult);
|
sl@0
|
2638 |
|
sl@0
|
2639 |
__UHEAP_MARK;
|
sl@0
|
2640 |
TPtrC header;
|
sl@0
|
2641 |
HBufC8* headerData = NULL;
|
sl@0
|
2642 |
|
sl@0
|
2643 |
if(GetStringFromConfig(ConfigSection(),_L("header"), header))
|
sl@0
|
2644 |
{
|
sl@0
|
2645 |
headerData = ConvertDes16toHBufC8LC(header);
|
sl@0
|
2646 |
}
|
sl@0
|
2647 |
else
|
sl@0
|
2648 |
{
|
sl@0
|
2649 |
headerData = CreateWmdrmHeaderLC();
|
sl@0
|
2650 |
}
|
sl@0
|
2651 |
|
sl@0
|
2652 |
CContent *content = CContent::NewLC(*headerData);
|
sl@0
|
2653 |
CData *data = content->OpenContentL(EPeek);
|
sl@0
|
2654 |
|
sl@0
|
2655 |
TBuf <200> value;
|
sl@0
|
2656 |
TInt result = data->GetStringAttribute(attribVal, value);
|
sl@0
|
2657 |
delete data;
|
sl@0
|
2658 |
|
sl@0
|
2659 |
if(result == expectedResult && value == expectedValue)
|
sl@0
|
2660 |
{
|
sl@0
|
2661 |
SetTestStepResult(EPass);
|
sl@0
|
2662 |
}
|
sl@0
|
2663 |
else
|
sl@0
|
2664 |
{
|
sl@0
|
2665 |
INFO_PRINTF3(_L("CData::GetStringAttribute() Expected result: %d, actual result: %d"), expectedResult, result);
|
sl@0
|
2666 |
INFO_PRINTF3(_L("CData::GetStringAttribute() Expected value: %S, actual value: %S"), &expectedValue, &value);
|
sl@0
|
2667 |
}
|
sl@0
|
2668 |
|
sl@0
|
2669 |
CleanupStack::PopAndDestroy(2, headerData);
|
sl@0
|
2670 |
|
sl@0
|
2671 |
__UHEAP_MARKEND;
|
sl@0
|
2672 |
|
sl@0
|
2673 |
return TestStepResult();
|
sl@0
|
2674 |
}
|
sl@0
|
2675 |
|
sl@0
|
2676 |
|
sl@0
|
2677 |
TVerdict CCAFDataStringAttributeSetStep::doWmdrmTestStepL()
|
sl@0
|
2678 |
{
|
sl@0
|
2679 |
SetTestStepResult(EFail);
|
sl@0
|
2680 |
|
sl@0
|
2681 |
TInt attribute1;
|
sl@0
|
2682 |
GetIntFromConfig(ConfigSection(),_L("attribute1"),attribute1);
|
sl@0
|
2683 |
|
sl@0
|
2684 |
TInt attribute2;
|
sl@0
|
2685 |
GetIntFromConfig(ConfigSection(),_L("attribute2"),attribute2);
|
sl@0
|
2686 |
|
sl@0
|
2687 |
TPtrC expectedValue1;
|
sl@0
|
2688 |
GetStringFromConfig(ConfigSection(),_L("value1"),expectedValue1);
|
sl@0
|
2689 |
|
sl@0
|
2690 |
TPtrC expectedValue2;
|
sl@0
|
2691 |
GetStringFromConfig(ConfigSection(),_L("value2"),expectedValue2);
|
sl@0
|
2692 |
|
sl@0
|
2693 |
__UHEAP_MARK;
|
sl@0
|
2694 |
TPtrC header;
|
sl@0
|
2695 |
HBufC8* headerData = NULL;
|
sl@0
|
2696 |
|
sl@0
|
2697 |
if(GetStringFromConfig(ConfigSection(),_L("header"), header))
|
sl@0
|
2698 |
{
|
sl@0
|
2699 |
headerData = ConvertDes16toHBufC8LC(header);
|
sl@0
|
2700 |
}
|
sl@0
|
2701 |
else
|
sl@0
|
2702 |
{
|
sl@0
|
2703 |
headerData = CreateWmdrmHeaderLC();
|
sl@0
|
2704 |
}
|
sl@0
|
2705 |
|
sl@0
|
2706 |
CContent *content = CContent::NewLC(*headerData);
|
sl@0
|
2707 |
CData *data = content->OpenContentL(EPeek);
|
sl@0
|
2708 |
|
sl@0
|
2709 |
RStringAttributeSet attributeSet;
|
sl@0
|
2710 |
CleanupClosePushL(attributeSet);
|
sl@0
|
2711 |
attributeSet.AddL(attribute1);
|
sl@0
|
2712 |
attributeSet.AddL(attribute2);
|
sl@0
|
2713 |
|
sl@0
|
2714 |
TInt result = data->GetStringAttributeSet(attributeSet);
|
sl@0
|
2715 |
delete data;
|
sl@0
|
2716 |
|
sl@0
|
2717 |
TBuf <200> value1;
|
sl@0
|
2718 |
TBuf <200> value2;
|
sl@0
|
2719 |
if(result == KErrNone)
|
sl@0
|
2720 |
{
|
sl@0
|
2721 |
TInt result3 = attributeSet.GetValue(attribute1, value1);
|
sl@0
|
2722 |
TInt result4 = attributeSet.GetValue(attribute2, value2);
|
sl@0
|
2723 |
|
sl@0
|
2724 |
if(value1 == expectedValue1 && value2 == expectedValue2 && attributeSet.Count() == 2
|
sl@0
|
2725 |
&& result3 == KErrNone && result4 == KErrNone)
|
sl@0
|
2726 |
{
|
sl@0
|
2727 |
SetTestStepResult(EPass);
|
sl@0
|
2728 |
}
|
sl@0
|
2729 |
else
|
sl@0
|
2730 |
{
|
sl@0
|
2731 |
INFO_PRINTF3(_L("RStringAttributeSet::GetValue() for attribute1.Expected value: %S, actual value: %S"), &expectedValue1, &value1);
|
sl@0
|
2732 |
INFO_PRINTF3(_L("RStringAttributeSet::GetValue() for attribute2.Expected value: %S, actual value: %S"), &expectedValue2, &value2);
|
sl@0
|
2733 |
INFO_PRINTF3(_L("RStringAttributeSet::GetValue() for attribute1. Expected result: %d, actual result: %d"), 0, result3);
|
sl@0
|
2734 |
INFO_PRINTF3(_L("RStringAttributeSet::GetValue() for attribute2. Expected result: %d, actual result: %d"), 0, result4);
|
sl@0
|
2735 |
}
|
sl@0
|
2736 |
}
|
sl@0
|
2737 |
else
|
sl@0
|
2738 |
{
|
sl@0
|
2739 |
INFO_PRINTF1(_L("CData::GetStringAttributeSet() failed"));
|
sl@0
|
2740 |
}
|
sl@0
|
2741 |
|
sl@0
|
2742 |
CleanupStack::PopAndDestroy(3, headerData);
|
sl@0
|
2743 |
|
sl@0
|
2744 |
__UHEAP_MARKEND;
|
sl@0
|
2745 |
|
sl@0
|
2746 |
return TestStepResult();
|
sl@0
|
2747 |
}
|
sl@0
|
2748 |
|
sl@0
|
2749 |
#endif //SYMBIAN_ENABLE_SDP_WMDRM_SUPPORT
|