748
|
1 |
// Copyright (c) 2002-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 the License "Symbian Foundation License v1.0"
|
|
5 |
// which accompanies this distribution, and is available
|
|
6 |
// at the URL "http://www.symbianfoundation.org/legal/sfl-v10.html".
|
|
7 |
//
|
|
8 |
// Initial Contributors:
|
|
9 |
// Nokia Corporation - initial contribution.
|
|
10 |
//
|
|
11 |
// Contributors:
|
|
12 |
//
|
|
13 |
// Description:
|
|
14 |
//
|
|
15 |
|
|
16 |
|
|
17 |
|
|
18 |
// INCLUDES
|
|
19 |
#include "ctlbsclientpostp272.h"
|
|
20 |
|
|
21 |
#include <e32std.h>
|
|
22 |
|
|
23 |
// CONSTANTS
|
|
24 |
const TInt KUpdateInterval = 10000000;
|
|
25 |
const TInt KUpdateInterval2 = 15000000;
|
|
26 |
const TInt KUpdateInterval3 = 2000000;
|
|
27 |
|
|
28 |
const TInt KMinTimeLimitRequest1 = 0;
|
|
29 |
const TInt KMaxTimeLimitRequest1 = 2000000;
|
|
30 |
|
|
31 |
const TInt KMinTimeLimitRequest2 = 9000000;
|
|
32 |
const TInt KMaxTimeLimitRequest2 = 12000000;
|
|
33 |
|
|
34 |
const TInt KMinTimeLimitRequest3 = 14000000;
|
|
35 |
const TInt KMaxTimeLimitRequest3 = 17000000;
|
|
36 |
|
|
37 |
const TInt KMinTimeLimitRequest4 = 0;
|
|
38 |
const TInt KMaxTimeLimitRequest4 = 3000000;//200000;
|
|
39 |
|
|
40 |
// ================= MEMBER FUNCTIONS =======================
|
|
41 |
|
|
42 |
// ---------------------------------------------------------
|
|
43 |
// Constructor.
|
|
44 |
// ---------------------------------------------------------
|
|
45 |
CT_LbsClientPosTp272::CT_LbsClientPosTp272(CT_LbsServer& aParent): CT_LbsPortedStepBase(aParent)
|
|
46 |
{
|
|
47 |
_LIT(KTestName,"Tp272-Perodic Update, Changing the interval");
|
|
48 |
SetTestStepName(KTestName);
|
|
49 |
}
|
|
50 |
|
|
51 |
// ---------------------------------------------------------
|
|
52 |
// Destructor.
|
|
53 |
// ---------------------------------------------------------
|
|
54 |
CT_LbsClientPosTp272::~CT_LbsClientPosTp272()
|
|
55 |
{
|
|
56 |
}
|
|
57 |
|
|
58 |
// ---------------------------------------------------------
|
|
59 |
// CT_LbsClientPosTp272::StartL
|
|
60 |
//
|
|
61 |
// (other items were commented in a header).
|
|
62 |
// ---------------------------------------------------------
|
|
63 |
//
|
|
64 |
void CT_LbsClientPosTp272::StartL()
|
|
65 |
{
|
|
66 |
_LIT(KOpenErr, "Error when opening MultiPSY, %d");
|
|
67 |
_LIT(KServiceName, "TP272");
|
|
68 |
|
|
69 |
SetupPsyL(iUidMultiPsy);
|
|
70 |
|
|
71 |
ConnectL();
|
|
72 |
|
|
73 |
TInt err = OpenPositionerByName(iUidMultiPsy);
|
|
74 |
AssertTrueSecL(err == KErrNone, KOpenErr, err);
|
|
75 |
|
|
76 |
iPositioner.SetRequestor(CRequestor::ERequestorService, CRequestor::EFormatApplication, KServiceName);
|
|
77 |
|
|
78 |
SetPeriodicUpdateL(KUpdateInterval);
|
|
79 |
|
|
80 |
TInt request=0;
|
|
81 |
// NotifyPositionUpdate should be called direct by the server on the first request
|
|
82 |
// even if update interval is used
|
|
83 |
RequestL(++request, KMinTimeLimitRequest1, KMaxTimeLimitRequest1);
|
|
84 |
|
|
85 |
// Even if same update interval is set again should the first request complete direct
|
|
86 |
SetPeriodicUpdateL(KUpdateInterval);
|
|
87 |
RequestL(++request, KMinTimeLimitRequest2, KMaxTimeLimitRequest2);
|
|
88 |
|
|
89 |
// NotifyPositionUpdate should be called after the update interval on the second request
|
|
90 |
// but when the update interval is changed should it be called direct
|
|
91 |
RequestL(++request, KMinTimeLimitRequest2, KMaxTimeLimitRequest2, KUpdateInterval2);
|
|
92 |
|
|
93 |
// Now should the request time be about 10 sec
|
|
94 |
RequestL(++request, KMinTimeLimitRequest3, KMaxTimeLimitRequest3);
|
|
95 |
|
|
96 |
SetPeriodicUpdateL(KUpdateInterval3);
|
|
97 |
|
|
98 |
// Should return direct since update interval changed again
|
|
99 |
RequestL(++request, KMinTimeLimitRequest4, KMaxTimeLimitRequest4);
|
|
100 |
|
|
101 |
|
|
102 |
}
|
|
103 |
|
|
104 |
// ---------------------------------------------------------
|
|
105 |
// CT_LbsClientPosTp272::CloseTest
|
|
106 |
//
|
|
107 |
// (other items were commented in a header).
|
|
108 |
// ---------------------------------------------------------
|
|
109 |
//
|
|
110 |
void CT_LbsClientPosTp272::CloseTest()
|
|
111 |
{
|
|
112 |
iPositioner.Close();
|
|
113 |
iPosServer.Close();
|
|
114 |
}
|
|
115 |
|
|
116 |
// ---------------------------------------------------------
|
|
117 |
// CT_LbsClientPosTp272::AssertTrueSecL
|
|
118 |
//
|
|
119 |
// (other items were commented in a header).
|
|
120 |
// ---------------------------------------------------------
|
|
121 |
//
|
|
122 |
void CT_LbsClientPosTp272::AssertTrueSecL(TBool aCondition, const TDesC& aErrorMsg, TInt aErrorCode)
|
|
123 |
{
|
|
124 |
if (!aCondition)
|
|
125 |
{
|
|
126 |
TBuf<100> buf;
|
|
127 |
buf.Format(aErrorMsg, aErrorCode);
|
|
128 |
LogErrorAndLeaveL(buf);
|
|
129 |
}
|
|
130 |
}
|
|
131 |
|
|
132 |
// ---------------------------------------------------------
|
|
133 |
// CT_LbsClientPosTp272::RequestL
|
|
134 |
//
|
|
135 |
// (other items were commented in a header).
|
|
136 |
// ---------------------------------------------------------
|
|
137 |
//
|
|
138 |
void CT_LbsClientPosTp272::RequestL(const TInt& aRequestIndex,
|
|
139 |
const TInt64& aMinTimeLimit,
|
|
140 |
const TInt64& aMaxTimeLimit,
|
|
141 |
const TInt& aPeriodicUpdateInterval)
|
|
142 |
{
|
|
143 |
_LIT(KUnexpectedErrCode, "Unexpected error code %d returned by the used PSY");
|
|
144 |
_LIT(KRequestMaxTimeErr, "Request took to long");
|
|
145 |
_LIT(KRequestMinTimeErr, "Request was to fast");
|
|
146 |
_LIT(KRequestTime, "Request took %d microsecs");
|
|
147 |
|
|
148 |
TBuf<100> info;
|
|
149 |
_LIT(KInfo, "Making request %d");
|
|
150 |
info.Format(KInfo, aRequestIndex);
|
|
151 |
INFO_PRINTF1(info);
|
|
152 |
|
|
153 |
TTime start, stop;
|
|
154 |
start.UniversalTime();
|
|
155 |
|
|
156 |
TPositionInfo posInfo;
|
|
157 |
TRequestStatus status;
|
|
158 |
iPositioner.NotifyPositionUpdate(posInfo, status);
|
|
159 |
|
|
160 |
if (aPeriodicUpdateInterval != 0)
|
|
161 |
{
|
|
162 |
User::After(5000000);
|
|
163 |
SetPeriodicUpdateL(KUpdateInterval2);
|
|
164 |
}
|
|
165 |
|
|
166 |
User::WaitForRequest(status);
|
|
167 |
stop.UniversalTime();
|
|
168 |
|
|
169 |
TInt64 usec = (stop.Int64() - start.Int64());
|
|
170 |
info.Format(KRequestTime, usec);
|
|
171 |
INFO_PRINTF1(info);
|
|
172 |
|
|
173 |
AssertTrueL(status.Int() == KErrNone, KUnexpectedErrCode, status.Int());
|
|
174 |
|
|
175 |
AssertTrueSecL(usec <= aMaxTimeLimit, KRequestMaxTimeErr);
|
|
176 |
AssertTrueSecL(usec >= aMinTimeLimit, KRequestMinTimeErr);
|
|
177 |
}
|
|
178 |
|
|
179 |
// ---------------------------------------------------------
|
|
180 |
// CT_LbsClientPosTp272::SetPeriodicUpdateL
|
|
181 |
//
|
|
182 |
// (other items were commented in a header).
|
|
183 |
// ---------------------------------------------------------
|
|
184 |
//
|
|
185 |
void CT_LbsClientPosTp272::SetPeriodicUpdateL(const TInt& aUpdateInterval)
|
|
186 |
{
|
|
187 |
_LIT(KUpdateErr, "Error when setting update interval, %d");
|
|
188 |
|
|
189 |
TPositionUpdateOptions updateOptions;
|
|
190 |
updateOptions.SetUpdateInterval(TTimeIntervalMicroSeconds(aUpdateInterval));
|
|
191 |
TInt err = iPositioner.SetUpdateOptions(updateOptions);
|
|
192 |
AssertTrueL(err == KErrNone, KUpdateErr, err);
|
|
193 |
|
|
194 |
}
|
|
195 |
|
|
196 |
// End of File
|