commsprocess/commsrootserverconfig/CapTestFramework/common/CStep.cpp
changeset 0 dfb7c4ff071f
equal deleted inserted replaced
-1:000000000000 0:dfb7c4ff071f
       
     1 // Copyright (c) 1997-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 // PARAM_MESS_NAME_cstep.CPP
       
    15 // 
       
    16 //
       
    17 
       
    18 
       
    19 
       
    20 //Test Step header
       
    21 #include "PARAM_MESS_NAME_cstep.h"
       
    22 
       
    23 //TO BE SAFE
       
    24 IMPORT_C TInt StartDialogThread();
       
    25 
       
    26 /**
       
    27  Each test step initialises it's own name
       
    28 */
       
    29 CPARAM_MESS_NAMEStep::CPARAM_MESS_NAMEStep()
       
    30 	{
       
    31 	// store the name of this test case
       
    32 	// this is the name that is used by the script file
       
    33 	//DEF iTestStepName = _L("CPARAM_MESS_NAMEStep");
       
    34 
       
    35 	//The server name and IPC number is obtained and all messages are checked Sync
       
    36 	SR_ServerName		= _L("PARAM_SVR_NAME");
       
    37 	SR_MESSAGE_TYPE		=	2;
       
    38 	SR_MESSAGE_ID		= PARAM_MESS_VALUE;
       
    39 	SR_MESSAGE_MASK		= PARAM_MESS_CAPMASK;
       
    40 
       
    41 	// Added to support SID/VID testing
       
    42 	SR_MESSAGE_SID		= TSecureId (PARAM_MESS_REQUIREDSID);
       
    43 	SR_MESSAGE_VID		= TVendorId (PARAM_MESS_REQUIREDVID);
       
    44 
       
    45 	//The iServer_Panic is a unique name from Server,but always truncated to KMaxExitCategoryName
       
    46 	
       
    47 	iServer_Panic		=	_L("PARAM_SVR_T16_PANIC");
       
    48 
       
    49 	TCapability cap[] = {ECapabilityPARAM_MESS_NAMECAP, ECapability_Limit};
       
    50 	
       
    51 	TSecurityInfo info;
       
    52 	info.Set(RProcess());
       
    53 	TBool result = EFalse;
       
    54 	
       
    55 	// Skip check if no caps are required
       
    56 	if (cap[0] != ECapability_None)
       
    57 		{
       
    58 		for (TInt i = 0; cap[i] != ECapability_Limit; i++) 
       
    59 			{
       
    60 			if (!(info.iCaps.HasCapability(cap[i])))
       
    61 				{
       
    62 				// this process doesn't have required caps - expect fail
       
    63 				result=ETrue;
       
    64 				break;
       
    65 				}
       
    66 			
       
    67 			}
       
    68 		}
       
    69 
       
    70 	if (!result && SR_MESSAGE_SID != 0)
       
    71 		{
       
    72 		if (info.iSecureId != SR_MESSAGE_SID)
       
    73 			{
       
    74 			// this process doesn't have the required SID - expect fail
       
    75 			result=ETrue;
       
    76 			}
       
    77 		}
       
    78 		
       
    79 	if (!result && SR_MESSAGE_VID != 0)
       
    80 		{
       
    81 		if (info.iVendorId != SR_MESSAGE_VID)
       
    82 			{
       
    83 			// this process doesn't have the required SID - expect fail
       
    84 			result=ETrue;
       
    85 			}
       
    86 		}
       
    87 	
       
    88 	iExpect_Rejection = result;
       
    89 	
       
    90 	iStepCap			= PARAM_MESS_CAPMASK;
       
    91 
       
    92 	//Get a unique thread name
       
    93 	ChildThread_SR.Format(_L("ChildThread_%S_%d"),&SR_ServerName,SR_MESSAGE_ID);
       
    94 
       
    95 	}
       
    96 
       
    97 /**
       
    98 	This Fn is called by the Child Thread
       
    99 1.	Create a session with the server
       
   100 2.	Test an SendReceive call
       
   101 3.	Informs the main thread about the status of the call using
       
   102 	a.	iSessionCreated, if the a connection is established
       
   103 	b.	iResult_Server, holds the return value for connection 
       
   104 	c.	iResult_SR, the return value of SendReceive	call
       
   105 */
       
   106 TInt CPARAM_MESS_NAMEStep::Exec_SendReceive()
       
   107 	{
       
   108 	iResult_Server = CreateSession(SR_ServerName,Version(),2);
       
   109 
       
   110 	if (iResult_Server!=KErrNone)
       
   111 		{
       
   112 		iResult_Server=StartServer();
       
   113 		if (iResult_Server!=KErrNone)
       
   114 			{
       
   115 			return(iResult_Server);
       
   116 			}
       
   117 
       
   118 		iResult_Server = CreateSession(SR_ServerName,TVersion(),2);
       
   119 		}
       
   120 		
       
   121 	if(iResult_Server == 0)
       
   122 		{
       
   123 		iSessionCreated = ETrue;
       
   124 		if(SR_MESSAGE_ID >= 0)
       
   125 			{
       
   126 			iResult_SR	=	SendReceive(SR_MESSAGE_ID,TIpcArgs(0,0,0,0));
       
   127 			}
       
   128 		}
       
   129 
       
   130 	return iResult_Server;
       
   131 	}
       
   132