textandloc_pub/directory_localizer_api/tsrc/src/testsdkdirlocblocks.cpp
changeset 16 56cd22a7a1cb
parent 0 1fb32624e06b
child 18 67f6b0d39020
child 21 f2f7b3284356
equal deleted inserted replaced
0:1fb32624e06b 16:56cd22a7a1cb
     1 /*
       
     2 * Copyright (c) 2002 - 2007 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:  Test for CDirectoryLocalizer.h
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 // [INCLUDE FILES]
       
    21 #include <e32svr.h>
       
    22 #include <stifparser.h>
       
    23 #include <stiftestinterface.h>
       
    24 #include <barsread.h>
       
    25 #include <pathinfo.h>
       
    26 #include <cdirectorylocalizer.h>
       
    27 #include <testsdkdirloc.rsg>
       
    28 
       
    29 #include "testsdkdirloc.h"
       
    30 
       
    31 // ============================ MEMBER FUNCTIONS ===============================
       
    32 
       
    33 // -----------------------------------------------------------------------------
       
    34 // Ctestsdkdirloc::Delete
       
    35 // Delete here all resources allocated and opened from test methods. 
       
    36 // Called from destructor. 
       
    37 // -----------------------------------------------------------------------------
       
    38 //
       
    39 void CTestSDKDirLoc::Delete() 
       
    40     {
       
    41 
       
    42     }
       
    43 
       
    44 // -----------------------------------------------------------------------------
       
    45 // Ctestsdkdirloc::RunMethodL
       
    46 // Run specified method. Contains also table of test mothods and their names.
       
    47 // -----------------------------------------------------------------------------
       
    48 //
       
    49 TInt CTestSDKDirLoc::RunMethodL( 
       
    50     CStifItemParser& aItem ) 
       
    51     {
       
    52 
       
    53     static TStifFunctionInfo const KFunctions[] =
       
    54         {  
       
    55         // First string is the function name used in TestScripter script file.
       
    56         // Second is the actual implementation member function. 
       
    57         ENTRY( "TestDLNewL", CTestSDKDirLoc::TestDLNewL ),
       
    58         ENTRY( "TestDLNewLReaderL", CTestSDKDirLoc::TestDLNewLResReaderL ),
       
    59         ENTRY( "TestDLNewLResIDL", CTestSDKDirLoc::TestDLNewLResIDL ),
       
    60         ENTRY( "TestDLAddFromResourceL", CTestSDKDirLoc::TestDLAddFromResourceL ),
       
    61         ENTRY( "TestDLAddFromResourceLResIDL", CTestSDKDirLoc::TestDLAddFromResourceLResIDL ),
       
    62         ENTRY( "TestDLSetFullPath", CTestSDKDirLoc::TestDLSetFullPath ),
       
    63         ENTRY( "TestDLIsLocalized", CTestSDKDirLoc::TestDLIsLocalized ),
       
    64         ENTRY( "TestDLLocalizedName", CTestSDKDirLoc::TestDLLocalizedName ),
       
    65         ENTRY( "TestDLExtraData", CTestSDKDirLoc::TestDLExtraData ),
       
    66         ENTRY( "TestDLIcon", CTestSDKDirLoc::TestDLIcon ),
       
    67         ENTRY( "TestDLDelete", CTestSDKDirLoc::TestDLDelete ),
       
    68         // [test cases entries]
       
    69 
       
    70         };
       
    71 
       
    72     const TInt count = sizeof( KFunctions ) / sizeof( TStifFunctionInfo );
       
    73 
       
    74     return RunInternalL( KFunctions, count, aItem );
       
    75 
       
    76     }
       
    77 
       
    78 // -----------------------------------------------------------------------------
       
    79 // CTestSDKDirLoc::TestDLNewL
       
    80 // -----------------------------------------------------------------------------
       
    81 //
       
    82 
       
    83 TInt CTestSDKDirLoc::TestDLNewL( CStifItemParser& /*aItem*/ )
       
    84     {
       
    85     // Print to UI
       
    86     _LIT( KTestDLModule, "TestDLModule" );
       
    87     _LIT( KTestDLNewL, "In TestDLNewL" );
       
    88     TestModuleIf().Printf( 0, KTestDLModule, KTestDLNewL );
       
    89     // Print to log file
       
    90     iLog->Log( KTestDLNewL );
       
    91 
       
    92     TInt err = KErrNone;
       
    93     TRAP( err, iDirLocalizer = CDirectoryLocalizer::NewL() );
       
    94     
       
    95     return err;
       
    96 
       
    97     }
       
    98 
       
    99 // -----------------------------------------------------------------------------
       
   100 // CTestSDKDirLoc::TestDLNewLReaderL
       
   101 // -----------------------------------------------------------------------------
       
   102 //
       
   103 
       
   104 TInt CTestSDKDirLoc::TestDLNewLResReaderL( CStifItemParser& /*aItem*/ )
       
   105     {
       
   106     // Print to UI
       
   107     _LIT( KTestDLModule, "TestDLModule" );
       
   108     _LIT( KTestDLNewLReaderL, "In TestDLNewLReaderL" );
       
   109     TestModuleIf().Printf( 0, KTestDLModule, KTestDLNewLReaderL );
       
   110     // Print to log file
       
   111     iLog->Log( KTestDLNewLReaderL );
       
   112 
       
   113     TInt err = KErrNone;
       
   114     TResourceReader resReader;
       
   115     CCoeEnv::Static()->CreateResourceReaderLC( resReader, R_EXAMPLE_LOCALIZER_ENTRIES );
       
   116     TRAP( err, iDirLocalizer = CDirectoryLocalizer::NewL( resReader ) );
       
   117     CleanupStack::PopAndDestroy();
       
   118 
       
   119     return err;
       
   120 
       
   121     }
       
   122 
       
   123 // -----------------------------------------------------------------------------
       
   124 // CTestSDKDirLoc::TestDLNewLResIDL
       
   125 // -----------------------------------------------------------------------------
       
   126 //
       
   127 
       
   128 TInt CTestSDKDirLoc::TestDLNewLResIDL( CStifItemParser& /*aItem*/ )
       
   129     {
       
   130     // Print to UI
       
   131     _LIT( KTestDLModule, "TestDLModule" );
       
   132     _LIT( KTestDLNewLReaderL, "In TestDLNewLReaderL" );
       
   133     TestModuleIf().Printf( 0, KTestDLModule, KTestDLNewLReaderL );
       
   134     // Print to log file
       
   135     iLog->Log( KTestDLNewLReaderL );
       
   136 
       
   137     TInt err = KErrNone;
       
   138     TRAP( err, iDirLocalizer = CDirectoryLocalizer::NewL( R_EXAMPLE_LOCALIZER_ENTRIES ) );
       
   139 
       
   140     return err;
       
   141 
       
   142     }
       
   143 
       
   144 // -----------------------------------------------------------------------------
       
   145 // CTestSDKDirLoc::TestDLAddFromResourceL
       
   146 // -----------------------------------------------------------------------------
       
   147 //
       
   148 
       
   149 TInt CTestSDKDirLoc::TestDLAddFromResourceL( CStifItemParser& /*aItem*/ )
       
   150     {
       
   151     // Print to UI
       
   152     _LIT( KTestDLModule, "TestDLModule" );
       
   153     _LIT( KTestDLAddFromResourceL, "In TestDLAddFromResourceL" );
       
   154     TestModuleIf().Printf( 0, KTestDLModule, KTestDLAddFromResourceL );
       
   155     // Print to log file
       
   156     iLog->Log( KTestDLAddFromResourceL );
       
   157 
       
   158     TInt err = KErrNone;
       
   159     TResourceReader resReader;
       
   160     CCoeEnv::Static()->CreateResourceReaderLC( resReader, R_EXAMPLE_LOCALIZER_ENTRIES );
       
   161     TRAP( err, iDirLocalizer->AddFromResourceL( resReader ) );
       
   162     CleanupStack::PopAndDestroy();
       
   163 
       
   164     return err;
       
   165 
       
   166     }
       
   167 
       
   168 // -----------------------------------------------------------------------------
       
   169 // CTestSDKDirLoc::TestDLAddFromResourceLResIDL
       
   170 // -----------------------------------------------------------------------------
       
   171 //
       
   172 
       
   173 TInt CTestSDKDirLoc::TestDLAddFromResourceLResIDL( CStifItemParser& /*aItem*/ )
       
   174     {
       
   175     // Print to UI
       
   176     _LIT( KTestDLModule, "TestDLModule" );
       
   177     _LIT( KTestDLAddFromResourceLResIDL, "In TestDLAddFromResourceLResIDL" );
       
   178     TestModuleIf().Printf( 0, KTestDLModule, KTestDLAddFromResourceLResIDL );
       
   179     // Print to log file
       
   180     iLog->Log( KTestDLAddFromResourceLResIDL );
       
   181 
       
   182     TInt err = KErrNone;
       
   183     TRAP( err, iDirLocalizer->AddFromResourceL( R_EXAMPLE_LOCALIZER_ENTRIES ) );
       
   184 
       
   185     return err;
       
   186 
       
   187     }
       
   188 
       
   189 // -----------------------------------------------------------------------------
       
   190 // CTestSDKDirLoc::TestDLSetFullPath
       
   191 // -----------------------------------------------------------------------------
       
   192 //
       
   193 
       
   194 TInt CTestSDKDirLoc::TestDLSetFullPath( CStifItemParser& /*aItem*/ )
       
   195     {
       
   196     // Print to UI
       
   197     _LIT( KTestDLModule, "TestDLModule" );
       
   198     _LIT( KTestDLSetFullPath, "In TestDLSetFullPath" );
       
   199     TestModuleIf().Printf( 0, KTestDLModule, KTestDLSetFullPath );
       
   200     // Print to log file
       
   201     iLog->Log( KTestDLSetFullPath );
       
   202 
       
   203     TInt err = KErrNone;
       
   204     TFileName path = PathInfo::GetPath( PathInfo::EPhoneMemoryRootPath );
       
   205     TRAP( err, iDirLocalizer->SetFullPath( path ) );
       
   206 
       
   207     return err;
       
   208 
       
   209     }
       
   210 
       
   211 // -----------------------------------------------------------------------------
       
   212 // CTestSDKDirLoc::TestDLIsLocalized
       
   213 // -----------------------------------------------------------------------------
       
   214 //
       
   215 
       
   216 TInt CTestSDKDirLoc::TestDLIsLocalized( CStifItemParser& /*aItem*/ )
       
   217     {
       
   218     // Print to UI
       
   219     _LIT( KTestDLModule, "TestDLModule" );
       
   220     _LIT( KTestDLIsLocalized, "In TestDLIsLocalized" );
       
   221     TestModuleIf().Printf( 0, KTestDLModule, KTestDLIsLocalized );
       
   222     // Print to log file
       
   223     iLog->Log( KTestDLIsLocalized );
       
   224 
       
   225     TInt err = KErrNone;
       
   226     TRAP( err, iDirLocalizer->IsLocalized() );
       
   227 
       
   228     return err;
       
   229 
       
   230     }
       
   231 
       
   232 // -----------------------------------------------------------------------------
       
   233 // CTestSDKDirLoc::TestDLLocalizedName
       
   234 // -----------------------------------------------------------------------------
       
   235 //
       
   236 
       
   237 TInt CTestSDKDirLoc::TestDLLocalizedName( CStifItemParser& /*aItem*/ )
       
   238     {
       
   239     // Print to UI
       
   240     _LIT( KTestDLModule, "TestDLModule" );
       
   241     _LIT( KTestDLLocalizedName, "In TestDLLocalizedName" );
       
   242     TestModuleIf().Printf( 0, KTestDLModule, KTestDLLocalizedName );
       
   243     // Print to log file
       
   244     iLog->Log( KTestDLLocalizedName );
       
   245 
       
   246     TInt err = KErrNone;
       
   247     TRAP( err, iDirLocalizer->LocalizedName() );
       
   248 
       
   249     return err;
       
   250 
       
   251     }
       
   252 
       
   253 // -----------------------------------------------------------------------------
       
   254 // CTestSDKDirLoc::TestDLExtraData
       
   255 // -----------------------------------------------------------------------------
       
   256 //
       
   257 
       
   258 TInt CTestSDKDirLoc::TestDLExtraData( CStifItemParser& /*aItem*/ )
       
   259     {
       
   260     // Print to UI
       
   261     _LIT( KTestDLModule, "TestDLModule" );
       
   262     _LIT( KTestDLExtraData, "In TestDLExtraData" );
       
   263     TestModuleIf().Printf( 0, KTestDLModule, KTestDLExtraData );
       
   264     // Print to log file
       
   265     iLog->Log( KTestDLExtraData );
       
   266 
       
   267     TInt err = KErrNone;
       
   268     TRAP( err, iDirLocalizer->ExtraData() );
       
   269 
       
   270     return err;
       
   271 
       
   272     }
       
   273 
       
   274 // -----------------------------------------------------------------------------
       
   275 // CTestSDKDirLoc::TestDLIcon
       
   276 // -----------------------------------------------------------------------------
       
   277 //
       
   278 
       
   279 TInt CTestSDKDirLoc::TestDLIcon( CStifItemParser& /*aItem*/ )
       
   280     {
       
   281     // Print to UI
       
   282     _LIT( KTestDLModule, "TestDLModule" );
       
   283     _LIT( KTestDLIcon, "In TestDLIcon" );
       
   284     TestModuleIf().Printf( 0, KTestDLModule, KTestDLIcon );
       
   285     // Print to log file
       
   286     iLog->Log( KTestDLIcon );
       
   287 
       
   288     TInt err = KErrNone;
       
   289     TRAP( err, iDirLocalizer->Icon() );
       
   290 
       
   291     return err;
       
   292 
       
   293     }
       
   294 
       
   295 // -----------------------------------------------------------------------------
       
   296 // CTestSDKDirLoc::TestDLDelete
       
   297 // -----------------------------------------------------------------------------
       
   298 //
       
   299 TInt CTestSDKDirLoc::TestDLDelete( CStifItemParser& /*aItem*/)
       
   300     {
       
   301     // Print to UI
       
   302     _LIT( KTestDLModule, "TestDLModule" );
       
   303     _LIT( KTestDLDelete, "In TestDLDelete" );
       
   304     TestModuleIf().Printf( 0, KTestDLModule, KTestDLDelete );
       
   305     // Print to log file
       
   306     iLog->Log( KTestDLDelete );
       
   307 
       
   308     if ( iDirLocalizer )
       
   309         {
       
   310         delete iDirLocalizer;
       
   311         iDirLocalizer = NULL;
       
   312         }
       
   313 
       
   314     return KErrNone;
       
   315     }
       
   316 
       
   317 //  [End of File]