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 |
* cafstep.cpp
|
sl@0
|
16 |
*
|
sl@0
|
17 |
*/
|
sl@0
|
18 |
|
sl@0
|
19 |
|
sl@0
|
20 |
#include <test/testexecutelog.h>
|
sl@0
|
21 |
#include <apgcli.h>
|
sl@0
|
22 |
#include <apmstd.h>
|
sl@0
|
23 |
#include "cafserver.h"
|
sl@0
|
24 |
#include "resolver.h"
|
sl@0
|
25 |
#include "RecognizerStep.h"
|
sl@0
|
26 |
#include "CafApaRecognizer.h"
|
sl@0
|
27 |
|
sl@0
|
28 |
using namespace ContentAccess;
|
sl@0
|
29 |
|
sl@0
|
30 |
const TInt KCafTestMaxDataTypeLength = 255;
|
sl@0
|
31 |
const TInt KCAFTestApparcBufferSize = 100;
|
sl@0
|
32 |
|
sl@0
|
33 |
/*
|
sl@0
|
34 |
* This step starts the CAF Apparc recognizer and checks to see that it recognizes the
|
sl@0
|
35 |
* correct files
|
sl@0
|
36 |
*
|
sl@0
|
37 |
*/
|
sl@0
|
38 |
|
sl@0
|
39 |
CCAFRecognizeStep::~CCAFRecognizeStep()
|
sl@0
|
40 |
{
|
sl@0
|
41 |
}
|
sl@0
|
42 |
|
sl@0
|
43 |
CCAFRecognizeStep::CCAFRecognizeStep(CCAFServer& aParent)
|
sl@0
|
44 |
: iParent(aParent)
|
sl@0
|
45 |
{
|
sl@0
|
46 |
SetTestStepName(KCAFRecognizeStep);
|
sl@0
|
47 |
}
|
sl@0
|
48 |
|
sl@0
|
49 |
/* Tests whether a file opened under the caf framework reports the same size as
|
sl@0
|
50 |
* RFile. Only works for files that are owned by the f32agent which doesn't
|
sl@0
|
51 |
* change the content at all.
|
sl@0
|
52 |
*/
|
sl@0
|
53 |
TVerdict CCAFRecognizeStep::doTestStepL()
|
sl@0
|
54 |
{
|
sl@0
|
55 |
#ifdef SYMBIAN_ENABLE_SDP_WMDRM_SUPPORT
|
sl@0
|
56 |
TBool wmdrmFlag = EFalse;
|
sl@0
|
57 |
GetBoolFromConfig(ConfigSection(),_L("wmdrmEnabled"), wmdrmFlag);
|
sl@0
|
58 |
|
sl@0
|
59 |
if(wmdrmFlag)
|
sl@0
|
60 |
{
|
sl@0
|
61 |
TVerdict verdict = doWmdrmTestStepL();
|
sl@0
|
62 |
return verdict;
|
sl@0
|
63 |
}
|
sl@0
|
64 |
#endif //SYMBIAN_ENABLE_SDP_WMDRM_SUPPORT
|
sl@0
|
65 |
|
sl@0
|
66 |
TBuf8 <KCAFTestApparcBufferSize> buf;
|
sl@0
|
67 |
|
sl@0
|
68 |
CAgentResolver *resolver;
|
sl@0
|
69 |
|
sl@0
|
70 |
// If we leave before our DoRecognize is complete, something must have gone seriously wrong
|
sl@0
|
71 |
SetTestStepResult(EFail);
|
sl@0
|
72 |
|
sl@0
|
73 |
TBuf8 <KCafTestMaxDataTypeLength> ContainerMimeType;
|
sl@0
|
74 |
TBuf8 <KCafTestMaxDataTypeLength> ContentMimeType;
|
sl@0
|
75 |
TBool result;
|
sl@0
|
76 |
|
sl@0
|
77 |
TPtrC fileName;
|
sl@0
|
78 |
TBool expectedresult;
|
sl@0
|
79 |
TPtrC expectedContainerMime, expectedContentMime;
|
sl@0
|
80 |
|
sl@0
|
81 |
// Retrieve filename to analyse and expected results from INI file
|
sl@0
|
82 |
GetStringFromConfig(ConfigSection(),_L("FileName"),fileName);
|
sl@0
|
83 |
GetStringFromConfig(ConfigSection(),_L("Container"),expectedContainerMime);
|
sl@0
|
84 |
GetStringFromConfig(ConfigSection(),_L("Content"),expectedContentMime);
|
sl@0
|
85 |
GetBoolFromConfig(ConfigSection(),_L("Recognized"),expectedresult);
|
sl@0
|
86 |
|
sl@0
|
87 |
if(expectedresult)
|
sl@0
|
88 |
{
|
sl@0
|
89 |
INFO_PRINTF4(_L("DoRecognize Test DRM file: %S, Container Mime Type: %S, Content Mime Type: %S"),&fileName, &expectedContainerMime, &expectedContentMime);
|
sl@0
|
90 |
}
|
sl@0
|
91 |
else
|
sl@0
|
92 |
{
|
sl@0
|
93 |
INFO_PRINTF2(_L("DoRecognize Test non DRM file: %S"), &fileName);
|
sl@0
|
94 |
}
|
sl@0
|
95 |
|
sl@0
|
96 |
__UHEAP_MARK;
|
sl@0
|
97 |
|
sl@0
|
98 |
// Read the first KCAFTestApparcBufferSize bytes into the buffer in the same way apparc would do
|
sl@0
|
99 |
ReadBufferL(fileName, buf);
|
sl@0
|
100 |
|
sl@0
|
101 |
// Pass the filename and buffer to CAF DoRecognize function
|
sl@0
|
102 |
resolver = CAgentResolver::NewLC(ETrue);
|
sl@0
|
103 |
|
sl@0
|
104 |
result = resolver->DoRecognizeL(fileName, buf, ContainerMimeType, ContentMimeType);
|
sl@0
|
105 |
|
sl@0
|
106 |
CheckResultL(result, ContainerMimeType, ContentMimeType, expectedresult, expectedContainerMime, expectedContentMime);
|
sl@0
|
107 |
|
sl@0
|
108 |
CleanupStack::PopAndDestroy(resolver);
|
sl@0
|
109 |
|
sl@0
|
110 |
__UHEAP_MARKEND;
|
sl@0
|
111 |
return TestStepResult();
|
sl@0
|
112 |
}
|
sl@0
|
113 |
|
sl@0
|
114 |
void CCAFRecognizeStep::CheckResultL(TBool aResult, TDes8& aContainerMimeType, TDes8& aContentMimeType, TBool aExpectedResult, TDesC16& aExpectedContainerMime, TDesC16& aExpectedContentMime)
|
sl@0
|
115 |
{
|
sl@0
|
116 |
// start off by assuming recognition was ok, then check
|
sl@0
|
117 |
SetTestStepResult(EPass);
|
sl@0
|
118 |
|
sl@0
|
119 |
if(aResult != aExpectedResult)
|
sl@0
|
120 |
{
|
sl@0
|
121 |
if(aResult)
|
sl@0
|
122 |
{
|
sl@0
|
123 |
INFO_PRINTF1(_L("File was incorrectly recognized as DRM"));
|
sl@0
|
124 |
}
|
sl@0
|
125 |
else
|
sl@0
|
126 |
{
|
sl@0
|
127 |
INFO_PRINTF1(_L("File was incorrectly recognized as not DRM"));
|
sl@0
|
128 |
}
|
sl@0
|
129 |
SetTestStepResult(EFail);
|
sl@0
|
130 |
return;
|
sl@0
|
131 |
}
|
sl@0
|
132 |
|
sl@0
|
133 |
if(!aResult) // not a drm file so we don't care about the mime types
|
sl@0
|
134 |
return;
|
sl@0
|
135 |
|
sl@0
|
136 |
TInt compare;
|
sl@0
|
137 |
|
sl@0
|
138 |
// Convert TDes16 mime types read from the INI file to TPtr8's
|
sl@0
|
139 |
HBufC8 *container = ConvertDes16toHBufC8LC(aExpectedContainerMime);
|
sl@0
|
140 |
TPtr8 containerptr(container->Des());
|
sl@0
|
141 |
|
sl@0
|
142 |
HBufC8 *content = ConvertDes16toHBufC8LC(aExpectedContentMime);
|
sl@0
|
143 |
TPtr8 contentptr(content->Des());
|
sl@0
|
144 |
|
sl@0
|
145 |
// Compare expected Mime Types vs mime type
|
sl@0
|
146 |
compare = aContainerMimeType.Compare(containerptr);
|
sl@0
|
147 |
if(compare != 0)
|
sl@0
|
148 |
{
|
sl@0
|
149 |
INFO_PRINTF1(_L("Incorrect Container Mime Type recognized"));
|
sl@0
|
150 |
SetTestStepResult(EFail);
|
sl@0
|
151 |
}
|
sl@0
|
152 |
compare = aContentMimeType.Compare(contentptr);
|
sl@0
|
153 |
if(compare != 0)
|
sl@0
|
154 |
{
|
sl@0
|
155 |
INFO_PRINTF1(_L("Incorrect Content Mime Type recognized"));
|
sl@0
|
156 |
SetTestStepResult(EFail);
|
sl@0
|
157 |
}
|
sl@0
|
158 |
CleanupStack::PopAndDestroy(2, container);
|
sl@0
|
159 |
}
|
sl@0
|
160 |
|
sl@0
|
161 |
|
sl@0
|
162 |
/*
|
sl@0
|
163 |
* This step starts the CAF Apparc recognizer speed test
|
sl@0
|
164 |
* Does 1000 recognitions, log file will measure the time
|
sl@0
|
165 |
*
|
sl@0
|
166 |
*/
|
sl@0
|
167 |
|
sl@0
|
168 |
CCAFRecognizerSpeedStep::~CCAFRecognizerSpeedStep()
|
sl@0
|
169 |
{
|
sl@0
|
170 |
}
|
sl@0
|
171 |
|
sl@0
|
172 |
CCAFRecognizerSpeedStep::CCAFRecognizerSpeedStep(CCAFServer& aParent) : iParent(aParent)
|
sl@0
|
173 |
{
|
sl@0
|
174 |
SetTestStepName(KCAFRecognizerSpeedStep);
|
sl@0
|
175 |
}
|
sl@0
|
176 |
|
sl@0
|
177 |
|
sl@0
|
178 |
TVerdict CCAFRecognizerSpeedStep::doTestStepL()
|
sl@0
|
179 |
{
|
sl@0
|
180 |
TBuf8 <KCAFTestApparcBufferSize> buf;
|
sl@0
|
181 |
|
sl@0
|
182 |
CAgentResolver *resolver;
|
sl@0
|
183 |
|
sl@0
|
184 |
// If we leave before our DoRecognize is complete, something must have gone seriously wrong
|
sl@0
|
185 |
SetTestStepResult(EFail);
|
sl@0
|
186 |
|
sl@0
|
187 |
TBuf8 <KCafTestMaxDataTypeLength> ContainerMimeType;
|
sl@0
|
188 |
TBuf8 <KCafTestMaxDataTypeLength> ContentMimeType;
|
sl@0
|
189 |
|
sl@0
|
190 |
TPtrC fileName;
|
sl@0
|
191 |
TBool expectedresult;
|
sl@0
|
192 |
TPtrC expectedContainerMime, expectedContentMime;
|
sl@0
|
193 |
|
sl@0
|
194 |
// Retrieve filename to analyse and expected results from INI file
|
sl@0
|
195 |
GetStringFromConfig(ConfigSection(),_L("FileName"),fileName);
|
sl@0
|
196 |
GetStringFromConfig(ConfigSection(),_L("Container"),expectedContainerMime);
|
sl@0
|
197 |
GetStringFromConfig(ConfigSection(),_L("Content"),expectedContentMime);
|
sl@0
|
198 |
GetBoolFromConfig(ConfigSection(),_L("Recognized"),expectedresult);
|
sl@0
|
199 |
|
sl@0
|
200 |
if(expectedresult)
|
sl@0
|
201 |
{
|
sl@0
|
202 |
INFO_PRINTF4(_L("DoRecognize Speed Test DRM file: %S, Container Mime Type: %S, Content Mime Type: %S"),&fileName, &expectedContainerMime, &expectedContentMime);
|
sl@0
|
203 |
}
|
sl@0
|
204 |
else
|
sl@0
|
205 |
{
|
sl@0
|
206 |
INFO_PRINTF2(_L("DoRecognize Speed Test non DRM file: %S"), &fileName);
|
sl@0
|
207 |
}
|
sl@0
|
208 |
|
sl@0
|
209 |
__UHEAP_MARK;
|
sl@0
|
210 |
|
sl@0
|
211 |
// Read the first KCAFTestApparcBufferSize bytes into the buffer in the same way apparc would do
|
sl@0
|
212 |
ReadBufferL(fileName, buf);
|
sl@0
|
213 |
|
sl@0
|
214 |
// Pass the filename and buffer to CAF DoRecognize function
|
sl@0
|
215 |
resolver = CAgentResolver::NewLC(ETrue);
|
sl@0
|
216 |
|
sl@0
|
217 |
INFO_PRINTF1(_L("Entering measured mile"));
|
sl@0
|
218 |
|
sl@0
|
219 |
for(TInt Count=0; Count < 1000; Count++)
|
sl@0
|
220 |
resolver->DoRecognizeL(fileName, buf, ContainerMimeType, ContentMimeType);
|
sl@0
|
221 |
|
sl@0
|
222 |
INFO_PRINTF1(_L("passing mile marker (1000 recognitions)"));
|
sl@0
|
223 |
|
sl@0
|
224 |
CleanupStack::PopAndDestroy(resolver);
|
sl@0
|
225 |
|
sl@0
|
226 |
__UHEAP_MARKEND;
|
sl@0
|
227 |
SetTestStepResult(EPass);
|
sl@0
|
228 |
return TestStepResult();
|
sl@0
|
229 |
}
|
sl@0
|
230 |
|
sl@0
|
231 |
|
sl@0
|
232 |
/*
|
sl@0
|
233 |
* This step starts the CAF Apparc recognizer and checks to see that it recognizes the
|
sl@0
|
234 |
* correct files
|
sl@0
|
235 |
*
|
sl@0
|
236 |
*/
|
sl@0
|
237 |
|
sl@0
|
238 |
CCAFBufferSizeStep::~CCAFBufferSizeStep()
|
sl@0
|
239 |
{
|
sl@0
|
240 |
}
|
sl@0
|
241 |
|
sl@0
|
242 |
CCAFBufferSizeStep::CCAFBufferSizeStep(CCAFServer& aParent) : iParent(aParent)
|
sl@0
|
243 |
{
|
sl@0
|
244 |
SetTestStepName(KCAFBufferSizeStep);
|
sl@0
|
245 |
}
|
sl@0
|
246 |
|
sl@0
|
247 |
|
sl@0
|
248 |
/* Apparc uses a buffer to pass data from the start of the file into the apparc recognizer
|
sl@0
|
249 |
* to help it determine what mime type the file is.
|
sl@0
|
250 |
* In CAF this recognition task is actually handed over to the agents. Each one attempts to
|
sl@0
|
251 |
* recognize the file until one is successful or until all agents have rejected the file.
|
sl@0
|
252 |
* Each agent may have it's own preferred size for this buffer. This is configured in each
|
sl@0
|
253 |
* agent's RSS file, under the default_data tag.
|
sl@0
|
254 |
* CAgentResolver::PreferredBufferSize() will return the highest value returned by any agent.
|
sl@0
|
255 |
*/
|
sl@0
|
256 |
TVerdict CCAFBufferSizeStep::doTestStepL()
|
sl@0
|
257 |
{
|
sl@0
|
258 |
CAgentResolver *resolver;
|
sl@0
|
259 |
TInt expectedBufferSize;
|
sl@0
|
260 |
TInt bufferSize=0;
|
sl@0
|
261 |
|
sl@0
|
262 |
SetTestStepResult(EFail);
|
sl@0
|
263 |
|
sl@0
|
264 |
|
sl@0
|
265 |
// Find the expected max buffer size from the INI file
|
sl@0
|
266 |
GetIntFromConfig(ConfigSection(),_L("size"),expectedBufferSize);
|
sl@0
|
267 |
|
sl@0
|
268 |
INFO_PRINTF2(_L("Expected buffer size: %d"), expectedBufferSize);
|
sl@0
|
269 |
|
sl@0
|
270 |
__UHEAP_MARK;
|
sl@0
|
271 |
|
sl@0
|
272 |
|
sl@0
|
273 |
resolver = CAgentResolver::NewLC(ETrue);
|
sl@0
|
274 |
|
sl@0
|
275 |
bufferSize = resolver->PreferredBufferSize();
|
sl@0
|
276 |
|
sl@0
|
277 |
INFO_PRINTF2(_L("Caf Preferred buffer size: %d"), bufferSize);
|
sl@0
|
278 |
|
sl@0
|
279 |
if(bufferSize == expectedBufferSize)
|
sl@0
|
280 |
{
|
sl@0
|
281 |
SetTestStepResult(EPass);
|
sl@0
|
282 |
}
|
sl@0
|
283 |
|
sl@0
|
284 |
CleanupStack::PopAndDestroy(resolver);
|
sl@0
|
285 |
|
sl@0
|
286 |
__UHEAP_MARKEND;
|
sl@0
|
287 |
return TestStepResult();
|
sl@0
|
288 |
}
|
sl@0
|
289 |
|
sl@0
|
290 |
|
sl@0
|
291 |
|
sl@0
|
292 |
CCAFApparcStep::~CCAFApparcStep()
|
sl@0
|
293 |
{
|
sl@0
|
294 |
}
|
sl@0
|
295 |
|
sl@0
|
296 |
CCAFApparcStep::CCAFApparcStep(CCAFServer& aParent) : iParent(aParent)
|
sl@0
|
297 |
{
|
sl@0
|
298 |
SetTestStepName(KCAFApparcStep);
|
sl@0
|
299 |
}
|
sl@0
|
300 |
|
sl@0
|
301 |
|
sl@0
|
302 |
/*
|
sl@0
|
303 |
* This step loads the apparc recognizer and gives it a test run by
|
sl@0
|
304 |
* pretending to be apparc
|
sl@0
|
305 |
*
|
sl@0
|
306 |
*/
|
sl@0
|
307 |
TVerdict CCAFApparcStep::doTestStepL()
|
sl@0
|
308 |
{
|
sl@0
|
309 |
TDataType dataType;
|
sl@0
|
310 |
TDataType dataType2;
|
sl@0
|
311 |
TDataType dataType3;
|
sl@0
|
312 |
TDataType dataTypeNull(_L8(""));
|
sl@0
|
313 |
TPtrC8 mimeType(KNullDesC8);
|
sl@0
|
314 |
HBufC16 *displayMime;
|
sl@0
|
315 |
HBufC16 *displayMime2;
|
sl@0
|
316 |
TPtrC fileName;
|
sl@0
|
317 |
TPtrC uri;
|
sl@0
|
318 |
TPtrC expectedMimeType;
|
sl@0
|
319 |
TPtrC nullFileName(KNullDesC);
|
sl@0
|
320 |
TUid uid = KNullUid;
|
sl@0
|
321 |
|
sl@0
|
322 |
SetTestStepResult(EInconclusive);
|
sl@0
|
323 |
|
sl@0
|
324 |
__UHEAP_MARK;
|
sl@0
|
325 |
|
sl@0
|
326 |
// Retrieve filename to analyse and expected results from INI file
|
sl@0
|
327 |
GetStringFromConfig(ConfigSection(),_L("URI"),uri);
|
sl@0
|
328 |
GetStringFromConfig(ConfigSection(),_L("FileName"),fileName);
|
sl@0
|
329 |
GetStringFromConfig(ConfigSection(),_L("CafMimeType"),expectedMimeType);
|
sl@0
|
330 |
|
sl@0
|
331 |
// Use the Application Architecture Server to find the Mime type
|
sl@0
|
332 |
RApaLsSession apparcSession;
|
sl@0
|
333 |
User::LeaveIfError(apparcSession.Connect());
|
sl@0
|
334 |
CleanupClosePushL(apparcSession);
|
sl@0
|
335 |
User::LeaveIfError(apparcSession.AppForDocument(fileName, uid, dataType));
|
sl@0
|
336 |
|
sl@0
|
337 |
RFile fileHandle;
|
sl@0
|
338 |
fileHandle.Open(iParent.Fs(), uri, EFileRead);
|
sl@0
|
339 |
User::LeaveIfError(apparcSession.AppForDocument(fileHandle, uid, dataType2));
|
sl@0
|
340 |
|
sl@0
|
341 |
// Pass in a null file name to make sure it doesn't panic
|
sl@0
|
342 |
User::LeaveIfError(apparcSession.AppForDocument(nullFileName, uid, dataType3));
|
sl@0
|
343 |
|
sl@0
|
344 |
CleanupStack::PopAndDestroy(&apparcSession); // close
|
sl@0
|
345 |
|
sl@0
|
346 |
|
sl@0
|
347 |
// check mime type of the file (fileName)
|
sl@0
|
348 |
mimeType.Set(dataType.Des8());
|
sl@0
|
349 |
displayMime = ConvertDes8toHBufC16LC(mimeType);
|
sl@0
|
350 |
TPtr16 displayPtr(displayMime->Des());
|
sl@0
|
351 |
if(displayPtr.Compare(expectedMimeType) != 0)
|
sl@0
|
352 |
{
|
sl@0
|
353 |
INFO_PRINTF2(_L("CAgentResolver returned a mime type of: %S"),&displayPtr);
|
sl@0
|
354 |
INFO_PRINTF1(_L("Please make sure the configuration file RecCafMimeTypes.txt exists for RECCAF.DLL."));
|
sl@0
|
355 |
SetTestStepResult(EFail);
|
sl@0
|
356 |
}
|
sl@0
|
357 |
else
|
sl@0
|
358 |
INFO_PRINTF3(_L("File - CAgentResolver returned a mime type of: %S, matching the expected mime type of: %S"),&displayPtr, &expectedMimeType);
|
sl@0
|
359 |
|
sl@0
|
360 |
|
sl@0
|
361 |
// check mime type of the file (fileHandle)
|
sl@0
|
362 |
mimeType.Set(dataType2.Des8());
|
sl@0
|
363 |
displayMime2 = ConvertDes8toHBufC16LC(mimeType);
|
sl@0
|
364 |
TPtr16 displayPtr2(displayMime2->Des());
|
sl@0
|
365 |
if(displayPtr2.Compare(expectedMimeType) != 0)
|
sl@0
|
366 |
{
|
sl@0
|
367 |
INFO_PRINTF2(_L("CAgentResolver returned a mime type of: %S"),&displayPtr2);
|
sl@0
|
368 |
INFO_PRINTF1(_L("Please make sure the configuration file RecCafMimeTypes.txt exists for RECCAF.DLL."));
|
sl@0
|
369 |
SetTestStepResult(EFail);
|
sl@0
|
370 |
}
|
sl@0
|
371 |
else
|
sl@0
|
372 |
INFO_PRINTF3(_L("FileHandle - CAgentResolver returned a mime type of: %S, matching the expected mime type of: %S"),&displayPtr2, &expectedMimeType);
|
sl@0
|
373 |
|
sl@0
|
374 |
// Check the returned datatype is null, when a null filename is passed in
|
sl@0
|
375 |
if (dataType3 == dataTypeNull)
|
sl@0
|
376 |
INFO_PRINTF1(_L("A null datatype is returned, when a null file name is passed in"));
|
sl@0
|
377 |
else
|
sl@0
|
378 |
SetTestStepResult(EFail);
|
sl@0
|
379 |
|
sl@0
|
380 |
CleanupStack::PopAndDestroy(displayMime2);
|
sl@0
|
381 |
CleanupStack::PopAndDestroy(displayMime);
|
sl@0
|
382 |
|
sl@0
|
383 |
__UHEAP_MARKEND;
|
sl@0
|
384 |
|
sl@0
|
385 |
if (TestStepResult() != EFail)
|
sl@0
|
386 |
{
|
sl@0
|
387 |
SetTestStepResult(EPass);
|
sl@0
|
388 |
}
|
sl@0
|
389 |
|
sl@0
|
390 |
return TestStepResult();
|
sl@0
|
391 |
}
|
sl@0
|
392 |
|
sl@0
|
393 |
/*
|
sl@0
|
394 |
* This test verifies that upper case Mime types can be recognized.
|
sl@0
|
395 |
*
|
sl@0
|
396 |
* See DEF077443: Propagated:CAF should not be performing case sensitive comparisons on MIME types
|
sl@0
|
397 |
*
|
sl@0
|
398 |
*/
|
sl@0
|
399 |
CCAF_DEF077443_Step::~CCAF_DEF077443_Step()
|
sl@0
|
400 |
{
|
sl@0
|
401 |
}
|
sl@0
|
402 |
|
sl@0
|
403 |
CCAF_DEF077443_Step::CCAF_DEF077443_Step(CCAFServer& aParent) : iParent(aParent)
|
sl@0
|
404 |
{
|
sl@0
|
405 |
SetTestStepName(KCAF_DEF077443_Step);
|
sl@0
|
406 |
}
|
sl@0
|
407 |
|
sl@0
|
408 |
TVerdict CCAF_DEF077443_Step::doTestStepL()
|
sl@0
|
409 |
{
|
sl@0
|
410 |
TDataType dataType;
|
sl@0
|
411 |
TDataType dataType2;
|
sl@0
|
412 |
TPtrC8 mimeType(KNullDesC8);
|
sl@0
|
413 |
HBufC16 *displayMime;
|
sl@0
|
414 |
HBufC16 *displayMime2;
|
sl@0
|
415 |
TPtrC upperCaseFileName;
|
sl@0
|
416 |
TPtrC emptyFileName;
|
sl@0
|
417 |
TPtrC expectedContentMimeType;
|
sl@0
|
418 |
TPtrC expectedFileMimeType;
|
sl@0
|
419 |
TUid uid = KNullUid;
|
sl@0
|
420 |
|
sl@0
|
421 |
SetTestStepResult(EInconclusive);
|
sl@0
|
422 |
|
sl@0
|
423 |
__UHEAP_MARK;
|
sl@0
|
424 |
|
sl@0
|
425 |
// Retrieve filename to analyse and expected results from INI file.
|
sl@0
|
426 |
// The CAF resolver forces mime types retrieved from agents to lower case.
|
sl@0
|
427 |
// When recognising the file mime type and content mine type for a file the
|
sl@0
|
428 |
// resolver passes the request to each agent. Its possible that the agent will
|
sl@0
|
429 |
// not use lower case for the file mime type and content mime type. To be
|
sl@0
|
430 |
// consistent the resolver should set the returned data to lower case as well.
|
sl@0
|
431 |
|
sl@0
|
432 |
// The test agent takes content mime type from the uppercasetest.drm file.
|
sl@0
|
433 |
// For this case the content mime type is upper case (e.g. TEXT/PLAIN).
|
sl@0
|
434 |
GetStringFromConfig(ConfigSection(),_L("FileName1"), upperCaseFileName);
|
sl@0
|
435 |
GetStringFromConfig(ConfigSection(),_L("CafContentMimeType"), expectedContentMimeType);
|
sl@0
|
436 |
|
sl@0
|
437 |
// For a drm file with no recognised content the test agent sets the file mime type
|
sl@0
|
438 |
// as APPLICATION/TESTAGENT.DRM.
|
sl@0
|
439 |
// For this case the file emptytest.drm is used.
|
sl@0
|
440 |
GetStringFromConfig(ConfigSection(),_L("FileName2"), emptyFileName);
|
sl@0
|
441 |
GetStringFromConfig(ConfigSection(),_L("CafFileMimeType"), expectedFileMimeType);
|
sl@0
|
442 |
|
sl@0
|
443 |
// create empty DRM file
|
sl@0
|
444 |
RFs fs;
|
sl@0
|
445 |
RFile file;
|
sl@0
|
446 |
|
sl@0
|
447 |
// remove first if exists
|
sl@0
|
448 |
Delete(emptyFileName);
|
sl@0
|
449 |
|
sl@0
|
450 |
fs.Connect();
|
sl@0
|
451 |
TInt result = file.Create(fs, emptyFileName, EFileWrite);
|
sl@0
|
452 |
file.Close();
|
sl@0
|
453 |
fs.Close();
|
sl@0
|
454 |
|
sl@0
|
455 |
// Use the Application Architecture Server to find the Content Mime type
|
sl@0
|
456 |
RApaLsSession apparcSession;
|
sl@0
|
457 |
User::LeaveIfError(apparcSession.Connect());
|
sl@0
|
458 |
CleanupClosePushL(apparcSession);
|
sl@0
|
459 |
User::LeaveIfError(apparcSession.AppForDocument(upperCaseFileName, uid, dataType));
|
sl@0
|
460 |
|
sl@0
|
461 |
// Use the Application Architecture Server to find the File Mime type
|
sl@0
|
462 |
User::LeaveIfError(apparcSession.AppForDocument(emptyFileName, uid, dataType2));
|
sl@0
|
463 |
|
sl@0
|
464 |
CleanupStack::PopAndDestroy(&apparcSession); // close
|
sl@0
|
465 |
|
sl@0
|
466 |
// remove empty file
|
sl@0
|
467 |
Delete(emptyFileName);
|
sl@0
|
468 |
|
sl@0
|
469 |
// check content mime type
|
sl@0
|
470 |
mimeType.Set(dataType.Des8());
|
sl@0
|
471 |
displayMime = ConvertDes8toHBufC16LC(mimeType);
|
sl@0
|
472 |
TPtr16 displayPtr(displayMime->Des());
|
sl@0
|
473 |
if(displayPtr.Compare(expectedContentMimeType) != 0)
|
sl@0
|
474 |
{
|
sl@0
|
475 |
INFO_PRINTF2(_L("CAgentResolver returned a content mime type of: %S"),&displayPtr);
|
sl@0
|
476 |
INFO_PRINTF1(_L("Please make sure the configuration file RecCafMimeTypes.txt exists for RECCAF.DLL."));
|
sl@0
|
477 |
SetTestStepResult(EFail);
|
sl@0
|
478 |
}
|
sl@0
|
479 |
else
|
sl@0
|
480 |
INFO_PRINTF3(_L("Content - CAgentResolver returned a mime type of: %S, matching the expected mime type of: %S"),&displayPtr, &expectedContentMimeType);
|
sl@0
|
481 |
|
sl@0
|
482 |
// check file mime type
|
sl@0
|
483 |
mimeType.Set(dataType2.Des8());
|
sl@0
|
484 |
displayMime2 = ConvertDes8toHBufC16LC(mimeType);
|
sl@0
|
485 |
TPtr16 displayPtr2(displayMime2->Des());
|
sl@0
|
486 |
if(displayPtr2.Compare(expectedFileMimeType) != 0)
|
sl@0
|
487 |
{
|
sl@0
|
488 |
INFO_PRINTF2(_L("CAgentResolver returned a file mime type of: %S"),&displayPtr2);
|
sl@0
|
489 |
INFO_PRINTF1(_L("Please make sure the configuration file RecCafMimeTypes.txt exists for RECCAF.DLL."));
|
sl@0
|
490 |
SetTestStepResult(EFail);
|
sl@0
|
491 |
}
|
sl@0
|
492 |
else
|
sl@0
|
493 |
INFO_PRINTF3(_L("File - CAgentResolver returned a mime type of: %S, matching the expected mime type of: %S"),&displayPtr2, &expectedFileMimeType);
|
sl@0
|
494 |
|
sl@0
|
495 |
CleanupStack::PopAndDestroy(displayMime2);
|
sl@0
|
496 |
CleanupStack::PopAndDestroy(displayMime);
|
sl@0
|
497 |
|
sl@0
|
498 |
__UHEAP_MARKEND;
|
sl@0
|
499 |
|
sl@0
|
500 |
if (TestStepResult() != EFail)
|
sl@0
|
501 |
{
|
sl@0
|
502 |
SetTestStepResult(EPass);
|
sl@0
|
503 |
}
|
sl@0
|
504 |
|
sl@0
|
505 |
return TestStepResult();
|
sl@0
|
506 |
}
|
sl@0
|
507 |
|
sl@0
|
508 |
#ifdef SYMBIAN_ENABLE_SDP_WMDRM_SUPPORT
|
sl@0
|
509 |
|
sl@0
|
510 |
// Tests DoRecognizeL API for WMDRM content .
|
sl@0
|
511 |
|
sl@0
|
512 |
TVerdict CCAFRecognizeStep::doWmdrmTestStepL()
|
sl@0
|
513 |
{
|
sl@0
|
514 |
SetTestStepResult(EFail);
|
sl@0
|
515 |
|
sl@0
|
516 |
TPtrC expectedFileMimeType;
|
sl@0
|
517 |
GetStringFromConfig(ConfigSection(),_L("filemime"), expectedFileMimeType);
|
sl@0
|
518 |
|
sl@0
|
519 |
TPtrC expectedContentMimeType;
|
sl@0
|
520 |
GetStringFromConfig(ConfigSection(),_L("contentmime"), expectedContentMimeType);
|
sl@0
|
521 |
|
sl@0
|
522 |
TBool expectedResult;
|
sl@0
|
523 |
GetBoolFromConfig(ConfigSection(),_L("recognized"), expectedResult);
|
sl@0
|
524 |
|
sl@0
|
525 |
__UHEAP_MARK;
|
sl@0
|
526 |
TPtrC header;
|
sl@0
|
527 |
HBufC8* headerData = NULL;
|
sl@0
|
528 |
|
sl@0
|
529 |
if(GetStringFromConfig(ConfigSection(),_L("header"), header))
|
sl@0
|
530 |
{
|
sl@0
|
531 |
headerData = ConvertDes16toHBufC8LC(header);
|
sl@0
|
532 |
}
|
sl@0
|
533 |
else
|
sl@0
|
534 |
{
|
sl@0
|
535 |
headerData = CreateWmdrmHeaderLC();
|
sl@0
|
536 |
}
|
sl@0
|
537 |
|
sl@0
|
538 |
// Pass the WMDRM header data to CAF DoRecognize function
|
sl@0
|
539 |
CAgentResolver* resolver = CAgentResolver::NewLC(ETrue);
|
sl@0
|
540 |
|
sl@0
|
541 |
TBuf8 <KCafTestMaxDataTypeLength> fileMimeType;
|
sl@0
|
542 |
TBuf8 <KCafTestMaxDataTypeLength> contentMimeType;
|
sl@0
|
543 |
|
sl@0
|
544 |
TBool result = resolver->DoRecognizeL(*headerData, fileMimeType, contentMimeType);
|
sl@0
|
545 |
|
sl@0
|
546 |
CheckResultL(result, fileMimeType, contentMimeType, expectedResult, expectedFileMimeType, expectedContentMimeType);
|
sl@0
|
547 |
|
sl@0
|
548 |
CleanupStack::PopAndDestroy(2, headerData);
|
sl@0
|
549 |
|
sl@0
|
550 |
__UHEAP_MARKEND;
|
sl@0
|
551 |
return TestStepResult();
|
sl@0
|
552 |
}
|
sl@0
|
553 |
|
sl@0
|
554 |
#endif //SYMBIAN_ENABLE_SDP_WMDRM_SUPPORT
|
sl@0
|
555 |
|