commonappservices/alarmservertest/TestAlarmSrv/EASShdOpCodeGetAlarmData1_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 "EASShdOpCodeGetAlarmData1_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 CEASShdOpCodeGetAlarmData1Step::CEASShdOpCodeGetAlarmData1Step()
       
    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		= 101;
       
    35 	iSrMessageMask		= 32768;
       
    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
       
    40 	iExpectRejection = EFalse;
       
    41 	
       
    42 	iStepCap = 32768;
       
    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 CEASShdOpCodeGetAlarmData1Step::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 				_LIT8(KSomeAlarmData, "This is some 8-bit data");
       
    83 				HBufC8* buf = HBufC8::NewLC(KSomeAlarmData().Size());
       
    84 				TPtr8 pBuf(buf->Des());
       
    85 				TIpcArgs args(alarmId,pBuf.MaxLength(),&pBuf);
       
    86 				iResultSr =	SendReceive(iSrMessageId, args);
       
    87 				
       
    88 				// NewLC was used. So clean up
       
    89 				CleanupStack::PopAndDestroy(buf);
       
    90 				}
       
    91 			else
       
    92 				{
       
    93 				// else leave
       
    94 				User::Leave(alarmId);
       
    95 				}	
       
    96 			}
       
    97 		}
       
    98 	return iResultServer;
       
    99 	}
       
   100