|
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 "IptvServiceManagementApiTest.h" |
|
24 #include "CIptvServiceManagementSync.h" |
|
25 #include "CIptvTestUtilities.h" |
|
26 #include "CIptvTestMobilecrashWatcher.h" |
|
27 #include "VCXTestLog.h" |
|
28 #include <f32file.h> |
|
29 #include <S32FILE.H> |
|
30 #include "IptvTestUtilALR.h" |
|
31 |
|
32 #include <mmf/common/mmfcontrollerpluginresolver.h> |
|
33 #include "../../../server/IptvScheduledDownload/inc/iptvvodscheduleddownloaddefinitions.h" |
|
34 |
|
35 #include "CIptvTestServiceStore.h" |
|
36 |
|
37 //#include <commdb.h> |
|
38 |
|
39 // EXTERNAL DATA STRUCTURES |
|
40 |
|
41 // EXTERNAL FUNCTION PROTOTYPES |
|
42 |
|
43 // CONSTANTS |
|
44 |
|
45 // MACROS |
|
46 |
|
47 // LOCAL CONSTANTS AND MACROS |
|
48 |
|
49 // MODULE DATA STRUCTURES |
|
50 |
|
51 // LOCAL FUNCTION PROTOTYPES |
|
52 |
|
53 // FORWARD DECLARATIONS |
|
54 |
|
55 |
|
56 // ============================= LOCAL FUNCTIONS =============================== |
|
57 |
|
58 // ============================ MEMBER FUNCTIONS =============================== |
|
59 |
|
60 // ----------------------------------------------------------------------------- |
|
61 // CIptvServiceManagementApiTest::Delete |
|
62 // Delete here all resources allocated and opened from test methods. |
|
63 // Called from destructor. |
|
64 // ----------------------------------------------------------------------------- |
|
65 // |
|
66 void CIptvServiceManagementApiTest::Delete() |
|
67 { |
|
68 DeAllocateResources(); |
|
69 } |
|
70 |
|
71 // ----------------------------------------------------------------------------- |
|
72 // CIptvServiceManagementApiTest::RunMethodL |
|
73 // Run specified method. Contains also table of test mothods and their names. |
|
74 // ----------------------------------------------------------------------------- |
|
75 // |
|
76 TInt CIptvServiceManagementApiTest::RunMethodL( |
|
77 CStifItemParser& aItem ) |
|
78 { |
|
79 |
|
80 static TStifFunctionInfo const KFunctions[] = |
|
81 { |
|
82 // Copy this line for every implemented function. |
|
83 // First string is the function name used in TestScripter script file. |
|
84 // Second is the actual implementation member function. |
|
85 ENTRY( "Create", CIptvServiceManagementApiTest::CreateL ), |
|
86 ENTRY( "AddHardCodedService", CIptvServiceManagementApiTest::AddHardCodedServiceL ), |
|
87 ENTRY( "UpdateService", CIptvServiceManagementApiTest::UpdateServiceL ), |
|
88 ENTRY( "UpdateServiceField", CIptvServiceManagementApiTest::UpdateServiceFieldL ), |
|
89 ENTRY( "DeleteService", CIptvServiceManagementApiTest::DeleteServiceL ), |
|
90 ENTRY( "DeleteAllServices", CIptvServiceManagementApiTest::DeleteAllServicesL ), |
|
91 ENTRY( "GetServices", CIptvServiceManagementApiTest::GetServicesL ), |
|
92 ENTRY( "GetServicesByProviderId", CIptvServiceManagementApiTest::GetServicesByProviderIdL ), |
|
93 ENTRY( "GetAllSelectedServices", CIptvServiceManagementApiTest::GetAllSelectedServicesL ), // GetFilteredServices should be used |
|
94 ENTRY( "GetServicesFiltered", CIptvServiceManagementApiTest::GetServicesFilteredL ), |
|
95 ENTRY( "GetServicesByType", CIptvServiceManagementApiTest::GetServicesByTypeL ), |
|
96 ENTRY( "ShutdownServer", CIptvServiceManagementApiTest::ShutdownServerL ), |
|
97 ENTRY( "SetUsedIap", CIptvServiceManagementApiTest::SetUsedIap ), |
|
98 ENTRY( "GetUsedIap", CIptvServiceManagementApiTest::GetUsedIap ), |
|
99 ENTRY( "ClearUsedIap", CIptvServiceManagementApiTest::ClearUsedIapL ), |
|
100 ENTRY( "SetAllIaps", CIptvServiceManagementApiTest::SetAllIapsL ), |
|
101 ENTRY( "SetConnectionAllowed", CIptvServiceManagementApiTest::SetConnectionAllowedL ), |
|
102 ENTRY( "IsConnectionAllowed", CIptvServiceManagementApiTest::IsConnectionAllowedL ), |
|
103 ENTRY( "VerifyServerIsShutdown", CIptvServiceManagementApiTest::VerifyServerIsShutdownL ), |
|
104 ENTRY( "SetSpecialAction", CIptvServiceManagementApiTest::SetSpecialAction), |
|
105 ENTRY( "RepeatNextRequest", CIptvServiceManagementApiTest::RepeatNextRequest), |
|
106 |
|
107 ENTRY( "DeleteServicesDb", CIptvServiceManagementApiTest::Dummy), |
|
108 ENTRY( "Cleanup", CIptvServiceManagementApiTest::Dummy), |
|
109 ENTRY( "Initialize", CIptvServiceManagementApiTest::Dummy), |
|
110 |
|
111 ENTRY( "Destroy", CIptvServiceManagementApiTest::DestroyL ), |
|
112 }; |
|
113 |
|
114 const TInt count = sizeof( KFunctions ) / |
|
115 sizeof( TStifFunctionInfo ); |
|
116 |
|
117 return RunInternalL( KFunctions, count, aItem ); |
|
118 |
|
119 } |
|
120 /*****************************************************/ |
|
121 /*************** Test methods *****************/ |
|
122 /*****************************************************/ |
|
123 |
|
124 // ----------------------------------------------------------------------------- |
|
125 // CIptvServiceManagementApiTest::CreateL |
|
126 // ----------------------------------------------------------------------------- |
|
127 // |
|
128 TInt CIptvServiceManagementApiTest::CreateL( CStifItemParser& /* aItem */ ) |
|
129 { |
|
130 VCXLOGLO1(">>>CIptvServiceManagementApiTest::CreateL"); |
|
131 // Print to UI |
|
132 _LIT( KIptvServiceManagementApiTest, "IptvServiceManagementApiTest" ); |
|
133 _LIT( KCreate, "In Create" ); |
|
134 TestModuleIf().Printf( 0, KIptvServiceManagementApiTest, KCreate ); |
|
135 // Print to log file |
|
136 iLog->Log( KCreate ); |
|
137 |
|
138 TInt err = KErrNone; |
|
139 |
|
140 TRAP(err, iIptvTestMobilecrashWatcher = CIptvTestMobilecrashWatcher::NewL() ); |
|
141 if(KErrNone != err)//Leave |
|
142 { |
|
143 if(iIptvTestMobilecrashWatcher) |
|
144 { |
|
145 delete iIptvTestMobilecrashWatcher; |
|
146 iIptvTestMobilecrashWatcher = NULL; |
|
147 } |
|
148 VCXLOGLO1("Leave in creating iIptvTestMobilecrashWatcher instance"); |
|
149 return err; |
|
150 } |
|
151 |
|
152 TRAP(err, iIptvServiceManagementSync = CIptvServiceManagementSync::NewL() ); |
|
153 if(err != KErrNone) |
|
154 { |
|
155 VCXLOGLO1("CIptvServiceManagementApiTest:: ** FAIL ** Creating CIptvServiceManagementSync failed!"); |
|
156 VCXLOGLO1("<<<CIptvServiceManagementApiTest::CreateL"); |
|
157 return err; |
|
158 } |
|
159 |
|
160 CDesC8ArraySeg* servicesArrayDesc = NULL; |
|
161 |
|
162 // This will execute the possible provisioning of services.xml |
|
163 TRespStatus respStatus = iIptvServiceManagementSync->CallGetServices(CIptvServiceManagementSync::EIptvSmTestSync, 0, 10, &servicesArrayDesc); |
|
164 if(respStatus == ESucceeded) |
|
165 { |
|
166 servicesArrayDesc->Reset(); |
|
167 delete servicesArrayDesc; |
|
168 servicesArrayDesc = NULL; |
|
169 } |
|
170 |
|
171 // Wait for the provisioning events |
|
172 iIptvServiceManagementSync->WaitForProvisioningEvents(); |
|
173 |
|
174 TRAP(err, iIptvTestUtilities = CIptvTestUtilities::NewL() ); |
|
175 if(err != KErrNone) |
|
176 { |
|
177 VCXLOGLO1("CIptvServiceManagementApiTest:: ** FAIL ** Creating CIptvTestUtilities failed!"); |
|
178 VCXLOGLO1("<<<CIptvServiceManagementApiTest::CreateL"); |
|
179 return err; |
|
180 } |
|
181 |
|
182 iServiceStore = CIptvTestServiceStore::NewL(NULL, iIptvTestUtilities); |
|
183 |
|
184 // Construct list of iaps |
|
185 |
|
186 iIapNumList = new (ELeave) CArrayFixFlat<TUint32>(30); |
|
187 |
|
188 TBuf<1024> iapName; |
|
189 |
|
190 for(TInt id=0;id<20;id++) |
|
191 { |
|
192 // If there's iap with the id then add it |
|
193 iapName.Zero(); |
|
194 if(iIptvTestUtilities->GetIapNameById(iapName, id) ) |
|
195 { |
|
196 iIapNumList->AppendL(id); |
|
197 } |
|
198 } |
|
199 |
|
200 iAlrUtil = CIptvTestUtilALR::NewL(); |
|
201 |
|
202 VCXLOGLO1("<<<CIptvServiceManagementApiTest::CreateL"); |
|
203 return KErrNone; |
|
204 } |
|
205 // ----------------------------------------------------------------------------- |
|
206 // CIptvServiceManagementApiTest::DestroyL |
|
207 // ----------------------------------------------------------------------------- |
|
208 // |
|
209 TInt CIptvServiceManagementApiTest::DestroyL( CStifItemParser& /*aItem*/ ) |
|
210 { |
|
211 VCXLOGLO1(">>>CIptvServiceManagementApiTest::DestroyL"); |
|
212 // Print to UI |
|
213 _LIT( KIptvServiceManagementApiTest, "IptvServiceManagementApiTest" ); |
|
214 _LIT( KDestroy, "In Destroy" ); |
|
215 TestModuleIf().Printf( 0, KIptvServiceManagementApiTest, KDestroy ); |
|
216 // Print to log file |
|
217 iLog->Log( KDestroy ); |
|
218 |
|
219 DeAllocateResources(); |
|
220 |
|
221 VCXLOGLO1("<<<CIptvServiceManagementApiTest::DestroyL"); |
|
222 return KErrNone; |
|
223 } |
|
224 |
|
225 // ----------------------------------------------------------------------------- |
|
226 // CIptvServiceManagementApiTest::Dummy |
|
227 // ----------------------------------------------------------------------------- |
|
228 // |
|
229 TInt CIptvServiceManagementApiTest::Dummy( CStifItemParser& /*aItem*/ ) |
|
230 { |
|
231 return KErrNone; |
|
232 } |
|
233 |
|
234 // ----------------------------------------------------------------------------- |
|
235 // CIptvServiceManagementApiTest::AddHardCodedServiceL |
|
236 // ----------------------------------------------------------------------------- |
|
237 // |
|
238 TInt CIptvServiceManagementApiTest::AddHardCodedServiceL( CStifItemParser& aItem ) |
|
239 { |
|
240 VCXLOGLO1(">>>CIptvServiceManagementApiTest::AddHardCodedServiceL"); |
|
241 // Print to UI |
|
242 _LIT( KIptvServiceManagementApiTest, "IptvServiceManagementApiTest" ); |
|
243 _LIT( KAddHardCodedService, "In AddHardCodedService" ); |
|
244 TestModuleIf().Printf( 0, KIptvServiceManagementApiTest, KAddHardCodedService ); |
|
245 // Print to log file |
|
246 iLog->Log( KAddHardCodedService ); |
|
247 |
|
248 TInt msgTypeInt = 0; |
|
249 TPtrC serviceToAdd; |
|
250 TInt loopCnt = 1; // Default loop once |
|
251 TInt iapsToAdd = 0; |
|
252 TInt expectedServiceId = -1; |
|
253 TBool iapNameSpecified = EFalse; |
|
254 TPtrC iapName; |
|
255 TRespStatus respStatus = ESucceeded; |
|
256 TRespStatus expectedRespStatus = ESucceeded; |
|
257 TInt rv = KErrNone; |
|
258 |
|
259 CIptvService* iptvService = NULL; |
|
260 |
|
261 // Read parameters |
|
262 |
|
263 aItem.SetParsingType(CStifItemParser::EQuoteStyleParsing); |
|
264 |
|
265 aItem.GetNextInt(msgTypeInt); |
|
266 aItem.GetNextString(serviceToAdd); |
|
267 if(KErrNone != aItem.GetNextString(iapName) ) |
|
268 { |
|
269 VCXLOGLO1("** FAIL ** Invalid testcase parameter! Iap name or count was not specified."); |
|
270 VCXLOGLO1("<<<CIptvServiceManagementApiTest::AddHardCodedServiceL"); |
|
271 return KErrArgument; |
|
272 } |
|
273 |
|
274 TLex lex(iapName); |
|
275 if( KErrNone != lex.Val(iapsToAdd) ) |
|
276 { |
|
277 iapNameSpecified = ETrue; |
|
278 } |
|
279 |
|
280 aItem.GetNextInt(loopCnt); |
|
281 |
|
282 VCXLOGLO2("MsgType: %d", msgTypeInt); |
|
283 VCXLOGLO2("ServiceNumberToAdd: %S", &serviceToAdd); |
|
284 VCXLOGLO2("IapsToAdd: %d", iapsToAdd); |
|
285 VCXLOGLO2("IapName: %d", &iapName); |
|
286 VCXLOGLO2("LoopCount: %d", loopCnt); |
|
287 VCXLOGLO2("ExpectedServiceId: %d", expectedServiceId); |
|
288 |
|
289 if(loopCnt < 0 || msgTypeInt < 0 || msgTypeInt > 1) |
|
290 { |
|
291 VCXLOGLO1("** FAIL **Invalid testcase parameter!"); |
|
292 VCXLOGLO1("<<<CIptvServiceManagementApiTest::AddHardCodedServiceL"); |
|
293 return KErrArgument; |
|
294 } |
|
295 |
|
296 CIptvServiceManagementSync::TIptvSmTestConnection msgType = static_cast<CIptvServiceManagementSync::TIptvSmTestConnection>(msgTypeInt); |
|
297 |
|
298 // No full verifying when request is repeated |
|
299 |
|
300 TUint repeatRequest = iIptvServiceManagementSync->GetRepeatNextRequestCount(); |
|
301 |
|
302 for(TInt i = 0; i < loopCnt; i++) |
|
303 { |
|
304 VCXLOGLO2("loop %d",i); |
|
305 |
|
306 // Create service |
|
307 |
|
308 if(iapNameSpecified) |
|
309 iptvService = GetHardcodedService(serviceToAdd, iapName); |
|
310 else |
|
311 iptvService = GetHardcodedService(serviceToAdd, iapsToAdd); |
|
312 |
|
313 if(iptvService == NULL) |
|
314 { |
|
315 VCXLOGLO1("** FAIL ** Invalid params? GetHardcodedService failed"); |
|
316 rv = KErrArgument; |
|
317 break; |
|
318 } |
|
319 |
|
320 CleanupStack::PushL(iptvService); |
|
321 |
|
322 // Check provider ID |
|
323 |
|
324 TBuf<512> newProviderId(iptvService->GetProviderId()); |
|
325 |
|
326 iServiceStore->RefreshServicesFromDbL(KNoFilter, KNoSort); |
|
327 |
|
328 RPointerArray<CIptvService> services; |
|
329 iServiceStore->GetServicesByProviderId(services, newProviderId); |
|
330 |
|
331 // If there's already service(s) with the provider ID, create an unique ID |
|
332 if(services.Count() > 0) |
|
333 { |
|
334 TUint32 lastServiceId (0); |
|
335 |
|
336 if(iServiceStore->ServiceCount() >= 1) |
|
337 { |
|
338 lastServiceId = iServiceStore->GetService( iServiceStore->ServiceCount()-1 )->GetId(); |
|
339 newProviderId.AppendNum(lastServiceId); |
|
340 } |
|
341 |
|
342 iptvService->SetProviderId(newProviderId); |
|
343 } |
|
344 |
|
345 services.Reset(); |
|
346 |
|
347 // Do the request |
|
348 |
|
349 respStatus = iIptvServiceManagementSync->CallAddService(msgType, *iptvService); |
|
350 |
|
351 if(respStatus != expectedRespStatus) |
|
352 { |
|
353 rv = respStatus; |
|
354 break; |
|
355 } |
|
356 |
|
357 // Verify |
|
358 CIptvTestServiceStore* oldServices = CIptvTestServiceStore::NewL( iServiceStore ); |
|
359 CleanupStack::PushL(oldServices); |
|
360 |
|
361 oldServices->AddServiceL( *iptvService ); |
|
362 |
|
363 iServiceStore->RefreshServicesFromDbL(KNoFilter, KNoSort); |
|
364 iServiceStore->PrintServices(); |
|
365 |
|
366 rv = iServiceStore->Compare( *oldServices ); |
|
367 if(rv != KErrNone) |
|
368 { |
|
369 break; |
|
370 } |
|
371 |
|
372 CleanupStack::PopAndDestroy(oldServices); |
|
373 CleanupStack::PopAndDestroy(iptvService); |
|
374 } |
|
375 |
|
376 VCXLOGLO1("<<<CIptvServiceManagementApiTest::AddHardCodedServiceL"); |
|
377 return rv; |
|
378 } |
|
379 |
|
380 // ----------------------------------------------------------------------------- |
|
381 // CIptvServiceManagementApiTest::UpdateServiceL |
|
382 // ----------------------------------------------------------------------------- |
|
383 // |
|
384 TInt CIptvServiceManagementApiTest::UpdateServiceL( CStifItemParser& aItem ) |
|
385 { |
|
386 VCXLOGLO1(">>>CIptvServiceManagementApiTest::UpdateServiceL"); |
|
387 // Print to UI |
|
388 _LIT( KIptvServiceManagementApiTest, "IptvServiceManagementApiTest" ); |
|
389 _LIT( KUpdateService, "In UpdateService" ); |
|
390 TestModuleIf().Printf( 0, KIptvServiceManagementApiTest, KUpdateService ); |
|
391 // Print to log file |
|
392 iLog->Log( KUpdateService ); |
|
393 |
|
394 TInt msgTypeInt(0); |
|
395 TInt destinationId(0); |
|
396 TInt sourceId(0); |
|
397 TBuf<256> destinationName; |
|
398 TBuf<256> sourceName; |
|
399 TInt rv = KErrNone; |
|
400 TPtrC service1, service2; |
|
401 |
|
402 // Read parameters |
|
403 |
|
404 aItem.SetParsingType(CStifItemParser::EQuoteStyleParsing); |
|
405 |
|
406 aItem.GetNextInt(msgTypeInt); |
|
407 |
|
408 rv = GetServiceIdFromParam(aItem, destinationId, destinationName); |
|
409 if(rv != KErrNone) |
|
410 { |
|
411 VCXLOGLO1("<<<CIptvServiceManagementApiTest::UpdateServiceL"); |
|
412 return rv; |
|
413 } |
|
414 rv = GetServiceIdFromParam(aItem, sourceId, sourceName); |
|
415 if(rv != KErrNone) |
|
416 { |
|
417 VCXLOGLO1("<<<CIptvServiceManagementApiTest::UpdateServiceL"); |
|
418 return rv; |
|
419 } |
|
420 |
|
421 iServiceStore->RefreshServicesFromDbL(KNoFilter, KNoSort); |
|
422 |
|
423 if(sourceId == KLastServiceInDb) |
|
424 { |
|
425 sourceId = iServiceStore->GetService( iServiceStore->ServiceCount()-1 )->GetId(); |
|
426 sourceName = iServiceStore->GetService( iServiceStore->ServiceCount()-1 )->GetName(); |
|
427 } |
|
428 |
|
429 VCXLOGLO2("destinationId = %d", destinationId ); |
|
430 VCXLOGLO2("destinationName = %S", &destinationName ); |
|
431 VCXLOGLO2("sourceId = %d", sourceId ); |
|
432 VCXLOGLO2("sourceName = %S", &sourceName ); |
|
433 |
|
434 if(destinationId < 0 || sourceId < 0 || msgTypeInt < 0 || msgTypeInt > 1) |
|
435 { |
|
436 VCXLOGLO1("** FAIL ** Invalid testcase parameter!"); |
|
437 VCXLOGLO1("<<<CIptvServiceManagementApiTest::UpdateServiceL"); |
|
438 return KErrArgument; |
|
439 } |
|
440 |
|
441 CIptvServiceManagementSync::TIptvSmTestConnection msgType = static_cast<CIptvServiceManagementSync::TIptvSmTestConnection>(msgTypeInt); |
|
442 |
|
443 // Do the request |
|
444 |
|
445 rv = TestUpdateService(msgType, destinationId, sourceId); |
|
446 if(rv == KErrNone) |
|
447 { |
|
448 |
|
449 // Verify |
|
450 |
|
451 CIptvTestServiceStore* oldServices = CIptvTestServiceStore::NewL( iServiceStore ); |
|
452 CleanupStack::PushL(oldServices); |
|
453 |
|
454 iServiceStore->RefreshServicesFromDbL(KNoFilter, KNoSort); |
|
455 |
|
456 VCXLOGLO1("Services before: "); |
|
457 oldServices->PrintServices(); |
|
458 VCXLOGLO1("Services after: "); |
|
459 iServiceStore->PrintServices(); |
|
460 |
|
461 CIptvService* sourceService; |
|
462 CIptvService* destService; |
|
463 |
|
464 sourceService = oldServices->GetServiceById( sourceId ); |
|
465 destService = oldServices->GetServiceById( destinationId ); |
|
466 |
|
467 if( sourceService && destService ) |
|
468 { |
|
469 oldServices->ReplaceServiceL( destService->GetId(), *sourceService ); |
|
470 |
|
471 rv = iServiceStore->Compare( *oldServices ); |
|
472 } |
|
473 |
|
474 CleanupStack::PopAndDestroy(oldServices); |
|
475 |
|
476 } |
|
477 |
|
478 VCXLOGLO1("<<<CIptvServiceManagementApiTest::UpdateServiceL"); |
|
479 return rv; |
|
480 } |
|
481 |
|
482 // ----------------------------------------------------------------------------- |
|
483 // CIptvServiceManagementApiTest::UpdateServiceFieldL |
|
484 // ----------------------------------------------------------------------------- |
|
485 // |
|
486 TInt CIptvServiceManagementApiTest::UpdateServiceFieldL( CStifItemParser& aItem ) |
|
487 { |
|
488 VCXLOGLO1(">>>CIptvServiceManagementApiTest::UpdateServiceFieldL"); |
|
489 // Print to UI |
|
490 _LIT( KIptvServiceManagementApiTest, "IptvServiceManagementApiTest" ); |
|
491 _LIT( KUpdateServiceField, "In UpdateServiceFieldL" ); |
|
492 TestModuleIf().Printf( 0, KIptvServiceManagementApiTest, KUpdateServiceField ); |
|
493 // Print to log file |
|
494 iLog->Log( KUpdateServiceField ); |
|
495 |
|
496 TInt msgTypeInt(0); |
|
497 TInt fieldIdInt(0); |
|
498 TInt serviceId(-1); |
|
499 TBuf<256> serviceName; |
|
500 TInt rv = KErrNone; |
|
501 |
|
502 // Read parameters |
|
503 |
|
504 aItem.SetParsingType(CStifItemParser::EQuoteStyleParsing); |
|
505 |
|
506 aItem.GetNextInt(msgTypeInt); |
|
507 |
|
508 rv = GetServiceIdFromParam(aItem, serviceId, serviceName); |
|
509 if(rv != KErrNone) |
|
510 { |
|
511 VCXLOGLO1("<<<CIptvServiceManagementApiTest::UpdateServiceFieldL"); |
|
512 return rv; |
|
513 } |
|
514 |
|
515 aItem.GetNextInt(fieldIdInt); |
|
516 |
|
517 VCXLOGLO3("serviceId, Name = %d, %S", serviceId, &serviceName ); |
|
518 VCXLOGLO2("fieldId = %d", fieldIdInt ); |
|
519 |
|
520 iServiceStore->RefreshServicesFromDbL(KNoFilter, KNoSort); |
|
521 |
|
522 if(iServiceStore->ServiceCount() <= 0) |
|
523 { |
|
524 VCXLOGLO1("** FAIL ** No services in db, Cannot update!"); |
|
525 VCXLOGLO1("<<<CIptvServiceManagementApiTest::UpdateServiceFieldL"); |
|
526 return KErrArgument; |
|
527 } |
|
528 |
|
529 CIptvServiceManagementSync::TIptvSmTestConnection msgType = static_cast<CIptvServiceManagementSync::TIptvSmTestConnection>(msgTypeInt); |
|
530 |
|
531 TServiceFieldId fieldId = static_cast<TServiceFieldId>(fieldIdInt); |
|
532 |
|
533 TPtrC stringValue; |
|
534 TInt intValue(0); |
|
535 |
|
536 aItem.SetParsingType(CStifItemParser::EQuoteStyleParsing); |
|
537 |
|
538 TInt err = KErrNone; |
|
539 |
|
540 // disables event verifying. run cases without this line |
|
541 iIptvServiceManagementSync->SetSpecialAction(CIptvServiceManagementSync::EIptvSmWaitNoEvents); |
|
542 |
|
543 /* // Only updating these fields causes an event |
|
544 if(!(fieldId == EAddress || fieldId == EScheduleDlTime || fieldId == EScheduleDlNetwork || |
|
545 fieldId == EScheduleDlType || fieldId == EScheduleLastDlTime) ) |
|
546 { |
|
547 // iIptvServiceManagementSync->SetSpecialAction(CIptvServiceManagementSync::EIptvSmWaitNoEvents); |
|
548 }*/ |
|
549 |
|
550 if( (serviceId < 0 || msgTypeInt < 0 || msgTypeInt > 1) |
|
551 || (intValue < 0 ) ) |
|
552 { |
|
553 VCXLOGLO1("** FAIL ** Invalid testcase parameter!"); |
|
554 |
|
555 VCXLOGLO1("<<<CIptvServiceManagementApiTest::UpdateServiceFieldL"); |
|
556 return KErrArgument; |
|
557 } |
|
558 |
|
559 // Find the service |
|
560 |
|
561 CIptvService *service = NULL; |
|
562 service = iServiceStore->GetServiceById( serviceId ); |
|
563 |
|
564 if(service == NULL) |
|
565 { |
|
566 VCXLOGLO1("** FAIL ** Could not find service."); |
|
567 VCXLOGLO1("<<<CIptvServiceManagementApiTest::UpdateServiceFieldL"); |
|
568 return KErrArgument; |
|
569 } |
|
570 |
|
571 // Read the new value and update the service field |
|
572 |
|
573 VCXLOGLO1("Updating the field."); |
|
574 |
|
575 CIptvSmEvent::TEvent expectedEvent; |
|
576 expectedEvent = CIptvSmEvent::EServiceModified; |
|
577 |
|
578 switch(fieldId) |
|
579 { |
|
580 case EName: |
|
581 { |
|
582 VCXLOGLO1("service->SetName."); |
|
583 aItem.GetNextString(stringValue); |
|
584 err = service->SetName(stringValue); |
|
585 } |
|
586 break; |
|
587 |
|
588 case EAddress: |
|
589 { |
|
590 VCXLOGLO1("service->SetAddress."); |
|
591 aItem.GetNextString(stringValue); |
|
592 |
|
593 HBufC* address = HBufC::NewL(2048 + 128); // 2048 is the max, reserve some extra for too long addresses |
|
594 |
|
595 CleanupStack::PushL(address); |
|
596 |
|
597 *address = stringValue; |
|
598 |
|
599 if(stringValue == _L("Address_2kLongUrl")) |
|
600 { |
|
601 *address = K2kLongUrl; |
|
602 } |
|
603 else |
|
604 if(stringValue == _L("Address_256CharsLongFileName")) |
|
605 { |
|
606 *address = K256LongFile; |
|
607 } |
|
608 |
|
609 // if addresses are same there will not be ServiceModified event |
|
610 if(service->GetAddress() == stringValue) |
|
611 { |
|
612 iIptvServiceManagementSync->SetSpecialAction(CIptvServiceManagementSync::EIptvSmWaitNoEvents); |
|
613 } |
|
614 |
|
615 TInt len = address->Length(); |
|
616 VCXLOGLO2("Address length: %d", len); |
|
617 err = service->SetAddress(*address); |
|
618 |
|
619 CleanupStack::PopAndDestroy(address); |
|
620 } |
|
621 break; |
|
622 |
|
623 case EIconPath: |
|
624 { |
|
625 VCXLOGLO1("service->SetIconPath."); |
|
626 aItem.GetNextString(stringValue); |
|
627 err = service->SetIconPath(stringValue); |
|
628 } |
|
629 break; |
|
630 |
|
631 case EEpgPluginUid: // TUid |
|
632 { |
|
633 VCXLOGLO1("service->SetEpgPluginUid."); |
|
634 aItem.GetNextInt(intValue); |
|
635 TUid uid; |
|
636 uid.iUid = intValue; |
|
637 service->SetEpgPluginUid(uid); |
|
638 } |
|
639 break; |
|
640 |
|
641 case EVodPluginUid: // TUid |
|
642 { |
|
643 VCXLOGLO1("service->SetVodPluginUid."); |
|
644 aItem.GetNextInt(intValue); |
|
645 TUid uid; |
|
646 uid.iUid = intValue; |
|
647 service->SetVodPluginUid(uid); |
|
648 } |
|
649 break; |
|
650 |
|
651 case EIptvPluginUid: // TUid |
|
652 { |
|
653 VCXLOGLO1("service->SetIptvPluginUid."); |
|
654 aItem.GetNextInt(intValue); |
|
655 TUid uid; |
|
656 uid.iUid = intValue; |
|
657 service->SetIptvPluginUid(uid); |
|
658 } |
|
659 break; |
|
660 |
|
661 case EServiceType: // TServiceType |
|
662 { |
|
663 aItem.GetNextInt(intValue); |
|
664 VCXLOGLO2("service->SetType (%d).", intValue); |
|
665 service->SetType( static_cast<CIptvService::TServiceType>(intValue) ); |
|
666 } |
|
667 break; |
|
668 |
|
669 case ESetIapList: // TInt count of iaps |
|
670 { |
|
671 VCXLOGLO1("service->SetIapListL."); |
|
672 TInt index; |
|
673 TIptvIap iap; |
|
674 |
|
675 TPtrC iapName; |
|
676 |
|
677 intValue = 1; // otherwise parameter check later will fail |
|
678 |
|
679 CIptvIapList *iapList; |
|
680 iapList = CIptvIapList::NewL(); |
|
681 CleanupStack::PushL(iapList); |
|
682 |
|
683 if(KErrNone != aItem.GetNextString(iapName) ) |
|
684 { |
|
685 // empty iap list |
|
686 |
|
687 TRAPD(err2, err = service->SetIapListL(*iapList) ); |
|
688 |
|
689 CleanupStack::PopAndDestroy(iapList); |
|
690 |
|
691 if(err2 != KErrNone) |
|
692 { |
|
693 VCXLOGLO1("** FAIL ** SetIapListL (empty) caused a leave."); |
|
694 VCXLOGLO1("<<<CIptvServiceManagementApiTest::UpdateServiceFieldL"); |
|
695 return err2; |
|
696 } |
|
697 break; |
|
698 } |
|
699 |
|
700 // parameter can be iap count or list of iap names and priorities |
|
701 |
|
702 TBool iapNameSpecified = EFalse; |
|
703 |
|
704 TLex lex(iapName); |
|
705 if( KErrNone != lex.Val(intValue) ) |
|
706 { |
|
707 iapNameSpecified = ETrue; |
|
708 } |
|
709 |
|
710 // Iap count was specified |
|
711 if(!iapNameSpecified) |
|
712 { |
|
713 |
|
714 if(intValue >= 0) |
|
715 { |
|
716 if(intValue > iIapNumList->Count()) |
|
717 { |
|
718 intValue = iIapNumList->Count(); |
|
719 VCXLOGLO2("Not enough iaps, adding only: %d.", intValue); |
|
720 |
|
721 } |
|
722 |
|
723 for(index = 0; index < intValue; index++) |
|
724 { |
|
725 GetCommDbIapIdByOrder(index, iap.iId); |
|
726 iap.iPriority = index; |
|
727 iapList->AddIap(iap, ETrue); |
|
728 } |
|
729 } |
|
730 // add invalid iaps |
|
731 else |
|
732 { |
|
733 VCXLOGLO1("Adding invalid iaps."); |
|
734 |
|
735 intValue *= -1; |
|
736 |
|
737 if(intValue > iIapNumList->Count()) |
|
738 { |
|
739 intValue = iIapNumList->Count(); |
|
740 } |
|
741 |
|
742 for(index = 0; index < intValue; index++) |
|
743 { |
|
744 iap.iId = 100 + index; |
|
745 iap.iPriority = index; |
|
746 iapList->AddIap(iap, ETrue); |
|
747 } |
|
748 } |
|
749 } |
|
750 |
|
751 // Get the iap names and priorities |
|
752 else |
|
753 { |
|
754 while(1) |
|
755 { |
|
756 TInt prio; |
|
757 if(KErrNone == aItem.GetNextInt(prio) ) |
|
758 { |
|
759 TUint32 iapId; |
|
760 TBufC<256> name(iapName); |
|
761 |
|
762 if(iIptvTestUtilities->GetIapIdL(name, iapId)) |
|
763 { |
|
764 iap.iId = iapId; |
|
765 iap.iPriority = prio; |
|
766 iapList->AddIap(iap, ETrue); |
|
767 } |
|
768 else |
|
769 { |
|
770 VCXLOGLO2("** FAIL ** Test case error. No iap with name: %S.", &iapName); |
|
771 CleanupStack::PopAndDestroy(iapList); |
|
772 |
|
773 VCXLOGLO1("<<<CIptvServiceManagementApiTest::UpdateServiceFieldL"); |
|
774 return KErrArgument; |
|
775 } |
|
776 |
|
777 } |
|
778 else |
|
779 { |
|
780 VCXLOGLO2("** FAIL ** Test case error. No priority specified for iap: %S", &iapName); |
|
781 CleanupStack::PopAndDestroy(iapList); |
|
782 |
|
783 VCXLOGLO1("<<<CIptvServiceManagementApiTest::UpdateServiceFieldL"); |
|
784 return KErrArgument; |
|
785 } |
|
786 |
|
787 if(KErrNone != aItem.GetNextString(iapName) ) |
|
788 { |
|
789 VCXLOGLO1("All iaps added."); |
|
790 break; |
|
791 } |
|
792 } |
|
793 } |
|
794 |
|
795 // set service iaplist |
|
796 TRAPD(err2, err = service->SetIapListL(*iapList) ); |
|
797 |
|
798 CleanupStack::PopAndDestroy(iapList); |
|
799 |
|
800 if(err2 != KErrNone) |
|
801 { |
|
802 VCXLOGLO1("** FAIL ** SetIapListL caused a leave."); |
|
803 VCXLOGLO1("<<<CIptvServiceManagementApiTest::UpdateServiceFieldL"); |
|
804 return err2; |
|
805 } |
|
806 |
|
807 } |
|
808 break; |
|
809 |
|
810 case EUserName: |
|
811 { |
|
812 VCXLOGLO1("service->SetUserName."); |
|
813 aItem.GetNextString(stringValue); |
|
814 err = service->SetUserName(stringValue); |
|
815 } |
|
816 break; |
|
817 |
|
818 case EPassword: |
|
819 { |
|
820 VCXLOGLO1("service->SetPassword."); |
|
821 aItem.GetNextString(stringValue); |
|
822 err = service->SetPassword(stringValue); |
|
823 } |
|
824 break; |
|
825 |
|
826 case EDesc: |
|
827 { |
|
828 VCXLOGLO1("service->SetDesc."); |
|
829 aItem.GetNextString(stringValue); |
|
830 err = service->SetDesc(stringValue); |
|
831 } |
|
832 break; |
|
833 |
|
834 case EFlags: |
|
835 { |
|
836 VCXLOGLO1("service->SetFlags with next flags."); |
|
837 TUint flags = 0; |
|
838 |
|
839 while( KErrNone == aItem.GetNextInt(intValue) ) |
|
840 { |
|
841 flags |= intValue; |
|
842 |
|
843 if(intValue & CIptvService::ESelected) |
|
844 { |
|
845 VCXLOGLO1("ESelected"); |
|
846 } |
|
847 if(intValue & CIptvService::EReadOnly) |
|
848 { |
|
849 VCXLOGLO1("EReadOnly"); |
|
850 } |
|
851 if(intValue & CIptvService::EMainService) |
|
852 { |
|
853 VCXLOGLO1("EMainService"); |
|
854 } |
|
855 if(intValue & CIptvService::EConnectionApproved) |
|
856 { |
|
857 VCXLOGLO1("EConnectionApproved"); |
|
858 } |
|
859 if(intValue & CIptvService::EReadOnlyIaps) |
|
860 { |
|
861 VCXLOGLO1("EReadOnlyIaps"); |
|
862 } |
|
863 if(intValue & CIptvService::EGroupedService) |
|
864 { |
|
865 VCXLOGLO1("EGroupedService"); |
|
866 } |
|
867 if(intValue & CIptvService::EGroupReceived) |
|
868 { |
|
869 VCXLOGLO1("EGroupReceived"); |
|
870 } |
|
871 } |
|
872 |
|
873 VCXLOGLO2("old selection: %d", service->GetFlags() & CIptvSmEvent::EServiceSelectionModified); |
|
874 VCXLOGLO2("new selection: %d", flags & CIptvSmEvent::EServiceSelectionModified); |
|
875 |
|
876 |
|
877 if( (service->GetFlags() & CIptvSmEvent::EServiceSelectionModified) |
|
878 != (flags & CIptvSmEvent::EServiceSelectionModified) ) |
|
879 { |
|
880 // Service selection was modified. Expect event. |
|
881 expectedEvent = CIptvSmEvent::EServiceSelectionModified; |
|
882 } |
|
883 else |
|
884 { |
|
885 // Service selection was not modified |
|
886 iIptvServiceManagementSync->SetSpecialAction(CIptvServiceManagementSync::EIptvSmWaitNoEvents); |
|
887 } |
|
888 |
|
889 service->SetFlags(flags); |
|
890 if(service->GetFlags() != flags) |
|
891 { |
|
892 VCXLOGLO1("CIptvService::GetFlags returned wrong flags right after SetFlags."); |
|
893 } |
|
894 |
|
895 VCXLOGLO4("Service ID: %d, Name: %S, Flags: 0x%x", service->GetId(), &service->GetName(), flags); |
|
896 |
|
897 } |
|
898 break; |
|
899 |
|
900 case EApplicationUid: // TInt32 |
|
901 { |
|
902 VCXLOGLO1("service->SetApplicationUid."); |
|
903 aItem.GetNextInt(intValue); |
|
904 service->SetApplicationUid(intValue); |
|
905 } |
|
906 break; |
|
907 |
|
908 case EDisplayOrder: // TUint32 |
|
909 { |
|
910 VCXLOGLO1("service->SetDisplayOrder."); |
|
911 aItem.GetNextInt(intValue); |
|
912 service->SetDisplayOrder(intValue); |
|
913 } |
|
914 break; |
|
915 |
|
916 case EProviderId: // TDesC |
|
917 { |
|
918 VCXLOGLO1("service->SetProviderId."); |
|
919 aItem.GetNextString(stringValue); |
|
920 err = service->SetProviderId(stringValue); |
|
921 } |
|
922 break; |
|
923 |
|
924 case EAccountManagementUrl: |
|
925 { |
|
926 VCXLOGLO1("service->SetAccountManagementUrl."); |
|
927 aItem.GetNextString(stringValue); |
|
928 err = service->SetAccountManagementUrl(stringValue); |
|
929 } |
|
930 break; |
|
931 |
|
932 case EScheduleDlTime: |
|
933 { |
|
934 expectedEvent = CIptvSmEvent::EServiceScheduleModified; |
|
935 |
|
936 TUint flags = 0; |
|
937 |
|
938 while( KErrNone == aItem.GetNextInt(intValue) ) |
|
939 { |
|
940 flags |= intValue; |
|
941 |
|
942 if(intValue == 0 ) |
|
943 { |
|
944 VCXLOGLO1("ENoSchedule"); |
|
945 flags = 0; |
|
946 break; |
|
947 } |
|
948 if(intValue == 1 ) |
|
949 { |
|
950 VCXLOGLO1("ENight"); |
|
951 } |
|
952 if(intValue == 2 ) |
|
953 { |
|
954 VCXLOGLO1("EMorning"); |
|
955 } |
|
956 if(intValue == 4 ) |
|
957 { |
|
958 VCXLOGLO1("ENoon"); |
|
959 } |
|
960 if(intValue == 8 ) |
|
961 { |
|
962 VCXLOGLO1("EAfternoon"); |
|
963 } |
|
964 if(intValue == 16 ) |
|
965 { |
|
966 VCXLOGLO1("EEvening"); |
|
967 } |
|
968 } |
|
969 |
|
970 VCXLOGLO1("service->SetScheduleDlTime."); |
|
971 service->SetScheduleDlTime(flags); |
|
972 } |
|
973 break; |
|
974 |
|
975 case EScheduleDlNetwork: |
|
976 { |
|
977 expectedEvent = CIptvSmEvent::EServiceScheduleModified; |
|
978 |
|
979 TInt network; |
|
980 if(KErrNone != aItem.GetNextInt(network) ) |
|
981 { |
|
982 VCXLOGLO1("** FAIL ** Specify parameter: network type be used for scheduled download"); |
|
983 VCXLOGLO1("<<<CIptvServiceManagementApiTest::UpdateServiceFieldL"); |
|
984 return KErrArgument; |
|
985 } |
|
986 |
|
987 VCXLOGLO1("service->SetScheduleDlNetwork."); |
|
988 service->SetScheduleDlNetwork(network); |
|
989 |
|
990 } |
|
991 break; |
|
992 |
|
993 case EScheduleLastDlTime: |
|
994 { |
|
995 expectedEvent = CIptvSmEvent::EServiceScheduleModified; |
|
996 |
|
997 VCXLOGLO1("service->SetScheduledLastDownloadTime."); |
|
998 TTime time; |
|
999 time.UniversalTime(); |
|
1000 service->SetScheduledLastDownloadTime(time); |
|
1001 |
|
1002 TTime gotTime; |
|
1003 gotTime = service->GetScheduledLastDownloadTime(); |
|
1004 |
|
1005 _LIT(KDateTimeString,"%D%M%Y%/0%1%/1%2%/2%3%/3 %-B%:0%H%:1%T%:2%S%.%*C2%:3%-B"); |
|
1006 TBuf<256> str; |
|
1007 |
|
1008 if(gotTime != time) |
|
1009 { |
|
1010 VCXLOGLO1("GetScheduledLastDownloadTime does not match to what was set!"); |
|
1011 |
|
1012 TRAPD(err, gotTime.FormatL(str, KDateTimeString)); |
|
1013 if(err != KErrNone) |
|
1014 { |
|
1015 VCXLOGLO2("TTime::FormatL failed for gotTime: %d", err); |
|
1016 } |
|
1017 VCXLOGLO2("gotTime: %S", &str); |
|
1018 |
|
1019 TRAP(err, time.FormatL(str, KDateTimeString)); |
|
1020 if(err != KErrNone) |
|
1021 { |
|
1022 VCXLOGLO2("TTime::FormatL failed for time: %d", err); |
|
1023 } |
|
1024 VCXLOGLO2("time: %S", &str); |
|
1025 |
|
1026 VCXLOGLO1("<<<CIptvServiceManagementApiTest::UpdateServiceFieldL"); |
|
1027 return KErrCorrupt; |
|
1028 } |
|
1029 |
|
1030 } |
|
1031 break; |
|
1032 |
|
1033 case EScheduleDlType: |
|
1034 { |
|
1035 expectedEvent = CIptvSmEvent::EServiceScheduleModified; |
|
1036 |
|
1037 TInt dlType; |
|
1038 TInt dlCount = 0; |
|
1039 if(KErrNone != aItem.GetNextInt(dlType)) |
|
1040 { |
|
1041 VCXLOGLO1("** FAIL ** Specify parameter: dl type to be used for scheduled download"); |
|
1042 VCXLOGLO1("<<<CIptvServiceManagementApiTest::UpdateServiceFieldL"); |
|
1043 return KErrArgument; |
|
1044 } |
|
1045 |
|
1046 TInt type = 0; |
|
1047 |
|
1048 if(dlType != EIptvTestNoDownload) |
|
1049 { |
|
1050 if(KErrNone != aItem.GetNextInt(dlCount)) |
|
1051 { |
|
1052 VCXLOGLO1("** FAIL ** Specify parameter: dl count to be used for scheduled download"); |
|
1053 VCXLOGLO1("<<<CIptvServiceManagementApiTest::UpdateServiceFieldL"); |
|
1054 return KErrArgument; |
|
1055 } |
|
1056 } |
|
1057 |
|
1058 type |= dlCount; |
|
1059 |
|
1060 switch(dlType) |
|
1061 { |
|
1062 case EIptvTestNoDownload: |
|
1063 { |
|
1064 type = 0; |
|
1065 } |
|
1066 break; |
|
1067 |
|
1068 case EIptvTestDownloadLatest: |
|
1069 { |
|
1070 type |= EDownloadLatest; |
|
1071 } |
|
1072 break; |
|
1073 |
|
1074 case EIptvTestDownloadOldest: |
|
1075 { |
|
1076 type |= EDownloadOldest; |
|
1077 } |
|
1078 break; |
|
1079 |
|
1080 case EIptvTestDownloadAddedAfterLastScheduledDownload: |
|
1081 { |
|
1082 type |= EDownloadAddedAfterLastScheduledDownload; |
|
1083 } |
|
1084 break; |
|
1085 |
|
1086 case EIptvTestDownloadAll: |
|
1087 { |
|
1088 type |= EDownloadAll; |
|
1089 } |
|
1090 break; |
|
1091 |
|
1092 default: |
|
1093 { |
|
1094 VCXLOGLO1("** FAIL ** Uknown dl type for scheduled download"); |
|
1095 VCXLOGLO1("<<<CIptvServiceManagementApiTest::UpdateServiceFieldL"); |
|
1096 return KErrArgument; |
|
1097 } |
|
1098 } |
|
1099 |
|
1100 VCXLOGLO1("service->SetScheduleDlType."); |
|
1101 service->SetScheduleDlType(type); |
|
1102 |
|
1103 } |
|
1104 break; |
|
1105 |
|
1106 case ESearchUrl: |
|
1107 { |
|
1108 VCXLOGLO1("service->SetSearchUrl."); |
|
1109 aItem.GetNextString(stringValue); |
|
1110 |
|
1111 HBufC* address = HBufC::NewL(2048 + 128); // 2048 is the max, reserve some extra for too long addresses |
|
1112 |
|
1113 CleanupStack::PushL(address); |
|
1114 |
|
1115 *address = stringValue; |
|
1116 |
|
1117 if(stringValue == _L("Address_256charsLongSearchUrl")) |
|
1118 { |
|
1119 *address = K256charsLongSearchUrl; |
|
1120 } |
|
1121 |
|
1122 service->SetSearchUrlL( address->Des() ); |
|
1123 |
|
1124 CleanupStack::PopAndDestroy(address); |
|
1125 } |
|
1126 break; |
|
1127 |
|
1128 default: |
|
1129 { |
|
1130 VCXLOGLO2("** FAIL ** Invalid field id parameter! %d", fieldId); |
|
1131 VCXLOGLO1("<<<CIptvServiceManagementApiTest::UpdateServiceFieldL"); |
|
1132 return KErrArgument; |
|
1133 } |
|
1134 } |
|
1135 |
|
1136 VCXLOGLO2("intValue = %d", intValue); |
|
1137 VCXLOGLO2("stringValue = %S", &stringValue); |
|
1138 |
|
1139 if(err != KErrNone) |
|
1140 { |
|
1141 VCXLOGLO1("** FAIL ** Service set method returned error."); |
|
1142 |
|
1143 VCXLOGLO1("<<<CIptvServiceManagementApiTest::UpdateServiceFieldL"); |
|
1144 return err; |
|
1145 } |
|
1146 |
|
1147 // Do the request |
|
1148 TRespStatus respStatus = iIptvServiceManagementSync->CallUpdateService(msgType, *service, expectedEvent); |
|
1149 |
|
1150 if(respStatus != ESucceeded) |
|
1151 { |
|
1152 VCXLOGLO2("** FAIL ** Updating service failed: status = %d", respStatus); |
|
1153 rv = respStatus; |
|
1154 } |
|
1155 else |
|
1156 { |
|
1157 // Verify |
|
1158 CIptvTestServiceStore* oldServices = CIptvTestServiceStore::NewL( iServiceStore ); |
|
1159 CleanupStack::PushL(oldServices); |
|
1160 |
|
1161 oldServices->ReplaceServiceL( service->GetId(), *service ); |
|
1162 |
|
1163 iServiceStore->RefreshServicesFromDbL(KNoFilter, KNoSort); |
|
1164 rv = iServiceStore->Compare( *oldServices ); |
|
1165 |
|
1166 CleanupStack::PopAndDestroy(oldServices); |
|
1167 } |
|
1168 |
|
1169 VCXLOGLO1("<<<CIptvServiceManagementApiTest::UpdateServiceFieldL"); |
|
1170 return rv; |
|
1171 } |
|
1172 |
|
1173 // ----------------------------------------------------------------------------- |
|
1174 // CIptvServiceManagementApiTest::DeleteServiceL |
|
1175 // ----------------------------------------------------------------------------- |
|
1176 // |
|
1177 TInt CIptvServiceManagementApiTest::DeleteServiceL( CStifItemParser& aItem ) |
|
1178 { |
|
1179 VCXLOGLO1(">>>CIptvServiceManagementApiTest::DeleteServiceL"); |
|
1180 // Print to UI |
|
1181 _LIT( KIptvServiceManagementApiTest, "IptvServiceManagementApiTest" ); |
|
1182 _LIT( KDeleteService, "In DeleteService" ); |
|
1183 TestModuleIf().Printf( 0, KIptvServiceManagementApiTest, KDeleteService ); |
|
1184 // Print to log file |
|
1185 iLog->Log( KDeleteService ); |
|
1186 |
|
1187 TRespStatus expectedRespStatus = ESucceeded; |
|
1188 TRespStatus respStatus = ESucceeded; |
|
1189 TInt msgTypeInt(0); |
|
1190 TInt serviceId(-1); |
|
1191 TBuf<256> serviceName; |
|
1192 TInt rv = KErrNone; |
|
1193 |
|
1194 // Read parameters |
|
1195 |
|
1196 aItem.SetParsingType(CStifItemParser::EQuoteStyleParsing); |
|
1197 |
|
1198 aItem.GetNextInt(msgTypeInt); |
|
1199 |
|
1200 rv = GetServiceIdFromParam(aItem, serviceId, serviceName); |
|
1201 if(rv != KErrNone) |
|
1202 { |
|
1203 VCXLOGLO1("<<<CIptvServiceManagementApiTest::DeleteServiceL"); |
|
1204 return rv; |
|
1205 } |
|
1206 |
|
1207 VCXLOGLO3("ServiceId = %d, name: %S",serviceId, &serviceName ); |
|
1208 |
|
1209 if(serviceId < 0 || msgTypeInt < 0 || msgTypeInt > 1) |
|
1210 { |
|
1211 VCXLOGLO1("** FAIL ** Invalid testcase parameter!"); |
|
1212 VCXLOGLO1("<<<CIptvServiceManagementApiTest::DeleteServiceL"); |
|
1213 return KErrArgument; |
|
1214 } |
|
1215 |
|
1216 CIptvServiceManagementSync::TIptvSmTestConnection msgType = static_cast<CIptvServiceManagementSync::TIptvSmTestConnection>(msgTypeInt); |
|
1217 |
|
1218 // Do the request |
|
1219 |
|
1220 TUint repeatRequest = iIptvServiceManagementSync->GetRepeatNextRequestCount(); |
|
1221 if(repeatRequest == 0) repeatRequest = 1; // Still need to do this once |
|
1222 |
|
1223 iServiceStore->RefreshServicesFromDbL(KNoFilter, KNoSort); |
|
1224 |
|
1225 CIptvTestServiceStore* oldServices = CIptvTestServiceStore::NewL( iServiceStore ); |
|
1226 CleanupStack::PushL(oldServices); |
|
1227 |
|
1228 respStatus = iIptvServiceManagementSync->CallDeleteService(msgType, serviceId); |
|
1229 |
|
1230 if(respStatus != expectedRespStatus) |
|
1231 { |
|
1232 VCXLOGLO3("** FAIL ** Service return value was not expected: expected %d, returned %d", expectedRespStatus, respStatus); |
|
1233 rv = respStatus; |
|
1234 } |
|
1235 else |
|
1236 { |
|
1237 // Verify |
|
1238 if( repeatRequest <= 1 ) |
|
1239 { |
|
1240 iServiceStore->RefreshServicesFromDbL(KNoFilter, KNoSort); |
|
1241 |
|
1242 CIptvService* service(NULL); |
|
1243 service = oldServices->GetServiceById( serviceId ); |
|
1244 if(service) |
|
1245 { |
|
1246 oldServices->DeleteService( service->GetId() ); |
|
1247 |
|
1248 rv = iServiceStore->Compare( *oldServices ); |
|
1249 } |
|
1250 } |
|
1251 } |
|
1252 |
|
1253 CleanupStack::PopAndDestroy(oldServices); |
|
1254 |
|
1255 VCXLOGLO1("<<<CIptvServiceManagementApiTest::DeleteServiceL"); |
|
1256 return rv; |
|
1257 } |
|
1258 |
|
1259 // ----------------------------------------------------------------------------- |
|
1260 // CIptvServiceManagementApiTest::DeleteAllServicesL |
|
1261 // ----------------------------------------------------------------------------- |
|
1262 // |
|
1263 TInt CIptvServiceManagementApiTest::DeleteAllServicesL( CStifItemParser& aItem ) |
|
1264 { |
|
1265 VCXLOGLO1(">>>CIptvServiceManagementApiTest::DeleteAllServicesL"); |
|
1266 |
|
1267 // Print to UI |
|
1268 _LIT( KIptvServiceManagementApiTest, "IptvServiceManagementApiTest" ); |
|
1269 _LIT( KWhere, "In DeleteAllServicesL" ); |
|
1270 TestModuleIf().Printf( 0, KIptvServiceManagementApiTest, KWhere ); |
|
1271 // Print to log file |
|
1272 iLog->Log( KWhere ); |
|
1273 |
|
1274 TInt rv = KErrNone; |
|
1275 TRespStatus respStatus = ESucceeded; |
|
1276 TInt msgTypeInt(0); |
|
1277 |
|
1278 // Read parameters |
|
1279 |
|
1280 aItem.GetNextInt(msgTypeInt); |
|
1281 |
|
1282 if(msgTypeInt < 0 || msgTypeInt > 1) |
|
1283 { |
|
1284 VCXLOGLO1("** FAIL ** Invalid testcase parameter!"); |
|
1285 VCXLOGLO1("<<<CIptvServiceManagementApiTest::DeleteServiceL"); |
|
1286 return KErrArgument; |
|
1287 } |
|
1288 |
|
1289 CIptvServiceManagementSync::TIptvSmTestConnection msgType = static_cast<CIptvServiceManagementSync::TIptvSmTestConnection>(msgTypeInt); |
|
1290 |
|
1291 iServiceStore->RefreshServicesFromDbL(KNoFilter, KNoSort); |
|
1292 |
|
1293 VCXLOGLO2("Services found: %d", iServiceStore->ServiceCount() ); |
|
1294 |
|
1295 /* If there is a deletion of group going on .. */ |
|
1296 RPointerArray<CIptvService> services; |
|
1297 |
|
1298 /*for(i = 0; i < iServiceStore->ServiceCount(); i++)*/ |
|
1299 while( iServiceStore->ServiceCount() > 0) |
|
1300 { |
|
1301 iServiceStore->GetServices( services ); |
|
1302 |
|
1303 CIptvService* iptvService = NULL; |
|
1304 iptvService = services[0]; |
|
1305 |
|
1306 VCXLOGLO2("Deleting service: %d", iptvService->GetId()); |
|
1307 |
|
1308 if( iptvService->GetType() == CIptvService::EServiceGroup ) |
|
1309 { |
|
1310 respStatus = iIptvServiceManagementSync->CallDeleteService( msgType, iptvService->GetId() ); |
|
1311 |
|
1312 /* Grouped services are also deleted, first get the grouped because they still exist */ |
|
1313 iServiceStore->GetGroupedServicesByGroupId( services, iptvService->GetGroupId() ); |
|
1314 iServiceStore->DeleteService( iptvService->GetId() ); |
|
1315 |
|
1316 /* Increase expected event count by the count of grouped services*/ |
|
1317 if( services.Count() > 0 ) |
|
1318 { |
|
1319 iIptvServiceManagementSync->IncreaseExpectedEventCount( services.Count() ); |
|
1320 services.Reset(); |
|
1321 } |
|
1322 } |
|
1323 else |
|
1324 { |
|
1325 /* Delete a single service, also from servicestore */ |
|
1326 respStatus = iIptvServiceManagementSync->CallDeleteService(msgType, iptvService->GetId()); |
|
1327 iServiceStore->DeleteService( iptvService->GetId() ); |
|
1328 } |
|
1329 |
|
1330 if(respStatus != ESucceeded) |
|
1331 { |
|
1332 VCXLOGLO2("** FAIL ** DeleteServiceRequest failed, response = %d",respStatus); |
|
1333 rv = respStatus; |
|
1334 break; |
|
1335 } |
|
1336 |
|
1337 services.Reset(); |
|
1338 } |
|
1339 |
|
1340 iServiceStore->RefreshServicesFromDbL(KNoFilter, KNoSort); |
|
1341 |
|
1342 if(iServiceStore->ServiceCount() != 0) |
|
1343 { |
|
1344 VCXLOGLO1("* FAIL * Service DB has services."); |
|
1345 rv = KErrCorrupt; |
|
1346 } |
|
1347 |
|
1348 VCXLOGLO1("<<<CIptvServiceManagementApiTest::DeleteAllServicesL"); |
|
1349 return rv; |
|
1350 } |
|
1351 |
|
1352 // ----------------------------------------------------------------------------- |
|
1353 // CIptvServiceManagementApiTest::GetServicesByProviderIdL |
|
1354 // ----------------------------------------------------------------------------- |
|
1355 // |
|
1356 TInt CIptvServiceManagementApiTest::GetServicesByProviderIdL( CStifItemParser& aItem ) |
|
1357 { |
|
1358 VCXLOGLO1(">>>CIptvServiceManagementApiTest::GetServicesByProviderIdL"); |
|
1359 // Print to UI |
|
1360 _LIT( KIptvServiceManagementApiTest, "IptvServiceManagementApiTest" ); |
|
1361 _LIT( KGetServicesByProviderId, "In GetServicesByProviderIdL" ); |
|
1362 TestModuleIf().Printf( 0, KIptvServiceManagementApiTest, KGetServicesByProviderId ); |
|
1363 // Print to log file |
|
1364 iLog->Log( KGetServicesByProviderId ); |
|
1365 |
|
1366 TRespStatus respStatus = ESucceeded; |
|
1367 TInt rv = KErrNone; |
|
1368 CIptvServices* services = NULL; |
|
1369 TPtrC providerId; |
|
1370 |
|
1371 // Read parameters |
|
1372 |
|
1373 aItem.SetParsingType(CStifItemParser::EQuoteStyleParsing); |
|
1374 |
|
1375 if(aItem.GetNextString(providerId) == KErrNone) |
|
1376 { |
|
1377 VCXLOGLO2("Parameter provider id: %S", &providerId); |
|
1378 } |
|
1379 else |
|
1380 { |
|
1381 VCXLOGLO1("** FAIL ** Reading parameter provider id failed"); |
|
1382 VCXLOGLO1("<<<IptvServiceManagementApiTest::GetServicesByProviderIdL"); |
|
1383 return KErrArgument; |
|
1384 } |
|
1385 |
|
1386 services = CIptvServices::NewL(); |
|
1387 CleanupStack::PushL(services); |
|
1388 |
|
1389 TRAP(rv, respStatus = iIptvServiceManagementSync->CallGetServicesByProviderId(providerId, *services)); |
|
1390 |
|
1391 if(rv != KErrNone) |
|
1392 { |
|
1393 VCXLOGLO2("** FAIL ** CallGetServicesByProviderId left: %d.", rv); |
|
1394 } |
|
1395 else |
|
1396 if(respStatus != ESucceeded) |
|
1397 { |
|
1398 VCXLOGLO2("** FAIL ** GetServicesByProviderId failed, response = %d",respStatus); |
|
1399 rv = respStatus; |
|
1400 } |
|
1401 else |
|
1402 { |
|
1403 // Verify |
|
1404 CIptvTestServiceStore* gotServices = CIptvTestServiceStore::NewL( services ); |
|
1405 CleanupStack::PushL( gotServices ); |
|
1406 |
|
1407 CIptvTestServiceStore* verifyServices = CIptvTestServiceStore::NewL( ); |
|
1408 CleanupStack::PushL( verifyServices ); |
|
1409 |
|
1410 iServiceStore->RefreshServicesFromDbL(KNoFilter, KNoSort); |
|
1411 iServiceStore->PrintServices(); |
|
1412 |
|
1413 TInt i; |
|
1414 for(i=0; i<iServiceStore->ServiceCount(); i++) |
|
1415 { |
|
1416 CIptvService *service; |
|
1417 service = iServiceStore->GetService(i); |
|
1418 if(service->GetProviderId() == providerId) |
|
1419 { |
|
1420 verifyServices->AddServiceL( *service ); |
|
1421 } |
|
1422 } |
|
1423 |
|
1424 rv = verifyServices->Compare( *gotServices ); |
|
1425 |
|
1426 CleanupStack::PopAndDestroy(verifyServices); |
|
1427 CleanupStack::PopAndDestroy(gotServices); |
|
1428 } |
|
1429 |
|
1430 CleanupStack::PopAndDestroy(services); |
|
1431 |
|
1432 VCXLOGLO1("<<<CIptvServiceManagementApiTest::GetServicesByProviderIdL"); |
|
1433 return rv; |
|
1434 } |
|
1435 |
|
1436 // ----------------------------------------------------------------------------- |
|
1437 // CIptvServiceManagementApiTest::SetUsedIap |
|
1438 // ----------------------------------------------------------------------------- |
|
1439 // |
|
1440 TInt CIptvServiceManagementApiTest::SetUsedIap( CStifItemParser& aItem ) |
|
1441 { |
|
1442 VCXLOGLO1(">>>CIptvServiceManagementApiTest::SetUsedIap"); |
|
1443 // Print to UI |
|
1444 _LIT( KIptvServiceManagementApiTest, "IptvServiceManagementApiTest" ); |
|
1445 _LIT( KSetUsedIap, "In SetUsedIap" ); |
|
1446 TestModuleIf().Printf( 0, KIptvServiceManagementApiTest, KSetUsedIap ); |
|
1447 // Print to log file |
|
1448 iLog->Log( KSetUsedIap ); |
|
1449 |
|
1450 //TPtrC iapName; |
|
1451 TUint32 iapId(0); |
|
1452 TInt usedIapNum(0); |
|
1453 TInt runOnlyIfIapExists(0); |
|
1454 TInt serviceId(-1); |
|
1455 TBuf<256> serviceName; |
|
1456 MIptvServiceManagementClientObserver::TRespStatus respStatus; |
|
1457 TInt rv = KErrNone; |
|
1458 |
|
1459 // Read parameters |
|
1460 |
|
1461 aItem.SetParsingType(CStifItemParser::EQuoteStyleParsing); |
|
1462 |
|
1463 rv = GetServiceIdFromParam(aItem, serviceId, serviceName); |
|
1464 if(rv != KErrNone) |
|
1465 { |
|
1466 VCXLOGLO1("<<<CIptvServiceManagementApiTest::SetUsedIap"); |
|
1467 return rv; |
|
1468 } |
|
1469 |
|
1470 TPtrC iapName; |
|
1471 if(KErrNone != aItem.GetNextString(iapName) ) |
|
1472 { |
|
1473 VCXLOGLO1("** FAIL ** Invalid testcase parameter! Iap name or count was not specified."); |
|
1474 VCXLOGLO1("<<<CIptvServiceManagementApiTest::SetUsedIap"); |
|
1475 return KErrArgument; |
|
1476 } |
|
1477 |
|
1478 TBool iapNameSpecified = EFalse; |
|
1479 TLex lex(iapName); |
|
1480 if( KErrNone != lex.Val(usedIapNum) ) |
|
1481 { |
|
1482 iapNameSpecified = ETrue; |
|
1483 } |
|
1484 |
|
1485 aItem.GetNextInt(runOnlyIfIapExists); |
|
1486 |
|
1487 VCXLOGLO2("iapName = %S", &iapName); |
|
1488 VCXLOGLO2("iapNum = %d", usedIapNum); |
|
1489 VCXLOGLO3("ServiceId = %d, name: %S",serviceId, &serviceName ); |
|
1490 |
|
1491 if(iapNameSpecified) |
|
1492 { |
|
1493 TBufC<256> name(iapName); |
|
1494 if(!iIptvTestUtilities->GetIapIdL(name, iapId)) |
|
1495 { |
|
1496 VCXLOGLO2("** FAIL ** Test case error. Iap with name %S does not exist.", &name); |
|
1497 VCXLOGLO1("<<<CIptvServiceManagementApiTest::SetUsedIap"); |
|
1498 return KErrArgument; |
|
1499 } |
|
1500 } |
|
1501 else |
|
1502 { |
|
1503 if(usedIapNum >= 0) |
|
1504 { |
|
1505 // Get iap id and skip the test if needed |
|
1506 if(KErrNone != GetCommDbIapIdByOrder(usedIapNum , iapId) && runOnlyIfIapExists ) |
|
1507 { |
|
1508 VCXLOGLO1("Iap does not exist and flag set, skipping."); |
|
1509 VCXLOGLO1("<<<CIptvServiceManagementApiTest::SetUsedIap"); |
|
1510 return KErrNone; |
|
1511 } |
|
1512 } |
|
1513 // Invalid iap id |
|
1514 else |
|
1515 { |
|
1516 iapId = 1000; |
|
1517 } |
|
1518 } |
|
1519 |
|
1520 if(serviceId < 0) |
|
1521 { |
|
1522 VCXLOGLO1("** FAIL ** Invalid testcase parameter!"); |
|
1523 VCXLOGLO1("<<<CIptvServiceManagementApiTest::SetUsedIap"); |
|
1524 return KErrArgument; |
|
1525 } |
|
1526 |
|
1527 VCXLOGLO2("iapId = %d", iapId); |
|
1528 |
|
1529 // Do the request |
|
1530 |
|
1531 respStatus = iIptvServiceManagementSync->CallSetUsedIap(iapId, serviceId, TRUE ); |
|
1532 |
|
1533 // Set also used destination and set the IAP to highest priority. |
|
1534 // We presume the IAPs are in Internet destination |
|
1535 |
|
1536 _LIT(KDestinationName, "Internet"); |
|
1537 TInt err (KErrNone); |
|
1538 TBuf<64> destName( KDestinationName ); |
|
1539 TBuf<64> iapNameTemp( iapName ); |
|
1540 TRAP(err, iAlrUtil->SetUsedDestinationL( destName ) ); |
|
1541 if(err != KErrNone) |
|
1542 { |
|
1543 VCXLOGLO2("** FAIL ** SetUsedDestinationL failed. Error: %d", err ); |
|
1544 } |
|
1545 TRAP(err, iAlrUtil->SetMethodPriorityL( destName, iapNameTemp, 0 ) ); |
|
1546 if(err != KErrNone) |
|
1547 { |
|
1548 VCXLOGLO2("** FAIL ** SetMethodPriorityL failed. Error: %d", err ); |
|
1549 } |
|
1550 |
|
1551 if(respStatus != MIptvServiceManagementClientObserver::ESucceeded) |
|
1552 { |
|
1553 VCXLOGLO2("** FAIL ** CallSetUsedIap returned error. error: %d", respStatus ); |
|
1554 rv = respStatus; |
|
1555 } |
|
1556 |
|
1557 VCXLOGLO1("<<<CIptvServiceManagementApiTest::SetUsedIap"); |
|
1558 |
|
1559 return rv; |
|
1560 } |
|
1561 // ----------------------------------------------------------------------------- |
|
1562 // CIptvServiceManagementApiTest::GetUsedIap |
|
1563 // ----------------------------------------------------------------------------- |
|
1564 // |
|
1565 TInt CIptvServiceManagementApiTest::GetUsedIap( CStifItemParser& aItem ) |
|
1566 { |
|
1567 VCXLOGLO1(">>>CIptvServiceManagementApiTest::GetUsedIap"); |
|
1568 // Print to UI |
|
1569 _LIT( KIptvServiceManagementApiTest, "IptvServiceManagementApiTest" ); |
|
1570 _LIT( KGetUsedIap, "In GetUsedIap" ); |
|
1571 TestModuleIf().Printf( 0, KIptvServiceManagementApiTest, KGetUsedIap ); |
|
1572 // Print to log file |
|
1573 iLog->Log( KGetUsedIap ); |
|
1574 |
|
1575 aItem.SetParsingType(CStifItemParser::EQuoteStyleParsing); |
|
1576 |
|
1577 TUint32 iapId(10000); |
|
1578 TUint32 expectedIapId(20000); |
|
1579 TInt msgTypeInt(0); |
|
1580 TInt expectedIapNumber(0); |
|
1581 TInt runOnlyIfIapExists(0); |
|
1582 TInt serviceId(-1); |
|
1583 TBuf<256> serviceName; |
|
1584 TInt rv = KErrNone; |
|
1585 |
|
1586 // Read parameters |
|
1587 |
|
1588 aItem.GetNextInt(msgTypeInt); |
|
1589 |
|
1590 aItem.SetParsingType(CStifItemParser::EQuoteStyleParsing); |
|
1591 |
|
1592 rv = GetServiceIdFromParam(aItem, serviceId, serviceName); |
|
1593 if(rv != KErrNone) |
|
1594 { |
|
1595 VCXLOGLO1("<<<CIptvServiceManagementApiTest::GetUsedIap"); |
|
1596 return rv; |
|
1597 } |
|
1598 |
|
1599 TPtrC expectedIapName; |
|
1600 if(KErrNone != aItem.GetNextString(expectedIapName) ) |
|
1601 { |
|
1602 VCXLOGLO1("** FAIL ** Invalid testcase parameter! Iap name or count was not specified."); |
|
1603 VCXLOGLO1("<<<CIptvServiceManagementApiTest::GetUsedIap"); |
|
1604 return KErrArgument; |
|
1605 } |
|
1606 |
|
1607 if(!iIptvTestUtilities->GetIapIdByNameL(expectedIapName, expectedIapId)) |
|
1608 { |
|
1609 VCXLOGLO2("** FAIL ** Test case error. Iap with name %S does not exist.", &expectedIapName); |
|
1610 VCXLOGLO1("<<<CIptvServiceManagementApiTest::GetUsedIap"); |
|
1611 return KErrArgument; |
|
1612 } |
|
1613 |
|
1614 aItem.GetNextInt(runOnlyIfIapExists); |
|
1615 |
|
1616 VCXLOGLO3("ServiceId = %d, name: %S",serviceId, &serviceName ); |
|
1617 VCXLOGLO2("runOnlyIfIapExists: %d", runOnlyIfIapExists); |
|
1618 VCXLOGLO2("expectedIapName: %S", &expectedIapName); |
|
1619 VCXLOGLO2("expectedIapNumber: %d", expectedIapNumber); |
|
1620 VCXLOGLO2("expectedIapId: %d", expectedIapId); |
|
1621 |
|
1622 if(serviceId < 0 || msgTypeInt < 0) |
|
1623 { |
|
1624 VCXLOGLO1("** FAIL ** Invalid testcase parameter!"); |
|
1625 VCXLOGLO1("<<<CIptvServiceManagementApiTest::GetUsedIap"); |
|
1626 return KErrArgument; |
|
1627 } |
|
1628 |
|
1629 CIptvServiceManagementSync::TIptvSmTestConnection msgType = static_cast<CIptvServiceManagementSync::TIptvSmTestConnection>(msgTypeInt); |
|
1630 |
|
1631 MIptvServiceManagementClientObserver::TRespStatus respStatus; |
|
1632 |
|
1633 CIptvService *service = iIptvTestUtilities->GetServiceFromDb(serviceId); |
|
1634 if(!service) |
|
1635 { |
|
1636 VCXLOGLO1("** FAIL ** No such service in DB. Continuing test run."); |
|
1637 } |
|
1638 else |
|
1639 { |
|
1640 iIptvTestUtilities->PrintIptvService(service); |
|
1641 delete service; |
|
1642 service = NULL; |
|
1643 } |
|
1644 |
|
1645 // Do the request |
|
1646 |
|
1647 respStatus = iIptvServiceManagementSync->CallGetUsedIap(msgType, serviceId, iapId ); |
|
1648 |
|
1649 if(respStatus != MIptvServiceManagementClientObserver::ESucceeded) |
|
1650 { |
|
1651 VCXLOGLO2("** FAIL ** CallGetUsedIap returned error. error: %d", respStatus ); |
|
1652 rv = respStatus; |
|
1653 } |
|
1654 else |
|
1655 if( iapId != expectedIapId ) |
|
1656 { |
|
1657 VCXLOGLO2("** FAIL ** CallGetUsedIap returned iapId %d", iapId); |
|
1658 VCXLOGLO2("Expected iap id: %d", expectedIapId ); |
|
1659 rv = KErrCorrupt; |
|
1660 } |
|
1661 |
|
1662 VCXLOGLO1("<<<CIptvServiceManagementApiTest::GetUsedIap"); |
|
1663 return rv; |
|
1664 } |
|
1665 |
|
1666 // ----------------------------------------------------------------------------- |
|
1667 // CIptvServiceManagementApiTest::ClearUsedIapL |
|
1668 // ----------------------------------------------------------------------------- |
|
1669 // |
|
1670 TInt CIptvServiceManagementApiTest::ClearUsedIapL( CStifItemParser& /*aItem*/ ) |
|
1671 { |
|
1672 VCXLOGLO1(">>>CIptvServiceManagementApiTest::ClearUsedIapL"); |
|
1673 // Print to UI |
|
1674 _LIT( KIptvServiceManagementApiTest, "IptvServiceManagementApiTest" ); |
|
1675 _LIT( KClearUsedIap, "In ClearUsedIapL" ); |
|
1676 TestModuleIf().Printf( 0, KIptvServiceManagementApiTest, KClearUsedIap ); |
|
1677 // Print to log file |
|
1678 iLog->Log( KClearUsedIap ); |
|
1679 |
|
1680 TInt rv = KErrNone; |
|
1681 |
|
1682 MIptvServiceManagementClientObserver::TRespStatus respStatus; |
|
1683 |
|
1684 respStatus = iIptvServiceManagementSync->CallClearUsedIap(); |
|
1685 |
|
1686 if(respStatus == MIptvServiceManagementClientObserver::ESucceeded) |
|
1687 { |
|
1688 |
|
1689 // verify somehow |
|
1690 } |
|
1691 else |
|
1692 { |
|
1693 VCXLOGLO2("** FAIL ** CallClearUsedIap returned error. error: %d", rv ); |
|
1694 rv = respStatus; |
|
1695 } |
|
1696 |
|
1697 VCXLOGLO1("<<<CIptvServiceManagementApiTest::ClearUsedIapL"); |
|
1698 return rv; |
|
1699 } |
|
1700 |
|
1701 // ----------------------------------------------------------------------------- |
|
1702 // CIptvServiceManagementApiTest::SetAllIapsL |
|
1703 // ----------------------------------------------------------------------------- |
|
1704 // |
|
1705 TInt CIptvServiceManagementApiTest::SetAllIapsL( CStifItemParser& aItem ) |
|
1706 { |
|
1707 VCXLOGLO1(">>>CIptvServiceManagementApiTest::SetAllIapsL"); |
|
1708 // Print to UI |
|
1709 _LIT( KIptvServiceManagementApiTest, "IptvServiceManagementApiTest" ); |
|
1710 _LIT( KSetAllIapsL, "In SetAllIapsL" ); |
|
1711 TestModuleIf().Printf( 0, KIptvServiceManagementApiTest, KSetAllIapsL ); |
|
1712 // Print to log file |
|
1713 iLog->Log( KSetAllIapsL ); |
|
1714 |
|
1715 TRespStatus respStatus = ESucceeded; |
|
1716 TInt rv = KErrNone; |
|
1717 TInt i = 0; |
|
1718 TInt iapCount = 0; |
|
1719 TInt ignoreReadOnlyInt = 0; |
|
1720 TInt msgTypeInt(0); |
|
1721 |
|
1722 // Read parameters |
|
1723 |
|
1724 aItem.GetNextInt(msgTypeInt); |
|
1725 aItem.GetNextInt(iapCount); |
|
1726 aItem.GetNextInt(ignoreReadOnlyInt); |
|
1727 |
|
1728 VCXLOGLO2("iapCount: %d", iapCount); |
|
1729 VCXLOGLO2("ignoreReadOnlyInt: %d", ignoreReadOnlyInt); |
|
1730 |
|
1731 if(iapCount < 0 || ignoreReadOnlyInt < 0 || ignoreReadOnlyInt > 1 || msgTypeInt < 0 || msgTypeInt > 1) |
|
1732 { |
|
1733 VCXLOGLO1("** FAIL ** Invalid testcase parameter!"); |
|
1734 VCXLOGLO1("<<<CIptvServiceManagementApiTest::SetAllIapsL"); |
|
1735 return KErrArgument; |
|
1736 } |
|
1737 |
|
1738 CIptvServiceManagementSync::TIptvSmTestConnection msgType = static_cast<CIptvServiceManagementSync::TIptvSmTestConnection>(msgTypeInt); |
|
1739 |
|
1740 TBool ignoreReadOnly; |
|
1741 ignoreReadOnlyInt == 1 ? ignoreReadOnly = ETrue : ignoreReadOnly = EFalse; |
|
1742 |
|
1743 CIptvIapList* iapList = CIptvIapList::NewL(); |
|
1744 CleanupStack::PushL(iapList); |
|
1745 |
|
1746 TIptvIap iap; |
|
1747 |
|
1748 for(i=0;i<iapCount;i++) |
|
1749 { |
|
1750 iap.iId = i+1; |
|
1751 iap.iPriority = i+1; |
|
1752 iapList->AddIap(iap); |
|
1753 } |
|
1754 |
|
1755 respStatus = iIptvServiceManagementSync->CallSetAllIaps(msgType, *iapList, ignoreReadOnly); |
|
1756 |
|
1757 CleanupStack::PopAndDestroy(iapList); |
|
1758 |
|
1759 if(respStatus != ESucceeded) |
|
1760 { |
|
1761 VCXLOGLO2("** FAIL ** CallSetAllIapsL returned error. error: %d", respStatus ); |
|
1762 rv = respStatus; |
|
1763 } |
|
1764 |
|
1765 VCXLOGLO1("<<<CIptvServiceManagementApiTest::SetAllIapsL"); |
|
1766 return rv; |
|
1767 } |
|
1768 |
|
1769 |
|
1770 // ----------------------------------------------------------------------------- |
|
1771 // CIptvServiceManagementApiTest::SetConnectionAllowedL |
|
1772 // ----------------------------------------------------------------------------- |
|
1773 // |
|
1774 TInt CIptvServiceManagementApiTest::SetConnectionAllowedL( CStifItemParser& aItem ) |
|
1775 { |
|
1776 VCXLOGLO1(">>>CIptvServiceManagementApiTest::SetConnectionAllowedL"); |
|
1777 // Print to UI |
|
1778 _LIT( KIptvServiceManagementApiTest, "IptvServiceManagementApiTest" ); |
|
1779 _LIT( KSetConnectionAllowed, "In SetConnectionAllowedL" ); |
|
1780 TestModuleIf().Printf( 0, KIptvServiceManagementApiTest, KSetConnectionAllowed ); |
|
1781 // Print to log file |
|
1782 iLog->Log( KSetConnectionAllowed ); |
|
1783 |
|
1784 TUint32 iapId(0); |
|
1785 TPtrC iapName; |
|
1786 TInt connectionAllowedInt(0); |
|
1787 |
|
1788 // Read parameters |
|
1789 |
|
1790 aItem.SetParsingType(CStifItemParser::EQuoteStyleParsing); |
|
1791 |
|
1792 User::LeaveIfError( aItem.GetNextString(iapName) ); |
|
1793 |
|
1794 if( iapName == _L("INVALIDIAPID") ) |
|
1795 { |
|
1796 iapId = 1000; |
|
1797 } |
|
1798 else |
|
1799 if( !iIptvTestUtilities->GetIapIdL(iapName, iapId) ) |
|
1800 { |
|
1801 User::Leave( KErrArgument ); |
|
1802 } |
|
1803 |
|
1804 aItem.GetNextInt( connectionAllowedInt ); |
|
1805 |
|
1806 TBool connectionAllowed = static_cast<TBool>(connectionAllowedInt); |
|
1807 |
|
1808 MIptvServiceManagementClientObserver::TRespStatus respStatus; |
|
1809 |
|
1810 VCXLOGLO2("iapId = %d", iapId); |
|
1811 VCXLOGLO2("connectionAllowedInt = %d", connectionAllowedInt); |
|
1812 |
|
1813 TInt rv = KErrNone; |
|
1814 |
|
1815 respStatus = iIptvServiceManagementSync->CallSetConnectionAllowed(connectionAllowed, iapId); |
|
1816 |
|
1817 if(respStatus != MIptvServiceManagementClientObserver::ESucceeded) |
|
1818 { |
|
1819 VCXLOGLO2("** FAIL ** CallSetConnectionAllowedL returned error. error: %d", respStatus ); |
|
1820 rv = respStatus; |
|
1821 } |
|
1822 else |
|
1823 { |
|
1824 // Verify the result |
|
1825 CIptvNetworkSelection::TConnectionPermission currentPermission = CIptvNetworkSelection::EMustAskConfirmation; |
|
1826 |
|
1827 CIptvNetworkSelection::TConnectionPermission expectedPermission = CIptvNetworkSelection::EMustAskConfirmation; |
|
1828 if( connectionAllowed ) |
|
1829 { |
|
1830 expectedPermission = CIptvNetworkSelection::EAllowed; |
|
1831 } |
|
1832 |
|
1833 respStatus = iIptvServiceManagementSync->CallIsConnectionAllowed( currentPermission, iapId ); |
|
1834 |
|
1835 if(respStatus != MIptvServiceManagementClientObserver::ESucceeded) |
|
1836 { |
|
1837 VCXLOGLO2("** FAIL ** CallIsConnectionAllowedL failed, response = %d", respStatus); |
|
1838 rv = respStatus; |
|
1839 } |
|
1840 else |
|
1841 if( expectedPermission != currentPermission ) |
|
1842 { |
|
1843 VCXLOGLO1("** FAIL ** CallIsConnectionAllowedL returned wrong permission"); |
|
1844 rv = KErrCorrupt; |
|
1845 } |
|
1846 } |
|
1847 |
|
1848 VCXLOGLO1("<<<CIptvServiceManagementApiTest::SetConnectionAllowedL"); |
|
1849 return rv; |
|
1850 } |
|
1851 |
|
1852 // ----------------------------------------------------------------------------- |
|
1853 // CIptvServiceManagementApiTest::IsConnectionAllowedL |
|
1854 // ----------------------------------------------------------------------------- |
|
1855 // |
|
1856 TInt CIptvServiceManagementApiTest::IsConnectionAllowedL( CStifItemParser& aItem ) |
|
1857 { |
|
1858 VCXLOGLO1(">>>CIptvServiceManagementApiTest::IsConnectionAllowedL"); |
|
1859 // Print to UI |
|
1860 _LIT( KIptvServiceManagementApiTest, "IptvServiceManagementApiTest" ); |
|
1861 _LIT( KIsConnectionAllowed, "In IsConnectionAllowedL" ); |
|
1862 TestModuleIf().Printf( 0, KIptvServiceManagementApiTest, KIsConnectionAllowed ); |
|
1863 // Print to log file |
|
1864 iLog->Log( KIsConnectionAllowed ); |
|
1865 |
|
1866 TPtrC iapName; |
|
1867 TUint32 iapId(0); |
|
1868 TInt expectedPermissionInt(0); |
|
1869 |
|
1870 // Read parameters |
|
1871 |
|
1872 aItem.SetParsingType(CStifItemParser::EQuoteStyleParsing); |
|
1873 |
|
1874 User::LeaveIfError( aItem.GetNextString(iapName) ); |
|
1875 |
|
1876 if( iapName == _L("INVALIDIAPID") ) |
|
1877 { |
|
1878 iapId = 1000; |
|
1879 } |
|
1880 else |
|
1881 if( !iIptvTestUtilities->GetIapIdL(iapName, iapId) ) |
|
1882 { |
|
1883 User::Leave( KErrArgument ); |
|
1884 } |
|
1885 |
|
1886 aItem.GetNextInt(expectedPermissionInt); |
|
1887 |
|
1888 if(expectedPermissionInt < 0) |
|
1889 { |
|
1890 VCXLOGLO1("** FAIL ** Invalid testcase parameter!"); |
|
1891 VCXLOGLO1("<<<CIptvServiceManagementApiTest::IsConnectionAllowedL"); |
|
1892 return KErrArgument; |
|
1893 } |
|
1894 |
|
1895 CIptvNetworkSelection::TConnectionPermission expectedPermission = static_cast<CIptvNetworkSelection::TConnectionPermission>(expectedPermissionInt); |
|
1896 |
|
1897 if(expectedPermission == CIptvNetworkSelection::ENotAllowed) |
|
1898 { |
|
1899 expectedPermission = CIptvNetworkSelection::EMustAskConfirmation; |
|
1900 } |
|
1901 |
|
1902 MIptvServiceManagementClientObserver::TRespStatus respStatus; |
|
1903 |
|
1904 VCXLOGLO2("iapId = %d", iapId); |
|
1905 VCXLOGLO2("expectedPermissionInt = %d", expectedPermissionInt); |
|
1906 |
|
1907 TInt rv = KErrNone; |
|
1908 |
|
1909 CIptvNetworkSelection::TConnectionPermission permission = CIptvNetworkSelection::ENotAllowed; |
|
1910 |
|
1911 respStatus = iIptvServiceManagementSync->CallIsConnectionAllowed(permission, iapId); |
|
1912 |
|
1913 if(respStatus != MIptvServiceManagementClientObserver::ESucceeded) |
|
1914 { |
|
1915 VCXLOGLO2("** FAIL ** CallIsConnectionAllowedL failed, response = %d", respStatus); |
|
1916 rv = respStatus; |
|
1917 } |
|
1918 else |
|
1919 if(permission != expectedPermission) |
|
1920 { |
|
1921 VCXLOGLO1("** FAIL ** CallIsConnectionAllowedL returned wrong permission"); |
|
1922 rv = KErrCorrupt; |
|
1923 } |
|
1924 |
|
1925 VCXLOGLO1("<<<CIptvServiceManagementApiTest::IsConnectionAllowedL"); |
|
1926 return rv; |
|
1927 |
|
1928 } |
|
1929 |
|
1930 // ----------------------------------------------------------------------------- |
|
1931 // CIptvServiceManagementApiTest::GetServicesL |
|
1932 // ----------------------------------------------------------------------------- |
|
1933 // |
|
1934 TInt CIptvServiceManagementApiTest::GetServicesL( CStifItemParser& aItem ) |
|
1935 { |
|
1936 VCXLOGLO1(">>>CIptvServiceManagementApiTest::GetServicesL"); |
|
1937 // Print to UI |
|
1938 _LIT( KIptvServiceManagementApiTest, "IptvServiceManagementApiTest" ); |
|
1939 _LIT( KGetServices, "In GetServicesL" ); |
|
1940 TestModuleIf().Printf( 0, KIptvServiceManagementApiTest, KGetServices ); |
|
1941 // Print to log file |
|
1942 iLog->Log( KGetServices ); |
|
1943 |
|
1944 TRespStatus respStatus = ESucceeded; |
|
1945 TInt rv = KErrNone; |
|
1946 TInt i = 0; |
|
1947 CDesC8ArraySeg* servicesArrayDesc = NULL; |
|
1948 TInt msgTypeInt(0); |
|
1949 TUint startId(0); |
|
1950 TUint endId(0); |
|
1951 |
|
1952 aItem.GetNextInt(msgTypeInt); |
|
1953 |
|
1954 CIptvServiceManagementSync::TIptvSmTestConnection msgType = static_cast<CIptvServiceManagementSync::TIptvSmTestConnection>(msgTypeInt); |
|
1955 |
|
1956 aItem.GetNextInt(startId); |
|
1957 aItem.GetNextInt(endId); |
|
1958 |
|
1959 VCXLOGLO2("startId = %d", startId); |
|
1960 VCXLOGLO2("endId = %d", endId); |
|
1961 |
|
1962 iServiceStore->RefreshServicesFromDbL(KNoFilter, KNoSort); |
|
1963 |
|
1964 respStatus = iIptvServiceManagementSync->CallGetServices(msgType, |
|
1965 startId, |
|
1966 endId, |
|
1967 &servicesArrayDesc); |
|
1968 if(servicesArrayDesc != NULL) |
|
1969 { |
|
1970 |
|
1971 VCXLOGLO1("Services:"); |
|
1972 for(i = 0; i < servicesArrayDesc->MdcaCount(); i++) |
|
1973 { |
|
1974 CIptvService* iptvService = CIptvService::NewL(); |
|
1975 |
|
1976 iptvService->SetL(servicesArrayDesc->MdcaPoint(i)); |
|
1977 iIptvTestUtilities->PrintIptvService(iptvService); |
|
1978 |
|
1979 delete iptvService; |
|
1980 } |
|
1981 } |
|
1982 |
|
1983 if(respStatus != ESucceeded && servicesArrayDesc != NULL) |
|
1984 { |
|
1985 VCXLOGLO2("** FAIL ** CallGetServices returned error. error: %d", respStatus ); |
|
1986 if(servicesArrayDesc != NULL) |
|
1987 { |
|
1988 servicesArrayDesc->Reset(); |
|
1989 delete servicesArrayDesc; |
|
1990 servicesArrayDesc = NULL; |
|
1991 } |
|
1992 else |
|
1993 { |
|
1994 VCXLOGLO1("** FAIL ** servicesArrayDesc is NULL"); |
|
1995 } |
|
1996 |
|
1997 rv = respStatus; |
|
1998 } |
|
1999 else |
|
2000 { |
|
2001 // verify that right services were returned. |
|
2002 } |
|
2003 |
|
2004 VCXLOGLO1("<<<CIptvServiceManagementApiTest::GetServicesL"); |
|
2005 return rv; |
|
2006 } |
|
2007 |
|
2008 // ----------------------------------------------------------------------------- |
|
2009 // CIptvServiceManagementApiTest::GetAllSelectedServicesL |
|
2010 // ----------------------------------------------------------------------------- |
|
2011 // |
|
2012 TInt CIptvServiceManagementApiTest::GetAllSelectedServicesL( CStifItemParser& aItem ) |
|
2013 { |
|
2014 VCXLOGLO1(">>>CIptvServiceManagementApiTest::GetAllSelectedServicesL"); |
|
2015 // Print to UI |
|
2016 _LIT( KIptvServiceManagementApiTest, "IptvServiceManagementApiTest" ); |
|
2017 _LIT( KGetAllSelectedServices, "In GetAllSelectedServicesL" ); |
|
2018 TestModuleIf().Printf( 0, KIptvServiceManagementApiTest, KGetAllSelectedServices ); |
|
2019 // Print to log file |
|
2020 iLog->Log( KGetAllSelectedServices ); |
|
2021 TRespStatus respStatus = ESucceeded; |
|
2022 TInt rv = KErrNone; |
|
2023 CDesC8ArraySeg* selectedServicesArray = NULL; |
|
2024 |
|
2025 TInt msgTypeInt; |
|
2026 aItem.GetNextInt(msgTypeInt); |
|
2027 |
|
2028 CIptvServiceManagementSync::TIptvSmTestConnection msgType = |
|
2029 static_cast<CIptvServiceManagementSync::TIptvSmTestConnection>(msgTypeInt); |
|
2030 |
|
2031 // Get selected services |
|
2032 respStatus = iIptvServiceManagementSync->CallGetServicesFiltered( |
|
2033 CIptvServiceManagementClient::ESelectedServices, |
|
2034 CIptvServiceManagementClient::EDisplayOrderAscending, |
|
2035 msgType, |
|
2036 &selectedServicesArray |
|
2037 ); |
|
2038 |
|
2039 if(respStatus != MIptvServiceManagementClientObserver::ESucceeded) |
|
2040 { |
|
2041 if(selectedServicesArray) |
|
2042 { |
|
2043 selectedServicesArray->Reset(); |
|
2044 delete selectedServicesArray; |
|
2045 selectedServicesArray = NULL; |
|
2046 } |
|
2047 |
|
2048 VCXLOGLO2("** FAIL ** CallGetServices returned error. error: %d", respStatus ); |
|
2049 rv = respStatus; |
|
2050 } |
|
2051 |
|
2052 VCXLOGLO1("<<<CIptvServiceManagementApiTest::GetAllSelectedServicesL"); |
|
2053 return rv; |
|
2054 |
|
2055 } |
|
2056 |
|
2057 // ----------------------------------------------------------------------------- |
|
2058 // CIptvServiceManagementApiTest::GetServicesFilteredL |
|
2059 // ----------------------------------------------------------------------------- |
|
2060 // |
|
2061 TInt CIptvServiceManagementApiTest::GetServicesFilteredL( CStifItemParser& aItem ) |
|
2062 { |
|
2063 VCXLOGLO1(">>>CIptvServiceManagementApiTest::GetServicesFilteredL"); |
|
2064 // Print to UI |
|
2065 _LIT( KIptvServiceManagementApiTest, "IptvServiceManagementApiTest" ); |
|
2066 _LIT( KGetServicesFilteredL, "In GetServicesFilteredL" ); |
|
2067 TestModuleIf().Printf( 0, KIptvServiceManagementApiTest, KGetServicesFilteredL ); |
|
2068 // Print to log file |
|
2069 iLog->Log( KGetServicesFilteredL ); |
|
2070 TRespStatus respStatus = ESucceeded; |
|
2071 TInt rv = KErrNone; |
|
2072 CDesC8ArraySeg* selectedServicesArray = NULL; |
|
2073 |
|
2074 TInt msgTypeInt; |
|
2075 TInt expectedServiceCount = 0; |
|
2076 TUint32 flags = 0; |
|
2077 |
|
2078 aItem.GetNextInt(msgTypeInt); |
|
2079 CIptvServiceManagementSync::TIptvSmTestConnection msgType = static_cast<CIptvServiceManagementSync::TIptvSmTestConnection>(msgTypeInt); |
|
2080 |
|
2081 aItem.GetNextInt(expectedServiceCount); |
|
2082 |
|
2083 TInt orderInt = 2; |
|
2084 aItem.GetNextInt(orderInt); |
|
2085 CIptvServiceManagementClient::TOrder order = static_cast<CIptvServiceManagementClient::TOrder>(orderInt); |
|
2086 VCXLOGLO2("Order: %d", order); |
|
2087 |
|
2088 TBuf<256> searchLimitFlags; |
|
2089 |
|
2090 TInt flagInt = 0; |
|
2091 while(KErrNone == aItem.GetNextInt(flagInt)) |
|
2092 { |
|
2093 flags |= flagInt; |
|
2094 |
|
2095 CIptvServiceManagementClient::TSearchLimitFlag flag = static_cast<CIptvServiceManagementClient::TSearchLimitFlag>(flagInt); |
|
2096 |
|
2097 switch(flag) |
|
2098 { |
|
2099 case CIptvServiceManagementClient::ESelectedServices: |
|
2100 { |
|
2101 searchLimitFlags.Append(_L("ESelectedServices ")); |
|
2102 VCXLOGLO1("Appending ESelectedServices to search flags"); |
|
2103 } |
|
2104 break; |
|
2105 case CIptvServiceManagementClient::EMainServices: |
|
2106 { |
|
2107 searchLimitFlags.Append(_L("EMainServices ")); |
|
2108 VCXLOGLO1("Appending EMainServices to search flags"); |
|
2109 } |
|
2110 break; |
|
2111 case CIptvServiceManagementClient::ESubServices: |
|
2112 { |
|
2113 searchLimitFlags.Append(_L("ESubServices ")); |
|
2114 VCXLOGLO1("Appending ESubServices to search flags"); |
|
2115 } |
|
2116 break; |
|
2117 case CIptvServiceManagementClient::EVod: |
|
2118 { |
|
2119 searchLimitFlags.Append(_L("EVod ")); |
|
2120 VCXLOGLO1("Appending EVod to search flags"); |
|
2121 } |
|
2122 break; |
|
2123 case CIptvServiceManagementClient::ELiveTv: |
|
2124 { |
|
2125 searchLimitFlags.Append(_L("ELiveTv ")); |
|
2126 VCXLOGLO1("Appending ELiveTv to search flags"); |
|
2127 } |
|
2128 break; |
|
2129 case CIptvServiceManagementClient::EVodCast: |
|
2130 { |
|
2131 searchLimitFlags.Append(_L("EVodCast ")); |
|
2132 VCXLOGLO1("Appending EVodCast to search flags"); |
|
2133 } |
|
2134 break; |
|
2135 case CIptvServiceManagementClient::EBrowser: |
|
2136 { |
|
2137 searchLimitFlags.Append(_L("EBrowser ")); |
|
2138 VCXLOGLO1("Appending EBrowser to search flags"); |
|
2139 } |
|
2140 break; |
|
2141 case CIptvServiceManagementClient::EApplication: |
|
2142 { |
|
2143 searchLimitFlags.Append(_L("EApplication ")); |
|
2144 VCXLOGLO1("Appending EApplication to search flags"); |
|
2145 } |
|
2146 break; |
|
2147 case CIptvServiceManagementClient::EVideoRemote: |
|
2148 { |
|
2149 searchLimitFlags.Append(_L("EVideoRemote ")); |
|
2150 VCXLOGLO1("Appending EVideoRemote to search flags"); |
|
2151 } |
|
2152 break; |
|
2153 case CIptvServiceManagementClient::EMobileTv: |
|
2154 { |
|
2155 searchLimitFlags.Append(_L("EMobileTv ")); |
|
2156 VCXLOGLO1("Appending EMobileTv to search flags"); |
|
2157 } |
|
2158 break; |
|
2159 case CIptvServiceManagementClient::EServiceGroup: |
|
2160 { |
|
2161 searchLimitFlags.Append(_L("EServiceGroup ")); |
|
2162 VCXLOGLO1("Appending EServiceGroup to search flags"); |
|
2163 } |
|
2164 break; |
|
2165 case CIptvServiceManagementClient::EGroupedServices: |
|
2166 { |
|
2167 searchLimitFlags.Append(_L("EGroupedServices ")); |
|
2168 VCXLOGLO1("Appending EGroupedServices to search flags"); |
|
2169 } |
|
2170 break; |
|
2171 case CIptvServiceManagementClient::EOther: |
|
2172 { |
|
2173 searchLimitFlags.Append(_L("EOther ")); |
|
2174 VCXLOGLO1("Appending EOther to search flags"); |
|
2175 } |
|
2176 break; |
|
2177 case 0: |
|
2178 break; |
|
2179 default: |
|
2180 VCXLOGLO2("Invalid search limit flag in test case! %d", flagInt); |
|
2181 VCXLOGLO1("<<<CIptvServiceManagementApiTest::GetServicesFilteredL"); |
|
2182 return KErrArgument; |
|
2183 } |
|
2184 } |
|
2185 |
|
2186 VCXLOGLO2("Search limit flags: ", &searchLimitFlags); |
|
2187 |
|
2188 iServiceStore->RefreshServicesFromDbL(KNoFilter, KNoSort); |
|
2189 |
|
2190 respStatus = iIptvServiceManagementSync->CallGetServicesFiltered(flags, |
|
2191 order, |
|
2192 msgType, |
|
2193 &selectedServicesArray |
|
2194 ); |
|
2195 |
|
2196 if(respStatus != MIptvServiceManagementClientObserver::ESucceeded) |
|
2197 { |
|
2198 if(selectedServicesArray) |
|
2199 { |
|
2200 selectedServicesArray->Reset(); |
|
2201 delete selectedServicesArray; |
|
2202 selectedServicesArray = NULL; |
|
2203 } |
|
2204 VCXLOGLO2("** FAIL ** CallGetServicesFiltered returned error. error: %d", respStatus ); |
|
2205 rv = respStatus; |
|
2206 } |
|
2207 else |
|
2208 { |
|
2209 if(selectedServicesArray != NULL) |
|
2210 { |
|
2211 /* Print all received services */ |
|
2212 VCXLOGLO1("Filtered services:"); |
|
2213 TInt i( 0 ); |
|
2214 for(i = 0; i < selectedServicesArray->MdcaCount(); i++) |
|
2215 { |
|
2216 CIptvService* iptvService = CIptvService::NewL(); |
|
2217 iptvService->SetL(selectedServicesArray->MdcaPoint(i)); |
|
2218 iIptvTestUtilities->PrintIptvService(iptvService); |
|
2219 delete iptvService; |
|
2220 } |
|
2221 |
|
2222 /* Verifying the expected amount of services */ |
|
2223 VCXLOGLO3("CIptvServiceManagementApiTest::GetServicesFilteredL -- Expected %d, Received %d", expectedServiceCount, selectedServicesArray->MdcaCount()); |
|
2224 |
|
2225 if( expectedServiceCount != -1 ) |
|
2226 { |
|
2227 /* We were expecting some count */ |
|
2228 if( expectedServiceCount != selectedServicesArray->MdcaCount() ) |
|
2229 { |
|
2230 VCXLOGLO1("Wrong service count!"); |
|
2231 VCXLOGLO1("<<<CIptvServiceManagementApiTest::GetServicesFilteredL"); |
|
2232 return KErrCorrupt; |
|
2233 } |
|
2234 } |
|
2235 } |
|
2236 } |
|
2237 |
|
2238 VCXLOGLO1("<<<CIptvServiceManagementApiTest::GetServicesFilteredL"); |
|
2239 return rv; |
|
2240 } |
|
2241 |
|
2242 // ----------------------------------------------------------------------------- |
|
2243 // CIptvServiceManagementApiTest::GetServicesByTypeL |
|
2244 // ----------------------------------------------------------------------------- |
|
2245 // |
|
2246 TInt CIptvServiceManagementApiTest::GetServicesByTypeL( CStifItemParser& aItem ) |
|
2247 { |
|
2248 VCXLOGLO1(">>>CIptvServiceManagementApiTest::GetServicesByTypeL"); |
|
2249 // Print to UI |
|
2250 _LIT( KIptvServiceManagementApiTest, "IptvServiceManagementApiTest" ); |
|
2251 _LIT( KWhere, "In GetServicesByTypeL" ); |
|
2252 TestModuleIf().Printf( 0, KIptvServiceManagementApiTest, KWhere ); |
|
2253 // Print to log file |
|
2254 iLog->Log( KWhere ); |
|
2255 |
|
2256 TInt rv = KErrNone; |
|
2257 |
|
2258 TInt msgTypeInt; |
|
2259 TInt expectedServiceCount = 0; |
|
2260 |
|
2261 User::LeaveIfError( aItem.GetNextInt(msgTypeInt) ); |
|
2262 |
|
2263 User::LeaveIfError( aItem.GetNextInt(expectedServiceCount) ); |
|
2264 |
|
2265 TInt type; |
|
2266 User::LeaveIfError( aItem.GetNextInt( type ) ); |
|
2267 |
|
2268 VCXLOGLO2("Services with type %d requested.", type); |
|
2269 |
|
2270 iServiceStore->RefreshServicesFromDbL(KNoFilter, KNoSort); |
|
2271 |
|
2272 TInt typeCount(0); |
|
2273 for( TInt i=0; i<iServiceStore->ServiceCount(); i++ ) |
|
2274 { |
|
2275 if( iServiceStore->GetService(i)->GetType() == type ) |
|
2276 { |
|
2277 typeCount++; |
|
2278 } |
|
2279 } |
|
2280 |
|
2281 // Verifying the expected amount of services |
|
2282 VCXLOGLO3("CIptvServiceManagementApiTest::GetServicesFilteredL -- Expected %d, Received %d", expectedServiceCount, typeCount); |
|
2283 |
|
2284 if( expectedServiceCount != typeCount ) |
|
2285 { |
|
2286 VCXLOGLO2("Wrong service count: %d!", typeCount); |
|
2287 rv = KErrCorrupt; |
|
2288 } |
|
2289 |
|
2290 VCXLOGLO1("<<<CIptvServiceManagementApiTest::GetServicesFilteredL"); |
|
2291 return rv; |
|
2292 } |
|
2293 |
|
2294 // ----------------------------------------------------------------------------- |
|
2295 // CIptvServiceManagementApiTest::ShutdownServerL |
|
2296 // ----------------------------------------------------------------------------- |
|
2297 // |
|
2298 // Not supported |
|
2299 // |
|
2300 TInt CIptvServiceManagementApiTest::ShutdownServerL( CStifItemParser& aItem ) |
|
2301 { |
|
2302 VCXLOGLO1(">>>CIptvServiceManagementApiTest::ShutdownServerL"); |
|
2303 // Print to UI |
|
2304 _LIT( KIptvServiceManagementApiTest, "IptvServiceManagementApiTest" ); |
|
2305 _LIT( KWhere, "In ShutdownServerL" ); |
|
2306 TestModuleIf().Printf( 0, KIptvServiceManagementApiTest, KWhere ); |
|
2307 |
|
2308 // Print to log file |
|
2309 iLog->Log( KWhere ); |
|
2310 |
|
2311 aItem.SetParsingType(CStifItemParser::EQuoteStyleParsing); |
|
2312 |
|
2313 TInt msgTypeInt; |
|
2314 if( KErrNone != aItem.GetNextInt(msgTypeInt) ) |
|
2315 { |
|
2316 VCXLOGLO1("* ERROR * Specify parameter async / sync!"); |
|
2317 VCXLOGLO1("<<<CIptvServiceManagementApiTest::ShutdownServerL"); |
|
2318 return KErrArgument; |
|
2319 } |
|
2320 |
|
2321 VCXLOGLO2("MsgType: %d", msgTypeInt); |
|
2322 |
|
2323 CIptvServiceManagementSync::TIptvSmTestConnection msgType = static_cast<CIptvServiceManagementSync::TIptvSmTestConnection>(msgTypeInt); |
|
2324 |
|
2325 TRespStatus respStatus = ESucceeded; |
|
2326 |
|
2327 respStatus = iIptvServiceManagementSync->CallShutdownServer(msgType); |
|
2328 |
|
2329 if(respStatus == ESucceeded) |
|
2330 { |
|
2331 VCXLOGLO1("<<<CIptvServiceManagementApiTest::ShutdownServerL"); |
|
2332 return KErrNone; |
|
2333 } |
|
2334 |
|
2335 VCXLOGLO2("Shutdown failed with error code: %d", respStatus); |
|
2336 VCXLOGLO1("<<<CIptvServiceManagementApiTest::ShutdownServerL"); |
|
2337 return respStatus; |
|
2338 } |
|
2339 |
|
2340 // ----------------------------------------------------------------------------- |
|
2341 // CIptvServiceManagementApiTest::SetSpecialAction() |
|
2342 // ----------------------------------------------------------------------------- |
|
2343 // |
|
2344 TInt CIptvServiceManagementApiTest::SetSpecialAction( CStifItemParser& aItem ) |
|
2345 { |
|
2346 VCXLOGLO1(">>>CIptvServiceManagementApiTest::SetSpecialAction"); |
|
2347 // Print to UI |
|
2348 _LIT( KIptvServiceManagementApiTest, "IptvServiceManagementApiTest" ); |
|
2349 _LIT( KSetSpecialAction, "In SetSpecialAction" ); |
|
2350 TestModuleIf().Printf( 0, KIptvServiceManagementApiTest, KSetSpecialAction ); |
|
2351 // Print to log file |
|
2352 iLog->Log( KSetSpecialAction ); |
|
2353 |
|
2354 TInt action(-1); |
|
2355 |
|
2356 aItem.GetNextInt(action); |
|
2357 |
|
2358 if(action < 0) |
|
2359 { |
|
2360 VCXLOGLO1("Incorrect parameter."); |
|
2361 VCXLOGLO1("<<<CIptvServiceManagementApiTest::SetSpecialAction"); |
|
2362 return KErrArgument; |
|
2363 } |
|
2364 |
|
2365 iIptvServiceManagementSync->SetSpecialAction(action); |
|
2366 VCXLOGLO2("SetSpecialAction: %d", action); |
|
2367 |
|
2368 VCXLOGLO1("<<<CIptvServiceManagementApiTest::SetSpecialAction"); |
|
2369 return KErrNone; |
|
2370 } |
|
2371 |
|
2372 // ----------------------------------------------------------------------------- |
|
2373 // CIptvServiceManagementApiTest::RepeatNextRequest |
|
2374 // ----------------------------------------------------------------------------- |
|
2375 // |
|
2376 TInt CIptvServiceManagementApiTest::RepeatNextRequest( CStifItemParser& aItem ) |
|
2377 { |
|
2378 VCXLOGLO1(">>>CIptvServiceManagementApiTest::RepeatNextRequest"); |
|
2379 // Print to UI |
|
2380 _LIT( KIptvServiceManagementApiTest, "IptvServiceManagementApiTest" ); |
|
2381 _LIT( KRepeatNextRequest, "In RepeatNextRequest" ); |
|
2382 TestModuleIf().Printf( 0, KIptvServiceManagementApiTest, KRepeatNextRequest ); |
|
2383 // Print to log file |
|
2384 iLog->Log( KRepeatNextRequest ); |
|
2385 |
|
2386 TInt repeatRequest(0); |
|
2387 |
|
2388 aItem.GetNextInt(repeatRequest); |
|
2389 |
|
2390 iIptvServiceManagementSync->RepeatNextRequest(repeatRequest); |
|
2391 |
|
2392 VCXLOGLO1("<<<CIptvServiceManagementApiTest::RepeatNextRequest"); |
|
2393 |
|
2394 return KErrNone; |
|
2395 } |
|
2396 |
|
2397 // ----------------------------------------------------------------------------- |
|
2398 // CIptvServiceManagementApiTest::VerifyServerIsShutdownL |
|
2399 // ----------------------------------------------------------------------------- |
|
2400 // |
|
2401 TInt CIptvServiceManagementApiTest::VerifyServerIsShutdownL( CStifItemParser& /* aItem */ ) |
|
2402 { |
|
2403 VCXLOGLO1(">>>CIptvServiceManagementApiTest::VerifyServerIsShutdownL"); |
|
2404 // Print to UI |
|
2405 _LIT( KIptvServiceManagementApiTest, "IptvServiceManagementApiTest" ); |
|
2406 _LIT( KShutDownServer, "In VerifyServerIsShutdownL" ); |
|
2407 TestModuleIf().Printf( 0, KIptvServiceManagementApiTest, KShutDownServer ); |
|
2408 // Print to log file |
|
2409 iLog->Log( KShutDownServer ); |
|
2410 |
|
2411 TInt rv = KErrNone; |
|
2412 |
|
2413 TFindServer findIptvServer( KIptvServerName ); |
|
2414 TFullName name; |
|
2415 |
|
2416 if ( findIptvServer.Next( name ) == KErrNone ) |
|
2417 { |
|
2418 // Server running |
|
2419 VCXLOGLO1("** FAIL ** IptvServer is not closed!"); |
|
2420 VCXLOGLO2("Name: %S", &name); |
|
2421 rv = KErrCorrupt; |
|
2422 } |
|
2423 |
|
2424 VCXLOGLO1("<<<CIptvServiceManagementApiTest::VerifyServerIsShutdownL"); |
|
2425 |
|
2426 return rv; |
|
2427 } |
|
2428 |
|
2429 // ----------------------------------------------------------------------------- |
|
2430 // CIptvServiceManagementApiTest::DeAllocateResources |
|
2431 // ----------------------------------------------------------------------------- |
|
2432 // |
|
2433 void CIptvServiceManagementApiTest::DeAllocateResources() |
|
2434 { |
|
2435 VCXLOGLO1(">>>CIptvServiceManagementApiTest::DeAllocateResources"); |
|
2436 |
|
2437 iHardcodedServices.ResetAndDestroy(); |
|
2438 iHardcodedServices.Close(); |
|
2439 |
|
2440 delete iIptvServiceManagementSync; |
|
2441 iIptvServiceManagementSync = NULL; |
|
2442 |
|
2443 delete iIptvTestUtilities; |
|
2444 iIptvTestUtilities = NULL; |
|
2445 |
|
2446 if(iIapNumList) |
|
2447 { |
|
2448 iIapNumList->Reset(); |
|
2449 delete iIapNumList; |
|
2450 iIapNumList = NULL; |
|
2451 } |
|
2452 |
|
2453 TInt err = KErrNone; |
|
2454 if(iIptvTestMobilecrashWatcher) |
|
2455 { |
|
2456 TRAP(err, iIptvTestMobilecrashWatcher->CheckNewCrashesL()); |
|
2457 delete iIptvTestMobilecrashWatcher; |
|
2458 iIptvTestMobilecrashWatcher = NULL; |
|
2459 } |
|
2460 |
|
2461 if(err != KErrNone) |
|
2462 { |
|
2463 User::Leave(err); |
|
2464 } |
|
2465 |
|
2466 if(iServiceStore) |
|
2467 { |
|
2468 delete iServiceStore; |
|
2469 iServiceStore = NULL; |
|
2470 } |
|
2471 |
|
2472 delete iAlrUtil; |
|
2473 iAlrUtil = NULL; |
|
2474 |
|
2475 VCXLOGLO1("<<<CIptvServiceManagementApiTest::DeAllocateResources"); |
|
2476 } |
|
2477 |
|
2478 // ----------------------------------------------------------------------------- |
|
2479 // CIptvServiceManagementApiTest::GetCommDbIapIdByOrder |
|
2480 // ----------------------------------------------------------------------------- |
|
2481 // |
|
2482 TInt CIptvServiceManagementApiTest::GetCommDbIapIdByOrder(TInt aIndex, TUint32& aIapId) |
|
2483 { |
|
2484 VCXLOGLO1(">>>CIptvServiceManagementApiTest::GetCommDbIapIdByOrder"); |
|
2485 aIapId = 0; |
|
2486 if(aIndex >= iIapNumList->Count()) |
|
2487 { |
|
2488 VCXLOGLO1("Index out of bounds."); |
|
2489 return KErrOverflow; |
|
2490 } |
|
2491 VCXLOGLO1("<<<CIptvServiceManagementApiTest::GetCommDbIapIdByOrder"); |
|
2492 aIapId = iIapNumList->At(aIndex); |
|
2493 |
|
2494 return KErrNone; |
|
2495 } |
|
2496 |
|
2497 // ----------------------------------------------------------------------------- |
|
2498 // CIptvServiceManagementApiTest::GetServiceIdFromParam |
|
2499 // ----------------------------------------------------------------------------- |
|
2500 // |
|
2501 TInt CIptvServiceManagementApiTest::GetServiceIdFromParam(CStifItemParser& aItem, TInt& aServiceId, TDes& aServiceName) |
|
2502 { |
|
2503 VCXLOGLO1(">>>CIptvServiceManagementApiTest::ReadServiceNameOrIdParam"); |
|
2504 |
|
2505 aItem.SetParsingType(CStifItemParser::EQuoteStyleParsing); |
|
2506 |
|
2507 TPtrC serviceString; |
|
2508 |
|
2509 if(aItem.GetNextString(serviceString) != KErrNone) |
|
2510 { |
|
2511 VCXLOGLO1("Can't read testcase parameter, serviceName/number !!!"); |
|
2512 VCXLOGLO1("<<<CIptvServiceManagementApiTest::ReadServiceNameOrIdParam"); |
|
2513 return KErrArgument; |
|
2514 } |
|
2515 |
|
2516 TInt err = KErrNone; |
|
2517 |
|
2518 if(KErrNone != CIptvTestUtilities::ParseIntFromString(aServiceId, serviceString)) |
|
2519 { |
|
2520 // service name specified, find the service ID |
|
2521 |
|
2522 aServiceName = serviceString; |
|
2523 VCXLOGLO2("ServiceName specified: %S", &aServiceName); |
|
2524 |
|
2525 TInt rv = KErrNone; |
|
2526 |
|
2527 TRAPD(err, rv = iIptvTestUtilities->GetServiceIdByNameL(aServiceName, aServiceId)); |
|
2528 if(KErrNone != err) |
|
2529 { |
|
2530 VCXLOGLO2("GetServiceIdByNameL caused a leave: %d.", err); |
|
2531 VCXLOGLO1("<<<CIptvServiceManagementApiTest::ReadServiceNameOrIdParam"); |
|
2532 return err; |
|
2533 } |
|
2534 if(KErrNone != rv) |
|
2535 { |
|
2536 VCXLOGLO2("GetServiceIdByNameL returned error: %d.", rv); |
|
2537 VCXLOGLO1("<<<CIptvServiceManagementApiTest::ReadServiceNameOrIdParam"); |
|
2538 return rv; |
|
2539 } |
|
2540 } |
|
2541 else |
|
2542 { |
|
2543 RPointerArray<CIptvService> services; |
|
2544 |
|
2545 VCXLOGLO2("ServiceID specified: %d", aServiceId); |
|
2546 |
|
2547 CleanupResetAndDestroyPushL(services); |
|
2548 |
|
2549 if(!iIptvTestUtilities->GetServicesFromDbL(services)) |
|
2550 { |
|
2551 VCXLOGLO1("GetServicesFromDbL returned failed."); |
|
2552 VCXLOGLO1("<<<CIptvServiceManagementApiTest::ReadServiceNameOrIdParam"); |
|
2553 |
|
2554 CleanupStack::PopAndDestroy(&services); |
|
2555 return err; |
|
2556 } |
|
2557 |
|
2558 TInt i; |
|
2559 for(i=0; i<services.Count(); i++) |
|
2560 { |
|
2561 VCXLOGLO2("ServiceName id: %d", services[i]->GetId() ); |
|
2562 if(services[i]->GetId() == aServiceId) |
|
2563 { |
|
2564 aServiceName = services[i]->GetName(); |
|
2565 break; |
|
2566 } |
|
2567 } |
|
2568 CleanupStack::PopAndDestroy(&services); |
|
2569 } |
|
2570 |
|
2571 VCXLOGLO1("<<<CIptvServiceManagementApiTest::ReadServiceNameOrIdParam"); |
|
2572 |
|
2573 return err; |
|
2574 } |
|
2575 |
|
2576 // End of File |
|
2577 |
|
2578 // ========================== OTHER EXPORTED FUNCTIONS ========================= |
|
2579 // None |
|
2580 |
|
2581 |
|
2582 // End of File |