|
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 "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 // |
|
15 |
|
16 |
|
17 |
|
18 // INCLUDES |
|
19 #include "ctlbsclientpostp176.h" |
|
20 #include <lbs/epos_cposmodules.h> |
|
21 #include <lbs/epos_cposmoduleupdate.h> |
|
22 #include <lbs/epos_cposmoduleidlist.h> |
|
23 // ================= MEMBER FUNCTIONS ======================= |
|
24 |
|
25 // --------------------------------------------------------- |
|
26 // Constructor. |
|
27 // --------------------------------------------------------- |
|
28 CT_LbsClientPosTp176::CT_LbsClientPosTp176(CT_LbsServer& aParent): CT_LbsPortedStepBase(aParent) |
|
29 { |
|
30 _LIT(KTestName, "TP176 - Basic PSY test"); |
|
31 SetTestStepName(KTestName); |
|
32 } |
|
33 |
|
34 // --------------------------------------------------------- |
|
35 // Destructor. |
|
36 // --------------------------------------------------------- |
|
37 CT_LbsClientPosTp176::~CT_LbsClientPosTp176() |
|
38 { |
|
39 } |
|
40 |
|
41 // --------------------------------------------------------- |
|
42 // CT_LbsClientPosTp176::CloseTest |
|
43 // Always called after the test, even if the test leaves |
|
44 // (other items were commented in a header). |
|
45 // --------------------------------------------------------- |
|
46 // |
|
47 void CT_LbsClientPosTp176::CloseTest() |
|
48 { |
|
49 |
|
50 } |
|
51 |
|
52 // --------------------------------------------------------- |
|
53 // CT_LbsClientPosTp176::CloseTest |
|
54 // Always called after the test, even if the test leaves |
|
55 // (other items were commented in a header). |
|
56 // --------------------------------------------------------- |
|
57 // |
|
58 void CT_LbsClientPosTp176::InitTestL() |
|
59 { |
|
60 |
|
61 } |
|
62 |
|
63 // --------------------------------------------------------- |
|
64 // CT_LbsClientPosTp176::StartL |
|
65 // |
|
66 // (other items were commented in a header). |
|
67 // --------------------------------------------------------- |
|
68 // |
|
69 void CT_LbsClientPosTp176::StartL() |
|
70 { |
|
71 _LIT(KService, "service"); |
|
72 CPosModules *modDb = CPosModules::OpenL(); |
|
73 CleanupStack::PushL(modDb); |
|
74 CPosModuleUpdate* moduleUpdate = CPosModuleUpdate::NewLC(); |
|
75 |
|
76 moduleUpdate->SetUpdateAvailability(ETrue); |
|
77 modDb->UpdateModuleL(iUidTestPsyTp176, *moduleUpdate); |
|
78 modDb->UpdateModuleL(iUidTestPsy1, *moduleUpdate); |
|
79 |
|
80 CleanupStack::PopAndDestroy(2); |
|
81 |
|
82 ConnectL(); |
|
83 |
|
84 User::LeaveIfError(OpenPositionerByName(iUidTestPsyTp176)); |
|
85 TPositionInfo info = TPositionInfo(); |
|
86 |
|
87 // Request data from test psy 176 psy |
|
88 TInt err = PerformSyncRequest(KService, &info); |
|
89 |
|
90 if (err != KErrNone) |
|
91 { |
|
92 _LIT(KErrorRequest, "The request was not completed with KErrorNone"); |
|
93 LogErrorAndLeaveL(KErrorRequest); |
|
94 } |
|
95 |
|
96 // just to make sure that dynamic quality is updated |
|
97 err = PerformSyncRequest(KService, &info); |
|
98 |
|
99 if (err != KErrNone) |
|
100 { |
|
101 _LIT(KErrorRequest, "The request was not completed with KErrorNone"); |
|
102 LogErrorAndLeaveL(KErrorRequest); |
|
103 } |
|
104 |
|
105 |
|
106 HPositionGenericInfo* genericInfo = HPositionGenericInfo::NewLC(); |
|
107 |
|
108 // Request a genericInfo from test psy 176 should fail. |
|
109 err = PerformSyncRequest(KService, genericInfo); |
|
110 |
|
111 |
|
112 //Magic number KErrHardwareNotAvailable is used to check that the psy is |
|
113 //not responsible for determine if the class is supported. |
|
114 if (err == KErrHardwareNotAvailable) |
|
115 { |
|
116 _LIT(KErrorRequest, "The type checking was done in the PSY"); |
|
117 LogErrorAndLeaveL(KErrorRequest); |
|
118 } |
|
119 else if (err != KErrArgument) |
|
120 { |
|
121 _LIT(KErrWrongType, "Wrong error type returned"); |
|
122 LogErrorAndLeaveL(KErrWrongType); |
|
123 } |
|
124 |
|
125 |
|
126 // not set uid |
|
127 err = PerformSyncRequest(KService, &info); |
|
128 |
|
129 if (err != KErrGeneral) |
|
130 { |
|
131 _LIT(KErrorRequest, "The request was not completed with KErrGeneral"); |
|
132 LogErrorAndLeaveL(KErrorRequest); |
|
133 } |
|
134 |
|
135 |
|
136 // incorrect uid, but existing |
|
137 err = PerformSyncRequest(KService, &info); |
|
138 if (err != KErrGeneral) |
|
139 { |
|
140 _LIT(KErrorRequest, "The request was not completed with KErrGeneral"); |
|
141 LogErrorAndLeaveL(KErrorRequest); |
|
142 } |
|
143 |
|
144 //incorrect uid |
|
145 err = PerformSyncRequest(KService, &info); |
|
146 if (err != KErrGeneral) |
|
147 { |
|
148 _LIT(KErrorRequest, "The request was not completed with KErrGeneral"); |
|
149 LogErrorAndLeaveL(KErrorRequest); |
|
150 } |
|
151 |
|
152 |
|
153 ClosePositioner(); |
|
154 Disconnect(); |
|
155 |
|
156 CleanupStack::PopAndDestroy(); //genericInfo |
|
157 |
|
158 } |
|
159 |
|
160 |
|
161 |
|
162 TBool CT_LbsClientPosTp176::IsQualityUpdatedL(TUid aUid) |
|
163 { |
|
164 TBool updated = ETrue; |
|
165 CPosModules *modDb = CPosModules::OpenL(); |
|
166 CleanupStack::PushL(modDb); |
|
167 |
|
168 TPositionQuality dynQuality; |
|
169 |
|
170 //TTimeIntervalMicroSeconds timeToFirstFix = dynQuality.TimeToNextFix(); |
|
171 TTimeIntervalMicroSeconds timeToFirstFixBefore; |
|
172 TReal32 horAccBefore; |
|
173 TReal32 horAccAfter = dynQuality.HorizontalAccuracy(); |
|
174 |
|
175 if (aUid == iUidTestPsyTp176) |
|
176 { |
|
177 timeToFirstFixBefore = iQuality.TimeToNextFix(); |
|
178 horAccBefore = iQuality.HorizontalAccuracy(); |
|
179 } |
|
180 else |
|
181 { |
|
182 timeToFirstFixBefore = iQualityTestPsy1.TimeToNextFix(); |
|
183 horAccBefore = iQualityTestPsy1.HorizontalAccuracy(); |
|
184 } |
|
185 |
|
186 |
|
187 if (horAccBefore != horAccAfter) |
|
188 { |
|
189 updated = ETrue; |
|
190 iQuality = dynQuality; |
|
191 _LIT(KUpdated, "Dynamic Quality is updated"); |
|
192 INFO_PRINTF1(KUpdated); |
|
193 } |
|
194 else |
|
195 { |
|
196 updated = EFalse; |
|
197 _LIT(KNotUpdated, "Dynamic Quality is NOT updated"); |
|
198 INFO_PRINTF1(KNotUpdated); |
|
199 } |
|
200 |
|
201 CleanupStack::PopAndDestroy(); |
|
202 return updated; |
|
203 } |