|
1 // Copyright (c) 2007-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 // @file ctlbshybridmultiplestep.cpp |
|
15 // This is the class implementation for the Lbs Hybrid Multiple Test Step Base |
|
16 // |
|
17 // |
|
18 |
|
19 #include "ctlbshybridmultiplestep.h" |
|
20 |
|
21 CT_LbsHybridMultipleStep::~CT_LbsHybridMultipleStep() |
|
22 { |
|
23 iSequences.ResetAndDestroy(); |
|
24 iSequences.Close(); |
|
25 |
|
26 iProxy.ResetAndDestroy(); |
|
27 iProxy.Close(); |
|
28 |
|
29 iExpectedModuleGpsOptions.ResetAndDestroy(); |
|
30 iExpectedModuleGpsOptions.Close(); |
|
31 } |
|
32 |
|
33 |
|
34 CT_LbsHybridMultipleStep::CT_LbsHybridMultipleStep(CT_LbsHybridMultipleServer& aParent) :iParent(aParent), iExpectedModuleGpsOptionsIndex(0), |
|
35 iAgpsModuleEventListener(NULL) |
|
36 { |
|
37 } |
|
38 |
|
39 void CT_LbsHybridMultipleStep::ConstructL() |
|
40 { |
|
41 } |
|
42 |
|
43 /** |
|
44 * @return - TVerdict |
|
45 * Implementation of CTestStep base class virtual |
|
46 * It is used for doing all initialisation common to derived classes in here. |
|
47 * Make it being able to leave if there are any errors here as there's no point in |
|
48 * trying to run a test step if anything fails. |
|
49 * The leave will be picked up by the framework. |
|
50 */ |
|
51 TVerdict CT_LbsHybridMultipleStep::doTestStepPreambleL() |
|
52 { |
|
53 // Process some common pre setting to test steps then set SetTestStepResult to EFail or Epass. |
|
54 INFO_PRINTF1(_L("doTestStepPreabmleL()")); |
|
55 SetTestStepResult(EPass); |
|
56 |
|
57 // Get the expected module GPS options |
|
58 T_LbsUtils utils; |
|
59 TPtrC configFileName; |
|
60 _LIT(KUpdateOptionsFile, "agps_module_update_file"); |
|
61 GetStringFromConfig(ConfigSection(), KUpdateOptionsFile, configFileName); |
|
62 utils.GetExpected_ModuleModes(configFileName, ConfigSection(), iExpectedModuleGpsOptions); |
|
63 if(iExpectedModuleGpsOptions.Count() > 0) |
|
64 { // Start listening for the GPS module options only if expecting any options |
|
65 iAgpsModuleEventListener = CT_AgpsModuleEventListener::NewL(*this); |
|
66 } |
|
67 |
|
68 //Read in the sequences from the testdata ini file |
|
69 TInt numberOfSequences = 0; |
|
70 GetIntFromConfig(ConfigSection(), _L("NumberOfSequences"), numberOfSequences); |
|
71 if(numberOfSequences <= 0) |
|
72 { |
|
73 INFO_PRINTF1(_L("ERROR - Trying to run the test with no sequences!")); |
|
74 SetTestStepResult(EFail); |
|
75 return TestStepResult(); |
|
76 } |
|
77 |
|
78 //Loop through the sequences carrying out the required configuration |
|
79 for(TInt i=0; i<numberOfSequences; ++i) |
|
80 { |
|
81 ReadTestDataConfig(i); |
|
82 } |
|
83 |
|
84 return TestStepResult(); |
|
85 } |
|
86 |
|
87 |
|
88 /** |
|
89 * @return - TVerdict |
|
90 * Implementation of CTestStep base class virtual |
|
91 * It is used for doing all after test treatment common to derived classes in here. |
|
92 * Make it being able to leave |
|
93 * The leave will be picked up by the framework. |
|
94 */ |
|
95 TVerdict CT_LbsHybridMultipleStep::doTestStepPostambleL() |
|
96 { |
|
97 // Process some common post setting to test steps then set SetTestStepResult to EFail or Epass. |
|
98 INFO_PRINTF1(_L("doTestStepPostabmleL()")); |
|
99 |
|
100 //Loop through all the sequences to print out their final status |
|
101 INFO_PRINTF1(_L("---------------------------------- Sequence Status ----------------------------------")); |
|
102 INFO_PRINTF1(_L("Still waiting for the following messages on the following sequences:")); |
|
103 for(TInt i=0; i<iSequences.Count(); ++i) |
|
104 { |
|
105 iSequences[i]->PrintRemainingActions(); |
|
106 } |
|
107 |
|
108 TEST(iExpectedModuleGpsOptionsIndex == iExpectedModuleGpsOptions.Count()); |
|
109 iExpectedModuleGpsOptions.ResetAndDestroy(); |
|
110 iExpectedModuleGpsOptionsIndex = 0; |
|
111 delete iAgpsModuleEventListener; |
|
112 iAgpsModuleEventListener = NULL; |
|
113 |
|
114 //SetTestStepResult(EPass); // or EFail |
|
115 return TestStepResult(); |
|
116 } |
|
117 |
|
118 /** Reads in the details of a sequence from the test data ini file |
|
119 */ |
|
120 void CT_LbsHybridMultipleStep::ReadTestDataConfig(TInt aCurrentNum) |
|
121 { |
|
122 CTestSessionSequence* newSequence; |
|
123 |
|
124 //Get the name of the file being used |
|
125 TPtrC fileName; |
|
126 GetStringFromConfig(_L("FileName"), _L("sequence_data_file"), fileName); |
|
127 |
|
128 //Find out what Protocol Module this sequence is going to be run on |
|
129 TBuf<4> pmName; |
|
130 TInt pmNum = 0; |
|
131 pmName.Format(_L("PM%d"), aCurrentNum); |
|
132 GetIntFromConfig(ConfigSection(), pmName, pmNum); |
|
133 |
|
134 //Create the required protocol module Net Proxy and get the position of this PM in the array |
|
135 TInt position; |
|
136 position = CreateProtocolModuleProxy(pmNum); |
|
137 |
|
138 //Find out what type the sequence is |
|
139 TBuf<6> typeName; |
|
140 TPtrC sequenceType; |
|
141 typeName.Format(_L("Type%d"), aCurrentNum); |
|
142 GetStringFromConfig(ConfigSection(), typeName, sequenceType); |
|
143 |
|
144 //Create the specific test sequence type |
|
145 if(sequenceType.Find(_L("MOLR")) != KErrNotFound) //MOLR |
|
146 { |
|
147 newSequence = CTestMolrSessionSequence::NewL(*iProxy[position], *this, aCurrentNum, fileName, ConfigSection()); |
|
148 } |
|
149 else if(sequenceType.Find(_L("X3P")) != KErrNotFound) //X3P |
|
150 { |
|
151 newSequence = CTestX3PSessionSequence::NewL(*iProxy[position], *this, aCurrentNum, fileName, ConfigSection()); |
|
152 } |
|
153 else if((sequenceType.Find(_L("MTLR")) != KErrNotFound) || (sequenceType.Find(_L("NIMTLR")) != KErrNotFound)) //MTLR |
|
154 { |
|
155 newSequence = CTestMtlrSessionSequence::NewL(*iProxy[position], *this, aCurrentNum, fileName, ConfigSection()); |
|
156 } |
|
157 else //Unknown type, will get generic handling |
|
158 { |
|
159 newSequence = CTestSessionSequence::NewL(*iProxy[position], *this, aCurrentNum, fileName, ConfigSection()); |
|
160 } |
|
161 |
|
162 //Add the new sequence to the array |
|
163 TRAPD(err, iSequences.AppendL(newSequence)); |
|
164 if(err != KErrNone) |
|
165 { |
|
166 SetTestStepResult(EFail); |
|
167 } |
|
168 } |
|
169 |
|
170 |
|
171 /** Creates the Protocol Module Proxy for the PM id past into the function. If the |
|
172 * protocol module proxy is already created, do nothing, just return the position |
|
173 * of the proxy in the iProxy array |
|
174 */ |
|
175 CLbsTestNgMessageHandler* CT_LbsHybridMultipleStep::LookupProtocolModuleProxy(TInt aPmId) |
|
176 { |
|
177 for(TInt i=0; i<iProxy.Count(); ++i) |
|
178 { |
|
179 if(iProxy[i]->GetPmId() == aPmId) |
|
180 { |
|
181 return iProxy[i]; |
|
182 } |
|
183 } |
|
184 |
|
185 // Didn't find a proxy, so return null |
|
186 return 0; |
|
187 } |
|
188 |
|
189 |
|
190 /** Creates the Protocol Module Proxy for the PM id past into the function. If the |
|
191 * protocol module proxy is already created, do nothing, just return the position |
|
192 * of the proxy in the iProxy array |
|
193 */ |
|
194 TInt CT_LbsHybridMultipleStep::CreateProtocolModuleProxy(TInt aPmId) |
|
195 { |
|
196 TInt position = KErrNotFound; |
|
197 |
|
198 //Check to see whether this PM has already been created for another sequence |
|
199 for(TInt i=0; i<iProxy.Count(); ++i) |
|
200 { |
|
201 if(iProxy[i]->GetPmId() == aPmId) |
|
202 { |
|
203 position = i; |
|
204 break; |
|
205 } |
|
206 } |
|
207 |
|
208 if(position == KErrNotFound) |
|
209 { |
|
210 //Create the new Protocol Proxy for this new Protocol Module |
|
211 CLbsTestNgMessageHandler* pmProxy = CLbsTestNgMessageHandler::NewL(*this, aPmId); |
|
212 iProxy.AppendL(pmProxy); |
|
213 position = iProxy.Count() - 1; |
|
214 } |
|
215 |
|
216 return position; |
|
217 } |
|
218 |
|
219 |
|
220 void CT_LbsHybridMultipleStep::OnSetGpsOptions(const TLbsGpsOptions& aGpsOptions) |
|
221 /** |
|
222 * Compares the GPS options received by the AGPS module to the ones expected by the test |
|
223 */ |
|
224 { |
|
225 INFO_PRINTF1(_L("CT_LbsHybridMTLRStep::OnSetGpsOptions()")); |
|
226 if(iExpectedModuleGpsOptionsIndex >= iExpectedModuleGpsOptions.Count()) |
|
227 { |
|
228 INFO_PRINTF3(_L("CT_LbsHybridX3PStep::OnSetGpsOptions - FAILED because got unexpected number of mode changes. Got %d expected %d"), iExpectedModuleGpsOptionsIndex -1, iExpectedModuleGpsOptions.Count()); |
|
229 TEST(EFalse); |
|
230 return; |
|
231 } |
|
232 TLbsGpsOptions* expectedOptions = iExpectedModuleGpsOptions[iExpectedModuleGpsOptionsIndex]; |
|
233 ++iExpectedModuleGpsOptionsIndex; |
|
234 |
|
235 if(aGpsOptions.GpsMode() != expectedOptions->GpsMode()) |
|
236 { |
|
237 INFO_PRINTF3(_L("CT_LbsHybridX3PStep::OnSetGpsOptions - FAILED because got unexpected mode. Got 0x%x expected 0x%x()"), aGpsOptions.GpsMode(), expectedOptions->GpsMode()); |
|
238 TEST(EFalse); |
|
239 return; |
|
240 } |
|
241 if(aGpsOptions.ClassType() != expectedOptions->ClassType()) |
|
242 { |
|
243 TEST(EFalse); |
|
244 return; |
|
245 } |
|
246 if(aGpsOptions.ClassType() & ELbsGpsOptionsArrayClass) |
|
247 { |
|
248 const TLbsGpsOptionsArray& optionsArr = reinterpret_cast<const TLbsGpsOptionsArray&>(aGpsOptions); |
|
249 const TLbsGpsOptionsArray& expectedOptionsArr = reinterpret_cast<const TLbsGpsOptionsArray&>(*expectedOptions); |
|
250 if(optionsArr.NumOptionItems() != expectedOptionsArr.NumOptionItems()) |
|
251 { |
|
252 TEST(EFalse); |
|
253 return; |
|
254 } |
|
255 for(TInt index = 0; index < optionsArr.NumOptionItems(); ++index) |
|
256 { |
|
257 TLbsGpsOptionsItem item; |
|
258 TLbsGpsOptionsItem expectedItem; |
|
259 optionsArr.GetOptionItem(index, item); |
|
260 expectedOptionsArr.GetOptionItem(index, expectedItem); |
|
261 |
|
262 if(item.PosUpdateType() != expectedItem.PosUpdateType()) |
|
263 { |
|
264 TEST(EFalse); |
|
265 return; |
|
266 } |
|
267 } |
|
268 } |
|
269 } |
|
270 |