53
|
1 |
/*
|
|
2 |
* Copyright (c) 2010 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 "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: API test automation for thumbnail engine
|
|
15 |
*
|
|
16 |
*/
|
|
17 |
|
|
18 |
|
|
19 |
// INCLUDE FILES
|
|
20 |
|
|
21 |
#include <gdi.h>
|
|
22 |
#include "tnetest.h"
|
|
23 |
#include <flogger.h>
|
|
24 |
|
|
25 |
|
|
26 |
|
|
27 |
// PRINT macro
|
|
28 |
#ifdef _DEBUG
|
|
29 |
#include <e32svr.h>
|
|
30 |
#define PRINT(x) RDebug::Print x
|
|
31 |
#else
|
|
32 |
#define PRINT(x)
|
|
33 |
#endif
|
|
34 |
|
|
35 |
//#ifdef _DEBUG
|
|
36 |
#define ENABLE_S60_TNE_LOGGING 1
|
|
37 |
//#endif
|
|
38 |
|
|
39 |
//implementation
|
|
40 |
#ifdef ENABLE_S60_TNE_LOGGING
|
|
41 |
#define FLOG FileLog
|
|
42 |
inline static void FileLog(TRefByValue<const TDesC16> aFmt,...)
|
|
43 |
{
|
|
44 |
VA_LIST args;
|
|
45 |
VA_START (args, aFmt);
|
|
46 |
RFileLogger::WriteFormat(_L("tne"), _L("S60tne.log"),
|
|
47 |
EFileLoggingModeAppend, aFmt, args);
|
|
48 |
}
|
|
49 |
|
|
50 |
#else // logging is disabled
|
|
51 |
#define FLOG LogFNull
|
|
52 |
inline static void LogFNull(TRefByValue<const TDesC16> aFmt,...){}
|
|
53 |
|
|
54 |
#endif // enable logging
|
|
55 |
|
|
56 |
|
|
57 |
|
|
58 |
|
|
59 |
// ============================ MEMBER FUNCTIONS ===============================
|
|
60 |
|
|
61 |
// -----------------------------------------------------------------------------
|
|
62 |
// CRadioUtilityTestClass::CRadioUtilityTestClass
|
|
63 |
// C++ default constructor can NOT contain any code, that
|
|
64 |
// might leave.
|
|
65 |
// -----------------------------------------------------------------------------
|
|
66 |
//
|
|
67 |
CTneTestClass::CTneTestClass(
|
|
68 |
CTestModuleIf& aTestModuleIf ):
|
|
69 |
CScriptBase( aTestModuleIf ),
|
|
70 |
iTestModuleIf(aTestModuleIf)
|
|
71 |
{
|
|
72 |
}
|
|
73 |
|
|
74 |
// -----------------------------------------------------------------------------
|
|
75 |
// CTneTestClass::ConstructL
|
|
76 |
// Symbian 2nd phase constructor can leave.
|
|
77 |
// -----------------------------------------------------------------------------
|
|
78 |
//
|
|
79 |
|
|
80 |
void CTneTestClass::ConstructL()
|
|
81 |
{
|
|
82 |
// intialize memeber variables
|
|
83 |
// iLog->Log(_L("CTneTestClass::ConstructL()in "));
|
|
84 |
|
|
85 |
|
|
86 |
iTNEVideoClipInfo = NULL;
|
|
87 |
User::LeaveIfError(iWS.Connect());
|
|
88 |
User::LeaveIfError(iFs.Connect());
|
|
89 |
|
|
90 |
|
|
91 |
}
|
|
92 |
|
|
93 |
|
|
94 |
// -----------------------------------------------------------------------------
|
|
95 |
// CTneTestClass::NewL
|
|
96 |
// Two-phased constructor.
|
|
97 |
// -----------------------------------------------------------------------------
|
|
98 |
//
|
|
99 |
CTneTestClass* CTneTestClass::NewL(CTestModuleIf& aTestModuleIf )
|
|
100 |
{
|
|
101 |
FLOG(_L("CTneTestClass::NewL in "));
|
|
102 |
CTneTestClass* self = new (ELeave) CTneTestClass( aTestModuleIf );
|
|
103 |
CleanupStack::PushL( self );
|
|
104 |
self->ConstructL();
|
|
105 |
CleanupStack::Pop();
|
|
106 |
return self;
|
|
107 |
FLOG(_L("CTneTestClass::NewL out "));
|
|
108 |
}
|
|
109 |
|
|
110 |
TInt CTneTestClass::FindFileName(CStifItemParser& aItem)
|
|
111 |
{
|
|
112 |
TPtrC string;
|
|
113 |
//TFileName aFileName;
|
|
114 |
TInt lRetVal = KErrNone;
|
|
115 |
aItem.SetParsingType( CStifItemParser::EQuoteStyleParsing );
|
|
116 |
|
|
117 |
lRetVal = aItem.GetNextString ( string );
|
|
118 |
|
|
119 |
if ( lRetVal != KErrNone )
|
|
120 |
{
|
|
121 |
// FLOG(_L("CHelixSTIFClient:: File name missing in config file "));
|
|
122 |
return lRetVal;
|
|
123 |
}
|
|
124 |
else
|
|
125 |
{
|
|
126 |
iFileName.Copy(string);
|
|
127 |
}
|
|
128 |
|
|
129 |
return lRetVal;
|
|
130 |
|
|
131 |
}
|
|
132 |
|
|
133 |
|
|
134 |
|
|
135 |
// intialize thumbnail Newl FIle name
|
|
136 |
TInt CTneTestClass::TNENewLFileNameL(CStifItemParser& aItem)
|
|
137 |
{
|
|
138 |
FLOG(_L("CTneTestClass::TNENewLFileNameL in "));
|
|
139 |
TInt error = KErrNone;
|
|
140 |
|
|
141 |
if ((error = FindFileName(aItem)) == KErrNone)
|
|
142 |
{
|
|
143 |
FLOG(_L("CTneTestClass:Filename=%S"),&iFileName );
|
|
144 |
if( iTNEVideoClipInfo )
|
|
145 |
{
|
|
146 |
delete iTNEVideoClipInfo;
|
|
147 |
iTNEVideoClipInfo = NULL;
|
|
148 |
}
|
|
149 |
TRAPD( err,iTNEVideoClipInfo = CTNEVideoClipInfo::NewL( iFileName, *this ) );
|
|
150 |
error = err;
|
|
151 |
FLOG(_L("TNENewLFileNameL error returned = %d"),error );
|
|
152 |
return error;
|
|
153 |
}
|
|
154 |
FLOG(_L(" TNENewLFileNameL error returned if not KErrnone = %d"),error );
|
|
155 |
return error;
|
|
156 |
}
|
|
157 |
|
|
158 |
|
|
159 |
|
|
160 |
// intialize thumbnail Newl File Handle
|
|
161 |
TInt CTneTestClass::TNENewLFileHandleL(CStifItemParser& aItem)
|
|
162 |
{
|
|
163 |
FLOG(_L("CTneTestClass::TNENewLFileHandleL in "));
|
|
164 |
TInt error = KErrNone;
|
|
165 |
RFile afileHandle;
|
|
166 |
if ((error = FindFileName(aItem)) == KErrNone)
|
|
167 |
{
|
|
168 |
FLOG(_L("CTneTestClass:Filename=%S"),&iFileName );
|
|
169 |
// convert into a file handle and intialize tne
|
|
170 |
if( (error = afileHandle.Open( iFs,(TDesC &) iFileName, EFileShareReadersOnly | EFileStream | EFileRead)) != KErrNone )
|
|
171 |
{
|
|
172 |
return error;
|
|
173 |
}
|
|
174 |
if( iTNEVideoClipInfo )
|
|
175 |
{
|
|
176 |
delete iTNEVideoClipInfo;
|
|
177 |
iTNEVideoClipInfo = NULL;
|
|
178 |
}
|
|
179 |
TRAPD( err,iTNEVideoClipInfo = CTNEVideoClipInfo::NewL( afileHandle, *this ) );
|
|
180 |
afileHandle.Close();
|
|
181 |
error = err;
|
|
182 |
FLOG(_L("TNENewLFileHandleL error returned = %d"),error );
|
|
183 |
return error;
|
|
184 |
}
|
|
185 |
FLOG(_L("TNENewLFileHandleL error returned if not KErrnone = %d"),error );
|
|
186 |
return error;
|
|
187 |
|
|
188 |
}
|
|
189 |
|
|
190 |
|
|
191 |
|
|
192 |
|
|
193 |
TInt CTneTestClass::TNENewLCFileNameL(CStifItemParser& aItem)
|
|
194 |
{
|
|
195 |
FLOG(_L("CTneTestClass::TNENewLCFileNameL in "));
|
|
196 |
TInt error = KErrNone;
|
|
197 |
|
|
198 |
if ((error = FindFileName(aItem)) == KErrNone)
|
|
199 |
{
|
|
200 |
FLOG(_L("CTneTestClass:Filename=%S"),&iFileName );
|
|
201 |
if( iTNEVideoClipInfo )
|
|
202 |
{
|
|
203 |
delete iTNEVideoClipInfo;
|
|
204 |
iTNEVideoClipInfo = NULL;
|
|
205 |
}
|
|
206 |
TRAPD( err,iTNEVideoClipInfo = CTNEVideoClipInfo::NewLC( iFileName, *this ) );
|
|
207 |
error = err;
|
|
208 |
FLOG(_L(" TNENewLCFileNameL error returned = %d"),error );
|
|
209 |
return error;
|
|
210 |
}
|
|
211 |
FLOG(_L(" TNENewLCFileNameL error returned if not KErrnone = %d"),error );
|
|
212 |
return error;
|
|
213 |
|
|
214 |
}
|
|
215 |
|
|
216 |
|
|
217 |
TInt CTneTestClass::TNENewLCFileHandleL(CStifItemParser& aItem)
|
|
218 |
{
|
|
219 |
FLOG(_L("CTneTestClass::TNENewLCFileHandleL in "));
|
|
220 |
TInt error = KErrNone;
|
|
221 |
RFile afileHandle;
|
|
222 |
if ((error = FindFileName(aItem)) == KErrNone)
|
|
223 |
{
|
|
224 |
FLOG(_L("CTneTestClass : Filename=%S"),&iFileName );
|
|
225 |
// convert into a file handle and intialize tne
|
|
226 |
if( (error = afileHandle.Open( iFs,(TDesC &) iFileName, EFileShareReadersOnly | EFileStream | EFileRead)) != KErrNone )
|
|
227 |
{
|
|
228 |
return error;
|
|
229 |
}
|
|
230 |
if( iTNEVideoClipInfo )
|
|
231 |
{
|
|
232 |
delete iTNEVideoClipInfo;
|
|
233 |
iTNEVideoClipInfo = NULL;
|
|
234 |
}
|
|
235 |
TRAPD( err,iTNEVideoClipInfo = CTNEVideoClipInfo::NewLC( afileHandle, *this ) );
|
|
236 |
afileHandle.Close();
|
|
237 |
error = err;
|
|
238 |
FLOG(_L("TNENewLCFileHandleL error returned = %d"),error );
|
|
239 |
return error;
|
|
240 |
}
|
|
241 |
FLOG(_L("TNENewLCFileHandleL error returned if not KErrnone = %d"),error );
|
|
242 |
return error;
|
|
243 |
|
|
244 |
}
|
|
245 |
|
|
246 |
|
|
247 |
|
|
248 |
|
|
249 |
// get thumb
|
|
250 |
|
|
251 |
TInt CTneTestClass::GetThumb(CStifItemParser& aItem)
|
|
252 |
|
|
253 |
{
|
|
254 |
_LIT(KTagId, "");
|
|
255 |
TInt lRetVal = KErrNone;
|
|
256 |
TInt iThumbnailFrameIndex;
|
|
257 |
TSize iThumbnailSize;
|
|
258 |
TDisplayMode iDisplayMode;
|
|
259 |
TInt iDisplInt;
|
|
260 |
TInt ienh;
|
|
261 |
TBool iEnhance;
|
|
262 |
TInt iWidth;
|
|
263 |
TInt iHeight;
|
|
264 |
TPtrC string;
|
|
265 |
|
|
266 |
// thumbindex
|
|
267 |
//
|
|
268 |
//if ((lRetVal = aItem.GetInt(KTagId,iThumbnailFrameIndex)) != KErrNone )
|
|
269 |
if ((lRetVal = aItem.GetNextInt(iThumbnailFrameIndex)) != KErrNone )
|
|
270 |
{
|
|
271 |
FLOG(_L("CTneTestClass: Getthumb if ((lRetVal = aItem.GetNextInt(iThumbnailFrameIndex)) != KErrNone ) error = %d"),lRetVal );
|
|
272 |
return lRetVal ;
|
|
273 |
}
|
|
274 |
//width
|
|
275 |
else if ((lRetVal = aItem.GetNextInt(iWidth)) != KErrNone )
|
|
276 |
{
|
|
277 |
FLOG(_L("CTneTestClass: Getthumb else if ((lRetVal = aItem.GetNextInt(iWidth)) != KErrNone ) error = %d"),lRetVal );
|
|
278 |
return lRetVal ;
|
|
279 |
}
|
|
280 |
//height
|
|
281 |
else if ((lRetVal = aItem.GetNextInt(iHeight)) != KErrNone )
|
|
282 |
{
|
|
283 |
FLOG(_L("CTneTestClass : Getthumb else if ((lRetVal = aItem.GetNextInt(iHeight)) != KErrNone ) error = %d"),lRetVal );
|
|
284 |
return lRetVal ;
|
|
285 |
}
|
|
286 |
//enhance
|
|
287 |
else if ((lRetVal = aItem.GetNextInt(ienh)) != KErrNone )
|
|
288 |
{
|
|
289 |
FLOG(_L("CTneTestClass : Getthumb else if ((lRetVal = aItem.GetNextInt(ienh)) != KErrNone ) error = %d"),lRetVal );
|
|
290 |
return lRetVal ;
|
|
291 |
}
|
|
292 |
|
|
293 |
// thumbnail size
|
|
294 |
iThumbnailSize = TSize(iWidth,iHeight);
|
|
295 |
|
|
296 |
// display mode
|
|
297 |
|
|
298 |
|
|
299 |
|
|
300 |
if ((lRetVal = aItem.GetNextInt(iDisplInt)) != KErrNone )
|
|
301 |
{
|
|
302 |
FLOG(_L(" CTneTestClass : Getthumb if ((lRetVal = aItem.GetNextInt(iDisplInt)) != KErrNone ) error = %d"),lRetVal );
|
|
303 |
return lRetVal;
|
|
304 |
}
|
|
305 |
else
|
|
306 |
{
|
|
307 |
iDisplayMode = (TDisplayMode)iDisplInt;
|
|
308 |
}
|
|
309 |
|
|
310 |
// set enhance boolean value
|
|
311 |
|
|
312 |
|
|
313 |
if (ienh == 0)
|
|
314 |
{
|
|
315 |
iEnhance = ETrue;
|
|
316 |
}
|
|
317 |
else
|
|
318 |
{
|
|
319 |
iEnhance = EFalse;
|
|
320 |
}
|
|
321 |
|
|
322 |
// getThumbL call to TNE
|
|
323 |
TRAPD( error,iTNEVideoClipInfo->GetThumbL( *this, iThumbnailFrameIndex, &iThumbnailSize, iDisplayMode, iEnhance, CActive::EPriorityIdle ) );
|
|
324 |
lRetVal = error;
|
|
325 |
FLOG(_L(" CTneTestClass : error returned from Getthumb = %d"),lRetVal );
|
|
326 |
return lRetVal;
|
|
327 |
}
|
|
328 |
|
|
329 |
|
|
330 |
|
|
331 |
void CTneTestClass::NotifyVideoClipInfoReady( CTNEVideoClipInfo& aInfo, TInt aError )
|
|
332 |
{
|
|
333 |
FLOG(_L("error returned CTneTestClass::NotifyVideoClipInfoReady = %d"),aError );
|
|
334 |
Signal(aError);
|
|
335 |
}
|
|
336 |
|
|
337 |
|
|
338 |
void CTneTestClass::NotifyVideoClipThumbCompleted( CTNEVideoClipInfo& /*aInfo*/, TInt aError, CFbsBitmap* aThumb )
|
|
339 |
{
|
|
340 |
FLOG(_L(" CTneTestClass : error returned CTneTestClass::NotifyVideoClipThumbCompleted = %d"),aError );
|
|
341 |
if ( aError == KErrNone && aThumb == NULL)
|
|
342 |
{
|
|
343 |
// there is no error code returned but the bitmap pointer is NULL
|
|
344 |
// This is still an error.
|
|
345 |
aError = KErrNotFound;
|
|
346 |
}
|
|
347 |
Signal(aError);
|
|
348 |
}
|
|
349 |
|
|
350 |
|
|
351 |
//////////////RunMethodL()/////////////////
|
|
352 |
|
|
353 |
TInt CTneTestClass::RunMethodL(
|
|
354 |
CStifItemParser& aItem )
|
|
355 |
{
|
|
356 |
static TStifFunctionInfo const KFunctions[] =
|
|
357 |
{
|
|
358 |
// Copy this line for every implemented function.
|
|
359 |
// First string is the function name used in TestScripter script file.
|
|
360 |
// Second is the actual implementation member function.
|
|
361 |
ENTRY( "TNENewLFileName", CTneTestClass::TNENewLFileNameL ),
|
|
362 |
ENTRY( "TNENewLFileHandle", CTneTestClass::TNENewLFileHandleL ),
|
|
363 |
ENTRY( "TNENewLCFileName", CTneTestClass::TNENewLCFileNameL ),
|
|
364 |
ENTRY( "TNENewLCFileHandle", CTneTestClass::TNENewLCFileHandleL ),
|
|
365 |
ENTRY( "GetThumb", CTneTestClass::GetThumb ),
|
|
366 |
|
|
367 |
};
|
|
368 |
|
|
369 |
const TInt count = sizeof( KFunctions ) /
|
|
370 |
sizeof( TStifFunctionInfo );
|
|
371 |
|
|
372 |
return RunInternalL( KFunctions, count, aItem );
|
|
373 |
}
|
|
374 |
|
|
375 |
|
|
376 |
|
|
377 |
|
|
378 |
|
|
379 |
// Destructor
|
|
380 |
CTneTestClass::~CTneTestClass()
|
|
381 |
{
|
|
382 |
FLOG(_L("CTneTestClass::~CTneTestClass() in") );
|
|
383 |
// delete iLog;
|
|
384 |
if ( iTNEVideoClipInfo )
|
|
385 |
{
|
|
386 |
delete iTNEVideoClipInfo;
|
|
387 |
}
|
|
388 |
iWS.Close();
|
|
389 |
iFs.Close();
|
|
390 |
|
|
391 |
// Delete logger
|
|
392 |
// delete iLog;
|
|
393 |
// delete iTimeoutController;
|
|
394 |
FLOG(_L("CTneTestClass::~CTneTestClass() out") );
|
|
395 |
}
|
|
396 |
|
|
397 |
|
|
398 |
|
|
399 |
|
|
400 |
|
|
401 |
/* this will be looked on later
|
|
402 |
// Timeout
|
|
403 |
|
|
404 |
// -----------------------------------------------------------------------------
|
|
405 |
// CRadioUtilityTestClass::SetTimeout
|
|
406 |
// Create a timer and set a timeout
|
|
407 |
// When the timeout is reached the test case is marked as failed
|
|
408 |
// It's used rather than the "timeout" keyword in the configuration file
|
|
409 |
// because in this way the log continues
|
|
410 |
// -----------------------------------------------------------------------------
|
|
411 |
TInt CTneTestClass::SetTimeout( CStifItemParser& aItem )
|
|
412 |
{
|
|
413 |
FTRACE(FPrint(_L("CRadioUtilityTestClass::SetTimeout")));
|
|
414 |
TInt timeout=0;
|
|
415 |
TInt error = aItem.GetNextInt(timeout) ;
|
|
416 |
if ( iTimeoutController )
|
|
417 |
{
|
|
418 |
if ( timeout > 0 )
|
|
419 |
{
|
|
420 |
iTimeoutController->Start( TTimeIntervalMicroSeconds(timeout*1000) );
|
|
421 |
}
|
|
422 |
else
|
|
423 |
{
|
|
424 |
iTimeoutController->Start( TTimeIntervalMicroSeconds(1000000) );
|
|
425 |
}
|
|
426 |
}
|
|
427 |
else
|
|
428 |
{
|
|
429 |
FLOG(_L("Timeout Controller doesn't exist"));
|
|
430 |
error = KErrTimeoutController;
|
|
431 |
}
|
|
432 |
return error;
|
|
433 |
}
|
|
434 |
|
|
435 |
*/
|
|
436 |
|
|
437 |
|
|
438 |
// ========================== OTHER EXPORTED FUNCTIONS =========================
|
|
439 |
|
|
440 |
// -----------------------------------------------------------------------------
|
|
441 |
// LibEntryL is a polymorphic Dll entry point.
|
|
442 |
// Returns: CScriptBase: New CScriptBase derived object
|
|
443 |
// -----------------------------------------------------------------------------
|
|
444 |
//
|
|
445 |
EXPORT_C CScriptBase* LibEntryL(
|
|
446 |
CTestModuleIf& aTestModuleIf ) // Backpointer to STIF Test Framework
|
|
447 |
{
|
|
448 |
|
|
449 |
return ( CScriptBase* ) CTneTestClass::NewL( aTestModuleIf );
|
|
450 |
|
|
451 |
}
|
|
452 |
|
|
453 |
// -----------------------------------------------------------------------------
|
|
454 |
// E32Dll is a DLL entry point function.
|
|
455 |
// Returns: KErrNone
|
|
456 |
// -----------------------------------------------------------------------------
|
|
457 |
//
|
|
458 |
#ifndef EKA2 // Hide Dll entry point to EKA2
|
|
459 |
GLDEF_C TInt E32Dll(
|
|
460 |
TDllReason /*aReason*/) // Reason code
|
|
461 |
{
|
|
462 |
return(KErrNone);
|
|
463 |
|
|
464 |
}
|
|
465 |
#endif // EKA2
|
|
466 |
|
|
467 |
// End of File
|
|
468 |
|
|
469 |
|