harvesterplugins/tsrc/harvesterplugintester/src/harvesterplugintesterblocks.cpp
changeset 17 7d8c8d8f5eab
parent 12 993ab30e92fc
child 20 68cdadcf169e
--- a/harvesterplugins/tsrc/harvesterplugintester/src/harvesterplugintesterblocks.cpp	Tue Jul 06 14:17:22 2010 +0300
+++ b/harvesterplugins/tsrc/harvesterplugintester/src/harvesterplugintesterblocks.cpp	Wed Aug 18 09:49:49 2010 +0300
@@ -45,11 +45,14 @@
 #include <harvesterclient.h>
 #include "mdsitementity.h"
 #include "cpixmdedbmanager.h"
+#include "cpixindexerutils.h"
 #include "cfolderrenamedharvester.h"
 #include "videoplugin.h"
 #include "imageplugin.h"
 #include "cemailplugin.h"
 #include "cmessagedatahandler.h"
+#include <common.h>
+
 _LIT(KAppBasePath,"@c:root file content");
 _LIT(KEmailAppBasePath,"@c:root msg email");
 _LIT(KAppBaseFolderFilePath,"@c:root file folder");
@@ -125,7 +128,12 @@
         ENTRY( "TestAddLongNoteL", CHarvesterPluginTester::TestAddLongNoteL ),
         ENTRY( "TestAddAlphaNumericNoteL", CHarvesterPluginTester::TestAddAlphaNumericNoteL ),
         ENTRY( "TestDeleteNoteL", CHarvesterPluginTester::TestDeleteNoteL ),
-        ENTRY( "TestUpdateNoteL", CHarvesterPluginTester::TestUpdateNoteL ),                
+        ENTRY( "TestUpdateNoteL", CHarvesterPluginTester::TestUpdateNoteL ),
+        ENTRY( "TestNotesEntryNegative", CHarvesterPluginTester::TestNotesEntryNegativeL ),
+        ENTRY( "TestNotesDestructor", CHarvesterPluginTester::TestNotesDestructorL ),
+        ENTRY( "TestNotesDelayedError", CHarvesterPluginTester::TestNotesDelayedErrorL ),
+        ENTRY( "TestNotesChangeEntry", CHarvesterPluginTester::TestNotesChangeEntryL),
+        ENTRY( "TestNotesEntryNoIndexer", CHarvesterPluginTester::TestNotesEntryNoIndexerL),
         ENTRY( "TestContactsHarvesting", CHarvesterPluginTester::TestStartContactsHarvesterL ),
         ENTRY( "TestCreateContactIndexItemL_Add", CHarvesterPluginTester::TestCreateContactIndexItemL ),
         ENTRY( "TestCreateAllContactFields", CHarvesterPluginTester::TestCreateAllContactFieldsL ),
@@ -140,25 +148,33 @@
         ENTRY( "TestCreateContactGroup", CHarvesterPluginTester::TestCreateContactGroupL ),
         ENTRY( "TestCalenderHarvesting", CHarvesterPluginTester::TestStartCalenderHarvesterL ),
         ENTRY( "TestCalenderEntry",CHarvesterPluginTester::TestCalenderEntryL ),
-        ENTRY( "TestCreateMMS",CHarvesterPluginTester::TestCreateMmsL ),
+        ENTRY( "TestCreateMMS",CHarvesterPluginTester::TestCreateMmsL ),        
+        ENTRY( "Testcalenderdestructor",CHarvesterPluginTester::TestcalenderdestructorL ),
+        ENTRY( "TestCalChangeEntry",CHarvesterPluginTester::TestCalChangeEntryL ),
+        ENTRY( "TestCalCreateEntry",CHarvesterPluginTester::TestCalCreateEntryL ),
         ENTRY( "TestCreateEmail",CHarvesterPluginTester::TestCreateEmailL ),
-		ENTRY( "TestAudioHarvesting",CHarvesterPluginTester::TestAudioHarvestingL ),
-        ENTRY( "TestAudioHarvestingUpdateIndex",CHarvesterPluginTester::TestAudioHarvestingUpdateIndexL ),
-        ENTRY( "TestAudioHarvestingDeleteIndex",CHarvesterPluginTester::TestAudioHarvestingDeleteIndexL ),
+		ENTRY( "TestAudioHarvesting",CHarvesterPluginTester::TestAudioHarvestingL ),        
 		ENTRY( "TestMdsSyncController",CHarvesterPluginTester::TestMdsSyncControllerL ),
+		ENTRY( "TestAudioHandleItem",CHarvesterPluginTester::TestAudioHandleItemL ),
+		ENTRY( "TestAudioSyncDbManager",CHarvesterPluginTester::TestAudioSyncDbManagerL ),
+        ENTRY( "TestAudioMMCEventL",CHarvesterPluginTester::TestAudioMMCEventL ),
+        ENTRY( "TestAudioNoIndexer",CHarvesterPluginTester::TestAudioNoIndexerL ),
 		//ENTRY( "TestBlacklistPlugin",CHarvesterPluginTester::TestBlacklistPluginL ),
 		//ENTRY( "TestBlacklistPluginVersion",CHarvesterPluginTester::TestBlacklistPluginVersionL ),
-		ENTRY( "TestVideoHarvestingIndex",CHarvesterPluginTester::TestVideoHarvestingIndexL ),		
-		ENTRY( "TestVideoHarvestingUpdateIndex",CHarvesterPluginTester::TestVideoHarvestingUpdateIndexL ),
-		ENTRY( "TestVideoHarvestingDeleteIndex",CHarvesterPluginTester::TestVideoHarvestingDeleteIndexL ),
-		ENTRY( "TestImageHarvestingAddIndex",CHarvesterPluginTester::TestImageHarvestingAddIndexL ),
-		ENTRY( "TestImageHarvestingUpdateIndex",CHarvesterPluginTester::TestImageHarvestingUpdateIndexL ),
-		ENTRY( "TestImageHarvestingDeleteIndex",CHarvesterPluginTester::TestImageHarvestingDeleteIndexL ),
-		ENTRY( "TestAudioMMCEventL",CHarvesterPluginTester::TestAudioMMCEventL ),
-		ENTRY( "TestVideoMMCEventL",CHarvesterPluginTester::TestVideoMMCEventL ),
+		ENTRY( "TestVideoHarvesting",CHarvesterPluginTester::TestVideoHarvestingL ),		
+        ENTRY( "TestVideoHandleItem",CHarvesterPluginTester::TestVideoHandleItemL ),
+		ENTRY( "TestVideoSyncDbManager",CHarvesterPluginTester::TestVideoSyncDbManagerL ),
+        ENTRY( "TestVideoMMCEventL",CHarvesterPluginTester::TestVideoMMCEventL ),
+        ENTRY( "TestVideoNoIndexer",CHarvesterPluginTester::TestVideoNoIndexerL ),
+		ENTRY( "TestImageHarvesting",CHarvesterPluginTester::TestImageHarvestingL ),				
+		ENTRY( "TestImageHandleItem",CHarvesterPluginTester::TestImageHandleItemL ),
+		ENTRY( "TestImageSyncDbManager",CHarvesterPluginTester::TestImageSyncDbManagerL ),
 		ENTRY( "TestImageMMCEventL",CHarvesterPluginTester::TestImageMMCEventL ),
+		ENTRY( "TestImageNoIndexer",CHarvesterPluginTester::TestImageNoIndexerL ),
 		ENTRY( "TestStartEmailPlugin",CHarvesterPluginTester::TestStartEmailPluginL ),
 		ENTRY( "TestHandleEmailDoc",CHarvesterPluginTester::TestHandleEmailDocL ),
+		ENTRY( "TestEmailBaseappclass",CHarvesterPluginTester::TestEmailBaseappclassL ),
+		ENTRY( "TestEmailHandleDoc",CHarvesterPluginTester::TestEmailHandleDocL ),
         //ADD NEW ENTRY HERE
         // [test cases entries] - Do not remove
         };
@@ -835,6 +851,7 @@
         {
         DocumentCount = searcher->SearchL(aQueryString, aDefaultField);
         }
+    session.Close();
     return DocumentCount;
     }
 
@@ -1043,7 +1060,7 @@
     return error;
     }
 
-TInt CHarvesterPluginTester::TestDeleteNoteL( CStifItemParser& aItem )
+TInt CHarvesterPluginTester::TestDeleteNoteL( CStifItemParser& /*aItem */)
     {	
     TInt error = KErrNone;
     _LIT( KSearchError, "Search Failed" );   
@@ -1053,9 +1070,10 @@
     
     CCalendarObserver* session = CCalendarObserver::NewL();
     plugin->StartHarvestingL( _L(NOTES_QBASEAPPCLASS) );
+    session->DeleteNoteEntryL();
     iPluginTester->iWaitForHarvester->Start();
     // Add a Note entry
-    TPtrC searchstring;
+    /*TPtrC searchstring;
     error = aItem.GetNextString( searchstring );
     HBufC8* buf8 = HBufC8::NewL(2*searchstring.Length());
     buf8->Des().Copy(searchstring);
@@ -1073,7 +1091,7 @@
         //If the entery is succesfully deleted, make error to KErrNone.To show testcase success
         if(error == KErrNotFound)
             error = KErrNone;    
-        }
+        }*/
     delete session;
     delete plugin;
     delete iPluginTester;
@@ -1125,6 +1143,76 @@
     return error;    
     }
 
+TInt CHarvesterPluginTester::TestNotesEntryNegativeL( CStifItemParser& /*aItem*/ )
+    {   
+    CNotesPlugin* plugin = CNotesPlugin::NewL();
+    CHarvesterObserver* iPluginTester = CHarvesterObserver::NewL( plugin );
+    plugin->StartPluginL();
+    plugin->StartHarvestingL( _L(NOTES_QBASEAPPCLASS) );
+    iPluginTester->iWaitForHarvester->Start();//Wait here till Harvesting is complete.
+    plugin->CreateNoteEntryL(0, ECPixUpdateAction);
+    delete plugin;
+    delete iPluginTester;
+    iPluginTester = NULL;
+    doLog( iLog, KErrNone, KNoErrorString );    
+    return KErrNone;
+    }
+
+TInt CHarvesterPluginTester::TestNotesDestructorL( CStifItemParser& /*aItem*/ )
+    {
+    CNotesPlugin* plugin = CNotesPlugin::NewL();    
+    plugin->iAsynchronizer->CancelCallback();
+    plugin->iAsynchronizer = NULL;
+    plugin->iSession->StopChangeNotification();
+    plugin->iSession = NULL;
+    delete plugin;
+    return KErrNone;
+    }
+
+TInt CHarvesterPluginTester::TestNotesDelayedErrorL( CStifItemParser& /*aItem*/ )
+    {
+    CNotesPlugin* plugin = CNotesPlugin::NewL();
+    CHarvesterObserver* iPluginTester = CHarvesterObserver::NewL( plugin );
+    iPluginTester->SetWaitTime(2000000);
+    plugin->StartPluginL();
+    TRAPD(err, plugin->DelayedError( KErrGeneral ));
+    delete plugin;
+    delete iPluginTester;
+    return KErrNone;
+    }
+
+TInt CHarvesterPluginTester::TestNotesChangeEntryL( CStifItemParser& /*aItem*/ )
+    {
+    CNotesPlugin* plugin = CNotesPlugin::NewL();
+    CHarvesterObserver* iPluginTester = CHarvesterObserver::NewL( plugin );
+    iPluginTester->SetWaitTime(2000000);
+    plugin->StartPluginL();
+    TCalChangeEntry calEntry;
+    calEntry.iChangeType = MCalChangeCallBack2::EChangeUndefined; //undefined type
+    plugin->HandleNoteChangedEntryL( calEntry );
+    calEntry.iChangeType = MCalChangeCallBack2::EChangeTzRules; //default check
+    plugin->HandleNoteChangedEntryL( calEntry );
+    delete plugin;
+    delete iPluginTester;
+    return KErrNone;
+    }
+
+TInt CHarvesterPluginTester::TestNotesEntryNoIndexerL( CStifItemParser& /*aItem*/ )
+    {    
+    CNotesPlugin* plugin = CNotesPlugin::NewL();
+    CHarvesterObserver* iPluginTester = CHarvesterObserver::NewL( plugin );
+    plugin->StartPluginL();
+    TRAPD(err, plugin->CreateNoteEntryL(0, ECPixUpdateAction) );
+    TRAP(err, plugin->CreateNoteEntryL(0, (TCPixActionType)3) );
+    iPluginTester->SetWaitTime(2000000);    
+    CCalendarObserver* calobserver = CCalendarObserver::NewL();
+    calobserver->AddEntryL();
+    delete calobserver;
+    delete plugin;
+    delete iPluginTester;
+    return err;
+    }
+	
 TInt CHarvesterPluginTester::TestStartContactsHarvesterL( CStifItemParser& /*aItem*/ )
     {
     CContactsPlugin* plugin = CContactsPlugin::NewL();
@@ -1442,6 +1530,10 @@
 
 TInt CHarvesterPluginTester::TestStartCalenderHarvesterL( CStifItemParser& /*aItem*/ )
     {
+    CCalendarObserver* session = CCalendarObserver::NewL();
+    // Add a calender entry
+    session->AddEntryL();
+    delete session;
     CCalendarPlugin* plugin = CCalendarPlugin::NewL();
     CHarvesterObserver* iPluginTester = CHarvesterObserver::NewL( plugin );
     plugin->StartPluginL(); //start to moniter contacts db
@@ -1534,6 +1626,67 @@
     return KErrNone;
     }
 
+TInt CHarvesterPluginTester::TestcalenderdestructorL( CStifItemParser& /*aItem */ )
+    {
+    CCalendarPlugin* plugin = CCalendarPlugin::NewL();
+    CHarvesterObserver* iPluginTester = CHarvesterObserver::NewL( plugin );
+    plugin->StartPluginL(); //start to moniter contacts db   
+    plugin->Progress(100);
+    iPluginTester->SetWaitTime(2000000);
+    plugin->StartHarvestingL( _L(CALENDAR_QBASEAPPCLASS) );
+    plugin->DelayedError(KErrNone);
+    iPluginTester->iWaitForHarvester->Start();//Wait here till Harvesting is complete.
+    plugin->Completed(KErrGeneral);  
+    plugin->iAsynchronizer->CancelCallback();
+    plugin->iAsynchronizer = NULL;
+    plugin->iSession->StopChangeNotification();
+    plugin->iSession = NULL;
+    delete plugin;
+    delete iPluginTester;
+    iPluginTester = NULL;
+    doLog( iLog, KErrNone, KNoErrorString );
+    return KErrNone; 
+    }
+
+TInt CHarvesterPluginTester::TestCalChangeEntryL( CStifItemParser& /*aItem */ )
+    {
+    CCalendarPlugin* plugin = CCalendarPlugin::NewL();
+    CHarvesterObserver* iPluginTester = CHarvesterObserver::NewL( plugin );
+    iPluginTester->SetWaitTime(2000000);
+    plugin->StartPluginL();
+    TCalChangeEntry calEntry;
+    calEntry.iChangeType = MCalChangeCallBack2::EChangeAdd; //undefined type
+    plugin->HandleChangedEntryL( calEntry );
+    calEntry.iChangeType = MCalChangeCallBack2::EChangeUndefined; //undefined type
+    plugin->HandleChangedEntryL( calEntry );
+    calEntry.iChangeType = MCalChangeCallBack2::EChangeTzRules; //default check
+    plugin->HandleChangedEntryL( calEntry );
+    delete plugin;
+    return KErrNone;
+    }
+
+TInt CHarvesterPluginTester::TestCalCreateEntryL( CStifItemParser& /*aItem */ )
+    {
+    _LIT8(KTestmemo , "Notesplugin");
+    CCalendarPlugin* plugin = CCalendarPlugin::NewL();
+    CHarvesterObserver* iPluginTester = CHarvesterObserver::NewL( plugin );
+    iPluginTester->SetWaitTime(2000000);
+    plugin->CreateEntryL(0,ECPixAddAction );
+    plugin->StartPluginL();
+    plugin->CreateEntryL(0,ECPixAddAction );
+    CCalendarObserver* calobserver = CCalendarObserver::NewL();
+    HBufC8* memo = HBufC8::New(10);
+    TPtr8 ptr = memo->Des();
+    ptr.Copy(KTestmemo);
+    calobserver->AddNoteL(ptr);
+    delete calobserver;
+    delete memo;
+    plugin->CreateEntryL(0,(TCPixActionType )3);
+    delete plugin;
+    delete iPluginTester;
+    return KErrNone;
+    }
+
 TInt CHarvesterPluginTester::TestCreateEmailL( CStifItemParser& /*aItem */)
     {
     TInt error = KErrNone;
@@ -1596,119 +1749,14 @@
     //Wait for one minutes after doc processing to Index and Flush to happen
     iPluginTester->SetWaitTime((TTimeIntervalMicroSeconds32)60000000);
     iPluginTester->iWaitForHarvester->Start(); //Start Wait AO and let it complete
-    TInt count = SearchForTextL(_L("Eagle"),_L(MEDIA_QBASEAPPCLASS),KNullDesC);
-    if(count <= 0)
-        {
-        error = KErrNotFound;
-        }
-    doLog(iLog,error,_L("Error in TestAudioHarvestingL"));
+    error = doSearchL( _L("Eagle"),_L(MEDIA_QBASEAPPCLASS), ESearchTypeResultsExpected ); 
+    
     delete plugin;
     delete iPluginTester;
     iPluginTester = NULL;
     fileSession.Close();    
     //End search
-    return error;
-    }
-TInt CHarvesterPluginTester::TestAudioHarvestingUpdateIndexL( CStifItemParser& aItem )
-    {
-    TInt error = KErrNone;
-    TPtrC filepath;
-    TPtrC filename;
-    TPtrC newFile;
-    TBuf<KMaxFileName> srcPath(_L("c:\\data\\Sounds\\"));
-    TBuf<KMaxFileName> desPath;
-    desPath.Copy( srcPath );
-    CAudioPlugin* plugin = CAudioPlugin::NewL();
-    CHarvesterObserver* iPluginTester = CHarvesterObserver::NewL( plugin );
-    plugin->StartPluginL();
-    RFs fSession;
-    User::LeaveIfError( fSession.Connect());
-    CleanupClosePushL( fSession );
-    if((aItem.GetNextString(filepath)==KErrNone) && (aItem.GetNextString(filename) == KErrNone))
-        {
-        srcPath.Append( filename );
-        if( aItem.GetNextString(newFile) == KErrNone )
-            {
-            desPath.Append( newFile );
-            RHarvesterClient harvester;
-            User::LeaveIfError(harvester.Connect());
-            harvester.Pause();
-            TBool fileExist = BaflUtils::FileExists( fSession, srcPath );        
-            if(!fileExist)
-            {
-            BaflUtils::EnsurePathExistsL( fSession, srcPath );//Create folder
-            BaflUtils::CopyFile( fSession, filepath, srcPath );                    
-            }            
-            BaflUtils::RenameFile( fSession, srcPath, desPath );
-            harvester.Resume();
-            harvester.Close();
-            plugin->StartHarvestingL( _L(MEDIA_QBASEAPPCLASS) );
-            //wait for index to flush
-            iPluginTester->SetWaitTime( (TTimeIntervalMicroSeconds32)60000000 );
-            //wait till video harvesting completes
-            iPluginTester->iWaitForHarvester->Start();
-            TInt count = SearchForTextL(_L("testaudio"), _L(MEDIA_QBASEAPPCLASS), KNullDesC );
-            if(count <= 0)
-               {
-               error = KErrNotFound;
-               }
-            doLog( iLog, error, _L("Error in TestAudioHarvestingUpdateIndexL") );
-            }        
-        }
-        else
-            doLog( iLog, KErrNotFound, _L("Error in TestAudioHarvestingUpdateIndexL") );           
-        CleanupStack::PopAndDestroy();
-        delete plugin;
-        delete iPluginTester;
-        iPluginTester = NULL;
-        return error;
-        }
-
-TInt CHarvesterPluginTester::TestAudioHarvestingDeleteIndexL( CStifItemParser& aItem )
-    {
-    TInt error = KErrNone;
-    TPtrC filepath;
-    TPtrC filename;    
-    TBuf<KMaxFileName> srcPath(_L("c:\\data\\Sounds\\"));
-    CAudioPlugin* plugin = CAudioPlugin::NewL();
-    CHarvesterObserver* iPluginTester = CHarvesterObserver::NewL( plugin );
-    plugin->StartPluginL();
-    RFs fSession;
-    User::LeaveIfError( fSession.Connect());
-    CleanupClosePushL( fSession );
-    if((aItem.GetNextString(filepath)==KErrNone) && (aItem.GetNextString(filename) == KErrNone))
-        {
-        srcPath.Append( filename );        
-        RHarvesterClient harvester;
-        User::LeaveIfError(harvester.Connect());
-        harvester.Pause();
-        TBool fileExist = BaflUtils::FileExists( fSession, srcPath );        
-        if(!fileExist)
-        {
-        BaflUtils::EnsurePathExistsL( fSession, srcPath );//Create folder
-        BaflUtils::CopyFile( fSession, filepath, srcPath );                    
-        }            
-        BaflUtils::DeleteFile( fSession, srcPath );        
-        harvester.Resume();
-        harvester.Close();
-        plugin->StartHarvestingL( _L(MEDIA_QBASEAPPCLASS) );
-        //wait for index to flush
-        iPluginTester->SetWaitTime( (TTimeIntervalMicroSeconds32)60000000 );
-        //wait till video harvesting completes
-        iPluginTester->iWaitForHarvester->Start();
-        TInt count = SearchForTextL(_L("eagle"), _L(MEDIA_QBASEAPPCLASS), KNullDesC );
-        if(count <= 0)
-           {
-           // If the search is not found,then testcase is success
-           doLog( iLog, error, _L("Error in TestAudioHarvestingDeleteIndexL") );
-           }
-        }
-    else
-        doLog( iLog, KErrNotFound, _L("Error in TestAudioHarvestingDeleteIndexL") );           
-    CleanupStack::PopAndDestroy();
-    delete plugin;
-    delete iPluginTester;
-    iPluginTester = NULL;
+    doLog(iLog,error,_L("Error in TestAudioHarvestingL"));
     return error;
     }
         
@@ -1748,7 +1796,83 @@
     delete dbcontroller;
     return error;
     }
-	
+
+TInt CHarvesterPluginTester::TestAudioHandleItemL( CStifItemParser& aItem)
+    {
+    TInt error = KErrNone;    
+    TInt objId;    
+    TInt actionType;
+    aItem.GetNextInt ( objId );
+    aItem.GetNextInt ( actionType );    
+    CAudioPlugin* plugin = CAudioPlugin::NewL(); 
+    CHarvesterObserver* iPluginTester = CHarvesterObserver::NewL( plugin );
+    plugin->StartPluginL();
+    TRAPD( err , plugin->HandleMdeItemL(objId, (TCPixActionType)actionType) );
+    doLog(iLog,error,_L("Error in TestAudioHandleItemL"));
+    delete plugin;
+    delete iPluginTester;
+    iPluginTester = NULL;
+    return KErrNone;
+    }
+
+TInt CHarvesterPluginTester::TestAudioSyncDbManagerL( CStifItemParser& /* aItem */)
+    {    
+    CAudioPlugin* plugin = CAudioPlugin::NewL(); 
+    CHarvesterObserver* iPluginTester = CHarvesterObserver::NewL( plugin );
+    plugin->StartPluginL();
+    CMDSEntity* entity;    
+    entity = CMDSEntity::NewL();    
+    entity->Setkey(100);
+    entity->SetUri(_L("\\music\\audio.mp3"));
+    TDriveNumber drive = TDriveNumber(EDriveC);
+    entity->SetDrive(drive);    
+    plugin->iDBManager->AddL( entity->Key(),*entity );
+    TRAPD( err , plugin->HandleMdeItemL(entity->Key(), ECPixAddAction));
+    TRAP( err , plugin->HandleMdeItemL(entity->Key(), ECPixUpdateAction));
+    TRAP( err , plugin->HandleMdeItemL(entity->Key(), ECPixRemoveAction));
+    delete plugin;
+    delete iPluginTester;
+    iPluginTester = NULL;
+    return KErrNone;
+    }
+
+TInt CHarvesterPluginTester::TestAudioMMCEventL( CStifItemParser& aItem )
+    {    
+    TInt error(KErrNone);
+    TInt drive;    
+    TInt mmcstatus;
+    aItem.GetNextInt ( drive );
+    aItem.GetNextInt ( mmcstatus );    
+    CAudioPlugin* plugin = CAudioPlugin::NewL();
+    CHarvesterObserver* iPluginTester = CHarvesterObserver::NewL( plugin );
+    plugin->StartPluginL(); //Initialize the Plugin
+    TRAPD( err , plugin->HandleMMCEventL( (TDriveNumber)drive , mmcstatus) );
+    //iPluginTester->iWaitForHarvester->Start(); //Start Wait AO and let it complete
+    doLog(iLog,error,_L("Error in TestAudioMMCEventL"));
+    delete plugin;
+    delete iPluginTester;
+    iPluginTester = NULL;
+    //End search
+    return err;
+    }
+
+TInt CHarvesterPluginTester::TestAudioNoIndexerL( CStifItemParser& aItem )
+    {
+    TInt drive;
+    TInt objId;
+    aItem.GetNextInt ( drive );
+    aItem.GetNextInt ( objId );
+    CAudioPlugin* plugin = CAudioPlugin::NewL(); 
+    CHarvesterObserver* iPluginTester = CHarvesterObserver::NewL( plugin );
+    plugin->StartPluginL();
+    plugin->iIndexerUtil->iIndexer[drive]= NULL;
+    TRAPD( err , plugin->HandleMdeItemL(objId, ECPixUpdateAction) );
+    delete plugin;
+    delete iPluginTester;
+    iPluginTester = NULL;    
+    return KErrNone;
+    }
+
 TInt CHarvesterPluginTester::TestBlacklistPluginL( CStifItemParser& /*aItem*/ )
     {
     //@todo: This test case shoud be in IDS middleware harvester STIF cases
@@ -1805,7 +1929,7 @@
     doLog( iLog, err, KNoErrorString );*/
     return err;
     }
-TInt CHarvesterPluginTester::TestVideoHarvestingIndexL( CStifItemParser& aItem )
+TInt CHarvesterPluginTester::TestVideoHarvestingL( CStifItemParser& aItem )
     {
     TInt error = KErrNone;
     TPtrC filepath;
@@ -1815,8 +1939,7 @@
     CHarvesterObserver* iPluginTester = CHarvesterObserver::NewL( plugin );
     plugin->StartPluginL();
     RFs fSession;
-    User::LeaveIfError( fSession.Connect());
-    CleanupClosePushL( fSession );
+    User::LeaveIfError( fSession.Connect());    
     if((aItem.GetNextString(filepath)==KErrNone) && (aItem.GetNextString(filename) == KErrNone))
         {        
         TBuf<KMaxFileName> desPath(_L("c:\\data\\Videos\\"));
@@ -1843,121 +1966,72 @@
            {
            error = KErrNotFound;
            }
-        }
-        else
-           error = KErrNotFound;
-    CleanupStack::PopAndDestroy();
+        }        
+    fSession.Close();
     delete plugin;
     delete iPluginTester;
     iPluginTester = NULL;
-    doLog( iLog, error, _L("Error in TestVideoHarvestingIndexL") );
+    doLog( iLog, error, _L("Error in TestVideoHarvesting") );
     return error;
     }
 
-TInt CHarvesterPluginTester::TestVideoHarvestingUpdateIndexL( CStifItemParser& aItem )
+TInt CHarvesterPluginTester::TestVideoHandleItemL( CStifItemParser& aItem )
     {
-    TInt error = KErrNone;
-    TPtrC filepath;
-    TPtrC filename;
-    TPtrC newFile;
-    TBuf<KMaxFileName> srcPath(_L("c:\\data\\Videos\\"));
-    TBuf<KMaxFileName> desPath;
-    desPath.Copy( srcPath );
-    CVideoPlugin* plugin = CVideoPlugin::NewL();
+    TInt error = KErrNone;    
+    TInt objId;    
+    TInt actionType;
+    aItem.GetNextInt ( objId );
+    aItem.GetNextInt ( actionType );    
+    CVideoPlugin* plugin = CVideoPlugin::NewL(); 
     CHarvesterObserver* iPluginTester = CHarvesterObserver::NewL( plugin );
     plugin->StartPluginL();
-    RFs fSession;
-    User::LeaveIfError( fSession.Connect());
-    CleanupClosePushL( fSession );
-    if((aItem.GetNextString(filepath)==KErrNone) && (aItem.GetNextString(filename) == KErrNone))
-        {
-        srcPath.Append( filename );
-        if( aItem.GetNextString(newFile) == KErrNone )
-            {
-            desPath.Append( newFile );
-            RHarvesterClient harvester;
-            User::LeaveIfError(harvester.Connect());
-            harvester.Pause();
-            TBool fileExist = BaflUtils::FileExists( fSession, srcPath );        
-            if(!fileExist)
-            {
-            BaflUtils::EnsurePathExistsL( fSession, srcPath );//Create folder
-            BaflUtils::CopyFile( fSession, filepath, srcPath );                    
-            }            
-            BaflUtils::RenameFile( fSession, srcPath, desPath );
-            harvester.Resume();
-            harvester.Close();
-            plugin->StartHarvestingL( _L(VIDEO_QBASEAPPCLASS) );
-            //wait for index to flush
-            iPluginTester->SetWaitTime( (TTimeIntervalMicroSeconds32)60000000 );
-            //wait till video harvesting completes
-            iPluginTester->iWaitForHarvester->Start();
-            TInt count = SearchForTextL(_L("Falls"), _L(VIDEO_QBASEAPPCLASS), KNullDesC );
-            if(count <= 0)
-               {
-               error = KErrNotFound;
-               }
-            doLog( iLog, error, _L("Error in TestVideoHarvestingUpdateIndexL") );
-            }        
-        }
-    else
-        doLog( iLog, KErrNotFound, _L("Error in TestVideoHarvestingUpdateIndexL") );           
-    CleanupStack::PopAndDestroy();
+    TRAPD( err , plugin->HandleMdeItemL(objId, (TCPixActionType)actionType) );
+    doLog(iLog,error,_L("Error in TestVideoHandleItemL"));
     delete plugin;
     delete iPluginTester;
     iPluginTester = NULL;
-    return error;
+    return KErrNone;
     }
 
-TInt CHarvesterPluginTester::TestVideoHarvestingDeleteIndexL( CStifItemParser& aItem )
+TInt CHarvesterPluginTester::TestVideoSyncDbManagerL( CStifItemParser& /*aItem */)
     {
-    TInt error = KErrNone;
-    TPtrC filepath;
-    TPtrC filename;    
-    TBuf<KMaxFileName> srcPath(_L("c:\\data\\Videos\\"));
-    CVideoPlugin* plugin = CVideoPlugin::NewL();
+    CVideoPlugin* plugin = CVideoPlugin::NewL(); 
     CHarvesterObserver* iPluginTester = CHarvesterObserver::NewL( plugin );
     plugin->StartPluginL();
-    RFs fSession;
-    User::LeaveIfError( fSession.Connect());
-    CleanupClosePushL( fSession );
-    if((aItem.GetNextString(filepath)==KErrNone) && (aItem.GetNextString(filename) == KErrNone))
-        {
-        srcPath.Append( filename );        
-        RHarvesterClient harvester;
-        User::LeaveIfError(harvester.Connect());
-        harvester.Pause();
-        TBool fileExist = BaflUtils::FileExists( fSession, srcPath );        
-        if(!fileExist)
-        {
-        BaflUtils::EnsurePathExistsL( fSession, srcPath );//Create folder
-        BaflUtils::CopyFile( fSession, filepath, srcPath );                    
-        }            
-        BaflUtils::DeleteFile( fSession, srcPath );        
-        harvester.Resume();
-        harvester.Close();
-        plugin->StartHarvestingL( _L(VIDEO_QBASEAPPCLASS) );
-        //wait for index to flush
-        iPluginTester->SetWaitTime( (TTimeIntervalMicroSeconds32)60000000 );
-        //wait till video harvesting completes
-        iPluginTester->iWaitForHarvester->Start();
-        TInt count = SearchForTextL(_L("Niagara"), _L(VIDEO_QBASEAPPCLASS), KNullDesC );
-        if(count <= 0)
-           {
-           // If the search is not found,then testcase is success
-           doLog( iLog, error, _L("Error in TestVideoHarvestingDeleteIndexL") );
-           }
-        }
-    else
-        doLog( iLog, KErrNotFound, _L("Error in TestVideoHarvestingDeleteIndexL") );           
-    CleanupStack::PopAndDestroy();
+    CMDSEntity* entity;    
+    entity = CMDSEntity::NewL();    
+    entity->Setkey(101);
+    entity->SetUri(_L("\\video\\video.mpg"));
+    TDriveNumber drive = TDriveNumber(EDriveC);
+    entity->SetDrive(drive);    
+    plugin->iDBManager->AddL( entity->Key(),*entity );
+    TRAPD( err , plugin->HandleMdeItemL(entity->Key(), ECPixAddAction));
+    TRAP( err , plugin->HandleMdeItemL(entity->Key(), ECPixUpdateAction));
+    TRAP( err , plugin->HandleMdeItemL(entity->Key(), ECPixRemoveAction));
     delete plugin;
     delete iPluginTester;
     iPluginTester = NULL;
-    return error;
+    return KErrNone;
     }
 
-TInt CHarvesterPluginTester::TestImageHarvestingAddIndexL( CStifItemParser& aItem )
+TInt CHarvesterPluginTester::TestVideoNoIndexerL( CStifItemParser& aItem )
+    {
+    TInt drive;
+    TInt objId;
+    aItem.GetNextInt ( drive );
+    aItem.GetNextInt ( objId );
+    CVideoPlugin* plugin = CVideoPlugin::NewL(); 
+    CHarvesterObserver* iPluginTester = CHarvesterObserver::NewL( plugin );
+    plugin->StartPluginL();
+    plugin->iIndexerUtil->iIndexer[drive]= NULL;
+    TRAPD( err , plugin->HandleMdeItemL(objId, ECPixUpdateAction) );
+    delete plugin;
+    delete iPluginTester;
+    iPluginTester = NULL;    
+    return KErrNone;
+    }
+
+TInt CHarvesterPluginTester::TestImageHarvestingL( CStifItemParser& aItem )
     {
     TInt error = KErrNone;
     TPtrC filepath;
@@ -1967,8 +2041,7 @@
     CHarvesterObserver* iPluginTester = CHarvesterObserver::NewL( plugin );
     plugin->StartPluginL();
     RFs fSession;
-    User::LeaveIfError( fSession.Connect());
-    CleanupClosePushL( fSession );
+    User::LeaveIfError( fSession.Connect());    
     if((aItem.GetNextString(filepath)==KErrNone) && (aItem.GetNextString(filename) == KErrNone))
         {        
         TBuf<KMaxFileName> desPath(_L("c:\\data\\Images\\"));
@@ -1998,135 +2071,68 @@
         else
            error = KErrNotFound;
     doLog( iLog, error, _L("Error in TestImageHarvestingAddIndexL") );  
-    CleanupStack::PopAndDestroy();
-    delete plugin;
-    delete iPluginTester;
-    iPluginTester = NULL;
-    return error;
-    }
-
-TInt CHarvesterPluginTester::TestImageHarvestingUpdateIndexL( CStifItemParser& aItem )
-    {
-    TInt error = KErrNone;
-    TPtrC filepath;
-    TPtrC filename;
-    TPtrC newFile;
-    TBuf<KMaxFileName> srcPath(_L("c:\\data\\Images\\"));
-    TBuf<KMaxFileName> desPath;
-    desPath.Copy( srcPath );
-    CImagePlugin* plugin = CImagePlugin::NewL();
-    CHarvesterObserver* iPluginTester = CHarvesterObserver::NewL( plugin );
-    plugin->StartPluginL();
-    RFs fSession;
-    User::LeaveIfError( fSession.Connect());
-    CleanupClosePushL( fSession );
-    if((aItem.GetNextString(filepath)==KErrNone) && (aItem.GetNextString(filename) == KErrNone))
-        {
-        srcPath.Append( filename );
-        if( aItem.GetNextString(newFile) == KErrNone )
-            {
-            desPath.Append( newFile );
-            RHarvesterClient harvester;
-            User::LeaveIfError(harvester.Connect());
-            harvester.Pause();
-            TBool fileExist = BaflUtils::FileExists( fSession, srcPath );        
-            if(!fileExist)
-            {
-            BaflUtils::EnsurePathExistsL( fSession, srcPath );//Create folder
-            BaflUtils::CopyFile( fSession, filepath, srcPath );                    
-            }            
-            BaflUtils::RenameFile( fSession, srcPath, desPath );
-            harvester.Resume();
-            harvester.Close();
-            plugin->StartHarvestingL( _L(IMAGE_QBASEAPPCLASS) );
-            //wait for index to flush
-            iPluginTester->SetWaitTime( (TTimeIntervalMicroSeconds32)60000000 );            
-            iPluginTester->iWaitForHarvester->Start();
-            TInt count = SearchForTextL(_L("Portrait"), _L(IMAGE_QBASEAPPCLASS), KNullDesC );
-            if(count <= 0)
-               {
-               error = KErrNotFound;
-               }
-            doLog( iLog, error, _L("Error in TestImageHarvestingUpdateIndexL") );
-            }        
-        }
-    else
-        doLog( iLog, KErrNotFound, _L("Error in TestImageHarvestingUpdateIndexL") );           
-    CleanupStack::PopAndDestroy();
+    fSession.Close();
     delete plugin;
     delete iPluginTester;
     iPluginTester = NULL;
     return error;
     }
 
-TInt CHarvesterPluginTester::TestImageHarvestingDeleteIndexL( CStifItemParser& aItem )
+TInt CHarvesterPluginTester::TestImageHandleItemL( CStifItemParser& aItem )
     {
-    TInt error = KErrNone;
-    TPtrC filepath;
-    TPtrC filename;    
-    TBuf<KMaxFileName> srcPath(_L("c:\\data\\Images\\"));
-    CImagePlugin* plugin = CImagePlugin::NewL();
+    TInt error = KErrNone;    
+    TInt objId;    
+    TInt actionType;
+    aItem.GetNextInt ( objId );
+    aItem.GetNextInt ( actionType );    
+    CImagePlugin* plugin = CImagePlugin::NewL(); 
     CHarvesterObserver* iPluginTester = CHarvesterObserver::NewL( plugin );
     plugin->StartPluginL();
-    RFs fSession;
-    User::LeaveIfError( fSession.Connect() );
-    CleanupClosePushL( fSession );
-    if((aItem.GetNextString(filepath)==KErrNone) && (aItem.GetNextString(filename) == KErrNone))
-        {
-        srcPath.Append( filename );        
-        RHarvesterClient harvester;
-        User::LeaveIfError(harvester.Connect());
-        harvester.Pause();
-        TBool fileExist = BaflUtils::FileExists( fSession, srcPath );        
-        if(!fileExist)
-        {
-        BaflUtils::EnsurePathExistsL( fSession, srcPath );//Create folder
-        BaflUtils::CopyFile( fSession, filepath, srcPath );                    
-        }            
-        BaflUtils::DeleteFile( fSession, srcPath );        
-        harvester.Resume();
-        harvester.Close();
-        plugin->StartHarvestingL( _L(IMAGE_QBASEAPPCLASS) );
-        //wait for index to flush
-        iPluginTester->SetWaitTime( (TTimeIntervalMicroSeconds32)60000000 );
-        //wait till image harvesting completes
-        iPluginTester->iWaitForHarvester->Start();
-        TInt count = SearchForTextL(_L("Square"), _L(IMAGE_QBASEAPPCLASS), KNullDesC );
-        if(count <= 0)
-           {
-           // If the search is not found,then testcase is success
-           doLog( iLog, error, _L("Error in TestImageHarvestingDeleteIndexL") );
-           }
-        }
-    else
-        doLog( iLog, KErrNotFound, _L("Error in TestImageHarvestingDeleteIndexL") );           
-    CleanupStack::PopAndDestroy();
+    TRAPD( err , plugin->HandleMdeItemL(objId, (TCPixActionType)actionType) );
+    doLog(iLog,error,_L("Error in TestImageHandleItemL"));
     delete plugin;
     delete iPluginTester;
     iPluginTester = NULL;
-    return error;
+    return KErrNone;
     }
 
-TInt CHarvesterPluginTester::TestAudioMMCEventL( CStifItemParser& aItem )
-    {    
-    TInt error(KErrNone);
-    TInt drive;    
-    TInt mmcstatus;
-    aItem.GetNextInt ( drive );
-    aItem.GetNextInt ( mmcstatus );    
-    CAudioPlugin* plugin = CAudioPlugin::NewL();
+TInt CHarvesterPluginTester::TestImageSyncDbManagerL( CStifItemParser& /*aItem */)
+    {
+    CImagePlugin* plugin = CImagePlugin::NewL(); 
     CHarvesterObserver* iPluginTester = CHarvesterObserver::NewL( plugin );
-    plugin->StartPluginL(); //Initialize the Plugin
-    TRAPD( err , plugin->HandleMMCEventL( (TDriveNumber)drive , mmcstatus) );
-    //iPluginTester->iWaitForHarvester->Start(); //Start Wait AO and let it complete
-    doLog(iLog,error,_L("Error in TestAudioMMCEventL"));
+    plugin->StartPluginL();
+    CMDSEntity* entity;    
+    entity = CMDSEntity::NewL();    
+    entity->Setkey(102);
+    entity->SetUri(_L("\\image\\image.jpg"));
+    TDriveNumber drive = TDriveNumber(EDriveC);
+    entity->SetDrive(drive);    
+    plugin->iDBManager->AddL( entity->Key(),*entity );
+    TRAPD( err , plugin->HandleMdeItemL(entity->Key(), ECPixAddAction));
+    TRAP( err , plugin->HandleMdeItemL(entity->Key(), ECPixUpdateAction));
+    TRAP( err , plugin->HandleMdeItemL(entity->Key(), ECPixRemoveAction));
     delete plugin;
     delete iPluginTester;
     iPluginTester = NULL;
-    //End search
-    return err;
+    return KErrNone;
     }
-        
+
+TInt CHarvesterPluginTester::TestImageNoIndexerL( CStifItemParser& aItem )
+    {
+    TInt drive;
+    TInt objId;
+    aItem.GetNextInt ( drive );
+    aItem.GetNextInt ( objId );
+    CImagePlugin* plugin = CImagePlugin::NewL(); 
+    CHarvesterObserver* iPluginTester = CHarvesterObserver::NewL( plugin );
+    plugin->StartPluginL();
+    plugin->iIndexerUtil->iIndexer[drive]= NULL;
+    TRAPD( err , plugin->HandleMdeItemL(objId, ECPixUpdateAction) );
+    delete plugin;
+    delete iPluginTester;
+    iPluginTester = NULL;    
+    return KErrNone;
+    }        
 TInt CHarvesterPluginTester::TestVideoMMCEventL( CStifItemParser& aItem )
     {
     TInt error(KErrNone);
@@ -2177,8 +2183,11 @@
     iLog->Log( KExample );
     CEmailPlugin* emailPlugin = CEmailPlugin::NewL();
     CHarvesterObserver* iPluginTester = CHarvesterObserver::NewL( emailPlugin );    
-    emailPlugin->StartPluginL(); //Calls Add
+    emailPlugin->StartPluginL();
+    iPluginTester->SetWaitTime( (TTimeIntervalMicroSeconds32)5000000 );
     emailPlugin->StartHarvestingL( KEmailAppBasePath );
+    emailPlugin->HarvestingCompleted();
+    iPluginTester->iWaitForHarvester->Start();
     delete emailPlugin;
     delete iPluginTester;
     doLog( iLog, KErrNone, KNoErrorString );
@@ -2194,14 +2203,63 @@
     // Print to log file
     iLog->Log( KExample );
     CEmailPlugin* emailPlugin = CEmailPlugin::NewL();
-    CHarvesterObserver* iPluginTester = CHarvesterObserver::NewL( emailPlugin );   
+    CHarvesterObserver* iPluginTester = CHarvesterObserver::NewL( emailPlugin );
+    TRAPD(err , emailPlugin->StartPluginL());
     CSearchDocument* doc = prepareemaildocument();
-    TRAPD(err , emailPlugin->HandleDocumentL( doc , ECPixAddAction));
-    iPluginTester->iWaitForHarvester->Start();//Wait here till Harvesting is complete.
+    TRAP(err , emailPlugin->HandleDocumentL( doc , ECPixAddAction));    
+    TRAP(err , emailPlugin->HandleDocumentL( doc , ECPixRemoveAction));
+    //iPluginTester->iWaitForHarvester->Start();//Wait here till Harvesting is complete.
+    delete doc;
     delete emailPlugin;
     delete iPluginTester;
     doLog( iLog, err, KNoErrorString );
     return err;
     }
 
+TInt CHarvesterPluginTester::TestEmailBaseappclassL( CStifItemParser& /*aItem*/ )
+    {
+    _LIT( KHarvesterPluginTester, "HarvesterPluginTester: %S" );
+    _LIT( KExample, "In TestEmailBaseappclassL" );
+    TestModuleIf().Printf( 0, KHarvesterPluginTester, KExample );
+    
+    TDriveNumber drive ( EDriveA ); 
+    _LIT( appcls1 ,"@c:root msg email" );
+    _LIT( appcls2 ,"@*:root msg email" );
+    _LIT( appcls3 ,"d:root msg email" );    
+    CEmailPlugin* emailPlugin = CEmailPlugin::NewL();
+    CHarvesterObserver* iPluginTester = CHarvesterObserver::NewL( emailPlugin );
+    TRAPD(err , emailPlugin->StartPluginL());
+    TRAP(err, emailPlugin->StartHarvestingL(appcls1));
+    delete emailPlugin->iIndexer[EDriveC];
+    emailPlugin->iIndexer[EDriveC] = NULL;
+    TRAP(err, emailPlugin->StartHarvestingL(appcls1));
+    TRAP(err, emailPlugin->StartHarvestingL(appcls2));
+    TRAP(err, emailPlugin->StartHarvestingL(appcls3));
+    delete emailPlugin;
+    delete iPluginTester;
+    return err;
+    }
+
+TInt CHarvesterPluginTester::TestEmailHandleDocL( CStifItemParser& /*aItem*/ )
+    {
+    _LIT( KHarvesterPluginTester, "HarvesterPluginTester: %S" );
+    _LIT( KExample, "In TestEmailHandleDocL" );
+    TestModuleIf().Printf( 0, KHarvesterPluginTester, KExample );
+    CEmailPlugin* emailPlugin = CEmailPlugin::NewL();
+    CHarvesterObserver* iPluginTester = CHarvesterObserver::NewL( emailPlugin );
+    CSearchDocument* doc = prepareemaildocument();
+    TRAPD(err , emailPlugin->StartPluginL());
+    TRAP(err, emailPlugin->StartHarvestingL( KEmailAppBasePath ));    
+    delete emailPlugin->iIndexer[EDriveC];    
+    TRAP(err,emailPlugin->HandleDocumentL(doc,ECPixRemoveAction));
+    TRAP(err,emailPlugin->HandleDocumentL(doc,ECPixAddAction));
+    emailPlugin->MountL(EDriveC);
+    TRAP(err,emailPlugin->HandleDocumentL(doc,ECPixAddAction));
+    TRAP(err,emailPlugin->HandleDocumentL(doc,ECPixUpdateAction));
+    delete doc;
+    delete emailPlugin;
+    delete iPluginTester;
+    return err;
+    }
+
 //  [End of File] - Do not remove