serviceproviders/sapi_mediamanagement/tsrc/testing/tmediaprovidertesting/src/tmediaprovidertestingBlocks.cpp
changeset 22 fc9cf246af83
parent 19 989d2f495d90
child 33 50974a8b132e
equal deleted inserted replaced
19:989d2f495d90 22:fc9cf246af83
    19 // [INCLUDE FILES] - do not remove
    19 // [INCLUDE FILES] - do not remove
    20 #include <e32svr.h>
    20 #include <e32svr.h>
    21 #include <StifParser.h>
    21 #include <StifParser.h>
    22 #include <Stiftestinterface.h>
    22 #include <Stiftestinterface.h>
    23 #include <LiwServiceHandler.h>
    23 #include <LiwServiceHandler.h>
    24 
    24 #include<f32file.h>
    25 #include "tmediaprovidertesting.h"
    25 #include "tmediaprovidertesting.h"
    26 #include "tmediaprovidertesting.hrh"
    26 #include "tmediaprovidertesting.hrh"
       
    27 #include "tmediaobserver.h"
    27 
    28 
    28 
    29 
    29 
    30 
    30 using namespace LIW;
    31 using namespace LIW;
       
    32 
       
    33 TInt count = 0; 
    31 
    34 
    32 // ============================ MEMBER FUNCTIONS ===============================
    35 // ============================ MEMBER FUNCTIONS ===============================
    33 
    36 
    34 // -----------------------------------------------------------------------------
    37 // -----------------------------------------------------------------------------
    35 // Ctmediaprovidertesting::Delete
    38 // Ctmediaprovidertesting::Delete
    58 //
    61 //
    59 TInt Ctmediaprovidertesting::RunMethodL(CStifItemParser& aItem) 
    62 TInt Ctmediaprovidertesting::RunMethodL(CStifItemParser& aItem) 
    60     {
    63     {
    61     static TStifFunctionInfo const KFunctions[] =
    64     static TStifFunctionInfo const KFunctions[] =
    62         {          
    65         {          
    63         ENTRY("GetFilesListL", Ctmediaprovidertesting::GetFilesListL)            
    66         ENTRY("GetFilesListL", Ctmediaprovidertesting::GetFilesListL)  , 
       
    67         ENTRY("GetListBackToBackCall",Ctmediaprovidertesting::GetListBackToBackCallL)
    64         };
    68         };
    65     const TInt count = sizeof( KFunctions ) / 
    69     const TInt count = sizeof( KFunctions ) / 
    66                         sizeof( TStifFunctionInfo );
    70                         sizeof( TStifFunctionInfo );
    67     return RunInternalL( KFunctions, count, aItem );
    71     return RunInternalL( KFunctions, count, aItem );
    68     }
    72     }
   188                                                         KService);    
   192                                                         KService);    
   189     CleanupStack :: PushL(criteria);    
   193     CleanupStack :: PushL(criteria);    
   190     
   194     
   191     criteria->SetServiceClass(TUid::Uid(KLiwClassBase));    
   195     criteria->SetServiceClass(TUid::Uid(KLiwClassBase));    
   192 	RCriteriaArray critArray;
   196 	RCriteriaArray critArray;
       
   197 	CleanupClosePushL(critArray);
   193     critArray.AppendL(criteria);
   198     critArray.AppendL(criteria);
   194     
   199     
   195     iServicehandler->AttachL(critArray);
   200     iServicehandler->AttachL(critArray);
   196     iServicehandler->ExecuteServiceCmdL(*criteria, 
   201     iServicehandler->ExecuteServiceCmdL(*criteria, 
   197                                        *iInList, 
   202                                        *iInList, 
   206         {
   211         {
   207         User::Leave(KErrNotFound);
   212         User::Leave(KErrNotFound);
   208         }                                             
   213         }                                             
   209     iInList->Reset();
   214     iInList->Reset();
   210     iOutList->Reset();    
   215     iOutList->Reset();    
       
   216     CleanupStack :: PopAndDestroy(); 
   211     CleanupStack :: PopAndDestroy(criteria); 
   217     CleanupStack :: PopAndDestroy(criteria); 
   212     critArray.Close();
       
   213     }           
   218     }           
       
   219 
       
   220 /*--------------------------------------------------------------------------
       
   221  Ctmediaprovidertesting :: LoadServiceL
       
   222  Loads the mediamanagement service.
       
   223 -----------------------------------------------------------------------------
       
   224 */
       
   225 TInt Ctmediaprovidertesting::GetListBackToBackCallL( CStifItemParser& aItem )
       
   226     {
       
   227     TInt error = KErrGeneral;
       
   228      
       
   229      LoadServiceL(); 
       
   230   //__UHEAP_MARK;
       
   231      // Creating callback instance
       
   232   TInt a  =User::CountAllocCells();
       
   233      CMediaObserver* observer = CMediaObserver::NewL();
       
   234      CleanupStack::PushL(observer);
       
   235      //Parsing stiff input 
       
   236      observer->ParseStiffInput(aItem);
       
   237      
       
   238      //Creating another callback
       
   239      CMediaObserver* observer2 = CMediaObserver::NewL();
       
   240      CleanupStack::PushL(observer2);
       
   241      //Parsing stiff input 
       
   242      observer2->ParseStiffInput(aItem);
       
   243    
       
   244    // Giving first call  
       
   245      iIface->ExecuteCmdL(command8,
       
   246                          *(observer->iInList),
       
   247                          *(observer->iOutList),
       
   248                          KLiwOptASyncronous,
       
   249                          observer);    
       
   250      TInt pos = 0;
       
   251      const TLiwGenericParam* p = observer->iOutList->FindFirst(pos,
       
   252                                                      KErrorCode); // Finding Error Code
       
   253      //count++;
       
   254      if(p)
       
   255          {
       
   256          TInt retcode = p->Value().AsTInt32();
       
   257          if(KErrNone == retcode)
       
   258              {
       
   259    //          CActiveScheduler::Start();
       
   260              //give second call 
       
   261              
       
   262             iIface->ExecuteCmdL(command8,
       
   263                                   *(observer2->iInList),
       
   264                                   *(observer2->iOutList),
       
   265                                   KLiwOptASyncronous,
       
   266                                   observer2);    
       
   267              //count++;
       
   268              pos =0 ;
       
   269              
       
   270              const TLiwGenericParam* p = observer2->iOutList->FindFirst(pos,
       
   271                                                              KErrorCode); // Finding Error Code
       
   272             
       
   273              
       
   274              if(p)
       
   275                  {
       
   276                  TInt retcode = p->Value().AsTInt32();
       
   277                  if(KErrNone == retcode)
       
   278                      {
       
   279                      CActiveScheduler::Start();                     
       
   280                      }
       
   281                  else
       
   282                      {
       
   283                      if(observer2->iExpErrorCode == retcode)
       
   284                          {
       
   285                          observer2->iResult = KErrNone;
       
   286                          }
       
   287                      else
       
   288                          {
       
   289                          User::Leave(KErrGeneral);
       
   290                          }             
       
   291                      }
       
   292 
       
   293                      }
       
   294              
       
   295              
       
   296                  }
       
   297          else
       
   298              {  if(observer->iExpErrorCode == retcode)
       
   299                  {
       
   300                  observer->iResult = KErrNone;
       
   301                  }
       
   302              else
       
   303                  {
       
   304                  User::Leave(KErrGeneral);
       
   305                  }          
       
   306              }
       
   307            }   
       
   308 
       
   309      if( (KErrNone == observer->iResult) && (KErrNone == observer2->iResult) )
       
   310          {
       
   311          error = KErrNone ;
       
   312          }
       
   313      else
       
   314          {
       
   315          error = KErrGeneral;
       
   316          }
       
   317      
       
   318 observer->iInList->Reset();
       
   319 observer->iOutList->Reset();
       
   320      
       
   321 observer2->iInList->Reset();
       
   322 observer2->iOutList->Reset();
       
   323 
       
   324 CleanupStack::PopAndDestroy(observer2);
       
   325 CleanupStack::PopAndDestroy(observer);
       
   326 a  =User::CountAllocCells();
       
   327 a = error;
       
   328 //__UHEAP_MARKEND;    
       
   329     return a;
       
   330     }