commonservices/PlatformEnv/tsrc/platformenvtest/src/PlatformEnvTestCases.cpp
changeset 0 4e1aa6a622a0
child 21 ccb4f6b3db21
equal deleted inserted replaced
-1:000000000000 0:4e1aa6a622a0
       
     1 /*
       
     2 * Copyright (c) 2002 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:  ?Description
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 // INCLUDE FILES
       
    21 #include <e32math.h>
       
    22 #include <f32file.h>
       
    23 #include "PlatformEnvTest.h"
       
    24 #include <PathInfo.h>
       
    25 #include <DriveInfo.h>
       
    26 
       
    27 // EXTERNAL DATA STRUCTURES
       
    28 //extern  ?external_data;
       
    29 
       
    30 // EXTERNAL FUNCTION PROTOTYPES  
       
    31 //extern ?external_function( ?arg_type,?arg_type );
       
    32 
       
    33 // CONSTANTS
       
    34 //const ?type ?constant_var = ?constant;
       
    35 
       
    36 // MACROS
       
    37 //#define ?macro ?macro_def
       
    38 
       
    39 // LOCAL CONSTANTS AND MACROS
       
    40 //const ?type ?constant_var = ?constant;
       
    41 //#define ?macro_name ?macro_def
       
    42 
       
    43 // MODULE DATA STRUCTURES
       
    44 //enum ?declaration
       
    45 //typedef ?declaration
       
    46 
       
    47 // LOCAL FUNCTION PROTOTYPES
       
    48 //?type ?function_name( ?arg_type, ?arg_type );
       
    49 
       
    50 // FORWARD DECLARATIONS
       
    51 //class ?FORWARD_CLASSNAME;
       
    52 
       
    53 // ============================= LOCAL FUNCTIONS ===============================
       
    54 
       
    55 // -----------------------------------------------------------------------------
       
    56 // ?function_name ?description.
       
    57 // ?description
       
    58 // Returns: ?value_1: ?description
       
    59 //          ?value_n: ?description_line1
       
    60 //                    ?description_line2
       
    61 // -----------------------------------------------------------------------------
       
    62 //
       
    63 /*
       
    64 ?type ?function_name(
       
    65     ?arg_type arg,  // ?description
       
    66     ?arg_type arg)  // ?description
       
    67     {
       
    68 
       
    69     ?code  // ?comment
       
    70 
       
    71     // ?comment
       
    72     ?code
       
    73     }
       
    74 */
       
    75 
       
    76 // ============================ MEMBER FUNCTIONS ===============================
       
    77 
       
    78 // -----------------------------------------------------------------------------
       
    79 // CPlatformEnvTest::Case
       
    80 // Returns a test case by number.
       
    81 //
       
    82 // This function contains an array of all available test cases 
       
    83 // i.e pair of case name and test function. If case specified by parameter
       
    84 // aCaseNumber is found from array, then that item is returned.
       
    85 // 
       
    86 // The reason for this rather complicated function is to specify all the
       
    87 // test cases only in one place. It is not necessary to understand how
       
    88 // function pointers to class member functions works when adding new test
       
    89 // cases. See function body for instructions how to add new test case.
       
    90 // -----------------------------------------------------------------------------
       
    91 //
       
    92 const TCaseInfo CPlatformEnvTest::Case ( 
       
    93     const TInt aCaseNumber ) const 
       
    94      {
       
    95 
       
    96     /**
       
    97     * To add new test cases, implement new test case function and add new 
       
    98     * line to KCases array specify the name of the case and the function 
       
    99     * doing the test case
       
   100     * In practice, do following
       
   101     * 1) Make copy of existing test case function and change its name
       
   102     *    and functionality. Note that the function must be added to 
       
   103     *    PlatformEnvTest.cpp file and to PlatformEnvTest.h 
       
   104     *    header file.
       
   105     *
       
   106     * 2) Add entry to following KCases array either by using:
       
   107     *
       
   108     * 2.1: FUNCENTRY or ENTRY macro
       
   109     * ENTRY macro takes two parameters: test case name and test case 
       
   110     * function name.
       
   111     *
       
   112     * FUNCENTRY macro takes only test case function name as a parameter and
       
   113     * uses that as a test case name and test case function name.
       
   114     *
       
   115     * Or
       
   116     *
       
   117     * 2.2: OOM_FUNCENTRY or OOM_ENTRY macro. Note that these macros are used
       
   118     * only with OOM (Out-Of-Memory) testing!
       
   119     *
       
   120     * OOM_ENTRY macro takes five parameters: test case name, test case 
       
   121     * function name, TBool which specifies is method supposed to be run using
       
   122     * OOM conditions, TInt value for first heap memory allocation failure and 
       
   123     * TInt value for last heap memory allocation failure.
       
   124     * 
       
   125     * OOM_FUNCENTRY macro takes test case function name as a parameter and uses
       
   126     * that as a test case name, TBool which specifies is method supposed to be
       
   127     * run using OOM conditions, TInt value for first heap memory allocation 
       
   128     * failure and TInt value for last heap memory allocation failure. 
       
   129     */ 
       
   130 
       
   131     static TCaseInfoInternal const KCases[] =
       
   132         {
       
   133         // To add new test cases, add new items to this array
       
   134         //FUNCENTRY( PrintTest ),
       
   135         ENTRY( "[PLATFORMENV] PathTest", PathTest ),
       
   136         ENTRY( "[PLATFORMENV] GetPathTest", GetPathTest ),       
       
   137         ENTRY( "[PLATFORMENV] GetRootPathTest", GetRootPathTest ),
       
   138         ENTRY( "[PLATFORMENV] GetFullPathTest", GetFullPathTest ),
       
   139         ENTRY( "[PLATFORMENV] PathTypeTest", PathTypeTest ),
       
   140         ENTRY( "[PLATFORMENV] GetListOfPathsTest", GetListOfPathsTest ),
       
   141         ENTRY( "[PLATFORMENV] GetDefaultDriveTest", GetDefaultDriveTest ),
       
   142         ENTRY( "[PLATFORMENV] GetDefaultDriveTest2", GetDefaultDriveTest2 ),
       
   143         ENTRY( "[PLATFORMENV] GetDriveStatusTest", GetDriveStatusTest ),
       
   144         ENTRY( "[PLATFORMENV] GetUserVisibleDrivesTest", GetUserVisibleDrivesTest ),
       
   145         ENTRY( "[PLATFORMENV] StripUserHiddenDrivesTest", StripUserHiddenDrivesTest ),
       
   146         ENTRY( "[PLATFORMENV] DriveCountTest", DriveCountTest ),
       
   147         ENTRY( "[PLATFORMENV] DriveArrayTest", DriveArrayTest ),
       
   148         ENTRY( "[PLATFORMENV] GetUserVisibleDrivesTest2", GetUserVisibleDrivesTest2 ),
       
   149      
       
   150         OOM_ENTRY( "[OOM_PLATFORMENV] PathTest", PathTest ,ETrue,1,5),
       
   151         OOM_ENTRY( "[OOM_PLATFORMENV] GetPathTest", GetPathTest ,ETrue,1,5),  
       
   152         OOM_ENTRY( "[OOM_PLATFORMENV] GetRootPathTest", GetRootPathTest ,ETrue,1,5),
       
   153         OOM_ENTRY( "[OOM_PLATFORMENV] GetFullPathTest", GetFullPathTest ,ETrue,1,5),
       
   154         OOM_ENTRY( "[OOM_PLATFORMENV] PathTypeTest", PathTypeTest ,ETrue,1,5),
       
   155         OOM_ENTRY( "[OOM_PLATFORMENV] GetListOfPathsTest", GetListOfPathsTest,ETrue,1,5 ),
       
   156         OOM_ENTRY( "[OOM_PLATFORMENV] GetDefaultDriveTest", GetDefaultDriveTest ,ETrue,1,5),
       
   157         OOM_ENTRY( "[OOM_PLATFORMENV] GetDefaultDriveTest2", GetDefaultDriveTest2 ,ETrue,1,5),
       
   158         OOM_ENTRY( "[OOM_PLATFORMENV] GetDriveStatusTest", GetDriveStatusTest ,ETrue,1,5),
       
   159         OOM_ENTRY( "[OOM_PLATFORMENV] GetUserVisibleDrivesTest", GetUserVisibleDrivesTest,ETrue,1,5 ),
       
   160         OOM_ENTRY( "[OOM_PLATFORMENV] StripUserHiddenDrivesTest", StripUserHiddenDrivesTest ,ETrue,1,5),
       
   161         OOM_ENTRY( "[OOM_PLATFORMENV] DriveCountTest", DriveCountTest ,ETrue,1,5),
       
   162         OOM_ENTRY( "[OOM_PLATFORMENV] DriveArrayTest", DriveArrayTest ,ETrue,1,5),
       
   163         OOM_ENTRY( "[OOM_PLATFORMENV] GetUserVisibleDrivesTest2", GetUserVisibleDrivesTest2 ,ETrue,1,5)
       
   164                 
       
   165         // Example how to use OOM functionality
       
   166         //OOM_ENTRY( "Loop test with OOM", LoopTest, ETrue, 2, 3),
       
   167         //OOM_FUNCENTRY( PrintTest, ETrue, 1, 3 ),
       
   168         };
       
   169 
       
   170     // Verify that case number is valid
       
   171     if( (TUint) aCaseNumber >= sizeof( KCases ) / 
       
   172                                sizeof( TCaseInfoInternal ) )
       
   173         {
       
   174         // Invalid case, construct empty object
       
   175         TCaseInfo null( (const TText*) L"" );
       
   176         null.iMethod = NULL;
       
   177         null.iIsOOMTest = EFalse;
       
   178         null.iFirstMemoryAllocation = 0;
       
   179         null.iLastMemoryAllocation = 0;
       
   180         return null;
       
   181         } 
       
   182 
       
   183     // Construct TCaseInfo object and return it
       
   184     TCaseInfo tmp ( KCases[ aCaseNumber ].iCaseName );
       
   185     tmp.iMethod = KCases[ aCaseNumber ].iMethod;
       
   186     tmp.iIsOOMTest = KCases[ aCaseNumber ].iIsOOMTest;
       
   187     tmp.iFirstMemoryAllocation = KCases[ aCaseNumber ].iFirstMemoryAllocation;
       
   188     tmp.iLastMemoryAllocation = KCases[ aCaseNumber ].iLastMemoryAllocation;
       
   189     return tmp;
       
   190 
       
   191     }
       
   192 
       
   193 // -----------------------------------------------------------------------------
       
   194 // CPlatformEnvTest::PrintTest
       
   195 // Simple printing to UI test.
       
   196 // -----------------------------------------------------------------------------
       
   197 //
       
   198 TInt CPlatformEnvTest::PrintTest( 
       
   199     TTestResult& aResult )
       
   200     {
       
   201      /* Simple print test */
       
   202     _LIT( KPrintTest, "PrintTest" );
       
   203     _LIT( KEnter, "Enter" );
       
   204     _LIT( KOnGoing, "On-going" );
       
   205     _LIT( KExit, "Exit" );
       
   206 
       
   207     TestModuleIf().Printf( 0, KPrintTest, KEnter );
       
   208            
       
   209     TestModuleIf().Printf( 1, KPrintTest, KOnGoing );
       
   210     
       
   211     TestModuleIf().Printf( 0, KPrintTest, KExit );
       
   212 
       
   213     // Test case passed
       
   214 
       
   215     // Sets test case result and description(Maximum size is KStifMaxResultDes)
       
   216     _LIT( KDescription, "PrintTest passed" );
       
   217     aResult.SetResult( KErrNone, KDescription );
       
   218 
       
   219     // Case was executed
       
   220     return KErrNone;
       
   221 
       
   222     }
       
   223 
       
   224 // -----------------------------------------------------------------------------
       
   225 // CPlatformEnvTest::LoopTest
       
   226 // Another printing to UI test.
       
   227 // -----------------------------------------------------------------------------
       
   228 //
       
   229 TInt CPlatformEnvTest::LoopTest( TTestResult& aResult )
       
   230     {
       
   231 
       
   232     /* Simple print and wait loop */
       
   233     _LIT( KState, "State" );
       
   234     _LIT( KLooping, "Looping" );
       
   235 
       
   236     TestModuleIf().Printf( 0, KState, KLooping );
       
   237 
       
   238     _LIT( KRunning, "Running" );
       
   239     _LIT( KLoop, "%d" );
       
   240     for( TInt i=0; i<10; i++)
       
   241         {
       
   242         TestModuleIf().Printf( 1, KRunning, KLoop, i);
       
   243         User::After( 1000000 );
       
   244         }
       
   245 
       
   246     _LIT( KFinished, "Finished" );
       
   247     TestModuleIf().Printf( 0, KState, KFinished );
       
   248 
       
   249     // Test case passed
       
   250 
       
   251     // Sets test case result and description(Maximum size is KStifMaxResultDes)
       
   252     _LIT( KDescription, "LoopTest passed" );
       
   253     aResult.SetResult( KErrNone, KDescription );
       
   254 
       
   255     // Case was executed
       
   256     return KErrNone;
       
   257 
       
   258     }
       
   259 
       
   260 
       
   261 // -----------------------------------------------------------------------------
       
   262 // CPlatformEnvTest::PathTest
       
   263 //
       
   264 // -----------------------------------------------------------------------------
       
   265 //
       
   266 TInt CPlatformEnvTest::PathTest( TTestResult& aResult )
       
   267     {
       
   268 
       
   269 	TBuf<50> iRomBootPath,
       
   270 	iPhoneMemoryRootPath,
       
   271 	iMemoryCardRootPath,
       
   272 	iGamesPath,
       
   273 	iInstallsPath,
       
   274 	iOthersPath,
       
   275 	iVideosPath,
       
   276 	iImagesPath,
       
   277 	iPicturesPath,
       
   278 	iGmsPicturesPath,
       
   279 	iMmsBackgroundImagesPath,
       
   280 	iPresenceLogosPath,
       
   281 	iSoundsPath,
       
   282 	iDigitalSoundsPath,
       
   283 	iSimpleSoundsPath,
       
   284 	iImagesThumbnailPath,
       
   285 	iMemoryCardContactsPath = _L("");
       
   286 		
       
   287 	iRomBootPath = PathInfo::RomRootPath();
       
   288 	iPhoneMemoryRootPath = PathInfo::PhoneMemoryRootPath();
       
   289 	iMemoryCardRootPath = PathInfo::MemoryCardRootPath();
       
   290 	iGamesPath = PathInfo::GamesPath();
       
   291 	iInstallsPath = PathInfo::InstallsPath();
       
   292 	iOthersPath = PathInfo::OthersPath();
       
   293 	iVideosPath = PathInfo::VideosPath();
       
   294 	iImagesPath = PathInfo::ImagesPath();
       
   295 	iPicturesPath = PathInfo::PicturesPath();
       
   296 	iGmsPicturesPath = PathInfo::GmsPicturesPath();
       
   297 	iMmsBackgroundImagesPath = PathInfo::MmsBackgroundImagesPath();
       
   298 	iPresenceLogosPath = PathInfo::PresenceLogosPath();
       
   299 	iSoundsPath = PathInfo::SoundsPath();
       
   300 	iDigitalSoundsPath = PathInfo::DigitalSoundsPath();
       
   301 	iSimpleSoundsPath = PathInfo::SimpleSoundsPath();
       
   302 	iImagesThumbnailPath = PathInfo::ImagesThumbnailPath();
       
   303 	iMemoryCardContactsPath = PathInfo::MemoryCardContactsPath();
       
   304 	
       
   305 	iLog->Log( _L( "PlatformEnvTest Paths:" ));
       
   306 	iLog->Log( iRomBootPath );
       
   307 	iLog->Log( iPhoneMemoryRootPath );
       
   308 	iLog->Log( iMemoryCardRootPath );
       
   309 	iLog->Log( iGamesPath );
       
   310 	iLog->Log( iInstallsPath );
       
   311 	iLog->Log( iOthersPath );
       
   312 	iLog->Log( iVideosPath );
       
   313 	iLog->Log( iImagesPath );
       
   314 	iLog->Log( iPicturesPath );
       
   315 	iLog->Log( iGmsPicturesPath );
       
   316 	iLog->Log( iMmsBackgroundImagesPath );
       
   317 	iLog->Log( iPresenceLogosPath );
       
   318 	iLog->Log( iSoundsPath );
       
   319 	iLog->Log( iDigitalSoundsPath );
       
   320 	iLog->Log( iSimpleSoundsPath );
       
   321 	iLog->Log( iImagesThumbnailPath );
       
   322 	iLog->Log( iMemoryCardContactsPath );
       
   323 		
       
   324     // Sets test case result and description(Maximum size is KStifMaxResultDes)
       
   325     _LIT( KDescription, "Path Test passed" );
       
   326     aResult.SetResult( KErrNone, KDescription );
       
   327 
       
   328     // Case was executed
       
   329     return KErrNone;
       
   330 
       
   331     }
       
   332 
       
   333 
       
   334 // -----------------------------------------------------------------------------
       
   335 // CPlatformEnvTest::GetPathTest
       
   336 // Testing relations between retrieving paths via direct methods and 
       
   337 // via GetPath( aPath) method.
       
   338 // Note: This case results KErrGeneral even if just one of the path pairs differ 
       
   339 // -----------------------------------------------------------------------------
       
   340 //
       
   341 TInt CPlatformEnvTest::GetPathTest( TTestResult& aResult )
       
   342     { 
       
   343 
       
   344     //Array for paths retrieved via GetPath-method  
       
   345     RArray<TFileName> getPaths;
       
   346           
       
   347     getPaths.Append( PathInfo::GetPath( PathInfo::ERomRootPath ) );             //0
       
   348     getPaths.Append( PathInfo::GetPath( PathInfo::EPhoneMemoryRootPath ) );     //1
       
   349     getPaths.Append( PathInfo::GetPath( PathInfo::EMemoryCardRootPath ) );      //2
       
   350     getPaths.Append( PathInfo::GetPath( PathInfo::EGamesPath ) );               //3
       
   351     getPaths.Append( PathInfo::GetPath( PathInfo::EInstallsPath ) );            //4
       
   352     getPaths.Append( PathInfo::GetPath( PathInfo::EOthersPath ) );              //5
       
   353     getPaths.Append( PathInfo::GetPath( PathInfo::EVideosPath ) );              //6
       
   354     getPaths.Append( PathInfo::GetPath( PathInfo::EImagesPath ) );              //7
       
   355     getPaths.Append( PathInfo::GetPath( PathInfo::EGsmPicturesPath ) );         //8
       
   356     getPaths.Append( PathInfo::GetPath( PathInfo::EMmsBackgroundImagesPath ) ); //9
       
   357     getPaths.Append( PathInfo::GetPath( PathInfo::EPresenceLogosPath ) );       //10
       
   358     getPaths.Append( PathInfo::GetPath( PathInfo::ESoundsPath ) );              //11
       
   359     getPaths.Append( PathInfo::GetPath( PathInfo::EDigitalSoundsPath ) );       //12
       
   360     getPaths.Append( PathInfo::GetPath( PathInfo::ESimpleSoundsPath ) );        //13
       
   361     getPaths.Append( PathInfo::GetPath( PathInfo::EImagesThumbnailPath ) );     //14
       
   362     getPaths.Append( PathInfo::GetPath( PathInfo::EMemoryCardContactsPath ) );  //15
       
   363      
       
   364     //Array for paths retrieve via direct path functions
       
   365     // NOTE!!! Paths in both arrays must be set on corresponding indexes in order to get the test to work    
       
   366     RArray<TFileName> funcPaths;
       
   367     
       
   368     funcPaths.Append( PathInfo::RomRootPath() );            //0
       
   369     funcPaths.Append( PathInfo::PhoneMemoryRootPath() );    //1
       
   370     funcPaths.Append( PathInfo::MemoryCardRootPath() );     //2
       
   371     funcPaths.Append( PathInfo::GamesPath() );              //3
       
   372     funcPaths.Append( PathInfo::InstallsPath() );           //4
       
   373     funcPaths.Append( PathInfo::OthersPath() );             //5
       
   374     funcPaths.Append( PathInfo::VideosPath() );             //6    
       
   375     funcPaths.Append( PathInfo::ImagesPath() );             //7
       
   376     funcPaths.Append( PathInfo::GmsPicturesPath() );        //8    
       
   377     funcPaths.Append( PathInfo::MmsBackgroundImagesPath() );//9
       
   378     funcPaths.Append( PathInfo::PresenceLogosPath() );      //10
       
   379     funcPaths.Append( PathInfo::SoundsPath() );             //11
       
   380     funcPaths.Append( PathInfo::DigitalSoundsPath() );      //12
       
   381     funcPaths.Append( PathInfo::SimpleSoundsPath() );       //13
       
   382     funcPaths.Append( PathInfo::ImagesThumbnailPath() );    //14
       
   383     funcPaths.Append( PathInfo::MemoryCardContactsPath() ); //15
       
   384     
       
   385     
       
   386  
       
   387     //if the size of the arrays ain't the same, fail the test
       
   388     if( funcPaths.Count() != getPaths.Count() )
       
   389         {
       
   390         _LIT( KDescription, "GetPathTest::Path Array setup failed" );
       
   391         aResult.SetResult( KErrGeneral, KDescription );
       
   392         funcPaths.Close();
       
   393         getPaths.Close(); 
       
   394         return KErrNone;
       
   395         }
       
   396     
       
   397     _LIT( KDescription, "GetPathTest executed. ( Failed indexes: " );
       
   398     _LIT( KFailIndex, "%d,");
       
   399     _LIT( KTextNone, "NONE )" );
       
   400     _LIT( KTextParCl, " )" );
       
   401      
       
   402     TBuf<100> description;    
       
   403     TInt err(KErrNone);
       
   404     TInt count = getPaths.Count();
       
   405  
       
   406     description.Format( KDescription ) ;   
       
   407  
       
   408     for( TInt i(0); i < count; i++ )
       
   409         {
       
   410         iLog -> Log(getPaths[i]);
       
   411         iLog -> Log(funcPaths[i]);
       
   412         
       
   413         if( getPaths[i].Compare( funcPaths[i] ) != 0 )
       
   414             {
       
   415             description.AppendFormat( KFailIndex, i );
       
   416             err = KErrGeneral;
       
   417             }
       
   418         }
       
   419  
       
   420  
       
   421     // Sets test case result and description(Maximum size is KStifMaxResultDes)
       
   422     if( err == KErrNone )
       
   423         {
       
   424         description.Append( KTextNone );
       
   425         }
       
   426     else
       
   427         {
       
   428         //strip the last comma
       
   429         description.Delete( description.Length() -1 , 1);
       
   430         description.Append( KTextParCl );
       
   431         }
       
   432     
       
   433     
       
   434     aResult.SetResult( err, description );
       
   435   
       
   436     funcPaths.Close();
       
   437     getPaths.Close();     
       
   438   
       
   439     return KErrNone;
       
   440     }
       
   441 
       
   442 // -----------------------------------------------------------------------------
       
   443 // CPlatformEnvTest::GetRootPathTest
       
   444 // Testing relations between retrieving paths via direct methods and 
       
   445 // via GetRootPathTest( aPath) method.
       
   446 // Note: This case results KErrGeneral even if just one of the path pairs differ 
       
   447 // -----------------------------------------------------------------------------
       
   448 //
       
   449 TInt CPlatformEnvTest::GetRootPathTest( TTestResult& aResult )
       
   450     { 
       
   451 
       
   452     //Array for paths retrieved via GetRootPath-method  
       
   453     RArray<TFileName> getPaths;
       
   454     TFileName root;
       
   455 
       
   456     for ( TInt i( EDriveA ); i <= EDriveZ; ++i )
       
   457         {
       
   458         User::LeaveIfError( PathInfo::GetRootPath( root, i ) ); 
       
   459         getPaths.Append( root );
       
   460         }
       
   461 
       
   462     //Array for paths retrieve via direct path functions
       
   463     // NOTE!!! Paths in both arrays must be set on corresponding indexes in order to get the test to work    
       
   464     RArray<TFileName> funcPaths;
       
   465     funcPaths.Append( PathInfo::RomRootPath() );
       
   466     funcPaths.Append( PathInfo::PhoneMemoryRootPath() );
       
   467     funcPaths.Append( PathInfo::MemoryCardRootPath() );
       
   468     
       
   469     _LIT( KDescription, "GetRootPathTest executed. ( Failed indexes: " );
       
   470     _LIT( KFailIndex, "%d,");
       
   471     _LIT( KTextNone, "NONE )" );
       
   472     _LIT( KTextParCl, " )" );
       
   473      
       
   474     TBuf<100> description;    
       
   475     TInt err(KErrNone);
       
   476     TInt pathCount = getPaths.Count();
       
   477     TInt funcCount = funcPaths.Count();
       
   478  
       
   479     description.Format( KDescription );
       
   480  
       
   481     for( TInt i(0); i < pathCount; i++ )
       
   482         {
       
   483         TFileName& getPath = getPaths[i];
       
   484         
       
   485         iLog -> Log(getPath);
       
   486         
       
   487         TBool found( EFalse );
       
   488         for ( TInt j( 0 ); j < funcCount; ++j )
       
   489             {
       
   490             TFileName& funcPath = funcPaths[j];
       
   491             if ( getPath[ 0 ] == funcPath[ 0 ] )
       
   492                 {
       
   493                 found = ETrue;
       
   494                 if ( getPath.Compare( funcPath ) )
       
   495                     {
       
   496                     description.AppendFormat( KFailIndex, i );
       
   497                     err = KErrGeneral;
       
   498                     }
       
   499                 }
       
   500             }
       
   501         if ( !found )
       
   502             {
       
   503             TParsePtrC parse( getPath );
       
   504             if ( !parse.DrivePresent() || parse.DriveAndPath().Compare( getPath ) )
       
   505                 {
       
   506                 description.AppendFormat( KFailIndex, i );
       
   507                 err = KErrGeneral;
       
   508                 }
       
   509             }
       
   510         }
       
   511  
       
   512  
       
   513     // Sets test case result and description(Maximum size is KStifMaxResultDes)
       
   514     if( err == KErrNone )
       
   515         {
       
   516         description.Append( KTextNone );
       
   517         }
       
   518     else
       
   519         {
       
   520         //strip the last comma
       
   521         description.Delete( description.Length() -1 , 1);
       
   522         description.Append( KTextParCl );
       
   523         }
       
   524     
       
   525     
       
   526     aResult.SetResult( err, description );
       
   527   
       
   528     funcPaths.Close();
       
   529     getPaths.Close();     
       
   530   
       
   531     return KErrNone;
       
   532     }
       
   533 
       
   534 // -----------------------------------------------------------------------------
       
   535 // CPlatformEnvTest::GetFullPathTest
       
   536 // Testing relations between retrieving paths via direct methods and 
       
   537 // via GetRootPathTest( aPath) method.
       
   538 // Note: This case results KErrGeneral even if just one of the path pairs differ 
       
   539 // -----------------------------------------------------------------------------
       
   540 //
       
   541 TInt CPlatformEnvTest::GetFullPathTest( TTestResult& aResult )
       
   542     { 
       
   543 
       
   544     //Array for paths retrieved via GetFullPath-method  
       
   545     const TInt KLastPath = 15;
       
   546     RArray<TFileName> getPaths;
       
   547     TFileName path;
       
   548 
       
   549     for ( TInt i( EDriveA ); i <= EDriveZ; ++i )
       
   550         {
       
   551         for ( TInt j( -1 ); j <= KLastPath + 1; ++j )
       
   552             {
       
   553             if ( PathInfo::GetFullPath( path, i, j ) == KErrNone )
       
   554                 {
       
   555                 getPaths.Append( path );
       
   556                 }
       
   557             }
       
   558         }
       
   559 
       
   560     _LIT( KDescription, "GetFullPathTest executed. ( Failed indexes: " );
       
   561     _LIT( KFailIndex, "%d,");
       
   562     _LIT( KTextNone, "NONE )" );
       
   563     _LIT( KTextParCl, " )" );
       
   564      
       
   565     TBuf<100> description;    
       
   566     TInt err(KErrNone);
       
   567     TInt count = getPaths.Count();
       
   568  
       
   569     description.Format( KDescription ) ;   
       
   570  
       
   571     for( TInt i(0); i < count; i++ )
       
   572         {
       
   573         TFileName& getPath = getPaths[i];
       
   574         iLog -> Log(getPath);
       
   575 
       
   576         if ( PathInfo::PathType( getPath ) == PathInfo::ENotSystemPath )
       
   577             {
       
   578             description.AppendFormat( KFailIndex, i );
       
   579             err = KErrGeneral;
       
   580             }
       
   581         }
       
   582  
       
   583 
       
   584     // Sets test case result and description(Maximum size is KStifMaxResultDes)
       
   585     if( err == KErrNone )
       
   586         {
       
   587         description.Append( KTextNone );
       
   588         }
       
   589     else
       
   590         {
       
   591         //strip the last comma
       
   592         description.Delete( description.Length() -1 , 1);
       
   593         description.Append( KTextParCl );
       
   594         }
       
   595     
       
   596     
       
   597     aResult.SetResult( err, description );
       
   598   
       
   599     getPaths.Close();     
       
   600   
       
   601     return KErrNone;
       
   602     }
       
   603 
       
   604 // -----------------------------------------------------------------------------
       
   605 // CPlatformEnvTest::PathTypeTest
       
   606 // Testing relations between retrieving paths via direct methods and 
       
   607 // via GetRootPathTest( aPath) method.
       
   608 // Note: This case results KErrGeneral even if just one of the path pairs differ 
       
   609 // -----------------------------------------------------------------------------
       
   610 //
       
   611 TInt CPlatformEnvTest::PathTypeTest( TTestResult& aResult )
       
   612     { 
       
   613 
       
   614     //Array for paths retrieved via GetFullPath-method  
       
   615     const TInt KLastPath = 15;
       
   616     RArray<TFileName> getPaths;
       
   617     TFileName path;
       
   618     for ( TInt i( EDriveA ); i <= EDriveZ; ++i )
       
   619         {
       
   620         for ( TInt j( 0 ); j <= KLastPath; ++j )
       
   621             {
       
   622             if ( PathInfo::GetFullPath( path, i, j ) == KErrNone )
       
   623                 {
       
   624                 getPaths.Append( path );
       
   625                 }
       
   626             }
       
   627         }
       
   628     // Thumbnail path may exists in any folder
       
   629     PathInfo::GetFullPath( path, EDriveA, PathInfo::EImagesPath );
       
   630     path.Append( PathInfo::ImagesThumbnailPath()  );
       
   631     getPaths.Append( path );
       
   632 
       
   633     // Array of invalid paths
       
   634     RArray<TFileName> invalidPaths;
       
   635     invalidPaths.Append( _L("E:\\not_a_system_path\\") );
       
   636 
       
   637     PathInfo::GetFullPath( path, EDriveA, PathInfo::EImagesPath );
       
   638     path.Append( _L("invalid\\") );
       
   639     invalidPaths.Append( path );
       
   640     
       
   641 
       
   642     _LIT( KDescription, "PathTypeTest executed. ( Failed indexes: " );
       
   643     _LIT( KFailIndex, "%d,");
       
   644     _LIT( KTextNone, "NONE )" );
       
   645     _LIT( KTextParCl, " )" );
       
   646      
       
   647     TBuf<100> description;    
       
   648     TInt err(KErrNone);
       
   649     TInt count = getPaths.Count();
       
   650  
       
   651     description.Format( KDescription ) ;   
       
   652  
       
   653     // Test valid paths
       
   654     for( TInt i(0); i < count; i++ )
       
   655         {
       
   656         TFileName& getPath = getPaths[i];
       
   657         iLog -> Log(getPath);
       
   658 
       
   659         if ( PathInfo::PathType( getPath ) == PathInfo::ENotSystemPath )
       
   660             {
       
   661             description.AppendFormat( KFailIndex, i );
       
   662             err = KErrGeneral;
       
   663             }
       
   664         }
       
   665     // Test invalid paths
       
   666     TInt invCount = invalidPaths.Count();
       
   667     for( TInt i(0); i < invCount; i++ )
       
   668         {
       
   669         TFileName& invPath = invalidPaths[i];
       
   670         iLog -> Log(invPath);
       
   671 
       
   672         if ( PathInfo::PathType( invPath ) != PathInfo::ENotSystemPath )
       
   673             {
       
   674             description.AppendFormat( KFailIndex, i );
       
   675             err = KErrGeneral;
       
   676             }
       
   677         }
       
   678   
       
   679 
       
   680     // Sets test case result and description(Maximum size is KStifMaxResultDes)
       
   681     if( err == KErrNone )
       
   682         {
       
   683         description.Append( KTextNone );
       
   684         }
       
   685     else
       
   686         {
       
   687         //strip the last comma
       
   688         description.Delete( description.Length() -1 , 1);
       
   689         description.Append( KTextParCl );
       
   690         }
       
   691     
       
   692     
       
   693     aResult.SetResult( err, description );
       
   694   
       
   695     getPaths.Close();     
       
   696     invalidPaths.Close();
       
   697     return KErrNone;
       
   698     }
       
   699 
       
   700 // -----------------------------------------------------------------------------
       
   701 // CPlatformEnvTest::GetListOfPathsTest
       
   702 // Testing relations between retrieving paths via direct methods and 
       
   703 // via GetRootPathTest( aPath) method.
       
   704 // Note: This case results KErrGeneral even if just one of the path pairs differ 
       
   705 // -----------------------------------------------------------------------------
       
   706 //
       
   707 TInt CPlatformEnvTest::GetListOfPathsTest( TTestResult& aResult )
       
   708     { 
       
   709     RPointerArray< CDesCArray > allPaths;
       
   710 
       
   711     for ( TInt i( EDriveA ); i <= EDriveZ; ++i )
       
   712         {
       
   713         if ( i & 1)
       
   714             {
       
   715             CDesCArray* paths = PathInfo::GetListOfPathsLC( i );
       
   716             allPaths.Append( paths );
       
   717             CleanupStack::Pop( paths );
       
   718             }
       
   719         else
       
   720             {
       
   721             CDesCArray* paths = PathInfo::GetListOfPathsL( i );
       
   722             allPaths.Append( paths );
       
   723             }
       
   724         }
       
   725 
       
   726     _LIT( KDescription, "GetListOfPathsTest executed. ( Failed indexes: " );
       
   727     _LIT( KFailIndex, "%d,");
       
   728     _LIT( KTextNone, "NONE )" );
       
   729     _LIT( KTextParCl, " )" );
       
   730 
       
   731     TInt allCount = allPaths.Count();
       
   732     TInt err(KErrNone);
       
   733     TBuf<100> description;  
       
   734     description.Format( KDescription ) ;   
       
   735  
       
   736     // Test valid paths
       
   737     for( TInt i(0); i < allCount; i++ )
       
   738         {
       
   739         CDesCArray* paths = allPaths[ i ];
       
   740         TInt count = paths->MdcaCount();
       
   741         for( TInt j(0); j < count; j++ )
       
   742             {
       
   743             TPtrC path = paths->MdcaPoint(j);
       
   744             iLog -> Log(path);
       
   745 
       
   746             if ( PathInfo::PathType( path ) == PathInfo::ENotSystemPath )
       
   747                 {
       
   748                 description.AppendFormat( KFailIndex, i );
       
   749                 err = KErrGeneral;
       
   750                 }
       
   751             }
       
   752         }
       
   753   
       
   754     // Sets test case result and description(Maximum size is KStifMaxResultDes)
       
   755     if( err == KErrNone )
       
   756         {
       
   757         description.Append( KTextNone );
       
   758         }
       
   759     else
       
   760         {
       
   761         //strip the last comma
       
   762         description.Delete( description.Length() -1 , 1);
       
   763         description.Append( KTextParCl );
       
   764         }
       
   765     
       
   766     
       
   767     aResult.SetResult( err, description );
       
   768   
       
   769     allPaths.ResetAndDestroy();
       
   770     allPaths.Close();
       
   771   
       
   772     return KErrNone;
       
   773     }
       
   774 
       
   775 // -----------------------------------------------------------------------------
       
   776 // CPlatformEnvTest::GetDefaultDriveTest
       
   777 // Testing relations between retrieving paths via direct methods and 
       
   778 // via GetRootPathTest( aPath) method.
       
   779 // Note: This case results KErrGeneral even if just one of the path pairs differ 
       
   780 // -----------------------------------------------------------------------------
       
   781 //
       
   782 TInt CPlatformEnvTest::GetDefaultDriveTest( TTestResult& aResult )
       
   783     { 
       
   784     //Array for paths retrieved via GetDefaultDriveTest-method  
       
   785     RArray<TInt> drives;
       
   786     const TInt KLastDrive = 5 + 1; // +1 for invalid default drive
       
   787     
       
   788     for ( TInt i( 0 ); i <= KLastDrive; i++ )
       
   789         {
       
   790         TInt drive( KErrNotFound );
       
   791         if ( DriveInfo::GetDefaultDrive( i, drive ) == KErrNone )
       
   792             {
       
   793             drives.Append( drive );
       
   794             }
       
   795         }
       
   796 
       
   797     _LIT( KDescription, "GetDefaultDriveTest executed. ( Failed indexes: " );
       
   798     _LIT( KFailIndex, "%d,");
       
   799     _LIT( KTextNone, "NONE )" );
       
   800     _LIT( KTextParCl, " )" );
       
   801 
       
   802     TInt count = drives.Count();
       
   803     TInt err(KErrNone);
       
   804     TBuf<100> description;  
       
   805     description.Format( KDescription ) ;   
       
   806  
       
   807     for( TInt i(0); i < count; i++ )
       
   808         {
       
   809         TInt drive = drives[i];
       
   810         TDriveInfo dummy;
       
   811         if ( drive < EDriveA || drive > EDriveZ || iFs.Drive( dummy, drive ) != KErrNone )
       
   812             {
       
   813             description.AppendFormat( KFailIndex, i );
       
   814             err = KErrGeneral;
       
   815             }
       
   816         }
       
   817   
       
   818     // Sets test case result and description(Maximum size is KStifMaxResultDes)
       
   819     if( err == KErrNone )
       
   820         {
       
   821         description.Append( KTextNone );
       
   822         }
       
   823     else
       
   824         {
       
   825         //strip the last comma
       
   826         description.Delete( description.Length() -1 , 1);
       
   827         description.Append( KTextParCl );
       
   828         }
       
   829     
       
   830     
       
   831     aResult.SetResult( err, description );
       
   832   
       
   833     drives.Close();
       
   834   
       
   835     return KErrNone;
       
   836     }
       
   837 
       
   838 // -----------------------------------------------------------------------------
       
   839 // CPlatformEnvTest::GetDefaultDriveTest2
       
   840 // Testing relations between retrieving paths via direct methods and 
       
   841 // via GetRootPathTest( aPath) method.
       
   842 // Note: This case results KErrGeneral even if just one of the path pairs differ 
       
   843 // -----------------------------------------------------------------------------
       
   844 //
       
   845 TInt CPlatformEnvTest::GetDefaultDriveTest2( TTestResult& aResult )
       
   846     { 
       
   847     //Array for paths retrieved via GetDefaultDriveTest-method  
       
   848     RArray<TChar> drives;
       
   849     const TInt KLastDrive = 5 + 1; // +1 for invalid default drive
       
   850     
       
   851     for ( TInt i( 0 ); i <= KLastDrive; i++ )
       
   852         {
       
   853         TChar driveLetter( 0 );
       
   854         if ( DriveInfo::GetDefaultDrive( i, driveLetter ) == KErrNone )
       
   855             {
       
   856             drives.Append( driveLetter );
       
   857             }
       
   858         }
       
   859 
       
   860     _LIT( KDescription, "GetDefaultDriveTest2 executed. ( Failed indexes: " );
       
   861     _LIT( KFailIndex, "%d,");
       
   862     _LIT( KTextNone, "NONE )" );
       
   863     _LIT( KTextParCl, " )" );
       
   864 
       
   865     TInt count = drives.Count();
       
   866     TInt err(KErrNone);
       
   867     TBuf<100> description;  
       
   868     description.Format( KDescription ) ;   
       
   869  
       
   870     for( TInt i(0); i < count; i++ )
       
   871         {
       
   872         TChar driveLetter = drives[i];
       
   873         driveLetter.UpperCase();
       
   874         if ( driveLetter < 'A' || driveLetter > 'Z' )
       
   875         
       
   876             {
       
   877             description.AppendFormat( KFailIndex, i );
       
   878             err = KErrGeneral;
       
   879             }
       
   880         }
       
   881   
       
   882     // Sets test case result and description(Maximum size is KStifMaxResultDes)
       
   883     if( err == KErrNone )
       
   884         {
       
   885         description.Append( KTextNone );
       
   886         }
       
   887     else
       
   888         {
       
   889         //strip the last comma
       
   890         description.Delete( description.Length() -1 , 1);
       
   891         description.Append( KTextParCl );
       
   892         }
       
   893     
       
   894     
       
   895     aResult.SetResult( err, description );
       
   896   
       
   897     drives.Close();
       
   898   
       
   899     return KErrNone;
       
   900     }
       
   901 
       
   902 // -----------------------------------------------------------------------------
       
   903 // CPlatformEnvTest::GetDriveStatusTest
       
   904 // Testing relations between retrieving paths via direct methods and 
       
   905 // via GetRootPathTest( aPath) method.
       
   906 // Note: This case results KErrGeneral even if just one of the path pairs differ 
       
   907 // -----------------------------------------------------------------------------
       
   908 //
       
   909 TInt CPlatformEnvTest::GetDriveStatusTest( TTestResult& aResult )
       
   910     { 
       
   911     //Array for paths retrieved via GetDriveStatus-method  
       
   912     RArray<TUint> driveStatus;
       
   913     
       
   914     for ( TInt i( EDriveA - 1 ); i <= EDriveZ + 1; i++ )
       
   915         {
       
   916         TUint status( 0 );
       
   917         if ( DriveInfo::GetDriveStatus( iFs, i, status ) == KErrNone )
       
   918             {
       
   919             driveStatus.Append( status );
       
   920             }
       
   921         }
       
   922 
       
   923     _LIT( KDescription, "GetDriveStatusTest executed. ( Failed indexes: " );
       
   924     _LIT( KFailIndex, "%d,");
       
   925     _LIT( KTextNone, "NONE )" );
       
   926     _LIT( KTextParCl, " )" );
       
   927 
       
   928     TInt count = driveStatus.Count();
       
   929     TInt err(KErrNone);
       
   930     TBuf<100> description;  
       
   931     description.Format( KDescription ) ;   
       
   932  
       
   933     for( TInt i(0); i < count; i++ )
       
   934         {
       
   935         TUint status = driveStatus[i];
       
   936         if ( !status )
       
   937             {
       
   938             description.AppendFormat( KFailIndex, i );
       
   939             err = KErrGeneral;
       
   940             }
       
   941         }
       
   942   
       
   943     // Sets test case result and description(Maximum size is KStifMaxResultDes)
       
   944     if( err == KErrNone )
       
   945         {
       
   946         description.Append( KTextNone );
       
   947         }
       
   948     else
       
   949         {
       
   950         //strip the last comma
       
   951         description.Delete( description.Length() -1 , 1);
       
   952         description.Append( KTextParCl );
       
   953         }
       
   954     
       
   955     
       
   956     aResult.SetResult( err, description );
       
   957   
       
   958     driveStatus.Close();
       
   959   
       
   960     return KErrNone;
       
   961     }
       
   962 
       
   963 // -----------------------------------------------------------------------------
       
   964 // CPlatformEnvTest::GetUserVisibleDrivesTest
       
   965 // Testing relations between retrieving paths via direct methods and 
       
   966 // via GetRootPathTest( aPath) method.
       
   967 // Note: This case results KErrGeneral even if just one of the path pairs differ 
       
   968 // -----------------------------------------------------------------------------
       
   969 //
       
   970 TInt CPlatformEnvTest::GetUserVisibleDrivesTest( TTestResult& aResult )
       
   971     { 
       
   972     TDriveList allDrives;
       
   973     TInt allDriveCount( 0 );
       
   974     DriveInfo::GetUserVisibleDrives( iFs, allDrives, allDriveCount );
       
   975 
       
   976     TDriveList intDrives;
       
   977     TInt intDriveCount( 0 );
       
   978     DriveInfo::GetUserVisibleDrives( iFs, intDrives, intDriveCount, KDriveAttInternal );
       
   979 
       
   980     TDriveList remDrives;
       
   981     TInt remDriveCount( 0 );
       
   982     DriveInfo::GetUserVisibleDrives( iFs, remDrives, remDriveCount, KDriveAttRemovable );
       
   983 
       
   984     _LIT( KDescription, "GetUserVisibleDrivesTest executed. ( Failed indexes: " );
       
   985     _LIT( KFailIndex, "%d,");
       
   986     _LIT( KTextNone, "NONE )" );
       
   987     _LIT( KTextParCl, " )" );
       
   988 
       
   989     TInt count = allDrives.Length();
       
   990     TInt err(KErrNone);
       
   991     TBuf<100> description;  
       
   992     TInt checkCount( 0 );
       
   993     description.Format( KDescription );   
       
   994 
       
   995     if ( !allDriveCount || !count )
       
   996         {
       
   997         description.AppendFormat( _L("List is empty") );
       
   998         err = KErrGeneral;
       
   999         }
       
  1000 
       
  1001     // All drives
       
  1002     for( TInt i(0); i < count; i++ )
       
  1003         {
       
  1004         if ( allDrives[ i ] )
       
  1005             {
       
  1006             ++checkCount;
       
  1007             TUint status( 0 );
       
  1008             if ( DriveInfo::GetDriveStatus( iFs, i, status ) == KErrNone )
       
  1009                 {
       
  1010                 if ( !( status & DriveInfo::EDriveUserVisible ) )
       
  1011                     {
       
  1012                     description.AppendFormat( KFailIndex, i );
       
  1013                     err = KErrGeneral;
       
  1014                     }
       
  1015                 }
       
  1016             else
       
  1017                 {
       
  1018                 description.AppendFormat( KFailIndex, i );
       
  1019                 err = KErrGeneral;
       
  1020                 }
       
  1021             }
       
  1022         }
       
  1023       if ( checkCount != allDriveCount )
       
  1024         {
       
  1025         description.AppendFormat( _L("All count does not match") );
       
  1026         err = KErrGeneral;
       
  1027         }
       
  1028 
       
  1029     // Internal drives
       
  1030     count = intDrives.Length();
       
  1031     checkCount = 0;
       
  1032     for( TInt i(0); i < count; i++ )
       
  1033         {
       
  1034         if ( intDrives[ i ] )
       
  1035             {
       
  1036             ++checkCount;
       
  1037             TUint status( 0 );
       
  1038             if ( DriveInfo::GetDriveStatus( iFs, i, status ) == KErrNone )
       
  1039                 {
       
  1040                 if ( !( status & DriveInfo::EDriveInternal ) )
       
  1041                     {
       
  1042                     description.AppendFormat( KFailIndex, i );
       
  1043                     err = KErrGeneral;
       
  1044                     }
       
  1045                 }
       
  1046             else
       
  1047                 {
       
  1048                 description.AppendFormat( KFailIndex, i );
       
  1049                 err = KErrGeneral;
       
  1050                 }
       
  1051             }
       
  1052         }
       
  1053       if ( checkCount != intDriveCount )
       
  1054         {
       
  1055         description.AppendFormat( _L("Internal count does not match") );
       
  1056         err = KErrGeneral;
       
  1057         }
       
  1058 
       
  1059     // Removable drives
       
  1060     count = remDrives.Length();
       
  1061     checkCount = 0;
       
  1062     for( TInt i(0); i < count; i++ )
       
  1063         {
       
  1064         if ( remDrives[ i ] )
       
  1065             {
       
  1066             ++checkCount;
       
  1067             TUint status( 0 );
       
  1068             if ( DriveInfo::GetDriveStatus( iFs, i, status ) == KErrNone )
       
  1069                 {
       
  1070                 if ( !( status & DriveInfo::EDriveRemovable ) )
       
  1071                     {
       
  1072                     description.AppendFormat( KFailIndex, i );
       
  1073                     err = KErrGeneral;
       
  1074                     }
       
  1075                 }
       
  1076             else
       
  1077                 {
       
  1078                 description.AppendFormat( KFailIndex, i );
       
  1079                 err = KErrGeneral;
       
  1080                 }
       
  1081             }
       
  1082         }
       
  1083       if ( checkCount != remDriveCount )
       
  1084         {
       
  1085         description.AppendFormat( _L("Removable count does not match") );
       
  1086         err = KErrGeneral;
       
  1087         }
       
  1088 
       
  1089     // Sets test case result and description(Maximum size is KStifMaxResultDes)
       
  1090     if( err == KErrNone )
       
  1091         {
       
  1092         description.Append( KTextNone );
       
  1093         }
       
  1094     else
       
  1095         {
       
  1096         //strip the last comma
       
  1097         description.Delete( description.Length() -1 , 1);
       
  1098         description.Append( KTextParCl );
       
  1099         }
       
  1100     
       
  1101     
       
  1102     aResult.SetResult( err, description );
       
  1103     
       
  1104     return KErrNone;
       
  1105     }
       
  1106 
       
  1107 // -----------------------------------------------------------------------------
       
  1108 // CPlatformEnvTest::StripUserHiddenDrivesTest
       
  1109 // Testing relations between retrieving paths via direct methods and 
       
  1110 // via GetRootPathTest( aPath) method.
       
  1111 // Note: This case results KErrGeneral even if just one of the path pairs differ 
       
  1112 // -----------------------------------------------------------------------------
       
  1113 //
       
  1114 TInt CPlatformEnvTest::StripUserHiddenDrivesTest( TTestResult& aResult )
       
  1115     { 
       
  1116     TDriveList allDrives;
       
  1117     iFs.DriveList( allDrives );
       
  1118 
       
  1119     TDriveList drives = allDrives;
       
  1120     TInt driveCount = DriveInfo::StripUserHiddenDrives( drives );
       
  1121 
       
  1122     _LIT( KDescription, "StripUserHiddenDrivesTest executed. ( Failed indexes: " );
       
  1123     _LIT( KFailIndex, "%d,");
       
  1124     _LIT( KTextNone, "NONE )" );
       
  1125     _LIT( KTextParCl, " )" );
       
  1126 
       
  1127     TInt count = allDrives.Length();
       
  1128     TInt err(KErrNone);
       
  1129     TBuf<100> description;  
       
  1130     description.Format( KDescription );   
       
  1131 
       
  1132     if ( !driveCount || !count )
       
  1133         {
       
  1134         description.AppendFormat( _L("List is empty") );
       
  1135         err = KErrGeneral;
       
  1136         }
       
  1137     TInt checkCount( 0 );
       
  1138     for( TInt i(0); i < count; i++ )
       
  1139         {
       
  1140         if ( drives[ i ] )
       
  1141             {
       
  1142             ++checkCount;
       
  1143             }
       
  1144 
       
  1145         if ( allDrives[ i ] )
       
  1146             {
       
  1147             TUint status( 0 );
       
  1148             if ( DriveInfo::GetDriveStatus( iFs, i, status ) == KErrNone )
       
  1149                 {
       
  1150                 if ( !( status & DriveInfo::EDriveUserVisible ) )
       
  1151                     {
       
  1152                     if ( drives[ i ] )
       
  1153                         {
       
  1154                         description.AppendFormat( KFailIndex, i );
       
  1155                         err = KErrGeneral;
       
  1156                         }
       
  1157                     }
       
  1158                 }
       
  1159             else
       
  1160                 {
       
  1161                 description.AppendFormat( KFailIndex, i );
       
  1162                 err = KErrGeneral;
       
  1163                 }
       
  1164             }
       
  1165         }
       
  1166   
       
  1167     if ( checkCount != driveCount )
       
  1168         {
       
  1169         description.AppendFormat( _L("Count does not match") );
       
  1170         err = KErrGeneral;
       
  1171         }
       
  1172 
       
  1173     // Sets test case result and description(Maximum size is KStifMaxResultDes)
       
  1174     if( err == KErrNone )
       
  1175         {
       
  1176         description.Append( KTextNone );
       
  1177         }
       
  1178     else
       
  1179         {
       
  1180         //strip the last comma
       
  1181         description.Delete( description.Length() -1 , 1);
       
  1182         description.Append( KTextParCl );
       
  1183         }
       
  1184     
       
  1185     
       
  1186     aResult.SetResult( err, description );
       
  1187     
       
  1188     return KErrNone;
       
  1189     }
       
  1190 
       
  1191 // -----------------------------------------------------------------------------
       
  1192 // CPlatformEnvTest::DriveCountTest
       
  1193 // Testing relations between retrieving paths via direct methods and 
       
  1194 // via GetRootPathTest( aPath) method.
       
  1195 // Note: This case results KErrGeneral even if just one of the path pairs differ 
       
  1196 // -----------------------------------------------------------------------------
       
  1197 //
       
  1198 TInt CPlatformEnvTest::DriveCountTest( TTestResult& aResult )
       
  1199     { 
       
  1200     TDriveList allDrives;
       
  1201     iFs.DriveList( allDrives );
       
  1202     TInt driveCount = DriveInfo::DriveCount( allDrives );
       
  1203 
       
  1204     _LIT( KDescription, "DriveCountTest executed. ( " );
       
  1205     _LIT( KTextNone, "NONE )" );
       
  1206     _LIT( KTextParCl, " )" );
       
  1207 
       
  1208     TInt count = allDrives.Length();
       
  1209     TInt err(KErrNone);
       
  1210     TBuf<100> description;  
       
  1211     description.Format( KDescription );   
       
  1212 
       
  1213     if ( !driveCount || !count )
       
  1214         {
       
  1215         description.AppendFormat( _L("List is empty") );
       
  1216         err = KErrGeneral;
       
  1217         }
       
  1218  
       
  1219     TInt checkCount( 0 );
       
  1220     for( TInt i(0); i < count; i++ )
       
  1221         {
       
  1222         if ( allDrives[ i ] )
       
  1223             {
       
  1224             ++checkCount;
       
  1225             }
       
  1226         }
       
  1227 
       
  1228     if ( checkCount != driveCount )
       
  1229         {
       
  1230         description.AppendFormat( _L("Count does not match") );
       
  1231         err = KErrGeneral;
       
  1232         }
       
  1233   
       
  1234     // Sets test case result and description(Maximum size is KStifMaxResultDes)
       
  1235     if( err == KErrNone )
       
  1236         {
       
  1237         description.Append( KTextNone );
       
  1238         }
       
  1239     else
       
  1240         {
       
  1241         //strip the last comma
       
  1242         description.Delete( description.Length() -1 , 1);
       
  1243         description.Append( KTextParCl );
       
  1244         }
       
  1245     
       
  1246     
       
  1247     aResult.SetResult( err, description );
       
  1248     
       
  1249     return KErrNone;
       
  1250     }
       
  1251 
       
  1252 // -----------------------------------------------------------------------------
       
  1253 // CPlatformEnvTest::DriveArrayTest
       
  1254 // Testing relations between retrieving paths via direct methods and 
       
  1255 // via GetRootPathTest( aPath) method.
       
  1256 // Note: This case results KErrGeneral even if just one of the path pairs differ 
       
  1257 // -----------------------------------------------------------------------------
       
  1258 //
       
  1259 TInt CPlatformEnvTest::DriveArrayTest( TTestResult& aResult )
       
  1260     { 
       
  1261     _LIT( KDescription, "DriveArrayTest executed. ( " );
       
  1262     _LIT( KTextNone, "NONE )" );
       
  1263     _LIT( KFailIndex, "%d,");
       
  1264     _LIT( KTextParCl, " )" );
       
  1265     TInt err(KErrNone);
       
  1266     TBuf<100> description;  
       
  1267     description.Format( KDescription );   
       
  1268 
       
  1269     TDriveList allDrives;
       
  1270     iFs.DriveList( allDrives );
       
  1271     
       
  1272     DriveInfo::TDriveArray driveArray( allDrives );
       
  1273     if ( !driveArray.Count() )
       
  1274         {
       
  1275         description.AppendFormat( _L("Count does not match") );
       
  1276         err = KErrGeneral;
       
  1277         }
       
  1278     driveArray.Reset();
       
  1279     if ( err == KErrNone && driveArray.Count() )
       
  1280         {
       
  1281         description.AppendFormat( _L("Count does not match") );
       
  1282         err = KErrGeneral;
       
  1283         }
       
  1284     driveArray.Set( allDrives );
       
  1285     TInt driveCount( driveArray.Count() );    
       
  1286     for( TInt i(0); i < driveCount; i++ )
       
  1287         {
       
  1288         TInt drive = driveArray[ i ];
       
  1289         TChar driveLetter = driveArray.LetterAt( i );
       
  1290         driveLetter.UpperCase();
       
  1291         if ( drive < EDriveA || drive > EDriveZ )
       
  1292             {
       
  1293             description.AppendFormat( KFailIndex, i );
       
  1294             err = KErrGeneral;
       
  1295             break;
       
  1296             }
       
  1297         else if ( driveLetter < 'A' || driveLetter > 'Z' )
       
  1298             {
       
  1299             description.AppendFormat( KFailIndex, i );
       
  1300             err = KErrGeneral;
       
  1301             break;
       
  1302             }
       
  1303         }
       
  1304 
       
  1305     TInt checkCount( DriveInfo::DriveCount( allDrives ) );
       
  1306     if ( checkCount != driveCount )
       
  1307         {
       
  1308         description.AppendFormat( _L("Count does not match") );
       
  1309         err = KErrGeneral;
       
  1310         }
       
  1311   
       
  1312     // Sets test case result and description(Maximum size is KStifMaxResultDes)
       
  1313     if( err == KErrNone )
       
  1314         {
       
  1315         description.Append( KTextNone );
       
  1316         }
       
  1317     else
       
  1318         {
       
  1319         //strip the last comma
       
  1320         description.Delete( description.Length() -1 , 1);
       
  1321         description.Append( KTextParCl );
       
  1322         }
       
  1323     
       
  1324     
       
  1325     aResult.SetResult( err, description );
       
  1326     
       
  1327     return KErrNone;
       
  1328    }
       
  1329 
       
  1330 // -----------------------------------------------------------------------------
       
  1331 // CPlatformEnvTest::GetUserVisibleDrivesTest2
       
  1332 // Testing relations between retrieving paths via direct methods and 
       
  1333 // via GetRootPathTest( aPath) method.
       
  1334 // Note: This case results KErrGeneral even if just one of the path pairs differ 
       
  1335 // -----------------------------------------------------------------------------
       
  1336 //
       
  1337 TInt CPlatformEnvTest::GetUserVisibleDrivesTest2( TTestResult& aResult )
       
  1338     { 
       
  1339     DriveInfo::TDriveArray allDrives;
       
  1340     DriveInfo::GetUserVisibleDrives( iFs, allDrives );
       
  1341 
       
  1342     DriveInfo::TDriveArray intDrives;
       
  1343     DriveInfo::GetUserVisibleDrives( iFs, intDrives, KDriveAttInternal );
       
  1344 
       
  1345     DriveInfo::TDriveArray remDrives;
       
  1346     DriveInfo::GetUserVisibleDrives( iFs, remDrives, KDriveAttRemovable );
       
  1347 
       
  1348     _LIT( KDescription, "GetUserVisibleDrivesTest2 executed. ( Failed indexes: " );
       
  1349     _LIT( KFailIndex, "%d,");
       
  1350     _LIT( KTextNone, "NONE )" );
       
  1351     _LIT( KTextParCl, " )" );
       
  1352 
       
  1353     TInt count = allDrives.Count();
       
  1354     TInt err(KErrNone);
       
  1355     TBuf<100> description;
       
  1356     description.Format( KDescription );   
       
  1357 
       
  1358     if ( !count )
       
  1359         {
       
  1360         description.AppendFormat( _L("List is empty") );
       
  1361         err = KErrGeneral;
       
  1362         }
       
  1363 
       
  1364     // All drives
       
  1365     TInt drive( 0 );
       
  1366     TUint driveStatus( 0 );
       
  1367     TInt i( 0 );
       
  1368 
       
  1369     for( ; i < count; i++ )
       
  1370         {
       
  1371         drive = allDrives[ i ];
       
  1372         if ( DriveInfo::GetDriveStatus( iFs, drive, driveStatus ) == KErrNone )
       
  1373             {
       
  1374             if ( !( driveStatus & DriveInfo::EDriveUserVisible ) )
       
  1375                 {
       
  1376                 description.AppendFormat( KFailIndex, i );
       
  1377                 err = KErrGeneral;
       
  1378                 }
       
  1379             }
       
  1380         else
       
  1381             {
       
  1382             description.AppendFormat( KFailIndex, i );
       
  1383             err = KErrGeneral;
       
  1384             }
       
  1385         }
       
  1386 
       
  1387     // Internal drives
       
  1388     count = intDrives.Count();
       
  1389     for( i = 0; i < count; i++ )
       
  1390         {
       
  1391         drive = intDrives[ i ];
       
  1392         if ( DriveInfo::GetDriveStatus( iFs, drive, driveStatus ) == KErrNone )
       
  1393             {
       
  1394             if ( !( driveStatus & DriveInfo::EDriveInternal ) )
       
  1395                 {
       
  1396                 description.AppendFormat( KFailIndex, i );
       
  1397                 err = KErrGeneral;
       
  1398                 }
       
  1399             }
       
  1400         else
       
  1401             {
       
  1402             description.AppendFormat( KFailIndex, i );
       
  1403             err = KErrGeneral;
       
  1404             }
       
  1405         }
       
  1406 
       
  1407     // Removable drives
       
  1408     count = remDrives.Count();
       
  1409     for( i = 0; i < count; i++ )
       
  1410         {
       
  1411         drive = remDrives[ i ];
       
  1412         if ( DriveInfo::GetDriveStatus( iFs, drive, driveStatus ) == KErrNone )
       
  1413             {
       
  1414             if ( !( driveStatus & DriveInfo::EDriveRemovable ) )
       
  1415                 {
       
  1416                 description.AppendFormat( KFailIndex, i );
       
  1417                 err = KErrGeneral;
       
  1418                 }
       
  1419             }
       
  1420         else
       
  1421             {
       
  1422             description.AppendFormat( KFailIndex, i );
       
  1423             err = KErrGeneral;
       
  1424             }
       
  1425         }
       
  1426 
       
  1427     // Sets test case result and description(Maximum size is KStifMaxResultDes)
       
  1428     if( err == KErrNone )
       
  1429         {
       
  1430         description.Append( KTextNone );
       
  1431         }
       
  1432     else
       
  1433         {
       
  1434         //strip the last comma
       
  1435         description.Delete( description.Length() -1 , 1);
       
  1436         description.Append( KTextParCl );
       
  1437         }
       
  1438     
       
  1439     
       
  1440     aResult.SetResult( err, description );
       
  1441     
       
  1442     return KErrNone;
       
  1443     }
       
  1444 
       
  1445 // -----------------------------------------------------------------------------
       
  1446 // ?classname::?member_function
       
  1447 // ?implementation_description
       
  1448 // (other items were commented in a header).
       
  1449 // -----------------------------------------------------------------------------
       
  1450 //
       
  1451 /*
       
  1452 ?type ?classname::?member_function(
       
  1453    ?arg_type arg,
       
  1454    ?arg_type arg )
       
  1455    {
       
  1456 
       
  1457    ?code
       
  1458 
       
  1459    }
       
  1460 */
       
  1461 
       
  1462 // ========================== OTHER EXPORTED FUNCTIONS =========================
       
  1463 
       
  1464 // -----------------------------------------------------------------------------
       
  1465 // ?function_name implements...
       
  1466 // ?implementation_description.
       
  1467 // Returns: ?value_1: ?description
       
  1468 //          ?value_n: ?description
       
  1469 //                    ?description
       
  1470 // -----------------------------------------------------------------------------
       
  1471 //
       
  1472 /*
       
  1473 ?type  ?function_name(
       
  1474     ?arg_type arg,  // ?description
       
  1475     ?arg_type arg )  // ?description
       
  1476     {
       
  1477 
       
  1478     ?code
       
  1479 
       
  1480     }
       
  1481 */
       
  1482 //  End of File