|
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: This file contains testclass implementation. |
|
15 * |
|
16 */ |
|
17 |
|
18 // change the level of RVCT compiler warning 'non-POD class passed thru ellipses' to a remark. |
|
19 #ifdef __MARM__ |
|
20 #pragma diag_remark 1446 |
|
21 #endif |
|
22 |
|
23 // [INCLUDE FILES] - do not remove |
|
24 #include "harvesterplugintester.h" |
|
25 #include <e32svr.h> |
|
26 #include <f32file.h> |
|
27 #include <stifparser.h> |
|
28 #include <stiftestinterface.h> |
|
29 #include <favouritesdb.h> |
|
30 #include <msvapi.h> |
|
31 #include <bautils.h> |
|
32 #include "harvesterobserver.h" |
|
33 #include "cmessageplugin.h" |
|
34 #include "cmessagesessionobserver.h" //For CMsvSession |
|
35 #include "ccpixsearcher.h" |
|
36 #include "bookmarksplugin.h" |
|
37 #include "applicationsplugin.h" |
|
38 #include "ccontactsplugin.h" |
|
39 #include "ccalendarplugin.h" |
|
40 #include "ccalendarobserver.h" |
|
41 #include "mediaplugin.h" |
|
42 #include <harvesterclient.h> |
|
43 #include "mdsitementity.h" |
|
44 #include "cpixmdedbmanager.h" |
|
45 //#include "CBlacklistMgr.h" |
|
46 #include "videoplugin.h" |
|
47 #include "imageplugin.h" |
|
48 |
|
49 _LIT(KAppBasePath,"@c:root file"); |
|
50 const TInt KMsgPluginBaseAppClassMaxLen = 64; |
|
51 |
|
52 // For Notes --Start |
|
53 #include <d32dbms.h> |
|
54 #include <utf.h> |
|
55 #include "notesplugin.h" |
|
56 |
|
57 //Test Uid for testing Blacklist manager |
|
58 |
|
59 //const TUid KTestUid = { 0x101D6348 }; |
|
60 |
|
61 #define MEDIA_QBASEAPPCLASS "@c:root media audio" |
|
62 #define LMEDIA_QBASEAPPCLASS L"@c:root media audio" |
|
63 #define VIDEO_QBASEAPPCLASS "@c:root media video" |
|
64 #define LVIDEO_QBASEAPPCLASS L"@c:root media video" |
|
65 #define IMAGE_QBASEAPPCLASS "@c:root media image" |
|
66 #define LIMAGE_QBASEAPPCLASS L"@c:root media image" |
|
67 |
|
68 // For Notes --End |
|
69 |
|
70 // ============================ MEMBER FUNCTIONS =============================== |
|
71 |
|
72 // ----------------------------------------------------------------------------- |
|
73 // Delete here all resources allocated and opened from test methods. |
|
74 // Called from destructor. |
|
75 void CHarvesterPluginTester::Delete() |
|
76 { |
|
77 } |
|
78 |
|
79 // ----------------------------------------------------------------------------- |
|
80 // Run specified method. Contains also table of test mothods and their names. |
|
81 TInt CHarvesterPluginTester::RunMethodL( |
|
82 CStifItemParser& aItem ) |
|
83 { |
|
84 |
|
85 static TStifFunctionInfo const KFunctions[] = |
|
86 { |
|
87 // Copy this line for every implemented function. |
|
88 // First string is the function name used in TestScripter script file. |
|
89 // Second is the actual implementation member function. |
|
90 ENTRY( "TestStartHarvester", CHarvesterPluginTester::TestStartHarvesterL ), |
|
91 ENTRY( "TestFolderRename", CHarvesterPluginTester::TestFolderRenamingL ), |
|
92 ENTRY( "TestFormBaseAppClass", CHarvesterPluginTester::TestFormBaseAppClass ), |
|
93 ENTRY( "TestDatabasePath", CHarvesterPluginTester::TestDatabasePathL ), |
|
94 ENTRY( "TestCreateIndexItemL_Add", CHarvesterPluginTester::TestCreateIndexItemL ), |
|
95 ENTRY( "TestCreateIndexItemL_Update", CHarvesterPluginTester::TestCreateIndexItemL ), |
|
96 ENTRY( "TestCreateIndexItemL_Delete", CHarvesterPluginTester::TestCreateIndexItemL ), |
|
97 ENTRY( "TestMessaging", CHarvesterPluginTester::TestMessageHarvesterL ), |
|
98 ENTRY( "TestMessageHarvesting", CHarvesterPluginTester::TestMessageHarvesterWithMessageL ), |
|
99 ENTRY( "TestMessageDriveChange", CHarvesterPluginTester::TestMessageHarvesterChangeDriveL ), |
|
100 ENTRY( "TestStartBookmarksHarvesterL", CHarvesterPluginTester::TestStartBookmarksHarvesterL ), |
|
101 ENTRY( "TestAddBookmarkL", CHarvesterPluginTester::TestAddBookmarkL ), |
|
102 ENTRY( "TestAddGetDomainL", CHarvesterPluginTester::TestAddGetDomainL ), |
|
103 ENTRY( "TestStartApplicationsHarvesterL", CHarvesterPluginTester::TestStartApplicationsHarvesterL ), |
|
104 ENTRY( "TestCreateApplicationsIndexItemL", CHarvesterPluginTester::TestCreateApplicationsIndexItemL ), |
|
105 ENTRY( "TestStartNotesHarvesterL", CHarvesterPluginTester::TestStartNotesHarvesterL ), |
|
106 ENTRY( "TestAddNoteL", CHarvesterPluginTester::TestAddNoteL ), |
|
107 ENTRY( "TestAddLongNoteL", CHarvesterPluginTester::TestAddLongNoteL ), |
|
108 ENTRY( "TestAddAlphaNumericNoteL", CHarvesterPluginTester::TestAddAlphaNumericNoteL ), |
|
109 ENTRY( "TestDeleteNoteL", CHarvesterPluginTester::TestDeleteNoteL ), |
|
110 ENTRY( "TestUpdateNoteL", CHarvesterPluginTester::TestUpdateNoteL ), |
|
111 ENTRY( "TestContactsHarvesting", CHarvesterPluginTester::TestStartContactsHarvesterL ), |
|
112 ENTRY( "TestCreateContactIndexItemL_Add", CHarvesterPluginTester::TestCreateContactIndexItemL ), |
|
113 ENTRY( "TestCreateContactIndexItemL_Edit", CHarvesterPluginTester::TestCreateContactIndexItemL ), |
|
114 ENTRY( "TestCreateContactIndexItemL_Delete", CHarvesterPluginTester::TestCreateContactIndexItemL ), |
|
115 ENTRY( "TestCreateContactGroup", CHarvesterPluginTester::TestCreateContactGroupL ), |
|
116 ENTRY( "TestCalenderHarvesting", CHarvesterPluginTester::TestStartCalenderHarvesterL ), |
|
117 ENTRY( "TestCalenderEntry",CHarvesterPluginTester::TestCalenderEntryL ), |
|
118 ENTRY( "TestCreateMMS",CHarvesterPluginTester::TestCreateMmsL ), |
|
119 ENTRY( "TestCreateEmail",CHarvesterPluginTester::TestCreateEmailL ), |
|
120 ENTRY( "TestAudioHarvesting",CHarvesterPluginTester::TestAudioHarvestingL ), |
|
121 ENTRY( "TestMdsSyncController",CHarvesterPluginTester::TestMdsSyncControllerL ), |
|
122 //ENTRY( "TestBlacklistPlugin",CHarvesterPluginTester::TestBlacklistPluginL ), |
|
123 //ENTRY( "TestBlacklistPluginVersion",CHarvesterPluginTester::TestBlacklistPluginVersionL ), |
|
124 ENTRY( "TestVideoHarvestingIndex",CHarvesterPluginTester::TestVideoHarvestingIndexL ), |
|
125 ENTRY( "TestVideoHarvestingUpdateIndex",CHarvesterPluginTester::TestVideoHarvestingUpdateIndexL ), |
|
126 ENTRY( "TestVideoHarvestingDeleteIndex",CHarvesterPluginTester::TestVideoHarvestingDeleteIndexL ), |
|
127 ENTRY( "TestImageHarvestingAddIndex",CHarvesterPluginTester::TestImageHarvestingAddIndexL ), |
|
128 ENTRY( "TestImageHarvestingUpdateIndex",CHarvesterPluginTester::TestImageHarvestingUpdateIndexL ), |
|
129 ENTRY( "TestImageHarvestingDeleteIndex",CHarvesterPluginTester::TestImageHarvestingDeleteIndexL ), |
|
130 ENTRY( "TestAudioMMCEventL",CHarvesterPluginTester::TestAudioMMCEventL ), |
|
131 ENTRY( "TestVideoMMCEventL",CHarvesterPluginTester::TestVideoMMCEventL ), |
|
132 ENTRY( "TestImageMMCEventL",CHarvesterPluginTester::TestImageMMCEventL ), |
|
133 //ADD NEW ENTRY HERE |
|
134 // [test cases entries] - Do not remove |
|
135 }; |
|
136 |
|
137 const TInt count = sizeof( KFunctions ) / |
|
138 sizeof( TStifFunctionInfo ); |
|
139 |
|
140 return RunInternalL( KFunctions, count, aItem ); |
|
141 |
|
142 } |
|
143 |
|
144 _LIT( KNoErrorString, "No Error" ); |
|
145 //_LIT( KErrorString, " *** Error ***" ); |
|
146 |
|
147 void doLog( CStifLogger* logger, TInt error, const TDesC& errorString ) |
|
148 { |
|
149 if( KErrNone == error ) logger->Log( KNoErrorString ); |
|
150 else logger->Log( errorString ); |
|
151 } |
|
152 |
|
153 // Example test method function. |
|
154 // ----------------------------------------------------------------------------- |
|
155 TInt CHarvesterPluginTester::TestStartHarvesterL( CStifItemParser& /*aItem*/ ) |
|
156 { |
|
157 // Print to UI |
|
158 _LIT( KHarvesterPluginTester, "HarvesterPluginTester: %S" ); |
|
159 _LIT( KExample, "In TestStartHarvesterL" ); |
|
160 TestModuleIf().Printf( 0, KHarvesterPluginTester, KExample ); |
|
161 |
|
162 // Print to log file |
|
163 iLog->Log( KExample ); |
|
164 CFilePlugin* filePlugin = CFilePlugin::NewL(); |
|
165 CHarvesterObserver* iPluginTester = CHarvesterObserver::NewL( filePlugin ); |
|
166 filePlugin->StartPluginL(); //Calls Add |
|
167 filePlugin->StartHarvestingL( KAppBasePath ); |
|
168 iPluginTester->iWaitForHarvester->Start();//Wait here till Harvesting is complete. |
|
169 delete filePlugin; |
|
170 delete iPluginTester; |
|
171 doLog( iLog, KErrNone, KNoErrorString ); |
|
172 return KErrNone; |
|
173 } |
|
174 |
|
175 //Same as before, except we rename a directory before calling wait->Start() |
|
176 TInt CHarvesterPluginTester::TestFolderRenamingL( CStifItemParser& /*aItem*/ ) |
|
177 { |
|
178 CFilePlugin* filePlugin = CFilePlugin::NewL(); |
|
179 CHarvesterObserver* iPluginTester = CHarvesterObserver::NewL( filePlugin ); |
|
180 filePlugin->StartPluginL(); //Calls Add |
|
181 filePlugin->StartHarvestingL( KAppBasePath ); |
|
182 |
|
183 _LIT( KDirectoryToRenameFrom, "C:\\data\\FileToTestRename" ); |
|
184 _LIT( KDirectoryToRenameTo, "C:\\data\\FileToTestRenamed" ); |
|
185 RFs fs; |
|
186 fs.Connect(); |
|
187 TInt error = fs.Rename( KDirectoryToRenameFrom, KDirectoryToRenameTo ); |
|
188 iPluginTester->iWaitForHarvester->Start();//Wait here till Harvesting is complete. |
|
189 //rename it back to what it was. |
|
190 error = fs.Rename( KDirectoryToRenameTo, KDirectoryToRenameFrom ); |
|
191 |
|
192 delete filePlugin; |
|
193 delete iPluginTester; |
|
194 doLog( iLog, error, _L("Error: TestFolderRename.") ); |
|
195 |
|
196 return error; |
|
197 } |
|
198 |
|
199 TInt CHarvesterPluginTester::TestFormBaseAppClass( CStifItemParser& aItem ) |
|
200 { |
|
201 // Print to UI |
|
202 _LIT( KFilePluginBaseAppClass, "FormBaseAppClass" ); |
|
203 _LIT( KExample, "In TestFormBaseAppClass" ); |
|
204 TestModuleIf().Printf( 0, KFilePluginBaseAppClass, KExample ); |
|
205 |
|
206 TInt driveNumber; |
|
207 TBuf<100> formedBaseAppClass; |
|
208 TBuf<100> expectedBaseAppClass; |
|
209 TChar driveChar; |
|
210 CFilePlugin* filePlugin = CFilePlugin::NewL(); |
|
211 CHarvesterObserver* iPluginTester = CHarvesterObserver::NewL( filePlugin ); |
|
212 filePlugin->StartPluginL(); |
|
213 |
|
214 TInt error = KErrNone; |
|
215 TInt errorNumber = 0; |
|
216 _LIT( KBaseAppClassFormatString, "@%c:root file"); |
|
217 _LIT( KTestFormBaseAppClassNoError, "TestFormBaseAppClass: No Error" ); |
|
218 |
|
219 if( aItem.GetNextInt ( driveNumber ) == KErrNone && error == KErrNone ) |
|
220 { |
|
221 filePlugin->FormBaseAppClass( static_cast<TDriveNumber>( driveNumber ), formedBaseAppClass ); |
|
222 if( aItem.GetNextChar ( driveChar ) == KErrNone ) |
|
223 { |
|
224 expectedBaseAppClass.Format( KBaseAppClassFormatString, driveChar ); |
|
225 error = expectedBaseAppClass.Compare( formedBaseAppClass ); |
|
226 if( aItem.GetNextInt ( errorNumber ) == KErrNone ) |
|
227 error = ( KErrNone == error || -1 == errorNumber ) ? KErrNone : KErrGeneral ; |
|
228 } |
|
229 } |
|
230 delete filePlugin; |
|
231 delete iPluginTester; |
|
232 |
|
233 doLog( iLog, error, KTestFormBaseAppClassNoError ); |
|
234 return error; |
|
235 } |
|
236 |
|
237 TInt CHarvesterPluginTester::TestDatabasePathL( CStifItemParser& aItem ) |
|
238 { |
|
239 TInt driveNumber; |
|
240 CFilePlugin* filePlugin = CFilePlugin::NewL(); |
|
241 CHarvesterObserver* iPluginTester = CHarvesterObserver::NewL( filePlugin ); |
|
242 filePlugin->StartPluginL(); |
|
243 |
|
244 HBufC* buffer; |
|
245 TBuf<KMaxFileName> returnedDbPath; |
|
246 TBuf<KMaxFileName> expectedDbPath; |
|
247 TInt error = KErrNone; |
|
248 TInt errorNumber; |
|
249 TChar driveChar; |
|
250 _LIT( KTestDatabasePathNoError, "TestDatabasePathL: No Error" ); |
|
251 |
|
252 _LIT( KDbFormatString, "%c:\\Private\\2001f6f7\\indexing\\indexdb\\root\\file" ); |
|
253 if( aItem.GetNextInt ( driveNumber ) == KErrNone && error == KErrNone ) |
|
254 { |
|
255 buffer = filePlugin->DatabasePathLC( static_cast<TDriveNumber>( driveNumber ) ); |
|
256 returnedDbPath.Copy( *buffer ); |
|
257 if( aItem.GetNextChar ( driveChar ) == KErrNone ) |
|
258 { |
|
259 expectedDbPath.Format( KDbFormatString, driveChar ); |
|
260 error = expectedDbPath.Compare( returnedDbPath ); |
|
261 if( aItem.GetNextInt ( errorNumber ) == KErrNone ) |
|
262 error = ( KErrNone == error || -1 == errorNumber ) ? KErrNone : KErrGeneral ; |
|
263 } |
|
264 } |
|
265 CleanupStack::PopAndDestroy( buffer ); |
|
266 delete filePlugin; |
|
267 delete iPluginTester; |
|
268 doLog( iLog, error, KTestDatabasePathNoError ); |
|
269 return error; |
|
270 } |
|
271 |
|
272 //Helper functions |
|
273 enum TSearchType |
|
274 { |
|
275 ESearchTypeResultsExpected=0, |
|
276 ESearchTypeNoResultsExpected |
|
277 }; |
|
278 |
|
279 TInt doSearch( const TDesC& aSearchString, const TDesC& aBaseAppClass, TSearchType aSearchType ) |
|
280 { |
|
281 RSearchServerSession session; |
|
282 User::LeaveIfError( session.Connect() ); |
|
283 CCPixSearcher* searcher = CCPixSearcher::NewLC( session ); |
|
284 searcher->OpenDatabaseL( aBaseAppClass ); |
|
285 |
|
286 TInt docCount = searcher->SearchL( aSearchString, KNullDesC); |
|
287 |
|
288 CleanupStack::PopAndDestroy( searcher ); |
|
289 session.Close(); |
|
290 |
|
291 if( aSearchType == ESearchTypeResultsExpected ) |
|
292 { |
|
293 return docCount > 0 ? KErrNone : KErrNotFound; |
|
294 } |
|
295 else |
|
296 { |
|
297 return 0 == docCount ? KErrNone : KErrNotFound; |
|
298 } |
|
299 } |
|
300 |
|
301 TInt CHarvesterPluginTester::TestCreateIndexItemL( CStifItemParser& aItem ) |
|
302 { |
|
303 TInt error = KErrNone; |
|
304 TPtrC fileName; |
|
305 TPtrC createIndexAction; |
|
306 CFilePlugin* filePlugin = CFilePlugin::NewL(); |
|
307 CHarvesterObserver* observer = CHarvesterObserver::NewL( filePlugin ); |
|
308 filePlugin->StartPluginL(); |
|
309 _LIT( KFileNameFormat, "C:\\TestFramework\\" ); |
|
310 _LIT( KActionAdd, "add" ); |
|
311 _LIT( KActionDelete, "delete" ); |
|
312 _LIT( KActionUpdate, "update" ); |
|
313 _LIT( KCreateIndexItemNoError, "CreateIndexItemL: Error" ); |
|
314 |
|
315 TBuf<KMaxFileName> filePathName( KFileNameFormat ); |
|
316 |
|
317 if( aItem.GetNextString ( createIndexAction ) == KErrNone ) |
|
318 { |
|
319 if( createIndexAction.Compare( KActionAdd ) == 0 ) |
|
320 { |
|
321 if( aItem.GetNextString ( fileName ) == KErrNone && error == KErrNone ) |
|
322 { |
|
323 filePathName.Append( fileName ); |
|
324 filePlugin->CreateFileIndexItemL( filePathName, ECPixAddAction ); |
|
325 TPtrC searchString; |
|
326 while( aItem.GetNextString ( searchString ) == KErrNone && error == KErrNone ) |
|
327 { |
|
328 error = doSearch( searchString, _L(FILE_QBASEAPPCLASS), ESearchTypeResultsExpected ); |
|
329 } |
|
330 filePlugin->CreateFileIndexItemL( filePathName, ECPixRemoveAction ); |
|
331 } |
|
332 } |
|
333 if( createIndexAction.Compare( KActionDelete ) == 0 ) |
|
334 { |
|
335 if( aItem.GetNextString ( fileName ) == KErrNone && error == KErrNone ) |
|
336 { |
|
337 filePathName.Append( fileName ); |
|
338 filePlugin->CreateFileIndexItemL( filePathName, ECPixRemoveAction ); |
|
339 TPtrC searchString; |
|
340 while( aItem.GetNextString ( searchString ) == KErrNone && error == KErrNone ) |
|
341 { |
|
342 error = doSearch( searchString, _L(FILE_QBASEAPPCLASS), ESearchTypeNoResultsExpected ); |
|
343 } |
|
344 } |
|
345 } |
|
346 if( createIndexAction.Compare( KActionUpdate ) == 0 ) |
|
347 { |
|
348 if( aItem.GetNextString ( fileName ) == KErrNone && error == KErrNone ) |
|
349 { |
|
350 filePathName.Append( fileName ); |
|
351 filePlugin->CreateFileIndexItemL( filePathName, ECPixUpdateAction ); |
|
352 TPtrC searchString; |
|
353 while( aItem.GetNextString ( searchString ) == KErrNone && error == KErrNone ) |
|
354 { |
|
355 error = doSearch( searchString, _L(FILE_QBASEAPPCLASS), ESearchTypeResultsExpected ); |
|
356 } |
|
357 } |
|
358 } |
|
359 } |
|
360 delete filePlugin; |
|
361 delete observer; |
|
362 doLog( iLog, error, KCreateIndexItemNoError ); |
|
363 return error; |
|
364 } |
|
365 |
|
366 /** |
|
367 * Message harvester test method. |
|
368 * @since ?Series60_version |
|
369 * @param aItem Script line containing parameters. |
|
370 * @return Symbian OS error code. |
|
371 */ |
|
372 TInt CHarvesterPluginTester::TestMessageHarvesterL( CStifItemParser& /*aItem*/ ) |
|
373 { |
|
374 // Print to UI |
|
375 _LIT( KHarvesterPluginTester, "HarvesterPluginTester" ); |
|
376 _LIT( KExample, "In TestMessageHarvesterL" ); |
|
377 TestModuleIf().Printf( 0, KHarvesterPluginTester, KExample ); |
|
378 // Print to log file |
|
379 iLog->Log( KExample ); |
|
380 |
|
381 CMessagePlugin* plugin = CMessagePlugin::NewL(); |
|
382 CHarvesterObserver* iPluginTester = CHarvesterObserver::NewL( plugin ); |
|
383 plugin->StartPluginL(); |
|
384 CMessageSessionObserver* sessionobserver = CMessageSessionObserver::NewL(); |
|
385 CMsvSession* msgSession = CMsvSession::OpenSyncL(*sessionobserver); |
|
386 // Form the baseappclass for this media |
|
387 TBuf<KMsgPluginBaseAppClassMaxLen> baseAppClass; |
|
388 TInt drive = msgSession->CurrentDriveL(); |
|
389 CMessagePlugin::FormBaseAppClass(TDriveNumber(drive),baseAppClass); |
|
390 //Get current base app class for drive |
|
391 //CMessagePlugin::FormBaseAppClass |
|
392 plugin->StartHarvestingL( baseAppClass ); |
|
393 iPluginTester->iWaitForHarvester->Start(); |
|
394 |
|
395 delete plugin; |
|
396 delete iPluginTester; |
|
397 delete sessionobserver; |
|
398 delete msgSession; |
|
399 doLog(iLog,KErrNone,KNoErrorString); |
|
400 return KErrNone; |
|
401 } |
|
402 |
|
403 TInt CHarvesterPluginTester::TestMessageHarvesterWithMessageL( CStifItemParser& /*aItem*/ ) |
|
404 { |
|
405 _LIT( KHarvesterPluginTester, "HarvesterPluginTester" ); |
|
406 _LIT( KExample, "In TestMessageHarvesterWithMessageL" ); |
|
407 TInt error(KErrNone); |
|
408 |
|
409 TestModuleIf().Printf( 0, KHarvesterPluginTester, KExample ); |
|
410 // Print to log file |
|
411 iLog->Log( KExample ); |
|
412 CMessagePlugin* plugin = CMessagePlugin::NewL(); |
|
413 CHarvesterObserver* iPluginTester = CHarvesterObserver::NewL( plugin ); |
|
414 plugin->StartPluginL(); |
|
415 CMessageSessionObserver* sessionobserver = CMessageSessionObserver::NewL(); |
|
416 CMsvSession* msgSession = CMsvSession::OpenSyncL(*sessionobserver); |
|
417 // Form the baseappclass for this media |
|
418 TBuf<KMsgPluginBaseAppClassMaxLen> baseAppClass; |
|
419 TInt drive = msgSession->CurrentDriveL(); |
|
420 //Get current base app class for drive |
|
421 CMessagePlugin::FormBaseAppClass(TDriveNumber(drive),baseAppClass); |
|
422 plugin->StartHarvestingL( baseAppClass ); |
|
423 //Create a new SMS message |
|
424 TMsvId msgid = MessagingUtils::CreateMessageL(msgSession, |
|
425 _L("+3584400220055"), |
|
426 _L("+919845062437"), |
|
427 _L("This is test from bhuvnesh")); |
|
428 iPluginTester->iWaitForHarvester->Start(); |
|
429 TInt count = SearchForTextL(_L("+919845062437"),baseAppClass,KNullDesC); |
|
430 MessagingUtils::RemoveEntryL(msgSession,msgid); |
|
431 if(count <= 0) |
|
432 { |
|
433 error = KErrNotFound; |
|
434 } |
|
435 |
|
436 delete plugin; |
|
437 delete iPluginTester; |
|
438 delete sessionobserver; |
|
439 delete msgSession; |
|
440 doLog(iLog,error,_L("Error in TestMessageHarvesterWithMessageL")); |
|
441 return error; |
|
442 } |
|
443 |
|
444 TInt CHarvesterPluginTester::TestMessageHarvesterChangeDriveL( CStifItemParser& /*aItem*/ ) |
|
445 { |
|
446 _LIT( KHarvesterPluginTester, "HarvesterPluginTester" ); |
|
447 _LIT( KExample, "In TestMessageHarvesterChangeDriveL" ); |
|
448 TInt error(KErrNone); |
|
449 |
|
450 TestModuleIf().Printf( 0, KHarvesterPluginTester, KExample ); |
|
451 // Print to log file |
|
452 iLog->Log( KExample ); |
|
453 CMessagePlugin* plugin = CMessagePlugin::NewL(); |
|
454 CHarvesterObserver* iPluginTester = CHarvesterObserver::NewL( plugin ); |
|
455 plugin->StartPluginL(); |
|
456 CMessageSessionObserver* sessionobserver = CMessageSessionObserver::NewL(); |
|
457 CMsvSession* msgSession = CMsvSession::OpenSyncL(*sessionobserver); |
|
458 // Form the baseappclass for this media |
|
459 TBuf<KMsgPluginBaseAppClassMaxLen> baseAppClass; |
|
460 TInt drive = msgSession->CurrentDriveL(); |
|
461 //Get current base app class for drive |
|
462 CMessagePlugin::FormBaseAppClass(TDriveNumber(drive),baseAppClass); |
|
463 plugin->StartHarvestingL( baseAppClass ); |
|
464 iPluginTester->iWaitForHarvester->Start(); |
|
465 //Harvesting completed change the drive and make sure new message harvested |
|
466 drive == EDriveC ? drive = EDriveE : drive = EDriveC; |
|
467 TRequestStatus status = KRequestPending; |
|
468 msgSession->ChangeDriveL(drive,status); |
|
469 User::WaitForAnyRequest(); |
|
470 //User::WaitForRequest(status);//Wait to complete this request |
|
471 plugin->StartHarvestingL( baseAppClass ); |
|
472 TMsvId msgid = MessagingUtils::CreateMessageL(msgSession, |
|
473 _L("+3584400220055"), |
|
474 _L("+919845062437"), |
|
475 _L("This is test from bhuvnesh")); |
|
476 iPluginTester->iWaitForHarvester->Start();//Start again |
|
477 drive = msgSession->CurrentDriveL(); |
|
478 CMessagePlugin::FormBaseAppClass(TDriveNumber(drive),baseAppClass); |
|
479 TInt count = SearchForTextL(_L("+919845062437"),baseAppClass,KNullDesC); |
|
480 if(count <= 0) |
|
481 { |
|
482 error = KErrNotFound; |
|
483 } |
|
484 MessagingUtils::RemoveEntryL(msgSession,msgid); |
|
485 |
|
486 delete plugin; |
|
487 delete iPluginTester; |
|
488 delete sessionobserver; |
|
489 delete msgSession; |
|
490 doLog(iLog,error,_L("Error in TestMessageHarvesterChangeDriveL")); |
|
491 return error; |
|
492 } |
|
493 |
|
494 TInt CHarvesterPluginTester::SearchForTextL(const TDesC& aQueryString, const TDesC& aBaseAppclass,const TDesC& aDefaultField) |
|
495 { |
|
496 TInt DocumentCount(KErrNotFound); |
|
497 RSearchServerSession session; |
|
498 User::LeaveIfError(session.Connect()); |
|
499 CCPixSearcher* searcher = CCPixSearcher::NewL(session); |
|
500 searcher->OpenDatabaseL(aBaseAppclass); |
|
501 // Send for indexing |
|
502 if ( searcher ) |
|
503 { |
|
504 DocumentCount = searcher->SearchL(aQueryString, aDefaultField); |
|
505 } |
|
506 return DocumentCount; |
|
507 } |
|
508 |
|
509 TInt CHarvesterPluginTester::TestStartBookmarksHarvesterL( CStifItemParser& /*aItem */) |
|
510 { |
|
511 CBookmarksPlugin* plugin = CBookmarksPlugin::NewL(); |
|
512 CHarvesterObserver* iPluginTester = CHarvesterObserver::NewL( plugin ); |
|
513 plugin->StartPluginL(); |
|
514 plugin->StartHarvestingL( _L(BOOKMARK_QBASEAPPCLASS) ); |
|
515 iPluginTester->iWaitForHarvester->Start();//Wait here till Harvesting is complete. |
|
516 delete plugin; |
|
517 delete iPluginTester; |
|
518 doLog( iLog, KErrNone, KNoErrorString ); |
|
519 return KErrNone; |
|
520 } |
|
521 |
|
522 TInt CHarvesterPluginTester::TestAddBookmarkL( CStifItemParser& aItem ) |
|
523 { |
|
524 TInt error = KErrNone; |
|
525 CBookmarksPlugin* plugin = CBookmarksPlugin::NewL(); |
|
526 CHarvesterObserver* iPluginTester = CHarvesterObserver::NewL( plugin ); |
|
527 plugin->StartPluginL(); //starts the bookmarks db monitor. |
|
528 |
|
529 //now add a bookmark. |
|
530 CFavouritesItem* item = CFavouritesItem::NewL(); |
|
531 RFavouritesDb favoritesDb; |
|
532 RFavouritesSession favSession; |
|
533 error = favSession.Connect(); |
|
534 if( KErrNone == error ) error = favoritesDb.Open( favSession, KBrowserBookmarks ) ; |
|
535 if( KErrNone != error ) return error; |
|
536 |
|
537 item->SetType( CFavouritesItem::EItem ); |
|
538 item->SetParentFolder( KFavouritesRootUid ); |
|
539 |
|
540 TPtrC string; |
|
541 error = aItem.GetNextString( string ); |
|
542 if( KErrNone == error ) |
|
543 item->SetNameL( string ); |
|
544 |
|
545 error = aItem.GetNextString( string ); |
|
546 if( KErrNone == error ) |
|
547 item->SetUrlL( string ); |
|
548 |
|
549 if( KErrNone == error ) |
|
550 { |
|
551 error = favoritesDb.Begin( ETrue ); |
|
552 if( KErrNone == error ) error = favoritesDb.Add( *item, ETrue ); //ETrue for Autorename. We are searching only by URL so this is fine. |
|
553 if( KErrNone == error ) error = favoritesDb.Commit(); |
|
554 plugin->StartHarvestingL( _L(BOOKMARK_QBASEAPPCLASS) ); |
|
555 if( KErrNone == error ) iPluginTester->iWaitForHarvester->Start();//Wait here till Harvesting is complete. |
|
556 } |
|
557 |
|
558 //now, search for URL. |
|
559 if( KErrNone == error ) |
|
560 { |
|
561 error = aItem.GetNextString( string ); |
|
562 if( KErrNone == error ) |
|
563 error = doSearch( string , _L( BOOKMARK_QBASEAPPCLASS ), ESearchTypeResultsExpected ); |
|
564 } |
|
565 |
|
566 delete plugin; |
|
567 delete iPluginTester; |
|
568 |
|
569 favoritesDb.Close(); |
|
570 favSession.Close(); |
|
571 |
|
572 doLog( iLog, error, _L("Error in AddBookmarkL") ); |
|
573 return error; |
|
574 } |
|
575 |
|
576 //Forward declare this function. |
|
577 //It is a local function in the .cpp file and hence not listed in .h file. |
|
578 //Forward declare it so that the compilation can go thru - the implementation |
|
579 //will be picked up by the linker. |
|
580 void GetDomainNameL( const TDesC& aUrl, TPtrC& aDomain ); |
|
581 |
|
582 TInt CHarvesterPluginTester::TestAddGetDomainL( CStifItemParser& aItem ) |
|
583 { |
|
584 TInt error = KErrNone; |
|
585 TPtrC inputString; |
|
586 TPtrC domain; |
|
587 while( aItem.GetNextString( inputString ) == KErrNone ) |
|
588 { |
|
589 GetDomainNameL( inputString, domain ); |
|
590 if( aItem.GetNextString( inputString ) == KErrNone ) |
|
591 error = domain.Compare( inputString ); |
|
592 if( error != KErrNone ) return error; |
|
593 } |
|
594 return KErrNone; |
|
595 } |
|
596 |
|
597 TInt CHarvesterPluginTester::TestStartApplicationsHarvesterL( CStifItemParser& /*aItem*/ ) |
|
598 { |
|
599 CApplicationsPlugin* appsPlugin = CApplicationsPlugin::NewL(); |
|
600 CHarvesterObserver* iPluginTester = CHarvesterObserver::NewL( appsPlugin ); |
|
601 appsPlugin->StartPluginL(); //Calls Add |
|
602 appsPlugin->StartHarvestingL( KNullDesC ); |
|
603 iPluginTester->iWaitForHarvester->Start();//Wait here till Harvesting is complete. |
|
604 delete appsPlugin; |
|
605 delete iPluginTester; |
|
606 doLog( iLog, KErrNone, KNoErrorString ); |
|
607 return KErrNone; |
|
608 } |
|
609 |
|
610 TInt CHarvesterPluginTester::TestCreateApplicationsIndexItemL( CStifItemParser& /*aItem*/ ) |
|
611 { |
|
612 CApplicationsPlugin* appsPlugin = CApplicationsPlugin::NewL(); |
|
613 CHarvesterObserver* iPluginTester = CHarvesterObserver::NewL( appsPlugin ); |
|
614 appsPlugin->StartPluginL(); |
|
615 |
|
616 //Force reharvesting: |
|
617 appsPlugin->HandleAppListEvent( 1 ); //EListChanged = 1 |
|
618 iPluginTester->iWaitForHarvester->Start();//Wait here till Harvesting is complete. |
|
619 |
|
620 delete appsPlugin; |
|
621 delete iPluginTester; |
|
622 doLog( iLog, KErrNone, KNoErrorString ); |
|
623 return KErrNone; |
|
624 } |
|
625 |
|
626 TInt CHarvesterPluginTester::TestStartNotesHarvesterL( CStifItemParser& /*aItem*/ ) |
|
627 { |
|
628 CNotesPlugin* plugin = CNotesPlugin::NewL(); |
|
629 CHarvesterObserver* iPluginTester = CHarvesterObserver::NewL( plugin ); |
|
630 plugin->StartPluginL(); |
|
631 plugin->StartHarvestingL( _L(NOTES_QBASEAPPCLASS) ); |
|
632 iPluginTester->iWaitForHarvester->Start();//Wait here till Harvesting is complete. |
|
633 delete plugin; |
|
634 delete iPluginTester; |
|
635 doLog( iLog, KErrNone, KNoErrorString ); |
|
636 return KErrNone; |
|
637 } |
|
638 |
|
639 TInt CHarvesterPluginTester::TestAddNoteL( CStifItemParser& aItem ) |
|
640 { |
|
641 TPtrC string; |
|
642 TPtrC searchstring; |
|
643 TInt error = aItem.GetNextString( string ); |
|
644 error = aItem.GetNextString( searchstring ); |
|
645 error = PerformNotesTestL(string , searchstring); |
|
646 return error; |
|
647 } |
|
648 |
|
649 TInt CHarvesterPluginTester::TestAddLongNoteL( CStifItemParser& aItem ) |
|
650 { |
|
651 TPtrC string; |
|
652 TPtrC searchstring; |
|
653 TInt error = aItem.GetNextString( string ); |
|
654 error = aItem.GetNextString( searchstring ); |
|
655 error = PerformNotesTestL(string , searchstring); |
|
656 return error; |
|
657 } |
|
658 TInt CHarvesterPluginTester::TestAddAlphaNumericNoteL( CStifItemParser& aItem ) |
|
659 { |
|
660 TPtrC string; |
|
661 TPtrC searchstring; |
|
662 TInt error = aItem.GetNextString( string ); |
|
663 error = aItem.GetNextString( searchstring ); |
|
664 error = PerformNotesTestL(string , searchstring); |
|
665 return error; |
|
666 } |
|
667 TInt CHarvesterPluginTester::PerformNotesTestL( TPtrC aString1 , TPtrC aString2) |
|
668 { |
|
669 TInt error = KErrNone; |
|
670 HBufC8* memo = NULL; |
|
671 CNotesPlugin* plugin = CNotesPlugin::NewL(); |
|
672 CHarvesterObserver* iPluginTester = CHarvesterObserver::NewL( plugin ); |
|
673 plugin->StartPluginL(); //starts the Notes database notifier |
|
674 if(aString1.Length() > 0) |
|
675 { |
|
676 RFs fssession; |
|
677 User::LeaveIfError( fssession.Connect() ); |
|
678 RFile testfile; |
|
679 error = testfile.Open(fssession,aString1,EFileRead); |
|
680 if(error == KErrNone) |
|
681 { |
|
682 TInt size(0); |
|
683 testfile.Size(size); |
|
684 memo = HBufC8::NewL(size); |
|
685 TPtr8 memoptr = memo->Des(); |
|
686 User::LeaveIfError( testfile.Read(memoptr, size ) ); |
|
687 //testfile.Read(memoptr,size); |
|
688 testfile.Close(); |
|
689 fssession.Close(); |
|
690 } |
|
691 } |
|
692 if(error == KErrNone) |
|
693 { |
|
694 CCalendarObserver* session = CCalendarObserver::NewL(); |
|
695 session->AddNoteL(memo->Des()); |
|
696 plugin->StartHarvestingL( _L(NOTES_QBASEAPPCLASS) ); |
|
697 iPluginTester->iWaitForHarvester->Start();//Wait here till Harvesting is complete. |
|
698 error = doSearch( aString2, _L(NOTES_QBASEAPPCLASS), ESearchTypeResultsExpected ); |
|
699 |
|
700 delete session; |
|
701 doLog( iLog, error, KNoErrorString ); |
|
702 } |
|
703 delete memo; |
|
704 delete plugin; |
|
705 delete iPluginTester; |
|
706 return error; |
|
707 } |
|
708 |
|
709 TInt CHarvesterPluginTester::TestDeleteNoteL( CStifItemParser& aItem ) |
|
710 { |
|
711 TInt error = KErrNone; |
|
712 _LIT( KSearchError, "Search Failed" ); |
|
713 |
|
714 CNotesPlugin* plugin = CNotesPlugin::NewL(); |
|
715 CHarvesterObserver* iPluginTester = CHarvesterObserver::NewL( plugin ); |
|
716 plugin->StartPluginL(); |
|
717 |
|
718 CCalendarObserver* session = CCalendarObserver::NewL(); |
|
719 plugin->StartHarvestingL( _L(NOTES_QBASEAPPCLASS) ); |
|
720 // Add a Note entry |
|
721 TPtrC searchstring; |
|
722 error = aItem.GetNextString( searchstring ); |
|
723 HBufC8* buf8 = HBufC8::NewL(2*searchstring.Length()); |
|
724 buf8->Des().Copy(searchstring); |
|
725 session->AddNoteL( buf8->Des()); |
|
726 delete buf8; |
|
727 iPluginTester->iWaitForHarvester->Start(); |
|
728 error = doSearch( _L("TestNote"), _L( NOTES_QBASEAPPCLASS ), ESearchTypeResultsExpected ); |
|
729 doLog( iLog, error, KSearchError ); |
|
730 if( error == KErrNone) |
|
731 { |
|
732 session->DeleteNoteEntryL(); |
|
733 plugin->StartHarvestingL( _L(NOTES_QBASEAPPCLASS) ); |
|
734 iPluginTester->iWaitForHarvester->Start(); |
|
735 //Delete the Note entry added previously and search for result |
|
736 error = doSearch( _L("TestNote"), _L( NOTES_QBASEAPPCLASS ), ESearchTypeResultsExpected ); |
|
737 //If the entery is succesfully deleted, make error to KErrNone.To show testcase success |
|
738 if(error == KErrNotFound) |
|
739 error = KErrNone; |
|
740 } |
|
741 delete session; |
|
742 delete plugin; |
|
743 delete iPluginTester; |
|
744 doLog( iLog, error, KSearchError ); |
|
745 return KErrNone; |
|
746 } |
|
747 |
|
748 TInt CHarvesterPluginTester::TestUpdateNoteL( CStifItemParser& aItem ) |
|
749 { |
|
750 TInt error = KErrNone; |
|
751 _LIT( KSearchError, "Search Failed" ); |
|
752 TPtrC oldString; |
|
753 error = aItem.GetNextString( oldString ); |
|
754 TPtrC newString; |
|
755 error = aItem.GetNextString( newString ); |
|
756 CNotesPlugin* plugin = CNotesPlugin::NewL(); |
|
757 CHarvesterObserver* iPluginTester = CHarvesterObserver::NewL( plugin ); |
|
758 plugin->StartPluginL(); |
|
759 CCalendarObserver* session = CCalendarObserver::NewL(); |
|
760 plugin->StartHarvestingL( _L(NOTES_QBASEAPPCLASS) ); |
|
761 // Add a Note entry |
|
762 HBufC8* oldbuf8 = HBufC8::NewL(2*oldString.Length()); |
|
763 oldbuf8->Des().Copy(oldString); |
|
764 session->AddNoteL( oldbuf8->Des()); |
|
765 TBuf<20> oldsearchstring; |
|
766 oldsearchstring.Copy( oldString ); |
|
767 iPluginTester->iWaitForHarvester->Start(); |
|
768 error = doSearch( oldsearchstring, _L( NOTES_QBASEAPPCLASS ), ESearchTypeResultsExpected ); |
|
769 doLog( iLog, error, KSearchError ); |
|
770 |
|
771 TBuf<20> newsearchstring; |
|
772 newsearchstring.Copy( newString ); |
|
773 HBufC8* newbuf8 = HBufC8::NewL(2*newString.Length()); |
|
774 newbuf8->Des().Copy(newString); |
|
775 //update the Note entry and search for result |
|
776 session->UpdateNoteEntryL( oldbuf8->Des(), newbuf8->Des() ); |
|
777 plugin->StartHarvestingL( _L(NOTES_QBASEAPPCLASS) ); |
|
778 iPluginTester->iWaitForHarvester->Start(); |
|
779 error = doSearch( newsearchstring, _L( NOTES_QBASEAPPCLASS ), ESearchTypeResultsExpected ); |
|
780 doLog( iLog, error, KSearchError ); |
|
781 |
|
782 delete newbuf8; |
|
783 delete oldbuf8; |
|
784 delete session; |
|
785 delete plugin; |
|
786 delete iPluginTester; |
|
787 return error; |
|
788 } |
|
789 |
|
790 TInt CHarvesterPluginTester::TestStartContactsHarvesterL( CStifItemParser& /*aItem*/ ) |
|
791 { |
|
792 CContactsPlugin* plugin = CContactsPlugin::NewL(); |
|
793 CHarvesterObserver* iPluginTester = CHarvesterObserver::NewL( plugin ); |
|
794 plugin->StartPluginL(); //start to moniter contacts db |
|
795 plugin->StartHarvestingL( _L(CONTACT_QBASEAPPCLASS) ); |
|
796 iPluginTester->iWaitForHarvester->Start();//Wait here till Harvesting is complete. |
|
797 delete plugin; |
|
798 delete iPluginTester; |
|
799 doLog( iLog, KErrNone, KNoErrorString ); |
|
800 return KErrNone; |
|
801 } |
|
802 |
|
803 TContactItemId CHarvesterPluginTester::CreateNewContactL( CContactDatabase& database,const TDesC& aName,const TDesC& aPhoneNumber ) |
|
804 { |
|
805 // Create a contact card to contain the data |
|
806 CContactCard* newCard = CContactCard::NewLC(); |
|
807 |
|
808 // Create the firstName field and add the data to it |
|
809 CContactItemField* firstName = CContactItemField::NewLC( KStorageTypeText, KUidContactFieldGivenName ); |
|
810 firstName->TextStorage()->SetTextL(aName); |
|
811 newCard->AddFieldL(*firstName); |
|
812 CleanupStack::Pop(firstName); |
|
813 |
|
814 // Create the phoneNo field and add the data to it |
|
815 CContactItemField* phoneNumber = CContactItemField::NewLC( KStorageTypeText, KUidContactFieldPhoneNumber ); |
|
816 phoneNumber->SetMapping(KUidContactFieldVCardMapTEL); |
|
817 phoneNumber ->TextStorage()->SetTextL(aPhoneNumber); |
|
818 newCard->AddFieldL(*phoneNumber); |
|
819 CleanupStack::Pop(phoneNumber); |
|
820 |
|
821 // Add newCard to the database |
|
822 const TContactItemId contactId = database.AddNewContactL(*newCard); |
|
823 CleanupStack::PopAndDestroy(newCard); |
|
824 return contactId; |
|
825 } |
|
826 |
|
827 TInt CHarvesterPluginTester::TestCreateContactIndexItemL( CStifItemParser& aItem ) |
|
828 { |
|
829 TInt error = KErrNone; |
|
830 TPtrC IndexAction; |
|
831 TPtrC ContactName; |
|
832 TPtrC NewContactName; |
|
833 _LIT( KActionAdd, "add" ); |
|
834 _LIT( KSearchError, "Search Failed" ); |
|
835 _LIT( KActionDelete, "delete" ); |
|
836 _LIT( KActionUpdate, "update" ); |
|
837 |
|
838 CContactsPlugin* plugin = CContactsPlugin::NewL(); |
|
839 CHarvesterObserver* iPluginTester = CHarvesterObserver::NewL( plugin ); |
|
840 plugin->StartPluginL(); //start to moniter contacts db |
|
841 CContactDatabase* db = CContactDatabase::OpenL(); |
|
842 |
|
843 if( aItem.GetNextString ( IndexAction ) == KErrNone ) |
|
844 { |
|
845 if( IndexAction.Compare( KActionAdd ) == 0 ) |
|
846 { |
|
847 if( aItem.GetNextString ( ContactName ) == KErrNone ) |
|
848 { |
|
849 TInt aContactId; |
|
850 plugin->StartHarvestingL( _L(CONTACT_QBASEAPPCLASS) ); |
|
851 aContactId = CreateNewContactL( *db, ContactName, _L("1234") ); |
|
852 iPluginTester->iWaitForHarvester->Start();//Wait here till Harvesting is complete. |
|
853 |
|
854 error = doSearch( ContactName, _L( CONTACT_QBASEAPPCLASS ), ESearchTypeResultsExpected ); |
|
855 db->DeleteContactL(aContactId); |
|
856 } |
|
857 } |
|
858 if( IndexAction.Compare( KActionUpdate ) == 0 ) |
|
859 { |
|
860 if( aItem.GetNextString ( ContactName ) == KErrNone ) |
|
861 { |
|
862 TInt aContactId; |
|
863 //Add a contact first and later edit the contact |
|
864 aContactId = CreateNewContactL( *db, ContactName, _L("123") ); |
|
865 |
|
866 CContactItem* contactItem = db->OpenContactL( aContactId ); |
|
867 CleanupStack::PushL( contactItem ); |
|
868 // First get the item's field set |
|
869 CContactItemFieldSet& fieldSet=contactItem->CardFields(); |
|
870 // Search the field set for the given name field |
|
871 TInt index = fieldSet.Find( KUidContactFieldGivenName ); |
|
872 CContactItemField &field= fieldSet[index]; |
|
873 if( aItem.GetNextString ( NewContactName ) == KErrNone ) |
|
874 { |
|
875 field.TextStorage()->SetTextL( NewContactName ); |
|
876 // Commit the change back to database and clean up |
|
877 db->CommitContactL( *contactItem ); |
|
878 } |
|
879 CleanupStack::PopAndDestroy(contactItem); |
|
880 |
|
881 plugin->StartHarvestingL( _L(CONTACT_QBASEAPPCLASS) ); |
|
882 iPluginTester->iWaitForHarvester->Start(); |
|
883 error = doSearch( NewContactName, _L( CONTACT_QBASEAPPCLASS ), ESearchTypeResultsExpected ); |
|
884 db->DeleteContactL( aContactId ); |
|
885 } |
|
886 } |
|
887 if( IndexAction.Compare( KActionDelete ) == 0 ) |
|
888 { |
|
889 if( aItem.GetNextString ( ContactName ) == KErrNone ) |
|
890 { |
|
891 TInt aContactId; |
|
892 plugin->StartHarvestingL( _L(CONTACT_QBASEAPPCLASS)); |
|
893 //Add a contact to contactdatabase and later delete it |
|
894 aContactId = CreateNewContactL( *db, ContactName, _L("123455")); |
|
895 db->DeleteContactL(aContactId); |
|
896 iPluginTester->iWaitForHarvester->Start(); |
|
897 error = doSearch( ContactName, _L( CONTACT_QBASEAPPCLASS ), ESearchTypeResultsExpected ); |
|
898 //If the contact is succesfully deleted, make error to KErrNone.To show testcase success |
|
899 if(error == KErrNotFound) |
|
900 error = KErrNone; |
|
901 } |
|
902 } |
|
903 } |
|
904 |
|
905 delete db; |
|
906 delete plugin; |
|
907 delete iPluginTester; |
|
908 |
|
909 doLog( iLog, error, KSearchError ); |
|
910 return KErrNone; |
|
911 } |
|
912 TInt CHarvesterPluginTester::TestCreateContactGroupL( CStifItemParser& aItem ) |
|
913 { |
|
914 TInt error = KErrNone; |
|
915 _LIT( KSearchError, "Search Failed" ); |
|
916 TPtrC GroupName; |
|
917 CContactsPlugin* plugin = CContactsPlugin::NewL(); |
|
918 CHarvesterObserver* iPluginTester = CHarvesterObserver::NewL( plugin ); |
|
919 plugin->StartPluginL(); //start to moniter contacts db |
|
920 CContactDatabase* db = CContactDatabase::OpenL(); |
|
921 |
|
922 if( aItem.GetNextString ( GroupName ) == KErrNone ) |
|
923 { |
|
924 plugin->StartHarvestingL( _L(CONTACT_QBASEAPPCLASS) ); |
|
925 TInt aContactId = CreateNewContactL( *db, _L("Group Contact"), _L("123455") ); |
|
926 CContactItem* newitem = db->CreateContactGroupL( _L("TestGroup") ); |
|
927 db->AddContactToGroupL( aContactId, newitem->Id() ); |
|
928 iPluginTester->iWaitForHarvester->Start(); |
|
929 error = doSearch( GroupName, _L( CONTACT_QBASEAPPCLASS ), ESearchTypeResultsExpected ); |
|
930 db->DeleteContactL(aContactId); |
|
931 db->DeleteContactL( newitem->Id() ); |
|
932 } |
|
933 |
|
934 delete plugin; |
|
935 delete iPluginTester; |
|
936 delete db; |
|
937 doLog( iLog, error, KSearchError ); |
|
938 return KErrNone; |
|
939 } |
|
940 |
|
941 TInt CHarvesterPluginTester::TestStartCalenderHarvesterL( CStifItemParser& /*aItem*/ ) |
|
942 { |
|
943 CCalendarPlugin* plugin = CCalendarPlugin::NewL(); |
|
944 CHarvesterObserver* iPluginTester = CHarvesterObserver::NewL( plugin ); |
|
945 plugin->StartPluginL(); //start to moniter contacts db |
|
946 plugin->StartHarvestingL( _L(CALENDAR_QBASEAPPCLASS) ); |
|
947 iPluginTester->iWaitForHarvester->Start();//Wait here till Harvesting is complete. |
|
948 delete plugin; |
|
949 delete iPluginTester; |
|
950 doLog( iLog, KErrNone, KNoErrorString ); |
|
951 return KErrNone; |
|
952 } |
|
953 |
|
954 TInt CHarvesterPluginTester::TestCalenderEntryL( CStifItemParser& /*aItem*/ ) |
|
955 { |
|
956 TInt error = KErrNone; |
|
957 _LIT( KSearchError, "Search Failed" ); |
|
958 CCalendarPlugin* plugin = CCalendarPlugin::NewL(); |
|
959 CHarvesterObserver* iPluginTester = CHarvesterObserver::NewL( plugin ); |
|
960 plugin->StartPluginL(); |
|
961 |
|
962 CCalendarObserver* session = CCalendarObserver::NewL(); |
|
963 plugin->StartHarvestingL( _L(CALENDAR_QBASEAPPCLASS) ); |
|
964 // Add a calender entry |
|
965 session->AddEntryL(); |
|
966 iPluginTester->iWaitForHarvester->Start(); |
|
967 User::After((TTimeIntervalMicroSeconds32)30000000); |
|
968 error = doSearch( _L("scheduled"), _L( CALENDAR_QBASEAPPCLASS ), ESearchTypeResultsExpected ); |
|
969 doLog( iLog, error, KSearchError ); |
|
970 |
|
971 plugin->StartHarvestingL( _L(CALENDAR_QBASEAPPCLASS) ); |
|
972 session->DeleteEntryL(); |
|
973 iPluginTester->iWaitForHarvester->Start(); |
|
974 //Delete the calender entry added previously and search for result |
|
975 error = doSearch( _L("scheduled"), _L( CALENDAR_QBASEAPPCLASS ), ESearchTypeResultsExpected ); |
|
976 |
|
977 //If the entery is succesfully deleted, make error to KErrNone.To show testcase success |
|
978 if(error == KErrNotFound) |
|
979 error = KErrNone; |
|
980 |
|
981 delete session; |
|
982 delete plugin; |
|
983 delete iPluginTester; |
|
984 doLog( iLog, error, KSearchError ); |
|
985 return KErrNone; |
|
986 } |
|
987 |
|
988 TInt CHarvesterPluginTester::TestCreateMmsL( CStifItemParser& aItem ) |
|
989 { |
|
990 TInt error = KErrNone; |
|
991 _LIT( KSearchError, "Search Failed" ); |
|
992 TPtrC filepath; |
|
993 CMessagePlugin* plugin = CMessagePlugin::NewL(); |
|
994 CHarvesterObserver* iPluginTester = CHarvesterObserver::NewL( plugin ); |
|
995 plugin->StartPluginL(); |
|
996 CMessageSessionObserver* sessionobserver = CMessageSessionObserver::NewL(); |
|
997 CMsvSession* msgSession = CMsvSession::OpenSyncL(*sessionobserver); |
|
998 TInt found = aItem.GetNextString( filepath ); |
|
999 TBuf<KMsgPluginBaseAppClassMaxLen> baseAppClass; |
|
1000 TInt drive = msgSession->CurrentDriveL(); |
|
1001 CMessagePlugin::FormBaseAppClass(TDriveNumber(drive),baseAppClass); |
|
1002 |
|
1003 plugin->StartHarvestingL( baseAppClass ); |
|
1004 |
|
1005 //Create MMS with text attachment for UTF encoded data |
|
1006 TMsvId msgid = MessagingUtils::CreateMmsMessageL(msgSession, |
|
1007 _L("+358440067886"), |
|
1008 _L("+919845062437"), |
|
1009 filepath); |
|
1010 |
|
1011 iPluginTester->iWaitForHarvester->Start(); |
|
1012 |
|
1013 TInt count = SearchForTextL(_L("UTF"),baseAppClass,KNullDesC); |
|
1014 if(count <= 0) |
|
1015 { |
|
1016 error = KErrNotFound; |
|
1017 } |
|
1018 MessagingUtils::RemoveMmsEntryL( msgSession, msgid ); |
|
1019 delete plugin; |
|
1020 delete iPluginTester; |
|
1021 delete sessionobserver; |
|
1022 delete msgSession; |
|
1023 doLog(iLog,error,KSearchError); |
|
1024 return KErrNone; |
|
1025 } |
|
1026 |
|
1027 TInt CHarvesterPluginTester::TestCreateEmailL( CStifItemParser& /*aItem */) |
|
1028 { |
|
1029 TInt error = KErrNone; |
|
1030 _LIT( KSearchError, "Search Failed" ); |
|
1031 CMessagePlugin* plugin = CMessagePlugin::NewL(); |
|
1032 CHarvesterObserver* iPluginTester = CHarvesterObserver::NewL( plugin ); |
|
1033 plugin->StartPluginL(); |
|
1034 CMessageSessionObserver* sessionobserver = CMessageSessionObserver::NewL(); |
|
1035 CMsvSession* msgSession = CMsvSession::OpenSyncL( *sessionobserver ); |
|
1036 |
|
1037 TBuf<KMsgPluginBaseAppClassMaxLen> baseAppClass; |
|
1038 TInt drive = msgSession->CurrentDriveL(); |
|
1039 CMessagePlugin::FormBaseAppClass( TDriveNumber(drive), baseAppClass ); |
|
1040 plugin->StartHarvestingL( baseAppClass ); |
|
1041 //Create Email entry using SMTP client |
|
1042 TMsvId msgid = MessagingUtils::CreateEmailEntryL( msgSession ); |
|
1043 iPluginTester->iWaitForHarvester->Start(); |
|
1044 TInt count = SearchForTextL( _L("SampleEmail"), baseAppClass, KNullDesC ); |
|
1045 if(count <= 0) |
|
1046 { |
|
1047 error = KErrNotFound; |
|
1048 } |
|
1049 MessagingUtils::RemoveMmsEntryL( msgSession, msgid ); |
|
1050 delete plugin; |
|
1051 delete iPluginTester; |
|
1052 delete sessionobserver; |
|
1053 delete msgSession; |
|
1054 doLog(iLog,error,KSearchError); |
|
1055 return KErrNone; |
|
1056 } |
|
1057 |
|
1058 TInt CHarvesterPluginTester::TestAudioHarvestingL( CStifItemParser& /*aItem*/ ) |
|
1059 { |
|
1060 _LIT( KHarvesterPluginTester, "HarvesterPluginTester" ); |
|
1061 _LIT( KExample, "In TestAudioHarvestingL" ); |
|
1062 TInt error(KErrNone); |
|
1063 TestModuleIf().Printf( 0, KHarvesterPluginTester, KExample ); |
|
1064 // Print to log file |
|
1065 iLog->Log( KExample ); |
|
1066 CAudioPlugin* plugin = CAudioPlugin::NewL(); |
|
1067 CHarvesterObserver* iPluginTester = CHarvesterObserver::NewL( plugin ); |
|
1068 plugin->StartPluginL(); //Initialize the Plugin |
|
1069 //Copy file path |
|
1070 RFs fileSession; |
|
1071 fileSession.Connect(); |
|
1072 _LIT(KPathToMusic,"c:\\data\\music\\"); |
|
1073 fileSession.Delete(_L("c:\\data\\music\\Eagle_Landed.mp3")); //Delete if already exist |
|
1074 //pause harvester while copy |
|
1075 RHarvesterClient harvester; |
|
1076 User::LeaveIfError(harvester.Connect() ); |
|
1077 harvester.Pause(); |
|
1078 TRAP_IGNORE( BaflUtils::EnsurePathExistsL(fileSession,KPathToMusic) );//Create folder |
|
1079 BaflUtils::CopyFile(fileSession,_L("c:\\data\\Eagle_Landed.mp3"),KPathToMusic); |
|
1080 //Resume harvester for this harvesting |
|
1081 harvester.Resume(); |
|
1082 harvester.Close(); |
|
1083 //Do harvesting and search for Eagle it should be available |
|
1084 plugin->StartHarvestingL(_L(MEDIA_QBASEAPPCLASS)); |
|
1085 //Wait for one minutes after doc processing to Index and Flush to happen |
|
1086 iPluginTester->SetWaitTime((TTimeIntervalMicroSeconds32)60000000); |
|
1087 iPluginTester->iWaitForHarvester->Start(); //Start Wait AO and let it complete |
|
1088 TInt count = SearchForTextL(_L("Eagle"),_L(MEDIA_QBASEAPPCLASS),KNullDesC); |
|
1089 if(count <= 0) |
|
1090 { |
|
1091 error = KErrNotFound; |
|
1092 } |
|
1093 doLog(iLog,error,_L("Error in TestAudioHarvestingL")); |
|
1094 delete plugin; |
|
1095 delete iPluginTester; |
|
1096 fileSession.Close(); |
|
1097 //End search |
|
1098 return error; |
|
1099 } |
|
1100 |
|
1101 TInt CHarvesterPluginTester::TestMdsSyncControllerL( CStifItemParser& /*aItem*/ ) |
|
1102 { |
|
1103 _LIT( KHarvesterPluginTester, "HarvesterPluginTester" ); |
|
1104 _LIT( KExample, "In TestMdsSyncControllerL" ); |
|
1105 TInt error(KErrNone); |
|
1106 TestModuleIf().Printf( 0, KHarvesterPluginTester, KExample ); |
|
1107 // Print to log file |
|
1108 iLog->Log( KExample ); |
|
1109 CMDSEntity* entity; |
|
1110 CCPIXMDEDbManager* dbcontroller; |
|
1111 entity = CMDSEntity::NewL(); |
|
1112 TUid uid = {0x101FB3E3}; |
|
1113 dbcontroller = CCPIXMDEDbManager::NewL(uid); |
|
1114 entity->Setkey(1); |
|
1115 entity->SetUri(_L("\\music\\bhuvnesh.mp3")); |
|
1116 TDriveNumber drive = TDriveNumber(EDriveC); |
|
1117 entity->SetDrive(drive); |
|
1118 dbcontroller->AddL(entity->Key(),*entity); |
|
1119 error = dbcontroller->IsAlreadyExistL(entity->Key()); |
|
1120 if( error ) |
|
1121 { |
|
1122 iLog->Log( _L("Already exist") ); |
|
1123 } |
|
1124 entity->Reset(); |
|
1125 dbcontroller->GetItemL(1,*entity); |
|
1126 dbcontroller->RemoveL(entity->Key()); |
|
1127 error = dbcontroller->IsAlreadyExistL( entity->Key() ); |
|
1128 if( error ) |
|
1129 { |
|
1130 iLog->Log( _L("Already exist") ); |
|
1131 } |
|
1132 dbcontroller->ResetL(); |
|
1133 delete entity; |
|
1134 delete dbcontroller; |
|
1135 return error; |
|
1136 } |
|
1137 |
|
1138 TInt CHarvesterPluginTester::TestBlacklistPluginL( CStifItemParser& /*aItem*/ ) |
|
1139 { |
|
1140 //@todo: This test case shoud be in IDS middleware harvester STIF cases |
|
1141 TInt err = KErrNone; |
|
1142 /* |
|
1143 CBlacklistMgr* blacklistmanager = CBlacklistMgr::NewL(); |
|
1144 CleanupStack::PushL( blacklistmanager ); |
|
1145 TInt version = 0; |
|
1146 aItem.GetNextInt(version); |
|
1147 //Add an Uid to Blacklist DB |
|
1148 blacklistmanager->AddL( KTestUid , version ); |
|
1149 //Check if the Uid is added to database or not |
|
1150 TBool found = blacklistmanager->FindL(KTestUid , version ); |
|
1151 |
|
1152 if(!found) err = KErrNotFound; |
|
1153 //clear the UID from the database |
|
1154 blacklistmanager->Remove(KTestUid); |
|
1155 CleanupStack::PopAndDestroy( blacklistmanager ); |
|
1156 doLog( iLog, err, KNoErrorString ); |
|
1157 */ |
|
1158 return err; |
|
1159 } |
|
1160 |
|
1161 TInt CHarvesterPluginTester::TestBlacklistPluginVersionL( CStifItemParser& /*aItem*/ ) |
|
1162 { |
|
1163 //@todo: This test case shoud be in IDS middleware harvester STIF cases |
|
1164 TInt err = KErrNone; |
|
1165 /* |
|
1166 CBlacklistMgr* blacklistmanager = CBlacklistMgr::NewL(); |
|
1167 CleanupStack::PushL( blacklistmanager ); |
|
1168 TInt oldversion = 0; |
|
1169 TInt newversion = 0; |
|
1170 aItem.GetNextInt(oldversion); |
|
1171 aItem.GetNextInt(newversion); |
|
1172 //Add an Uid to Blacklist DB with old version |
|
1173 blacklistmanager->AddL( KTestUid , oldversion ); |
|
1174 //Add an Uid to Blacklist DB with new version |
|
1175 blacklistmanager->AddL( KTestUid , newversion ); |
|
1176 //Check if the Uid with old version exists |
|
1177 TBool found = blacklistmanager->FindL(KTestUid , oldversion ); |
|
1178 if( found ) |
|
1179 { |
|
1180 err = KErrNotFound; |
|
1181 } |
|
1182 else |
|
1183 { |
|
1184 //check with new version |
|
1185 found = blacklistmanager->FindL(KTestUid , newversion ); |
|
1186 if(!found) err = KErrNotFound; |
|
1187 } |
|
1188 //clear the UID from the database |
|
1189 blacklistmanager->Remove(KTestUid); |
|
1190 CleanupStack::PopAndDestroy( blacklistmanager ); |
|
1191 doLog( iLog, err, KNoErrorString );*/ |
|
1192 return err; |
|
1193 } |
|
1194 TInt CHarvesterPluginTester::TestVideoHarvestingIndexL( CStifItemParser& aItem ) |
|
1195 { |
|
1196 TInt error = KErrNone; |
|
1197 TPtrC filepath; |
|
1198 TPtrC filename; |
|
1199 TPtrC newFile; |
|
1200 CVideoPlugin* plugin = CVideoPlugin::NewL(); |
|
1201 CHarvesterObserver* iPluginTester = CHarvesterObserver::NewL( plugin ); |
|
1202 plugin->StartPluginL(); |
|
1203 RFs fSession; |
|
1204 fSession.Connect(); |
|
1205 CleanupClosePushL( fSession ); |
|
1206 if((aItem.GetNextString(filepath)==KErrNone) && (aItem.GetNextString(filename) == KErrNone)) |
|
1207 { |
|
1208 TBuf<KMaxFileName> desPath(_L("c:\\data\\Videos\\")); |
|
1209 desPath.Append( filename ); |
|
1210 //Delete the file if it already exists |
|
1211 fSession.Delete( desPath ); |
|
1212 //To ensure video plugin is loaded, pause the harvester |
|
1213 RHarvesterClient harvester; |
|
1214 User::LeaveIfError(harvester.Connect()); |
|
1215 harvester.Pause(); |
|
1216 BaflUtils::EnsurePathExistsL( fSession, desPath );//Create folder |
|
1217 BaflUtils::CopyFile( fSession, filepath, desPath ); |
|
1218 //Resume harvester for this harvesting |
|
1219 harvester.Resume(); |
|
1220 harvester.Close(); |
|
1221 //Now start video plugin harvesting |
|
1222 plugin->StartHarvestingL( _L(VIDEO_QBASEAPPCLASS) ); |
|
1223 //wait for index to flush |
|
1224 iPluginTester->SetWaitTime( (TTimeIntervalMicroSeconds32)60000000 ); |
|
1225 //wait till video harvesting completes |
|
1226 iPluginTester->iWaitForHarvester->Start(); |
|
1227 TInt count = SearchForTextL( filename, _L(VIDEO_QBASEAPPCLASS), KNullDesC ); |
|
1228 if(count <= 0) |
|
1229 { |
|
1230 error = KErrNotFound; |
|
1231 } |
|
1232 } |
|
1233 else |
|
1234 error = KErrNotFound; |
|
1235 CleanupStack::PopAndDestroy(); |
|
1236 delete plugin; |
|
1237 delete iPluginTester; |
|
1238 doLog( iLog, error, _L("Error in TestVideoHarvestingIndexL") ); |
|
1239 return error; |
|
1240 } |
|
1241 |
|
1242 TInt CHarvesterPluginTester::TestVideoHarvestingUpdateIndexL( CStifItemParser& aItem ) |
|
1243 { |
|
1244 TInt error = KErrNone; |
|
1245 TPtrC filepath; |
|
1246 TPtrC filename; |
|
1247 TPtrC newFile; |
|
1248 TBuf<KMaxFileName> srcPath(_L("c:\\data\\Videos\\")); |
|
1249 TBuf<KMaxFileName> desPath; |
|
1250 desPath.Copy( srcPath ); |
|
1251 CVideoPlugin* plugin = CVideoPlugin::NewL(); |
|
1252 CHarvesterObserver* iPluginTester = CHarvesterObserver::NewL( plugin ); |
|
1253 plugin->StartPluginL(); |
|
1254 RFs fSession; |
|
1255 fSession.Connect(); |
|
1256 CleanupClosePushL( fSession ); |
|
1257 if((aItem.GetNextString(filepath)==KErrNone) && (aItem.GetNextString(filename) == KErrNone)) |
|
1258 { |
|
1259 srcPath.Append( filename ); |
|
1260 if( aItem.GetNextString(newFile) == KErrNone ) |
|
1261 { |
|
1262 desPath.Append( newFile ); |
|
1263 RHarvesterClient harvester; |
|
1264 User::LeaveIfError(harvester.Connect()); |
|
1265 harvester.Pause(); |
|
1266 TBool fileExist = BaflUtils::FileExists( fSession, srcPath ); |
|
1267 if(!fileExist) |
|
1268 { |
|
1269 BaflUtils::EnsurePathExistsL( fSession, srcPath );//Create folder |
|
1270 BaflUtils::CopyFile( fSession, filepath, srcPath ); |
|
1271 } |
|
1272 BaflUtils::RenameFile( fSession, srcPath, desPath ); |
|
1273 harvester.Resume(); |
|
1274 harvester.Close(); |
|
1275 plugin->StartHarvestingL( _L(VIDEO_QBASEAPPCLASS) ); |
|
1276 //wait for index to flush |
|
1277 iPluginTester->SetWaitTime( (TTimeIntervalMicroSeconds32)60000000 ); |
|
1278 //wait till video harvesting completes |
|
1279 iPluginTester->iWaitForHarvester->Start(); |
|
1280 TInt count = SearchForTextL(_L("Falls"), _L(VIDEO_QBASEAPPCLASS), KNullDesC ); |
|
1281 if(count <= 0) |
|
1282 { |
|
1283 error = KErrNotFound; |
|
1284 } |
|
1285 doLog( iLog, error, _L("Error in TestVideoHarvestingUpdateIndexL") ); |
|
1286 } |
|
1287 } |
|
1288 else |
|
1289 doLog( iLog, KErrNotFound, _L("Error in TestVideoHarvestingUpdateIndexL") ); |
|
1290 CleanupStack::PopAndDestroy(); |
|
1291 delete plugin; |
|
1292 delete iPluginTester; |
|
1293 return error; |
|
1294 } |
|
1295 |
|
1296 TInt CHarvesterPluginTester::TestVideoHarvestingDeleteIndexL( CStifItemParser& aItem ) |
|
1297 { |
|
1298 TInt error = KErrNone; |
|
1299 TPtrC filepath; |
|
1300 TPtrC filename; |
|
1301 TBuf<KMaxFileName> srcPath(_L("c:\\data\\Videos\\")); |
|
1302 CVideoPlugin* plugin = CVideoPlugin::NewL(); |
|
1303 CHarvesterObserver* iPluginTester = CHarvesterObserver::NewL( plugin ); |
|
1304 plugin->StartPluginL(); |
|
1305 RFs fSession; |
|
1306 fSession.Connect(); |
|
1307 CleanupClosePushL( fSession ); |
|
1308 if((aItem.GetNextString(filepath)==KErrNone) && (aItem.GetNextString(filename) == KErrNone)) |
|
1309 { |
|
1310 srcPath.Append( filename ); |
|
1311 RHarvesterClient harvester; |
|
1312 User::LeaveIfError(harvester.Connect()); |
|
1313 harvester.Pause(); |
|
1314 TBool fileExist = BaflUtils::FileExists( fSession, srcPath ); |
|
1315 if(!fileExist) |
|
1316 { |
|
1317 BaflUtils::EnsurePathExistsL( fSession, srcPath );//Create folder |
|
1318 BaflUtils::CopyFile( fSession, filepath, srcPath ); |
|
1319 } |
|
1320 BaflUtils::DeleteFile( fSession, srcPath ); |
|
1321 harvester.Resume(); |
|
1322 harvester.Close(); |
|
1323 plugin->StartHarvestingL( _L(VIDEO_QBASEAPPCLASS) ); |
|
1324 //wait for index to flush |
|
1325 iPluginTester->SetWaitTime( (TTimeIntervalMicroSeconds32)60000000 ); |
|
1326 //wait till video harvesting completes |
|
1327 iPluginTester->iWaitForHarvester->Start(); |
|
1328 TInt count = SearchForTextL(_L("Niagara"), _L(VIDEO_QBASEAPPCLASS), KNullDesC ); |
|
1329 if(count <= 0) |
|
1330 { |
|
1331 // If the search is not found,then testcase is success |
|
1332 doLog( iLog, error, _L("Error in TestVideoHarvestingDeleteIndexL") ); |
|
1333 } |
|
1334 } |
|
1335 else |
|
1336 doLog( iLog, KErrNotFound, _L("Error in TestVideoHarvestingDeleteIndexL") ); |
|
1337 CleanupStack::PopAndDestroy(); |
|
1338 delete plugin; |
|
1339 delete iPluginTester; |
|
1340 return error; |
|
1341 } |
|
1342 |
|
1343 TInt CHarvesterPluginTester::TestImageHarvestingAddIndexL( CStifItemParser& aItem ) |
|
1344 { |
|
1345 TInt error = KErrNone; |
|
1346 TPtrC filepath; |
|
1347 TPtrC filename; |
|
1348 TPtrC newFile; |
|
1349 CImagePlugin* plugin = CImagePlugin::NewL(); |
|
1350 CHarvesterObserver* iPluginTester = CHarvesterObserver::NewL( plugin ); |
|
1351 plugin->StartPluginL(); |
|
1352 RFs fSession; |
|
1353 fSession.Connect(); |
|
1354 CleanupClosePushL( fSession ); |
|
1355 if((aItem.GetNextString(filepath)==KErrNone) && (aItem.GetNextString(filename) == KErrNone)) |
|
1356 { |
|
1357 TBuf<KMaxFileName> desPath(_L("c:\\data\\Images\\")); |
|
1358 desPath.Append( filename ); |
|
1359 //Delete the file if it already exists |
|
1360 fSession.Delete( desPath ); |
|
1361 //To ensure video plugin is loaded, pause the harvester |
|
1362 RHarvesterClient harvester; |
|
1363 User::LeaveIfError(harvester.Connect()); |
|
1364 harvester.Pause(); |
|
1365 BaflUtils::EnsurePathExistsL( fSession, desPath );//Create folder |
|
1366 BaflUtils::CopyFile( fSession, filepath, desPath ); |
|
1367 //Resume harvester for this harvesting |
|
1368 harvester.Resume(); |
|
1369 harvester.Close(); |
|
1370 //Now start video plugin harvesting |
|
1371 plugin->StartHarvestingL( _L(IMAGE_QBASEAPPCLASS) ); |
|
1372 //wait for index to flush |
|
1373 iPluginTester->SetWaitTime( (TTimeIntervalMicroSeconds32)60000000 ); |
|
1374 iPluginTester->iWaitForHarvester->Start(); |
|
1375 TInt count = SearchForTextL( filename, _L(IMAGE_QBASEAPPCLASS), KNullDesC ); |
|
1376 if(count <= 0) |
|
1377 { |
|
1378 error = KErrNotFound; |
|
1379 } |
|
1380 } |
|
1381 else |
|
1382 error = KErrNotFound; |
|
1383 doLog( iLog, error, _L("Error in TestImageHarvestingAddIndexL") ); |
|
1384 CleanupStack::PopAndDestroy(); |
|
1385 delete plugin; |
|
1386 delete iPluginTester; |
|
1387 return error; |
|
1388 } |
|
1389 |
|
1390 TInt CHarvesterPluginTester::TestImageHarvestingUpdateIndexL( CStifItemParser& aItem ) |
|
1391 { |
|
1392 TInt error = KErrNone; |
|
1393 TPtrC filepath; |
|
1394 TPtrC filename; |
|
1395 TPtrC newFile; |
|
1396 TBuf<KMaxFileName> srcPath(_L("c:\\data\\Images\\")); |
|
1397 TBuf<KMaxFileName> desPath; |
|
1398 desPath.Copy( srcPath ); |
|
1399 CImagePlugin* plugin = CImagePlugin::NewL(); |
|
1400 CHarvesterObserver* iPluginTester = CHarvesterObserver::NewL( plugin ); |
|
1401 plugin->StartPluginL(); |
|
1402 RFs fSession; |
|
1403 fSession.Connect(); |
|
1404 CleanupClosePushL( fSession ); |
|
1405 if((aItem.GetNextString(filepath)==KErrNone) && (aItem.GetNextString(filename) == KErrNone)) |
|
1406 { |
|
1407 srcPath.Append( filename ); |
|
1408 if( aItem.GetNextString(newFile) == KErrNone ) |
|
1409 { |
|
1410 desPath.Append( newFile ); |
|
1411 RHarvesterClient harvester; |
|
1412 User::LeaveIfError(harvester.Connect()); |
|
1413 harvester.Pause(); |
|
1414 TBool fileExist = BaflUtils::FileExists( fSession, srcPath ); |
|
1415 if(!fileExist) |
|
1416 { |
|
1417 BaflUtils::EnsurePathExistsL( fSession, srcPath );//Create folder |
|
1418 BaflUtils::CopyFile( fSession, filepath, srcPath ); |
|
1419 } |
|
1420 BaflUtils::RenameFile( fSession, srcPath, desPath ); |
|
1421 harvester.Resume(); |
|
1422 harvester.Close(); |
|
1423 plugin->StartHarvestingL( _L(IMAGE_QBASEAPPCLASS) ); |
|
1424 //wait for index to flush |
|
1425 iPluginTester->SetWaitTime( (TTimeIntervalMicroSeconds32)60000000 ); |
|
1426 iPluginTester->iWaitForHarvester->Start(); |
|
1427 TInt count = SearchForTextL(_L("Portrait"), _L(IMAGE_QBASEAPPCLASS), KNullDesC ); |
|
1428 if(count <= 0) |
|
1429 { |
|
1430 error = KErrNotFound; |
|
1431 } |
|
1432 doLog( iLog, error, _L("Error in TestImageHarvestingUpdateIndexL") ); |
|
1433 } |
|
1434 } |
|
1435 else |
|
1436 doLog( iLog, KErrNotFound, _L("Error in TestImageHarvestingUpdateIndexL") ); |
|
1437 CleanupStack::PopAndDestroy(); |
|
1438 delete plugin; |
|
1439 delete iPluginTester; |
|
1440 return error; |
|
1441 } |
|
1442 |
|
1443 TInt CHarvesterPluginTester::TestImageHarvestingDeleteIndexL( CStifItemParser& aItem ) |
|
1444 { |
|
1445 TInt error = KErrNone; |
|
1446 TPtrC filepath; |
|
1447 TPtrC filename; |
|
1448 TBuf<KMaxFileName> srcPath(_L("c:\\data\\Images\\")); |
|
1449 CImagePlugin* plugin = CImagePlugin::NewL(); |
|
1450 CHarvesterObserver* iPluginTester = CHarvesterObserver::NewL( plugin ); |
|
1451 plugin->StartPluginL(); |
|
1452 RFs fSession; |
|
1453 fSession.Connect(); |
|
1454 CleanupClosePushL( fSession ); |
|
1455 if((aItem.GetNextString(filepath)==KErrNone) && (aItem.GetNextString(filename) == KErrNone)) |
|
1456 { |
|
1457 srcPath.Append( filename ); |
|
1458 RHarvesterClient harvester; |
|
1459 User::LeaveIfError(harvester.Connect()); |
|
1460 harvester.Pause(); |
|
1461 TBool fileExist = BaflUtils::FileExists( fSession, srcPath ); |
|
1462 if(!fileExist) |
|
1463 { |
|
1464 BaflUtils::EnsurePathExistsL( fSession, srcPath );//Create folder |
|
1465 BaflUtils::CopyFile( fSession, filepath, srcPath ); |
|
1466 } |
|
1467 BaflUtils::DeleteFile( fSession, srcPath ); |
|
1468 harvester.Resume(); |
|
1469 harvester.Close(); |
|
1470 plugin->StartHarvestingL( _L(IMAGE_QBASEAPPCLASS) ); |
|
1471 //wait for index to flush |
|
1472 iPluginTester->SetWaitTime( (TTimeIntervalMicroSeconds32)60000000 ); |
|
1473 //wait till image harvesting completes |
|
1474 iPluginTester->iWaitForHarvester->Start(); |
|
1475 TInt count = SearchForTextL(_L("Square"), _L(IMAGE_QBASEAPPCLASS), KNullDesC ); |
|
1476 if(count <= 0) |
|
1477 { |
|
1478 // If the search is not found,then testcase is success |
|
1479 doLog( iLog, error, _L("Error in TestImageHarvestingDeleteIndexL") ); |
|
1480 } |
|
1481 } |
|
1482 else |
|
1483 doLog( iLog, KErrNotFound, _L("Error in TestImageHarvestingDeleteIndexL") ); |
|
1484 CleanupStack::PopAndDestroy(); |
|
1485 delete plugin; |
|
1486 delete iPluginTester; |
|
1487 return error; |
|
1488 } |
|
1489 |
|
1490 TInt CHarvesterPluginTester::TestAudioMMCEventL( CStifItemParser& aItem ) |
|
1491 { |
|
1492 TInt error(KErrNone); |
|
1493 TInt drive; |
|
1494 TInt mmcstatus; |
|
1495 aItem.GetNextInt ( drive ); |
|
1496 aItem.GetNextInt ( mmcstatus ); |
|
1497 CAudioPlugin* plugin = CAudioPlugin::NewL(); |
|
1498 CHarvesterObserver* iPluginTester = CHarvesterObserver::NewL( plugin ); |
|
1499 plugin->StartPluginL(); //Initialize the Plugin |
|
1500 TRAPD( err , plugin->HandleMMCEventL( (TDriveNumber)drive , mmcstatus) ); |
|
1501 //iPluginTester->iWaitForHarvester->Start(); //Start Wait AO and let it complete |
|
1502 doLog(iLog,error,_L("Error in TestAudioMMCEventL")); |
|
1503 delete plugin; |
|
1504 delete iPluginTester; |
|
1505 //End search |
|
1506 return err; |
|
1507 } |
|
1508 |
|
1509 TInt CHarvesterPluginTester::TestVideoMMCEventL( CStifItemParser& aItem ) |
|
1510 { |
|
1511 TInt error(KErrNone); |
|
1512 TInt drive; |
|
1513 TInt mmcstatus; |
|
1514 aItem.GetNextInt ( drive ); |
|
1515 aItem.GetNextInt ( mmcstatus ); |
|
1516 CVideoPlugin* plugin = CVideoPlugin::NewL(); |
|
1517 CHarvesterObserver* iPluginTester = CHarvesterObserver::NewL( plugin ); |
|
1518 plugin->StartPluginL(); //Initialize the Plugin |
|
1519 TRAPD( err , plugin->HandleMMCEventL( (TDriveNumber)drive , mmcstatus) ); |
|
1520 //iPluginTester->iWaitForHarvester->Start(); //Start Wait AO and let it complete |
|
1521 doLog(iLog,error,_L("Error in TestVideoMMCEventL")); |
|
1522 delete plugin; |
|
1523 delete iPluginTester; |
|
1524 //End search |
|
1525 return err; |
|
1526 } |
|
1527 |
|
1528 TInt CHarvesterPluginTester::TestImageMMCEventL( CStifItemParser& aItem ) |
|
1529 { |
|
1530 TInt error(KErrNone); |
|
1531 TInt drive; |
|
1532 TInt mmcstatus; |
|
1533 aItem.GetNextInt ( drive ); |
|
1534 aItem.GetNextInt ( mmcstatus ); |
|
1535 CImagePlugin* plugin = CImagePlugin::NewL(); |
|
1536 CHarvesterObserver* iPluginTester = CHarvesterObserver::NewL( plugin ); |
|
1537 plugin->StartPluginL(); //Initialize the Plugin |
|
1538 TRAPD( err , plugin->HandleMMCEventL( (TDriveNumber)drive , mmcstatus) ); |
|
1539 //iPluginTester->iWaitForHarvester->Start(); //Start Wait AO and let it complete |
|
1540 doLog(iLog,error,_L("Error in TestImageMMCEventL")); |
|
1541 delete plugin; |
|
1542 delete iPluginTester; |
|
1543 //End search |
|
1544 return err; |
|
1545 } |
|
1546 |
|
1547 // [End of File] - Do not remove |