|
1 /* |
|
2 * Copyright (c) 2002 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 the License "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: ?Description* |
|
15 */ |
|
16 |
|
17 |
|
18 |
|
19 // INCLUDE FILES |
|
20 #include <e32svr.h> |
|
21 #include <StifParser.h> |
|
22 #include <Stiftestinterface.h> |
|
23 #include "VCXProvisioningTest.h" |
|
24 #include "VCXTestLog.h" |
|
25 #include "CIptvTestUtilities.h" |
|
26 #include <f32file.h> |
|
27 |
|
28 #include "CIptvServices.h" |
|
29 #include "CIptvProvisioningProcessor.h" |
|
30 #include "CIptvServiceManagementClient.h" |
|
31 |
|
32 // EXTERNAL DATA STRUCTURES |
|
33 //extern ?external_data; |
|
34 |
|
35 // EXTERNAL FUNCTION PROTOTYPES |
|
36 //extern ?external_function( ?arg_type,?arg_type ); |
|
37 |
|
38 // CONSTANTS |
|
39 //const ?type ?constant_var = ?constant; |
|
40 |
|
41 // MACROS |
|
42 //#define ?macro ?macro_def |
|
43 |
|
44 // LOCAL CONSTANTS AND MACROS |
|
45 //const ?type ?constant_var = ?constant; |
|
46 //#define ?macro_name ?macro_def |
|
47 |
|
48 // MODULE DATA STRUCTURES |
|
49 //enum ?declaration |
|
50 //typedef ?declaration |
|
51 |
|
52 // LOCAL FUNCTION PROTOTYPES |
|
53 //?type ?function_name( ?arg_type, ?arg_type ); |
|
54 |
|
55 // FORWARD DECLARATIONS |
|
56 //class ?FORWARD_CLASSNAME; |
|
57 |
|
58 // ============================= LOCAL FUNCTIONS =============================== |
|
59 |
|
60 // ----------------------------------------------------------------------------- |
|
61 // ?function_name ?description. |
|
62 // ?description |
|
63 // Returns: ?value_1: ?description |
|
64 // ?value_n: ?description_line1 |
|
65 // ?description_line2 |
|
66 // ----------------------------------------------------------------------------- |
|
67 // |
|
68 /* |
|
69 ?type ?function_name( |
|
70 ?arg_type arg, // ?description |
|
71 ?arg_type arg) // ?description |
|
72 { |
|
73 |
|
74 ?code // ?comment |
|
75 |
|
76 // ?comment |
|
77 ?code |
|
78 } |
|
79 */ |
|
80 |
|
81 // ============================ MEMBER FUNCTIONS =============================== |
|
82 |
|
83 // ----------------------------------------------------------------------------- |
|
84 // CIptvProvisioningTest::Delete |
|
85 // Delete here all resources allocated and opened from test methods. |
|
86 // Called from destructor. |
|
87 // ----------------------------------------------------------------------------- |
|
88 // |
|
89 void CIptvProvisioningTest::Delete() |
|
90 { |
|
91 DeAllocateResources(); |
|
92 } |
|
93 |
|
94 // ----------------------------------------------------------------------------- |
|
95 // CIptvProvisioningTest::RunMethodL |
|
96 // Run specified method. Contains also table of test mothods and their names. |
|
97 // ----------------------------------------------------------------------------- |
|
98 // |
|
99 TInt CIptvProvisioningTest::RunMethodL( |
|
100 CStifItemParser& aItem ) |
|
101 { |
|
102 |
|
103 static TStifFunctionInfo const KFunctions[] = |
|
104 { |
|
105 // Copy this line for every implemented function. |
|
106 // First string is the function name used in TestScripter script file. |
|
107 // Second is the actual implementation member function. |
|
108 ENTRY( "Create", CIptvProvisioningTest::Create ), |
|
109 ENTRY( "Destroy", CIptvProvisioningTest::Destroy ), |
|
110 ENTRY( "EnableVerifying", CIptvProvisioningTest::EnableVerifying ), |
|
111 ENTRY( "Verify", CIptvProvisioningTest::Verify ), |
|
112 ENTRY( "ExternalProvision", CIptvProvisioningTest::ExternalProvision ), |
|
113 ENTRY( "LocalProvision", CIptvProvisioningTest::LocalProvision ), |
|
114 |
|
115 }; |
|
116 |
|
117 const TInt count = sizeof( KFunctions ) / |
|
118 sizeof( TStifFunctionInfo ); |
|
119 |
|
120 return RunInternalL( KFunctions, count, aItem ); |
|
121 |
|
122 } |
|
123 |
|
124 // ----------------------------------------------------------------------------- |
|
125 // CIptvProvisioningTest::Create |
|
126 // Example test method function. |
|
127 // (other items were commented in a header). |
|
128 // ----------------------------------------------------------------------------- |
|
129 // |
|
130 TInt CIptvProvisioningTest::Create( CStifItemParser& /* aItem */ ) |
|
131 { |
|
132 VCXLOGLO1(">>>CIptvProvisioningTest::DestroyL"); |
|
133 // Print to UI |
|
134 _LIT( KIptvProvisioningTest, "IptvProvisioningTest" ); |
|
135 _LIT( KCreate, "In Create" ); |
|
136 TestModuleIf().Printf( 0, KIptvProvisioningTest, KCreate ); |
|
137 // Print to log file |
|
138 iLog->Log( KCreate); |
|
139 |
|
140 // TRAP |
|
141 iIptvProvisioningProcessor = CIptvProvisioningProcessor::NewL(); |
|
142 iIptvTestUtilities = CIptvTestUtilities::NewL(); |
|
143 iIptvServiceManagementClient = CIptvServiceManagementClient::NewL(*this); |
|
144 |
|
145 VCXLOGLO1("<<<CIptvProvisioningTest::DestroyL"); |
|
146 return KErrNone; |
|
147 |
|
148 } |
|
149 |
|
150 // ----------------------------------------------------------------------------- |
|
151 // CIptvProvisioningTest::Destroy |
|
152 // Example test method function. |
|
153 // (other items were commented in a header). |
|
154 // ----------------------------------------------------------------------------- |
|
155 // |
|
156 TInt CIptvProvisioningTest::Destroy( CStifItemParser& /* aItem */ ) |
|
157 { |
|
158 |
|
159 // Print to UI |
|
160 _LIT( KIptvProvisioningTest, "IptvProvisioningTest" ); |
|
161 _LIT( KDestroy, "In Destroy" ); |
|
162 TestModuleIf().Printf( 0, KIptvProvisioningTest, KDestroy ); |
|
163 // Print to log file |
|
164 iLog->Log( KDestroy); |
|
165 |
|
166 DeAllocateResources(); |
|
167 return KErrNone; |
|
168 |
|
169 } |
|
170 |
|
171 |
|
172 // ----------------------------------------------------------------------------- |
|
173 // CIptvProvisioningTest::EnableVerifying(); |
|
174 // ?implementation_description |
|
175 // (other items were commented in a header). |
|
176 // ----------------------------------------------------------------------------- |
|
177 // |
|
178 TInt CIptvProvisioningTest::EnableVerifying( CStifItemParser& aItem ) |
|
179 { |
|
180 VCXLOGLO1(">>>CIptvProvisioningTest::EnableVerifying"); |
|
181 // Print to UI |
|
182 _LIT( KIptvProvisioningTest, "CIptvProvisioningTest" ); |
|
183 _LIT( KEnableVerifying , "In EnableVerifying" ); |
|
184 TestModuleIf().Printf( 0, KIptvProvisioningTest, KEnableVerifying ); |
|
185 // Print to log file |
|
186 iLog->Log( KEnableVerifying ); |
|
187 |
|
188 //Script parameters |
|
189 |
|
190 TInt result = KErrNone; |
|
191 |
|
192 TPtrC caseId; |
|
193 |
|
194 TBool IsParametersValid = ETrue; |
|
195 |
|
196 //Script parameters |
|
197 if(aItem.GetNextString(caseId) != KErrNone) |
|
198 { |
|
199 IsParametersValid = EFalse; |
|
200 } |
|
201 |
|
202 TInt appendInt = 0; |
|
203 TBool append = EFalse; |
|
204 if(aItem.GetNextInt(appendInt) == KErrNone) |
|
205 { |
|
206 append = static_cast<TBool>(appendInt); |
|
207 } |
|
208 |
|
209 if(!IsParametersValid) |
|
210 { |
|
211 VCXLOGLO1("Error in testparameters"); |
|
212 iLog->Log(_L("Error in testparameters")); |
|
213 result = KErrGeneral; |
|
214 } |
|
215 else |
|
216 { |
|
217 iCaseId = caseId; |
|
218 iIptvTestUtilities->CreateVerifyData(iCaseId, append); |
|
219 } |
|
220 |
|
221 VCXLOGLO1("<<<CIptvProvisioningTest::EnableVerifying"); |
|
222 return result; |
|
223 } |
|
224 |
|
225 |
|
226 // ----------------------------------------------------------------------------- |
|
227 // CIptvProvisioningTest::Verify |
|
228 // Example test method function. |
|
229 // (other items were commented in a header). |
|
230 // ----------------------------------------------------------------------------- |
|
231 // |
|
232 TInt CIptvProvisioningTest::Verify( CStifItemParser& aItem ) |
|
233 { |
|
234 VCXLOGLO1(">>>CIptvProvisioningTest::Verify"); |
|
235 // Print to UI |
|
236 _LIT( KIptvProvisioningTest, "CIptvProvisioningTest" ); |
|
237 _LIT( KVerify , "In Verify" ); |
|
238 TestModuleIf().Printf( 0, KIptvProvisioningTest, KVerify ); |
|
239 // Print to log file |
|
240 iLog->Log( KVerify ); |
|
241 |
|
242 TInt paramCount = 0; |
|
243 TPtrC caseId; |
|
244 TInt error = KErrNone; |
|
245 while(aItem.GetNextString(caseId) == KErrNone) |
|
246 { |
|
247 paramCount++; |
|
248 VCXLOGLO2("Verifying: %S.", &caseId); |
|
249 CIptvTestVerifyData::TVerifyResult verifyResult; |
|
250 error = iIptvTestUtilities->VerifyData(caseId, verifyResult); |
|
251 if(verifyResult != CIptvTestVerifyData::EVerifyOk) |
|
252 { |
|
253 VCXLOGLO3("Verify failed, VerifyResult: %d, err: %d", verifyResult, error); |
|
254 TestModuleIf().Printf( 0, _L("Verify failed"), _L("") ); |
|
255 error = verifyResult; |
|
256 } |
|
257 else |
|
258 { |
|
259 VCXLOGLO1("Data verified succesfully."); |
|
260 } |
|
261 } |
|
262 |
|
263 if(paramCount == 0) |
|
264 { |
|
265 error = KErrGeneral; |
|
266 VCXLOGLO1("Test case logic error, no CaseId(s) defined for verification.."); |
|
267 } |
|
268 |
|
269 |
|
270 VCXLOGLO1("<<<CIptvProvisioningTest::Verify"); |
|
271 return error; |
|
272 } |
|
273 |
|
274 |
|
275 // ----------------------------------------------------------------------------- |
|
276 // CIptvProvisioningTest::ExternalProvision |
|
277 // Example test method function. |
|
278 // (other items were commented in a header). |
|
279 // ----------------------------------------------------------------------------- |
|
280 // |
|
281 TInt CIptvProvisioningTest::ExternalProvision( CStifItemParser& aItem ) |
|
282 { |
|
283 VCXLOGLO1(">>>CIptvProvisioningTest::ExternalProvision"); |
|
284 // Print to UI |
|
285 _LIT( KIptvProvisioningTest, "IptvProvisioningTest" ); |
|
286 _LIT( KExternalProvision, "In ExternalProvision" ); |
|
287 TestModuleIf().Printf( 0, KIptvProvisioningTest, KExternalProvision ); |
|
288 // Print to log file |
|
289 iLog->Log( KExternalProvision); |
|
290 |
|
291 |
|
292 TInt i=0; |
|
293 TInt error = KErrNone; |
|
294 TPtrC fileName; |
|
295 |
|
296 //services from provisioning xml |
|
297 CIptvServices* pIptvServices = NULL; |
|
298 CIptvService* pIptvService = NULL; |
|
299 |
|
300 //Allow quotes in cfg file |
|
301 aItem.SetParsingType(CStifItemParser::EQuoteStyleParsing); |
|
302 |
|
303 //Get xml -filename of the xml file |
|
304 aItem.GetNextString(fileName); |
|
305 |
|
306 TInt checkSchemaValidity = 0; |
|
307 if(KErrNone != aItem.GetNextInt(checkSchemaValidity)) |
|
308 { |
|
309 checkSchemaValidity = 0; |
|
310 } |
|
311 |
|
312 RFs session; |
|
313 RFile fileHandle; |
|
314 |
|
315 error = session.Connect(); |
|
316 |
|
317 if (error != KErrNone) |
|
318 { |
|
319 VCXLOGLO2("CIptvProvisioningTest::ExternalProvision, can't create RFs session, error %d", error); |
|
320 VCXLOGLO1("<<<CIptvProvisioningTest::ExternalProvision"); |
|
321 return error; |
|
322 } |
|
323 |
|
324 TInt err = KErrNone; |
|
325 |
|
326 //invalid handle case |
|
327 if(fileName.Compare(_L("Invalid handle"))==0) |
|
328 { |
|
329 TRAP(err, pIptvServices = iIptvProvisioningProcessor->ExternalProvisionL(fileHandle, error)); |
|
330 } |
|
331 else //open the file to get valid handle |
|
332 { |
|
333 |
|
334 // check the xml schema if specified |
|
335 /*error = CheckIptvXmlSchema(fileName); |
|
336 if(checkSchemaValidity && KErrNone != error) |
|
337 { |
|
338 VCXLOGLO1("<<<CIptvProvisioningTest::ExternalProvision"); |
|
339 session.Close(); |
|
340 return error; |
|
341 }*/ |
|
342 |
|
343 error = fileHandle.Open( session, fileName, EFileRead ); |
|
344 } |
|
345 |
|
346 if (error != KErrNone) |
|
347 { |
|
348 VCXLOGLO2("CIptvProvisioningTest::ExternalProvision, file can't be opened, response error %d", error); |
|
349 session.Close(); |
|
350 VCXLOGLO1("<<<CIptvProvisioningTest::ExternalProvision"); |
|
351 return error; |
|
352 } |
|
353 |
|
354 if (err != KErrNone) |
|
355 { |
|
356 VCXLOGLO2("CIptvProvisioningTest::ExternalProvision, file can't be opened, ExternalProvisionL left: %d", err); |
|
357 session.Close(); |
|
358 VCXLOGLO1("<<<CIptvProvisioningTest::ExternalProvision"); |
|
359 return err; |
|
360 } |
|
361 |
|
362 |
|
363 //Read services from xml file to CIptvServices -classes |
|
364 TRAP(err, pIptvServices = iIptvProvisioningProcessor->ExternalProvisionL(fileHandle,error)); |
|
365 if(err != KErrNone) |
|
366 { |
|
367 VCXLOGLO2("ExternalProvisionL left, err = %d",err); |
|
368 } |
|
369 else if(error != KErrNone) |
|
370 { |
|
371 VCXLOGLO2("ExternalProvisionL failed, error = %d",error); |
|
372 } |
|
373 else //ExternalProvisionL succeeded |
|
374 { |
|
375 CleanupStack::PushL(pIptvServices); |
|
376 |
|
377 VCXLOGLO2("Count = %d",pIptvServices->Count()); |
|
378 for(i = 0; i < pIptvServices->Count();i++) |
|
379 { |
|
380 pIptvService = pIptvServices->GetServiceL(i); |
|
381 CleanupStack::PushL(pIptvService); |
|
382 iIptvTestUtilities->PrintIptvService(pIptvService); |
|
383 iIptvTestUtilities->WriteVerifyIptvService(iCaseId, pIptvService); |
|
384 //Add service to db |
|
385 error = AddService(*pIptvService); |
|
386 CleanupStack::PopAndDestroy(pIptvService); |
|
387 } |
|
388 CleanupStack::PopAndDestroy(pIptvServices); |
|
389 } |
|
390 |
|
391 fileHandle.Close(); |
|
392 session.Close(); |
|
393 |
|
394 VCXLOGLO1("<<<CIptvProvisioningTest::ExternalProvision"); |
|
395 return error; |
|
396 |
|
397 } |
|
398 |
|
399 |
|
400 |
|
401 // ----------------------------------------------------------------------------- |
|
402 // CIptvProvisioningTest::LocalProvision |
|
403 // Example test method function. |
|
404 // (other items were commented in a header). |
|
405 // ----------------------------------------------------------------------------- |
|
406 // |
|
407 TInt CIptvProvisioningTest::LocalProvision( CStifItemParser& aItem ) |
|
408 { |
|
409 VCXLOGLO1(">>>CIptvProvisioningTest::LocalProvision"); |
|
410 // Print to UI |
|
411 _LIT( KIptvProvisioningTest, "IptvProvisioningTest" ); |
|
412 _LIT( KLocalProvision, "In DestrLocalProvisionoy" ); |
|
413 TestModuleIf().Printf( 0, KIptvProvisioningTest, KLocalProvision ); |
|
414 // Print to log file |
|
415 iLog->Log( KLocalProvision); |
|
416 |
|
417 TInt i=0; |
|
418 TPtrC fileName; |
|
419 TInt rv(KErrNone); |
|
420 //services from provisioning xml |
|
421 CIptvServices* pIptvServices = NULL; |
|
422 CIptvService* pIptvService = NULL; |
|
423 |
|
424 TInt error(KErrNone); |
|
425 |
|
426 //Allow quotes in cfg file |
|
427 aItem.SetParsingType(CStifItemParser::EQuoteStyleParsing); |
|
428 |
|
429 //Get xml -filename of the xml file |
|
430 aItem.GetNextString(fileName); |
|
431 |
|
432 TInt checkSchemaValidity = 0; |
|
433 if(KErrNone != aItem.GetNextInt(checkSchemaValidity)) |
|
434 { |
|
435 checkSchemaValidity = 0; |
|
436 } |
|
437 |
|
438 // check the xml schema if specified |
|
439 error = CheckIptvXmlSchema(fileName); |
|
440 if(checkSchemaValidity && KErrNone != error) |
|
441 { |
|
442 VCXLOGLO1("<<<CIptvProvisioningTest::ExternalProvision"); |
|
443 return error; |
|
444 } |
|
445 |
|
446 TRAPD(err,pIptvServices = iIptvProvisioningProcessor->LocalProvisionL(fileName,error)); |
|
447 |
|
448 if(err != KErrNone) |
|
449 { |
|
450 VCXLOGLO2("LocalProvisionL left, err = %d",err); |
|
451 rv = err; |
|
452 } |
|
453 else if(error != KErrNone) |
|
454 { |
|
455 VCXLOGLO2("LocalProvisionL failed, error = %d",error); |
|
456 rv = error; |
|
457 } |
|
458 else //LocalProvisionL succeeded |
|
459 { |
|
460 CleanupStack::PushL(pIptvServices); |
|
461 |
|
462 VCXLOGLO2("services in xml = %d",pIptvServices->Count()); |
|
463 for(i = 0; i < pIptvServices->Count();i++) |
|
464 { |
|
465 pIptvService = pIptvServices->GetServiceL(i); |
|
466 CleanupStack::PushL(pIptvService); |
|
467 |
|
468 iIptvTestUtilities->PrintIptvService(pIptvService); |
|
469 iIptvTestUtilities->WriteVerifyIptvService(iCaseId, pIptvService); |
|
470 |
|
471 //Add service to db |
|
472 rv = AddService(*pIptvService); |
|
473 |
|
474 CleanupStack::PopAndDestroy(pIptvService); |
|
475 } |
|
476 CleanupStack::PopAndDestroy(pIptvServices); |
|
477 } |
|
478 |
|
479 VCXLOGLO1("<<<CIptvProvisioningTest::LocalProvision"); |
|
480 return rv; |
|
481 |
|
482 } |
|
483 // ----------------------------------------------------------------------------- |
|
484 // CIptvProvisioningTest::AddService |
|
485 // Example test method function. |
|
486 // (other items were commented in a header). |
|
487 // ----------------------------------------------------------------------------- |
|
488 // |
|
489 |
|
490 TInt CIptvProvisioningTest::AddService(CIptvService& aService) |
|
491 { |
|
492 VCXLOGLO1(">>>CIptvProvisioningTest::AddService"); |
|
493 TInt rv = 0; |
|
494 MIptvServiceManagementClientObserver::TRespStatus respStatus = ESucceeded; |
|
495 |
|
496 TRAPD(error, rv = iIptvServiceManagementClient->AddServiceL(aService,respStatus)); |
|
497 |
|
498 if(error != KErrNone) |
|
499 { |
|
500 VCXLOGLO2("iIptvServiceManagementClient->AddServiceL() failed, error = %d", error); |
|
501 rv = error; |
|
502 } |
|
503 else if(respStatus != ESucceeded) |
|
504 { |
|
505 VCXLOGLO2("iIptvServiceManagementClient->AddServiceL() failed, error = %d", respStatus); |
|
506 rv = KErrGeneral; |
|
507 } |
|
508 |
|
509 VCXLOGLO1(">>>CIptvProvisioningTest::AddService"); |
|
510 return rv; |
|
511 } |
|
512 |
|
513 TInt CIptvProvisioningTest::CheckIptvXmlSchema( TDesC& aFileName ) |
|
514 { |
|
515 // No need to check by tests. |
|
516 return KErrNone; |
|
517 } |
|
518 |
|
519 // ----------------------------------------------------------------------------- |
|
520 // CIptvProvisioningTest::DeAllocateResources |
|
521 // Example test method function. |
|
522 // (other items were commented in a header). |
|
523 // ----------------------------------------------------------------------------- |
|
524 // |
|
525 |
|
526 void CIptvProvisioningTest::DeAllocateResources() |
|
527 { |
|
528 VCXLOGLO1(">>>CIptvProvisioningTest::DeAllocateResources"); |
|
529 if(iIptvProvisioningProcessor) |
|
530 { |
|
531 delete iIptvProvisioningProcessor; |
|
532 iIptvProvisioningProcessor = NULL; |
|
533 } |
|
534 |
|
535 if(iIptvTestUtilities) |
|
536 { |
|
537 delete iIptvTestUtilities; |
|
538 iIptvTestUtilities = NULL; |
|
539 } |
|
540 |
|
541 if(iIptvServiceManagementClient) |
|
542 { |
|
543 delete iIptvServiceManagementClient; |
|
544 iIptvServiceManagementClient = NULL; |
|
545 } |
|
546 |
|
547 VCXLOGLO1(">>>CIptvProvisioningTest::DeAllocateResources"); |
|
548 } |
|
549 |
|
550 /***** Callbakcs *********/ |
|
551 /*void CIptvProvisioningTest::Notify(TInt aNotification) |
|
552 { |
|
553 |
|
554 }*/ |
|
555 // ----------------------------------------------------------------------------- |
|
556 // CIptvProvisioningTest::?member_function |
|
557 // ?implementation_description |
|
558 // (other items were commented in a header). |
|
559 // ----------------------------------------------------------------------------- |
|
560 // |
|
561 /* |
|
562 TInt CIptvProvisioningTest::?member_function( |
|
563 CItemParser& aItem ) |
|
564 { |
|
565 |
|
566 ?code |
|
567 |
|
568 } |
|
569 */ |
|
570 |
|
571 // ========================== OTHER EXPORTED FUNCTIONS ========================= |
|
572 // None |
|
573 |
|
574 // End of File |