testexecmdw/tef/tef/workshop/demoipsuite/src/ipsuitestepbase.cpp
branchRCL_3
changeset 3 9397a16b6eb8
parent 1 6edeef394eb7
equal deleted inserted replaced
1:6edeef394eb7 3:9397a16b6eb8
     1 /*
       
     2 * Copyright (c) 2005-2009 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: 
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 /**
       
    21  @file IPSuiteStepBase.cpp
       
    22 */
       
    23 
       
    24 #include "ipsuitestepbase.h"
       
    25 #include "ipsuitedefs.h"
       
    26 
       
    27 // Device driver constants
       
    28 #if (defined __WINS__)
       
    29 _LIT(KPdd,"ECDRV");
       
    30 #else
       
    31 _LIT(KPdd,"EUART1");
       
    32 #endif
       
    33 _LIT(KLdd,"ECOMM");
       
    34 
       
    35 TVerdict CIPSuiteStepBase::doTestStepPreambleL()
       
    36 /**
       
    37  * @return - TVerdict
       
    38  * Implementation of CTestStep base class virtual
       
    39  * Do all initialisation common to derived classes in here.
       
    40  * Just leave if there are any errors here as there's no point in
       
    41  * trying to run a test step if anything fails.
       
    42  * The leave will be picked up by the framework.
       
    43  */
       
    44 	{
       
    45 	// For the emulator and 2 box solutions we need to load the
       
    46 	// physical device drivers
       
    47 	// Leave if there are any errors
       
    48 	TInt ret = KErrNone;
       
    49 	ret = User::LoadPhysicalDevice(KPdd);
       
    50 	if(ret != KErrNone && ret != KErrAlreadyExists)
       
    51 		User::Leave(ret);
       
    52 	ret = User::LoadLogicalDevice(KLdd);
       
    53 	if(ret != KErrNone && ret != KErrAlreadyExists)
       
    54 		User::Leave(ret);
       
    55 
       
    56 	// Read the ini file to get the destination IP address and the data
       
    57 	TPtrC IPAddr;
       
    58 	TPtrC configWriteData;
       
    59 	TInt port = 7;
       
    60 	if(!GetStringFromConfig(ConfigSection(),KDemoSuiteIPAddress, IPAddr) ||
       
    61 	   !GetStringFromConfig(ConfigSection(),KDemoSuiteTestData,configWriteData) ||
       
    62 	   !GetIntFromConfig(ConfigSection(),KDemoSuiteIPPort,port)
       
    63 		)
       
    64 		// Leave if there's any error.
       
    65 		User::Leave(KErrNotFound);
       
    66 	// Connect to the socket server
       
    67 	User::LeaveIfError(iServer.Connect());
       
    68 
       
    69 	// Set the ip address class
       
    70 	// Could read the port from the ini file
       
    71 	iDestAddr.Input(IPAddr);
       
    72 	iDestAddr.SetPort(port);
       
    73 
       
    74 	// Set up the read and write buffers
       
    75 	iReadData = HBufC8::NewMaxL(configWriteData.Length());
       
    76 	iWriteData = HBufC8::NewMaxL(configWriteData.Length());
       
    77 	iWriteData->Des().Copy(configWriteData);	
       
    78 
       
    79 	SetTestStepResult(EPass);
       
    80 	return TestStepResult();
       
    81 	}
       
    82 
       
    83 CIPSuiteStepBase::~CIPSuiteStepBase()
       
    84 	{
       
    85 	iServer.Close();
       
    86 	delete iReadData;
       
    87 	delete iWriteData;
       
    88 	}
       
    89 
       
    90 CIPSuiteStepBase::CIPSuiteStepBase()
       
    91 	{
       
    92 	}