|
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 "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 "ctlbscalculationtp233.h" |
|
20 #include "tlbscalculationcheck.h" |
|
21 |
|
22 // C++ constructor |
|
23 CT_LbsCalculationTP233::CT_LbsCalculationTP233(CT_LbsCalculationServer& aParent) : CT_LbsCalculationStepBase(aParent) |
|
24 { |
|
25 _LIT(KTestName, "Calculation TP233 - Calculate Distance"); |
|
26 SetTestStepName(KTestName); |
|
27 } |
|
28 |
|
29 CT_LbsCalculationTP233::~CT_LbsCalculationTP233() |
|
30 { |
|
31 } |
|
32 |
|
33 CT_LbsCalculationTP233* CT_LbsCalculationTP233::New(CT_LbsCalculationServer& aParent) |
|
34 { |
|
35 CT_LbsCalculationTP233* testStep = new CT_LbsCalculationTP233(aParent); |
|
36 // Note the lack of ELeave. |
|
37 // This means that having insufficient memory will return NULL; |
|
38 |
|
39 if (testStep) |
|
40 { |
|
41 TInt err = KErrNone; |
|
42 |
|
43 TRAP(err, testStep->ConstructL()); |
|
44 if (err) |
|
45 { |
|
46 delete testStep; |
|
47 testStep = NULL; |
|
48 } |
|
49 } |
|
50 return testStep; |
|
51 } |
|
52 |
|
53 |
|
54 TVerdict CT_LbsCalculationTP233::doTestStepL() |
|
55 { |
|
56 TestValuesL(); |
|
57 return TestStepResult(); |
|
58 } |
|
59 |
|
60 void CT_LbsCalculationTP233::TestValuesL() |
|
61 { |
|
62 _LIT(KOpenFailed, "File open failed with %d"); |
|
63 |
|
64 TInt err=0; |
|
65 err=ReadValues(); |
|
66 AssertTrueSecL(err == KErrNone, KOpenFailed, err); |
|
67 |
|
68 TInt index=5; |
|
69 for (TInt i=0; i< iCalculationChecks.Count(); i++) |
|
70 { |
|
71 T_LbsCalculationCheck cc =iCalculationChecks[i]; |
|
72 |
|
73 TInt err=cc.CheckDistance(); |
|
74 LogError(err==KErrNone, cc, err, index); |
|
75 |
|
76 err=cc.CheckDistanceCoordinate(); |
|
77 LogError(err==KErrNone, cc, err, index); |
|
78 |
|
79 err=cc.CheckDistanceDelta(); |
|
80 LogError(err==KErrNone, cc, err, index); |
|
81 |
|
82 ++index; |
|
83 if (index == 21 || index == 26 || index == 33 || index == 38|| index == 40 || index == 45 || |
|
84 index == 50 || index == 73 || index == 78 || index == 85 || index == 92 || index == 96 || |
|
85 index == 33 || index == 106 || index == 123 || index == 128 || index == 133) |
|
86 { |
|
87 ++index; |
|
88 } |
|
89 } |
|
90 |
|
91 // Checks that KErrArgumenet is returned |
|
92 T_LbsCalculationCheck c; |
|
93 err=c.CheckDistance(); |
|
94 LogError(err==KErrNone, c, err); |
|
95 |
|
96 err=c.CheckDistanceCoordinate(); |
|
97 LogError(err==KErrNone, c, err); |
|
98 |
|
99 err=c.CheckDistanceDelta(); |
|
100 LogError(err==KErrNone, c, err); |
|
101 |
|
102 } |
|
103 |
|
104 void CT_LbsCalculationTP233::LogTestError(const T_LbsCalculationCheck& aCalc, |
|
105 const TInt aError, |
|
106 const TInt aRow) |
|
107 { |
|
108 TBuf<KMaxLogLineLength> buf; |
|
109 TPosition source; |
|
110 TPosition target; |
|
111 aCalc.GetSourcePosition(source); |
|
112 aCalc.GetTargetPosition(target); |
|
113 |
|
114 if (aError==KErrCalculationCheckDistance) |
|
115 { |
|
116 _LIT(KDistanceError, "Calculated distance is not equal to read distance, values:"); |
|
117 _LIT(KValues, "Lat1= %f, Long1= %f, Lat2= %f, Long2= %f, calculated distance= %f, read distance= %f, row= %d"); |
|
118 |
|
119 buf.Format(KValues, source.Latitude(), |
|
120 source.Longitude(), |
|
121 target.Latitude(), |
|
122 target.Longitude(), |
|
123 aCalc.Calculated(), |
|
124 aCalc.Distance(), |
|
125 aRow); |
|
126 |
|
127 ERR_PRINTF1(KDistanceError); |
|
128 } |
|
129 else if(aError==KErrCalculationCheckDistanceDelta) |
|
130 { |
|
131 _LIT(KDeltaError, "Calculated delta is not equal to read delta:"); |
|
132 _LIT(KValues, "Lat1= %f, Long1= %f, Lat2= %f, Long2= %f, calculated delta= %f, read delta= %f, row= %d"); |
|
133 |
|
134 buf.Format(KValues, source.Latitude(), |
|
135 source.Longitude(), |
|
136 target.Latitude(), |
|
137 target.Longitude(), |
|
138 aCalc.Calculated(), |
|
139 aCalc.Delta(), |
|
140 aRow); |
|
141 ERR_PRINTF1(KDeltaError); |
|
142 } |
|
143 else if(aError==KErrCalculationCheckErrorCode) |
|
144 { |
|
145 _LIT(KIncorrectErrorCode, "Incorrect error code returned from calculation lib:"); |
|
146 _LIT(KCodes, "Returned = %d, Expected = %d, row= &d"); |
|
147 |
|
148 buf.Format(KCodes, aCalc.ReturnedErrorCode(), aCalc.ErrorCode(), aRow); |
|
149 ERR_PRINTF1(KIncorrectErrorCode); |
|
150 } |
|
151 ERR_PRINTF1(buf); |
|
152 } |
|
153 |
|
154 // End of File |