commonappservices/alarmservertest/TestAlarmSrv/EASShdOpCodeAlarmAdd1_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 "EASShdOpCodeAlarmAdd1_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 CEASShdOpCodeAlarmAdd1Step::CEASShdOpCodeAlarmAdd1Step()
       
    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		= 200;
       
    35 	iSrMessageMask		= 65536;
       
    36 	iServerPanic		= _L("ALARMSERVER");
       
    37 
       
    38 	TCapability cap[] = {ECapabilityWriteUserData, 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 = 65536;
       
    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 CEASShdOpCodeAlarmAdd1Step::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 			// Modifications made to tool generated code
       
    88 			// Create a TASShdAlarm object and set its properties
       
    89 			TASShdAlarm alarm;
       
    90 			alarm.Category() = KASCliCategoryClock;
       
    91 			alarm.RepeatDefinition() = EAlarmRepeatDefintionRepeatOnce;
       
    92 			alarm.NextDueTime().HomeTime();
       
    93 			
       
    94 			// Set the alarm to go off after 20 seconds.
       
    95 			// The alarm is intended to go off when EASShdOpCodeNotifyChange1_CStep, 
       
    96 			// the next test step that will be executed, is waiting for an event to occur.
       
    97 			TInt seconds = 20;
       
    98 			alarm.NextDueTime() += TTimeIntervalSeconds(seconds);
       
    99 			
       
   100 			// Construct the TIpcArgs for SendReceive
       
   101 			TPckg<TASShdAlarm> package(alarm);
       
   102 			TDesC8 emptydata = KNullDesC8;
       
   103 			TIpcArgs args(&package, emptydata.Length(), &emptydata);
       
   104 			
       
   105 			// Make the IPC call
       
   106 			iResultSr =	SendReceive(iSrMessageId, args);
       
   107 			
       
   108 			// Create one more alarm as AlarmCancelAndDeque test step will 
       
   109 			// remove one from the server
       
   110 			TASShdAlarm alarm1;
       
   111 			alarm1.Category() = KASCliCategoryClock;
       
   112 			alarm1.RepeatDefinition() = EAlarmRepeatDefintionRepeatOnce;
       
   113 			alarm1.NextDueTime().HomeTime();
       
   114 			seconds = 50;
       
   115 			alarm1.NextDueTime() += TTimeIntervalSeconds(seconds);
       
   116 			TPckg<TASShdAlarm> package1(alarm1);
       
   117 			TDesC8 emptydata1 = KNullDesC8;
       
   118 			TIpcArgs args1(&package1, emptydata1.Length(), &emptydata1);
       
   119 			iResultSr =	SendReceive(iSrMessageId, args1);
       
   120 			
       
   121 			// And one more just in case
       
   122 			TASShdAlarm alarm2;
       
   123 			alarm2.Category() = KASCliCategoryClock;
       
   124 			alarm2.RepeatDefinition() = EAlarmRepeatDefintionRepeatOnce;
       
   125 			alarm2.NextDueTime().HomeTime();
       
   126 			seconds = 70;
       
   127 			alarm2.NextDueTime() += TTimeIntervalSeconds(seconds);
       
   128 			TPckg<TASShdAlarm> package2(alarm2);
       
   129 			TDesC8 emptydata2 = KNullDesC8;
       
   130 			TIpcArgs args2(&package2, emptydata2.Length(), &emptydata2);
       
   131 			iResultSr =	SendReceive(iSrMessageId, args2);
       
   132 			}
       
   133 		}
       
   134 	return iResultServer;
       
   135 	}