commonappservices/alarmservertest/TestMultipleAlarmsSuite/src/TestPerformanceStep.cpp
changeset 0 2e3d3ce01487
equal deleted inserted replaced
-1:000000000000 0:2e3d3ce01487
       
     1 // Copyright (c) 2005-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 // Contains implementation of CTestPerformanceStep class
       
    15 // 
       
    16 //
       
    17 
       
    18 /**
       
    19  @file
       
    20  @internalTechnology 
       
    21 */
       
    22 
       
    23 // User Include
       
    24 #include "TestPerformanceStep.h"
       
    25 
       
    26 // System Include
       
    27 #include <calalarm.h>
       
    28 
       
    29 // Initializes to current time
       
    30 #define NOW(time) TTime time; time.HomeTime();
       
    31 
       
    32 /**
       
    33 Constructor. Sets the test step name. Testserver reference passed to make use 
       
    34 of TEF's method of sharing data between test steps
       
    35 @internalTechnology
       
    36 @test
       
    37 */
       
    38 CTestPerformanceStep::CTestPerformanceStep(CTestMultipleAlarmsServer& aTestServer) 
       
    39 : CTestAssociatedDataStep(aTestServer)
       
    40 	{
       
    41 	//Call base class method to set human readable name for test step
       
    42 	SetTestStepName(KTestPerformanceStep);
       
    43 	}
       
    44 
       
    45 /**
       
    46 Base class pure virtual.
       
    47 @return		EPass or EFail indicating the result of the test step.
       
    48 @internalTechnology
       
    49 @test
       
    50 */
       
    51 TVerdict CTestPerformanceStep::doTestStepL()
       
    52 	{
       
    53 	TPtrC dataReadTime;
       
    54 	TPtrC notificationTime;
       
    55 	if(!ReadStringsFromConfig(ConfigSection(), &KIniDataReadTime(), &dataReadTime, 
       
    56 										       &KIniNotificationTime(), &notificationTime, NULL))
       
    57 		{
       
    58 		IniProblem();
       
    59 		}
       
    60 	else
       
    61 		{
       
    62 		TRAPD(error, TestPerformanceL(GetTReal32(dataReadTime), GetTReal32(notificationTime)));
       
    63 		PrintIfError(error);
       
    64 		}	
       
    65 	return TestStepResult();	
       
    66 	}
       
    67 
       
    68 /**
       
    69 For all the alarm control object which the alarm controls manager holds,
       
    70 tests the associated data retreival performance, and the alert-server
       
    71 notification performance
       
    72 @param aDataReadTime Maximum time allowed to read the associated data
       
    73 @param aNotificationTime Maximum time allowed for alarm control object to 
       
    74 get notified of an alarm after it expires
       
    75 @internalTechnology
       
    76 @test
       
    77 */	
       
    78 void CTestPerformanceStep::TestPerformanceL(const TReal32& aDataReadTime, const TReal32& aNotificationTime)
       
    79 	{
       
    80 	RPointerArray<MEikServAlarm> alarmControlList = TestServer()->AlarmControlsManager()->GetAlarmControlListL();
       
    81 	for(TInt index = 0; index < alarmControlList.Count(); ++index)
       
    82 		{
       
    83 		CDummyAlarmControl* alarmControl = dynamic_cast<CDummyAlarmControl*>(alarmControlList[index]);
       
    84 		
       
    85 		INFO_PRINTF2(_L("Testing Associated Data Performance for %S"), &(alarmControl->AlarmMessage()));
       
    86 		TestAssociatedDataPerformanceL(alarmControl,aDataReadTime);
       
    87 		
       
    88 		INFO_PRINTF2(_L("Testing Notification Time Performance for %S"), &(alarmControl->AlarmMessage()));
       
    89 		TestAlarmNotificationPerformanceL(alarmControl, aNotificationTime);
       
    90 		}
       
    91 	}
       
    92 
       
    93 /**
       
    94 Tests the time difference in original expiry time of alarm and the actual 
       
    95 notification time.
       
    96 @param alarmControl The alarm control object
       
    97 @param aNotificationTime Maximum time allowed for alarm control object to 
       
    98 get notified of an alarm after it expires
       
    99 @internalTechnology
       
   100 @test
       
   101 */	
       
   102 void CTestPerformanceStep::TestAlarmNotificationPerformanceL(CDummyAlarmControl* aAlarmControl, const TReal32& aNotificationTime)
       
   103 	{
       
   104 	CheckTimeDifference(aAlarmControl->OriginalExpiryTime(), aAlarmControl->ActualNotificationTime(), aNotificationTime);
       
   105 	}
       
   106 
       
   107 /**
       
   108 Tests the time taken for reading associated data of an alarm
       
   109 @param alarmControl The alarm control object
       
   110 @param aDataReadTime Maximum time allowed to read the associated data
       
   111 @internalTechnology
       
   112 @test
       
   113 */	
       
   114 void CTestPerformanceStep::TestAssociatedDataPerformanceL(CDummyAlarmControl* aAlarmControl, const TReal32& aDataReadTime)
       
   115 	{
       
   116 	CCalEntryId* entryId = NULL;
       
   117 	if(!GetEntryIdL(aAlarmControl->AlarmMessage(), entryId))
       
   118 		{
       
   119 		ERR_PRINTF2(_L("No associated data attached with the alarm %S"), &(aAlarmControl->AlarmMessage()));
       
   120 		}
       
   121 	else
       
   122 		{
       
   123 		CCalEntry* calEntry = NULL;
       
   124 		CleanupStack::PushL(entryId);
       
   125 		
       
   126 		CCalSession* calSession = CreateAndInitializeCalSessionL(EFalse);
       
   127 		CleanupStack::PushL(calSession);
       
   128 		
       
   129 		if(!GetCalEntryL(entryId, calEntry, calSession))
       
   130 			{
       
   131 			ERR_PRINTF2(_L("The calendar entry was not found for %S. Failing the test..."), &(aAlarmControl->AlarmMessage()));
       
   132 			SetTestStepResult(EFail);
       
   133 			}
       
   134 		else
       
   135 			{
       
   136 			CleanupStack::PushL(calEntry);
       
   137 			
       
   138 			// Time the operation and perform the operation
       
   139 			NOW(startTime)
       
   140 			CCalAlarm* alarm = calEntry->AlarmL();
       
   141 			NOW(endTime)
       
   142 			
       
   143 			delete alarm; 
       
   144 			
       
   145 			// Check
       
   146 			CheckTimeDifference(startTime, endTime, aDataReadTime);
       
   147 				
       
   148 			CleanupStack::PopAndDestroy(calEntry);	
       
   149 			}
       
   150 		CleanupStack::PopAndDestroy(2, entryId); // calSession and entryId
       
   151 		}
       
   152 		
       
   153 	}
       
   154