|
1 // Copyright (c) 2001-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 "ctlbsclientpostp222.h" |
|
20 |
|
21 // CONSTANTS |
|
22 // ================= MEMBER FUNCTIONS ======================= |
|
23 |
|
24 // Constructor. |
|
25 CT_LbsClientPosTp222::CT_LbsClientPosTp222(CT_LbsServer& aParent): CT_LbsPortedStepBase(aParent) |
|
26 { |
|
27 _LIT(KTestName, "TP222 - Partial Update test"); |
|
28 SetTestStepName(KTestName); |
|
29 } |
|
30 |
|
31 // --------------------------------------------------------- |
|
32 // Destructor. |
|
33 // --------------------------------------------------------- |
|
34 CT_LbsClientPosTp222::~CT_LbsClientPosTp222() |
|
35 { |
|
36 } |
|
37 |
|
38 // --------------------------------------------------------- |
|
39 // CPosTp222::CloseTest |
|
40 // |
|
41 // (other items were commented in a header). |
|
42 // --------------------------------------------------------- |
|
43 // |
|
44 void CT_LbsClientPosTp222::CloseTest() |
|
45 { |
|
46 ClosePositioner(); |
|
47 Disconnect(); |
|
48 } |
|
49 |
|
50 // This flag must be defined if testing partial update NOT supported |
|
51 #ifdef PARTIAL_UPDATE_NOT_SUPPORTED |
|
52 // --------------------------------------------------------- |
|
53 // CPosTp222::StartL |
|
54 // |
|
55 // (other items were commented in a header). |
|
56 // --------------------------------------------------------- |
|
57 // |
|
58 // If partial update is NOT supported |
|
59 void CT_LbsClientPosTp222::StartL() |
|
60 { |
|
61 _LIT(KPartialUpdateTest, "-----Testing that PartialUpdate is NOT supported-----"); |
|
62 INFO_PRINTF1(KPartialUpdateTest); |
|
63 SetupPsyL(iUidTestPsyPartialUpdate); |
|
64 SetupGlobalPrivacyL(TPosPrivacy(TPosPrivacy::EAcceptAll, EFalse)); |
|
65 _LIT(KService, "PellesKattlåda"); |
|
66 |
|
67 ConnectL(); |
|
68 User::LeaveIfError(OpenPositionerByName(iUidTestPsyPartialUpdate)); |
|
69 |
|
70 TPositionUpdateOptions updateOptions; |
|
71 // Check that partial update is not supported |
|
72 updateOptions.SetAcceptPartialUpdates(ETrue); |
|
73 |
|
74 TInt res = iPositioner.SetUpdateOptions(updateOptions); |
|
75 _LIT(KSetUpdateOptions, "SetUpdateOptions should not be supported, instead error %d was return"); |
|
76 AssertTrueL(res == KErrNotSupported, KSetUpdateOptions, res); |
|
77 |
|
78 TPositionInfo info = TPositionInfo(); |
|
79 TInt err = PerformSyncRequest(KService, &info); |
|
80 _LIT(KErrRequest2, "error when performing sync request nr2, err: %d"); |
|
81 AssertTrueL(err == KErrNone, KErrRequest2, err); |
|
82 // Check that a "full" position is returned |
|
83 TPosition pos = TPosition(); |
|
84 info.GetPosition(pos); |
|
85 |
|
86 if (pos.Latitude() == 30 && pos.Longitude() == 40 && pos.Altitude() == 50) |
|
87 { |
|
88 _LIT(KErrorAndLeave, |
|
89 "Partial update position returned from positioner when this feature should be disabled"); |
|
90 LogErrorAndLeaveL(KErrorAndLeave); |
|
91 } |
|
92 |
|
93 ClosePositioner(); |
|
94 Disconnect(); |
|
95 |
|
96 _LIT(KFunctionDone, "Test Completed successfully"); |
|
97 INFO_PRINTF1(KFunctionDone); |
|
98 } |
|
99 |
|
100 #else |
|
101 // --------------------------------------------------------- |
|
102 // CPosTp222::StartL |
|
103 // |
|
104 // (other items were commented in a header). |
|
105 // --------------------------------------------------------- |
|
106 // |
|
107 // If partial update is supported |
|
108 void CT_LbsClientPosTp222::StartL() |
|
109 { |
|
110 _LIT(KPartialUpdateTest, "-----Testing that PartialUpdate is supported-----"); |
|
111 INFO_PRINTF1(KPartialUpdateTest); |
|
112 SetupPsyL(iUidTestPsyPartialUpdate); |
|
113 |
|
114 ConnectL(); |
|
115 User::LeaveIfError(OpenPositionerByName(iUidTestPsyPartialUpdate)); |
|
116 _LIT(KService, "PellesKaninlaada"); |
|
117 |
|
118 TPositionUpdateOptions updateOptions; |
|
119 TPositionUpdateOptions resultOptions; |
|
120 // Check that partial update is not set |
|
121 TBool res = updateOptions.AcceptPartialUpdates(); |
|
122 if (res) |
|
123 { |
|
124 _LIT(KErrorAndLeave, "Partial update default is not correct"); |
|
125 LogErrorAndLeaveL(KErrorAndLeave); |
|
126 } |
|
127 |
|
128 updateOptions.SetAcceptPartialUpdates(ETrue); |
|
129 TInt response = iPositioner.SetUpdateOptions(updateOptions); |
|
130 _LIT(KSetUpdateOptions, "SetUpdateOptions returned error: %d"); |
|
131 AssertTrueL(response == KErrNone, KSetUpdateOptions, res); |
|
132 |
|
133 // Check that partial update has been set |
|
134 iPositioner.GetUpdateOptions(resultOptions); |
|
135 res = resultOptions.AcceptPartialUpdates(); |
|
136 if (!res) |
|
137 { |
|
138 _LIT(KErrorAndLeave, "Partial update not correctly set"); |
|
139 LogErrorAndLeaveL(KErrorAndLeave); |
|
140 } |
|
141 |
|
142 TPositionInfo info = TPositionInfo(); |
|
143 TInt err = PerformSyncRequest(KService, &info); |
|
144 _LIT(KErrRequest, "error when performing sync request, err: %d"); |
|
145 AssertTrueL(err == KPositionPartialUpdate, KErrRequest, err); |
|
146 |
|
147 //Check that a "partial update" position is returned |
|
148 TPosition pos = TPosition(); |
|
149 info.GetPosition(pos); |
|
150 |
|
151 if (pos.Latitude() != 30 || pos.Longitude() != 40 || pos.Altitude() != 50) |
|
152 { |
|
153 _LIT(KErrorAndLeave, |
|
154 "Wrong position returned from positioner(partial update)"); |
|
155 LogErrorAndLeaveL(KErrorAndLeave); |
|
156 } |
|
157 |
|
158 // Disable partialupdate |
|
159 updateOptions.SetAcceptPartialUpdates(EFalse); |
|
160 response = iPositioner.SetUpdateOptions(updateOptions); |
|
161 _LIT(KSetUpdateOptions1, |
|
162 "SetUpdateOptions returned error when disabling partial update err: %d"); |
|
163 AssertTrueL(response == KErrNone, KSetUpdateOptions1, res); |
|
164 |
|
165 // Check that partial update has been disabled |
|
166 iPositioner.GetUpdateOptions(resultOptions); |
|
167 res = resultOptions.AcceptPartialUpdates(); |
|
168 if (res) |
|
169 { |
|
170 _LIT(KErrorAndLeave, "Partial update should not be set"); |
|
171 LogErrorAndLeaveL(KErrorAndLeave); |
|
172 } |
|
173 |
|
174 TPositionInfo info2 = TPositionInfo(); |
|
175 err = PerformSyncRequest(KService, &info2); |
|
176 _LIT(KErrRequest2, "error when performing sync request nr2, err: %d"); |
|
177 AssertTrueL(err == KErrNone, KErrRequest2, err); |
|
178 // Check that a "full" position is returned |
|
179 TPosition pos2 = TPosition(); |
|
180 info2.GetPosition(pos2); |
|
181 |
|
182 if (pos2.Latitude() == 30 && pos2.Longitude() == 40 && pos2.Altitude() == 50) |
|
183 { |
|
184 _LIT(KErrorAndLeave, "Partial update position returned from positioner"); |
|
185 LogErrorAndLeaveL(KErrorAndLeave); |
|
186 } |
|
187 |
|
188 ClosePositioner(); |
|
189 Disconnect(); |
|
190 _LIT(KFunctionDone, "Test Completed successfully"); |
|
191 INFO_PRINTF1(KFunctionDone); |
|
192 } |
|
193 #endif |
|
194 |
|
195 |
|
196 |