serialserver/c32serialserver/LOOPBACK/te_loopback/src/DataReadyNotificationStep.cpp
changeset 0 dfb7c4ff071f
equal deleted inserted replaced
-1:000000000000 0:dfb7c4ff071f
       
     1 // Copyright (c) 2005-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 // Example CTestStep derived implementation
       
    15 // 
       
    16 //
       
    17 
       
    18 /**
       
    19  @file DataReadyNotificationStep.cpp
       
    20  @internalTechnology
       
    21 */
       
    22 #include "DataReadyNotificationStep.h"
       
    23 #include "Te_loopbackSuiteDefs.h"
       
    24 
       
    25 CDataReadyNotificationStep::~CDataReadyNotificationStep()
       
    26 /**
       
    27  * Destructor
       
    28  */
       
    29 	{
       
    30 	}
       
    31 
       
    32 CDataReadyNotificationStep::CDataReadyNotificationStep()
       
    33 /**
       
    34  * Constructor
       
    35  */
       
    36 	{
       
    37 	// **MUST** call SetTestStepName in the constructor as the controlling
       
    38 	// framework uses the test step name immediately following construction to set
       
    39 	// up the step's unique logging ID.
       
    40 	SetTestStepName(KDataReadyNotificationStep);
       
    41 	}
       
    42 
       
    43 TVerdict CDataReadyNotificationStep::doTestStepPreambleL()
       
    44 /**
       
    45  * @return - TVerdict code
       
    46  * Override of base class virtual
       
    47  */
       
    48 	{
       
    49 	return OpenAllAvailablePortsL();
       
    50 	}
       
    51 
       
    52 
       
    53 TVerdict CDataReadyNotificationStep::doTestStepL()
       
    54 /**
       
    55  * @return - TVerdict code
       
    56  * Override of base class pure virtual
       
    57  * Our implementation only gets called if the base class doTestStepPreambleL() did
       
    58  * not leave. That being the case, the current test result value will be EPass.
       
    59  */
       
    60 	{
       
    61 	  if (TestStepResult()==EPass)
       
    62 		{
       
    63 		_LIT8(KTestOutBuf,"test message");
       
    64 		HBufC* InBuf = HBufC::NewLC(KTestOutBuf().Length() / 2);
       
    65 		TPtr ptr = InBuf->Des();
       
    66 		TPtr8 inBuf(ptr.Collapse());
       
    67 		
       
    68 		TBuf<50> msg;
       
    69 		_LIT(KOperReading, "Data available in port <%d>");
       
    70 		_LIT(KOperWriting, "Written port <%d>");
       
    71 		TRequestStatus status;
       
    72 		for(TInt i = 0; i < KSupportedPorts; i++)
       
    73 			{
       
    74 			if(IsEven(i))
       
    75 				{
       
    76 				iPortList[i].port.Write(status, KTestOutBuf);
       
    77 				msg.Format(KOperWriting, i);
       
    78 				}
       
    79 			else
       
    80 				{
       
    81 				iPortList[i].port.NotifyDataAvailable(status);
       
    82 				msg.Format(KOperReading, i);
       
    83 				}
       
    84 			User::WaitForRequest(status);
       
    85 			TestErrorCodeL(status.Int(), msg);
       
    86 			}
       
    87 		CleanupStack::PopAndDestroy();
       
    88 
       
    89 		SetTestStepResult(EPass);
       
    90 		}
       
    91 	  return TestStepResult();
       
    92 	}
       
    93 
       
    94 
       
    95 
       
    96 TVerdict CDataReadyNotificationStep::doTestStepPostambleL()
       
    97 /**
       
    98  * @return - TVerdict code
       
    99  * Override of base class virtual
       
   100  */
       
   101 	{
       
   102 	return CloseAllAvailablePortsL();
       
   103 	}
       
   104