|
1 /* |
|
2 * Copyright (c) 2004-2009 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of the License "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #include <test/testexecutelog.h> |
|
20 #include <s32mem.h> |
|
21 #include <caf/caf.h> |
|
22 #include "cafserver.h" |
|
23 #include "CafUtilsStep.h" |
|
24 |
|
25 #ifdef SYMBIAN_ENABLE_SDP_WMDRM_SUPPORT |
|
26 #include <test/refcafhelper.h> |
|
27 #include <caf/cafhelper.h> |
|
28 #endif //SYMBIAN_ENABLE_SDP_WMDRM_SUPPORT |
|
29 |
|
30 using namespace ContentAccess; |
|
31 |
|
32 |
|
33 CCafCDirStreamStep::~CCafCDirStreamStep() |
|
34 { |
|
35 } |
|
36 |
|
37 CCafCDirStreamStep::CCafCDirStreamStep(CCAFServer& aParent) : iParent(aParent) |
|
38 { |
|
39 SetTestStepName(KCAFCDirStreamStep); |
|
40 } |
|
41 |
|
42 |
|
43 TVerdict CCafCDirStreamStep::doTestStepL() |
|
44 { |
|
45 SetTestStepResult(EPass); |
|
46 |
|
47 _LIT(KTcafDir, "C:\\tcaf\\"); |
|
48 |
|
49 INFO_PRINTF1(_L("CDirStreamable test")); |
|
50 |
|
51 |
|
52 __UHEAP_MARK; |
|
53 |
|
54 CManager *manager = CManager::NewLC(); |
|
55 |
|
56 CDir *fileList = NULL; |
|
57 User::LeaveIfError(manager->GetDir(KTcafDir(),KNullUid, ESortByName, fileList)); |
|
58 |
|
59 CDirStreamable *newFileList = CDirStreamable::NewL(*fileList); |
|
60 delete fileList; |
|
61 |
|
62 // Create a buffer |
|
63 CBufFlat* buf = CBufFlat::NewL(50); |
|
64 CleanupStack::PushL(buf); |
|
65 |
|
66 // create write stream |
|
67 RBufWriteStream writeStream(*buf); |
|
68 CleanupClosePushL(writeStream); |
|
69 |
|
70 // write the directory to the stream |
|
71 newFileList->ExternalizeL(writeStream); |
|
72 CleanupStack::PopAndDestroy(&writeStream); |
|
73 |
|
74 // create read stream |
|
75 RBufReadStream readStream(*buf); |
|
76 CleanupClosePushL(readStream); |
|
77 |
|
78 // construct a new CDirStreamable from the stream |
|
79 CDirStreamable *streamDir = CDirStreamable::NewL(readStream); |
|
80 CleanupStack::PopAndDestroy(&readStream); |
|
81 |
|
82 for(TInt i = 0; i < newFileList->Count(); i++) |
|
83 { |
|
84 if((*newFileList)[i].iName != (*streamDir)[i].iName) |
|
85 { |
|
86 SetTestStepResult(EFail); |
|
87 } |
|
88 if((*newFileList)[i].iType != (*streamDir)[i].iType) |
|
89 { |
|
90 SetTestStepResult(EFail); |
|
91 } |
|
92 } |
|
93 |
|
94 CleanupStack::PopAndDestroy(buf); |
|
95 |
|
96 delete newFileList; |
|
97 delete streamDir; |
|
98 CleanupStack::PopAndDestroy(manager); |
|
99 |
|
100 __UHEAP_MARKEND; |
|
101 |
|
102 return TestStepResult(); |
|
103 } |
|
104 |
|
105 CCafRAttributeSetStreamStep::~CCafRAttributeSetStreamStep() |
|
106 { |
|
107 } |
|
108 |
|
109 CCafRAttributeSetStreamStep::CCafRAttributeSetStreamStep(CCAFServer& aParent) : iParent(aParent) |
|
110 { |
|
111 SetTestStepName(KCAFRAttributeSetStreamStep); |
|
112 } |
|
113 |
|
114 |
|
115 TVerdict CCafRAttributeSetStreamStep::doTestStepL() |
|
116 { |
|
117 SetTestStepResult(EPass); |
|
118 |
|
119 INFO_PRINTF1(_L("CRAttributeSet streaming test")); |
|
120 |
|
121 __UHEAP_MARK; |
|
122 |
|
123 |
|
124 RAttributeSet aSet; |
|
125 CleanupClosePushL(aSet); |
|
126 aSet.AddL(EIsProtected); |
|
127 aSet.AddL(EIsForwardable); |
|
128 aSet.AddL(EIsForwardable); |
|
129 |
|
130 aSet.SetValue(EIsProtected, (TInt) ETrue, KErrNone); |
|
131 aSet.SetValue(EIsForwardable, (TInt) EFalse, KErrNone); |
|
132 |
|
133 // Create a buffer |
|
134 CBufFlat* buf = CBufFlat::NewL(50); |
|
135 CleanupStack::PushL(buf); |
|
136 |
|
137 // create write stream |
|
138 RBufWriteStream writeStream(*buf); |
|
139 CleanupClosePushL(writeStream); |
|
140 |
|
141 // write the directory to the stream |
|
142 aSet.ExternalizeL(writeStream); |
|
143 CleanupStack::PopAndDestroy(&writeStream); |
|
144 |
|
145 // create read stream |
|
146 RBufReadStream readStream(*buf); |
|
147 CleanupClosePushL(readStream); |
|
148 |
|
149 // construct a new CDirStreamable from the stream |
|
150 RAttributeSet bSet; |
|
151 CleanupClosePushL(bSet); |
|
152 bSet.InternalizeL(readStream); |
|
153 |
|
154 TInt valueA, valueB; |
|
155 if(aSet.Count() != bSet.Count()) |
|
156 { |
|
157 SetTestStepResult(EFail); |
|
158 } |
|
159 |
|
160 for(TInt i = 0; i < aSet.Count(); i++) |
|
161 { |
|
162 valueA = -1; |
|
163 valueB = -1; |
|
164 if(aSet.GetValue(aSet[i],valueA) != bSet.GetValue(aSet[i],valueB)) |
|
165 { |
|
166 SetTestStepResult(EFail); |
|
167 } |
|
168 |
|
169 if(valueA != valueB) |
|
170 { |
|
171 SetTestStepResult(EFail); |
|
172 } |
|
173 } |
|
174 |
|
175 CleanupStack::PopAndDestroy(&bSet); |
|
176 CleanupStack::PopAndDestroy(&readStream); |
|
177 CleanupStack::PopAndDestroy(buf); |
|
178 CleanupStack::PopAndDestroy(&aSet); |
|
179 |
|
180 __UHEAP_MARKEND; |
|
181 |
|
182 return TestStepResult(); |
|
183 } |
|
184 |
|
185 |
|
186 CCafRStringAttributeSetStreamStep::~CCafRStringAttributeSetStreamStep() |
|
187 { |
|
188 } |
|
189 |
|
190 CCafRStringAttributeSetStreamStep::CCafRStringAttributeSetStreamStep(CCAFServer& aParent) : iParent(aParent) |
|
191 { |
|
192 SetTestStepName(KCAFRStringAttributeSetStreamStep); |
|
193 } |
|
194 |
|
195 |
|
196 TVerdict CCafRStringAttributeSetStreamStep::doTestStepL() |
|
197 { |
|
198 SetTestStepResult(EPass); |
|
199 |
|
200 INFO_PRINTF1(_L("CRStringAttributeSet streaming test")); |
|
201 |
|
202 _LIT(KMimeType,"mime/type"); |
|
203 |
|
204 __UHEAP_MARK; |
|
205 |
|
206 RStringAttributeSet aSet; |
|
207 CleanupClosePushL(aSet); |
|
208 aSet.AddL(EMimeType); |
|
209 aSet.AddL(EDescription); |
|
210 |
|
211 // Set some values, normally be done by the agent |
|
212 aSet.SetValue(EMimeType, KMimeType(), KErrNone); |
|
213 aSet.SetValue(EDescription, KNullDesC(), KErrNotSupported); |
|
214 |
|
215 // Create a buffer |
|
216 CBufFlat* buf = CBufFlat::NewL(50); |
|
217 CleanupStack::PushL(buf); |
|
218 |
|
219 // create write stream |
|
220 RBufWriteStream writeStream(*buf); |
|
221 CleanupClosePushL(writeStream); |
|
222 |
|
223 // write the directory to the stream |
|
224 aSet.ExternalizeL(writeStream); |
|
225 CleanupStack::PopAndDestroy(&writeStream); |
|
226 |
|
227 // create read stream |
|
228 RBufReadStream readStream(*buf); |
|
229 CleanupClosePushL(readStream); |
|
230 |
|
231 // construct a new CDirStreamable from the stream |
|
232 RStringAttributeSet bSet; |
|
233 CleanupClosePushL(bSet); |
|
234 bSet.InternalizeL(readStream); |
|
235 |
|
236 TBuf <1024> valueA; |
|
237 TBuf <1024> valueB; |
|
238 if(aSet.Count() != bSet.Count()) |
|
239 { |
|
240 SetTestStepResult(EFail); |
|
241 } |
|
242 |
|
243 for(TInt i = 0; i < aSet.Count(); i++) |
|
244 { |
|
245 valueA.SetLength(0); |
|
246 valueB.SetLength(0); |
|
247 if(aSet.GetValue(aSet[i],valueA) != bSet.GetValue(aSet[i],valueB)) |
|
248 { |
|
249 SetTestStepResult(EFail); |
|
250 } |
|
251 |
|
252 if(valueA != valueB) |
|
253 { |
|
254 SetTestStepResult(EFail); |
|
255 } |
|
256 } |
|
257 |
|
258 CleanupStack::PopAndDestroy(&bSet); |
|
259 CleanupStack::PopAndDestroy(&readStream); |
|
260 CleanupStack::PopAndDestroy(buf); |
|
261 CleanupStack::PopAndDestroy(&aSet); |
|
262 |
|
263 __UHEAP_MARKEND; |
|
264 |
|
265 return TestStepResult(); |
|
266 } |
|
267 |
|
268 |
|
269 |
|
270 CCafSupplierOutputFileStreamStep::~CCafSupplierOutputFileStreamStep() |
|
271 { |
|
272 } |
|
273 |
|
274 CCafSupplierOutputFileStreamStep::CCafSupplierOutputFileStreamStep(CCAFServer& aParent) : iParent(aParent) |
|
275 { |
|
276 SetTestStepName(KCAFSupplierOutputFileStreamStep); |
|
277 } |
|
278 |
|
279 |
|
280 TVerdict CCafSupplierOutputFileStreamStep::doTestStepL() |
|
281 { |
|
282 SetTestStepResult(EPass); |
|
283 |
|
284 _LIT(KDummyName, "C:\\tcaf\\supplieroutputfile.txt"); |
|
285 _LIT8(KDummyType, "something//caf"); |
|
286 |
|
287 INFO_PRINTF1(_L("CSupplierOutputFile test")); |
|
288 |
|
289 |
|
290 __UHEAP_MARK; |
|
291 |
|
292 CSupplierOutputFile *outputFile = CSupplierOutputFile::NewL(KDummyName(), EContent, KDummyType()); |
|
293 |
|
294 // Create a buffer |
|
295 CBufFlat* buf = CBufFlat::NewL(50); |
|
296 CleanupStack::PushL(buf); |
|
297 |
|
298 // create write stream |
|
299 RBufWriteStream writeStream(*buf); |
|
300 CleanupClosePushL(writeStream); |
|
301 |
|
302 // write the directory to the stream |
|
303 outputFile->ExternalizeL(writeStream); |
|
304 CleanupStack::PopAndDestroy(&writeStream); |
|
305 |
|
306 // create read stream |
|
307 RBufReadStream readStream(*buf); |
|
308 CleanupClosePushL(readStream); |
|
309 |
|
310 // construct a new CSupplierOutputFile from the stream |
|
311 CSupplierOutputFile *outputFile2= CSupplierOutputFile::NewL(readStream); |
|
312 CleanupStack::PopAndDestroy(&readStream); |
|
313 |
|
314 if(outputFile->FileName() != outputFile2->FileName()) |
|
315 { |
|
316 SetTestStepResult(EFail); |
|
317 } |
|
318 if(outputFile->OutputType() != outputFile2->OutputType()) |
|
319 { |
|
320 SetTestStepResult(EFail); |
|
321 } |
|
322 if(outputFile->MimeTypeL() != outputFile2->MimeTypeL()) |
|
323 { |
|
324 SetTestStepResult(EFail); |
|
325 } |
|
326 |
|
327 CleanupStack::PopAndDestroy(buf); |
|
328 |
|
329 delete outputFile; |
|
330 delete outputFile2; |
|
331 |
|
332 __UHEAP_MARKEND; |
|
333 |
|
334 return TestStepResult(); |
|
335 } |
|
336 |
|
337 CCafMetaDataArrayStep::~CCafMetaDataArrayStep() |
|
338 { |
|
339 } |
|
340 |
|
341 CCafMetaDataArrayStep::CCafMetaDataArrayStep(CCAFServer& aParent) : iParent(aParent) |
|
342 { |
|
343 SetTestStepName(KCAFMetaDataArrayStep); |
|
344 } |
|
345 |
|
346 |
|
347 TVerdict CCafMetaDataArrayStep::doTestStepL() |
|
348 { |
|
349 SetTestStepResult(EPass); |
|
350 |
|
351 _LIT(KTest1, "Cat"); |
|
352 _LIT(KValue1, "Sat"); |
|
353 |
|
354 _LIT8(KTest2, "Mellow"); |
|
355 _LIT8(KValue2, "Yellow"); |
|
356 |
|
357 _LIT8(KTest3, "Tree"); |
|
358 _LIT8(KValue3, "House"); |
|
359 |
|
360 |
|
361 INFO_PRINTF1(_L("CMetaDataArray test")); |
|
362 |
|
363 |
|
364 __UHEAP_MARK; |
|
365 |
|
366 CMetaDataArray *array = CMetaDataArray::NewLC(); |
|
367 array->AddL(KTest1(), KValue1()); |
|
368 array->AddL(KTest2(), KValue2()); |
|
369 array->AddL(KTest3(), KValue3()); |
|
370 |
|
371 // Create a buffer |
|
372 CBufFlat* buf = CBufFlat::NewL(50); |
|
373 CleanupStack::PushL(buf); |
|
374 |
|
375 // create write stream |
|
376 RBufWriteStream writeStream(*buf); |
|
377 CleanupClosePushL(writeStream); |
|
378 |
|
379 // write the directory to the stream |
|
380 array->ExternalizeL(writeStream); |
|
381 CleanupStack::PopAndDestroy(&writeStream); |
|
382 |
|
383 // create read stream |
|
384 RBufReadStream readStream(*buf); |
|
385 CleanupClosePushL(readStream); |
|
386 |
|
387 // construct a new CSupplierOutputFile from the stream |
|
388 CMetaDataArray *array2= CMetaDataArray::NewL(readStream); |
|
389 CleanupStack::PopAndDestroy(&readStream); |
|
390 |
|
391 |
|
392 if(array->Count() != array2->Count() || (*array)[0].Field() != KTest1() || (*array)[1].Data8() != KValue2()) |
|
393 { |
|
394 SetTestStepResult(EFail); |
|
395 } |
|
396 for(TInt i = 0; i < array->Count(); i++) |
|
397 { |
|
398 const CMetaData &a = (*array)[i]; |
|
399 const CMetaData &b = (*array2)[i]; |
|
400 if(a.Field() != b.Field()) |
|
401 { |
|
402 SetTestStepResult(EFail); |
|
403 } |
|
404 if(a.Field8() != b.Field8()) |
|
405 { |
|
406 SetTestStepResult(EFail); |
|
407 } |
|
408 if(a.Data() != b.Data()) |
|
409 { |
|
410 SetTestStepResult(EFail); |
|
411 } |
|
412 if(a.Data8() != b.Data8()) |
|
413 { |
|
414 SetTestStepResult(EFail); |
|
415 } |
|
416 } |
|
417 |
|
418 delete array2; |
|
419 |
|
420 CleanupStack::PopAndDestroy(buf); |
|
421 CleanupStack::PopAndDestroy(array); |
|
422 |
|
423 __UHEAP_MARKEND; |
|
424 |
|
425 return TestStepResult(); |
|
426 } |
|
427 |
|
428 |
|
429 CCafEmbeddedObjectStep::~CCafEmbeddedObjectStep() |
|
430 { |
|
431 } |
|
432 |
|
433 CCafEmbeddedObjectStep::CCafEmbeddedObjectStep(CCAFServer& aParent) : iParent(aParent) |
|
434 { |
|
435 SetTestStepName(KCAFEmbeddedObjectStep); |
|
436 } |
|
437 |
|
438 |
|
439 TVerdict CCafEmbeddedObjectStep::doTestStepL() |
|
440 { |
|
441 SetTestStepResult(EPass); |
|
442 |
|
443 _LIT(KTestUniqueId, "The UniqueId"); |
|
444 _LIT(KTestName, "The Name"); |
|
445 |
|
446 _LIT8(KTestMimeType, "The mime type"); |
|
447 |
|
448 |
|
449 INFO_PRINTF1(_L("CEmbeddedObject test")); |
|
450 |
|
451 |
|
452 __UHEAP_MARK; |
|
453 |
|
454 CEmbeddedObject *aObject = CEmbeddedObject::NewL(KTestUniqueId(), KTestName(), KTestMimeType(), EContentObject); |
|
455 |
|
456 // Create a buffer |
|
457 CBufFlat* buf = CBufFlat::NewL(50); |
|
458 CleanupStack::PushL(buf); |
|
459 |
|
460 // create write stream |
|
461 RBufWriteStream writeStream(*buf); |
|
462 CleanupClosePushL(writeStream); |
|
463 |
|
464 // write the directory to the stream |
|
465 aObject->ExternalizeL(writeStream); |
|
466 CleanupStack::PopAndDestroy(&writeStream); |
|
467 |
|
468 // create read stream |
|
469 RBufReadStream readStream(*buf); |
|
470 CleanupClosePushL(readStream); |
|
471 |
|
472 // construct a new CSupplierOutputFile from the stream |
|
473 CEmbeddedObject *bObject= CEmbeddedObject::NewL(readStream); |
|
474 CleanupStack::PopAndDestroy(&readStream); |
|
475 |
|
476 |
|
477 if(aObject->UniqueId() != bObject->UniqueId()) |
|
478 { |
|
479 SetTestStepResult(EFail); |
|
480 } |
|
481 |
|
482 if(aObject->Name() != bObject->Name()) |
|
483 { |
|
484 SetTestStepResult(EFail); |
|
485 } |
|
486 if(aObject->Type() != bObject->Type()) |
|
487 { |
|
488 SetTestStepResult(EFail); |
|
489 } |
|
490 if(aObject->MimeType() != bObject->MimeType()) |
|
491 { |
|
492 SetTestStepResult(EFail); |
|
493 } |
|
494 |
|
495 CleanupStack::PopAndDestroy(buf); |
|
496 delete aObject; |
|
497 delete bObject; |
|
498 |
|
499 __UHEAP_MARKEND; |
|
500 |
|
501 return TestStepResult(); |
|
502 } |
|
503 |
|
504 CCafVirtualPathStep::~CCafVirtualPathStep() |
|
505 { |
|
506 } |
|
507 |
|
508 CCafVirtualPathStep::CCafVirtualPathStep(CCAFServer& aParent) : iParent(aParent) |
|
509 { |
|
510 SetTestStepName(KCAFVirtualPathStep); |
|
511 } |
|
512 |
|
513 |
|
514 TVerdict CCafVirtualPathStep::doTestStepL() |
|
515 { |
|
516 SetTestStepResult(EPass); |
|
517 INFO_PRINTF1(_L("CVirtualPath test")); |
|
518 _LIT(KTestUniqueId, "The UniqueId"); |
|
519 _LIT(KTestUri, "A URI"); |
|
520 _LIT(KSection,"virtualpath"); |
|
521 _LIT(KDefaultUniqueID,"DEFAULT"); |
|
522 TPtrC uri; |
|
523 TPtrC uniqueID; |
|
524 TPtrC combined; |
|
525 TPtrC expecteduniqueid; |
|
526 TPtrC expecteduri; |
|
527 __UHEAP_MARK; |
|
528 |
|
529 /* test the creation of TVirtualPathPtr and CVirtualPath objects and check if they contain |
|
530 * the expected URI and UniqueID values. |
|
531 */ |
|
532 TInt i; |
|
533 for(i = 0;i<6;i++) |
|
534 { |
|
535 TBuf<13> sectionName(KSection); |
|
536 sectionName.AppendNum(i); |
|
537 GetStringFromConfig(sectionName,_L("uri"),uri); |
|
538 GetStringFromConfig(sectionName,_L("uniqueID"),uniqueID); |
|
539 GetStringFromConfig(sectionName,_L("combined"),combined); |
|
540 GetStringFromConfig(sectionName,_L("expecteduri"),expecteduri); |
|
541 GetStringFromConfig(sectionName,_L("expecteduniqueid"),expecteduniqueid); |
|
542 // Test the TVirtualPathPtr API |
|
543 TVirtualPathPtr vPath(uri,uniqueID); |
|
544 if(vPath.URI()!=expecteduri) |
|
545 { |
|
546 INFO_PRINTF4(_L("TVirtualPathPtr(uri,uniqueID) failed Uri for %S\nExpected %S\nGot %S"),&combined,&expecteduri,&vPath.URI()); |
|
547 SetTestStepResult(EFail); |
|
548 } |
|
549 if(vPath.UniqueId()!=expecteduniqueid) |
|
550 { |
|
551 INFO_PRINTF4(_L("TVirtualPathPtr(uri,uniqueID) failed uniqueID for %S\nExpected %S\nGot %S"),&combined,&expecteduniqueid,&vPath.UniqueId()); |
|
552 SetTestStepResult(EFail); |
|
553 } |
|
554 vPath=TVirtualPathPtr(combined); |
|
555 if(vPath.URI()!=expecteduri) |
|
556 { |
|
557 INFO_PRINTF4(_L("TVirtualPathPtr(uri,uniqueID) failed Uri() for %S\nExpected %S\nGot %S"),&combined,&expecteduri,&vPath.URI()); |
|
558 SetTestStepResult(EFail); |
|
559 } |
|
560 if(vPath.UniqueId()!=expecteduniqueid) |
|
561 { |
|
562 INFO_PRINTF4(_L("TVirtualPathPtr(aCombinedUriUniqueId) failed UniqueID() for %S\nExpected %S\nGot %S"),&combined,&expecteduniqueid,&vPath.UniqueId()); |
|
563 SetTestStepResult(EFail); |
|
564 } |
|
565 vPath=combined; |
|
566 if(vPath.URI()!=expecteduri) |
|
567 { |
|
568 INFO_PRINTF4(_L("TVirtualPathPtr operator = failed Uri for %S\nExpected %S\nGot %S"),&combined,&expecteduri,&vPath.URI()); |
|
569 SetTestStepResult(EFail); |
|
570 } |
|
571 if(vPath.UniqueId()!=expecteduniqueid) |
|
572 { |
|
573 INFO_PRINTF4(_L("TVirtualPathPtr operator = UniqueId for %S\nExpected %S\nGot %S"),&combined,&expecteduniqueid,&vPath.UniqueId()); |
|
574 SetTestStepResult(EFail); |
|
575 } |
|
576 // Test the CVirtualPath API |
|
577 CVirtualPath* heapPath = CVirtualPath::NewL(uri,uniqueID); |
|
578 if(heapPath->URI()!=expecteduri) |
|
579 { |
|
580 INFO_PRINTF4(_L("TCVirtualPath::NewL(uri,uniqueID) failed Uri for %S\nExpected %S\nGot %S"),&combined,&expecteduri,&heapPath->URI()); |
|
581 SetTestStepResult(EFail); |
|
582 } |
|
583 if(heapPath->UniqueId()!=expecteduniqueid) |
|
584 { |
|
585 INFO_PRINTF4(_L("CVirtualPath::NewL(uri,uniqueID) failed UniqueID for %S\nExpected %S\nGot %S"),&combined,&expecteduniqueid,&heapPath->UniqueId());; |
|
586 SetTestStepResult(EFail); |
|
587 } |
|
588 if(heapPath->GetCombinedUriUniqueId()!=combined) |
|
589 { |
|
590 INFO_PRINTF4(_L("CVirtualPath::NewL(uri,uniqueID) failed GetCombinedUriUniqueId() for %S\nExpected %S\nGot %S"),&combined,&combined,&heapPath->GetCombinedUriUniqueId()); |
|
591 SetTestStepResult(EFail); |
|
592 } |
|
593 delete heapPath; |
|
594 heapPath=NULL; |
|
595 |
|
596 heapPath = CVirtualPath::NewL(combined); |
|
597 if(heapPath->URI()!=expecteduri) |
|
598 { |
|
599 INFO_PRINTF4(_L("CVirtualPath::NewL(combined) failed Uri for %S\nExpected %S\nGot %S"),&combined,&expecteduri,&heapPath->URI()); |
|
600 SetTestStepResult(EFail); |
|
601 } |
|
602 if(heapPath->UniqueId()!=expecteduniqueid) |
|
603 { |
|
604 INFO_PRINTF4(_L("CVirtualPath::NewL(combined) failed UniqueID for %S\nExpected %S\nGot %S"),&combined,&expecteduniqueid,&heapPath->UniqueId()); |
|
605 SetTestStepResult(EFail); |
|
606 } |
|
607 if(heapPath->GetCombinedUriUniqueId()!=combined) |
|
608 { |
|
609 INFO_PRINTF4(_L("CVirtualPath::NewL(combined) failed GetCombinedUriUniqueId() for %S\nExpected %S\nGot %S"),&combined,&combined,&heapPath->GetCombinedUriUniqueId()); |
|
610 SetTestStepResult(EFail); |
|
611 } |
|
612 delete heapPath; |
|
613 heapPath=NULL; |
|
614 } |
|
615 |
|
616 |
|
617 CVirtualPath *aPath= CVirtualPath::NewL(KTestUri(), KTestUniqueId()); |
|
618 |
|
619 // Create a buffer |
|
620 CBufFlat* buf = CBufFlat::NewL(50); |
|
621 CleanupStack::PushL(buf); |
|
622 |
|
623 // create write stream |
|
624 RBufWriteStream writeStream(*buf); |
|
625 CleanupClosePushL(writeStream); |
|
626 |
|
627 // write the directory to the stream |
|
628 aPath->ExternalizeL(writeStream); |
|
629 CleanupStack::PopAndDestroy(&writeStream); |
|
630 |
|
631 // create read stream |
|
632 RBufReadStream readStream(*buf); |
|
633 CleanupClosePushL(readStream); |
|
634 |
|
635 // construct a new CSupplierOutputFile from the stream |
|
636 CVirtualPath *bPath= CVirtualPath::NewL(readStream); |
|
637 CleanupStack::PopAndDestroy(&readStream); |
|
638 |
|
639 |
|
640 if(aPath->UniqueId() != bPath->UniqueId()) |
|
641 { |
|
642 SetTestStepResult(EFail); |
|
643 } |
|
644 |
|
645 if(aPath->URI() != bPath->URI()) |
|
646 { |
|
647 SetTestStepResult(EFail); |
|
648 } |
|
649 |
|
650 // Test that if a uniqueID of length greater than ContentAccess::KMaxCafUniqueId |
|
651 // is given then it will not treat it as a valid uniqueID |
|
652 HBufC* longUID = HBufC::NewLC(aPath->UniqueId().Length() * 100+aPath->URI().Length()+1); |
|
653 longUID->Des().Append(aPath->URI()); |
|
654 longUID->Des().Append(KCafVirtualPathSeparator); |
|
655 // create a very long concatenated URI and UniqueID |
|
656 for ( i = 0; i < 100; ++i ) |
|
657 { |
|
658 longUID->Des().Append(aPath->UniqueId()); |
|
659 } |
|
660 // create a TVirtualPathPtr with the concatenated URI and UniqueID |
|
661 TVirtualPathPtr longPath(longUID->Des()); |
|
662 // check if the expected URI and UniqueID are stored |
|
663 if(longPath.URI()!=longUID->Des()) |
|
664 { |
|
665 SetTestStepResult(EFail); |
|
666 } |
|
667 if(longPath.UniqueId()!=KDefaultUniqueID) |
|
668 { |
|
669 SetTestStepResult(EFail); |
|
670 } |
|
671 |
|
672 CleanupStack::PopAndDestroy(longUID); |
|
673 CleanupStack::PopAndDestroy(buf); |
|
674 delete aPath; |
|
675 delete bPath; |
|
676 |
|
677 |
|
678 __UHEAP_MARKEND; |
|
679 |
|
680 return TestStepResult(); |
|
681 } |
|
682 |
|
683 |
|
684 |
|
685 CCafRightsInfoStep::~CCafRightsInfoStep() |
|
686 { |
|
687 } |
|
688 |
|
689 CCafRightsInfoStep::CCafRightsInfoStep(CCAFServer& aParent) : iParent(aParent) |
|
690 { |
|
691 SetTestStepName(KCAFRightsInfoStep); |
|
692 } |
|
693 |
|
694 |
|
695 TVerdict CCafRightsInfoStep::doTestStepL() |
|
696 { |
|
697 SetTestStepResult(EPass); |
|
698 |
|
699 _LIT(KTestUniqueId, "The UniqueId"); |
|
700 _LIT(KTestDescription, "A Description"); |
|
701 |
|
702 INFO_PRINTF1(_L("CRightsInfo test")); |
|
703 |
|
704 |
|
705 __UHEAP_MARK; |
|
706 |
|
707 CRightsInfo *aRights= CRightsInfo::NewL(KTestDescription(), KTestUniqueId(), ERightsTypeConsumable, ERightsStatusNone); |
|
708 |
|
709 |
|
710 // Create a buffer |
|
711 CBufFlat* buf = CBufFlat::NewL(50); |
|
712 CleanupStack::PushL(buf); |
|
713 |
|
714 // create write stream |
|
715 RBufWriteStream writeStream(*buf); |
|
716 CleanupClosePushL(writeStream); |
|
717 |
|
718 // write the directory to the stream |
|
719 aRights->ExternalizeL(writeStream); |
|
720 CleanupStack::PopAndDestroy(&writeStream); |
|
721 |
|
722 // create read stream |
|
723 RBufReadStream readStream(*buf); |
|
724 CleanupClosePushL(readStream); |
|
725 |
|
726 // construct a new CSupplierOutputFile from the stream |
|
727 CRightsInfo *bRights= CRightsInfo::NewL(readStream); |
|
728 CleanupStack::PopAndDestroy(&readStream); |
|
729 |
|
730 |
|
731 if(aRights->UniqueId() != bRights->UniqueId()) |
|
732 { |
|
733 SetTestStepResult(EFail); |
|
734 } |
|
735 |
|
736 if(aRights->Description() != bRights->Description()) |
|
737 { |
|
738 SetTestStepResult(EFail); |
|
739 } |
|
740 |
|
741 if(aRights->RightsType() != bRights->RightsType()) |
|
742 { |
|
743 SetTestStepResult(EFail); |
|
744 } |
|
745 |
|
746 if(aRights->RightsStatus() != bRights->RightsStatus()) |
|
747 { |
|
748 SetTestStepResult(EFail); |
|
749 } |
|
750 |
|
751 CleanupStack::PopAndDestroy(buf); |
|
752 delete aRights; |
|
753 delete bRights; |
|
754 |
|
755 __UHEAP_MARKEND; |
|
756 |
|
757 return TestStepResult(); |
|
758 } |
|
759 |
|
760 |
|
761 |
|
762 CCafStreamablePtrArrayStep::~CCafStreamablePtrArrayStep() |
|
763 { |
|
764 } |
|
765 |
|
766 CCafStreamablePtrArrayStep::CCafStreamablePtrArrayStep(CCAFServer& aParent) : iParent(aParent) |
|
767 { |
|
768 SetTestStepName(KCAFStreamablePtrArrayStep); |
|
769 } |
|
770 |
|
771 |
|
772 TVerdict CCafStreamablePtrArrayStep::doTestStepL() |
|
773 { |
|
774 SetTestStepResult(EPass); |
|
775 |
|
776 _LIT(KTestUniqueId, "The UniqueId"); |
|
777 _LIT(KTestName, "The Name"); |
|
778 _LIT8(KTestMimeType, "The mime type"); |
|
779 |
|
780 INFO_PRINTF1(_L("StreamablePtrArray test")); |
|
781 |
|
782 __UHEAP_MARK; |
|
783 |
|
784 RStreamablePtrArray <CEmbeddedObject> array; |
|
785 |
|
786 CEmbeddedObject *aObject = CEmbeddedObject::NewL(KTestUniqueId(), KTestName(), KTestMimeType(), EContentObject); |
|
787 CEmbeddedObject *bObject = CEmbeddedObject::NewL(KTestUniqueId(), KTestName(), KTestMimeType(), EContentObject); |
|
788 CEmbeddedObject *cObject = CEmbeddedObject::NewL(KTestUniqueId(), KTestName(), KTestMimeType(), EContentObject); |
|
789 |
|
790 array.AppendL(aObject); |
|
791 array.AppendL(bObject); |
|
792 array.AppendL(cObject); |
|
793 |
|
794 |
|
795 // Create a buffer |
|
796 CBufFlat* buf = CBufFlat::NewL(50); |
|
797 CleanupStack::PushL(buf); |
|
798 |
|
799 // create write stream |
|
800 RBufWriteStream writeStream(*buf); |
|
801 CleanupClosePushL(writeStream); |
|
802 |
|
803 // write the directory to the stream |
|
804 array.ExternalizeL(writeStream); |
|
805 CleanupStack::PopAndDestroy(&writeStream); |
|
806 |
|
807 // create read stream |
|
808 RBufReadStream readStream(*buf); |
|
809 CleanupClosePushL(readStream); |
|
810 |
|
811 // construct a new CSupplierOutputFile from the stream |
|
812 RStreamablePtrArray <CEmbeddedObject> bArray; |
|
813 bArray.InternalizeL(readStream); |
|
814 CleanupStack::PopAndDestroy(&readStream); |
|
815 |
|
816 if(array.Count() != bArray.Count()) |
|
817 { |
|
818 SetTestStepResult(EFail); |
|
819 } |
|
820 |
|
821 for(TInt i=0; i < array.Count(); i++) |
|
822 { |
|
823 if(array[i]->UniqueId() != bArray[i]->UniqueId()) |
|
824 { |
|
825 SetTestStepResult(EFail); |
|
826 } |
|
827 |
|
828 if(array[i]->Name() != bArray[i]->Name()) |
|
829 { |
|
830 SetTestStepResult(EFail); |
|
831 } |
|
832 } |
|
833 |
|
834 CleanupStack::PopAndDestroy(buf); |
|
835 array.Close(); |
|
836 bArray.Close(); |
|
837 |
|
838 __UHEAP_MARKEND; |
|
839 |
|
840 return TestStepResult(); |
|
841 } |
|
842 |
|
843 #ifdef SYMBIAN_ENABLE_SDP_WMDRM_SUPPORT |
|
844 |
|
845 CCafHelperStep::~CCafHelperStep() |
|
846 { |
|
847 } |
|
848 |
|
849 CCafHelperStep::CCafHelperStep() |
|
850 { |
|
851 SetTestStepName(KCAFHelperStep); |
|
852 } |
|
853 |
|
854 |
|
855 TVerdict CCafHelperStep::doTestStepL() |
|
856 { |
|
857 SetTestStepResult(EFail); |
|
858 __UHEAP_MARK; |
|
859 |
|
860 TInt result; |
|
861 |
|
862 TInt error; |
|
863 GetIntFromConfig(ConfigSection(),_L("error"),error); |
|
864 |
|
865 TInt expectedValue; |
|
866 GetIntFromConfig(ConfigSection(),_L("expected"),expectedValue); |
|
867 |
|
868 // fileheader case. |
|
869 TPtrC uri; |
|
870 if (!GetStringFromConfig(ConfigSection(), _L("uri"), uri)) |
|
871 { |
|
872 INFO_PRINTF1(_L("CCafHelper test : HeaderData case.")); |
|
873 result = TestHeaderDataCaseL(error); |
|
874 } |
|
875 |
|
876 else |
|
877 { |
|
878 TBool isFileName = EFalse; |
|
879 GetBoolFromConfig(ConfigSection(),_L("flag"),isFileName); |
|
880 |
|
881 // filehandle case |
|
882 if(isFileName == EFalse) |
|
883 { |
|
884 INFO_PRINTF1(_L("CCafHelper test : FileHandle case.")); |
|
885 result = TestFileHandleCaseL(error, uri); |
|
886 } |
|
887 |
|
888 // filename case. |
|
889 else |
|
890 { |
|
891 INFO_PRINTF1(_L("CCafHelper test : FileName case.")); |
|
892 |
|
893 CCAFHelper* helperObj = CCAFHelper::NewL(); |
|
894 CleanupStack::PushL(helperObj); |
|
895 |
|
896 result = (*helperObj)().HandleCAFErrorL(error, uri); |
|
897 CleanupStack::PopAndDestroy(helperObj); |
|
898 } |
|
899 } |
|
900 |
|
901 if(result == expectedValue) |
|
902 { |
|
903 SetTestStepResult(EPass); |
|
904 } |
|
905 |
|
906 __UHEAP_MARKEND; |
|
907 |
|
908 return TestStepResult(); |
|
909 } |
|
910 |
|
911 TInt CCafHelperStep::TestFileHandleCaseL(TInt aError, const TDesC& aFileName) |
|
912 { |
|
913 __UHEAP_MARK; |
|
914 RFs fs; |
|
915 RFile fileHandle; |
|
916 User::LeaveIfError(fs.Connect()); |
|
917 CleanupClosePushL(fs); |
|
918 User::LeaveIfError(fileHandle.Open(fs, aFileName, EFileRead)); |
|
919 CleanupClosePushL(fileHandle); |
|
920 |
|
921 CCAFHelper* helperObj = CCAFHelper::NewL(); |
|
922 CleanupStack::PushL(helperObj); |
|
923 TInt result = (*helperObj)().HandleCAFErrorL(aError, fileHandle); |
|
924 CleanupStack::PopAndDestroy(3, &fs); |
|
925 __UHEAP_MARKEND; |
|
926 |
|
927 return result; |
|
928 } |
|
929 |
|
930 TInt CCafHelperStep::TestHeaderDataCaseL(TInt aError) |
|
931 { |
|
932 _LIT8(KFileHeaderData,"W\0R\0M\0H\0E\0A\0D\0E\0R\0"); |
|
933 |
|
934 __UHEAP_MARK; |
|
935 CCAFHelper* helperObj = CCAFHelper::NewL(); |
|
936 CleanupStack::PushL(helperObj); |
|
937 |
|
938 TInt result = (*helperObj)().HandleCAFErrorL(aError, KFileHeaderData); |
|
939 CleanupStack::PopAndDestroy(helperObj); |
|
940 __UHEAP_MARKEND; |
|
941 |
|
942 return result; |
|
943 } |
|
944 |
|
945 #endif //SYMBIAN_ENABLE_SDP_WMDRM_SUPPORT |
|
946 |
|
947 |