5
|
1 |
/*
|
|
2 |
* Copyright (c) 2002 Nokia Corporation and/or its subsidiary(-ies).
|
|
3 |
* All rights reserved.
|
|
4 |
* This component and the accompanying materials are made available
|
|
5 |
* under the terms of the License "Eclipse Public License v1.0"
|
|
6 |
* which accompanies this distribution, and is available
|
|
7 |
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
|
8 |
*
|
|
9 |
* Initial Contributors:
|
|
10 |
* Nokia Corporation - initial contribution.
|
|
11 |
*
|
|
12 |
* Contributors:
|
|
13 |
*
|
|
14 |
* Description: ?Description
|
|
15 |
*
|
|
16 |
*/
|
|
17 |
|
|
18 |
|
|
19 |
#include <e32svr.h>
|
|
20 |
#include <StifParser.h>
|
|
21 |
#include <Stiftestinterface.h>
|
|
22 |
#include <e32base.h>
|
|
23 |
//#include <stdio.h>
|
|
24 |
|
|
25 |
// INCLUDE FILES
|
|
26 |
#include "sensrservicetest.h"
|
|
27 |
#include "sensrdatacallback.h"
|
|
28 |
|
|
29 |
_LIT(KLogChannelNotFound,"Channel not found - %d\n");
|
|
30 |
_LIT(KLogFindChannelFail,"Find channel failed for %d channel with %d error\n");
|
|
31 |
_LIT(KLogChannelFound,"Find channel passed with %d channel having %d channels\n");
|
|
32 |
|
|
33 |
// ============================ MEMBER FUNCTIONS ===============================
|
|
34 |
|
|
35 |
// -----------------------------------------------------------------------------
|
|
36 |
// CSensrServiceTest::Delete
|
|
37 |
// Delete here all resources allocated and opened from test methods.
|
|
38 |
// Called from destructor.
|
|
39 |
// -----------------------------------------------------------------------------
|
|
40 |
//
|
|
41 |
void CSensrServiceTest::Delete()
|
|
42 |
{
|
|
43 |
|
|
44 |
}
|
|
45 |
|
|
46 |
// -----------------------------------------------------------------------------
|
|
47 |
// CSensrServiceTest::RunMethodL
|
|
48 |
// Run specified method. Contains also table of test mothods and their names.
|
|
49 |
// -----------------------------------------------------------------------------
|
|
50 |
//
|
|
51 |
TInt CSensrServiceTest::RunMethodL(
|
|
52 |
CStifItemParser& aItem )
|
|
53 |
{
|
|
54 |
|
|
55 |
static TStifFunctionInfo const KFunctions[] =
|
|
56 |
{
|
|
57 |
// Copy this line for every implemented function.
|
|
58 |
// First string is the function name used in TestScripter script file.
|
|
59 |
// Second is the actual implementation member function.
|
|
60 |
ENTRY( "TestFindChannels",CSensrServiceTest::TestFindSensrChannel ),
|
|
61 |
ENTRY( "TestListenData",CSensrServiceTest::TestListenData ),
|
|
62 |
ENTRY( "TestGetProperty",CSensrServiceTest::TestGetProperty ),
|
|
63 |
};
|
|
64 |
|
|
65 |
const TInt count = sizeof( KFunctions ) /
|
|
66 |
sizeof( TStifFunctionInfo );
|
|
67 |
|
|
68 |
return RunInternalL( KFunctions, count, aItem );
|
|
69 |
|
|
70 |
}
|
|
71 |
|
|
72 |
TInt CSensrServiceTest::TestFindSensrChannel( CStifItemParser& aItem )
|
|
73 |
{
|
|
74 |
__UHEAP_MARK;
|
|
75 |
CSensorService* sensrChannel = CSensorService::NewL();
|
|
76 |
RSensrvChannelInfoList channelInfoList;
|
|
77 |
TInt channel;
|
|
78 |
aItem.GetNextInt(channel);
|
|
79 |
|
|
80 |
TRAPD(leavecode,(sensrChannel->FindSensorChannelsL(channel ,channelInfoList)));
|
|
81 |
|
|
82 |
//TInt error = sensrChannel->FindSensorChannelsL(channel ,channelInfoList);
|
|
83 |
|
|
84 |
if(leavecode == KErrNotFound)
|
|
85 |
{
|
|
86 |
iLog->Log(KLogChannelNotFound,channel);
|
|
87 |
leavecode = KErrNone;
|
|
88 |
}
|
|
89 |
else if(leavecode)
|
|
90 |
{
|
|
91 |
iLog->Log(KLogFindChannelFail,channel,leavecode);
|
|
92 |
}
|
|
93 |
else
|
|
94 |
{
|
|
95 |
TInt count = channelInfoList.Count();
|
|
96 |
iLog->Log(KLogChannelFound,channel,count);
|
|
97 |
}
|
|
98 |
channelInfoList.Close();
|
|
99 |
delete sensrChannel;
|
|
100 |
__UHEAP_MARKEND;
|
|
101 |
return leavecode;
|
|
102 |
}
|
|
103 |
|
|
104 |
|
|
105 |
TInt CSensrServiceTest::TestListenData( CStifItemParser& aItem )
|
|
106 |
{
|
|
107 |
__UHEAP_MARK;
|
|
108 |
CActiveScheduler* sched = NULL;
|
|
109 |
TInt channelid;
|
|
110 |
aItem.GetNextInt(channelid);
|
|
111 |
|
|
112 |
CSensorService* sensrChannel = CSensorService::NewL();
|
|
113 |
RSensrvChannelInfoList channelInfoList;
|
|
114 |
int error;
|
|
115 |
TRAP(error,(sensrChannel->FindSensorChannelsL(channelid,channelInfoList)));
|
|
116 |
|
|
117 |
if(error == KErrNotFound)
|
|
118 |
{
|
|
119 |
iLog->Log(_L("Channel not found - %d"),channelid);
|
|
120 |
delete sensrChannel;
|
|
121 |
return KErrNotFound;
|
|
122 |
}
|
|
123 |
else if ( error != KErrNone )
|
|
124 |
{
|
|
125 |
iLog->Log(_L("FindSensorChannel failed for %d channel"),channelid);
|
|
126 |
delete sensrChannel;
|
|
127 |
return error;
|
|
128 |
}
|
|
129 |
|
|
130 |
TInt count = channelInfoList.Count();
|
|
131 |
|
|
132 |
CSensrDataCallBack* callbackobj = CSensrDataCallBack::NewL(sensrChannel,channelid);
|
|
133 |
if ( !error )
|
|
134 |
{
|
|
135 |
TRAP(error,(sensrChannel->GetDataNotificationL(channelInfoList[0],callbackobj)));
|
|
136 |
sched = CActiveScheduler::Current();
|
|
137 |
sched->Start();
|
|
138 |
}
|
|
139 |
|
|
140 |
delete callbackobj;
|
|
141 |
channelInfoList.Close();
|
|
142 |
delete sensrChannel;
|
|
143 |
__UHEAP_MARKEND;
|
|
144 |
return error;
|
|
145 |
|
|
146 |
}
|
|
147 |
|
|
148 |
TInt CSensrServiceTest::TestGetProperty( CStifItemParser& aItem )
|
|
149 |
{
|
|
150 |
__UHEAP_MARK;
|
|
151 |
CSensorService* sensrChannel = CSensorService::NewL();
|
|
152 |
RSensrvChannelInfoList channelInfoList;
|
|
153 |
RSensrvPropertyList channelPropertyList;
|
|
154 |
TInt channel;
|
|
155 |
aItem.GetNextInt(channel);
|
|
156 |
TRAPD(error,(sensrChannel->FindSensorChannelsL(channel,channelInfoList)));
|
|
157 |
|
|
158 |
//TInt error = sensrChannel->FindSensorChannelsL(channel,channelInfoList);
|
|
159 |
|
|
160 |
if(error == KErrNotFound)
|
|
161 |
{
|
|
162 |
iLog->Log(KLogChannelNotFound,channel);
|
|
163 |
return KErrNone;
|
|
164 |
}
|
|
165 |
|
|
166 |
else if(error)
|
|
167 |
{
|
|
168 |
iLog->Log(KLogFindChannelFail,channel,error);
|
|
169 |
return error;
|
|
170 |
}
|
|
171 |
|
|
172 |
|
|
173 |
TInt count = channelInfoList.Count();
|
|
174 |
|
|
175 |
for(TInt i=0;i < count;i++)
|
|
176 |
{
|
|
177 |
TRAPD(error,(sensrChannel->GetChannelPropertyL(channelInfoList[i]
|
|
178 |
,channelPropertyList)));
|
|
179 |
|
|
180 |
if(error)
|
|
181 |
{
|
|
182 |
channelPropertyList.Close();
|
|
183 |
channelInfoList.Close();
|
|
184 |
delete sensrChannel;
|
|
185 |
return error;
|
|
186 |
}
|
|
187 |
|
|
188 |
TSensrvProperty property;
|
|
189 |
TUint propertyId;
|
|
190 |
TInt propValue,minValue,maxValue,propType ;
|
|
191 |
TReal rpropValue,rminValue,rmaxValue;
|
|
192 |
TBuf8<50> bpropValue;
|
|
193 |
TInt32 itemIndex;
|
|
194 |
TBool readOnly;
|
|
195 |
|
|
196 |
TInt propCount = channelPropertyList.Count();
|
|
197 |
|
|
198 |
iLog->Log(_L("Channel id = %d"),channelInfoList[i].iChannelId);
|
|
199 |
iLog->Log(_L("Property count= %d"),propCount);
|
|
200 |
iLog->Log(_L("PropId PropType Val Min Max Ind RD"));
|
|
201 |
|
|
202 |
for (TInt j=0;j < propCount; j++)
|
|
203 |
{
|
|
204 |
property = channelPropertyList[j];
|
|
205 |
propertyId = property.GetPropertyId();
|
|
206 |
propType = property.PropertyType();
|
|
207 |
|
|
208 |
itemIndex = property.PropertyItemIndex();
|
|
209 |
readOnly = property.ReadOnly();
|
|
210 |
|
|
211 |
if(propType == ESensrvIntProperty)
|
|
212 |
{
|
|
213 |
property.GetValue(propValue);
|
|
214 |
property.GetMinValue(minValue);
|
|
215 |
property.GetMaxValue(maxValue);
|
|
216 |
iLog->Log(_L("%d %d %d %d %d %d %d"),
|
|
217 |
propertyId,propType,propValue,minValue,maxValue,itemIndex,readOnly);
|
|
218 |
}
|
|
219 |
else if (propType == ESensrvRealProperty)
|
|
220 |
{
|
|
221 |
property.GetValue(rpropValue);
|
|
222 |
property.GetMinValue(rminValue);
|
|
223 |
property.GetMaxValue(rmaxValue);
|
|
224 |
iLog->Log(_L("%d %d %d %d %d %d %d"),
|
|
225 |
propertyId,propType,rpropValue,rminValue,rmaxValue,itemIndex,readOnly);
|
|
226 |
|
|
227 |
}
|
|
228 |
else if (propType == ESensrvBufferProperty)
|
|
229 |
{
|
|
230 |
property.GetValue(bpropValue);
|
|
231 |
iLog->Log(_L("%d %d buf %d %d"),propertyId,propType,itemIndex,readOnly);
|
|
232 |
}
|
|
233 |
}
|
|
234 |
}
|
|
235 |
|
|
236 |
channelPropertyList.Close();
|
|
237 |
channelInfoList.Close();
|
|
238 |
delete sensrChannel;
|
|
239 |
__UHEAP_MARKEND;
|
|
240 |
return error;
|
|
241 |
|
|
242 |
}
|