commonappservices/alarmservertest/TestAlarmSrv/EASShdOpCodeAlarmDataDetach1_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 "EASShdOpCodeAlarmDataDetach1_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 CEASShdOpCodeAlarmDataDetach1Step::CEASShdOpCodeAlarmDataDetach1Step()
       
    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		= 110;
       
    35 	iSrMessageMask		= 32;
       
    36 	iServerPanic		= _L("ALARMSERVER");
       
    37 
       
    38 	// NOT expected to be rejected as this test step will test for the condition: 
       
    39 	// none capapbility and same SID, and so has to pass. Also tests for correct capability.
       
    40 	iExpectRejection = EFalse;
       
    41 	
       
    42 	iStepCap = 32;
       
    43 
       
    44 	// Get a unique thread name
       
    45 	iSrChildThread.Format(_L("ChildThread_%S_%d"),&iSrServerName,iSrMessageId);
       
    46 	}
       
    47 
       
    48 /**
       
    49 This function is called by the Child Thread
       
    50 1.	Create a session with the server
       
    51 2.	Test an SendReceive call
       
    52 3.	Informs the main thread about the status of the call using
       
    53 	a.	iSessionCreated, if the a connection is established
       
    54 	b.	iResultServer, holds the return value for connection 
       
    55 	c.	iResultSr, the return value of SendReceive	call
       
    56 */
       
    57 TInt CEASShdOpCodeAlarmDataDetach1Step::Exec_SendReceiveL()
       
    58 	{
       
    59 	iResultServer = CreateSession(iSrServerName,Version(),KAlarmServerAsynchronousSlotCount);
       
    60 
       
    61 	if (iResultServer!=KErrNone)
       
    62 		{
       
    63 		iResultServer=StartServer();
       
    64 		if (iResultServer!=KErrNone)
       
    65 			{
       
    66 			return(iResultServer);
       
    67 			}
       
    68 		iResultServer = CreateSession(iSrServerName,Version(),KAlarmServerAsynchronousSlotCount);
       
    69 		}
       
    70 	if(iResultServer == 0)
       
    71 		{
       
    72 		iSessionCreated = ETrue;
       
    73 		if(iSrMessageId >= 0)
       
    74 			{
       
    75 			// Get the alarm id
       
    76 			TAlarmId alarmId;
       
    77 			alarmId = CCapabilityTestStep::GetAlarmId();
       
    78 			
       
    79 			if(alarmId >= 0)
       
    80 				{
       
    81 				// If valid alarm id, perform IPC call
       
    82 				TIpcArgs args(alarmId);
       
    83 				iResultSr =	SendReceive(iSrMessageId, args);
       
    84 				}
       
    85 			else
       
    86 				{
       
    87 				// else leave
       
    88 				User::Leave(alarmId);
       
    89 				}	
       
    90 			}
       
    91 		}
       
    92 	return iResultServer;
       
    93 	}
       
    94