organizer_pub/calendar_interim_utils2_api/tsrc/stiff/src/caleninterimutils2testblocks.cpp
changeset 0 f979ecb2b13e
child 18 c198609911f9
child 48 bf573002ff72
equal deleted inserted replaced
-1:000000000000 0:f979ecb2b13e
       
     1 /*
       
     2 * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). 
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 * 
       
    14 * Description: This file contains testclass implementation.
       
    15 *
       
    16 */
       
    17 
       
    18 // [INCLUDE FILES] - do not remove
       
    19 #include <e32svr.h>
       
    20 #include <StifParser.h>
       
    21 #include <Stiftestinterface.h>
       
    22 
       
    23 #include "caleninterimutils2test.h"
       
    24 #include "CalProgressCallBackListener.h"
       
    25 #include "calenglobaldata.h"
       
    26 
       
    27 
       
    28 //  LOCAL CONSTANTS AND MACROS
       
    29 const TInt KDefaultStartTime( 8 );
       
    30 
       
    31 // ============================= LOCAL FUNCTIONS ===============================
       
    32 
       
    33 // ============================ MEMBER FUNCTIONS ===============================
       
    34 
       
    35 // -----------------------------------------------------------------------------
       
    36 // CCalendarCommonUtilsTest::Delete
       
    37 // Delete here all resources allocated and opened from test methods. 
       
    38 // Called from destructor. 
       
    39 // -----------------------------------------------------------------------------
       
    40 //
       
    41 void CCalenInterimUtils2Test::Delete() 
       
    42     {
       
    43     // Nothing.
       
    44     }
       
    45 
       
    46 // -----------------------------------------------------------------------------
       
    47 // CCalendarCommonUtilsTest::RunMethodL
       
    48 // Run specified method. Contains also table of test mothods and their names.
       
    49 // -----------------------------------------------------------------------------
       
    50 //
       
    51 TInt CCalenInterimUtils2Test::RunMethodL( 
       
    52         CStifItemParser& aItem ) 
       
    53     {
       
    54 
       
    55     static TStifFunctionInfo const KFunctions[] =
       
    56         {
       
    57         // Copy this line for every implemented function.
       
    58         // First string is the function name used in TestScripter script file.
       
    59         // Second is the actual implementation member function. 
       
    60         // Example: ENTRY( "Example", CCalenInterimUtils2Test::ExampleL ),
       
    61 
       
    62         /** Test functions for API CalenDateUtils */
       
    63         ENTRY( "TestGlobalUUID", 
       
    64                 CCalenInterimUtils2Test::TestGlobalUUIDL ),
       
    65         //ADD NEW ENTRY HERE
       
    66         // [test cases entries] - Do not remove
       
    67         };
       
    68 
       
    69     const TInt count = sizeof( KFunctions ) / sizeof( TStifFunctionInfo );
       
    70     return RunInternalL( KFunctions, count, aItem );
       
    71 
       
    72     }
       
    73 
       
    74 // -----------------------------------------------------------------------------
       
    75 // CCalenInterimUtils2Test::TestGlobalUUIDL
       
    76 // Test funtion to test the API CCalenInterimUtils2::GlobalUidL
       
    77 // (other items were commented in a header).
       
    78 // -----------------------------------------------------------------------------
       
    79 //
       
    80 TInt CCalenInterimUtils2Test::TestGlobalUUIDL( CStifItemParser& aItem )
       
    81     {
       
    82     TInt retValue = KErrNone;
       
    83     // Print to UI
       
    84     _LIT( KCalenInterimUtils2Test, "CalenInterimUtils2Test" );
       
    85     _LIT( KDuplicateUids, "Uids are duplicate" );
       
    86     _LIT( KTestGlobalUUID, "In TestGlobalUUIDL" );
       
    87     _LIT( KTestGlobalUUIDs, "TestGlobalUUIDs are " );
       
    88     
       
    89     TestModuleIf().Printf( 0, KCalenInterimUtils2Test, KTestGlobalUUID );
       
    90     // Print to log file
       
    91     iLog->Log( KTestGlobalUUID );
       
    92     iLog->Log( KTestGlobalUUIDs );
       
    93         // Construct the calendar global data.
       
    94     CCalProgressCallBackListener *callBack = NULL;
       
    95     callBack = CCalProgressCallBackListener::NewL();
       
    96     CCalenGlobalData* globalData = CCalenGlobalData::NewL( *callBack );
       
    97     // Make the call to the API.
       
    98     // Create unique ID.
       
    99     RPointerArray<HBufC8> guids;
       
   100 
       
   101     TInt i = 0;
       
   102     
       
   103     for( ; i<20; i++ )
       
   104         {
       
   105         HBufC8* guid = globalData->InterimUtilsL().GlobalUidL();
       
   106         iLog->Log( *guid );
       
   107         guids.AppendL(guid);
       
   108         }
       
   109     
       
   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();
       
   124 
       
   125     // Validate the result.
       
   126 
       
   127     return retValue;
       
   128 
       
   129     }
       
   130 
       
   131 
       
   132 
       
   133 // ========================== OTHER EXPORTED FUNCTIONS =========================
       
   134 // None
       
   135 
       
   136 //  [End of File] - Do not remove