searcher/tsrc/cpixsearchertest/src/cpixsearchertester.cpp
changeset 14 8bd192d47aaa
parent 1 6f2c1c46032b
equal deleted inserted replaced
13:fcb2a58c181b 14:8bd192d47aaa
   232         iDocument = aDocument;
   232         iDocument = aDocument;
   233         // All done, signal that can continue now.
   233         // All done, signal that can continue now.
   234         iWait->AsyncStop();
   234         iWait->AsyncStop();
   235         }
   235         }
   236     }
   236     }
       
   237 void CTestSearcher::HandleBatchDocumentL(TInt /*aError*/, TInt aReturnCount, CSearchDocument** aDocument)
       
   238     {
       
   239     iHandleDocumentLFunctionCalled = ETrue;
       
   240     
       
   241     if (iWait && iWait->IsStarted())
       
   242             {
       
   243             for (int i=0; i<aReturnCount; i++)
       
   244                 delete aDocument[i];
       
   245             delete aDocument;
       
   246             
       
   247             TS_ASSERT(aReturnCount == iretcount);
       
   248             
       
   249             iWait->AsyncStop();
       
   250             }
       
   251     }
   237 
   252 
   238 // Timeout callback
   253 // Timeout callback
   239 void CTestSearcher::CallCompleted( int /* i */ )
   254 void CTestSearcher::CallCompleted( int /* i */ )
   240     {
   255     {
   241     if (iWait && iWait->IsStarted())
   256     if (iWait && iWait->IsStarted())
   569         length = document->Excerpt().Length();
   584         length = document->Excerpt().Length();
   570         delete document;           
   585         delete document;           
   571         }
   586         }
   572     return ( length > 125 )?KErrGeneral:KErrNone;
   587     return ( length > 125 )?KErrGeneral:KErrNone;
   573     }
   588     }
       
   589 
       
   590 void CTestSearcher::testgetbatchdoc()
       
   591     {
       
   592     //Make sure Hit count is 7 
       
   593     TInt hitcount = iSearcher->SearchL(KQueryString);
       
   594     CSearchDocument** doc = NULL;
       
   595     if ( hitcount )
       
   596         {
       
   597         TInt retcount=0,count=3;
       
   598         doc = iSearcher->GetBatchDocumentL(0,retcount,count);
       
   599         for (int i=0; i<retcount; i++)
       
   600             delete doc[i];
       
   601         delete doc;
       
   602         doc = NULL;
       
   603         TS_ASSERT(retcount == 3);
       
   604         //check the extreme conditions
       
   605         retcount = 0;
       
   606         doc = iSearcher->GetBatchDocumentL(3,retcount,count);
       
   607         for (int i=0; i<retcount; i++)
       
   608             delete doc[i];
       
   609         delete doc;
       
   610         doc = NULL;
       
   611         TS_ASSERT(retcount == 3);
       
   612         
       
   613         retcount = 0;
       
   614         doc = iSearcher->GetBatchDocumentL(4,retcount,count);
       
   615         for (int i=0; i<retcount; i++)
       
   616             delete doc[i];
       
   617         delete doc;
       
   618         doc = NULL;
       
   619         TS_ASSERT(retcount == 2);
       
   620         
       
   621         retcount = 0;
       
   622         TRAPD(err, doc = iSearcher->GetBatchDocumentL(11,retcount,count));
       
   623         TS_ASSERT(err == KErrDocumentAccessFailed);
       
   624         TS_ASSERT(retcount == 0);
       
   625         }
       
   626     return;
       
   627     }
       
   628 
       
   629 void CTestSearcher::testasyncgetbatchdoc()
       
   630     {
       
   631     //Make sure Hit count is 7 
       
   632     TInt hitcount = iSearcher->SearchL(KQueryString);
       
   633     if (hitcount)
       
   634         {
       
   635         TInt count =3;
       
   636         iretcount = 3;
       
   637         iSearcher->GetBatchDocumentL(0,*this,count);
       
   638         iWait->Start();
       
   639         
       
   640         iretcount = 3;
       
   641         iSearcher->GetBatchDocumentL(3,*this,count);
       
   642         iWait->Start();
       
   643         
       
   644         iretcount = 2;
       
   645         iSearcher->GetBatchDocumentL(4,*this,count);
       
   646         iWait->Start();
       
   647         
       
   648         iretcount = 0;
       
   649         iSearcher->GetBatchDocumentL(11,*this,count);
       
   650         iWait->Start();
       
   651                 
       
   652         }
       
   653     return;
       
   654     }