719
|
1 |
// Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
|
|
2 |
// All rights reserved.
|
|
3 |
// This component and the accompanying materials are made available
|
872
|
4 |
// under the terms of the License "Eclipse Public License v1.0"
|
719
|
5 |
// which accompanies this distribution, and is available
|
872
|
6 |
// at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
719
|
7 |
//
|
|
8 |
// Initial Contributors:
|
|
9 |
// Nokia Corporation - initial contribution.
|
|
10 |
//
|
|
11 |
// Contributors:
|
|
12 |
//
|
|
13 |
// Description:
|
|
14 |
// @file
|
|
15 |
// [TestStep Name]
|
|
16 |
// StartRamUsageTimer
|
|
17 |
// [Paramaters]
|
|
18 |
// IntervalTimeInMicroSecs <input> : The interval between events generated
|
|
19 |
// after the initial delay, in microseconds
|
|
20 |
// Starts periodical measurement of RAM memory used and updates the information kept
|
|
21 |
// in SMTP testserver.
|
|
22 |
// [APIs Used]
|
|
23 |
//
|
|
24 |
//
|
|
25 |
|
|
26 |
|
|
27 |
|
|
28 |
// User includes
|
|
29 |
#include "T_StartRamUsageTimer.h"
|
|
30 |
#include "T_MsgSharedDataSmtp.h"
|
|
31 |
|
|
32 |
// Epoc includes
|
|
33 |
#include <hal.h>
|
|
34 |
#include <hal_data.h>
|
|
35 |
|
|
36 |
// Literals used
|
|
37 |
_LIT(KIntervalTimeInMicroSecs, "IntervalTimeInMicroSecs");
|
|
38 |
|
|
39 |
/**
|
|
40 |
Function : CT_StartRamUsageTimer
|
|
41 |
Description : Constructor
|
|
42 |
@return : none
|
|
43 |
*/
|
|
44 |
CT_StartRamUsageTimer::CT_StartRamUsageTimer(CT_MsgSharedDataSmtp& aSharedDataSMTP)
|
|
45 |
:CT_MsgAsyncStepSMTP(aSharedDataSMTP)
|
|
46 |
{
|
|
47 |
SetTestStepName(KStartRamUsageTimer);
|
|
48 |
}
|
|
49 |
|
|
50 |
/**
|
|
51 |
Function : ~CT_StartRamUsageTimer
|
|
52 |
Description : Destructor
|
|
53 |
@return : N/A
|
|
54 |
*/
|
|
55 |
CT_StartRamUsageTimer::~CT_StartRamUsageTimer()
|
|
56 |
{}
|
|
57 |
|
|
58 |
|
|
59 |
/**
|
|
60 |
Function : doTestStepL
|
|
61 |
Description : Generate a periodic Timer event and handle the RAM usage callback function
|
|
62 |
@return : TVerdict Test result
|
|
63 |
*/
|
|
64 |
TVerdict CT_StartRamUsageTimer::doTestStepL()
|
|
65 |
{
|
|
66 |
INFO_PRINTF1(_L("TestStep :StartRamUsageTimer"));
|
|
67 |
TInt intervalTime = 0;
|
|
68 |
if(!GetIntFromConfig(ConfigSection(),KIntervalTimeInMicroSecs,intervalTime))
|
|
69 |
{
|
|
70 |
ERR_PRINTF1(_L("Interval time is not specified"));
|
|
71 |
SetTestStepResult(EFail);
|
|
72 |
}
|
|
73 |
else
|
|
74 |
{
|
|
75 |
iSharedDataSMTP.iPeriodic->Start(intervalTime, intervalTime, TCallBack(RamUsage,this));
|
|
76 |
}
|
|
77 |
return TestStepResult();
|
|
78 |
}
|
|
79 |
|
|
80 |
/**
|
|
81 |
Function : RamUsage
|
|
82 |
Description : Call non-static method DoRamUsage
|
|
83 |
@return : TInt
|
|
84 |
*/
|
|
85 |
TInt CT_StartRamUsageTimer::RamUsage(TAny* aObject)
|
|
86 |
{
|
|
87 |
// Cast, and call non-static function
|
|
88 |
((CT_StartRamUsageTimer *)aObject)->DoRamUsage();
|
|
89 |
return 1;
|
|
90 |
}
|
|
91 |
|
|
92 |
/**
|
|
93 |
Function : DoRamUsage
|
|
94 |
Description : Calculate the RAM usage value and percentage at a particular instance
|
|
95 |
@return : void
|
|
96 |
*/
|
|
97 |
void CT_StartRamUsageTimer::DoRamUsage()
|
|
98 |
{
|
|
99 |
|
|
100 |
TInt fullRamValue;
|
|
101 |
TInt ramFreeValue;
|
|
102 |
|
|
103 |
HAL data;
|
|
104 |
HALData haldata;
|
|
105 |
|
|
106 |
data.Get(haldata.EMemoryRAM, fullRamValue);
|
|
107 |
data.Get(haldata.EMemoryRAMFree, ramFreeValue);
|
|
108 |
|
|
109 |
TInt ramUsage = ((fullRamValue - ramFreeValue)/(1024));
|
|
110 |
|
|
111 |
if ( iSharedDataSMTP.iMark != EFalse )
|
|
112 |
{
|
|
113 |
iSharedDataSMTP.iStartRamValue = ramUsage;
|
|
114 |
iSharedDataSMTP.iMinRamValue = ramUsage;
|
|
115 |
iSharedDataSMTP.iMaxRamValue = ramUsage;
|
|
116 |
iSharedDataSMTP.iMark = EFalse;
|
|
117 |
}
|
|
118 |
|
|
119 |
if ( iSharedDataSMTP.iMinRamValue > ramUsage )
|
|
120 |
{
|
|
121 |
iSharedDataSMTP.iMinRamValue = ramUsage;
|
|
122 |
}
|
|
123 |
|
|
124 |
if ( iSharedDataSMTP.iMaxRamValue < ramUsage )
|
|
125 |
{
|
|
126 |
iSharedDataSMTP.iMaxRamValue = ramUsage;
|
|
127 |
}
|
|
128 |
|
|
129 |
iSharedDataSMTP.iEndRamValue = ramUsage;
|
|
130 |
}
|
|
131 |
|
|
132 |
|
|
133 |
|
|
134 |
/**
|
|
135 |
Function : ProgressL
|
|
136 |
Description : Displays the progress information of the asynchronous operation
|
|
137 |
@return : void
|
|
138 |
*/
|
|
139 |
void CT_StartRamUsageTimer::ProgressL(TBool /*aFinal*/)
|
|
140 |
{}
|
|
141 |
|
|
142 |
/**
|
|
143 |
Function : CancelStep
|
|
144 |
Description : Cancels the asynchronous operation
|
|
145 |
@return : void
|
|
146 |
*/
|
|
147 |
void CT_StartRamUsageTimer::CancelStep()
|
|
148 |
{}
|