datacommsserver/esockserver/test/TE_Protocol/src/TestStepProtocol.cpp
changeset 0 dfb7c4ff071f
equal deleted inserted replaced
-1:000000000000 0:dfb7c4ff071f
       
     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 "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 // Contains definition of CTestStepProtocol which is the base class 
       
    15 // for all the Protocol Test Step classes  		
       
    16 // 
       
    17 //
       
    18 
       
    19 /**
       
    20  @file TestStepProtocol.cpp
       
    21 */
       
    22 
       
    23 // EPOC includes
       
    24 #include <e32base.h>
       
    25 #include <es_sock.h>
       
    26 #include <test/es_dummy.h>
       
    27 
       
    28 // Test system includes
       
    29 #include "TestStepProtocol.h"
       
    30 #include "ProtocolTestSection.h"
       
    31 
       
    32 // static consts
       
    33 const TUint CTestStepProtocol::KNumTestSockets = 10;
       
    34 const TInt CTestStepProtocol::KNumExhaustiveSockets = 100;
       
    35 const TInt CTestStepProtocol::KNumStretchOpens = 16;
       
    36 
       
    37 
       
    38 
       
    39 // constructor
       
    40 CTestStepProtocol::CTestStepProtocol() : iErrText()
       
    41 	{
       
    42 	}
       
    43 
       
    44 // destructor
       
    45 CTestStepProtocol::~CTestStepProtocol()
       
    46 	{
       
    47 	delete iDummy;
       
    48 	}
       
    49 
       
    50 
       
    51 enum TVerdict CTestStepProtocol::doTestStepL()
       
    52 	{
       
    53 	
       
    54 	TRAPD(trapRet,
       
    55 		Logger().ShareAuto();
       
    56 	enum TVerdict stepRet = InternalDoTestStepL();
       
    57 	if (stepRet !=EPass)
       
    58 		{
       
    59 		SetTestStepResult(stepRet);
       
    60 		}
       
    61 		)
       
    62 		
       
    63 		if (trapRet != KErrNone)
       
    64 			{
       
    65 			SetTestStepResult(EFail);
       
    66 			return EFail;
       
    67 			}
       
    68 		return EPass;
       
    69 	};
       
    70 
       
    71 
       
    72 // extra logging methods
       
    73 const TPtrC& CTestStepProtocol::EpocErrorToText(const TInt aErrCode)
       
    74 /**
       
    75 Convert a Error code to text.
       
    76 
       
    77   @param aError error code to display as text.
       
    78   @return Text describing the error.
       
    79   */
       
    80 	{
       
    81 	//	TPtr errText;
       
    82 	switch (aErrCode)
       
    83 		{
       
    84 		case KErrNone:
       
    85 			iErrText.Set(_L("KErrNone"));
       
    86 			break;
       
    87 		case KErrNotFound:
       
    88 			iErrText.Set(_L("KErrNotFound"));
       
    89 			break;
       
    90 		case KErrGeneral:
       
    91 			iErrText.Set(_L("KErrGeneral"));
       
    92 			break;
       
    93 		case KErrCancel:
       
    94 			iErrText.Set(_L("KErrCancel"));
       
    95 			break;
       
    96 		case KErrNoMemory:
       
    97 			iErrText.Set(_L("KErrNoMemory"));
       
    98 			break;
       
    99 		case KErrNotSupported:
       
   100 			iErrText.Set(_L("KErrNotSupported"));
       
   101 			break;
       
   102 		case KErrArgument:
       
   103 			iErrText.Set(_L("KErrArgument"));
       
   104 			break;
       
   105 		case KErrTotalLossOfPrecision:
       
   106 			iErrText.Set(_L("KErrTotalLossOfPrecision"));
       
   107 			break;
       
   108 		case KErrBadHandle:
       
   109 			iErrText.Set(_L("KErrBadHandle"));
       
   110 			break;
       
   111 		case KErrOverflow:
       
   112 			iErrText.Set(_L("KErrOverflow"));
       
   113 			break;
       
   114 		case KErrUnderflow:
       
   115 			iErrText.Set(_L("KErrUnderflow"));
       
   116 			break;
       
   117 		case KErrAlreadyExists:
       
   118 			iErrText.Set(_L("KErrAlreadyExists"));
       
   119 			break;
       
   120 		case KErrPathNotFound:
       
   121 			iErrText.Set(_L("KErrPathNotFound"));
       
   122 			break;
       
   123 		case KErrDied:
       
   124 			iErrText.Set(_L("KErrDied"));
       
   125 			break;
       
   126 		case KErrInUse:
       
   127 			iErrText.Set(_L("KErrInUse"));
       
   128 			break;
       
   129 		case KErrServerTerminated:
       
   130 			iErrText.Set(_L("KErrServerTerminated"));
       
   131 			break;
       
   132 		case KErrServerBusy:
       
   133 			iErrText.Set(_L("KErrServerBusy"));
       
   134 			break;
       
   135 		case KErrCompletion:
       
   136 			iErrText.Set(_L("KErrCompletion"));
       
   137 			break;
       
   138 		case KErrNotReady:
       
   139 			iErrText.Set(_L("KErrNotReady"));
       
   140 			break;
       
   141 		case KErrUnknown:
       
   142 			iErrText.Set(_L("KErrUnknown"));
       
   143 			break;
       
   144 		case KErrCorrupt:
       
   145 			iErrText.Set(_L("KErrCorrupt"));
       
   146 			break;
       
   147 		case KErrAccessDenied:
       
   148 			iErrText.Set(_L("KErrAccessDenied"));
       
   149 			break;
       
   150 		case KErrLocked:
       
   151 			iErrText.Set(_L("KErrLocked"));
       
   152 			break;
       
   153 		case KErrWrite:
       
   154 			iErrText.Set(_L("KErrWrite"));
       
   155 			break;
       
   156 		case KErrDisMounted:
       
   157 			iErrText.Set(_L("KErrDisMounted"));
       
   158 			break;
       
   159 		case KErrEof:
       
   160 			iErrText.Set(_L("KErrEof"));
       
   161 			break;
       
   162 		case KErrDiskFull:
       
   163 			iErrText.Set(_L("KErrDiskFull"));
       
   164 			break;
       
   165 		case KErrBadDriver:
       
   166 			iErrText.Set(_L("KErrBadDriver"));
       
   167 			break;
       
   168 		case KErrBadName:
       
   169 			iErrText.Set(_L("KErrBadName"));
       
   170 			break;
       
   171 		case KErrCommsLineFail:
       
   172 			iErrText.Set(_L("KErrCommsLineFail"));
       
   173 			break;
       
   174 		case KErrCommsFrame:
       
   175 			iErrText.Set(_L("KErrCommsFrame"));
       
   176 			break;
       
   177 		case KErrCommsOverrun:
       
   178 			iErrText.Set(_L("KErrCommsOverrun"));
       
   179 			break;
       
   180 		case KErrCommsParity:
       
   181 			iErrText.Set(_L("KErrCommsParity"));
       
   182 			break;
       
   183 		case KErrTimedOut:
       
   184 			iErrText.Set(_L("KErrTimedOut"));
       
   185 			break;
       
   186 		case KErrCouldNotConnect:
       
   187 			iErrText.Set(_L("KErrCouldNotConnect"));
       
   188 			break;
       
   189 		case KErrCouldNotDisconnect:
       
   190 			iErrText.Set(_L("KErrCouldNotDisconnect"));
       
   191 			break;
       
   192 		case KErrDisconnected:
       
   193 			iErrText.Set(_L("KErrDisconnected"));
       
   194 			break;
       
   195 		case KErrBadLibraryEntryPoint:
       
   196 			iErrText.Set(_L("KErrBadLibraryEntryPoint"));
       
   197 			break;
       
   198 		case KErrBadDescriptor:
       
   199 			iErrText.Set(_L("KErrBadDescriptor"));
       
   200 			break;
       
   201 		case KErrAbort:
       
   202 			iErrText.Set(_L("KErrAbort"));
       
   203 			break;
       
   204 		case KErrTooBig:
       
   205 			iErrText.Set(_L("KErrTooBig"));
       
   206 			break;
       
   207 		case KErrCannotFindProtocol:
       
   208 			iErrText.Set(_L("KErrCannotFindProtocol"));
       
   209 			break;
       
   210 		case KErrPermissionDenied:
       
   211 			iErrText.Set(_L("KErrPermissionDenied"));
       
   212 			break;	
       
   213 		default:
       
   214 			iErrBuf.Format(_L(" %d"),aErrCode);
       
   215 			iErrText.Set(iErrBuf.Ptr());
       
   216 			break;
       
   217 		}
       
   218 		return iErrText;
       
   219 	}	
       
   220 
       
   221