baseintegtests/baseintegrationtest/testsuites/fat32/src/basetestfat32mount.cpp
changeset 15 4122176ea935
parent 0 a41df078684a
child 16 6d8ad5bee44b
child 30 9947e075979d
child 31 56f325a607ea
equal deleted inserted replaced
0:a41df078684a 15:4122176ea935
     1 // Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
       
     2 // All rights reserved.
       
     3 // This component and the accompanying materials are made available
       
     4 // under the terms of the License "Eclipse Public License v1.0"
       
     5 // which accompanies this distribution, and is available
       
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     7 //
       
     8 // Initial Contributors:
       
     9 // Nokia Corporation - initial contribution.
       
    10 //
       
    11 // Contributors:
       
    12 //
       
    13 // Description:
       
    14 // Performs the mounting of a filesystem on a drive
       
    15 // 
       
    16 //
       
    17 
       
    18 #include "basetestfat32mount.h"
       
    19 
       
    20 /**
       
    21 Class Constructor
       
    22 */		    
       
    23 CBaseTestFat32Mount::CBaseTestFat32Mount() 
       
    24 	{
       
    25 	SetTestStepName(KTestStepMount);
       
    26 	}
       
    27 	
       
    28 /**
       
    29 Class Destructor
       
    30 */
       
    31 CBaseTestFat32Mount::~CBaseTestFat32Mount() 
       
    32 	{
       
    33 	}
       
    34 
       
    35 /** 
       
    36 Mounting the file system
       
    37 From the ini file obtain whether the mount should pass or fail
       
    38 
       
    39 @return EPass if test passes and EFail if test fails
       
    40 */ 
       
    41 TVerdict CBaseTestFat32Mount::doTestStepL()
       
    42 	{
       
    43 	SetTestStepResult(EFail);
       
    44 	TDriveUnit drive (CurrentDrive());
       
    45 	TInt r;
       
    46 	TInt res;
       
    47 	_LIT(KMountPass, "Pass");
       
    48 	_LIT(KMountFail, "Fail");
       
    49 	_LIT(KCorrectVerdict,"CorrectVerdict");
       
    50 	TBuf<4> correctVerdict;
       
    51 	TPtrC16 correct = correctVerdict;
       
    52 	TBuf<4> actualVerdict;
       
    53 	TPtrC16 actual = actualVerdict;
       
    54 
       
    55 	if(IsFileSystemFAT32())
       
    56 		{
       
    57 		TFullName oldFs;
       
    58 		res = iTheFs.FileSystemName(oldFs,CurrentDrive());
       
    59 		res = iTheFs.DismountFileSystem(oldFs,CurrentDrive());
       
    60 		if (res != KErrNone)
       
    61 			{
       
    62 			_LIT(KDismountError, "Error %d - could not could not dismount filesystem from drive %d");
       
    63 			INFO_PRINTF3(KDismountError, res, CurrentDrive());
       
    64 			}
       
    65 		_LIT(KFsNameFat32, "Fat");
       
    66 		r = iTheFs.AddFileSystem(KFsNameFat32);
       
    67 		
       
    68 		TBool alright = GetStringFromConfig(ConfigSection(), KCorrectVerdict, correct);
       
    69 		if(alright)
       
    70 			{
       
    71 			r = iTheFs.MountFileSystem(KFsNameFat32, CurrentDrive());
       
    72 			if (r != KErrNone)
       
    73 				{
       
    74 				actualVerdict = KMountFail;
       
    75 				}
       
    76 			else 
       
    77 				{
       
    78 				actualVerdict = KMountPass;
       
    79 				}
       
    80 			if (actualVerdict == correct)
       
    81 				{
       
    82 				SetTestStepResult(EPass);
       
    83 				return TestStepResult();
       
    84 				}
       
    85 			else
       
    86 				{
       
    87 				SetTestStepResult(EFail);
       
    88 				return TestStepResult();
       
    89 				}
       
    90 			}
       
    91 		}
       
    92 	else
       
    93 		{
       
    94 			_LIT(KFsNameFat, "Fat");
       
    95 		res = iTheFs.DismountFileSystem(KFsNameFat,CurrentDrive());
       
    96 		if (res !=KErrNone)
       
    97 			{
       
    98 			_LIT(KDismountError, "Error %d - could not could not dismount filesystem from drive %d");
       
    99 			INFO_PRINTF3(KDismountError, res, CurrentDrive());
       
   100 			}
       
   101 		r = iTheFs.MountFileSystem(KFsNameFat, CurrentDrive());
       
   102 		}
       
   103 	if (r != KErrNone)
       
   104 		{
       
   105 		_LIT(KMountError, "Error %d - could not mount filesystem on drive %d");
       
   106 		INFO_PRINTF3(KMountError, r, CurrentDrive());
       
   107 		SetTestStepResult(EFail);
       
   108 		return TestStepResult();
       
   109 		}
       
   110 
       
   111 	SetTestStepResult(EPass);
       
   112 	return TestStepResult();
       
   113 	}