commonappservices/alarmservertest/TestAlarmSrv/CSuite.cpp
changeset 0 2e3d3ce01487
equal deleted inserted replaced
-1:000000000000 0:2e3d3ce01487
       
     1 // Copyright (c) 2004-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 main TestServer suite functions including E32Main.
       
    15 // For (WINS && !EKA2) versions will be xxxServer.Dll and require a thread to be started
       
    16 // in the process of the client. The client initialises the server by calling the
       
    17 // one and only ordinal.
       
    18 // 
       
    19 //
       
    20 
       
    21 // EPOC includes
       
    22 #include <e32base.h>
       
    23 #include <e32cmn.h> 
       
    24 
       
    25 // Type definitions
       
    26 #define UNUSED_VAR(a) a = a
       
    27 
       
    28 #if (!defined TS_Alarm_SERVER_H_)
       
    29 	#include "CSuite.h"
       
    30 #endif
       
    31 
       
    32 // Add Test Step headers here
       
    33 #include "EASShdOpCodeNotifyChange1_CStep.h"
       
    34 #include "EASShdOpCodeGetAlarmCategory1_CStep.h"
       
    35 #include "EASShdOpCodeGetAlarmOwner1_CStep.h"
       
    36 #include "EASShdOpCodeGetAlarmStatus1_CStep.h"
       
    37 #include "EASShdOpCodeGetAlarmDayOrTimed1_CStep.h"
       
    38 #include "EASShdOpCodeGetAlarmCharacteristics1_CStep.h"
       
    39 #include "EASShdOpCodeAlarmDataSize1_CStep.h"
       
    40 #include "EASShdOpCodeGetAlarmCountForCategory1_CStep.h"
       
    41 #include "EASShdOpCodeGetAvailableCategoryList1_CStep.h"
       
    42 #include "EASShdOpCodeGetAlarmIdListForCategory1_CStep.h"
       
    43 #include "EASShdOpCodeAlarmCountByState1_CStep.h"
       
    44 #include "EASShdOpCodeGetAlarmIdListByState1_CStep.h"
       
    45 #include "EASShdOpCodeGetAlarmIdList1_CStep.h"
       
    46 #include "EASShdOpCodeGetNextDueAlarmId1_CStep.h"
       
    47 #include "EASShdOpCodeNumberOfAlarmsActiveInQueue1_CStep.h"
       
    48 #include "EASShdOpCodeGetAlarmSoundState1_CStep.h"
       
    49 #include "EASShdOpCodeGetAlarmSoundsSilentUntil1_CStep.h"
       
    50 #include "SShdOpCodeAlarmSoundsTemporarilySilenced1_CStep.h"
       
    51 #include "EASShdOpCodeGetAlarmPlayIntervals1_CStep.h"
       
    52 #include "EASShdOpCodeNotifyChangeCancel1_CStep.h"
       
    53 #include "EASShdOpCodeFetchTransferBuffer1_CStep.h"
       
    54 #include "EASShdOpCodeAlarmCount1_CStep.h"
       
    55 #include "EASShdOpCodeDbgFailAlloc1_CStep.h"
       
    56 #include "EASShdOpCodeDbgPreventUserNotify1_CStep.h"
       
    57 #include "EASShdOpCodeDbgSnoozeAlarm1_CStep.h"
       
    58 #include "EASShdOpCodeFlushServer1_CStep.h"
       
    59 
       
    60 #include "EASShdOpCodeGetAlarmDetails1_CStep.h"
       
    61 #include "EASShdOpCodeGetAlarmDetails_DifferentSID1_CStep.h"
       
    62 
       
    63 #include "EASShdOpCodeGetAlarmData1_CStep.h"
       
    64 #include "EASShdOpCodeGetAlarmData_DifferentSID1_CStep.h"
       
    65 
       
    66 #include "EASShdOpCodeAlarmAtIndex1_CStep.h"
       
    67 #include "EASShdOpCodeAlarmAtIndex_DifferentSID1_CStep.h"
       
    68 
       
    69 #include "SShdpCdAlarmNotificationCancelAndDeQueue1_CStep.h"
       
    70 #include "SShdpCdAlarmNotificationCancelAndDeQueue_DifferentSID1_CStep.h"
       
    71 
       
    72 #include "EASShdOpCodeAlarmDelete1_CStep.h"
       
    73 #include "EASShdOpCodeAlarmDelete_DifferentSID1_CStep.h"
       
    74 
       
    75 #include "EASShdOpCodeSetAlarmStatus1_CStep.h"
       
    76 #include "EASShdOpCodeSetAlarmStatus_DifferentSID1_CStep.h"
       
    77 
       
    78 #include "EASShdOpCodeSetAlarmDayOrTimed1_CStep.h"
       
    79 #include "EASShdOpCodeSetAlarmDayOrTimed_DifferentSID1_CStep.h"
       
    80 
       
    81 #include "EASShdOpCodeSetAlarmCharacteristics1_CStep.h"
       
    82 #include "EASShdOpCodeSetAlarmCharacteristics_DifferentSID1_CStep.h"
       
    83 
       
    84 #include "EASShdOpCodeSetClientData1_CStep.h"
       
    85 #include "EASShdOpCodeSetClientData_DifferentSID1_CStep.h"
       
    86 
       
    87 #include "EASShdOpCodeAlarmDataAttach1_CStep.h"
       
    88 #include "EASShdOpCodeAlarmDataAttach_DifferentSID1_CStep.h"
       
    89 
       
    90 #include "EASShdOpCodeAlarmDataDetach1_CStep.h"
       
    91 #include "EASShdOpCodeAlarmDataDetach_DifferentSID1_CStep.h"
       
    92 
       
    93 #include "EASShdOpCodeAlarmAddWithNotification1_CStep.h"
       
    94 #include "EASShdOpCodeOrphanAlarm1_CStep.h"
       
    95 #include "EASShdOpCodeAlarmAdd1_CStep.h"
       
    96 #include "EASShdOpCodeSetAlarmSoundState1_CStep.h"
       
    97 #include "EASShdOpCodeSetAlarmSoundsSilentUntil1_CStep.h"
       
    98 #include "EASShdOpCodeSetAlarmSoundsSilentFor1_CStep.h"
       
    99 #include "EASShdOpCodeCancelAlarmSilence1_CStep.h"
       
   100 #include "EASShdOpCodeSetAlarmPlayIntervals1_CStep.h"
       
   101 #include "EASShdOpCodeSetAlarmStatusByCategory1_CStep.h"
       
   102 #include "EASShdOpCodeAlarmDeleteAllByCategory1_CStep.h"
       
   103 #include "EASShdOpCodeAlarmDeleteByCategory1_CStep.h"
       
   104 
       
   105 // __EDIT_ME__ - Substitute the name of your test server 
       
   106 _LIT(KServerName,"Cap_Alarm_sc");
       
   107 // __EDIT_ME__ - Use your own server class name
       
   108 
       
   109 
       
   110 /**
       
   111 Same code for Secure and non-secure variants
       
   112 Called inside the MainL() function to create and start the
       
   113 CTestServer derived server.
       
   114 @return - Instance of the test server
       
   115 */
       
   116 CTestAlarmServer* CTestAlarmServer::NewL()
       
   117 	{
       
   118 	// __EDIT_ME__ - Use your own server class name
       
   119 	CTestAlarmServer* server = new (ELeave) CTestAlarmServer();
       
   120 	CleanupStack::PushL(server);
       
   121 
       
   122 	// CServer base class call
       
   123 	server->StartL(KServerName);
       
   124 	CleanupStack::Pop(server);
       
   125 	return server;
       
   126 	}
       
   127 
       
   128 /**
       
   129 Base class pure virtual override
       
   130 Secure and non-secure variants
       
   131 Implementation of CTestServer pure virtual
       
   132 @return - A CTestStep derived instance
       
   133 */
       
   134 CTestStep* CTestAlarmServer::CreateTestStep(const TDesC& aStepName)
       
   135 	{
       
   136 	 CTestStep* testStep = NULL;
       
   137 	// add test steps
       
   138 		if (aStepName == _L("CEASShdOpCodeNotifyChange1Step"))
       
   139 			{
       
   140 			testStep =  new(ELeave) CEASShdOpCodeNotifyChange1Step; // Method can leave during construction
       
   141 			return testStep;
       
   142 			}
       
   143 			 
       
   144 		if (aStepName == _L("CEASShdOpCodeGetAlarmCategory1Step"))
       
   145 			{
       
   146 			testStep =  new(ELeave) CEASShdOpCodeGetAlarmCategory1Step;
       
   147 			return testStep;
       
   148 			}
       
   149 			 
       
   150 		if (aStepName == _L("CEASShdOpCodeGetAlarmOwner1Step"))
       
   151 			{
       
   152 			testStep =  new(ELeave) CEASShdOpCodeGetAlarmOwner1Step;
       
   153 			return testStep;
       
   154 			}
       
   155 			 
       
   156 		if (aStepName == _L("CEASShdOpCodeGetAlarmStatus1Step"))
       
   157 			{
       
   158 			testStep =  new(ELeave) CEASShdOpCodeGetAlarmStatus1Step;
       
   159 			return testStep;
       
   160 			}
       
   161 			 
       
   162 		if (aStepName == _L("CEASShdOpCodeGetAlarmDayOrTimed1Step"))
       
   163 			{
       
   164 			testStep =  new(ELeave) CEASShdOpCodeGetAlarmDayOrTimed1Step;
       
   165 			return testStep;
       
   166 			}
       
   167 			 
       
   168 		if (aStepName == _L("CEASShdOpCodeGetAlarmCharacteristics1Step"))
       
   169 			{
       
   170 			testStep =  new(ELeave) CEASShdOpCodeGetAlarmCharacteristics1Step;
       
   171 			return testStep;
       
   172 			}
       
   173 			 
       
   174 		if (aStepName == _L("CEASShdOpCodeAlarmDataSize1Step"))
       
   175 			{
       
   176 			testStep =  new(ELeave) CEASShdOpCodeAlarmDataSize1Step;
       
   177 			return testStep;
       
   178 			}
       
   179 			 
       
   180 		if (aStepName == _L("CEASShdOpCodeGetAlarmCountForCategory1Step"))
       
   181 			{
       
   182 			testStep =  new(ELeave) CEASShdOpCodeGetAlarmCountForCategory1Step;
       
   183 			return testStep;
       
   184 			}
       
   185 			 
       
   186 		if (aStepName == _L("CEASShdOpCodeGetAvailableCategoryList1Step"))
       
   187 			{
       
   188 			testStep =  new(ELeave) CEASShdOpCodeGetAvailableCategoryList1Step;
       
   189 			return testStep;
       
   190 			}
       
   191 			 
       
   192 		if (aStepName == _L("CEASShdOpCodeGetAlarmIdListForCategory1Step"))
       
   193 			{
       
   194 			testStep =  new(ELeave) CEASShdOpCodeGetAlarmIdListForCategory1Step;
       
   195 			return testStep;
       
   196 			}
       
   197 			 
       
   198 		if (aStepName == _L("CEASShdOpCodeAlarmCountByState1Step"))
       
   199 			{
       
   200 			testStep =  new(ELeave) CEASShdOpCodeAlarmCountByState1Step;
       
   201 			return testStep;
       
   202 			}
       
   203 			 
       
   204 		if (aStepName == _L("CEASShdOpCodeGetAlarmIdListByState1Step"))
       
   205 			{
       
   206 			testStep =  new(ELeave) CEASShdOpCodeGetAlarmIdListByState1Step;
       
   207 			return testStep;
       
   208 			}
       
   209 			 
       
   210 		if (aStepName == _L("CEASShdOpCodeGetAlarmIdList1Step"))
       
   211 			{
       
   212 			testStep =  new(ELeave) CEASShdOpCodeGetAlarmIdList1Step;
       
   213 			return testStep;
       
   214 			}
       
   215 			 
       
   216 		if (aStepName == _L("CEASShdOpCodeGetNextDueAlarmId1Step"))
       
   217 			{
       
   218 			testStep =  new(ELeave) CEASShdOpCodeGetNextDueAlarmId1Step;
       
   219 			return testStep;
       
   220 			}
       
   221 			 
       
   222 		if (aStepName == _L("CEASShdOpCodeNumberOfAlarmsActiveInQueue1Step"))
       
   223 			{
       
   224 			testStep =  new(ELeave) CEASShdOpCodeNumberOfAlarmsActiveInQueue1Step;
       
   225 			return testStep;
       
   226 			}
       
   227 			 
       
   228 		if (aStepName == _L("CEASShdOpCodeGetAlarmSoundState1Step"))
       
   229 			{
       
   230 			testStep =  new(ELeave) CEASShdOpCodeGetAlarmSoundState1Step;
       
   231 			return testStep;
       
   232 			}
       
   233 			 
       
   234 		if (aStepName == _L("CEASShdOpCodeGetAlarmSoundsSilentUntil1Step"))
       
   235 			{
       
   236 			testStep =  new(ELeave) CEASShdOpCodeGetAlarmSoundsSilentUntil1Step;
       
   237 			return testStep;
       
   238 			}
       
   239 			 
       
   240 		if (aStepName == _L("CSShdOpCodeAlarmSoundsTemporarilySilenced1Step"))
       
   241 			{
       
   242 			testStep =  new(ELeave) CSShdOpCodeAlarmSoundsTemporarilySilenced1Step;
       
   243 			return testStep;
       
   244 			}
       
   245 			 
       
   246 		if (aStepName == _L("CEASShdOpCodeGetAlarmPlayIntervals1Step"))
       
   247 			{
       
   248 			testStep =  new(ELeave) CEASShdOpCodeGetAlarmPlayIntervals1Step;
       
   249 			return testStep;
       
   250 			}
       
   251 			 
       
   252 		if (aStepName == _L("CEASShdOpCodeNotifyChangeCancel1Step"))
       
   253 			{
       
   254 			testStep =  new(ELeave) CEASShdOpCodeNotifyChangeCancel1Step;
       
   255 			return testStep;
       
   256 			}
       
   257 			 
       
   258 		if (aStepName == _L("CEASShdOpCodeFetchTransferBuffer1Step"))
       
   259 			{
       
   260 			testStep =  new(ELeave) CEASShdOpCodeFetchTransferBuffer1Step;
       
   261 			return testStep;
       
   262 			}
       
   263 			 
       
   264 		if (aStepName == _L("CEASShdOpCodeAlarmCount1Step"))
       
   265 			{
       
   266 			testStep =  new(ELeave) CEASShdOpCodeAlarmCount1Step;
       
   267 			return testStep;
       
   268 			}
       
   269 			 
       
   270 		if (aStepName == _L("CEASShdOpCodeDbgFailAlloc1Step"))
       
   271 			{
       
   272 			testStep =  new(ELeave) CEASShdOpCodeDbgFailAlloc1Step;
       
   273 			return testStep;
       
   274 			}
       
   275 			 
       
   276 		if (aStepName == _L("CEASShdOpCodeDbgPreventUserNotify1Step"))
       
   277 			{
       
   278 			testStep =  new(ELeave) CEASShdOpCodeDbgPreventUserNotify1Step;
       
   279 			return testStep;
       
   280 			}
       
   281 			 
       
   282 		if (aStepName == _L("CEASShdOpCodeDbgSnoozeAlarm1Step"))
       
   283 			{
       
   284 			testStep =  new(ELeave) CEASShdOpCodeDbgSnoozeAlarm1Step;
       
   285 			return testStep;
       
   286 			}
       
   287 			 
       
   288 		if (aStepName == _L("CEASShdOpCodeFlushServer1Step"))
       
   289 			{
       
   290 			testStep =  new(ELeave) CEASShdOpCodeFlushServer1Step;
       
   291 			return testStep;
       
   292 			}
       
   293 			 
       
   294 		if (aStepName == _L("CEASShdOpCodeGetAlarmDetails1Step"))
       
   295 			{
       
   296 			testStep =  new(ELeave) CEASShdOpCodeGetAlarmDetails1Step;
       
   297 			return testStep;
       
   298 			}
       
   299 		if (aStepName == _L("CEASShdOpCodeGetAlarmDetails_DifferentSID1Step"))
       
   300 			{
       
   301 			testStep =  new(ELeave) CEASShdOpCodeGetAlarmDetails_DifferentSID1Step;
       
   302 			return testStep;
       
   303 			}	
       
   304 			 
       
   305 		if (aStepName == _L("CEASShdOpCodeGetAlarmData1Step"))
       
   306 			{
       
   307 			testStep =  new(ELeave) CEASShdOpCodeGetAlarmData1Step;
       
   308 			return testStep;
       
   309 			}
       
   310 		if (aStepName == _L("CEASShdOpCodeGetAlarmData_DifferentSID1Step"))
       
   311 			{
       
   312 			testStep =  new(ELeave) CEASShdOpCodeGetAlarmData_DifferentSID1Step;
       
   313 			return testStep;
       
   314 			}	
       
   315 			
       
   316 			 
       
   317 		if (aStepName == _L("CEASShdOpCodeAlarmAtIndex1Step"))
       
   318 			{
       
   319 			testStep =  new(ELeave) CEASShdOpCodeAlarmAtIndex1Step;
       
   320 			return testStep;
       
   321 			}
       
   322 			if (aStepName == _L("CEASShdOpCodeAlarmAtIndex_DifferentSID1Step"))
       
   323 			{
       
   324 			testStep =  new(ELeave) CEASShdOpCodeAlarmAtIndex_DifferentSID1Step;
       
   325 			return testStep;
       
   326 			}
       
   327 			 
       
   328 			 
       
   329 		if (aStepName == _L("CSShdpCdAlarmNotificationCancelAndDeQueue1Step"))
       
   330 			{
       
   331 			testStep =  new(ELeave) CSShdpCdAlarmNotificationCancelAndDeQueue1Step;
       
   332 			return testStep;
       
   333 			}
       
   334 		if (aStepName == _L("CSShdpCdAlarmNotificationCancelAndDeQueue_DifferentSID1Step"))
       
   335 			{
       
   336 			testStep =  new(ELeave) CSShdpCdAlarmNotificationCancelAndDeQueue_DifferentSID1Step;
       
   337 			return testStep;
       
   338 			}
       
   339 			 
       
   340 		if (aStepName == _L("CEASShdOpCodeAlarmDelete1Step"))
       
   341 			{
       
   342 			testStep =  new(ELeave) CEASShdOpCodeAlarmDelete1Step;
       
   343 			return testStep;
       
   344 			}
       
   345 		if (aStepName == _L("CEASShdOpCodeAlarmDelete_DifferentSID1Step"))
       
   346 			{
       
   347 			testStep =  new(ELeave) CEASShdOpCodeAlarmDelete_DifferentSID1Step;
       
   348 			return testStep;
       
   349 			}
       
   350 			 
       
   351 		if (aStepName == _L("CEASShdOpCodeSetAlarmStatus1Step"))
       
   352 			{
       
   353 			testStep =  new(ELeave) CEASShdOpCodeSetAlarmStatus1Step;
       
   354 			return testStep;
       
   355 			}
       
   356 			if (aStepName == _L("CEASShdOpCodeSetAlarmStatus_DifferentSID1Step"))
       
   357 			{
       
   358 			testStep =  new(ELeave) CEASShdOpCodeSetAlarmStatus_DifferentSID1Step;
       
   359 			return testStep;
       
   360 			}
       
   361 			 
       
   362 		if (aStepName == _L("CEASShdOpCodeSetAlarmDayOrTimed1Step"))
       
   363 			{
       
   364 			testStep =  new(ELeave) CEASShdOpCodeSetAlarmDayOrTimed1Step;
       
   365 			return testStep;
       
   366 			}
       
   367 		if (aStepName == _L("CEASShdOpCodeSetAlarmDayOrTimed_DifferentSID1Step"))
       
   368 			{
       
   369 			testStep =  new(ELeave) CEASShdOpCodeSetAlarmDayOrTimed_DifferentSID1Step;
       
   370 			return testStep;
       
   371 			}	
       
   372 			 
       
   373 		if (aStepName == _L("CEASShdOpCodeSetAlarmCharacteristics1Step"))
       
   374 			{
       
   375 			testStep =  new(ELeave) CEASShdOpCodeSetAlarmCharacteristics1Step;
       
   376 			return testStep;
       
   377 			}
       
   378 		if (aStepName == _L("CEASShdOpCodeSetAlarmCharacteristics_DifferentSID1Step"))
       
   379 			{
       
   380 			testStep =  new(ELeave) CEASShdOpCodeSetAlarmCharacteristics_DifferentSID1Step;
       
   381 			return testStep;
       
   382 			}	
       
   383 			 
       
   384 		if (aStepName == _L("CEASShdOpCodeSetClientData1Step"))
       
   385 			{
       
   386 			testStep =  new(ELeave) CEASShdOpCodeSetClientData1Step;
       
   387 			return testStep;
       
   388 			}
       
   389 		if (aStepName == _L("CEASShdOpCodeSetClientData_DifferentSID1Step"))
       
   390 			{
       
   391 			testStep =  new(ELeave) CEASShdOpCodeSetClientData_DifferentSID1Step;
       
   392 			return testStep;
       
   393 			}	
       
   394 			 
       
   395 		if (aStepName == _L("CEASShdOpCodeAlarmDataAttach1Step"))
       
   396 			{
       
   397 			testStep =  new(ELeave) CEASShdOpCodeAlarmDataAttach1Step;
       
   398 			return testStep;
       
   399 			}
       
   400 		if (aStepName == _L("CEASShdOpCodeAlarmDataAttach_DifferentSID1Step"))
       
   401 			{
       
   402 			testStep =  new(ELeave) CEASShdOpCodeAlarmDataAttach_DifferentSID1Step;
       
   403 			return testStep;
       
   404 			}	
       
   405 			 
       
   406 		if (aStepName == _L("CEASShdOpCodeAlarmDataDetach1Step"))
       
   407 			{
       
   408 			testStep =  new(ELeave) CEASShdOpCodeAlarmDataDetach1Step;
       
   409 			return testStep;
       
   410 			}
       
   411 		if (aStepName == _L("CEASShdOpCodeAlarmDataDetach_DifferentSID1Step"))
       
   412 			{
       
   413 			testStep =  new(ELeave) CEASShdOpCodeAlarmDataDetach_DifferentSID1Step;
       
   414 			return testStep;
       
   415 			}	
       
   416 			 
       
   417 		if (aStepName == _L("CEASShdOpCodeAlarmAddWithNotification1Step"))
       
   418 			{
       
   419 			testStep =  new(ELeave) CEASShdOpCodeAlarmAddWithNotification1Step;
       
   420 			return testStep;
       
   421 			}
       
   422 			 
       
   423 		if (aStepName == _L("CEASShdOpCodeOrphanAlarm1Step"))
       
   424 			{
       
   425 			testStep =  new(ELeave) CEASShdOpCodeOrphanAlarm1Step;
       
   426 			return testStep;
       
   427 			}
       
   428 			 
       
   429 		if (aStepName == _L("CEASShdOpCodeAlarmAdd1Step"))
       
   430 			{
       
   431 			testStep =  new(ELeave) CEASShdOpCodeAlarmAdd1Step;
       
   432 			return testStep;
       
   433 			}
       
   434 			 
       
   435 		if (aStepName == _L("CEASShdOpCodeSetAlarmSoundState1Step"))
       
   436 			{
       
   437 			testStep =  new(ELeave) CEASShdOpCodeSetAlarmSoundState1Step;
       
   438 			return testStep;
       
   439 			}
       
   440 			 
       
   441 		if (aStepName == _L("CEASShdOpCodeSetAlarmSoundsSilentUntil1Step"))
       
   442 			{
       
   443 			testStep =  new(ELeave) CEASShdOpCodeSetAlarmSoundsSilentUntil1Step;
       
   444 			return testStep;
       
   445 			}
       
   446 			 
       
   447 		if (aStepName == _L("CEASShdOpCodeSetAlarmSoundsSilentFor1Step"))
       
   448 			{
       
   449 			testStep =  new(ELeave) CEASShdOpCodeSetAlarmSoundsSilentFor1Step;
       
   450 			return testStep;
       
   451 			}
       
   452 			 
       
   453 		if (aStepName == _L("CEASShdOpCodeCancelAlarmSilence1Step"))
       
   454 			{
       
   455 			testStep =  new(ELeave) CEASShdOpCodeCancelAlarmSilence1Step;
       
   456 			return testStep;
       
   457 			}
       
   458 			 
       
   459 		if (aStepName == _L("CEASShdOpCodeSetAlarmPlayIntervals1Step"))
       
   460 			{
       
   461 			testStep =  new(ELeave) CEASShdOpCodeSetAlarmPlayIntervals1Step;
       
   462 			return testStep;
       
   463 			}
       
   464 			 
       
   465 		if (aStepName == _L("CEASShdOpCodeSetAlarmStatusByCategory1Step"))
       
   466 			{
       
   467 			testStep =  new(ELeave) CEASShdOpCodeSetAlarmStatusByCategory1Step;
       
   468 			return testStep;
       
   469 			}
       
   470 			 
       
   471 		if (aStepName == _L("CEASShdOpCodeAlarmDeleteAllByCategory1Step"))
       
   472 			{
       
   473 			testStep =  new(ELeave) CEASShdOpCodeAlarmDeleteAllByCategory1Step;
       
   474 			return testStep;
       
   475 			}
       
   476 			 
       
   477 		if (aStepName == _L("CEASShdOpCodeAlarmDeleteByCategory1Step"))
       
   478 			{
       
   479 			testStep =  new(ELeave) CEASShdOpCodeAlarmDeleteByCategory1Step;
       
   480 			return testStep;
       
   481 			}
       
   482 			 
       
   483 		return testStep;
       
   484 	 }
       
   485 	
       
   486 /**
       
   487 Secure variant. Just an E32Main and a MainL()
       
   488 Much simpler, uses the new Rendezvous() call to sync with the client
       
   489 */
       
   490 LOCAL_C void MainL()
       
   491 	{
       
   492 #if (defined __DATA_CAGING__)
       
   493 	RProcess().DataCaging(RProcess::EDataCagingOn);
       
   494 	RProcess().DataCaging(RProcess::ESecureApiOn);
       
   495 #endif
       
   496 	CActiveScheduler* sched = NULL;
       
   497 	sched=new(ELeave) CActiveScheduler;
       
   498 	CActiveScheduler::Install(sched);
       
   499 	
       
   500 	// __EDIT_ME__ - Use your own server class name
       
   501 	CTestAlarmServer* server = NULL;
       
   502 	
       
   503 	// Create the CTestServer derived server
       
   504 	TRAPD(err,server = CTestAlarmServer::NewL());
       
   505 	if(!err)
       
   506 		{
       
   507 		// Sync with the client and enter the active scheduler
       
   508 		RProcess::Rendezvous(KErrNone);
       
   509 		sched->Start();
       
   510 		}
       
   511 	delete server;
       
   512 	delete sched;
       
   513 	}
       
   514 
       
   515 /**
       
   516 Secure variant only
       
   517 Process entry point. Called by client using RProcess API
       
   518 @return - Standard Epoc error code on process exit
       
   519 */
       
   520 GLDEF_C TInt E32Main()
       
   521 	{
       
   522 	__UHEAP_MARK;
       
   523 	CTrapCleanup* cleanup = CTrapCleanup::New();
       
   524 	if(cleanup == NULL)
       
   525 		{
       
   526 		return KErrNoMemory;
       
   527 		}
       
   528 	TRAPD(err,MainL());
       
   529 	UNUSED_VAR(err); //Used to supress build warnings
       
   530 	
       
   531 	delete cleanup;
       
   532 	__UHEAP_MARKEND;
       
   533 	return KErrNone;
       
   534     }
       
   535 /**
       
   536 Gets the id of the alarm in the Alarm Server
       
   537 */    
       
   538 TAlarmId CCapabilityTestStep::GetAlarmId()
       
   539 	{
       
   540 	// Connect to Alarm Server
       
   541 	RASCliSession alarmServerSession = RASCliSession();
       
   542 	TInt con = alarmServerSession.Connect();
       
   543 	if(con != KErrNone)
       
   544 		{
       
   545 		return con;
       
   546 		}
       
   547 	
       
   548 	// Get list of alarm id. There should be only one alarm
       
   549 	RArray<TAlarmId> alarmIds;
       
   550 	TInt err = KErrNone;	
       
   551 	TRAP(err, alarmServerSession.GetAlarmIdListL(alarmIds));
       
   552 			
       
   553 	TAlarmId alarmId;
       
   554 	
       
   555 	if(err != KErrNone)
       
   556 		{
       
   557 		alarmId = err;
       
   558 		}
       
   559 	else if(alarmIds.Count() == 0)
       
   560 		{
       
   561 		// after all alarms have been deleted , the count is 0.
       
   562 		// needed as this will help testing with correct capability
       
   563 		// where there is no SID checking.
       
   564 		alarmId = 0;
       
   565 		}
       
   566 	else
       
   567 		{
       
   568 		// return the first element in array.
       
   569 		alarmId = alarmIds[0];
       
   570 		}
       
   571 	alarmIds.Reset();
       
   572 	return alarmId;		
       
   573 	}
       
   574 
       
   575 TVerdict CCapabilityTestStep::doTestStepPreambleL( void )
       
   576 	{
       
   577 	// If Preamble is not required just pass a success value
       
   578 	TVerdict testResult = CTestStep::doTestStepPreambleL();
       
   579 	return TestStepResult();
       
   580 	}
       
   581 
       
   582 TVerdict CCapabilityTestStep::doTestStepPostambleL( void )
       
   583 	{
       
   584 	// If Postamble is not required just pass a success value
       
   585 	TVerdict testResult = CTestStep::doTestStepPostambleL();
       
   586 	return TestStepResult();
       
   587 	}
       
   588 
       
   589 enum TVerdict CCapabilityTestStep::doTestStepL()
       
   590 	{
       
   591 	// DEF! INFO_PRINTF2(_L("%S - Starting ..."), &iTestStepName);
       
   592 	// The MainThread()creates a separate thread that executes SendReceive
       
   593 	TVerdict vResult = MainThread();
       
   594 	SetTestStepResult(vResult);
       
   595 	return TestStepResult();
       
   596 	}
       
   597 
       
   598 /**
       
   599 ThreadStartFn:
       
   600 Called by:	The Child thread
       
   601 Function:	Calls the Exec_SendReceiveL
       
   602 */
       
   603 static TInt ThreadStartFn(TAny* aPtr)
       
   604 	{
       
   605 	__UHEAP_MARK;
       
   606 	CTrapCleanup* cleanup = CTrapCleanup::New();
       
   607 	TInt retVal;
       
   608 	TRAP(retVal, ((CCapabilityTestStep *)aPtr)->Exec_SendReceiveL());
       
   609 	delete cleanup;
       
   610 	__UHEAP_MARKEND;
       
   611 	return retVal;
       
   612 	}
       
   613 
       
   614 /**
       
   615 TVerdict GetVerdict(TInt aApiRetValue)
       
   616 Called by: "MainThread" for returning verdict
       
   617 Parameters(TInt aRetValue) :	0 if API call gets thru without any rejection
       
   618 								1 if API call is rejected for capability error	
       
   619 */
       
   620 enum TVerdict CCapabilityTestStep::GetVerdict(TInt aApiRetValue)
       
   621 	{
       
   622 	TVerdict vVerdict[] = {EPass, EFail};
       
   623 
       
   624 	// please leave the following if/else block as the information printed by INFO_PRINTF1
       
   625 	// is used by CapTestSumm
       
   626 	if(iExpectRejection) //[Inverse Test] EPass for 1 while EFail for 0
       
   627 		{
       
   628 		INFO_PRINTF1(_L("Test Expected to Fail due to lack of capabilities"));
       
   629 		return vVerdict[(aApiRetValue)?0:1];
       
   630 		
       
   631 		}
       
   632 	else //[Direct Test] EPass for 0 while EFail for 1
       
   633 		{
       
   634 		INFO_PRINTF1(_L("Test Expected to Pass with correct capabilities"));
       
   635 		return vVerdict[(aApiRetValue)?1:0];
       
   636 		}
       
   637 	}
       
   638 
       
   639 
       
   640 /**
       
   641 TVerdict MainThread()
       
   642 
       
   643 Called by: "doTestStepL"
       
   644 
       
   645 Purpose:	Creates the child thread(which calls the respective function with regard
       
   646 			to the server and also implements the Message Call). Then this fn.waits for the
       
   647 			completion of the childthread( doesnt matter how the thread did die!)
       
   648 
       
   649 Return Value(Verdict of the TestStep):
       
   650 
       
   651 			A.Reporting PASS/FAIL
       
   652 				Direct Test:
       
   653 						When a message call gets thru. Please note that in such cases
       
   654 						actually the implementation of the message has started. As we
       
   655 						are passing "0" Parameters, server may panic, though our botheration
       
   656 						stops once the call gets thru.
       
   657 						NOTE:	The style is the same when CONNECTION capabilities
       
   658 								are tested, the only diff is you dont have to expect a 
       
   659 								panic from server
       
   660 				Inverse Test:
       
   661 						The call should be either failed or panicked with
       
   662 						"KErrPermissionDenied" flag. 
       
   663 
       
   664 				General Case:
       
   665 						If a thread creation failed or if the server couldnt be connected
       
   666 						apart from the above two cases, then a FAIL is reported
       
   667 			
       
   668 			B.Reporting INCONCLUSIVE
       
   669 						Any panic say from unexpected source (eg:KERN-EXEC) will be
       
   670 						reported INCONCLUSIVE														
       
   671 */
       
   672 TVerdict CCapabilityTestStep::MainThread()
       
   673 	{
       
   674 	TBuf<100>	tExitCategory;
       
   675 	TInt		tExitReason = 0;		
       
   676 	TBuf<100>	tTestStyle;
       
   677 
       
   678 	iExpectRejection?tTestStyle = _L("Inverse"):tTestStyle = _L("Direct");
       
   679 	TCapabilitySet tCaps =  TSecurityInfo(RProcess()).iCaps ;
       
   680 	const TInt KMaxTestThreadHeapSize = 0x10000;
       
   681 
       
   682 	// Initialize return values
       
   683 	iResultSr		= KErrNone;
       
   684 	iResultServer	= KErrNone;	
       
   685 		
       
   686 
       
   687 	// Create a child thread, with a new heap
       
   688 	TInt resThread =	iChildThread.Create(
       
   689 						iSrChildThread,
       
   690 						ThreadStartFn,
       
   691 						KDefaultStackSize,
       
   692 						KMinHeapSize,
       
   693 						KMaxTestThreadHeapSize,
       
   694 						this,			
       
   695 						EOwnerProcess);
       
   696 
       
   697 
       
   698 	if(resThread == KErrNone) //Thread Created
       
   699 		{
       
   700 		// To when the thread is dead
       
   701 		TRequestStatus tThreadStatus;
       
   702 		iChildThread.Logon(tThreadStatus);
       
   703 		iChildThread.Resume(); 
       
   704 		
       
   705 		// Is the thread dead?
       
   706 		User::WaitForRequest(tThreadStatus);
       
   707 		
       
   708 		// Yes, The thread is dead. Now the Killer's profile
       
   709 		tExitCategory	=	iChildThread.ExitCategory();
       
   710 		tExitReason		=	iChildThread.ExitReason();
       
   711 		
       
   712 		// Somebody Please say what are we testing!!		
       
   713 		if(iSessionCreated && (iSrMessageId >=0)) //Flag set by Child thread when connected to Server
       
   714 			{
       
   715 			// DEF INFO_PRINTF5(_L("Connected to Server(%S) for %S Test [MessageID: %d,Req.Cap: 0x%x,Present.Cap: 0x%x]"),&iSrServerName,&tTestStyle,iSrMessageId,iStepCap,TSecurityInfo(RProcess()));			
       
   716 			}
       
   717 		else if(iSrMessageId < 0)
       
   718 			{
       
   719 			// DEF INFO_PRINTF5(_L("Testing Connection capabilities[%S Test] for Server(%S) [Req.Cap: 0x%x,Present.Cap: 0x%x]"),&tTestStyle,
       
   720 			// &iSrServerName,TSecurityInfo(RProcess()));			
       
   721 			}
       
   722 		else if(!iSessionCreated)// NO Connection
       
   723 			{
       
   724 			INFO_PRINTF4(	_L("Couldnt connect to the Server(%S) ErrorCode - ServerRet: %d C32ret: %d"),
       
   725 							&iSrServerName,iResultServer,iResultC32
       
   726 						);
       
   727 			// INFO_PRINTF3(_L("Child Thread: ExitCategory : %S ExitReason : %d"),&tExitCategory,tExitReason);
       
   728   			return EFail;
       
   729  			}
       
   730 
       
   731 		switch(iChildThread.ExitType())
       
   732 			{			
       
   733 			case EExitPanic:
       
   734 				// 1.A Panic from the connected Server 
       
   735 				// 2.A CServer Panic normally for capability rejection
       
   736 				// 3.A kernel Panic (consider yourself doomed!)
       
   737 				if((tExitReason == KErrPermissionDenied) ||
       
   738 					// DEF ? it's old version (tExitReason == CServer::EClientDoesntHaveRequiredCaps))
       
   739 					// Rejected for Insufficient Cap.
       
   740 					// is it correct ?
       
   741 					(tExitReason == CServer2::EClientDoesntHaveRequiredCaps))// Rejected for Insufficient Cap.
       
   742 					{
       
   743 					INFO_PRINTF2(_L("Rejected for insufficient capabilities [Return Value : %d] "),tExitReason);
       
   744 					return(GetVerdict(API_RETVALUE_PERMISSIONDENIED));
       
   745 					}
       
   746 				else if(tExitCategory == iServerPanic) //Panic from Server
       
   747 					{
       
   748 					INFO_PRINTF2(_L("Server(%S) Panic to child thread"),&tExitCategory);	
       
   749 					INFO_PRINTF3(_L("Child Thread: ExitCategory : %S ExitReason : %d"),&tExitCategory,tExitReason);			
       
   750 					return(GetVerdict(API_RETVALUE_SERVERPANIC));
       
   751 					}
       
   752 				else//A kernel Panic possibly
       
   753 					{
       
   754 					INFO_PRINTF3(	_L("Child Thread: Panic from unexpected source (ExitCategory: %S ExitReason : %d)!"),
       
   755 									&tExitCategory,tExitReason
       
   756 								);
       
   757 					return EInconclusive;
       
   758 					}
       
   759 			case EExitKill:
       
   760 				if(iResultSr != KErrPermissionDenied)
       
   761 					{
       
   762 					INFO_PRINTF2(
       
   763 									_L("A Successfull call (Return Value : %d)"),
       
   764 									((iSrMessageId >=0)?iResultSr:iResultServer)
       
   765 								);
       
   766 					return(GetVerdict(API_RETVALUE_NOCAPERROR));
       
   767 					}
       
   768 				else 
       
   769 					{
       
   770 					INFO_PRINTF2(
       
   771 									_L("Rejected for insufficient capabilities [Return Value : %d] "),
       
   772 									((iSrMessageId >=0)?iResultSr:iResultServer)
       
   773 								);
       
   774 					return(GetVerdict(API_RETVALUE_PERMISSIONDENIED));			
       
   775 					}
       
   776 			default:					
       
   777 					break;
       
   778 			}
       
   779 		}			
       
   780 	else //Our thread couldnt start
       
   781 		{
       
   782 		INFO_PRINTF2(_L("ERROR: Failed to create Child thread,  ErrorCode:(%d)"),resThread);
       
   783 		return EFail;
       
   784 		}
       
   785 	return EInconclusive;
       
   786 	}
       
   787 
       
   788 /** 
       
   789 Starts the alarm server.
       
   790 @return KErrNone if successful, KErrAlreadyExists if the server is already 
       
   791 running, otherwise a system-wide error.
       
   792 */
       
   793 TInt CCapabilityTestStep::StartServer()
       
   794 	{
       
   795 	return AlarmClientUtils::StartAlarmServer();
       
   796 	}
       
   797 
       
   798 	
       
   799 TInt CCapabilityTestStep::TestDebugHeap(TInt* aDbgIPCNo)
       
   800  	{
       
   801   	// TDbgFns  {MarkHeapStart, MarkHeapEnd, CheckHeap, FailNext, ResetFailNext};
       
   802  	TInt aFnToTest= aDbgIPCNo[5];
       
   803  	
       
   804  	TInt resultSr [6] ={0};
       
   805  	TInt index = 1;
       
   806  	TInt testedFn = 0;
       
   807  
       
   808  	TInt dbgTestSequence[5][6]	=	{	{MarkHeapStart	,2,0,1,-1,-1}, 
       
   809  										{MarkHeapEnd	,2,0,1,-1,-1},
       
   810  										{CheckHeap		,3,0,2, 1,-1},
       
   811  										{FailNext		,4,0,3, 4, 1},
       
   812  										{ResetFailNext	,4,0,3, 4, 1}
       
   813  										
       
   814  									};
       
   815  
       
   816  	
       
   817  	TInt aCount = dbgTestSequence[aFnToTest][index];
       
   818  
       
   819  	while(aCount--  )
       
   820  		{
       
   821  		testedFn =  dbgTestSequence[aFnToTest][(++index)];
       
   822 		resultSr[testedFn ]= SendReceive( aDbgIPCNo[testedFn],TIpcArgs(((aDbgIPCNo[testedFn]==3 )?4:0),0,0,0));
       
   823  		
       
   824  		if( ((testedFn !=aFnToTest)?resultSr[testedFn]:KErrNone) == KErrPermissionDenied) 			
       
   825 			{
       
   826 			User::Panic(_L("Failed at Initialization"),resultSr[testedFn]);		
       
   827 			}
       
   828 		}
       
   829 	return resultSr[aFnToTest];
       
   830 	}
       
   831 	
       
   832