baseintegtests/baseintegrationtest/testsuites/sd/src/sdcopyfile.cpp
branchanywhere
changeset 20 d63d727ee0a6
parent 19 f6d3d9676ee4
parent 16 6d8ad5bee44b
child 21 af091391d962
equal deleted inserted replaced
19:f6d3d9676ee4 20:d63d727ee0a6
     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 // Copy a file
       
    15 // 
       
    16 //
       
    17 
       
    18 #include "sdcopyfile.h"
       
    19 
       
    20 /*
       
    21 Class constructor
       
    22 
       
    23 @param None
       
    24 @return None
       
    25 */
       
    26 CBaseTestSDCopyFile::CBaseTestSDCopyFile()
       
    27 	{
       
    28 	SetTestStepName(KTestStepCopyFile);
       
    29 	}
       
    30 
       
    31 /*
       
    32 Test Step Preamble
       
    33  - Initialise attribute iDrive
       
    34  - Connect to the File Server
       
    35  - Instatiate a CFileMan object
       
    36  
       
    37 @param None
       
    38 @return EPass if successful or EFail if not
       
    39 @see TVerdict
       
    40 */
       
    41 TVerdict CBaseTestSDCopyFile::doTestStepPreambleL()
       
    42 	{
       
    43 	SetTestStepResult(EFail);
       
    44 	
       
    45 	if (!InitDriveLetter())
       
    46 		return TestStepResult();
       
    47 	if (!InitFileServer())
       
    48 		return TestStepResult();
       
    49 	if (!InitFileMan())
       
    50 		return TestStepResult();
       
    51 	
       
    52 	SetTestStepResult(EPass);
       
    53 	return TestStepResult();
       
    54 	}
       
    55 
       
    56 /*
       
    57 Test step
       
    58 
       
    59 @param None
       
    60 @return EPass if successful or EFail if not
       
    61 @see TVerdict
       
    62 */
       
    63 TVerdict CBaseTestSDCopyFile::doTestStepL()
       
    64 	{
       
    65 	if (TestStepResult() == EPass)
       
    66 		{
       
    67 		_LIT(KOriginalFile, "CopyFileOriginalFile");
       
    68 		_LIT(KDestinationDirectory, "CopyFileDestinationDirectory");
       
    69 		TPtrC pOrig;
       
    70 		TPtrC pDest;
       
    71 		
       
    72 		if (!GetStringFromConfig(ConfigSection(), KOriginalFile, pOrig))
       
    73 			{
       
    74 			ERR_PRINTF1(_L("INI File Read failed"));
       
    75 			SetTestStepResult(EFail);
       
    76 			return TestStepResult();
       
    77 			}
       
    78 		if (!GetStringFromConfig(ConfigSection(), KDestinationDirectory, pDest))
       
    79 			{
       
    80 			ERR_PRINTF1(_L("INI File Read failed"));
       
    81 			SetTestStepResult(EFail);
       
    82 			return TestStepResult();
       
    83 			}
       
    84 		TFileName orig(pOrig);
       
    85 		TFileName dest(pDest);
       
    86 		
       
    87 		TInt r;
       
    88 		TFileName driveRoot;
       
    89 		driveRoot.Format(_L("%c:\\"), 'A' + iDrive);
       
    90 		r = iFs.SetSessionPath(driveRoot);	
       
    91 		if (r != KErrNone)
       
    92 			{
       
    93 			ERR_PRINTF3(_L("Could not set RFs session path to %S: %d"), &driveRoot, r);
       
    94 			SetTestStepResult(EFail);
       
    95 			return TestStepResult();
       
    96 			}
       
    97 		
       
    98 		INFO_PRINTF3(_L("Copy %S to %S"), &orig, &dest);
       
    99 		
       
   100 		r = iFileMan->Copy(orig, dest, CFileMan::EOverWrite);
       
   101 		
       
   102 		if (r != KErrNone)
       
   103 			{
       
   104 			ERR_PRINTF4(_L("Failed to copy %S to %S - return value: %d"), &orig, &dest, r);
       
   105 			SetTestStepResult(EFail);
       
   106 			return TestStepResult();
       
   107 			}
       
   108 		}
       
   109 	else
       
   110 		{
       
   111 		INFO_PRINTF1(_L("Test preamble did not complete succesfully - Test Step skipped"));
       
   112 		}
       
   113 	return TestStepResult();
       
   114 	}