commonappservices/alarmservertest/TestAlarmSrv/EASShdOpCodeAlarmCountByState1_CStep.cpp
changeset 0 2e3d3ce01487
equal deleted inserted replaced
-1:000000000000 0:2e3d3ce01487
       
     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 // This file contains the functions to construct the Test Step and the 
       
    15 // Exec_SendReceiveL() function that connects to the server and makes IPC calls.
       
    16 // 
       
    17 //
       
    18 
       
    19 // Test Step header
       
    20 #include "EASShdOpCodeAlarmCountByState1_CStep.h"
       
    21 
       
    22 // TO BE SAFE
       
    23 IMPORT_C TInt StartDialogThread();
       
    24 
       
    25 /** 
       
    26 Constructor called from the respective Suite.cpp from their "AddTestStep" function
       
    27 Each test step initialises it's own name
       
    28 */
       
    29 CEASShdOpCodeAlarmCountByState1Step::CEASShdOpCodeAlarmCountByState1Step()
       
    30 	{
       
    31 	// The server name and IPC number is obtained and all messages are checked Sync
       
    32 	iSrServerName		= _L("!AlarmServer");
       
    33 	iSrMessageType		= 2;
       
    34 	iSrMessageId		= 10;
       
    35 	iSrMessageMask		= 0;
       
    36 	iServerPanic		= _L("ALARMSERVER");
       
    37 
       
    38 	TCapability cap[] = {ECapability_None, ECapability_Limit};
       
    39 	
       
    40 	TSecurityInfo info;
       
    41 	info.Set(RProcess());
       
    42 	TBool result = EFalse;
       
    43 	
       
    44 	TInt i;
       
    45 	for (i = 0; cap[i] != ECapability_Limit; i++) 
       
    46 		{
       
    47 		if (!(info.iCaps.HasCapability(cap[i])))
       
    48 			{
       
    49 			result=ETrue;
       
    50 			}
       
    51 		}
       
    52 		
       
    53 	iExpectRejection = result;
       
    54 	iStepCap = 0;
       
    55 
       
    56 	// Get a unique thread name
       
    57 	iSrChildThread.Format(_L("ChildThread_%S_%d"),&iSrServerName,iSrMessageId);
       
    58 	}
       
    59 
       
    60 /**
       
    61 This function is called by the Child Thread
       
    62 1.	Create a session with the server
       
    63 2.	Test an SendReceive call
       
    64 3.	Informs the main thread about the status of the call using
       
    65 	a.	iSessionCreated, if the a connection is established
       
    66 	b.	iResultServer, holds the return value for connection 
       
    67 	c.	iResultSr, the return value of SendReceive	call
       
    68 */
       
    69 TInt CEASShdOpCodeAlarmCountByState1Step::Exec_SendReceiveL()
       
    70 	{
       
    71 	iResultServer = CreateSession(iSrServerName,Version(),KAlarmServerAsynchronousSlotCount);
       
    72 
       
    73 	if (iResultServer!=KErrNone)
       
    74 		{
       
    75 		iResultServer=StartServer();
       
    76 		if (iResultServer!=KErrNone)
       
    77 			{
       
    78 			return(iResultServer);
       
    79 			}
       
    80 		iResultServer = CreateSession(iSrServerName,Version(),KAlarmServerAsynchronousSlotCount);
       
    81 		}
       
    82 	if(iResultServer == 0)
       
    83 		{
       
    84 		iSessionCreated = ETrue;
       
    85 		if(iSrMessageId >= 0)
       
    86 			{
       
    87 			TPckgBuf<TInt> count;
       
    88 			iResultSr =	SendReceive(iSrMessageId,TIpcArgs(0,&count));
       
    89 			}
       
    90 		}
       
    91 	return iResultServer;
       
    92 	}
       
    93