|
1 /* |
|
2 * Copyright (c) 2007 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 "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: Helper class for TPosition class |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 // System Includes |
|
20 |
|
21 |
|
22 // User Includes |
|
23 #include "testposition.h" |
|
24 #include <e32std.h> |
|
25 |
|
26 // Constant Declarations |
|
27 |
|
28 |
|
29 // ======== MEMBER FUNCTIONS ======== |
|
30 |
|
31 // --------------------------------------------------------------------------- |
|
32 // C++ Default Constructor |
|
33 // --------------------------------------------------------------------------- |
|
34 // |
|
35 TTestPosition ::TTestPosition (CStifLogger* aLog):iLog(aLog) |
|
36 { |
|
37 |
|
38 } |
|
39 |
|
40 // --------------------------------------------------------------------------- |
|
41 // C++ Destructor |
|
42 // --------------------------------------------------------------------------- |
|
43 // |
|
44 TTestPosition ::~TTestPosition () |
|
45 { |
|
46 |
|
47 } |
|
48 |
|
49 // ----------------------------------------------------------------------------- |
|
50 // This method calls the respective constructor based on the number of arguments |
|
51 // ----------------------------------------------------------------------------- |
|
52 // |
|
53 TInt TTestPosition ::CreatePosition(CStifItemParser& aItem) |
|
54 { |
|
55 TLocality locality; |
|
56 TInt time = 0; |
|
57 TInt error = aItem.GetNextInt(time); |
|
58 |
|
59 TTime time1(time); |
|
60 if(!error) |
|
61 { |
|
62 return Position1(locality,time1); |
|
63 } |
|
64 else |
|
65 return DefaultConstructor(); |
|
66 |
|
67 } |
|
68 |
|
69 // --------------------------------------------------------- |
|
70 // Test case for Default Constructor of TPosition |
|
71 // --------------------------------------------------------- |
|
72 // |
|
73 TInt TTestPosition :: DefaultConstructor() |
|
74 { |
|
75 TPosition position; |
|
76 |
|
77 return KErrNone; |
|
78 } |
|
79 // --------------------------------------------------------- |
|
80 // Test case for constructor of TPosition with locality object |
|
81 // ---------------------------------------------------------- |
|
82 |
|
83 TInt TTestPosition :: Position1(TLocality& locality,TTime time) |
|
84 { |
|
85 TPosition position(locality,time); |
|
86 if(position.Time()!=time) |
|
87 { |
|
88 return KErrGeneral; |
|
89 } |
|
90 else |
|
91 return KErrNone; |
|
92 } |
|
93 // --------------------------------------------------------- |
|
94 // Test case for setting & getting the time |
|
95 // ---------------------------------------------------------- |
|
96 TInt TTestPosition :: SetGetTime(CStifItemParser& aItem) |
|
97 { |
|
98 |
|
99 TPosition position; |
|
100 TInt time = 0; |
|
101 TInt error = aItem.GetNextInt(time); |
|
102 |
|
103 TTime time1(time); |
|
104 if(!error) |
|
105 { |
|
106 position.SetTime(time1); |
|
107 if(position.Time()==time1) |
|
108 { |
|
109 return KErrNone; |
|
110 |
|
111 } |
|
112 else return KErrGeneral; |
|
113 } |
|
114 else |
|
115 return KErrGeneral; |
|
116 } |
|
117 |
|
118 // --------------------------------------------------------- |
|
119 // Test case for setting current time |
|
120 // ---------------------------------------------------------- |
|
121 |
|
122 TInt TTestPosition :: SettingTime() |
|
123 { |
|
124 TPosition position; |
|
125 position.SetCurrentTime(); |
|
126 |
|
127 TTime uniTime; |
|
128 uniTime.UniversalTime(); |
|
129 |
|
130 TTimeIntervalSeconds last; |
|
131 uniTime.SecondsFrom(position.Time(), last); |
|
132 if(last <= TTimeIntervalSeconds(1)) |
|
133 { |
|
134 return KErrNone; |
|
135 } |
|
136 else |
|
137 return KErrGeneral; |
|
138 |
|
139 |
|
140 |
|
141 |
|
142 } |
|
143 |
|
144 |
|
145 |
|
146 |
|
147 // --------------------------------------------------------- |
|
148 // Test case for checking Speed method |
|
149 // ---------------------------------------------------------- |
|
150 |
|
151 TInt TTestPosition :: GetSpeed(CStifItemParser& aItem) |
|
152 { |
|
153 TInt lat1 = 0; |
|
154 TInt lon1 = 0; |
|
155 TInt lat2 = 0; |
|
156 TInt lon2 = 0; |
|
157 TInt haccuracy1 = 0; |
|
158 TInt haccuracy2 = 0; |
|
159 TInt time1 = 0; |
|
160 TInt time2 = 0; |
|
161 TInt err1 = aItem.GetNextInt(lat1); |
|
162 TInt err2 = aItem.GetNextInt(lon1); |
|
163 TInt err3 = aItem.GetNextInt(lat2); |
|
164 TInt err4 = aItem.GetNextInt(lon2); |
|
165 TInt err5 = aItem.GetNextInt(haccuracy1); |
|
166 TInt err6 = aItem.GetNextInt(haccuracy2); |
|
167 TInt err7 = aItem.GetNextInt(time1); |
|
168 TInt err8 = aItem.GetNextInt(time2); |
|
169 TTime time3(time1); |
|
170 TTime time4(time2); |
|
171 TReal32 speed; |
|
172 |
|
173 if(!err1 && !err2 && !err3 && !err4 && !err5 && !err6 && !err7 && !err8) |
|
174 { |
|
175 |
|
176 TCoordinate co_ord1(lat1,lon1); |
|
177 TCoordinate co_ord2(lat2,lon2); |
|
178 TLocality locality1(co_ord1,haccuracy1); |
|
179 TLocality locality2(co_ord2,haccuracy2); |
|
180 TPosition position1(locality1,time3); |
|
181 TPosition position2(locality2,time4); |
|
182 TInt error = position1.Speed(position2,speed); |
|
183 if(!error) |
|
184 { |
|
185 return KErrNone; |
|
186 } |
|
187 else |
|
188 return error; |
|
189 } |
|
190 else |
|
191 return KErrArgument; |
|
192 |
|
193 |
|
194 } |
|
195 |
|
196 |
|
197 // --------------------------------------------------------- |
|
198 // Test case for checking Speed method with accuracy |
|
199 // ---------------------------------------------------------- |
|
200 |
|
201 TInt TTestPosition :: GetSpeed1(CStifItemParser& aItem) |
|
202 { |
|
203 TInt lat1 = 0; |
|
204 TInt lon1 = 0; |
|
205 TInt lat2 = 0; |
|
206 TInt lon2 = 0; |
|
207 TInt haccuracy1 = 0; |
|
208 TInt haccuracy2 = 0; |
|
209 TInt time1 = 0; |
|
210 TInt time2 = 0; |
|
211 TInt err1 = aItem.GetNextInt(lat1); |
|
212 TInt err2 = aItem.GetNextInt(lon1); |
|
213 TInt err3 = aItem.GetNextInt(lat2); |
|
214 TInt err4 = aItem.GetNextInt(lon2); |
|
215 TInt err5 = aItem.GetNextInt(haccuracy1); |
|
216 TInt err6 = aItem.GetNextInt(haccuracy2); |
|
217 TInt err7 = aItem.GetNextInt(time1); |
|
218 TInt err8 = aItem.GetNextInt(time2); |
|
219 TTime time3(time1); |
|
220 TTime time4(time2); |
|
221 TReal32 speed; |
|
222 TReal32 delta; |
|
223 |
|
224 if(!err1 && !err2 && !err3 && !err4 && !err5 && !err6 && !err7 && !err8) |
|
225 { |
|
226 |
|
227 TCoordinate co_ord1(lat1,lon1); |
|
228 TCoordinate co_ord2(lat2,lon2); |
|
229 TLocality locality1(co_ord1,haccuracy1); |
|
230 TLocality locality2(co_ord2,haccuracy2); |
|
231 TPosition position1(locality1,time3); |
|
232 TPosition position2(locality2,time4); |
|
233 TInt error = position1.Speed(position2,speed,delta); |
|
234 if(!error) |
|
235 { |
|
236 return KErrNone; |
|
237 } |
|
238 else |
|
239 return error; |
|
240 } |
|
241 else |
|
242 return KErrArgument; |
|
243 |
|
244 |
|
245 } |
|
246 |
|
247 |