|
1 // Copyright (c) 2004-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 for GT0210 MS3.4 File Handle APIs. |
|
15 // EPOC includes |
|
16 // |
|
17 // |
|
18 |
|
19 #include <testframework.h> |
|
20 #include <caf/caf.h> |
|
21 #include "TestNegativeConversionNew.h" |
|
22 |
|
23 #include "ICLFbsSessionTest.h" |
|
24 |
|
25 using namespace ContentAccess; |
|
26 |
|
27 const TInt KMaxMimeLength = 256; |
|
28 |
|
29 /** |
|
30 * |
|
31 * |
|
32 * CTestNegativeConversionNew::NewL |
|
33 * |
|
34 */ |
|
35 CTestNegativeConversionNew *CTestNegativeConversionNew::NewL(const TDesC& aTestName) |
|
36 { |
|
37 CTestNegativeConversionNew* self = new(ELeave) CTestNegativeConversionNew(aTestName); |
|
38 return self; |
|
39 } |
|
40 |
|
41 /** |
|
42 * |
|
43 * |
|
44 * Implementation of Virtual Function CTestStep::DoTestStepL() |
|
45 * |
|
46 */ |
|
47 TVerdict CTestNegativeConversionNew::DoTestStepL() |
|
48 { |
|
49 TVerdict currentVerdict = EPass; |
|
50 |
|
51 if( ( iTestStepName.Compare(_L("MM-ICL-FRM-I-1701-HP")) == 0) || |
|
52 ( iTestStepName.Compare(_L("MM-ICL-FRM-I-1702-HP")) == 0) || |
|
53 ( iTestStepName.Compare(_L("MM-ICL-FRM-I-1703-HP")) == 0) ) |
|
54 { |
|
55 currentVerdict = Step1701_1703_HPL(); |
|
56 } |
|
57 else if( ( iTestStepName.Compare(_L("MM-ICL-FRM-I-1704-HP")) == 0) || |
|
58 ( iTestStepName.Compare(_L("MM-ICL-FRM-I-1705-HP")) == 0) || |
|
59 ( iTestStepName.Compare(_L("MM-ICL-FRM-I-1706-HP")) == 0) ) |
|
60 { |
|
61 currentVerdict = Step1704_1706_HPL(); |
|
62 } |
|
63 |
|
64 return currentVerdict; |
|
65 } |
|
66 |
|
67 |
|
68 /* |
|
69 * |
|
70 * CImageDecoder Negative tests - OpenFile by Handles. |
|
71 * |
|
72 * Step1701_1702_HP |
|
73 * |
|
74 */ |
|
75 TVerdict CTestNegativeConversionNew::Step1701_1703_HPL() |
|
76 { |
|
77 //[ Local variables ] |
|
78 TVerdict result = EFail; |
|
79 |
|
80 // dummy Hal call for heap balance on target |
|
81 if (DummyHalCall() != KErrNone) |
|
82 { |
|
83 return EInconclusive; |
|
84 } |
|
85 |
|
86 //__MM_HEAP_MARK; |
|
87 //[ Connect RFs ] |
|
88 User::LeaveIfError(iFs.Connect()); |
|
89 User::LeaveIfError(iFs.ShareProtected()); |
|
90 CleanupClosePushL(iFs); |
|
91 |
|
92 //[ Open the Source Image File using RFile ] |
|
93 TFileName theSourceFilename; |
|
94 Directory(EInput, theSourceFilename); |
|
95 theSourceFilename.Append(iFileNameSrc); |
|
96 |
|
97 INFO_PRINTF2(_L("Start : Open the file : %S by RFile"), &theSourceFilename); |
|
98 TInt theRes = iFile.Open(iFs, theSourceFilename, EFileWrite); |
|
99 User::LeaveIfError(theRes); |
|
100 CleanupClosePushL(iFile); |
|
101 INFO_PRINTF2(_L("End : Open the file : %S by RFile"), &theSourceFilename); |
|
102 |
|
103 //[ Open the File for convert, using the 'FileNewL' APIs for each test step ] |
|
104 INFO_PRINTF2(_L("Start : Open the file : %S by CImageDecoder::FileNewL"), &theSourceFilename); |
|
105 if (iTestStepName.Compare(_L("MM-ICL-FRM-I-1701-HP")) == 0) |
|
106 { |
|
107 INFO_PRINTF1(_L("Read, decode and verify JPEG, with an invalid MIME Type.")); |
|
108 TBuf8<KMaxMimeLength> mimeType; |
|
109 ReadMimeTypeFromConfig(mimeType); |
|
110 TRAP(theRes, iImageDecoder=CImageDecoder::FileNewL(iFile, mimeType, EPlay)); |
|
111 } |
|
112 else if (iTestStepName.Compare(_L("MM-ICL-FRM-I-1702-HP")) == 0) |
|
113 { |
|
114 INFO_PRINTF1(_L("Read, decode and verify JPEG, with an invalid Image Type.")); |
|
115 TRAP(theRes, iImageDecoder=CImageDecoder::FileNewL(iFile, EPlay, CImageDecoder::EOptionNone, iImageTypeUid, KNullUid, KNullUid)); |
|
116 } |
|
117 else if (iTestStepName.Compare(_L("MM-ICL-FRM-I-1703-HP")) == 0) |
|
118 { |
|
119 INFO_PRINTF1(_L("Decode text file.")); |
|
120 TRAP(theRes, iImageDecoder=CImageDecoder::FileNewL(iFile, EPlay)); |
|
121 } |
|
122 INFO_PRINTF2(_L("End : Open the file : %S by CImageDecoder::FileNewL"), &theSourceFilename); |
|
123 |
|
124 //[ Checking for the Correct Error returned ] |
|
125 if(theRes == KErrNotFound) |
|
126 { |
|
127 INFO_PRINTF1(_L("One or More Arguments are Invalid for 'CImageDecoder::FileNewL'. The Error Returned is -1 (KErrNotFound)")); |
|
128 result = EPass; |
|
129 } |
|
130 else |
|
131 { |
|
132 INFO_PRINTF1(_L("The Expected result is NOT returned for 'CImageDecoder::FileNewL'.")); |
|
133 result = EFail; |
|
134 } |
|
135 |
|
136 //[ Delete and Close ImageEncoder ] |
|
137 delete iImageDecoder; |
|
138 iImageDecoder = NULL; |
|
139 |
|
140 //[ Delete and Close RFs and RFile ] |
|
141 CleanupStack::PopAndDestroy(2); |
|
142 |
|
143 return result; |
|
144 } |
|
145 |
|
146 /* |
|
147 * |
|
148 * CImageEncoder Negative tests - OpenFile by Handles. |
|
149 * |
|
150 * Step1704_1706_HP |
|
151 * |
|
152 */ |
|
153 TVerdict CTestNegativeConversionNew::Step1704_1706_HPL() |
|
154 { |
|
155 //[ Local variables ] |
|
156 TVerdict result = EFail ; |
|
157 TInt theErr = KErrNone; |
|
158 |
|
159 //__MM_HEAP_MARK; |
|
160 //[ Connect RFs ] |
|
161 User::LeaveIfError(iFs.Connect()); |
|
162 User::LeaveIfError(iFs.ShareProtected()); |
|
163 CleanupClosePushL(iFs); |
|
164 |
|
165 // [ Open the Destination File using RFile ] |
|
166 TFileName theDestinationFileName; |
|
167 TBuf<KLenBuffer> theExtension; |
|
168 |
|
169 Directory(EOutput, theDestinationFileName); |
|
170 theDestinationFileName.Append(iFileNameSrc.Left(iFileNameSrc.Length()-3)); |
|
171 GetImageExtension(iImageTypeUid, theExtension); |
|
172 theDestinationFileName.Append(theExtension); |
|
173 |
|
174 INFO_PRINTF2(_L("Start : Open the file : %S by RFile"), &theDestinationFileName); |
|
175 TInt theRes = iFile.Replace(iFs, theDestinationFileName, EFileWrite); |
|
176 User::LeaveIfError(theRes); |
|
177 CleanupClosePushL(iFile); |
|
178 INFO_PRINTF2(_L("End : Open the file : %S by RFile"), &theDestinationFileName); |
|
179 |
|
180 //[ Connect to RFbsSession ] |
|
181 CICLFbsSessionTest* fbsSession = CICLFbsSessionTest::NewLC(); |
|
182 |
|
183 //[ Open the File for convert, using the 'FileNewL' APIs for each test step ] |
|
184 INFO_PRINTF2(_L("Start : Open the file : %S by CImageEncoder::FileNewL"), &theDestinationFileName); |
|
185 if (iTestStepName.Compare(_L("MM-ICL-FRM-I-1704-HP")) == 0) |
|
186 { |
|
187 INFO_PRINTF1(_L("Encode an image from bitmap to a file, specifying an invalid MIME type.")); |
|
188 TBuf8<KMaxMimeLength> mimeType; |
|
189 ReadMimeTypeFromConfig(mimeType); |
|
190 TRAP(theRes, iImageEncoder=CImageEncoder::FileNewL(iFile, mimeType)); |
|
191 } |
|
192 else if (iTestStepName.Compare(_L("MM-ICL-FRM-I-1705-HP")) == 0) |
|
193 { |
|
194 INFO_PRINTF1(_L("Encode an image from bitmap to a file, specifying an invalid image type.")); |
|
195 TRAP(theRes, iImageEncoder=CImageEncoder::FileNewL(iFile, CImageEncoder::EOptionNone, KImageTypeGIFUid, KNullUid, KNullUid)); |
|
196 } |
|
197 else if (iTestStepName.Compare(_L("MM-ICL-FRM-I-1706-HP")) == 0) |
|
198 { |
|
199 INFO_PRINTF1(_L("Encode to a jpg file containing text data.")); |
|
200 //Image type or encoder UID should be there, otherwise throws panic.. |
|
201 TRAP(theRes, iImageEncoder=CImageEncoder::FileNewL(iFile, CImageEncoder::EOptionNone, iImageTypeUid)); |
|
202 } |
|
203 INFO_PRINTF2(_L("End : Open the file : %S by CImageEncoder::FileNewL"), &theDestinationFileName); |
|
204 |
|
205 //[ Checking for the Correct Error returned ] |
|
206 if(theRes == KErrNotFound) |
|
207 { |
|
208 INFO_PRINTF1(_L("One or More Arguments are Invalid for 'CImageEncoder::FileNewL'. The Error Returned is -1 (KErrNotFound)")); |
|
209 result = EPass; |
|
210 } |
|
211 else if(theRes == KErrNone) |
|
212 { |
|
213 INFO_PRINTF1(_L("The Expected Error is NOT returned for 'CImageEncoder::FileNewL'. The Error Returned is 0 (KErrNone). So Proceeding to Encode.")); |
|
214 INFO_PRINTF2(_L("The file : %S had been opened"), &theDestinationFileName); |
|
215 |
|
216 //[ Call the main Encode Test Method ] |
|
217 TRAP(theErr, EncodeUsingEncoderL(iFileNameSrc)); |
|
218 |
|
219 //[ Check the Error ] |
|
220 if(theErr == KErrNone) |
|
221 { |
|
222 INFO_PRINTF1(_L("No Error is Returned after Encoding.")); |
|
223 result = EFail; |
|
224 } |
|
225 else if(theErr == KErrNotIdentical) |
|
226 { |
|
227 INFO_PRINTF1(_L("The Error Returned after Encoding is KErrNotIdentical.")); |
|
228 result = EPass; |
|
229 } |
|
230 } |
|
231 else |
|
232 { |
|
233 INFO_PRINTF2(_L("Unexpected Error : %d. The Expected Error is -1 (KErrNotFound)"), theRes); |
|
234 result = EInconclusive; |
|
235 } |
|
236 |
|
237 //[ Delete and Close ImageEncoder ] |
|
238 delete iImageEncoder; |
|
239 iImageEncoder = NULL; |
|
240 |
|
241 //[ Delete and Close RFs, RFile and fbsSession] |
|
242 CleanupStack::PopAndDestroy(3); |
|
243 |
|
244 //__MM_HEAP_MARKEND; |
|
245 |
|
246 return result; |
|
247 } |
|
248 |