|
1 // Copyright (c) 2002-2009 Nokia Corporation and/or its subsidiary(-ies). |
|
2 // All rights reserved. |
|
3 // This component and the accompanying materials are made available |
|
4 // under the terms of "Eclipse Public License v1.0" |
|
5 // which accompanies this distribution, and is available |
|
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
7 // |
|
8 // Initial Contributors: |
|
9 // Nokia Corporation - initial contribution. |
|
10 // |
|
11 // Contributors: |
|
12 // |
|
13 // Description: |
|
14 // This file contains the test steps ICL negative testing |
|
15 // EPOC includes |
|
16 // |
|
17 // |
|
18 |
|
19 #include <testframework.h> |
|
20 #include <caf/caf.h> |
|
21 #include "TestNegativeConversion.h" |
|
22 |
|
23 #include "rightsdatabase.h" |
|
24 |
|
25 using namespace ContentAccess; |
|
26 |
|
27 const TInt KMaxMimeLength = 256; |
|
28 |
|
29 const TInt KErrEncoderNonAvailable = -17014;//this error raises whenever you try to use |
|
30 //unavaliable plugin |
|
31 |
|
32 //const TInt KLenBufferSectionName = 64; // EABI warning removal |
|
33 //const TInt KLenMemBuffer = 1024; // EABI warning removal |
|
34 |
|
35 // DRM |
|
36 const TInt KDefaultRightsID = 1; |
|
37 const TInt KDefaultRightsCount = 2; |
|
38 const TInt KRightsNoCount = -1; |
|
39 |
|
40 |
|
41 CTestNegativeConversion *CTestNegativeConversion::NewL(const TDesC& aTestName) |
|
42 { |
|
43 CTestNegativeConversion* self = new(ELeave) CTestNegativeConversion(aTestName); |
|
44 return self; |
|
45 |
|
46 } |
|
47 |
|
48 /** |
|
49 * |
|
50 * |
|
51 * do the test step |
|
52 * |
|
53 */ |
|
54 TVerdict CTestNegativeConversion::DoTestStepL() |
|
55 { |
|
56 TVerdict currentVerdict = EPass; |
|
57 |
|
58 if( iTestStepName.Compare(_L("MM-ICL-FRM-I-0501-CP")) == 0) |
|
59 currentVerdict = Step0501_CP(); |
|
60 else if( iTestStepName.Compare(_L("MM-ICL-FRM-I-0502-LP")) == 0) |
|
61 currentVerdict = Step0502_LP(); |
|
62 else if( iTestStepName.Compare(_L("MM-ICL-FRM-I-0503-HP")) == 0) |
|
63 currentVerdict = Step0503_HP(); |
|
64 else if( iTestStepName.Compare(_L("MM-ICL-FRM-I-0504-HP")) == 0) |
|
65 currentVerdict = Step0504_HP(); |
|
66 else if( iTestStepName.Compare(_L("MM-ICL-FRM-I-0505-HP")) == 0) |
|
67 currentVerdict = Step0505_HP(); |
|
68 else if( iTestStepName.Compare(_L("MM-ICL-FRM-I-0506-LP")) == 0) |
|
69 currentVerdict = Step0506_LP(); |
|
70 else if( iTestStepName.Compare(_L("MM-ICL-FRM-I-0507-LP")) == 0) |
|
71 currentVerdict = Step0507_LP(); |
|
72 else if( iTestStepName.Compare(_L("MM-ICL-FRM-I-0508-HP")) == 0) |
|
73 currentVerdict = Step0508_HP(); |
|
74 else if( iTestStepName.Compare(_L("MM-ICL-FRM-I-0509-LP")) == 0) |
|
75 currentVerdict = Step0509_LP(); |
|
76 else if( iTestStepName.Compare(_L("MM-ICL-FRM-I-0510-LP")) == 0) |
|
77 currentVerdict = Step0510_LP(); |
|
78 else if( iTestStepName.Compare(_L("MM-ICL-FRM-I-0511-LP")) == 0) |
|
79 currentVerdict = Step0511_LP(); |
|
80 else if( iTestStepName.Compare(_L("MM-ICL-FRM-I-0512-LP")) == 0) |
|
81 currentVerdict = Step0512_LP_L(); |
|
82 else if( iTestStepName.Compare(_L("MM-ICL-FRM-I-0513-HP")) == 0) |
|
83 currentVerdict = Step0513_HP(); |
|
84 else if( iTestStepName.Compare(_L("MM-ICL-FRM-I-0602-HP")) == 0) |
|
85 currentVerdict = Step0602_HP(); |
|
86 else if( iTestStepName.Compare(_L("MM-ICL-FRM-I-0603-HP")) == 0) |
|
87 currentVerdict = Step0603_HP(); |
|
88 else if( iTestStepName.Compare(_L("MM-ICL-FRM-I-0604-HP")) == 0) |
|
89 currentVerdict = Step0604_HP(); |
|
90 else if( iTestStepName.Compare(_L("MM-ICL-FRM-I-0605-HP")) == 0) |
|
91 currentVerdict = Step0605_HP(); |
|
92 else if( iTestStepName.Compare(_L("MM-ICL-FRM-I-0606-HP")) == 0) |
|
93 currentVerdict = Step0606_HP(); |
|
94 else if( iTestStepName.Compare(_L("MM-ICL-FRM-I-0607-HP")) == 0) |
|
95 currentVerdict = Step0607_HP(); |
|
96 else if( iTestStepName.Compare(_L("MM-ICL-FRM-I-0020-CP")) == 0) |
|
97 currentVerdict = Step0020_CP(); |
|
98 else if( iTestStepName.Compare(_L("MM-ICL-FRM-I-0700-CP")) == 0) |
|
99 currentVerdict = Step0700_CP(); |
|
100 |
|
101 return currentVerdict; |
|
102 } |
|
103 |
|
104 /** |
|
105 * |
|
106 * Request an encode for |
|
107 * usupported image format |
|
108 */ |
|
109 TVerdict CTestNegativeConversion::Step0501_CP() |
|
110 { |
|
111 TVerdict result = EFail ; |
|
112 TInt theRes = KErrNone; |
|
113 |
|
114 TRAP_IGNORE(theRes = EncodeImageToMemoryL(iFileNameSrc, |
|
115 iImageTypeUid)); |
|
116 |
|
117 if(theRes == KErrNotFound) |
|
118 { |
|
119 INFO_PRINTF2(_L("Error during request unsupported image format, error %d\n"), |
|
120 theRes); |
|
121 |
|
122 result = EPass; |
|
123 } |
|
124 |
|
125 return result; |
|
126 |
|
127 } |
|
128 |
|
129 /** |
|
130 * |
|
131 * Request an encode for supported |
|
132 * image format but usupported |
|
133 * conversion type |
|
134 * |
|
135 * This test was removed. Cannot specify unsupported conversion type!!! (for ex. GIF89a) |
|
136 */ |
|
137 |
|
138 TVerdict CTestNegativeConversion::Step0502_LP() |
|
139 { |
|
140 |
|
141 // we have no subtypes specified for GIF |
|
142 INFO_PRINTF1(_L("Warning : test not valid - ICL has no subtypes specified but not implemented")); |
|
143 return EPass; |
|
144 |
|
145 /* TVerdict result = EPass ; |
|
146 TInt theRes = KErrNotSupported; |
|
147 |
|
148 TRAP(theRes, theRes = EncodeImageToMemoryL(iFileNameSrc, |
|
149 iImageTypeUid)); |
|
150 |
|
151 if(theRes == KErrNone) |
|
152 result = EPass; |
|
153 |
|
154 if(theRes == KErrNotFound) |
|
155 { |
|
156 INFO_PRINTF2(_L("Error during request unsupported image format, error %d\n"), |
|
157 theRes); |
|
158 |
|
159 } |
|
160 |
|
161 return result; |
|
162 */ |
|
163 } |
|
164 |
|
165 |
|
166 /** |
|
167 * |
|
168 * Request load and encode |
|
169 * of corrupt image |
|
170 * |
|
171 */ |
|
172 TVerdict CTestNegativeConversion::Step0503_HP() |
|
173 { |
|
174 TVerdict result = EFail ; |
|
175 TInt theRes = KErrNone; |
|
176 |
|
177 TInt err = RFbsSession::Connect(); |
|
178 if (err != KErrNone) |
|
179 { |
|
180 INFO_PRINTF2(_L("RFbsSession::Connect() failed, err = %d"), err); |
|
181 return EInconclusive; |
|
182 } |
|
183 |
|
184 //iImageTypeUid is not according to file format |
|
185 TRAP_IGNORE(theRes = OpenImageForDecodeFromBufferL(iFileNameSrc, iImageTypeUid)); |
|
186 |
|
187 RFbsSession::Disconnect(); |
|
188 |
|
189 if(theRes == KErrNotFound) |
|
190 { |
|
191 INFO_PRINTF2(_L("Error during load and decode of corrupt image, error %d\n"), |
|
192 theRes); |
|
193 |
|
194 result = EPass; |
|
195 } |
|
196 |
|
197 return result; |
|
198 } |
|
199 |
|
200 /** |
|
201 * |
|
202 * Request load and decode |
|
203 * of corrupt WMF image |
|
204 * |
|
205 */ |
|
206 TVerdict CTestNegativeConversion::Step0020_CP() |
|
207 { |
|
208 TVerdict result = EFail ; |
|
209 TInt theRes = KErrNone; |
|
210 |
|
211 TInt err = RFbsSession::Connect(); |
|
212 if (err != KErrNone) |
|
213 { |
|
214 INFO_PRINTF2(_L("RFbsSession::Connect() failed, err = %d"), err); |
|
215 return EInconclusive; |
|
216 } |
|
217 |
|
218 //try to open corrupted file |
|
219 TRAP_IGNORE(theRes = OpenImageForDecodeFromBufferL(iFileNameSrc, iImageTypeUid)); |
|
220 |
|
221 RFbsSession::Disconnect(); |
|
222 |
|
223 if(theRes == KErrCorrupt) |
|
224 { |
|
225 INFO_PRINTF2(_L("Error during load and decode of corrupt image, error %d\n"), |
|
226 theRes); |
|
227 |
|
228 result = EPass; |
|
229 } |
|
230 |
|
231 |
|
232 |
|
233 return result; |
|
234 } |
|
235 |
|
236 |
|
237 /** |
|
238 * |
|
239 * Request load and decode of |
|
240 * image from which content type |
|
241 * cannot be identified |
|
242 * |
|
243 */ |
|
244 TVerdict CTestNegativeConversion::Step0504_HP() |
|
245 { |
|
246 TVerdict result = EFail ; |
|
247 TInt theRes = KErrNone; |
|
248 |
|
249 TInt err = RFbsSession::Connect(); |
|
250 if (err != KErrNone) |
|
251 { |
|
252 INFO_PRINTF2(_L("RFbsSession::Connect() failed, err = %d"), err); |
|
253 return EInconclusive; |
|
254 } |
|
255 |
|
256 TRAP_IGNORE(theRes = OpenImageForDecodeFromBufferL(iFileNameSrc)); |
|
257 |
|
258 RFbsSession::Disconnect(); |
|
259 |
|
260 if(theRes == KErrNotFound) |
|
261 { |
|
262 INFO_PRINTF2(_L("Error decode cropped image format, error %d\n"), |
|
263 theRes); |
|
264 |
|
265 result = EPass; |
|
266 } |
|
267 |
|
268 return result; |
|
269 } |
|
270 /** |
|
271 * |
|
272 * Request load of non-existent |
|
273 * image |
|
274 * |
|
275 */ |
|
276 TVerdict CTestNegativeConversion::Step0505_HP() |
|
277 { |
|
278 TVerdict result = EFail ; |
|
279 TInt theRes = KErrNone; |
|
280 |
|
281 TRAP_IGNORE(theRes = OpenImageForDecodeFromFileL(iFileNameSrc)); |
|
282 |
|
283 if(theRes == KErrNotFound) |
|
284 { |
|
285 INFO_PRINTF2(_L("Error load of non-existent image, error %d\n"), |
|
286 theRes); |
|
287 result = EPass; |
|
288 |
|
289 } |
|
290 return result; |
|
291 } |
|
292 |
|
293 /** |
|
294 * |
|
295 * Request incremental load and |
|
296 * decode of an image, then break the connection |
|
297 * before completion |
|
298 * Test was removed!!!. Every attempt to close file server causes crash |
|
299 */ |
|
300 TVerdict CTestNegativeConversion::Step0506_LP() |
|
301 { |
|
302 INFO_PRINTF1(_L("Warning : test not valid - cannot break incremental load in Test Framework")); |
|
303 INFO_PRINTF1(_L("Run visual test in TImageViewer")); |
|
304 return EPass; |
|
305 |
|
306 /* TVerdict result = EFail ; |
|
307 TInt theRes = KErrNone; |
|
308 TInt theNumStepBeforeCancel = 0; |
|
309 |
|
310 TBuf<KLenBufferSectionName> nameSection; |
|
311 |
|
312 TPtrC ptr = iTestStepName; |
|
313 nameSection = ptr.Right(KLenNameInSection); |
|
314 |
|
315 GetIntFromConfig(nameSection, _L("NumStepBeforeCancel"), theNumStepBeforeCancel); |
|
316 |
|
317 |
|
318 TRAP(theRes, theRes = ReadAndDecodeIncrementallyL(iFileNameSrc, theNumStepBeforeCancel)); |
|
319 |
|
320 if(theRes == KErrNone) |
|
321 result = EPass; |
|
322 |
|
323 if(theRes == KErrNotFound) |
|
324 { |
|
325 INFO_PRINTF2(_L("Error during break connection before completion, error %d\n"), |
|
326 theRes); |
|
327 |
|
328 } |
|
329 |
|
330 return result; |
|
331 */ |
|
332 } |
|
333 |
|
334 /** |
|
335 * |
|
336 * Request incremental load and decode |
|
337 * of an image, then delete the image at the server |
|
338 * before completion |
|
339 * Test was removed!!!. During reading and decoding image incrementally |
|
340 * cannot delete source file |
|
341 */ |
|
342 TVerdict CTestNegativeConversion::Step0507_LP() |
|
343 { |
|
344 INFO_PRINTF1(_L("Warning : test not valid - cannot delete source image during decode in Test Framework")); |
|
345 INFO_PRINTF1(_L("Run visual test in TImageViewer")); |
|
346 return EPass; |
|
347 /* |
|
348 TVerdict result = EFail ; |
|
349 TInt theRes = KErrNone; |
|
350 |
|
351 TRAP(theRes, theRes = OpenImageForDecodeFromFileL(iFileNameSrc)); |
|
352 |
|
353 if(theRes == KErrNone) |
|
354 result = EPass; |
|
355 |
|
356 if(theRes == KErrNotFound) |
|
357 { |
|
358 INFO_PRINTF2(_L("Error during delete the image before completion, error %d\n"), |
|
359 theRes); |
|
360 |
|
361 } |
|
362 |
|
363 return result; |
|
364 */ |
|
365 } |
|
366 |
|
367 /** |
|
368 * |
|
369 * Request incremental load and decode of an image, |
|
370 * then cancel the incremental load at the client |
|
371 * before completion. |
|
372 * |
|
373 * Test was removed!!!. |
|
374 * Was replaced by MM-ICL-COD-U-08d4-HP |
|
375 * |
|
376 */ |
|
377 TVerdict CTestNegativeConversion::Step0508_HP() |
|
378 { |
|
379 INFO_PRINTF1(_L("Warning : Was replaced by MM-ICL-COD-U-08d4-HP")); |
|
380 return EFail; |
|
381 /* |
|
382 TVerdict result = EFail ; |
|
383 TInt theNumStepBeforeCancel = 0; |
|
384 TInt theRes = KErrNone; |
|
385 |
|
386 TBuf<KLenBuffer> nameSection; |
|
387 |
|
388 TPtrC ptr = iTestStepName; |
|
389 nameSection = ptr.Right(KLenNameInSection); |
|
390 |
|
391 GetIntFromConfig(nameSection, _L("NumStepBeforeCancel"), theNumStepBeforeCancel); |
|
392 |
|
393 |
|
394 TRAPD(theRes1, theRes = ReadAndDecodeIncrementallyL(iFileNameSrc, theNumStepBeforeCancel)); |
|
395 |
|
396 |
|
397 if(theRes == KErrCancel) |
|
398 { |
|
399 INFO_PRINTF2(_L("The incremental load and decode was canceled at the client before completion, error %d"), |
|
400 theRes); |
|
401 |
|
402 result = EPass; |
|
403 } |
|
404 else |
|
405 { |
|
406 |
|
407 if(theRes1 != KErrNone) |
|
408 theRes = theRes1; |
|
409 INFO_PRINTF2(_L("Unexpected error during request incremental load and decode of an image, error %d"), |
|
410 theRes); |
|
411 |
|
412 } |
|
413 |
|
414 return result; |
|
415 */ |
|
416 } |
|
417 |
|
418 /** |
|
419 * |
|
420 * List available encoders/decoders |
|
421 * where no plugin are available |
|
422 * |
|
423 */ |
|
424 |
|
425 TVerdict CTestNegativeConversion::Step0509_LP() |
|
426 { |
|
427 TInt theRes = KErrNone; |
|
428 TInt theRes1 = KErrNone; |
|
429 |
|
430 theRes = ListAllAvailableEncoders(); |
|
431 if(theRes == KErrEncoderNonAvailable) |
|
432 { |
|
433 INFO_PRINTF2(_L("List encoders plugin are not available, error %d\n"), |
|
434 theRes); |
|
435 |
|
436 } |
|
437 |
|
438 theRes1 = ListAllAvailableDecoders(); |
|
439 if(theRes1 == KErrEncoderNonAvailable) |
|
440 { |
|
441 INFO_PRINTF2(_L("List decoders plugin are not available, error %d\n"), |
|
442 theRes1); |
|
443 |
|
444 } |
|
445 |
|
446 INFO_PRINTF1(_L("Warning : test not valid - cannot delete plugins / Ecom registry in Test Framework")); |
|
447 INFO_PRINTF1(_L("To test, run on clean system with no plugins installed")); |
|
448 return EPass; |
|
449 /* |
|
450 TVerdict result = EFail ; |
|
451 if(theRes == KErrEncoderNonAvailable && theRes1 == KErrEncoderNonAvailable) |
|
452 result = EPass; |
|
453 |
|
454 return result; |
|
455 */ |
|
456 } |
|
457 |
|
458 /** |
|
459 * |
|
460 * List MIME types / UIDs for encodes/decoders |
|
461 * where no plugins are available |
|
462 * |
|
463 */ |
|
464 TVerdict CTestNegativeConversion::Step0510_LP() |
|
465 { |
|
466 TInt theRes = KErrNone; |
|
467 TInt theRes1 = KErrNone; |
|
468 |
|
469 __MM_HEAP_MARK; |
|
470 |
|
471 TInt err = RFbsSession::Connect(); |
|
472 if (err != KErrNone) |
|
473 { |
|
474 INFO_PRINTF2(_L("RFbsSession::Connect() failed, err = %d"), err); |
|
475 return EInconclusive; |
|
476 } |
|
477 |
|
478 // request list of encoders |
|
479 theRes = ListAvailableMIMEEncoders(); |
|
480 |
|
481 if(theRes == KErrEncoderNonAvailable) |
|
482 { |
|
483 INFO_PRINTF2(_L("A list of MIME types for encoders is not available, error %d\n"), |
|
484 theRes); |
|
485 |
|
486 } |
|
487 |
|
488 // request list of decoders |
|
489 theRes1 = ListAvailableMIMEDecoders(); |
|
490 |
|
491 if(theRes1 == KErrEncoderNonAvailable) |
|
492 { |
|
493 INFO_PRINTF2(_L("A list of MIME types for decoders is not available, error %d\n"), |
|
494 theRes1); |
|
495 } |
|
496 RFbsSession::Disconnect(); |
|
497 |
|
498 __MM_HEAP_MARKEND; |
|
499 |
|
500 INFO_PRINTF1(_L("Warning : test not valid - cannot delete plugins / Ecom registry in Test Framework")); |
|
501 INFO_PRINTF1(_L("To test, run on clean system with no plugins installed")); |
|
502 return EPass; |
|
503 /* |
|
504 TVerdict result = EFail ; |
|
505 if(theRes == KErrEncoderNonAvailable && theRes1 == KErrEncoderNonAvailable) |
|
506 result = EPass; |
|
507 |
|
508 return result; |
|
509 */ |
|
510 } |
|
511 |
|
512 /** |
|
513 * |
|
514 * Request a load and decode/encode |
|
515 * from a corrupt plugin |
|
516 * |
|
517 */ |
|
518 TVerdict CTestNegativeConversion::Step0511_LP() |
|
519 { |
|
520 INFO_PRINTF1(_L("Warning : test not valid - corrupt plugin not available")); |
|
521 return EPass; |
|
522 |
|
523 /* TVerdict result = EFail ; |
|
524 TInt theRes = KErrNone; |
|
525 TInt theRes1 = KErrNone; |
|
526 TInt theRes2 = KErrNone; |
|
527 |
|
528 TRAP(theRes2, theRes = OpenImageForDecodeFromFileL(iFileNameSrc)); |
|
529 |
|
530 if(theRes == KErrNotFound) |
|
531 { |
|
532 INFO_PRINTF2(_L("Decode plugin is not available, error %d\n"), |
|
533 theRes); |
|
534 |
|
535 } |
|
536 |
|
537 TBuf<KLenBuffer> theNameEncode; |
|
538 TBuf<KLenBufferExtension> theExtension; |
|
539 theNameEncode.Copy(iFileNameSrc.Left(iFileNameSrc.Length() - 3)); |
|
540 GetImageExtension(KImageTypeMBMUid, theExtension); |
|
541 theNameEncode.Append(theExtension); |
|
542 |
|
543 TRAP(theRes2, theRes1 = EncodeImageFromBitmapToFileL(theNameEncode, KImageTypeJPGUid)); |
|
544 |
|
545 if(theRes1 == KErrNotFound) |
|
546 { |
|
547 INFO_PRINTF2(_L("Encode plugin is not available, error %d\n"), |
|
548 theRes1); |
|
549 |
|
550 } |
|
551 if(theRes1 == KErrNotFound && theRes == KErrNotFound) |
|
552 result = EPass; |
|
553 |
|
554 |
|
555 return result; |
|
556 */ |
|
557 } |
|
558 |
|
559 /** |
|
560 * |
|
561 * Attempt to encode something which is not |
|
562 * a CFbsBitmap |
|
563 * |
|
564 */ |
|
565 TVerdict CTestNegativeConversion::Step0512_LP_L() |
|
566 { |
|
567 |
|
568 INFO_PRINTF1(_L("Warning : test not valid")); |
|
569 return EPass; |
|
570 /* |
|
571 TVerdict result = EFail ; |
|
572 TInt theRes = KErrNone; |
|
573 |
|
574 __MM_HEAP_MARK; |
|
575 |
|
576 TAny* memBuf = NULL; |
|
577 TRAPD(theRes1, memBuf = User::AllocL(KLenMemBuffer)); |
|
578 CleanupStack::PushL(memBuf); |
|
579 if(theRes1 != KErrNone) |
|
580 return result; |
|
581 |
|
582 TPtr8 buffer(STATIC_CAST(TUint8*, memBuf), 0, KLenMemBuffer); |
|
583 |
|
584 CFbsBitmap* theBitmap = (CFbsBitmap*) &buffer; |
|
585 |
|
586 |
|
587 TRAP(theRes1, theRes = EncodeImageFromBitmapToMemoryL( iFileNameSrc, theBitmap, iImageTypeUid)); |
|
588 |
|
589 // NB Encode Image may succeed in encoding, but the comparison will fail - then it will |
|
590 // return KErrNotIdentical - this is also a valid return |
|
591 |
|
592 if(theRes == KErrCorrupt || theRes == KErrNotIdentical) |
|
593 { |
|
594 INFO_PRINTF2(_L("Error encoding random buffer, error %d"), |
|
595 theRes); |
|
596 |
|
597 result = EPass; |
|
598 } |
|
599 else |
|
600 { |
|
601 INFO_PRINTF2(_L("Unexpected error during encoding random buffer, error %d"), |
|
602 theRes); |
|
603 |
|
604 } |
|
605 |
|
606 CleanupStack::PopAndDestroy(); // memBuf |
|
607 |
|
608 __MM_HEAP_MARKEND; |
|
609 return result; |
|
610 */ |
|
611 } |
|
612 |
|
613 /** |
|
614 * |
|
615 * Request frame data where no frame is loaded |
|
616 * |
|
617 */ |
|
618 TVerdict CTestNegativeConversion::Step0513_HP() |
|
619 { |
|
620 TVerdict result = EFail ; |
|
621 TInt theRes = KErrNone; |
|
622 |
|
623 TInt err = RFbsSession::Connect(); |
|
624 if (err != KErrNone) |
|
625 { |
|
626 INFO_PRINTF2(_L("RFbsSession::Connect() failed, err = %d"), err); |
|
627 return EInconclusive; |
|
628 } |
|
629 |
|
630 TRAP_IGNORE(theRes = OpenImageForDecodeFromBufferL( iFileNameSrc )); |
|
631 |
|
632 RFbsSession::Disconnect(); |
|
633 |
|
634 if(theRes == KErrUnderflow) |
|
635 { |
|
636 INFO_PRINTF2(_L("No frame is loaded, error %d\n"), |
|
637 theRes); |
|
638 |
|
639 result = EPass; |
|
640 } |
|
641 |
|
642 return result; |
|
643 |
|
644 } |
|
645 |
|
646 |
|
647 /** |
|
648 * |
|
649 * Read and Decoder using FileNewL with DRM intent API. |
|
650 * Negative Test, drm protected file with no rights |
|
651 * |
|
652 * Step 0602_HP |
|
653 * |
|
654 */ |
|
655 TVerdict CTestNegativeConversion::Step0602_HP() |
|
656 { |
|
657 TVerdict result = EFail ; |
|
658 TInt err = KErrNone; |
|
659 |
|
660 // dummy Hal call for heap balance on target |
|
661 if (DummyHalCall() != KErrNone) |
|
662 return EInconclusive; |
|
663 |
|
664 __MM_HEAP_MARK; |
|
665 err = RFbsSession::Connect(); |
|
666 if (err != KErrNone) |
|
667 { |
|
668 INFO_PRINTF2(_L("RFbsSession::Connect() failed, err = %d"), err); |
|
669 return EInconclusive; |
|
670 } |
|
671 |
|
672 CRightsDatabase* database = CRightsDatabase::NewL(EFalse); // clear current database |
|
673 delete database; // delete database object |
|
674 |
|
675 TRAP(err, OpenImageForDecodeFromFileWithIntentL(iFileNameSrc, EView)); |
|
676 |
|
677 RFbsSession::Disconnect(); |
|
678 |
|
679 __MM_HEAP_MARKEND; |
|
680 |
|
681 if(err == KErrCANoRights) |
|
682 { |
|
683 INFO_PRINTF1(_L("Expected Rights failure opening file")); |
|
684 result = EPass; |
|
685 } |
|
686 else |
|
687 INFO_PRINTF3(_L("Unexpected Error : %d, expected failure with %d"), err, KErrCANoRights); |
|
688 |
|
689 return result; |
|
690 } |
|
691 |
|
692 |
|
693 /** |
|
694 * |
|
695 * Read and Decoder using FileNewL with DRM intent API (specifying MIME Type) |
|
696 * Negative Test, drm protected file with no rights |
|
697 * Step 0603_HP |
|
698 * |
|
699 */ |
|
700 TVerdict CTestNegativeConversion::Step0603_HP() |
|
701 { |
|
702 TVerdict result = EFail ; |
|
703 TInt err = KErrNone; |
|
704 |
|
705 // dummy Hal call for heap balance on target |
|
706 if (DummyHalCall() != KErrNone) |
|
707 return EInconclusive; |
|
708 |
|
709 __MM_HEAP_MARK; |
|
710 err = RFbsSession::Connect(); |
|
711 if (err != KErrNone) |
|
712 { |
|
713 INFO_PRINTF2(_L("RFbsSession::Connect() failed, err = %d"), err); |
|
714 return EInconclusive; |
|
715 } |
|
716 |
|
717 CRightsDatabase* database = CRightsDatabase::NewL(EFalse); // clear current database |
|
718 delete database; // delete database object |
|
719 |
|
720 TBuf8<KMaxMimeLength> mimeType; |
|
721 ReadMimeTypeFromConfig(mimeType); |
|
722 |
|
723 TRAP(err, OpenImageForDecodeFromFileWithIntentL(iFileNameSrc, EView, mimeType)); |
|
724 |
|
725 RFbsSession::Disconnect(); |
|
726 |
|
727 __MM_HEAP_MARKEND; |
|
728 |
|
729 |
|
730 if(err == KErrCANoRights) |
|
731 { |
|
732 INFO_PRINTF1(_L("Expected Rights failure opening file")); |
|
733 result = EPass; |
|
734 } |
|
735 else |
|
736 INFO_PRINTF3(_L("Unexpected Error : %d, expected failure with %d"), err, KErrCANoRights); |
|
737 |
|
738 |
|
739 return result; |
|
740 } |
|
741 |
|
742 /** |
|
743 * |
|
744 * Read and Decoder using FileNewL with DRM intent API. |
|
745 * Negative Test, drm protected file with rights count |
|
746 * |
|
747 * Step 0604_HP |
|
748 * |
|
749 */ |
|
750 TVerdict CTestNegativeConversion::Step0604_HP() |
|
751 { |
|
752 |
|
753 TVerdict result = EFail ; |
|
754 TInt err = KErrNone; |
|
755 |
|
756 // dummy Hal call for heap balance on target |
|
757 if (DummyHalCall() != KErrNone) |
|
758 return EInconclusive; |
|
759 |
|
760 err = RFbsSession::Connect(); |
|
761 if (err != KErrNone) |
|
762 { |
|
763 INFO_PRINTF2(_L("RFbsSession::Connect() failed, err = %d"), err); |
|
764 return EInconclusive; |
|
765 } |
|
766 |
|
767 // set the rights count |
|
768 CRightsDatabase* rights = CRightsDatabase::NewL(EFalse); // create new database overwriting current one |
|
769 CleanupStack::PushL(rights); |
|
770 rights->AddRightsL(KDefaultRightsID,KDefaultRightsCount); // add rights count |
|
771 CleanupStack::PopAndDestroy(rights); // cleanup rights object |
|
772 |
|
773 //attempt KDefaultRightsCount times to open the file |
|
774 for (TInt i=0;i<KDefaultRightsCount;i++) |
|
775 { |
|
776 TRAP(err, OpenImageForDecodeFromFileWithIntentL(iFileNameSrc, EView)); |
|
777 |
|
778 INFO_PRINTF2( _L("CImageDecoder: DRM FileNewL number %d"),i); |
|
779 |
|
780 if (err != KErrNone) |
|
781 { |
|
782 INFO_PRINTF2(_L("Unexpected error %d"),err); |
|
783 break; |
|
784 } |
|
785 } |
|
786 |
|
787 // now attempt to open again |
|
788 if (err == KErrNone) |
|
789 { |
|
790 TRAP(err, OpenImageForDecodeFromFileWithIntentL(iFileNameSrc, EView)); |
|
791 |
|
792 INFO_PRINTF1( _L("CImageDecoder:DRM FileNewL with expired rights")); |
|
793 |
|
794 if (err != KErrCANoPermission) |
|
795 { |
|
796 INFO_PRINTF3(_L("Unexpected error %d, expected %d"),err,KErrCANoPermission); |
|
797 } |
|
798 else |
|
799 { |
|
800 INFO_PRINTF1(_L("Expected failure: rights denied")); |
|
801 result = EPass; |
|
802 } |
|
803 } |
|
804 |
|
805 |
|
806 RFbsSession::Disconnect(); |
|
807 |
|
808 return result; |
|
809 } |
|
810 |
|
811 |
|
812 /** |
|
813 * |
|
814 * Read and Decoder using FileNewL with DRM intent API (specifying MIME Type) |
|
815 * Negative Test, drm protected file with rights count |
|
816 * Step 0605_HP |
|
817 * |
|
818 */ |
|
819 TVerdict CTestNegativeConversion::Step0605_HP() |
|
820 { |
|
821 TVerdict result = EFail ; |
|
822 TInt err = KErrNone; |
|
823 |
|
824 // dummy Hal call for heap balance on target |
|
825 if (DummyHalCall() != KErrNone) |
|
826 return EInconclusive; |
|
827 |
|
828 err = RFbsSession::Connect(); |
|
829 if (err != KErrNone) |
|
830 { |
|
831 INFO_PRINTF2(_L("RFbsSession::Connect() failed, err = %d"), err); |
|
832 return EInconclusive; |
|
833 } |
|
834 |
|
835 //specify the MIME type |
|
836 TBuf8<KMaxMimeLength> mimeType; |
|
837 ReadMimeTypeFromConfig(mimeType); |
|
838 |
|
839 // set the rights count |
|
840 CRightsDatabase* rights = CRightsDatabase::NewL(EFalse); // create new database overwriting current one |
|
841 CleanupStack::PushL(rights); |
|
842 rights->AddRightsL(KDefaultRightsID,KDefaultRightsCount); // add rights count |
|
843 CleanupStack::PopAndDestroy(rights); // cleanup rights object |
|
844 |
|
845 //attempt KDefaultRightsCount times to open the file |
|
846 for (TInt i=0;i<KDefaultRightsCount;i++) |
|
847 { |
|
848 TRAP(err, OpenImageForDecodeFromFileWithIntentL(iFileNameSrc, EView, mimeType)); |
|
849 |
|
850 INFO_PRINTF2( _L("CImageDecoder: DRM FileNewL number %d"),i); |
|
851 |
|
852 if (err != KErrNone) |
|
853 { |
|
854 INFO_PRINTF2(_L("Unexpected error %d"),err); |
|
855 break; |
|
856 } |
|
857 } |
|
858 |
|
859 // now attempt to open again |
|
860 if (err == KErrNone) |
|
861 { |
|
862 TRAP(err, OpenImageForDecodeFromFileWithIntentL(iFileNameSrc, EView, mimeType)); |
|
863 |
|
864 INFO_PRINTF1( _L("CImageDecoder:DRM FileNewL with expired rights")); |
|
865 |
|
866 if (err != KErrCANoPermission) |
|
867 { |
|
868 INFO_PRINTF3(_L("Unexpected error %d, expected %d"),err,KErrCANoPermission); |
|
869 } |
|
870 else |
|
871 { |
|
872 INFO_PRINTF1(_L("Expected failure: rights denied")); |
|
873 result = EPass; |
|
874 } |
|
875 } |
|
876 |
|
877 |
|
878 RFbsSession::Disconnect(); |
|
879 |
|
880 return result; |
|
881 } |
|
882 |
|
883 |
|
884 |
|
885 /** |
|
886 * |
|
887 * Read and Decoder using FileNewL with DRM intent API (specifying MIME Type) |
|
888 * Negative Test, drm protected file with rights count |
|
889 * Step 0606_HP |
|
890 * |
|
891 */ |
|
892 TVerdict CTestNegativeConversion::Step0606_HP() |
|
893 { |
|
894 TVerdict result = EFail ; |
|
895 TInt err = KErrNone; |
|
896 |
|
897 // dummy Hal call for heap balance on target |
|
898 if (DummyHalCall() != KErrNone) |
|
899 return EInconclusive; |
|
900 |
|
901 err = RFbsSession::Connect(); |
|
902 if (err != KErrNone) |
|
903 { |
|
904 INFO_PRINTF2(_L("RFbsSession::Connect() failed, err = %d"), err); |
|
905 return EInconclusive; |
|
906 } |
|
907 |
|
908 //specify the MIME type |
|
909 TBuf8<KMaxMimeLength> mimeType; |
|
910 ReadMimeTypeFromConfig(mimeType); |
|
911 |
|
912 // set the rights count |
|
913 CRightsDatabase* rights = CRightsDatabase::NewL(EFalse); // create new database overwriting current one |
|
914 CleanupStack::PushL(rights); |
|
915 rights->AddRightsL(KDefaultRightsID, KRightsNoCount, mimeType); // add rights count |
|
916 CleanupStack::PopAndDestroy(rights); // cleanup rights object |
|
917 |
|
918 TRAP(err, OpenImageForDecodeFromFileWithIntentL(iFileNameSrc, EView)); |
|
919 |
|
920 if (err == KErrNone) |
|
921 { |
|
922 INFO_PRINTF1(_L("Successfully opened file, with mime type specified by DRM agent")); |
|
923 result = EPass; |
|
924 } |
|
925 else |
|
926 { |
|
927 INFO_PRINTF2(_L("Unexpected error %d"),err); |
|
928 } |
|
929 |
|
930 RFbsSession::Disconnect(); |
|
931 |
|
932 return result; |
|
933 } |
|
934 |
|
935 /** |
|
936 * |
|
937 * Read and Decoder using FileNewL with DRM intent API (specifying MIME Type) |
|
938 * Negative Test, drm protected file with rights count |
|
939 * Step 0607_HP |
|
940 * |
|
941 */ |
|
942 TVerdict CTestNegativeConversion::Step0607_HP() |
|
943 { |
|
944 TVerdict result = EFail ; |
|
945 TInt err = KErrNone; |
|
946 |
|
947 // dummy Hal call for heap balance on target |
|
948 if (DummyHalCall() != KErrNone) |
|
949 return EInconclusive; |
|
950 |
|
951 err = RFbsSession::Connect(); |
|
952 if (err != KErrNone) |
|
953 { |
|
954 INFO_PRINTF2(_L("RFbsSession::Connect() failed, err = %d"), err); |
|
955 return EInconclusive; |
|
956 } |
|
957 |
|
958 //specify the MIME type |
|
959 TBuf8<KMaxMimeLength> mimeType; |
|
960 ReadMimeTypeFromConfig(mimeType); |
|
961 |
|
962 // set the rights count |
|
963 CRightsDatabase* rights = CRightsDatabase::NewL(EFalse); // create new database overwriting current one |
|
964 CleanupStack::PushL(rights); |
|
965 rights->AddRightsL(KDefaultRightsID, KRightsNoCount, mimeType); // add rights count |
|
966 CleanupStack::PopAndDestroy(rights); // cleanup rights object |
|
967 |
|
968 TFileName theSourceFilename; |
|
969 Directory(EInput, theSourceFilename); |
|
970 theSourceFilename.Append(iFileNameSrc); |
|
971 |
|
972 RFs fs; |
|
973 User::LeaveIfError(fs.Connect()); |
|
974 |
|
975 TBuf8<KMaxMimeLength> returnedMimeType; |
|
976 |
|
977 TRAP(err, CImageDecoder::GetMimeTypeFileL(fs, theSourceFilename, returnedMimeType)); |
|
978 |
|
979 if (err != KErrNone) |
|
980 { |
|
981 INFO_PRINTF2(_L("Unexpected error %d while retrieving MIME type"), err); |
|
982 } |
|
983 else |
|
984 { |
|
985 if (mimeType.Compare(returnedMimeType)==0) |
|
986 { |
|
987 INFO_PRINTF1(_L("Mime type correctly retrieved from DRM agent")); |
|
988 result = EPass; |
|
989 } |
|
990 else |
|
991 { |
|
992 INFO_PRINTF3(_L("Mime type not returned correctly, expected %S, received %S"),&mimeType,&returnedMimeType); |
|
993 } |
|
994 } |
|
995 |
|
996 |
|
997 RFbsSession::Disconnect(); |
|
998 |
|
999 return result; |
|
1000 } |
|
1001 |
|
1002 /** |
|
1003 * |
|
1004 * Request load and decode |
|
1005 * of corrupt WMF image |
|
1006 * |
|
1007 */ |
|
1008 TVerdict CTestNegativeConversion::Step0700_CP() |
|
1009 { |
|
1010 |
|
1011 TInt theRes = KErrNone; |
|
1012 |
|
1013 HBufC8 *theDestinationImage = NULL; |
|
1014 CImageEncoder *theImageEncoder = NULL; |
|
1015 |
|
1016 TInt err = RFbsSession::Connect(); |
|
1017 |
|
1018 if (err != KErrNone) |
|
1019 { |
|
1020 INFO_PRINTF2(_L("RFbsSession::Connect() failed, err = %d"), err); |
|
1021 return EInconclusive; |
|
1022 } |
|
1023 |
|
1024 TRAP(theRes, theImageEncoder = CImageEncoder::DataNewL( theDestinationImage, |
|
1025 CImageEncoder::EOptionNone, KImageTypeJPGUid )); |
|
1026 |
|
1027 if(theRes != KErrNone) |
|
1028 { |
|
1029 User::Leave(theRes); |
|
1030 } |
|
1031 CleanupStack::PushL(theImageEncoder); |
|
1032 |
|
1033 |
|
1034 |
|
1035 // do conversion |
|
1036 CActiveListener* activeListener = new(ELeave)CActiveListener; |
|
1037 CleanupStack::PushL( activeListener ); |
|
1038 |
|
1039 CFbsBitmap* extBitmap = new (ELeave) CFbsBitmap; |
|
1040 |
|
1041 CleanupStack::PushL(extBitmap); |
|
1042 |
|
1043 |
|
1044 User::LeaveIfError(extBitmap->CreateExtendedBitmap( |
|
1045 TSize(100,100), |
|
1046 EColor16M,KImageTypeJPGUid,29143,*this)); |
|
1047 |
|
1048 activeListener->InitialiseActiveListener(); |
|
1049 theImageEncoder->Convert(&activeListener->iStatus,*extBitmap); |
|
1050 CActiveScheduler::Start(); |
|
1051 |
|
1052 theRes = activeListener->iStatus.Int(); |
|
1053 |
|
1054 if(theRes!=KErrNotSupported) |
|
1055 { |
|
1056 User::Leave(theRes); |
|
1057 } |
|
1058 |
|
1059 INFO_PRINTF1(_L("Got KErrNotSupported as expected")); |
|
1060 // |
|
1061 delete theDestinationImage; |
|
1062 theDestinationImage = NULL; |
|
1063 |
|
1064 CleanupStack::PopAndDestroy(3, theImageEncoder); |
|
1065 |
|
1066 return EPass; |
|
1067 } |
|
1068 |
|
1069 TInt CTestNegativeConversion::InitExtendedBitmap(TAny* /*aData*/, TInt /*aDataSize*/) |
|
1070 { |
|
1071 return KErrNone; |
|
1072 } |