serialserver/c32serialserver/Test/TE_C32/TE_c32base.h
changeset 0 dfb7c4ff071f
equal deleted inserted replaced
-1:000000000000 0:dfb7c4ff071f
       
     1 // Copyright (c) 2003-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 //
       
    15 
       
    16 #ifndef TE_C32BASE_H
       
    17 #define TE_C32BASE_H
       
    18 
       
    19 #include <testconfigfileparser.h>
       
    20 #include <test/testexecuteserverbase.h>
       
    21 
       
    22 #include <e32base.h>
       
    23 #include <e32test.h>
       
    24 #include <c32comm.h>
       
    25 #include <e32hal.h>
       
    26 #include <cs_port.h>
       
    27 #include <d32comm.h>
       
    28 #include "DParams.h"
       
    29 
       
    30 //
       
    31 // constants
       
    32 //
       
    33 #define NUMBER_OF_PORTS (2) //< number of ports for this machine
       
    34 const TTimeIntervalMicroSeconds32 KHugeTimeoutValue(1000000); 
       
    35 const TUint KDefaultHeapSizeThread = 0x4000; //< default heap size for the test Threads
       
    36 const TCommRole KCommDefaultPreemptRole = ECommRoleDTE; // default role for OpenWhenAvailble testing
       
    37 
       
    38 //
       
    39 // literals
       
    40 //
       
    41 _LIT8(KC32CompInfo, "C32 server");
       
    42 _LIT(KCommServerPanic, "!CommServer"); 	// for EKA2 from cc_utl.cpp
       
    43 _LIT(KCommServerFault, "C32-fault");  	// from cc_utl.cpp
       
    44 _LIT(KCommServerSuccess, "Kill");  		// Standard value for normal exit
       
    45 _LIT(KCsyName, "dummy");			   //< name of the CSY to load for the test
       
    46 _LIT(KCommPort0, "COMM::0");           //< first comm port name
       
    47 _LIT(KCommPort1, "COMM::1");           //< second comm port name
       
    48 _LIT(KDummyPortName,"dummy::6");
       
    49 
       
    50 /**
       
    51  * External representation of the state of a CPort object.
       
    52  */
       
    53 struct TCommDebugInfo 
       
    54 	{
       
    55 	TInternalCommAccess iMode;  //< The current main access mode of the port
       
    56 	TInt iAccessCount;          //< Number of open clients
       
    57 	TCommRole iRole;            //< DCE or DTE
       
    58 	TInt iOutstandingCommands;  //< Number of outstanding Opens, Closes, Waits etc.
       
    59 						        //< (excludes SetAccess requests)
       
    60 	};
       
    61 
       
    62 //
       
    63 // Test macros
       
    64 //
       
    65 #define TESTCHECKL(a, b) \
       
    66     { \
       
    67     if((a)!=(b)) \
       
    68 	    { \
       
    69 	    INFO_PRINTF3(_L("Failed: Got %d while expecting %d."),a,b); \
       
    70         SetTestStepResult(EFail); \
       
    71         User::Leave(EFail); \
       
    72         } \
       
    73     }
       
    74 
       
    75 #define TESTCHECKCONDITIONL(a) \
       
    76     { \
       
    77     if (!(a)) \
       
    78 	    { \
       
    79 	    INFO_PRINTF1(_L("Failed: Condition was false.")); \
       
    80         SetTestStepResult(EFail); \
       
    81         User::Leave(EFail); \
       
    82         } \
       
    83     }
       
    84     
       
    85 #define TESTCHECKSTRL(a, b) \
       
    86     { \
       
    87     if((a)!=(b)) \
       
    88 	    { \
       
    89 	    TBuf<255> temp = a ; \
       
    90 	    INFO_PRINTF3(_L("Failed: Got \"%S\" while expecting \"%S\"."), &temp,&(b)); \
       
    91         SetTestStepResult(EFail); \
       
    92         User::Leave(EFail); \
       
    93         } \
       
    94     }
       
    95     
       
    96 #define TESTCHECK(a, b) \
       
    97     { \
       
    98     if((a)!=(b)) \
       
    99 	    { \
       
   100 	    INFO_PRINTF3(_L("Failed: Got %d while expecting %d."),a,b); \
       
   101         SetTestStepResult(EFail); \
       
   102         } \
       
   103     }
       
   104 
       
   105 #define TESTCHECKCONDITION(a) \
       
   106     { \
       
   107     if (!(a)) \
       
   108 	    { \
       
   109 	    INFO_PRINTF1(_L("Failed: Condition was false.")); \
       
   110         SetTestStepResult(EFail); \
       
   111         } \
       
   112     }
       
   113     
       
   114 #define TESTCHECKSTR(a, b) \
       
   115     { \
       
   116     if((a)!=(b)) \
       
   117 	    { \
       
   118 	    TBuf<255> temp = a ; \
       
   119 	    INFO_PRINTF3(_L("Failed: Got \"%S\" while expecting \"%S\"."), &temp,&(b)); \
       
   120         SetTestStepResult(EFail); \
       
   121         } \
       
   122     }
       
   123     
       
   124 
       
   125 class CC32TestStep : public CTestStep
       
   126 	{
       
   127 protected:			
       
   128 	void ShowReceived(const TPtr8& aBuf);	
       
   129 protected:		
       
   130  	virtual TVerdict doTestStepPreambleL( void );
       
   131 	virtual TVerdict doTestStepPostambleL( void );
       
   132 protected:
       
   133 	RCommServ iCommSession; 				 //< the Comm server
       
   134     RComm iSerialPortList[NUMBER_OF_PORTS];  //< the Comm ports used here	
       
   135 	};
       
   136 
       
   137 #endif
       
   138