organizer_pub/calendar_interim_utils2_api/tsrc/stiff/src/caleninterimutils2testblocks.cpp
branchRCL_3
changeset 48 bf573002ff72
parent 0 f979ecb2b13e
child 60 96907930389d
equal deleted inserted replaced
36:9c5b1510919f 48:bf573002ff72
    77 // (other items were commented in a header).
    77 // (other items were commented in a header).
    78 // -----------------------------------------------------------------------------
    78 // -----------------------------------------------------------------------------
    79 //
    79 //
    80 TInt CCalenInterimUtils2Test::TestGlobalUUIDL( CStifItemParser& aItem )
    80 TInt CCalenInterimUtils2Test::TestGlobalUUIDL( CStifItemParser& aItem )
    81     {
    81     {
       
    82     CDesC8ArrayFlat* uidArray = new ( ELeave ) CDesC8ArrayFlat( KTestMax );
    82     TInt retValue = KErrNone;
    83     TInt retValue = KErrNone;
    83     // Print to UI
    84     // Print to UI
    84     _LIT( KCalenInterimUtils2Test, "CalenInterimUtils2Test" );
    85     _LIT( KCalenInterimUtils2Test, "CalenInterimUtils2Test" );
    85     _LIT( KDuplicateUids, "Uids are duplicate" );
    86     _LIT( KDuplicateUids, "Uids are duplicate" );
    86     _LIT( KTestGlobalUUID, "In TestGlobalUUIDL" );
    87     _LIT( KTestGlobalUUID, "In TestGlobalUUIDL" );
    93         // Construct the calendar global data.
    94         // Construct the calendar global data.
    94     CCalProgressCallBackListener *callBack = NULL;
    95     CCalProgressCallBackListener *callBack = NULL;
    95     callBack = CCalProgressCallBackListener::NewL();
    96     callBack = CCalProgressCallBackListener::NewL();
    96     CCalenGlobalData* globalData = CCalenGlobalData::NewL( *callBack );
    97     CCalenGlobalData* globalData = CCalenGlobalData::NewL( *callBack );
    97     // Make the call to the API.
    98     // Make the call to the API.
    98     // Create unique ID.
    99     // Create unique ID.   
    99     RPointerArray<HBufC8> guids;
   100     TBuf8<100> outputBuffer;
   100 
       
   101     TInt i = 0;
   101     TInt i = 0;
   102     
   102     
   103     for( ; i<20; i++ )
   103     for( ; i<2000; i++ )
   104         {
   104         {
   105         HBufC8* guid = globalData->InterimUtilsL().GlobalUidL();
   105         HBufC8* guid = globalData->InterimUtilsL().GlobalUidL();
   106         iLog->Log( *guid );
   106         CleanupStack::PushL(guid);
   107         guids.AppendL(guid);
   107         iLog->Log( *guid );       
       
   108         TRAPD( err, uidArray->InsertIsqL( *guid ) );
       
   109         
       
   110         if ( err == KErrAlreadyExists )
       
   111             {
       
   112             outputBuffer.Zero();
       
   113             outputBuffer.Append( _L8( "\n err == KErrAlreadyExists\n" ) );
       
   114             iLog->Log( outputBuffer );
       
   115             RDebug::Print(_L("failed %d"),i);
       
   116             retValue = KErrNotFound;            
       
   117             }
       
   118 
       
   119         CleanupStack::PopAndDestroy( guid );
   108         }
   120         }
   109     
   121    
   110     for(i=1; i < 20; i++)
       
   111         {
       
   112         for(TInt j = 0; j < i; j++)
       
   113             {
       
   114             if( guids[j] == guids[i] )
       
   115                 {
       
   116                 iLog->Log( KDuplicateUids );
       
   117                 retValue = KErrNotFound;
       
   118                 break;
       
   119                 }
       
   120             }
       
   121         }
       
   122     guids.ResetAndDestroy();
       
   123     globalData->Release();
   122     globalData->Release();
   124 
   123     delete uidArray; //cleanup uid array
   125     // Validate the result.
   124     // Validate the result.
   126 
   125 
   127     return retValue;
   126     return retValue;
   128 
   127 
   129     }
   128     }