mpengine/tsrc/unittest_mpmpxisolatedcollectionhelper/src/unittest_mpmpxisolatedcollectionhelper.cpp
changeset 48 af3740e3753f
parent 29 8192e5b5c935
child 51 560ce2306a17
equal deleted inserted replaced
42:79c49924ae23 48:af3740e3753f
    48 
    48 
    49 TestCMpMpxIsolatedCollectionHelper::TestCMpMpxIsolatedCollectionHelper()
    49 TestCMpMpxIsolatedCollectionHelper::TestCMpMpxIsolatedCollectionHelper()
    50     : mTest( 0 ),
    50     : mTest( 0 ),
    51       iEntriesFromoOpenCallback ( 0 ),
    51       iEntriesFromoOpenCallback ( 0 ),
    52       iErrorFromoOpenCallback( KErrNone ),
    52       iErrorFromoOpenCallback( KErrNone ),
    53       iOpenCallbackCounter( 0 )
    53       iOpenCallbackCounter( 0 ),
       
    54       iOpenRestoreCallbackCounter( 0 )
    54 {
    55 {
    55 }
    56 }
    56 
    57 
    57 TestCMpMpxIsolatedCollectionHelper::~TestCMpMpxIsolatedCollectionHelper()
    58 TestCMpMpxIsolatedCollectionHelper::~TestCMpMpxIsolatedCollectionHelper()
    58 {
    59 {
   112     QCOMPARE(mTest->iIncrementalOpenUtil->iStart,TBool(ETrue));
   113     QCOMPARE(mTest->iIncrementalOpenUtil->iStart,TBool(ETrue));
   113     QCOMPARE(mTest->iFirstIncrementalOpen,TBool(ETrue));
   114     QCOMPARE(mTest->iFirstIncrementalOpen,TBool(ETrue));
   114     QCOMPARE(mTest->iIncrementalOpenUtil->iDirection,CMPXCollectionOpenUtility::EFetchNormal);
   115     QCOMPARE(mTest->iIncrementalOpenUtil->iDirection,CMPXCollectionOpenUtility::EFetchNormal);
   115     QCOMPARE(mTest->iIncrementalOpenUtil->iChunkSize, KIncrementalFetchBlockSize);
   116     QCOMPARE(mTest->iIncrementalOpenUtil->iChunkSize, KIncrementalFetchBlockSize);
   116     QCOMPARE((int)mTest->iIncrementalOpenUtil->iPath, (int)path);
   117     QCOMPARE((int)mTest->iIncrementalOpenUtil->iPath, (int)path);
       
   118     QCOMPARE(mTest->iOpenMode, CMpMpxIsolatedCollectionHelper::DefaultMode );
       
   119     
       
   120     mTest->OpenCollectionL(*path,0,CMpMpxIsolatedCollectionHelper::RestorePathMode);
       
   121     QCOMPARE(mTest->iIncrementalOpenUtil->iDelay, KIncrementalDelayHalfSecond);
       
   122     QCOMPARE(mTest->iIncrementalOpenUtil->iStop,TBool(ETrue));
       
   123     QCOMPARE(mTest->iIncrementalOpenUtil->iStart,TBool(ETrue));
       
   124     QCOMPARE(mTest->iFirstIncrementalOpen,TBool(ETrue));
       
   125     QCOMPARE(mTest->iIncrementalOpenUtil->iDirection,CMPXCollectionOpenUtility::EFetchNormal);
       
   126     QCOMPARE(mTest->iIncrementalOpenUtil->iChunkSize, KIncrementalFetchBlockSize);
       
   127     QCOMPARE((int)mTest->iIncrementalOpenUtil->iPath, (int)path);
       
   128     QCOMPARE(mTest->iOpenMode, CMpMpxIsolatedCollectionHelper::RestorePathMode );
       
   129     
   117     delete path;
   130     delete path;
   118 }
   131 }
   119 
   132 
   120 /*!
   133 /*!
   121  Tests HandleOpen.
   134  Tests HandleOpen.
   122  */
   135  */
   123 void TestCMpMpxIsolatedCollectionHelper::testHandleOpen()
   136 void TestCMpMpxIsolatedCollectionHelper::testHandleOpen()
   124 {
   137 {
       
   138      //Default Mode
   125      iEntriesFromoOpenCallback = 0;
   139      iEntriesFromoOpenCallback = 0;
   126      iErrorFromoOpenCallback = KErrArgument;
   140      iErrorFromoOpenCallback = KErrArgument;
   127      iOpenCallbackCounter = 0;
   141      iOpenCallbackCounter = 0;
   128      CMPXMedia *media = CMPXMedia::NewL();
   142      CMPXMedia *media = CMPXMedia::NewL();
   129      mTest->iFirstIncrementalOpen = ETrue;
   143      mTest->iFirstIncrementalOpen = ETrue;
   130      mTest->HandleOpenL(*media, 0, false, KErrNone);
   144      mTest->HandleOpenL(*media, 0, false, KErrNone);
   131      QCOMPARE((int)iEntriesFromoOpenCallback,(int)media);
   145      QCOMPARE((int)iEntriesFromoOpenCallback,(int)media);
   132      QCOMPARE(iErrorFromoOpenCallback,KErrNone);
   146      QCOMPARE(iErrorFromoOpenCallback,KErrNone);
   133      QCOMPARE(iOpenCallbackCounter,1);
   147      QCOMPARE(iOpenCallbackCounter,1);
       
   148      QCOMPARE(iOpenRestoreCallbackCounter,0);
       
   149      
       
   150      //RestorePath mode
       
   151      CMPXCollectionPath* path = CMPXCollectionPath::NewL();
       
   152      mTest->iFirstIncrementalOpen = ETrue;
       
   153      mTest->iOpenMode = CMpMpxIsolatedCollectionHelper::RestorePathMode;
       
   154      mTest->HandleOpenL(*media, 0, false, KErrNotFound);
       
   155      
       
   156      QCOMPARE(iErrorFromoOpenCallback,KErrNotFound);
       
   157      QCOMPARE(iOpenCallbackCounter,1);
       
   158      QCOMPARE(iOpenRestoreCallbackCounter,1);
       
   159      
   134 }
   160 }
   135  
   161  
   136 /*!
   162 /*!
   137  Used to keep track of the callback from teh isolated collection helper.
   163  Used to keep track of the callback from the isolated collection helper.
   138  */
   164  */
   139 void TestCMpMpxIsolatedCollectionHelper::HandleIsolatedOpenL( const CMPXMedia& aEntries, TInt aError )
   165 void TestCMpMpxIsolatedCollectionHelper::HandleIsolatedOpenL( const CMPXMedia& aEntries, TInt aError )
   140 {
   166 {
   141      iEntriesFromoOpenCallback = &aEntries;
   167      iEntriesFromoOpenCallback = &aEntries;
   142      iErrorFromoOpenCallback = aError;
   168      iErrorFromoOpenCallback = aError;
   143      iOpenCallbackCounter++;
   169      iOpenCallbackCounter++;
   144 }
   170 }
   145 
   171 
       
   172 /*!
       
   173  Used to keep track of the callback from the isolated collection helper.
       
   174  */
       
   175 void TestCMpMpxIsolatedCollectionHelper::HandleIsolatedOpenRestorePathL( const CMPXCollectionPath& aPath, TInt aError )
       
   176 {
       
   177     Q_UNUSED( aPath );
       
   178     iErrorFromoOpenCallback = aError;
       
   179     iOpenRestoreCallbackCounter++;
       
   180 }
   146 //end of file
   181 //end of file