baseintegtests/baseintegrationtest/testsuites/sd/src/sdformat.cpp
changeset 0 a41df078684a
equal deleted inserted replaced
-1:000000000000 0:a41df078684a
       
     1 // Copyright (c) 2007-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 // Format disk
       
    15 // 
       
    16 //
       
    17 
       
    18 #include "sdformat.h"
       
    19 
       
    20 /*
       
    21 Class constructor
       
    22 
       
    23 @param None
       
    24 @return None
       
    25 */
       
    26 CBaseTestSDFormat::CBaseTestSDFormat()
       
    27 	{
       
    28 	SetTestStepName(KTestStepFormat);
       
    29 	}
       
    30 
       
    31 /*
       
    32 Test Step Preamble
       
    33  - Initialise attribute iDrive
       
    34  - Connect to the File Server
       
    35 
       
    36 @param None
       
    37 @return EPass if successful or EFail if not
       
    38 @see TVerdict
       
    39 */
       
    40 TVerdict CBaseTestSDFormat::doTestStepPreambleL()
       
    41 	{
       
    42 	SetTestStepResult(EFail);
       
    43 	
       
    44 	if (!InitDriveLetter())
       
    45 		return TestStepResult();
       
    46 	if (!InitFileServer())
       
    47 		return TestStepResult();
       
    48 	
       
    49 	SetTestStepResult(EPass);
       
    50 	return TestStepResult();
       
    51 	}
       
    52 
       
    53 /*
       
    54 Test step
       
    55 
       
    56 @param None
       
    57 @return EPass if successful or EFail if not
       
    58 @see TVerdict
       
    59 */
       
    60 TVerdict CBaseTestSDFormat::doTestStepL()
       
    61 	{
       
    62 	if (TestStepResult() == EPass)
       
    63 		{
       
    64 		TInt r;
       
    65 		TInt count;
       
    66 		TBuf<2> drive = _L("?:");
       
    67 		drive[0] = 'A' + iDrive;
       
    68 		
       
    69 		_LIT(KFormatType, "FormatType");
       
    70 		TInt formatType = 0;
       
    71 		GetIntFromConfig(ConfigSection(), KFormatType, formatType);
       
    72 		
       
    73 		if ((formatType != 1) && (formatType != 2))
       
    74 			{
       
    75 			ERR_PRINTF1(_L("Invalid Format Type Value"));
       
    76 			SetTestStepResult(EFail);
       
    77 			return TestStepResult();
       
    78 			}
       
    79 						
       
    80 		INFO_PRINTF2(_L("Formatting %S"), &drive);
       
    81 		RFormat format;
       
    82 		// 1 -> EQuickFormat
       
    83 		// 2 -> EFullFormat
       
    84 		r = format.Open(iFs, drive, formatType == 1 ? EQuickFormat : EFullFormat, count);
       
    85 		if (r != KErrNone)
       
    86 			{
       
    87 			ERR_PRINTF2(_L("RFormat::Open returned %d"), r);
       
    88 			SetTestStepResult(EFail);
       
    89 			return TestStepResult();
       
    90 			}
       
    91 		
       
    92 		if (count != 100)
       
    93 			{
       
    94 			ERR_PRINTF2(_L("Format count != 100 : %d"), count);
       
    95 			SetTestStepResult(EFail);
       
    96 			return TestStepResult();
       
    97 			}
       
    98 	
       
    99 		do
       
   100 			{
       
   101 			r = format.Next(count);
       
   102 			if (r != KErrNone)
       
   103 				{
       
   104 				ERR_PRINTF3(_L("RFormat::Next error %d count %d\n"), r, count);
       
   105 				SetTestStepResult(EFail);
       
   106 				return TestStepResult();
       
   107 				}
       
   108 			} while (count > 0);
       
   109 		format.Close();
       
   110 		}
       
   111 	else
       
   112 		{
       
   113 		INFO_PRINTF1(_L("Test preamble did not complete succesfully - Test Step skipped"));
       
   114 		}
       
   115 	return TestStepResult();
       
   116 	}