1 /* |
|
2 * Copyright (c) 2006 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: Thumbnail Manager API tests |
|
15 * |
|
16 */ |
|
17 |
|
18 // [INCLUDE FILES] - do not remove |
|
19 #include <e32svr.h> |
|
20 #include <StifParser.h> |
|
21 #include <Stiftestinterface.h> |
|
22 |
|
23 #include <fbs.h> |
|
24 #include <sqldb.h> |
|
25 #include <ImageConversion.h> |
|
26 #include <thumbnailmanager.h> |
|
27 |
|
28 #include "ThumbnailManagerTest.h" |
|
29 |
|
30 |
|
31 // ============================= LOCAL FUNCTIONS =============================== |
|
32 |
|
33 // ============================ MEMBER FUNCTIONS =============================== |
|
34 |
|
35 // ----------------------------------------------------------------------------- |
|
36 // CThumbnailManagerTest::Delete |
|
37 // Delete here all resources allocated and opened from test methods. |
|
38 // Called from destructor. |
|
39 // ----------------------------------------------------------------------------- |
|
40 // |
|
41 void CThumbnailManagerTest::Delete() |
|
42 { |
|
43 delete iPreviewThumbnail; |
|
44 iPreviewThumbnail = NULL; |
|
45 delete iThumbnail; |
|
46 iThumbnail = NULL; |
|
47 delete iEngine; |
|
48 iEngine = NULL; |
|
49 delete iObjectSource; |
|
50 iObjectSource = NULL; |
|
51 delete iCenrep; |
|
52 iCenrep = NULL; |
|
53 } |
|
54 |
|
55 // ----------------------------------------------------------------------------- |
|
56 // CThumbnailManagerTest::RunMethodL |
|
57 // Run specified method. Contains also table of test mothods and their names. |
|
58 // ----------------------------------------------------------------------------- |
|
59 // |
|
60 TInt CThumbnailManagerTest::RunMethodL( CStifItemParser& aItem ) |
|
61 { |
|
62 static TStifFunctionInfo const KFunctions[] = |
|
63 { |
|
64 ENTRY( "CreateInstanceL", CThumbnailManagerTest::CreateInstanceL ), |
|
65 ENTRY( "DeleteInstance", CThumbnailManagerTest::DeleteInstance ), |
|
66 ENTRY( "SetThumbnailSizeL", CThumbnailManagerTest::SetThumbnailSizeL ), |
|
67 ENTRY( "CheckThumbnailSizeL", CThumbnailManagerTest::CheckThumbnailSizeL ), |
|
68 ENTRY( "SetThumbnailEnumSizeL", CThumbnailManagerTest::SetThumbnailEnumSizeL ), |
|
69 ENTRY( "CreateSourceInstancePathL", CThumbnailManagerTest::CreateSourceInstancePathL ), |
|
70 ENTRY( "CreateSourceInstancePathTargetL", CThumbnailManagerTest::CreateSourceInstancePathTargetL ), |
|
71 ENTRY( "CreateSourceInstanceHandleL", CThumbnailManagerTest::CreateSourceInstanceHandleL ), |
|
72 ENTRY( "CreateSourceInstanceBufferL", CThumbnailManagerTest::CreateSourceInstanceBufferL ), |
|
73 ENTRY( "CreateSourceInstanceBitmapL", CThumbnailManagerTest::CreateSourceInstanceBitmapL ), |
|
74 ENTRY( "DeleteSourceInstance", CThumbnailManagerTest::DeleteSourceInstance ), |
|
75 ENTRY( "GetThumbnailL", CThumbnailManagerTest::GetThumbnailL ), |
|
76 ENTRY( "GetThumbnailByIdL", CThumbnailManagerTest::GetThumbnailByIdL ), |
|
77 ENTRY( "SetThumbnailL", CThumbnailManagerTest::SetThumbnailL ), |
|
78 ENTRY( "ImportThumbnailL", CThumbnailManagerTest::ImportThumbnailL ), |
|
79 ENTRY( "CheckPreviewThumbnailL", CThumbnailManagerTest::CheckPreviewThumbnailL ), |
|
80 ENTRY( "CheckThumbnailL", CThumbnailManagerTest::CheckThumbnailL ), |
|
81 ENTRY( "CheckThumbnailCenrepL", CThumbnailManagerTest::CheckThumbnailCenrepL ), |
|
82 ENTRY( "CancelPrevious", CThumbnailManagerTest::CancelPrevious ), |
|
83 ENTRY( "ChangePreviousPriority", CThumbnailManagerTest::ChangePreviousPriority ), |
|
84 ENTRY( "SetFlagsL", CThumbnailManagerTest::SetFlagsL ), |
|
85 ENTRY( "CheckFlags", CThumbnailManagerTest::CheckFlags ), |
|
86 ENTRY( "SetQualityPreferenceL", CThumbnailManagerTest::SetQualityPreferenceL ), |
|
87 ENTRY( "CheckQualityPreference", CThumbnailManagerTest::CheckQualityPreference ), |
|
88 ENTRY( "SetDisplayModeL", CThumbnailManagerTest::SetDisplayModeL ), |
|
89 ENTRY( "CheckDisplayModeL", CThumbnailManagerTest::CheckDisplayModeL ), |
|
90 ENTRY( "DeleteThumbnails", CThumbnailManagerTest::DeleteThumbnails ), |
|
91 ENTRY( "CreateThumbnailsByUrlL", CThumbnailManagerTest::CreateThumbnailsByUrlL ), |
|
92 ENTRY( "CreateThumbnails", CThumbnailManagerTest::CreateThumbnails ), |
|
93 ENTRY( "UpdatePathL", CThumbnailManagerTest::UpdatePathL ), |
|
94 ENTRY( "GetSupportedMimeTypesL", CThumbnailManagerTest::GetSupportedMimeTypesL ) |
|
95 }; |
|
96 |
|
97 const TInt count = sizeof( KFunctions ) / sizeof( TStifFunctionInfo ); |
|
98 |
|
99 return RunInternalL( KFunctions, count, aItem ); |
|
100 } |
|
101 |
|
102 TInt CThumbnailManagerTest::CreateInstanceL( CStifItemParser& /*aItem*/ ) |
|
103 { |
|
104 _LIT( KPanicTxt, "CreateInstanceL" ); |
|
105 __ASSERT_ALWAYS( !iEngine, User::Panic( KPanicTxt, 0 )); |
|
106 |
|
107 iEngine = CThumbnailManager::NewL( *this ); |
|
108 |
|
109 iCenrep = CThumbnailCenRep::NewL(); |
|
110 iPersistentSizes = iCenrep->GetPersistentSizes(); |
|
111 |
|
112 iCurrentThumbnailSize = EUnknownThumbnailSize; |
|
113 iDoNotCreate = EFalse; |
|
114 iCreateThumbnails = EFalse; |
|
115 |
|
116 return KErrNone; |
|
117 } |
|
118 |
|
119 TInt CThumbnailManagerTest::DeleteInstance( CStifItemParser& /*aItem*/ ) |
|
120 { |
|
121 // Bitmaps must be deleted before CThumbnailManager, since |
|
122 // CThumbnailManager will close the FBS session |
|
123 delete iPreviewThumbnail; |
|
124 iPreviewThumbnail = NULL; |
|
125 delete iThumbnail; |
|
126 iThumbnail = NULL; |
|
127 delete iEngine; |
|
128 iEngine = NULL; |
|
129 delete iObjectSource; |
|
130 iObjectSource = NULL; |
|
131 delete iCenrep; |
|
132 iCenrep = NULL; |
|
133 |
|
134 return KErrNone; |
|
135 } |
|
136 |
|
137 TInt CThumbnailManagerTest::SetThumbnailSizeL( CStifItemParser& aItem ) |
|
138 { |
|
139 _LIT( KPanicTxt, "SetThumbnailSizeL" ); |
|
140 __ASSERT_ALWAYS( iEngine, User::Panic( KPanicTxt, 0 )); |
|
141 |
|
142 TInt width = 0; |
|
143 TInt height = 0; |
|
144 User::LeaveIfError( aItem.GetNextInt( width )); |
|
145 User::LeaveIfError( aItem.GetNextInt( height )); |
|
146 iEngine->SetThumbnailSizeL( TSize( width, height )); |
|
147 return KErrNone; |
|
148 } |
|
149 |
|
150 TInt CThumbnailManagerTest::CheckThumbnailSizeL( CStifItemParser& aItem ) |
|
151 { |
|
152 _LIT( KPanicTxt, "CheckThumbnailSize" ); |
|
153 __ASSERT_ALWAYS( iEngine, User::Panic( KPanicTxt, 0 )); |
|
154 |
|
155 TInt width = 0; |
|
156 TInt height = 0; |
|
157 User::LeaveIfError( aItem.GetNextInt( width )); |
|
158 User::LeaveIfError( aItem.GetNextInt( height )); |
|
159 TInt ret = KErrArgument; |
|
160 TSize size = iEngine->ThumbnailSize(); |
|
161 |
|
162 if ( size == TSize( width, height )) |
|
163 { |
|
164 ret = KErrNone; |
|
165 } |
|
166 |
|
167 return ret; |
|
168 } |
|
169 |
|
170 TInt CThumbnailManagerTest::SetThumbnailEnumSizeL( CStifItemParser& aItem ) |
|
171 { |
|
172 _LIT( KPanicTxt, "SetThumbnailEnumSizeL" ); |
|
173 __ASSERT_ALWAYS( iEngine, User::Panic( KPanicTxt, 0 )); |
|
174 |
|
175 TInt enumSize = 0; |
|
176 User::LeaveIfError( aItem.GetNextInt( enumSize )); |
|
177 |
|
178 iEngine->SetThumbnailSizeL( (TThumbnailSize)enumSize ); |
|
179 iCurrentThumbnailSize = (TThumbnailSize)enumSize; |
|
180 |
|
181 return KErrNone; |
|
182 } |
|
183 |
|
184 TInt CThumbnailManagerTest::SetFlagsL( CStifItemParser& aItem ) |
|
185 { |
|
186 _LIT( KPanicTxt, "SetFlagsL" ); |
|
187 __ASSERT_ALWAYS( iEngine, User::Panic( KPanicTxt, 0 )); |
|
188 |
|
189 TInt flags = 0; |
|
190 User::LeaveIfError( aItem.GetNextInt( flags )); |
|
191 |
|
192 iEngine->SetFlagsL(( CThumbnailManager::TThumbnailFlags )flags ); |
|
193 |
|
194 if (flags == CThumbnailManager::EDoNotCreate) |
|
195 { |
|
196 iDoNotCreate = ETrue; |
|
197 } |
|
198 else |
|
199 { |
|
200 iDoNotCreate = EFalse; |
|
201 } |
|
202 |
|
203 return KErrNone; |
|
204 } |
|
205 |
|
206 TInt CThumbnailManagerTest::CheckFlags( CStifItemParser& aItem ) |
|
207 { |
|
208 _LIT( KPanicTxt, "CheckFlags" ); |
|
209 __ASSERT_ALWAYS( iEngine, User::Panic( KPanicTxt, 0 )); |
|
210 |
|
211 TInt flags = 0; |
|
212 aItem.GetNextInt( flags ); |
|
213 |
|
214 if ( iEngine->Flags() != flags ) |
|
215 { |
|
216 return KErrArgument; |
|
217 } |
|
218 |
|
219 return KErrNone; |
|
220 } |
|
221 |
|
222 TInt CThumbnailManagerTest::SetQualityPreferenceL( CStifItemParser& aItem |
|
223 ) |
|
224 { |
|
225 _LIT( KPanicTxt, "SetQualityPreferenceL" ); |
|
226 __ASSERT_ALWAYS( iEngine, User::Panic( KPanicTxt, 0 )); |
|
227 |
|
228 TInt qp = 0; |
|
229 User::LeaveIfError( aItem.GetNextInt( qp )); |
|
230 |
|
231 iEngine->SetQualityPreferenceL( (CThumbnailManager::TThumbnailQualityPreference)qp ); |
|
232 return KErrNone; |
|
233 } |
|
234 |
|
235 TInt CThumbnailManagerTest::CheckQualityPreference( CStifItemParser& |
|
236 aItem ) |
|
237 { |
|
238 _LIT( KPanicTxt, "CheckQualityPreference" ); |
|
239 __ASSERT_ALWAYS( iEngine, User::Panic( KPanicTxt, 0 )); |
|
240 |
|
241 TInt qp = 0; |
|
242 aItem.GetNextInt( qp ); |
|
243 |
|
244 if ( iEngine->QualityPreference() != qp ) |
|
245 { |
|
246 return KErrArgument; |
|
247 } |
|
248 |
|
249 return KErrNone; |
|
250 } |
|
251 |
|
252 TInt CThumbnailManagerTest::SetDisplayModeL( CStifItemParser& aItem ) |
|
253 { |
|
254 _LIT( KPanicTxt, "SetDisplayModeL" ); |
|
255 __ASSERT_ALWAYS( iEngine, User::Panic( KPanicTxt, 0 )); |
|
256 |
|
257 TInt displaymode = 0; |
|
258 User::LeaveIfError( aItem.GetNextInt( displaymode )); |
|
259 |
|
260 iEngine->SetDisplayModeL( (TDisplayMode)displaymode ); |
|
261 return KErrNone; |
|
262 } |
|
263 |
|
264 TInt CThumbnailManagerTest::CheckDisplayModeL( CStifItemParser& aItem ) |
|
265 { |
|
266 _LIT( KPanicTxt, "CheckDisplayModeL" ); |
|
267 __ASSERT_ALWAYS( iEngine, User::Panic( KPanicTxt, 0 )); |
|
268 |
|
269 TInt displaymode = 0; |
|
270 User::LeaveIfError( aItem.GetNextInt( displaymode )); |
|
271 |
|
272 if ( iEngine->DisplayMode() != displaymode ) |
|
273 { |
|
274 return KErrArgument; |
|
275 } |
|
276 |
|
277 return KErrNone; |
|
278 } |
|
279 |
|
280 TInt CThumbnailManagerTest::CreateSourceInstancePathL( CStifItemParser& aItem ) |
|
281 { |
|
282 _LIT( KPanicTxt, "CreateSrcPath" ); |
|
283 __ASSERT_ALWAYS( !iObjectSource, User::Panic( KPanicTxt, 0 )); |
|
284 |
|
285 TPtrC path; |
|
286 User::LeaveIfError( aItem.GetNextString( path )); |
|
287 |
|
288 TInt id = 0; |
|
289 aItem.GetNextInt( id ); |
|
290 |
|
291 TFileName filePath( iDataPath ); |
|
292 filePath.Append( path ); |
|
293 filePath.ZeroTerminate(); |
|
294 |
|
295 iLog->Log( _L( "CreateSourceInstancePathL - path = %S" ), &filePath ); |
|
296 |
|
297 delete iObjectSource; |
|
298 iObjectSource = NULL; |
|
299 |
|
300 iObjectSource = CThumbnailObjectSource::NewL( filePath, id ); |
|
301 return KErrNone; |
|
302 } |
|
303 |
|
304 TInt CThumbnailManagerTest::CreateSourceInstancePathTargetL( CStifItemParser& aItem ) |
|
305 { |
|
306 _LIT( KPanicTxt, "CreateSrcPathTarget" ); |
|
307 __ASSERT_ALWAYS( !iObjectSource, User::Panic( KPanicTxt, 0 )); |
|
308 |
|
309 TPtrC path; |
|
310 User::LeaveIfError( aItem.GetNextString( path )); |
|
311 |
|
312 TPtrC target; |
|
313 User::LeaveIfError( aItem.GetNextString( target )); |
|
314 |
|
315 TPtrC mimeType; |
|
316 User::LeaveIfError( aItem.GetNextString( mimeType )); |
|
317 |
|
318 TInt virtual1 = 0; |
|
319 aItem.GetNextInt( virtual1 ); |
|
320 |
|
321 TInt virtual2 = 0; |
|
322 aItem.GetNextInt( virtual2 ); |
|
323 |
|
324 TFileName filePath( iDataPath ); |
|
325 filePath.Append( path ); |
|
326 filePath.ZeroTerminate(); |
|
327 |
|
328 if (virtual1) |
|
329 { |
|
330 filePath.Delete(2,1); |
|
331 } |
|
332 |
|
333 TFileName targetPath( iDataPath ); |
|
334 targetPath.Append( target ); |
|
335 targetPath.ZeroTerminate(); |
|
336 |
|
337 if (virtual2) |
|
338 { |
|
339 targetPath.Delete(2,1); |
|
340 } |
|
341 |
|
342 iLog->Log( _L( "CreateSourceInstancePathTargetL - path = %S, target = %S" ), &filePath ); |
|
343 |
|
344 delete iObjectSource; |
|
345 iObjectSource = NULL; |
|
346 |
|
347 iObjectSource = CThumbnailObjectSource::NewL( filePath, targetPath, mimeType ); |
|
348 return KErrNone; |
|
349 } |
|
350 |
|
351 TInt CThumbnailManagerTest::CreateSourceInstanceHandleL( CStifItemParser& aItem ) |
|
352 { |
|
353 _LIT( KPanicTxt, "CreateSrcHandle" ); |
|
354 __ASSERT_ALWAYS( !iObjectSource, User::Panic( KPanicTxt, 0 )); |
|
355 |
|
356 TPtrC path; |
|
357 User::LeaveIfError( aItem.GetNextString( path )); |
|
358 |
|
359 TFileName filePath( iDataPath ); |
|
360 filePath.Append( path ); |
|
361 filePath.ZeroTerminate(); |
|
362 |
|
363 User::LeaveIfError( iFile.Open( iFs, filePath, EFileShareReadersOrWriters )); |
|
364 iLog->Log( _L( "CreateSourceInstanceHandleL - path = %S" ), &filePath ); |
|
365 |
|
366 delete iObjectSource; |
|
367 iObjectSource = NULL; |
|
368 iObjectSource = CThumbnailObjectSource::NewL( iFile ); |
|
369 return KErrNone; |
|
370 } |
|
371 |
|
372 TInt CThumbnailManagerTest::CreateSourceInstanceBufferL( CStifItemParser& aItem ) |
|
373 { |
|
374 _LIT( KPanicTxt, "CreateSrcBuffer" ); |
|
375 __ASSERT_ALWAYS( !iObjectSource, User::Panic( KPanicTxt, 0 )); |
|
376 |
|
377 TPtrC path; |
|
378 User::LeaveIfError( aItem.GetNextString( path )); |
|
379 |
|
380 TPtrC mimeType; |
|
381 User::LeaveIfError( aItem.GetNextString( mimeType )); |
|
382 |
|
383 TFileName filePath( iDataPath ); |
|
384 filePath.Append( path ); |
|
385 filePath.ZeroTerminate(); |
|
386 |
|
387 User::LeaveIfError( iFile.Open( iFs, filePath, EFileShareReadersOrWriters )); |
|
388 iLog->Log( _L( "CreateSourceInstanceBufferL - path = %S" ), &filePath ); |
|
389 |
|
390 TInt64 size; |
|
391 User::LeaveIfError( iFile.Size( size ) ); |
|
392 iBuffer = HBufC8::NewL( size ); |
|
393 TPtr8 ptr = iBuffer->Des(); |
|
394 iFile.Read( ptr ); |
|
395 iFile.Close(); |
|
396 |
|
397 delete iObjectSource; |
|
398 iObjectSource = NULL; |
|
399 iObjectSource = CThumbnailObjectSource::NewL( iBuffer, mimeType, filePath ); |
|
400 |
|
401 iBuffer = NULL; |
|
402 return KErrNone; |
|
403 } |
|
404 |
|
405 TInt CThumbnailManagerTest::CreateSourceInstanceBitmapL( CStifItemParser& aItem ) |
|
406 { |
|
407 _LIT( KPanicTxt, "CreateSrcBuffer" ); |
|
408 __ASSERT_ALWAYS( !iObjectSource, User::Panic( KPanicTxt, 0 )); |
|
409 |
|
410 TPtrC path; |
|
411 User::LeaveIfError( aItem.GetNextString( path )); |
|
412 |
|
413 TFileName filePath( iDataPath ); |
|
414 filePath.Append( path ); |
|
415 filePath.ZeroTerminate(); |
|
416 |
|
417 TPtrC target; |
|
418 User::LeaveIfError( aItem.GetNextString( target )); |
|
419 |
|
420 TFileName targetPath( iDataPath ); |
|
421 targetPath.Append( target ); |
|
422 targetPath.ZeroTerminate(); |
|
423 |
|
424 iLog->Log( _L( "CreateSourceInstanceBitmapL - bitmap = %S" ), &filePath ); |
|
425 iLog->Log( _L( "CreateSourceInstanceBitmapL - target = %S" ), &targetPath ); |
|
426 |
|
427 iBitmap = new (ELeave) CFbsBitmap(); |
|
428 User::LeaveIfError(iBitmap->Load(filePath, 0)); |
|
429 |
|
430 delete iObjectSource; |
|
431 iObjectSource = NULL; |
|
432 iObjectSource = CThumbnailObjectSource::NewL( iBitmap, targetPath ); |
|
433 |
|
434 return KErrNone; |
|
435 } |
|
436 |
|
437 TInt CThumbnailManagerTest::DeleteSourceInstance( CStifItemParser& /*aItem*/ ) |
|
438 { |
|
439 delete iObjectSource; |
|
440 iObjectSource = NULL; |
|
441 return KErrNone; |
|
442 } |
|
443 |
|
444 TInt CThumbnailManagerTest::GetThumbnailL( CStifItemParser& aItem ) |
|
445 { |
|
446 _LIT( KPanicTxt, "GetThumbnailL" ); |
|
447 __ASSERT_ALWAYS( iObjectSource, User::Panic( KPanicTxt, 0 )); |
|
448 __ASSERT_ALWAYS( iEngine, User::Panic( KPanicTxt, 1 )); |
|
449 |
|
450 TInt clientData = NULL; |
|
451 TInt priority = 0; |
|
452 |
|
453 TInt err = aItem.GetNextInt( clientData ); |
|
454 if ( !err ) |
|
455 { |
|
456 aItem.GetNextInt( priority ); |
|
457 } |
|
458 |
|
459 iPreviousRequestId = iEngine->GetThumbnailL( *iObjectSource, ( TAny* ) |
|
460 clientData, priority ); |
|
461 iLog->Log( _L( "GetThumbnailL - request id %d" ), iPreviousRequestId ); |
|
462 |
|
463 if (!iDoNotCreate) |
|
464 { |
|
465 iCreateThumbnails = EFalse; |
|
466 } |
|
467 |
|
468 return KErrNone; |
|
469 } |
|
470 |
|
471 TInt CThumbnailManagerTest::GetThumbnailByIdL( CStifItemParser& aItem ) |
|
472 { |
|
473 _LIT( KPanicTxt, "GetThumbnailByIdL" ); |
|
474 __ASSERT_ALWAYS( iObjectSource, User::Panic( KPanicTxt, 0 )); |
|
475 __ASSERT_ALWAYS( iEngine, User::Panic( KPanicTxt, 1 )); |
|
476 |
|
477 TInt id = 0; |
|
478 TInt clientData = NULL; |
|
479 TInt priority = 0; |
|
480 |
|
481 User::LeaveIfError( aItem.GetNextInt( id )); |
|
482 TInt err = aItem.GetNextInt( clientData ); |
|
483 if ( !err ) |
|
484 { |
|
485 aItem.GetNextInt( priority ); |
|
486 } |
|
487 |
|
488 iPreviousRequestId = iEngine->GetThumbnailL( id, (TAny*)clientData, priority ); |
|
489 iLog->Log( _L( "GetThumbnailByIdL - request id %d" ), iPreviousRequestId ); |
|
490 |
|
491 if (!iDoNotCreate) |
|
492 { |
|
493 iCreateThumbnails = EFalse; |
|
494 } |
|
495 |
|
496 return KErrNone; |
|
497 } |
|
498 |
|
499 TInt CThumbnailManagerTest::SetThumbnailL( CStifItemParser& aItem ) |
|
500 { |
|
501 _LIT( KPanicTxt, "SetThumbnailL" ); |
|
502 __ASSERT_ALWAYS( iObjectSource, User::Panic( KPanicTxt, 0 )); |
|
503 __ASSERT_ALWAYS( iEngine, User::Panic( KPanicTxt, 1 )); |
|
504 |
|
505 TInt clientData = NULL; |
|
506 TInt priority = 0; |
|
507 |
|
508 TInt err = aItem.GetNextInt( clientData ); |
|
509 if ( !err ) |
|
510 { |
|
511 aItem.GetNextInt( priority ); |
|
512 } |
|
513 |
|
514 iPreviousRequestId = iEngine->SetThumbnailL( *iObjectSource, ( TAny* ) |
|
515 clientData, priority ); |
|
516 iLog->Log( _L( "SetThumbnailL - request id %d" ), iPreviousRequestId ); |
|
517 |
|
518 if (!iDoNotCreate) |
|
519 { |
|
520 iCreateThumbnails = EFalse; |
|
521 } |
|
522 |
|
523 return KErrNone; |
|
524 } |
|
525 |
|
526 TInt CThumbnailManagerTest::ImportThumbnailL( CStifItemParser& aItem ) |
|
527 { |
|
528 _LIT( KPanicTxt, "ImportThumbnailL" ); |
|
529 __ASSERT_ALWAYS( iObjectSource, User::Panic( KPanicTxt, 0 )); |
|
530 __ASSERT_ALWAYS( iEngine, User::Panic( KPanicTxt, 1 )); |
|
531 |
|
532 TInt clientData = NULL; |
|
533 TInt priority = 0; |
|
534 TPtrC path; |
|
535 |
|
536 User::LeaveIfError( aItem.GetNextString( path )); |
|
537 |
|
538 TFileName filePath( iDataPath ); |
|
539 filePath.Append( path ); |
|
540 filePath.ZeroTerminate(); |
|
541 |
|
542 TInt err = aItem.GetNextInt( clientData ); |
|
543 if ( !err ) |
|
544 { |
|
545 aItem.GetNextInt( priority ); |
|
546 } |
|
547 |
|
548 iPreviousRequestId = iEngine->ImportThumbnailL( *iObjectSource, filePath, |
|
549 (TAny*)clientData, priority ); |
|
550 iLog->Log( _L( "ImportThumbnailL - request id %d" ), iPreviousRequestId ); |
|
551 |
|
552 if (!iDoNotCreate) |
|
553 { |
|
554 iCreateThumbnails = EFalse; |
|
555 } |
|
556 |
|
557 return KErrNone; |
|
558 } |
|
559 |
|
560 void CThumbnailManagerTest::ThumbnailPreviewReady( MThumbnailData& |
|
561 aThumbnail, TThumbnailRequestId aId ) |
|
562 { |
|
563 iLog->Log( _L( "ThumbnailPreviewReady aId=%d" ), aId ); |
|
564 delete iPreviewThumbnail; |
|
565 iPreviewThumbnail = aThumbnail.DetachBitmap(); |
|
566 iPreviewThumbnailCbId = aId; |
|
567 Signal( KErrNone ); |
|
568 } |
|
569 |
|
570 void CThumbnailManagerTest::ThumbnailReady( TInt aError, MThumbnailData& |
|
571 aThumbnail, TThumbnailRequestId aId ) |
|
572 { |
|
573 iLog->Log( _L( "ThumbnailReady aError=%d aId=%d" ), aError, aId ); |
|
574 delete iThumbnail; |
|
575 iThumbnail = aThumbnail.DetachBitmap(); |
|
576 iThumbnailCbId = aId; |
|
577 |
|
578 // ignore KErrNotFound, if auto create disabled (CreateThumbnails used) |
|
579 if (aError == KErrNotFound && iCreateThumbnails) |
|
580 { |
|
581 for ( TInt i = 0 ; i < iPersistentSizes.Count(); i++ ) |
|
582 { |
|
583 if ( iPersistentSizes[i].iType == iCurrentThumbnailSize && |
|
584 !iPersistentSizes[i].iAutoCreate ) |
|
585 { |
|
586 aError = KErrNone; |
|
587 break; |
|
588 } |
|
589 } |
|
590 } |
|
591 |
|
592 Signal( aError ); |
|
593 } |
|
594 |
|
595 TInt CThumbnailManagerTest::CheckPreviewThumbnailL( CStifItemParser& aItem ) |
|
596 { |
|
597 if ( iPreviewThumbnail ) |
|
598 { |
|
599 TInt width = 0; |
|
600 TInt height = 0; |
|
601 TInt displaymode = 0; |
|
602 User::LeaveIfError( aItem.GetNextInt( width )); |
|
603 User::LeaveIfError( aItem.GetNextInt( height )); |
|
604 User::LeaveIfError( aItem.GetNextInt( displaymode )); |
|
605 TSize size = iPreviewThumbnail->SizeInPixels(); |
|
606 iLog->Log( _L( |
|
607 "CheckPreviewThumbnailL - bitmap size %dx%d (expecting %dx%d)" ), |
|
608 size.iWidth, size.iHeight, width, height ); |
|
609 iLog->Log( _L( "CheckPreviewThumbnailL - bitmap mode %d (expecting %d)" |
|
610 ), iPreviewThumbnail->DisplayMode(), displaymode ); |
|
611 if ( size != TSize( width, height )) |
|
612 { |
|
613 iLog->Log( _L( "CheckPreviewThumbnailL - size mismatch" )); |
|
614 User::Leave( KErrArgument ); |
|
615 } |
|
616 else if ( displaymode != iPreviewThumbnail->DisplayMode()) |
|
617 { |
|
618 iLog->Log( _L( "CheckPreviewThumbnailL - displaymode mismatch" )); |
|
619 User::Leave( KErrArgument ); |
|
620 } |
|
621 else |
|
622 { |
|
623 iLog->Log( _L( "CheckPreviewThumbnailL - ok" )); |
|
624 } |
|
625 } |
|
626 else |
|
627 { |
|
628 // Bitmap missing |
|
629 iLog->Log( _L( "CheckPreviewThumbnailL - preview bitmap NULL" )); |
|
630 User::Leave( KErrUnknown ); |
|
631 } |
|
632 return KErrNone; |
|
633 } |
|
634 |
|
635 TInt CThumbnailManagerTest::CheckThumbnailL( CStifItemParser& aItem ) |
|
636 { |
|
637 if ( iThumbnail ) |
|
638 { |
|
639 TInt width = 0; |
|
640 TInt height = 0; |
|
641 TInt displaymode = 0; |
|
642 User::LeaveIfError( aItem.GetNextInt( width )); |
|
643 User::LeaveIfError( aItem.GetNextInt( height )); |
|
644 User::LeaveIfError( aItem.GetNextInt( displaymode )); |
|
645 TSize size = iThumbnail->SizeInPixels(); |
|
646 iLog->Log( _L( "CheckThumbnailL - bitmap size %dx%d (expecting %dx%d)" ) |
|
647 , size.iWidth, size.iHeight, width, height ); |
|
648 iLog->Log( _L( "CheckThumbnailL - bitmap mode %d (expecting %d)" ), |
|
649 iThumbnail->DisplayMode(), displaymode ); |
|
650 |
|
651 // one needs to match, aspect ratio scaling makes this difficult... |
|
652 if ( size.iWidth != width && size.iHeight != height ) |
|
653 { |
|
654 iLog->Log( _L( "CheckThumbnailL - size mismatch" )); |
|
655 User::Leave( KErrArgument ); |
|
656 } |
|
657 else if ( displaymode != iThumbnail->DisplayMode()) |
|
658 { |
|
659 iLog->Log( _L( "CheckThumbnailL - displaymode mismatch" )); |
|
660 } |
|
661 else |
|
662 { |
|
663 iLog->Log( _L( "CheckThumbnailL - ok" )); |
|
664 } |
|
665 } |
|
666 else |
|
667 { |
|
668 // Bitmap missing |
|
669 iLog->Log( _L( "CheckThumbnailL - bitmap NULL" )); |
|
670 User::Leave( KErrNotFound ); |
|
671 } |
|
672 return KErrNone; |
|
673 } |
|
674 |
|
675 TInt CThumbnailManagerTest::CheckThumbnailCenrepL( CStifItemParser& aItem ) |
|
676 { |
|
677 TInt err = KErrNone; |
|
678 TBool full = EFalse; |
|
679 |
|
680 TInt sizeType; |
|
681 TInt displaymode = 0; |
|
682 User::LeaveIfError( aItem.GetNextInt( sizeType )); |
|
683 User::LeaveIfError( aItem.GetNextInt( displaymode )); |
|
684 |
|
685 TThumbnailSize size = (TThumbnailSize)sizeType; |
|
686 if (size == EImageFullScreenThumbnailSize || |
|
687 size == EVideoFullScreenThumbnailSize || |
|
688 size == EAudioFullScreenThumbnailSize) |
|
689 { |
|
690 full = ETrue; |
|
691 } |
|
692 |
|
693 if ( iThumbnail ) |
|
694 { |
|
695 TInt width = 0; |
|
696 TInt height = 0; |
|
697 |
|
698 for ( TInt i = 0 ; i < iPersistentSizes.Count(); i++ ) |
|
699 { |
|
700 if ( iPersistentSizes[i].iType == size ) |
|
701 { |
|
702 width = iPersistentSizes[i].iSize.iWidth; |
|
703 height = iPersistentSizes[i].iSize.iHeight; |
|
704 break; |
|
705 } |
|
706 } |
|
707 |
|
708 TSize thumbSize = iThumbnail->SizeInPixels(); |
|
709 |
|
710 iLog->Log( _L( "CheckThumbnailCenrepL - bitmap size %dx%d (expecting %dx%d)" ) |
|
711 , thumbSize.iWidth, thumbSize.iHeight, width, height ); |
|
712 iLog->Log( _L( "CheckThumbnailCenrepL - bitmap mode %d (expecting %d)" ), |
|
713 iThumbnail->DisplayMode(), displaymode ); |
|
714 |
|
715 // one needs to match, and both need to be smaller than cenrep value |
|
716 if ( (thumbSize.iWidth == width || thumbSize.iHeight == height) && |
|
717 thumbSize.iWidth <= width && thumbSize.iHeight <= height) |
|
718 { |
|
719 iLog->Log( _L( "CheckThumbnailCenrepL - ok" )); |
|
720 } |
|
721 else if (full && (thumbSize.iWidth <= width && thumbSize.iHeight <= height)) |
|
722 { |
|
723 iLog->Log( _L( "CheckThumbnailCenrepL - fullscreen ok, not upscaled" )); |
|
724 } |
|
725 else |
|
726 { |
|
727 iLog->Log( _L( "CheckThumbnailCenrepL - size mismatch" )); |
|
728 err = KErrArgument; |
|
729 } |
|
730 |
|
731 // check display mode |
|
732 if ( displaymode != iThumbnail->DisplayMode()) |
|
733 { |
|
734 iLog->Log( _L( "CheckThumbnailCenrepL - displaymode mismatch" )); |
|
735 err = KErrArgument; |
|
736 } |
|
737 } |
|
738 else |
|
739 { |
|
740 for ( TInt i = 0 ; i < iPersistentSizes.Count(); i++ ) |
|
741 { |
|
742 if ( iPersistentSizes[i].iType == size && iPersistentSizes[i].iAutoCreate) |
|
743 { |
|
744 // Bitmap missing |
|
745 iLog->Log( _L( "CheckThumbnailCenrepL - bitmap NULL" )); |
|
746 err = KErrNotFound; |
|
747 break; |
|
748 } |
|
749 } |
|
750 } |
|
751 |
|
752 return err; |
|
753 } |
|
754 |
|
755 TInt CThumbnailManagerTest::CancelPrevious( CStifItemParser& /*aItem*/ ) |
|
756 { |
|
757 _LIT( KPanicTxt, "CancelPrevious" ); |
|
758 __ASSERT_ALWAYS( iEngine, User::Panic( KPanicTxt, 0 )); |
|
759 |
|
760 TInt err = iEngine->CancelRequest( iPreviousRequestId ); |
|
761 iLog->Log( _L( "CancelPrevious() returned %d" ), err ); |
|
762 return err; |
|
763 } |
|
764 |
|
765 TInt CThumbnailManagerTest::ChangePreviousPriority( CStifItemParser& |
|
766 aItem ) |
|
767 { |
|
768 _LIT( KPanicTxt, "ChangePreviousPriority" ); |
|
769 __ASSERT_ALWAYS( iEngine, User::Panic( KPanicTxt, 0 )); |
|
770 |
|
771 TInt priority = 0; |
|
772 aItem.GetNextInt( priority ); |
|
773 |
|
774 TInt err = iEngine->ChangePriority( iPreviousRequestId, priority ); |
|
775 iLog->Log( _L( "ChangePriority() returned %d" ), err ); |
|
776 return err; |
|
777 } |
|
778 |
|
779 |
|
780 TInt CThumbnailManagerTest::DeleteThumbnails( CStifItemParser& /*aItem*/ ) |
|
781 { |
|
782 iEngine->DeleteThumbnails( *iObjectSource ); |
|
783 return KErrNone; |
|
784 } |
|
785 |
|
786 TInt CThumbnailManagerTest::CreateThumbnailsByUrlL( CStifItemParser& aItem ) |
|
787 { |
|
788 _LIT( KPanicTxt, "CreateSrcPath" ); |
|
789 __ASSERT_ALWAYS( !iObjectSource, User::Panic( KPanicTxt, 0 )); |
|
790 |
|
791 TPtrC path; |
|
792 User::LeaveIfError( aItem.GetNextString( path )); |
|
793 |
|
794 TInt id = 0; |
|
795 aItem.GetNextInt( id ); |
|
796 |
|
797 TFileName filePath( iDataPath ); |
|
798 filePath.Append( path ); |
|
799 filePath.ZeroTerminate(); |
|
800 |
|
801 iLog->Log( _L( "CreateSourceInstancePathL - path = %S" ), &filePath ); |
|
802 |
|
803 delete iObjectSource; |
|
804 iObjectSource = NULL; |
|
805 |
|
806 iObjectSource = CThumbnailObjectSource::NewL( filePath, id ); |
|
807 |
|
808 id = iEngine->CreateThumbnails( *iObjectSource ); |
|
809 if (id < 0) |
|
810 { |
|
811 iLog->Log( _L( "CreateThumbnails - error %d" ), id ); |
|
812 return id; |
|
813 } |
|
814 else |
|
815 { |
|
816 iPreviousRequestId = id; |
|
817 iLog->Log( _L( "CreateThumbnails - request id %d" ), iPreviousRequestId ); |
|
818 } |
|
819 |
|
820 iCreateThumbnails = ETrue; |
|
821 |
|
822 return KErrNone; |
|
823 } |
|
824 |
|
825 |
|
826 TInt CThumbnailManagerTest::CreateThumbnails( CStifItemParser& aItem ) |
|
827 { |
|
828 _LIT( KPanicTxt, "CreateThumbnails" ); |
|
829 __ASSERT_ALWAYS( iObjectSource, User::Panic( KPanicTxt, 0 )); |
|
830 __ASSERT_ALWAYS( iEngine, User::Panic( KPanicTxt, 1 )); |
|
831 |
|
832 TInt priority = 0; |
|
833 |
|
834 aItem.GetNextInt( priority ); |
|
835 |
|
836 TInt id; |
|
837 id = iEngine->CreateThumbnails( *iObjectSource, priority ); |
|
838 if (id < 0) |
|
839 { |
|
840 iLog->Log( _L( "CreateThumbnails - error %d" ), id ); |
|
841 return id; |
|
842 } |
|
843 else |
|
844 { |
|
845 iPreviousRequestId = id; |
|
846 iLog->Log( _L( "CreateThumbnails - request id %d" ), iPreviousRequestId ); |
|
847 } |
|
848 |
|
849 iCreateThumbnails = ETrue; |
|
850 |
|
851 return KErrNone; |
|
852 } |
|
853 |
|
854 TInt CThumbnailManagerTest::UpdatePathL( CStifItemParser& aItem ) |
|
855 { |
|
856 _LIT( KPanicTxt, "UpdatePath" ); |
|
857 __ASSERT_ALWAYS( iEngine, User::Panic( KPanicTxt, 0 )); |
|
858 |
|
859 TInt id = 0; |
|
860 TPtrC path; |
|
861 User::LeaveIfError( aItem.GetNextInt( id )); |
|
862 User::LeaveIfError( aItem.GetNextString( path )); |
|
863 |
|
864 TFileName filePath( iDataPath ); |
|
865 filePath.Append( path ); |
|
866 filePath.ZeroTerminate(); |
|
867 |
|
868 iLog->Log( _L( "UpdatePath - path = %S" ), &filePath ); |
|
869 |
|
870 iEngine->UpdateThumbnailsL(id, filePath, 0, 1000, CActive::EPriorityIdle); |
|
871 |
|
872 return KErrNone; |
|
873 } |
|
874 |
|
875 TInt CThumbnailManagerTest::GetSupportedMimeTypesL( CStifItemParser& /*aItem*/ ) |
|
876 { |
|
877 _LIT( KPanicTxt, "GetSupportedMimeTypesL" ); |
|
878 __ASSERT_ALWAYS( iEngine, User::Panic( KPanicTxt, 0 )); |
|
879 |
|
880 iEngine->GetSupportedMimeTypesL(); |
|
881 |
|
882 return KErrNone; |
|
883 } |
|
884 |
|
885 |
|
886 // ========================== OTHER EXPORTED FUNCTIONS ========================= |
|
887 // None |
|
888 |
|
889 // [End of File] - Do not remove |
|