|
1 /* |
|
2 * Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 // INCLUDES |
|
20 #include "MT_CFClient.h" |
|
21 |
|
22 #include <EUnitMacros.h> |
|
23 #include <cfclient.h> |
|
24 #include <cfcontextsubscription.h> |
|
25 #include <cfcontextindication.h> |
|
26 #include <cfactionsubscription.h> |
|
27 #include <cfactionindication.h> |
|
28 #include <cfcontextsourcecommand.h> |
|
29 #include <f32file.h> |
|
30 #include <S32MEM.h> |
|
31 #include <e32property.h> |
|
32 #include <BAUTILS.H> |
|
33 |
|
34 #include "cfcommon.h" |
|
35 #include "testcontextdata.h" |
|
36 #include "cfcontextobjectimpl.h" |
|
37 #include "testcontextsourceplugin.h" |
|
38 #include "testcontextsourcepluginconst.hrh" |
|
39 #include "CFTestDelay.h" |
|
40 #include "cfenvutils.h" |
|
41 |
|
42 // CONSTANTS |
|
43 |
|
44 _LIT_SECURITY_POLICY_PASS( KPassSec ); |
|
45 _LIT_SECURITY_POLICY_FAIL( KFailSec ); |
|
46 |
|
47 _LIT( KContextSourceA, "TestSourceA" ); |
|
48 _LIT( KContextTypeA, "TestTypeA" ); |
|
49 _LIT( KContextValueA, "TestValueA" ); |
|
50 _LIT( KContextValueB, "TestValueB" ); |
|
51 |
|
52 _LIT( KContextSourceFormatWild, "Source" ); |
|
53 _LIT( KContextTypeFormatWild, "Type" ); |
|
54 _LIT( KContextSourceFormat, "Source.%d" ); |
|
55 _LIT( KContextTypeFormat, "Type.%d" ); |
|
56 _LIT( KContextValueFormat, "Value.%d" ); |
|
57 |
|
58 _LIT( KActionIdFormat, "AcionId.%d" ); |
|
59 |
|
60 _LIT( KActionA, "TestActionA" ); |
|
61 _LIT( KActionAParamA1, "ParamA1" ); |
|
62 _LIT( KActionAValueA1, "ValueA1" ); |
|
63 |
|
64 _LIT( KActionB, "TestActionB" ); |
|
65 _LIT( KActionBParamB1, "ParamB1" ); |
|
66 _LIT( KActionBValueB1, "ValueB1" ); |
|
67 _LIT( KActionBParamB2, "ParamB2" ); |
|
68 _LIT( KActionBValueB2, "ValueB2" ); |
|
69 |
|
70 _LIT( KActionC, "TestActionC" ); |
|
71 |
|
72 _LIT( KTestContextSource, "TestContextSource" ); |
|
73 _LIT( KTestContextType, "SubsNoSubsTest" ); |
|
74 _LIT( KTestContextType2, "SubsNoSubsTest2" ); |
|
75 _LIT( KTestContextValueType, "TestValue" ); |
|
76 _LIT( KTestContextValueSubsOk, "SubsOk" ); |
|
77 _LIT( KTestContextValueNosubsOk, "NoSubsOk" ); |
|
78 _LIT( KTestContextValueNok, "Nok" ); |
|
79 |
|
80 const TUid KTestContextSourcePluginImplUid = |
|
81 { |
|
82 KTestContextSourcePluginImplementationUid |
|
83 }; |
|
84 const TUid KBogusContextSourcePluginImplUid = |
|
85 { |
|
86 0xBAD50BAD |
|
87 }; |
|
88 |
|
89 const TInt KSecond = 1000000; |
|
90 |
|
91 _LIT( KSourceCommandId, "sourceCommand" ); |
|
92 _LIT( KSourceCommandUidId, "uid" ); |
|
93 _LIT( KSourceCommandParamCmd, "cmd" ); |
|
94 _LIT( KSourceCommandParamCmdParam, "cmdParam" ); |
|
95 _LIT( KSourceCommandParamCmdInfo, "cmdInfo" ); |
|
96 _LIT( KSourceCommandParamModifiers, "modifiers" ); |
|
97 _LIT( KSourceCommandAttributeType, "type" ); |
|
98 _LIT( KSourceCommandAttributeMode, "mode" ); |
|
99 _LIT( KSourceCommandAttributeOverride, "override" ); |
|
100 _LIT( KSourceCommandAttributeText, "text" ); |
|
101 _LIT( KSourceCommandAttributeValueText, "activate from really clean state" ); |
|
102 _LIT( KSourceCommandAttributeValue, "value" ); |
|
103 _LIT( KSourceCommandAttributeValueYes, "yes" ); |
|
104 _LIT( KSourceCommandAttributeValueActivate, "Activate" ); |
|
105 _LIT( KSourceCommandAttributeValueDeactivate, "Deactivate" ); |
|
106 _LIT( KSourceCommandAttributeValueClean, "clean" ); |
|
107 _LIT( KSourceCommandAttributeValueReally, "really" ); |
|
108 _LIT( KSourceCommandAttributeValueFull, "full" ); |
|
109 _LIT( KSourceCommandAttributeValueNoException, "noException" ); |
|
110 |
|
111 _LIT( KSourceCommandPluginScriptContextSource, "TestSourcePlugIn" ); |
|
112 _LIT( KSourceCommandClientScriptContextSource, "TestSourceClient" ); |
|
113 _LIT( KSourceCommandScriptContextType, "SendSourceCommand" ); |
|
114 _LIT( KSourceCommandScript1ContextValueActivate, "A" ); |
|
115 _LIT( KSourceCommandScript1ContextValueDeactivate, "B" ); |
|
116 _LIT( KSourceCommandScript2ContextValueActivate, "A2" ); |
|
117 _LIT( KSourceCommandScript2ContextValueDeactivate, "B2" ); |
|
118 |
|
119 _LIT( KSourceCommandSignalContextSource, "TestSourcePlugin" ); |
|
120 _LIT( KSourceCommandSignalContextType, "SourceCommand" ); |
|
121 _LIT( KSourceCommandSignalContextValueActivated, "Activated" ); |
|
122 _LIT( KSourceCommandSignalContextValueDeactivated, "Deactivated" ); |
|
123 _LIT( KSourceCommandSignalContextValueActiveReqActivate, "ActiveReqActivate" ); |
|
124 _LIT( KSourceCommandSignalContextValueActiveReqDeactivate, "ActiveReqDeactivate" ); |
|
125 _LIT( KSourceCommandSignalContextValueDeactiveReqDeactivate, "DeactiveReqDeactivate" ); |
|
126 _LIT( KSourceCommandSignalContextValueError, "Error" ); |
|
127 |
|
128 _LIT( KContextValueTriggerForSourceCommandClient, "SourceCommandClient" ); |
|
129 |
|
130 _LIT( KReservedActionPublishContext, "publishContext" ); |
|
131 _LIT( KReservedActionPublishContext2, "PUBLISHCONTEXT" ); |
|
132 _LIT( KReservedActionSourceCommand, "sourceCommand" ); |
|
133 _LIT( KReservedActionSourceCommand2, "SOURCECOMMAND" ); |
|
134 |
|
135 _LIT( KRomScriptAutoDefineContextSource, "RomScript" ); |
|
136 _LIT( KRomScriptAutoDefineContextType, "NewContext" ); |
|
137 _LIT( KRomScriptAutoDefineContextValue, "AutoDefined" ); |
|
138 _LIT( KRomScriptTriggerAutoDefineContextSource, "TestRomScript" ); |
|
139 _LIT( KRomScriptTriggerAutoDefineContextType, "PublishContext" ); |
|
140 _LIT( KRomScriptTriggerAutoDefineContextValue, "AutoDefine" ); |
|
141 |
|
142 _LIT( KRomScriptDetectedAutoDefinedContextSource, "AutoDefined" ); |
|
143 _LIT( KRomScriptDetectedAutoDefinedContextType, "RomScriptContext" ); |
|
144 _LIT( KRomScriptDetectedAutoDefinedContextValue, "Detected" ); |
|
145 |
|
146 // LOCAL DEFINITIONS |
|
147 |
|
148 /** |
|
149 * Clean up item for RContextObjectArray |
|
150 */ |
|
151 LOCAL_C void CleanupContextObjectArray( TAny* aArray ) |
|
152 { |
|
153 RContextObjectArray* array = static_cast<RContextObjectArray*>( aArray ); |
|
154 array->ResetAndDestroy(); |
|
155 } |
|
156 |
|
157 /** |
|
158 * Clean up function for RContextObjectArray |
|
159 */ |
|
160 LOCAL_C void CleanupResetAndDestroyPushL( RContextObjectArray& aArray ) |
|
161 { |
|
162 TCleanupItem item( CleanupContextObjectArray, &aArray ); |
|
163 CleanupStack::PushL( item ); |
|
164 } |
|
165 |
|
166 /** |
|
167 * Clean up item for RContextQueryArray |
|
168 */ |
|
169 LOCAL_C void CleanupContextQueryArray( TAny* aArray ) |
|
170 { |
|
171 RContextQueryArray* array = static_cast<RContextQueryArray*>( aArray ); |
|
172 array->ResetAndDestroy(); |
|
173 } |
|
174 |
|
175 /** |
|
176 * Clean up function for RContextQueryArray |
|
177 */ |
|
178 LOCAL_C void CleanupResetAndDestroyPushL( RContextQueryArray& aArray ) |
|
179 { |
|
180 TCleanupItem item( CleanupContextQueryArray, &aArray ); |
|
181 CleanupStack::PushL( item ); |
|
182 } |
|
183 |
|
184 /** |
|
185 * Wait info. |
|
186 */ |
|
187 NONSHARABLE_CLASS( TWaitInfo ) |
|
188 { |
|
189 public: |
|
190 |
|
191 CPeriodic* iPeriodic; |
|
192 CActiveSchedulerWait* iWait; |
|
193 }; |
|
194 |
|
195 /** |
|
196 * Call back method when we need to stop active scheduler wait. |
|
197 */ |
|
198 LOCAL_C TInt WaitCallBack( TAny* aSelf ) |
|
199 { |
|
200 if( aSelf ) |
|
201 { |
|
202 TWaitInfo* info = static_cast<TWaitInfo*>( aSelf ); |
|
203 if( info->iPeriodic ) |
|
204 { |
|
205 info->iPeriodic->Cancel(); |
|
206 } |
|
207 if( info->iWait ) |
|
208 { |
|
209 if( info->iWait->IsStarted() ) |
|
210 { |
|
211 info->iWait->AsyncStop(); |
|
212 } |
|
213 } |
|
214 } |
|
215 |
|
216 return KErrNone; |
|
217 } |
|
218 |
|
219 /** |
|
220 * Helper method to wait current scheduler before teardown is completed. |
|
221 */ |
|
222 LOCAL_C void Wait( TInt aIntervalInMicorseconds ) |
|
223 { |
|
224 TWaitInfo info; |
|
225 |
|
226 // Construct periodic |
|
227 CPeriodic* periodic = CPeriodic::NewL( CActive::EPriorityStandard ); |
|
228 CleanupStack::PushL( periodic ); |
|
229 info.iPeriodic = periodic; |
|
230 |
|
231 // Construct active scheduler wait |
|
232 CActiveSchedulerWait* wait = new( ELeave ) CActiveSchedulerWait; |
|
233 CleanupStack::PushL( wait ); |
|
234 info.iWait = wait; |
|
235 |
|
236 // Start timer and wait |
|
237 TCallBack cb( WaitCallBack, &info ); |
|
238 periodic->Start( aIntervalInMicorseconds, aIntervalInMicorseconds, cb ); |
|
239 wait->Start(); |
|
240 |
|
241 // Cleanup |
|
242 CleanupStack::PopAndDestroy( wait ); |
|
243 CleanupStack::PopAndDestroy( periodic ); |
|
244 } |
|
245 |
|
246 const TInt KDelay = 2000000; // 2 seconds |
|
247 const TInt KConfigDelay = 4000; |
|
248 |
|
249 /** |
|
250 * Orders source command sender identities. |
|
251 * @param aFirst First source command sender id. |
|
252 * @param aSecond Second source command sender id. |
|
253 * @return Zero if the uid and the script id of the first and second are equal. |
|
254 * Negative value if the uid of the first is less than the uid of the second |
|
255 * or script id of the first is less than second's when uid are equal. |
|
256 * Positive value if the uid of the first is greater than the uid of the |
|
257 * second or script id of the first is greater than second's when uid are |
|
258 * equal. |
|
259 */ |
|
260 LOCAL_C TInt SourceCommandSenderIdOrder( |
|
261 const TCFSourceCommandSenderId& aFirst, |
|
262 const TCFSourceCommandSenderId& aSecond ) |
|
263 { |
|
264 TInt orderValue = 1; |
|
265 |
|
266 if ( aFirst.iSender == aSecond.iSender ) |
|
267 { |
|
268 if ( aFirst.iScriptId == aSecond.iScriptId ) |
|
269 { |
|
270 orderValue = 0; |
|
271 } |
|
272 else if ( aFirst.iScriptId < aSecond.iScriptId ) |
|
273 { |
|
274 orderValue = -1; |
|
275 } |
|
276 } |
|
277 else if ( aFirst.iSender < aSecond.iSender ) |
|
278 { |
|
279 orderValue = -1; |
|
280 } |
|
281 |
|
282 return orderValue; |
|
283 } |
|
284 |
|
285 |
|
286 // CONSTRUCTION |
|
287 MT_CFClient* MT_CFClient::NewL( ) |
|
288 { |
|
289 MT_CFClient* self = MT_CFClient::NewLC ( ); |
|
290 CleanupStack::Pop ( ); |
|
291 |
|
292 return self; |
|
293 } |
|
294 |
|
295 MT_CFClient* MT_CFClient::NewLC( ) |
|
296 { |
|
297 MT_CFClient* self = new( ELeave ) MT_CFClient(); |
|
298 CleanupStack::PushL ( self ); |
|
299 |
|
300 self->ConstructL ( ); |
|
301 |
|
302 return self; |
|
303 } |
|
304 |
|
305 // Destructor (virtual by CBase) |
|
306 MT_CFClient::~MT_CFClient( ) |
|
307 { |
|
308 Teardown(); |
|
309 |
|
310 // Enable screen saver |
|
311 CFEnvUtils::EnableScreenSaver( ETrue ); |
|
312 } |
|
313 |
|
314 // Default constructor |
|
315 MT_CFClient::MT_CFClient( ) |
|
316 { |
|
317 } |
|
318 |
|
319 // Second phase construct |
|
320 void MT_CFClient::ConstructL( ) |
|
321 { |
|
322 // The ConstructL from the base class CEUnitTestSuiteClass must be called. |
|
323 // It generates the test case table. |
|
324 CEUnitTestSuiteClass::ConstructL ( ); |
|
325 |
|
326 // Disable screen saver |
|
327 CFEnvUtils::EnableScreenSaver( EFalse ); |
|
328 } |
|
329 |
|
330 // METHODS |
|
331 |
|
332 void MT_CFClient::ContextIndicationL(const CCFContextIndication& aChangedContext ) |
|
333 { |
|
334 if ( iCheckContextData ) |
|
335 { |
|
336 CheckContextDataIndicationL ( aChangedContext ); |
|
337 } |
|
338 else |
|
339 { |
|
340 CheckContextIndicationL ( aChangedContext ); |
|
341 } |
|
342 |
|
343 // Common for both indications |
|
344 if ( iWait && !iCheckA && !iCheckB ) |
|
345 { |
|
346 if ( iWait->IsStarted ( ) ) |
|
347 { |
|
348 iWait->AsyncStop ( ); |
|
349 } |
|
350 } |
|
351 if ( iDeleteClient ) |
|
352 { |
|
353 delete iClient; |
|
354 iClient = NULL; |
|
355 iDeleteClient = EFalse; |
|
356 } |
|
357 } |
|
358 |
|
359 void MT_CFClient::ActionIndicationL(const CCFActionIndication& aActionToExecute ) |
|
360 { |
|
361 TPtrC actionId( aActionToExecute.Identifier() ); |
|
362 if ( iLastActionId ) |
|
363 { |
|
364 delete iLastActionId; |
|
365 iLastActionId = NULL; |
|
366 } |
|
367 iLastActionId = actionId.AllocL(); |
|
368 |
|
369 if ( iCheckA ) |
|
370 { |
|
371 const RKeyValueArray& params = aActionToExecute.Parameters ( ); |
|
372 EUNIT_ASSERT_DESC( actionId == KActionA, |
|
373 "Incorrect action identifier!" ); |
|
374 EUNIT_ASSERT_DESC( params.Count() == 1, |
|
375 "Incorrect action param count!" ) |
|
376 EUNIT_ASSERT_DESC( params[0]->Key() == KActionAParamA1, |
|
377 "Incorrect action param count!" ) |
|
378 EUNIT_ASSERT_DESC( params[0]->Value() == KActionAValueA1, |
|
379 "Incorrect action param count!" ) |
|
380 if ( iCountActionAIndications ) |
|
381 { |
|
382 --iExpectedActionAIndicationCount; |
|
383 if ( !iExpectedActionAIndicationCount ) |
|
384 { |
|
385 iCheckA = EFalse; |
|
386 } |
|
387 } |
|
388 else |
|
389 { |
|
390 iCheckA = EFalse; |
|
391 } |
|
392 } |
|
393 else if ( iCheckB ) |
|
394 { |
|
395 const RKeyValueArray& params = aActionToExecute.Parameters ( ); |
|
396 EUNIT_ASSERT_DESC( actionId == KActionB, |
|
397 "Incorrect action identifier!" ); |
|
398 EUNIT_ASSERT_DESC( params.Count() == 2, |
|
399 "Incorrect action param count!" ) |
|
400 EUNIT_ASSERT_DESC( params[0]->Key() == KActionBParamB1, |
|
401 "Incorrect action param count!" ) |
|
402 EUNIT_ASSERT_DESC( params[0]->Value() == KActionBValueB1, |
|
403 "Incorrect action param count!" ) |
|
404 EUNIT_ASSERT_DESC( params[1]->Key() == KActionBParamB2, |
|
405 "Incorrect action param count!" ) |
|
406 EUNIT_ASSERT_DESC( params[1]->Value() == KActionBValueB2, |
|
407 "Incorrect action param count!" ) |
|
408 iCheckB = EFalse; |
|
409 } |
|
410 else if ( iCheckRegisterScriptAction ) |
|
411 { |
|
412 const RKeyValueArray& params = aActionToExecute.Parameters ( ); |
|
413 EUNIT_ASSERT_DESC( actionId == _L("RegisterScriptAction"), |
|
414 "Incorrect action identifier!" ); |
|
415 EUNIT_ASSERT_DESC( params.Count() == 1, |
|
416 "Incorrect action param count!" ) |
|
417 EUNIT_ASSERT_DESC( params[0]->Key() == _L("ParamA1"), |
|
418 "Incorrect action param count!" ) |
|
419 EUNIT_ASSERT_DESC( params[0]->Value() == _L("ValueA1"), |
|
420 "Incorrect action param count!" ) |
|
421 iCheckRegisterScriptAction = EFalse; |
|
422 } |
|
423 else if ( iCheckCustomAction ) |
|
424 { |
|
425 EUNIT_ASSERT_DESC( iCustomActionId == actionId, |
|
426 "Incorrect action id" ); |
|
427 const RKeyValueArray |
|
428 & params = aActionToExecute.Parameters ( ); |
|
429 EUNIT_ASSERT_DESC( params.Count() == iCustomActionParams.Count(), |
|
430 "Invalid amount of action parameters" ); |
|
431 for (TInt i = 0; i < iCustomActionParams.Count ( ); i++ ) |
|
432 { |
|
433 CCFKeyValuePair* pair1 = iCustomActionParams[i]; |
|
434 CCFKeyValuePair* pair2 = params[i]; |
|
435 EUNIT_ASSERT_DESC( pair2->Key() == pair1->Key(), |
|
436 "Invalid key" ); |
|
437 EUNIT_ASSERT_DESC( pair2->Value() == pair1->Value(), |
|
438 "Invalid value" ); |
|
439 } |
|
440 iCheckCustomAction = EFalse; |
|
441 iCustomActionId.Zero ( ); |
|
442 iCustomActionParams.ResetAndDestroy ( ); |
|
443 } |
|
444 |
|
445 if ( iWait && !iCheckA && !iCheckB && !iCheckRegisterScriptAction &&!iCheckCustomAction ) |
|
446 { |
|
447 if ( iWait->IsStarted ( ) ) |
|
448 { |
|
449 iWait->AsyncStop ( ); |
|
450 } |
|
451 } |
|
452 |
|
453 if ( iDeleteClient ) |
|
454 { |
|
455 delete iClient; |
|
456 iClient = NULL; |
|
457 iDeleteClient = EFalse; |
|
458 } |
|
459 } |
|
460 |
|
461 void MT_CFClient::HandleContextFrameworkError( TCFError aError, |
|
462 const TDesC& aSource, const TDesC& aType ) |
|
463 { |
|
464 if ( iCheckB ) |
|
465 { |
|
466 EUNIT_ASSERT_DESC( aError == MCFListener::ESecurityCheckErrorForContextSubscription, |
|
467 "Incorrect HandleContextFrameworkError error code!" ); |
|
468 EUNIT_ASSERT_DESC( aSource == iContextB->Source(), |
|
469 "Incorrect HandleContextFrameworkError context source!" ); |
|
470 EUNIT_ASSERT_DESC( aType == iContextB->Type(), |
|
471 "Incorrect HandleContextFrameworkError context type!" ); |
|
472 iCheckB = EFalse; |
|
473 } |
|
474 else if ( iCheckC ) |
|
475 { |
|
476 EUNIT_ASSERT_DESC( aError == MCFListener::ESecurityCheckErrorForContextSubscription, |
|
477 "Incorrect HandleContextFrameworkError error code!" ); |
|
478 EUNIT_ASSERT_DESC( aSource == iContextC->Source(), |
|
479 "Incorrect HandleContextFrameworkError context source!" ); |
|
480 EUNIT_ASSERT_DESC( aType == iContextC->Type(), |
|
481 "Incorrect HandleContextFrameworkError context type!" ); |
|
482 iCheckC = EFalse; |
|
483 } |
|
484 else if ( iCheckRomScriptContextAutoDefine ) |
|
485 { |
|
486 EUNIT_ASSERT_DESC( aError == MCFListener::ESecurityCheckErrorForContextSubscription, |
|
487 "Incorrect HandleContextFrameworkError error code!" ); |
|
488 EUNIT_ASSERT_DESC( aSource == KRomScriptAutoDefineContextSource, |
|
489 "Incorrect HandleContextFrameworkError context source!" ); |
|
490 EUNIT_ASSERT_DESC( aType == KRomScriptAutoDefineContextType, |
|
491 "Incorrect HandleContextFrameworkError context type!" ); |
|
492 iCheckRomScriptContextAutoDefine = EFalse; |
|
493 if ( iTestDelay ) |
|
494 { |
|
495 iTestDelay->Stop(); |
|
496 } |
|
497 } |
|
498 |
|
499 if ( iWait && !iCheckA && !iCheckB && !iCheckC && !iCheckRomScriptContextAutoDefine ) |
|
500 { |
|
501 if ( iWait->IsStarted ( ) ) |
|
502 { |
|
503 iWait->AsyncStop ( ); |
|
504 } |
|
505 } |
|
506 } |
|
507 |
|
508 TAny* MT_CFClient::Extension( const TUid& aExtensionUid ) const |
|
509 { |
|
510 switch ( aExtensionUid.iUid ) |
|
511 { |
|
512 case KCFContextSourceInterfaceUidValue: |
|
513 { |
|
514 if ( iReturnContextSourceInterface ) |
|
515 { |
|
516 MCFContextSource* csinterface = (MCFContextSource*) this; |
|
517 return (TAny*) csinterface; |
|
518 } |
|
519 break; |
|
520 } |
|
521 default: |
|
522 { |
|
523 return NULL; |
|
524 } |
|
525 } |
|
526 return NULL; |
|
527 } |
|
528 |
|
529 // from MCFContextSource |
|
530 void MT_CFClient::Subscribers( const TDesC& aContextSource, |
|
531 const TDesC& aContextType ) |
|
532 { |
|
533 if ( iCheckSubscribersNoSubscribersCalled ) |
|
534 { |
|
535 iCheckSubscribersNoSubscribersCalled = EFalse; |
|
536 iSubscribersCalled = ETrue; |
|
537 EUNIT_ASSERT_DESC( |
|
538 iExpectedSubscribersSource.Compare( aContextSource ) == 0, |
|
539 "No expected source"); |
|
540 EUNIT_ASSERT_DESC( |
|
541 iExpectedSubscribersType.Compare( aContextType ) == 0, |
|
542 "No expected type"); |
|
543 |
|
544 if ( iWait ) |
|
545 { |
|
546 if ( iWait->IsStarted ( ) ) |
|
547 { |
|
548 iWait->AsyncStop ( ); |
|
549 } |
|
550 } |
|
551 } |
|
552 } |
|
553 |
|
554 // from MCFContextSource |
|
555 void MT_CFClient::NoSubscribers( const TDesC& aContextSource, |
|
556 const TDesC& aContextType ) |
|
557 { |
|
558 if ( iCheckSubscribersNoSubscribersCalled ) |
|
559 { |
|
560 iCheckSubscribersNoSubscribersCalled = EFalse; |
|
561 iNoSubscribersCalled = ETrue; |
|
562 EUNIT_ASSERT_DESC( |
|
563 iExpectedSubscribersSource.Compare( aContextSource ) == 0, |
|
564 "No expected source"); |
|
565 EUNIT_ASSERT_DESC( |
|
566 iExpectedSubscribersType.Compare( aContextType ) == 0, |
|
567 "No expected type"); |
|
568 |
|
569 if ( iWait ) |
|
570 { |
|
571 if ( iWait->IsStarted ( ) ) |
|
572 { |
|
573 iWait->AsyncStop ( ); |
|
574 } |
|
575 } |
|
576 } |
|
577 } |
|
578 |
|
579 // from MCFContextSource |
|
580 void MT_CFClient::HandleCommand( const CCFContextSourceCommand& aCommand ) |
|
581 { |
|
582 TPtrC id( aCommand.Name() ); |
|
583 EUNIT_ASSERT_DESC( id.CompareF( KSourceCommandId ) == 0, |
|
584 "No expected source command id" ); |
|
585 |
|
586 // Parse context source command |
|
587 const RKeyValueArray& attributes = aCommand.Attributes(); |
|
588 EUNIT_ASSERT_DESC( attributes.Count() == 1, "No expected attribute count" ); |
|
589 |
|
590 TUid sourceUid = aCommand.SourceUid(); |
|
591 RThread thread; |
|
592 EUNIT_ASSERT_DESC( sourceUid == thread.SecureId(), "No expected uid" ); |
|
593 thread.Close(); |
|
594 |
|
595 const RSourceCommandParameterArray& params = aCommand.Parameters(); |
|
596 EUNIT_ASSERT_DESC( params.Count() >= 1, "No expected parameter count" ); |
|
597 |
|
598 TPtrC paramName( params[ 0 ]->Name() ); |
|
599 EUNIT_ASSERT_DESC( paramName.CompareF( KSourceCommandParamCmd ) == 0, |
|
600 "No expected param name" ); |
|
601 |
|
602 const RKeyValueArray& paramAttributes = params[ 0 ]->Attributes(); |
|
603 EUNIT_ASSERT_DESC( paramAttributes.Count() == 1, "No expected parameter attribute count" ); |
|
604 |
|
605 CCFKeyValuePair* keyValuePair = paramAttributes[ 0 ]; |
|
606 EUNIT_ASSERT_DESC( keyValuePair->Key().CompareF( |
|
607 KSourceCommandAttributeType ) == 0, |
|
608 "Type attribute expected" ); |
|
609 |
|
610 TLinearOrder< TCFSourceCommandSenderId > cmdSenderOrder( |
|
611 SourceCommandSenderIdOrder ); |
|
612 TCFSourceCommandSenderId sender = aCommand.Sender(); |
|
613 TInt pos = iActiveRequests.FindInOrder( sender, cmdSenderOrder ); |
|
614 |
|
615 TPtrC cmdType( keyValuePair->Value() ); |
|
616 if ( cmdType.CompareF( KSourceCommandAttributeValueActivate ) == 0 ) |
|
617 { |
|
618 if ( pos == KErrNotFound ) |
|
619 { |
|
620 iActiveRequests.InsertInOrder( sender, cmdSenderOrder ); |
|
621 } |
|
622 CheckActivateSourceCommandParams( params ); |
|
623 } |
|
624 else if ( cmdType.CompareF( KSourceCommandAttributeValueDeactivate ) == 0 ) |
|
625 { |
|
626 if ( pos != KErrNotFound ) |
|
627 { |
|
628 iActiveRequests.Remove( pos ); |
|
629 } |
|
630 CheckDeactivateSourceCommandParams( params ); |
|
631 } |
|
632 else |
|
633 { |
|
634 EUNIT_ASSERT_DESC( EFalse, "WRONG type attribute value" ); |
|
635 } |
|
636 |
|
637 iHandleCommandCalled = ETrue; |
|
638 |
|
639 if ( iWait && iWait->IsStarted() ) |
|
640 { |
|
641 iWait->AsyncStop ( ); |
|
642 } |
|
643 } |
|
644 |
|
645 void MT_CFClient::CheckActivateSourceCommandParams( |
|
646 const RSourceCommandParameterArray& aParams ) |
|
647 { |
|
648 EUNIT_ASSERT_DESC( aParams.Count() == 2, "No expected param count" ); |
|
649 |
|
650 // Check 1. param |
|
651 CCFContextSourceCommandParameter* param = aParams[ 0 ]; |
|
652 TPtrC paramName( param->Name() ); |
|
653 EUNIT_ASSERT_DESC( paramName.CompareF( KSourceCommandParamCmd ) == 0, |
|
654 "No expected param name" ); |
|
655 |
|
656 // Check 1. param attributes |
|
657 const RKeyValueArray& attributes = param->Attributes(); |
|
658 EUNIT_ASSERT_DESC( attributes.Count() == 1, "No expected attribute count" ); |
|
659 CCFKeyValuePair* keyValuePair = attributes[ 0 ]; |
|
660 EUNIT_ASSERT_DESC( keyValuePair->Key().CompareF( |
|
661 KSourceCommandAttributeType ) == 0, |
|
662 "Type attribute expected" ); |
|
663 EUNIT_ASSERT_DESC( keyValuePair->Value().CompareF( |
|
664 KSourceCommandAttributeValueActivate ) == 0, |
|
665 "No expected type attribute value" ); |
|
666 |
|
667 // Check 1. param nested params |
|
668 const RSourceCommandParameterArray& nestedParams = param->Parameters(); |
|
669 EUNIT_ASSERT_DESC( nestedParams.Count() == 2, "No expected nested parameter count" ); |
|
670 |
|
671 // Check 1. param 1. nested params attributes |
|
672 CCFContextSourceCommandParameter* nestedParam = nestedParams[ 0 ]; |
|
673 EUNIT_ASSERT_DESC( nestedParam->Name().CompareF( |
|
674 KSourceCommandParamCmdParam ) == 0, |
|
675 "Parameter cmdParam expected" ); |
|
676 const RKeyValueArray& nestedParamAttributes = nestedParam->Attributes(); |
|
677 EUNIT_ASSERT_DESC( nestedParamAttributes.Count() == 1, |
|
678 "No expected nested parameter attribute count" ); |
|
679 keyValuePair = nestedParamAttributes[ 0 ]; |
|
680 EUNIT_ASSERT_DESC( keyValuePair->Key().CompareF( |
|
681 KSourceCommandAttributeMode ) == 0, |
|
682 "Mode attribute expected" ); |
|
683 EUNIT_ASSERT_DESC( keyValuePair->Value().CompareF( |
|
684 KSourceCommandAttributeValueClean ) == 0, |
|
685 "No expected mode attribute value" ); |
|
686 |
|
687 // Check 1. param 1. nested params parameters |
|
688 const RSourceCommandParameterArray& nested2Params = nestedParam->Parameters(); |
|
689 EUNIT_ASSERT_DESC( nested2Params.Count() == 1, "No expected nested parameter count" ); |
|
690 |
|
691 // Check 1. param 1. nested params parameters attributes |
|
692 nestedParam = nested2Params[ 0 ]; |
|
693 EUNIT_ASSERT_DESC( nestedParam->Name().CompareF( |
|
694 KSourceCommandParamModifiers ) == 0, |
|
695 "Modifiers param expected" ); |
|
696 const RKeyValueArray& nested2ParamAttributes = nestedParam->Attributes(); |
|
697 EUNIT_ASSERT_DESC( nested2ParamAttributes.Count() == 1, |
|
698 "No expected nested parameter attribute count" ); |
|
699 keyValuePair = nested2ParamAttributes[ 0 ]; |
|
700 EUNIT_ASSERT_DESC( keyValuePair->Key().CompareF( |
|
701 KSourceCommandAttributeValue ) == 0, |
|
702 "Value attribute expected" ); |
|
703 EUNIT_ASSERT_DESC( keyValuePair->Value().CompareF( |
|
704 KSourceCommandAttributeValueReally ) == 0, |
|
705 "No expected value attribute value" ); |
|
706 |
|
707 const RSourceCommandParameterArray& nested3Params = nestedParam->Parameters(); |
|
708 EUNIT_ASSERT_DESC( nested3Params.Count() == 0, "No expected nested parameter count" ); |
|
709 |
|
710 // Check 1. param 2. nested params attributes |
|
711 nestedParam = nestedParams[ 1 ]; |
|
712 EUNIT_ASSERT_DESC( nestedParam->Name().CompareF( |
|
713 KSourceCommandParamCmdParam ) == 0, |
|
714 "Parameter cmdParam expected" ); |
|
715 const RKeyValueArray& nested3ParamAttributes = nestedParam->Attributes(); |
|
716 EUNIT_ASSERT_DESC( nested3ParamAttributes.Count() == 1, |
|
717 "No expected nested parameter attribute count" ); |
|
718 keyValuePair = nested3ParamAttributes[ 0 ]; |
|
719 EUNIT_ASSERT_DESC( keyValuePair->Key().CompareF( |
|
720 KSourceCommandAttributeOverride ) == 0, |
|
721 "Override attribute expected" ); |
|
722 EUNIT_ASSERT_DESC( keyValuePair->Value().CompareF( |
|
723 KSourceCommandAttributeValueYes ) == 0, |
|
724 "No expected override attribute value" ); |
|
725 |
|
726 const RSourceCommandParameterArray& nested4Params = nestedParam->Parameters(); |
|
727 EUNIT_ASSERT_DESC( nested4Params.Count() == 0, "No expected nested parameter count" ); |
|
728 |
|
729 // Check 2. param |
|
730 param = aParams[ 1 ]; |
|
731 paramName.Set( param->Name() ); |
|
732 EUNIT_ASSERT_DESC( paramName.CompareF( KSourceCommandParamCmdInfo ) == 0, |
|
733 "No expected param name" ); |
|
734 |
|
735 // Check 2. param attributes |
|
736 const RKeyValueArray& attributes2 = param->Attributes(); |
|
737 EUNIT_ASSERT_DESC( attributes2.Count() == 1, "No expected attribute count" ); |
|
738 keyValuePair = attributes2[ 0 ]; |
|
739 EUNIT_ASSERT_DESC( keyValuePair->Key().CompareF( |
|
740 KSourceCommandAttributeType ) == 0, |
|
741 "Type attribute expected" ); |
|
742 EUNIT_ASSERT_DESC( keyValuePair->Value().CompareF( |
|
743 KSourceCommandAttributeValueActivate ) == 0, |
|
744 "No expected type attribute value" ); |
|
745 |
|
746 // Check 2. param nested params |
|
747 const RSourceCommandParameterArray& nestedParams2 = param->Parameters(); |
|
748 EUNIT_ASSERT_DESC( nestedParams2.Count() == 1, "No expected nested parameter count" ); |
|
749 |
|
750 // Check 2. param nested params attributes |
|
751 nestedParam = nestedParams2[ 0 ]; |
|
752 EUNIT_ASSERT_DESC( nestedParam->Name().CompareF( |
|
753 KSourceCommandParamCmdParam ) == 0, |
|
754 "Parameter cmdParam expected" ); |
|
755 const RKeyValueArray& nestedParamAttributes2 = nestedParam->Attributes(); |
|
756 EUNIT_ASSERT_DESC( nestedParamAttributes2.Count() == 1, |
|
757 "No expected nested parameter attribute count" ); |
|
758 keyValuePair = nestedParamAttributes2[ 0 ]; |
|
759 EUNIT_ASSERT_DESC( keyValuePair->Key().CompareF( |
|
760 KSourceCommandAttributeText ) == 0, |
|
761 "Text attribute expected" ); |
|
762 EUNIT_ASSERT_DESC( keyValuePair->Value().CompareF( |
|
763 KSourceCommandAttributeValueText ) == 0, |
|
764 "No expected text attribute value" ); |
|
765 |
|
766 // Check 2. param 1. nested params parameters |
|
767 const RSourceCommandParameterArray& nested2Params2 = nestedParam->Parameters(); |
|
768 EUNIT_ASSERT_DESC( nested2Params2.Count() == 0, "No expected nested parameter count" ); |
|
769 } |
|
770 |
|
771 void MT_CFClient::CheckDeactivateSourceCommandParams( |
|
772 const RSourceCommandParameterArray& aParams ) |
|
773 { |
|
774 EUNIT_ASSERT_DESC( aParams.Count() == 1, "No expected param count" ); |
|
775 |
|
776 // Check param |
|
777 CCFContextSourceCommandParameter* param = aParams[ 0 ]; |
|
778 TPtrC paramName( param->Name() ); |
|
779 EUNIT_ASSERT_DESC( paramName.CompareF( KSourceCommandParamCmd ) == 0, |
|
780 "No expected param name" ); |
|
781 |
|
782 // Check param attributes |
|
783 const RKeyValueArray& attributes = param->Attributes(); |
|
784 EUNIT_ASSERT_DESC( attributes.Count() == 1, "No expected attribute count" ); |
|
785 CCFKeyValuePair* keyValuePair = attributes[ 0 ]; |
|
786 EUNIT_ASSERT_DESC( keyValuePair->Key().CompareF( |
|
787 KSourceCommandAttributeType ) == 0, |
|
788 "Type attribute expected" ); |
|
789 EUNIT_ASSERT_DESC( keyValuePair->Value().CompareF( |
|
790 KSourceCommandAttributeValueDeactivate ) == 0, |
|
791 "No expected type attribute value" ); |
|
792 |
|
793 // Check param nested params |
|
794 const RSourceCommandParameterArray& nestedParams = param->Parameters(); |
|
795 EUNIT_ASSERT_DESC( nestedParams.Count() == 1, "No expected nested parameter count" ); |
|
796 |
|
797 // Check param nested params attributes |
|
798 CCFContextSourceCommandParameter* nestedParam = nestedParams[ 0 ]; |
|
799 EUNIT_ASSERT_DESC( nestedParam->Name().CompareF( |
|
800 KSourceCommandParamCmdParam ) == 0, |
|
801 "Parameter cmdParam expected" ); |
|
802 const RKeyValueArray& nestedParamAttributes = nestedParam->Attributes(); |
|
803 EUNIT_ASSERT_DESC( nestedParamAttributes.Count() == 1, |
|
804 "No expected nested parameter attribute count" ); |
|
805 keyValuePair = nestedParamAttributes[ 0 ]; |
|
806 EUNIT_ASSERT_DESC( keyValuePair->Key().CompareF( |
|
807 KSourceCommandAttributeMode ) == 0, |
|
808 "Mode attribute expected" ); |
|
809 EUNIT_ASSERT_DESC( keyValuePair->Value().CompareF( |
|
810 KSourceCommandAttributeValueFull ) == 0, |
|
811 "No expected mode attribute value" ); |
|
812 |
|
813 // Check param nested params parameters |
|
814 const RSourceCommandParameterArray& nested2Params = nestedParam->Parameters(); |
|
815 EUNIT_ASSERT_DESC( nested2Params.Count() == 1, "No expected nested parameter count" ); |
|
816 |
|
817 // Check param nested params parameters attributes |
|
818 nestedParam = nested2Params[ 0 ]; |
|
819 EUNIT_ASSERT_DESC( nestedParam->Name().CompareF( |
|
820 KSourceCommandParamModifiers ) == 0, |
|
821 "Modifiers param expected" ); |
|
822 const RKeyValueArray& nested2ParamAttributes = nestedParam->Attributes(); |
|
823 EUNIT_ASSERT_DESC( nested2ParamAttributes.Count() == 1, |
|
824 "No expected nested parameter attribute count" ); |
|
825 keyValuePair = nested2ParamAttributes[ 0 ]; |
|
826 EUNIT_ASSERT_DESC( keyValuePair->Key().CompareF( |
|
827 KSourceCommandAttributeValue ) == 0, |
|
828 "Value attribute expected" ); |
|
829 EUNIT_ASSERT_DESC( keyValuePair->Value().CompareF( |
|
830 KSourceCommandAttributeValueNoException ) == 0, |
|
831 "No expected value attribute value" ); |
|
832 |
|
833 const RSourceCommandParameterArray& nested3Params = nestedParam->Parameters(); |
|
834 EUNIT_ASSERT_DESC( nested3Params.Count() == 0, "No expected nested parameter count" ); |
|
835 } |
|
836 |
|
837 |
|
838 void MT_CFClient::SetupL( ) |
|
839 { |
|
840 } |
|
841 |
|
842 void MT_CFClient::SetupClientL( ) |
|
843 { |
|
844 User::LeaveIfError ( iFs.Connect ( ) ); |
|
845 iClient = CCFClient::NewL ( *this ); |
|
846 iAnotherClient = CCFClient::NewL ( *this ); |
|
847 iContextA = CCFContextObject::NewL ( ); |
|
848 iContextB = CCFContextObject::NewL ( ); |
|
849 iContextC = CCFContextObject::NewL ( ); |
|
850 iWait = new( ELeave ) CActiveSchedulerWait; |
|
851 iContextDataA = CTestContextData::NewL ( _L("Key_A"), _L("Value_A") ); |
|
852 iContextDataB = CTestContextData::NewL ( _L("Key_B"), _L("Value_B") ); |
|
853 } |
|
854 |
|
855 void MT_CFClient::SetupNewClientL( ) |
|
856 { |
|
857 iReturnContextSourceInterface = ETrue; |
|
858 iTestDelay = CCFTestDelay::NewL ( ); |
|
859 SetupClientL ( ); |
|
860 } |
|
861 |
|
862 void MT_CFClient::SetupSourceSettingTestClientL( ) |
|
863 { |
|
864 iTestDelay = CCFTestDelay::NewL ( ); |
|
865 SetupClientL ( ); |
|
866 } |
|
867 |
|
868 void MT_CFClient::Teardown( ) |
|
869 { |
|
870 if ( iWait ) |
|
871 { |
|
872 if ( iWait->IsStarted ( ) ) |
|
873 { |
|
874 iWait->AsyncStop ( ); |
|
875 } |
|
876 delete iWait; |
|
877 iWait = NULL; |
|
878 } |
|
879 |
|
880 delete iClient; |
|
881 iClient = NULL; |
|
882 |
|
883 delete iAnotherClient; |
|
884 iAnotherClient = NULL; |
|
885 |
|
886 delete iContextA; |
|
887 iContextA = NULL; |
|
888 |
|
889 delete iContextB; |
|
890 iContextB = NULL; |
|
891 |
|
892 delete iContextC; |
|
893 iContextC = NULL; |
|
894 iFs.Close ( ); |
|
895 |
|
896 delete iContextDataA; |
|
897 iContextDataA = NULL; |
|
898 |
|
899 delete iContextDataB; |
|
900 iContextDataB = NULL; |
|
901 |
|
902 iReturnContextSourceInterface = EFalse; |
|
903 |
|
904 iCustomActionParams.ResetAndDestroy(); |
|
905 |
|
906 delete iLastActionId; |
|
907 iLastActionId = NULL; |
|
908 |
|
909 iActiveRequests.Close(); |
|
910 |
|
911 if ( iTestDelay ) |
|
912 { |
|
913 // Give some time for everything to be cleaned up. |
|
914 iTestDelay->Start ( 100000 ); // 100 ms |
|
915 } |
|
916 |
|
917 delete iTestDelay; |
|
918 iTestDelay = NULL; |
|
919 } |
|
920 |
|
921 void MT_CFClient::TeardownAndScriptCleanup( ) |
|
922 { |
|
923 iClient->DeleteScripts ( ); |
|
924 iClient->RestoreRomScript ( _L("test-scriptUpgradeRom") ); |
|
925 iClient->RestoreRomScript ( _L("test-scriptUpgradeRomClientMissingCapability") ); |
|
926 Teardown ( ); |
|
927 } |
|
928 |
|
929 void MT_CFClient::CheckContextIndicationL( |
|
930 const CCFContextIndication& aChangedContext ) |
|
931 { |
|
932 if ( iCheckA ) |
|
933 { |
|
934 const CCFContextObject& co = aChangedContext.Context ( ); |
|
935 EUNIT_ASSERT_DESC( co.Source() == iContextA->Source(), |
|
936 "Incorrect context source in context indication!" ); |
|
937 EUNIT_ASSERT_DESC( co.Type() == iContextA->Type(), |
|
938 "Incorrect context type in context indication!" ); |
|
939 EUNIT_ASSERT_DESC( co.Value() == iContextA->Value(), |
|
940 "Incorrect context value in context indication!" ); |
|
941 iCheckA = EFalse; |
|
942 } |
|
943 else if ( iCheckB ) |
|
944 { |
|
945 const CCFContextObject& co = aChangedContext.Context ( ); |
|
946 EUNIT_ASSERT_DESC( co.Source() == iContextB->Source(), |
|
947 "Incorrect context source in context indication!" ); |
|
948 EUNIT_ASSERT_DESC( co.Type() == iContextB->Type(), |
|
949 "Incorrect context type in context indication!" ); |
|
950 EUNIT_ASSERT_DESC( co.Value() == iContextB->Value(), |
|
951 "Incorrect context value in context indication!" ); |
|
952 iCheckB = EFalse; |
|
953 } |
|
954 else if ( iCheckPluginSubscribersCalled ) |
|
955 { |
|
956 const CCFContextObject& co = aChangedContext.Context ( ); |
|
957 EUNIT_ASSERT_DESC( iExpectedSubscribersSource == co.Source(), |
|
958 "No expected plugin subscriber source"); |
|
959 EUNIT_ASSERT_DESC( iExpectedSubscribersType == co.Type(), |
|
960 "No expected plugin subscriber type"); |
|
961 EUNIT_ASSERT_DESC( iExpectedSubscribersValue == co.Value(), |
|
962 "No expected plugin subscriber value"); |
|
963 |
|
964 iPluginSubscribersCalled = ETrue; |
|
965 iCheckPluginSubscribersCalled = EFalse; |
|
966 |
|
967 if ( iWait && iWait->IsStarted ( ) ) |
|
968 { |
|
969 iWait->AsyncStop ( ); |
|
970 } |
|
971 } |
|
972 else if ( iCheckSourceCommandHandled ) |
|
973 { |
|
974 const CCFContextObject& co = aChangedContext.Context ( ); |
|
975 EUNIT_ASSERT_DESC( iExpectedSubscribersSource == co.Source(), |
|
976 "No expected source command signal context source"); |
|
977 EUNIT_ASSERT_DESC( iExpectedSubscribersType == co.Type(), |
|
978 "No expected source command signal context type"); |
|
979 EUNIT_ASSERT_DESC( iExpectedSubscribersValue == co.Value(), |
|
980 "No expected source command signal context value"); |
|
981 |
|
982 iSourceCommandHandled = ETrue; |
|
983 iCheckSourceCommandHandled = EFalse; |
|
984 |
|
985 if ( iWait && iWait->IsStarted ( ) ) |
|
986 { |
|
987 iWait->AsyncStop ( ); |
|
988 } |
|
989 } |
|
990 else if ( iCheckRomScriptContextAutoDefineDetected ) |
|
991 { |
|
992 const CCFContextObject& co = aChangedContext.Context ( ); |
|
993 EUNIT_ASSERT_DESC( iExpectedSubscribersSource == co.Source(), |
|
994 "No expected source command signal context source"); |
|
995 EUNIT_ASSERT_DESC( iExpectedSubscribersType == co.Type(), |
|
996 "No expected source command signal context type"); |
|
997 EUNIT_ASSERT_DESC( iExpectedSubscribersValue == co.Value(), |
|
998 "No expected source command signal context value"); |
|
999 |
|
1000 iCheckRomScriptContextAutoDefineDetected = EFalse; |
|
1001 |
|
1002 if ( iWait && iWait->IsStarted ( ) ) |
|
1003 { |
|
1004 iWait->AsyncStop ( ); |
|
1005 } |
|
1006 } |
|
1007 } |
|
1008 |
|
1009 void MT_CFClient::CheckContextDataIndicationL( |
|
1010 const CCFContextIndication& aChangedContext ) |
|
1011 { |
|
1012 if ( iCheckA ) |
|
1013 { |
|
1014 // Check context |
|
1015 const CCFContextObject& co = aChangedContext.Context ( ); |
|
1016 EUNIT_ASSERT_DESC( co.Source() == iContextA->Source(), |
|
1017 "Incorrect context source in context indication!" ); |
|
1018 EUNIT_ASSERT_DESC( co.Type() == iContextA->Type(), |
|
1019 "Incorrect context type in context indication!" ); |
|
1020 EUNIT_ASSERT_DESC( co.Value() == iContextA->Value(), |
|
1021 "Incorrect context value in context indication!" ); |
|
1022 |
|
1023 // Check data object |
|
1024 EUNIT_ASSERT_DESC( aChangedContext.Uid() == KTestContextDataUid, |
|
1025 "Incorrect context data UID!" ); |
|
1026 if ( aChangedContext.Uid ( )== KTestContextDataUid ) |
|
1027 { |
|
1028 CCFContextIndication |
|
1029 & indication =const_cast<CCFContextIndication&>( aChangedContext ); |
|
1030 CTestContextData* contextData =CTestContextData::NewLC ( KNullDesC, |
|
1031 KNullDesC ); |
|
1032 indication.CreateDataObjectL ( *contextData ); |
|
1033 EUNIT_ASSERT_DESC( contextData->Key() == iContextDataA->Key(), |
|
1034 "Incorrect context data object comparison!" ); |
|
1035 EUNIT_ASSERT_DESC( contextData->Value() == iContextDataA->Value(), |
|
1036 "Incorrect context data object comparison!" ); |
|
1037 CleanupStack::PopAndDestroy ( contextData ); |
|
1038 } |
|
1039 iCheckA = EFalse; |
|
1040 } |
|
1041 else if ( iCheckB ) |
|
1042 { |
|
1043 // Check context |
|
1044 const CCFContextObject& co = aChangedContext.Context ( ); |
|
1045 EUNIT_ASSERT_DESC( co.Source() == iContextB->Source(), |
|
1046 "Incorrect context source in context indication!" ); |
|
1047 EUNIT_ASSERT_DESC( co.Type() == iContextB->Type(), |
|
1048 "Incorrect context type in context indication!" ); |
|
1049 EUNIT_ASSERT_DESC( co.Value() == iContextB->Value(), |
|
1050 "Incorrect context value in context indication!" ); |
|
1051 |
|
1052 // Check data object |
|
1053 EUNIT_ASSERT_DESC( aChangedContext.Uid() == KTestContextDataUid, |
|
1054 "Incorrect context data UID!" ); |
|
1055 if ( aChangedContext.Uid ( )== KTestContextDataUid ) |
|
1056 { |
|
1057 CCFContextIndication |
|
1058 & indication =const_cast<CCFContextIndication&>( aChangedContext ); |
|
1059 CTestContextData* contextData =CTestContextData::NewLC ( |
|
1060 KNullDesC, KNullDesC ); |
|
1061 indication.CreateDataObjectL ( *contextData ); |
|
1062 EUNIT_ASSERT_DESC( contextData->Key() == iContextDataB->Key(), |
|
1063 "Incorrect context data object comparison!" ); |
|
1064 EUNIT_ASSERT_DESC( contextData->Value() == iContextDataB->Value(), |
|
1065 "Incorrect context data object comparison!" ); |
|
1066 CleanupStack::PopAndDestroy ( contextData ); |
|
1067 } |
|
1068 iCheckB = EFalse; |
|
1069 } |
|
1070 } |
|
1071 |
|
1072 void MT_CFClient::ConfigureContextL( CCFContextObject& aContext ) |
|
1073 { |
|
1074 Wait ( KConfigDelay ); |
|
1075 |
|
1076 TBuf<256> buf( KNullDesC ); |
|
1077 TTime time; |
|
1078 time.HomeTime ( ); |
|
1079 |
|
1080 buf.Format ( KContextSourceFormat, time.Int64 ( ) ); |
|
1081 aContext.SetSourceL ( buf ); |
|
1082 |
|
1083 buf.Format ( KContextTypeFormat, time.Int64 ( ) ); |
|
1084 aContext.SetTypeL ( buf ); |
|
1085 |
|
1086 buf.Format ( KContextValueFormat, time.Int64 ( ) ); |
|
1087 aContext.SetValueL ( buf ); |
|
1088 } |
|
1089 |
|
1090 void MT_CFClient::UpdateContextValueL( CCFContextObject& aContext ) |
|
1091 { |
|
1092 Wait ( KConfigDelay ); |
|
1093 |
|
1094 TBuf<256> buf( KNullDesC ); |
|
1095 TTime time; |
|
1096 time.HomeTime ( ); |
|
1097 |
|
1098 buf.Format ( KContextValueFormat, time.Int64 ( ) ); |
|
1099 aContext.SetValueL ( buf ); |
|
1100 } |
|
1101 |
|
1102 void MT_CFClient::UpdateContextTypeL( CCFContextObject& aContext ) |
|
1103 { |
|
1104 Wait ( KConfigDelay ); |
|
1105 |
|
1106 TBuf<256> buf( KNullDesC ); |
|
1107 TTime time; |
|
1108 time.HomeTime ( ); |
|
1109 |
|
1110 buf.Format ( KContextTypeFormat, time.Int64 ( ) ); |
|
1111 aContext.SetTypeL ( buf ); |
|
1112 } |
|
1113 |
|
1114 HBufC* MT_CFClient::ConfigureActionIdLC( ) |
|
1115 { |
|
1116 Wait ( KConfigDelay ); |
|
1117 |
|
1118 TTime time; |
|
1119 time.HomeTime ( ); |
|
1120 HBufC* actionId = HBufC::NewLC ( 256 ); |
|
1121 TPtr actionIdPtr = actionId->Des ( ); |
|
1122 actionIdPtr.Format ( KActionIdFormat, time.Int64 ( ) ); |
|
1123 |
|
1124 return actionId; |
|
1125 } |
|
1126 |
|
1127 HBufC8* MT_CFClient::LoadScriptFromFile( const TDesC& aFilePath ) |
|
1128 { |
|
1129 HBufC8* script= NULL; |
|
1130 RFile file; |
|
1131 TFileName fileName; |
|
1132 fileName.Copy (_L("z:\\data\\cftestdata\\testscripts\\") ); |
|
1133 fileName.Append (aFilePath ); |
|
1134 TInt err = file.Open ( iFs, fileName, EFileRead ); |
|
1135 if ( err == KErrNone ) |
|
1136 { |
|
1137 TInt size = 0; |
|
1138 err = file.Size ( size ); |
|
1139 if ( err == KErrNone ) |
|
1140 { |
|
1141 script = HBufC8::New ( size ); |
|
1142 if ( script ) |
|
1143 { |
|
1144 TPtr8 scriptPtr = script->Des ( ); |
|
1145 err = file.Read ( scriptPtr ); |
|
1146 if ( err == KErrNone ) |
|
1147 { |
|
1148 // Strip all unnecassary data from script |
|
1149 TInt pos = scriptPtr.FindF ( KScriptStartTag ); |
|
1150 if ( pos != KErrNotFound ) |
|
1151 { |
|
1152 scriptPtr.Copy ( scriptPtr.MidTPtr ( pos ) ); |
|
1153 } |
|
1154 else |
|
1155 { |
|
1156 // Incorrect script |
|
1157 delete script; |
|
1158 script = NULL; |
|
1159 } |
|
1160 } |
|
1161 else |
|
1162 { |
|
1163 delete script; |
|
1164 script = NULL; |
|
1165 } |
|
1166 } |
|
1167 } |
|
1168 } |
|
1169 else |
|
1170 { |
|
1171 EUNIT_PRINT( _L("MT_CFClient::LoadScriptFromFile - Loading file [%S] failed with code = %d"), |
|
1172 &fileName, err ); |
|
1173 } |
|
1174 |
|
1175 // Cleanup |
|
1176 file.Close ( ); |
|
1177 return script; |
|
1178 } |
|
1179 |
|
1180 void MT_CFClient::ResetCustomAction() |
|
1181 { |
|
1182 iCheckCustomAction = EFalse; |
|
1183 iCustomActionId.Zero(); |
|
1184 iCustomActionParams.ResetAndDestroy(); |
|
1185 } |
|
1186 |
|
1187 TBool MT_CFClient::LastActionIdEquals( const TDesC& aId ) |
|
1188 { |
|
1189 if ( iLastActionId ) |
|
1190 { |
|
1191 return ( *iLastActionId == aId ); |
|
1192 } |
|
1193 else |
|
1194 { |
|
1195 return EFalse; |
|
1196 } |
|
1197 } |
|
1198 |
|
1199 void MT_CFClient::DeleteLastActionId() |
|
1200 { |
|
1201 delete iLastActionId; |
|
1202 iLastActionId = NULL; |
|
1203 } |
|
1204 |
|
1205 //----------------------------------------------------------------------------- |
|
1206 // CFClient module tests |
|
1207 //----------------------------------------------------------------------------- |
|
1208 // |
|
1209 void MT_CFClient::MT_CCFClient_NewLL( ) |
|
1210 { |
|
1211 CCFClient* client = CCFClient::NewL ( *this ); |
|
1212 CleanupStack::PushL ( client ); |
|
1213 |
|
1214 EUNIT_ASSERT_DESC( client, "CCFClient class instance not created!" ); |
|
1215 |
|
1216 CleanupStack::PopAndDestroy ( client ); |
|
1217 } |
|
1218 |
|
1219 void MT_CFClient::MT_CCFClient_NewLCL( ) |
|
1220 { |
|
1221 CCFClient* client = CCFClient::NewLC ( *this ); |
|
1222 |
|
1223 EUNIT_ASSERT_DESC( client, "CCFClient class instance not created!" ); |
|
1224 |
|
1225 CleanupStack::PopAndDestroy ( client ); |
|
1226 } |
|
1227 |
|
1228 void MT_CFClient::MT_CCFClient_DefineContextL( ) |
|
1229 { |
|
1230 CCFContextObject* context = CCFContextObject::NewLC ( ); |
|
1231 TInt err = KErrNone; |
|
1232 |
|
1233 // x. Define context from two different clients when context onwer is set |
|
1234 //-------------------------------------------------------------------------- |
|
1235 iReturnContextSourceInterface = ETrue; |
|
1236 CCFClient* client = CCFClient::NewLC ( *this ); |
|
1237 CCFClient* client2 = CCFClient::NewLC ( *this ); |
|
1238 ConfigureContextL ( *context ); |
|
1239 err = client->DefineContext ( context->Source ( ), context->Type ( ), |
|
1240 KPassSec ); |
|
1241 EUNIT_ASSERT_DESC( err == KErrNone, "Incorrect DefineContext return value! " ); |
|
1242 err = client->DefineContext ( context->Source ( ), context->Type ( ), |
|
1243 KFailSec ); |
|
1244 EUNIT_ASSERT_DESC( err == KErrNone, "Incorrect DefineContext return value! " ); |
|
1245 err = client2->DefineContext ( context->Source ( ), context->Type ( ), |
|
1246 KFailSec ); |
|
1247 EUNIT_ASSERT_DESC( err == KErrAlreadyExists, "Incorrect DefineContext return value! " ); |
|
1248 CleanupStack::PopAndDestroy ( client2 ); |
|
1249 CleanupStack::PopAndDestroy ( client ); |
|
1250 |
|
1251 // x. Define context, delete client and redefine context |
|
1252 //-------------------------------------------------------------------------- |
|
1253 iReturnContextSourceInterface = ETrue; |
|
1254 ConfigureContextL ( *context ); |
|
1255 client = CCFClient::NewLC ( *this ); |
|
1256 err = client->DefineContext ( context->Source ( ), context->Type ( ), |
|
1257 KPassSec ); |
|
1258 EUNIT_ASSERT_DESC( err == KErrNone, "Incorrect DefineContext return value! " ); |
|
1259 CleanupStack::PopAndDestroy ( client ); |
|
1260 |
|
1261 client = CCFClient::NewLC ( *this ); |
|
1262 err = client->DefineContext ( context->Source ( ), context->Type ( ), |
|
1263 KFailSec ); |
|
1264 EUNIT_ASSERT_DESC( err == KErrNone, "Incorrect DefineContext return value! " ); |
|
1265 err = client->DefineContext ( context->Source ( ), KNullDesC, KFailSec ); |
|
1266 CleanupStack::PopAndDestroy ( client ); |
|
1267 |
|
1268 // x. Define context, delete client and redefine context |
|
1269 //-------------------------------------------------------------------------- |
|
1270 client = CCFClient::NewLC ( *this ); |
|
1271 err = client->DefineContext ( context->Source(), KNullDesC, KFailSec ); |
|
1272 EUNIT_ASSERT_DESC( err == KErrArgument, "Incorrect DefineContext return value! " ); |
|
1273 err = client->DefineContext ( KNullDesC, context->Type ( ), KFailSec ); |
|
1274 EUNIT_ASSERT_DESC( err == KErrArgument, "Incorrect DefineContext return value! " ); |
|
1275 CleanupStack::PopAndDestroy ( client ); |
|
1276 |
|
1277 // Clean up |
|
1278 CleanupStack::PopAndDestroy ( context ); |
|
1279 } |
|
1280 |
|
1281 void MT_CFClient::MT_CCFClient_SubscribersNosubscribersL( ) |
|
1282 { |
|
1283 TInt err = KErrNone; |
|
1284 |
|
1285 // Define context |
|
1286 ConfigureContextL ( *iContextA ); |
|
1287 err = iClient->DefineContext ( iContextA->Source ( ), iContextA->Type ( ), |
|
1288 KPassSec, KPassSec ); |
|
1289 EUNIT_ASSERT_DESC( err == KErrNone, "Incorrect DefineContext return value! " ); |
|
1290 |
|
1291 // Delete & re-create client causing de-registering of publisher. |
|
1292 delete iClient; |
|
1293 iClient = NULL; |
|
1294 iClient = CCFClient::NewL ( *this ); |
|
1295 |
|
1296 // in this case redefine should work (same client) |
|
1297 err = iClient->DefineContext ( iContextA->Source ( ), iContextA->Type ( ), |
|
1298 KPassSec, KPassSec ); |
|
1299 EUNIT_ASSERT_DESC( err == KErrNone, "Incorrect DefineContext return value! " ); |
|
1300 |
|
1301 // Test if we get Subscribers() callback if we add subscription |
|
1302 iCheckSubscribersNoSubscribersCalled = ETrue; |
|
1303 iSubscribersCalled = EFalse; |
|
1304 iExpectedSubscribersSource.Copy ( iContextA->Source ( ) ); |
|
1305 iExpectedSubscribersType.Copy ( iContextA->Type ( ) ); |
|
1306 |
|
1307 CCFContextSubscription* subscription= NULL; |
|
1308 // Define a context and subscribe it |
|
1309 subscription = CCFContextSubscription::NewLC ( ); |
|
1310 subscription->SetContextSourceL ( iContextA->Source ( ) ); |
|
1311 subscription->SetContextTypeL ( iContextA->Type ( ) ); |
|
1312 err = iClient->SubscribeContext ( *subscription ); |
|
1313 EUNIT_ASSERT_DESC( err == KErrNone, "Incorrect SubscribeContext return value!" ); |
|
1314 CleanupStack::PopAndDestroy ( subscription ); |
|
1315 |
|
1316 iWait->Start ( ); |
|
1317 EUNIT_ASSERT_DESC( iSubscribersCalled, "MCFContextSource::Subscribers not called" ); |
|
1318 EUNIT_ASSERT_DESC( !iCheckSubscribersNoSubscribersCalled, "Subscribers not called" ); |
|
1319 |
|
1320 // Test if we get NoSubsscribers() callback if we remove subscription |
|
1321 iCheckSubscribersNoSubscribersCalled = ETrue; |
|
1322 iSubscribersCalled = EFalse; |
|
1323 iNoSubscribersCalled = EFalse; |
|
1324 iExpectedSubscribersSource.Copy ( iContextA->Source ( ) ); |
|
1325 iExpectedSubscribersType.Copy ( iContextA->Type ( ) ); |
|
1326 |
|
1327 // Define a context and subscribe it |
|
1328 subscription = CCFContextSubscription::NewLC ( ); |
|
1329 subscription->SetContextSourceL ( iContextA->Source ( ) ); |
|
1330 subscription->SetContextTypeL ( iContextA->Type ( ) ); |
|
1331 err = iClient->UnsubscribeContext ( *subscription ); |
|
1332 EUNIT_ASSERT_DESC( err == KErrNone, "Incorrect SubscribeContext return value!" ); |
|
1333 CleanupStack::PopAndDestroy ( subscription ); |
|
1334 |
|
1335 iWait->Start(); |
|
1336 EUNIT_ASSERT_DESC( iNoSubscribersCalled, "MCFContextSource::NoSubscribers not called" ); |
|
1337 EUNIT_ASSERT_DESC( !iCheckSubscribersNoSubscribersCalled, "Subscribers not called" ); |
|
1338 } |
|
1339 |
|
1340 void MT_CFClient::MT_CCFClient_SubscribersNosubscribersPluginL( ) |
|
1341 { |
|
1342 TInt err = KErrNone; |
|
1343 |
|
1344 // Subscribe to value context signalling plugin "reactions". |
|
1345 // below // CLEANUP<< valueSub |
|
1346 CCFContextSubscription* valueSub = CCFContextSubscription::NewLC ( ); |
|
1347 valueSub->SetContextSourceL ( KTestContextSource ); |
|
1348 valueSub->SetContextTypeL ( KTestContextValueType ); |
|
1349 err = iClient->SubscribeContext ( *valueSub ); |
|
1350 EUNIT_ASSERT_DESC( err == KErrNone, "Incorrect SubscribeContext return value!" ); |
|
1351 |
|
1352 // Test if plugin gets Subscribers() callback if we add subscription |
|
1353 iExpectedSubscribersSource.Copy ( KTestContextSource ); |
|
1354 iExpectedSubscribersType.Copy ( KTestContextValueType ); |
|
1355 iExpectedSubscribersValue.Copy ( KTestContextValueSubsOk ); |
|
1356 |
|
1357 // 1.Subscription |
|
1358 iCheckPluginSubscribersCalled = ETrue; |
|
1359 iPluginSubscribersCalled = EFalse; |
|
1360 // below // CLEANUP<< pluginSub1 |
|
1361 CCFContextSubscription* pluginSub1 = CCFContextSubscription::NewLC ( ); |
|
1362 pluginSub1->SetContextSourceL ( KTestContextSource ); |
|
1363 pluginSub1->SetContextTypeL ( KTestContextType ); |
|
1364 err = iClient->SubscribeContext ( *pluginSub1 ); |
|
1365 EUNIT_ASSERT_DESC( err == KErrNone, "Incorrect SubscribeContext return value!" ); |
|
1366 |
|
1367 // Wait for correct context as answer. |
|
1368 iTestDelay->Start ( 250000 ); // 250 ms |
|
1369 EUNIT_ASSERT_DESC( iPluginSubscribersCalled, "SubscribeContext was not detected by plugin" ); |
|
1370 |
|
1371 // 2.Subscription via iAnotherClient |
|
1372 iCheckPluginSubscribersCalled = ETrue; |
|
1373 iPluginSubscribersCalled = EFalse; |
|
1374 // below // CLEANUP<< pluginSub2 |
|
1375 CCFContextSubscription* pluginSub2 = CCFContextSubscription::NewLC ( ); |
|
1376 pluginSub2->SetContextSourceL ( KTestContextSource ); |
|
1377 pluginSub2->SetContextTypeL ( KTestContextType ); |
|
1378 err = iAnotherClient->SubscribeContext ( *pluginSub2 ); |
|
1379 EUNIT_ASSERT_DESC( err == KErrNone, "Incorrect SubscribeContext return value!" ); |
|
1380 |
|
1381 // Wait and no answer expected. |
|
1382 iTestDelay->Start ( 500000 ); // 0.5 s |
|
1383 EUNIT_ASSERT_DESC( iCheckPluginSubscribersCalled, "SubscribeContext was detected by plugin" ); |
|
1384 EUNIT_ASSERT_DESC( !iPluginSubscribersCalled, "SubscribeContext was detected by plugin" ); |
|
1385 |
|
1386 // Unsubscribe 2.Subscription via iAnotherClient |
|
1387 iCheckPluginSubscribersCalled = ETrue; |
|
1388 iPluginSubscribersCalled = EFalse; |
|
1389 err = iAnotherClient->UnsubscribeContext ( *pluginSub2 ); |
|
1390 EUNIT_ASSERT_DESC( err == KErrNone, "Incorrect UnsubscribeContext return value!" ); |
|
1391 |
|
1392 // Wait and no answer expected. |
|
1393 iTestDelay->Start ( 250000 ); // 250 ms |
|
1394 EUNIT_ASSERT_DESC( iCheckPluginSubscribersCalled, "UnsubscribeContext was detected by plugin" ); |
|
1395 EUNIT_ASSERT_DESC( !iPluginSubscribersCalled, "UnsubscribeContext was detected by plugin" ); |
|
1396 |
|
1397 // Test if plugin gets NoSubscribers() callback if we remove last subscription |
|
1398 iExpectedSubscribersSource.Copy ( KTestContextSource ); |
|
1399 iExpectedSubscribersType.Copy ( KTestContextValueType ); |
|
1400 iExpectedSubscribersValue.Copy ( KTestContextValueNosubsOk ); |
|
1401 |
|
1402 // Unsubscribe 1.Subscription |
|
1403 iCheckPluginSubscribersCalled = ETrue; |
|
1404 iPluginSubscribersCalled = EFalse; |
|
1405 err = iClient->UnsubscribeContext ( *pluginSub1 ); |
|
1406 EUNIT_ASSERT_DESC( err == KErrNone, "Incorrect UnsubscribeContext return value!" ); |
|
1407 |
|
1408 // Wait for correct context as answer. |
|
1409 iTestDelay->Start ( 500000 ); // 0.5 s |
|
1410 EUNIT_ASSERT_DESC( iPluginSubscribersCalled, "UnsubscribeContext was not detected by plugin" ); |
|
1411 |
|
1412 err = iClient->UnsubscribeContext ( *valueSub ); |
|
1413 EUNIT_ASSERT_DESC( err == KErrNone, "Incorrect UnsubscribeContext return value!" ); |
|
1414 |
|
1415 CleanupStack::PopAndDestroy ( pluginSub2 ); //CLEANUP>> pluginSub2 |
|
1416 CleanupStack::PopAndDestroy ( pluginSub1 ); //CLEANUP>> pluginSub1 |
|
1417 CleanupStack::PopAndDestroy ( valueSub ); //CLEANUP>> valueSub |
|
1418 } |
|
1419 |
|
1420 void MT_CFClient::MT_CCFClient_SubscribersNosubscribersPlugin2L( ) |
|
1421 { |
|
1422 TInt err = KErrNone; |
|
1423 |
|
1424 // Subscribe to value context signalling plugin "reactions". |
|
1425 // below // CLEANUP<< valueSub |
|
1426 CCFContextSubscription* valueSub = CCFContextSubscription::NewLC ( ); |
|
1427 valueSub->SetContextSourceL ( KTestContextSource ); |
|
1428 valueSub->SetContextTypeL ( KTestContextValueType ); |
|
1429 err = iClient->SubscribeContext ( *valueSub ); |
|
1430 EUNIT_ASSERT_DESC( err == KErrNone, "Incorrect SubscribeContext return value!" ); |
|
1431 |
|
1432 // Test if plugin gets Subscribers() callback if we add subscription |
|
1433 iExpectedSubscribersSource.Copy ( KTestContextSource ); |
|
1434 iExpectedSubscribersType.Copy ( KTestContextValueType ); |
|
1435 iExpectedSubscribersValue.Copy ( KTestContextValueSubsOk ); |
|
1436 |
|
1437 // 1.Subscription |
|
1438 iCheckPluginSubscribersCalled = ETrue; |
|
1439 iPluginSubscribersCalled = EFalse; |
|
1440 // below // CLEANUP<< pluginSub1 |
|
1441 CCFContextSubscription* pluginSub1 = CCFContextSubscription::NewLC ( ); |
|
1442 pluginSub1->SetContextSourceL ( KTestContextSource ); |
|
1443 pluginSub1->SetContextTypeL ( KTestContextType ); |
|
1444 err = iClient->SubscribeContext ( *pluginSub1 ); |
|
1445 EUNIT_ASSERT_DESC( err == KErrNone, "Incorrect SubscribeContext return value!" ); |
|
1446 |
|
1447 // Wait for correct context as answer. |
|
1448 iTestDelay->Start ( 250000 ); // 250 ms |
|
1449 EUNIT_ASSERT_DESC( !iCheckPluginSubscribersCalled, "SubscribeContext was not detected by plugin" ); |
|
1450 EUNIT_ASSERT_DESC( iPluginSubscribersCalled, "SubscribeContext was not detected by plugin" ); |
|
1451 |
|
1452 // 2.Subscription |
|
1453 iCheckPluginSubscribersCalled = ETrue; |
|
1454 iPluginSubscribersCalled = EFalse; |
|
1455 // below // CLEANUP<< pluginSub2 |
|
1456 CCFContextSubscription* pluginSub2 = CCFContextSubscription::NewLC ( ); |
|
1457 pluginSub2->SetContextSourceL ( KTestContextSource ); |
|
1458 pluginSub2->SetContextTypeL ( KTestContextType2 ); |
|
1459 err = iAnotherClient->SubscribeContext ( *pluginSub2 ); |
|
1460 EUNIT_ASSERT_DESC( err == KErrNone, "Incorrect SubscribeContext return value!" ); |
|
1461 |
|
1462 // Wait and no answer expected. |
|
1463 iTestDelay->Start ( 500000 ); // 0.5 s |
|
1464 EUNIT_ASSERT_DESC( !iCheckPluginSubscribersCalled, "SubscribeContext was not detected by plugin" ); |
|
1465 EUNIT_ASSERT_DESC( iPluginSubscribersCalled, "SubscribeContext was not detected by plugin" ); |
|
1466 |
|
1467 // 3.Subscription dummy |
|
1468 // below // CLEANUP<< dummySub |
|
1469 CCFContextSubscription* dummySub = CCFContextSubscription::NewLC(); |
|
1470 dummySub->SetContextSourceL( _L( "jusTaDummySubSource" ) ); |
|
1471 dummySub->SetContextTypeL( _L( "jusTaDummySubType" ) ); |
|
1472 err = iClient->SubscribeContext( *dummySub ); |
|
1473 EUNIT_ASSERT_DESC( err == KErrNone, "Incorrect SubscribeContext return value!" ); |
|
1474 |
|
1475 // Test if plugin gets NoSubscribers() callback if we remove last subscription |
|
1476 iExpectedSubscribersSource.Copy ( KTestContextSource ); |
|
1477 iExpectedSubscribersType.Copy ( KTestContextValueType ); |
|
1478 iExpectedSubscribersValue.Copy ( KTestContextValueNosubsOk ); |
|
1479 |
|
1480 // Unsubscribe 1.Subscription |
|
1481 iCheckPluginSubscribersCalled = ETrue; |
|
1482 iPluginSubscribersCalled = EFalse; |
|
1483 err = iClient->UnsubscribeContext ( *pluginSub1 ); |
|
1484 EUNIT_ASSERT_DESC( err == KErrNone, "Incorrect UnsubscribeContext return value!" ); |
|
1485 |
|
1486 // Wait and no answer expected. |
|
1487 iTestDelay->Start ( 500000 ); // 500 ms |
|
1488 EUNIT_ASSERT_DESC( !iCheckPluginSubscribersCalled, "UnsubscribeContext was not detected by plugin" ); |
|
1489 EUNIT_ASSERT_DESC( iPluginSubscribersCalled, "UnsubscribeContext was not detected by plugin" ); |
|
1490 |
|
1491 // Test if plugin gets NoSubscribers() callback if we remove last subscription |
|
1492 iExpectedSubscribersSource.Copy ( KTestContextSource ); |
|
1493 iExpectedSubscribersType.Copy ( KTestContextValueType ); |
|
1494 iExpectedSubscribersValue.Copy ( KTestContextValueNosubsOk ); |
|
1495 |
|
1496 // Unsubscribe 2.Subscription |
|
1497 iCheckPluginSubscribersCalled = ETrue; |
|
1498 iPluginSubscribersCalled = EFalse; |
|
1499 err = iAnotherClient->UnsubscribeContext ( *pluginSub2 ); |
|
1500 EUNIT_ASSERT_DESC( err == KErrNone, "Incorrect UnsubscribeContext return value!" ); |
|
1501 |
|
1502 // Wait for correct context as answer. |
|
1503 iTestDelay->Start ( 500000 ); // 0.5 s |
|
1504 EUNIT_ASSERT_DESC( !iCheckPluginSubscribersCalled, "UnsubscribeContext was not detected by plugin" ); |
|
1505 EUNIT_ASSERT_DESC( iPluginSubscribersCalled, "UnsubscribeContext was not detected by plugin" ); |
|
1506 |
|
1507 // Unsubscribe 3.Subscription dummy |
|
1508 err = iClient->UnsubscribeContext( *dummySub ); |
|
1509 EUNIT_ASSERT_DESC( err == KErrNone, "Incorrect UnsubscribeContext return value!" ); |
|
1510 |
|
1511 err = iClient->UnsubscribeContext ( *valueSub ); |
|
1512 EUNIT_ASSERT_DESC( err == KErrNone, "Incorrect UnsubscribeContext return value!" ); |
|
1513 |
|
1514 CleanupStack::PopAndDestroy ( dummySub ); //CLEANUP>> dummySub |
|
1515 CleanupStack::PopAndDestroy ( pluginSub2 ); //CLEANUP>> pluginSub2 |
|
1516 CleanupStack::PopAndDestroy ( pluginSub1 ); //CLEANUP>> pluginSub1 |
|
1517 CleanupStack::PopAndDestroy ( valueSub ); //CLEANUP>> valueSub |
|
1518 } |
|
1519 |
|
1520 void MT_CFClient::MT_CCFClient_SubscribersNosubscribersPlugin3L() |
|
1521 { |
|
1522 TInt err = KErrNone; |
|
1523 |
|
1524 // Subscribe to value context signalling plugin "reactions". |
|
1525 // below // CLEANUP<< valueSub |
|
1526 CCFContextSubscription* valueSub = CCFContextSubscription::NewLC ( ); |
|
1527 valueSub->SetContextSourceL ( KTestContextSource ); |
|
1528 valueSub->SetContextTypeL ( KTestContextValueType ); |
|
1529 err = iClient->SubscribeContext ( *valueSub ); |
|
1530 EUNIT_ASSERT_DESC( err == KErrNone, "Incorrect SubscribeContext return value!" ); |
|
1531 |
|
1532 // Test if plugin gets Subscribers() callback if we add subscription |
|
1533 iExpectedSubscribersSource.Copy ( KTestContextSource ); |
|
1534 iExpectedSubscribersType.Copy ( KTestContextValueType ); |
|
1535 iExpectedSubscribersValue.Copy ( KTestContextValueSubsOk ); |
|
1536 |
|
1537 // 1.Subscription |
|
1538 iCheckPluginSubscribersCalled = ETrue; |
|
1539 iPluginSubscribersCalled = EFalse; |
|
1540 // below // CLEANUP<< pluginSub1 |
|
1541 CCFContextSubscription* pluginSub1 = CCFContextSubscription::NewLC ( ); |
|
1542 pluginSub1->SetContextSourceL ( KTestContextSource ); |
|
1543 pluginSub1->SetContextTypeL ( KTestContextType ); |
|
1544 err = iClient->SubscribeContext ( *pluginSub1 ); |
|
1545 EUNIT_ASSERT_DESC( err == KErrNone, "Incorrect SubscribeContext return value!" ); |
|
1546 |
|
1547 // Wait for correct context as answer. |
|
1548 iTestDelay->Start ( 250000 ); // 250 ms |
|
1549 EUNIT_ASSERT_DESC( !iCheckPluginSubscribersCalled, "SubscribeContext was not detected by plugin" ); |
|
1550 EUNIT_ASSERT_DESC( iPluginSubscribersCalled, "SubscribeContext was not detected by plugin" ); |
|
1551 |
|
1552 // 2.Subscription |
|
1553 iCheckPluginSubscribersCalled = ETrue; |
|
1554 iPluginSubscribersCalled = EFalse; |
|
1555 // below // CLEANUP<< pluginSub2 |
|
1556 CCFContextSubscription* pluginSub2 = CCFContextSubscription::NewLC ( ); |
|
1557 pluginSub2->SetContextSourceL ( KTestContextSource ); |
|
1558 pluginSub2->SetContextTypeL ( KTestContextType2 ); |
|
1559 err = iAnotherClient->SubscribeContext ( *pluginSub2 ); |
|
1560 EUNIT_ASSERT_DESC( err == KErrNone, "Incorrect SubscribeContext return value!" ); |
|
1561 |
|
1562 // Wait and no answer expected. |
|
1563 iTestDelay->Start ( 500000 ); // 0.5 s |
|
1564 EUNIT_ASSERT_DESC( !iCheckPluginSubscribersCalled, "SubscribeContext was not detected by plugin" ); |
|
1565 EUNIT_ASSERT_DESC( iPluginSubscribersCalled, "SubscribeContext was not detected by plugin" ); |
|
1566 |
|
1567 // 3.Subscription dummy |
|
1568 // below // CLEANUP<< dummySub |
|
1569 CCFContextSubscription* dummySub = CCFContextSubscription::NewLC(); |
|
1570 dummySub->SetContextSourceL( _L( "jusTaDummySubSource" ) ); |
|
1571 dummySub->SetContextTypeL( _L( "jusTaDummySubType" ) ); |
|
1572 err = iClient->SubscribeContext( *dummySub ); |
|
1573 EUNIT_ASSERT_DESC( err == KErrNone, "Incorrect SubscribeContext return value!" ); |
|
1574 |
|
1575 // Unsubscribe Subscriptions by deleting the client |
|
1576 delete iClient; |
|
1577 iClient = NULL; |
|
1578 delete iAnotherClient; |
|
1579 iAnotherClient = NULL; |
|
1580 |
|
1581 CleanupStack::PopAndDestroy ( dummySub ); //CLEANUP>> dummySub |
|
1582 CleanupStack::PopAndDestroy ( pluginSub2 ); //CLEANUP>> pluginSub2 |
|
1583 CleanupStack::PopAndDestroy ( pluginSub1 ); //CLEANUP>> pluginSub1 |
|
1584 CleanupStack::PopAndDestroy ( valueSub ); //CLEANUP>> valueSub |
|
1585 } |
|
1586 |
|
1587 void MT_CFClient::MT_CCFClient_ContextSourceCommandPluginL( ) |
|
1588 { |
|
1589 TInt err = KErrNone; |
|
1590 |
|
1591 // Subscribe to value context signalling plugin "reactions". |
|
1592 // below // CLEANUP<< sourceCmdSignalSub |
|
1593 CCFContextSubscription* sourceCmdSignalSub = CCFContextSubscription::NewLC(); |
|
1594 sourceCmdSignalSub->SetContextSourceL( KSourceCommandSignalContextSource ); |
|
1595 sourceCmdSignalSub->SetContextTypeL( KSourceCommandSignalContextType ); |
|
1596 err = iClient->SubscribeContext( *sourceCmdSignalSub ); |
|
1597 EUNIT_ASSERT_DESC( err == KErrNone, "Incorrect SubscribeContext return value!" ); |
|
1598 |
|
1599 // Define context // CLEANUP<< context |
|
1600 CCFContextObject* context = CCFContextObject::NewLC( |
|
1601 KSourceCommandPluginScriptContextSource, |
|
1602 KSourceCommandScriptContextType, |
|
1603 KSourceCommandScript1ContextValueDeactivate ); |
|
1604 err = iClient->DefineContext( context->Source(), context->Type(), |
|
1605 KPassSec, KPassSec ); |
|
1606 EUNIT_ASSERT_DESC( err == KErrNone, "Incorrect DefineContext return value! " ); |
|
1607 |
|
1608 // Registering scripts with context source command as action |
|
1609 HBufC8* script = LoadScriptFromFile(_L("test-sourceCommandPlugIn.xml") ); |
|
1610 TInt scriptId( -1 ); |
|
1611 err = iClient->RegisterScript( _L("test-sourceCommandPlugIn.xml"), |
|
1612 *script, |
|
1613 scriptId ); |
|
1614 EUNIT_ASSERT_DESC( err == KErrNone, "Error when registering script!" ); |
|
1615 delete script; |
|
1616 script = NULL; |
|
1617 |
|
1618 script = LoadScriptFromFile(_L("test-sourceCommandPlugIn2.xml") ); |
|
1619 TInt scriptId2( -1 ); |
|
1620 err = iClient->RegisterScript( _L("test-sourceCommandPlugIn2.xml"), |
|
1621 *script, |
|
1622 scriptId2 ); |
|
1623 EUNIT_ASSERT_DESC( err == KErrNone, "Error when registering script!" ); |
|
1624 delete script; |
|
1625 script = NULL; |
|
1626 |
|
1627 // 1. Publish script1 deactivate |
|
1628 // Test values that plugin responds correctly to source command |
|
1629 iExpectedSubscribersSource.Copy( KSourceCommandSignalContextSource ); |
|
1630 iExpectedSubscribersType.Copy( KSourceCommandSignalContextType ); |
|
1631 iExpectedSubscribersValue.Copy( KSourceCommandSignalContextValueDeactiveReqDeactivate ); |
|
1632 iCheckSourceCommandHandled = ETrue; |
|
1633 iSourceCommandHandled = EFalse; |
|
1634 context->SetValueL( KSourceCommandScript1ContextValueDeactivate ); |
|
1635 err = iClient->PublishContext( *context ); |
|
1636 EUNIT_ASSERT_DESC( err == KErrNone, "Incorrect PublishContext return value!" ); |
|
1637 // Wait for correct context as answer. |
|
1638 iWait->Start(); |
|
1639 EUNIT_ASSERT_DESC( !iCheckSourceCommandHandled, "Source command was not checked" ); |
|
1640 EUNIT_ASSERT_DESC( iSourceCommandHandled, "Source command was not detected by plugin" ); |
|
1641 |
|
1642 // 2. Publish script2 deactivate |
|
1643 iExpectedSubscribersValue.Copy( KSourceCommandSignalContextValueDeactiveReqDeactivate ); |
|
1644 iCheckSourceCommandHandled = ETrue; |
|
1645 iSourceCommandHandled = EFalse; |
|
1646 context->SetValueL( KSourceCommandScript2ContextValueDeactivate ); |
|
1647 err = iClient->PublishContext( *context ); |
|
1648 EUNIT_ASSERT_DESC( err == KErrNone, "Incorrect PublishContext return value!" ); |
|
1649 // Wait for correct context as answer. |
|
1650 iWait->Start(); |
|
1651 EUNIT_ASSERT_DESC( !iCheckSourceCommandHandled, "Source command was not checked" ); |
|
1652 EUNIT_ASSERT_DESC( iSourceCommandHandled, "Source command was not detected by plugin" ); |
|
1653 |
|
1654 // 3. Publish script1 activate |
|
1655 iExpectedSubscribersValue.Copy( KSourceCommandSignalContextValueActivated ); |
|
1656 iCheckSourceCommandHandled = ETrue; |
|
1657 iSourceCommandHandled = EFalse; |
|
1658 context->SetValueL( KSourceCommandScript1ContextValueActivate ); |
|
1659 err = iClient->PublishContext( *context ); |
|
1660 EUNIT_ASSERT_DESC( err == KErrNone, "Incorrect PublishContext return value!" ); |
|
1661 // Wait for correct context as answer. |
|
1662 iWait->Start(); |
|
1663 EUNIT_ASSERT_DESC( !iCheckSourceCommandHandled, "Source command was not checked" ); |
|
1664 EUNIT_ASSERT_DESC( iSourceCommandHandled, "Source command was not detected by plugin" ); |
|
1665 |
|
1666 // 4. Publish script1 activate |
|
1667 iExpectedSubscribersValue.Copy( KSourceCommandSignalContextValueActiveReqActivate ); |
|
1668 iCheckSourceCommandHandled = ETrue; |
|
1669 iSourceCommandHandled = EFalse; |
|
1670 context->SetValueL( KSourceCommandScript1ContextValueActivate ); |
|
1671 err = iClient->PublishContext( *context ); |
|
1672 EUNIT_ASSERT_DESC( err == KErrNone, "Incorrect PublishContext return value!" ); |
|
1673 // Wait for correct context as answer. |
|
1674 iWait->Start(); |
|
1675 EUNIT_ASSERT_DESC( !iCheckSourceCommandHandled, "Source command was not checked" ); |
|
1676 EUNIT_ASSERT_DESC( iSourceCommandHandled, "Source command was not detected by plugin" ); |
|
1677 |
|
1678 // 5. Publish script2 activate |
|
1679 iExpectedSubscribersValue.Copy( KSourceCommandSignalContextValueActiveReqActivate ); |
|
1680 iCheckSourceCommandHandled = ETrue; |
|
1681 iSourceCommandHandled = EFalse; |
|
1682 context->SetValueL( KSourceCommandScript2ContextValueActivate ); |
|
1683 err = iClient->PublishContext( *context ); |
|
1684 EUNIT_ASSERT_DESC( err == KErrNone, "Incorrect PublishContext return value!" ); |
|
1685 // Wait for correct context as answer. |
|
1686 iWait->Start(); |
|
1687 EUNIT_ASSERT_DESC( !iCheckSourceCommandHandled, "Source command was not checked" ); |
|
1688 EUNIT_ASSERT_DESC( iSourceCommandHandled, "Source command was not detected by plugin" ); |
|
1689 |
|
1690 // 6. Publish script2 deactivate |
|
1691 iExpectedSubscribersValue.Copy( KSourceCommandSignalContextValueActiveReqDeactivate ); |
|
1692 iCheckSourceCommandHandled = ETrue; |
|
1693 iSourceCommandHandled = EFalse; |
|
1694 context->SetValueL( KSourceCommandScript2ContextValueDeactivate ); |
|
1695 err = iClient->PublishContext( *context ); |
|
1696 EUNIT_ASSERT_DESC( err == KErrNone, "Incorrect PublishContext return value!" ); |
|
1697 // Wait for correct context as answer. |
|
1698 iWait->Start(); |
|
1699 EUNIT_ASSERT_DESC( !iCheckSourceCommandHandled, "Source command was not checked" ); |
|
1700 EUNIT_ASSERT_DESC( iSourceCommandHandled, "Source command was not detected by plugin" ); |
|
1701 |
|
1702 // 7. Publish script2 deactivate |
|
1703 iExpectedSubscribersValue.Copy( KSourceCommandSignalContextValueActiveReqDeactivate ); |
|
1704 iCheckSourceCommandHandled = ETrue; |
|
1705 iSourceCommandHandled = EFalse; |
|
1706 context->SetValueL( KSourceCommandScript2ContextValueDeactivate ); |
|
1707 err = iClient->PublishContext( *context ); |
|
1708 EUNIT_ASSERT_DESC( err == KErrNone, "Incorrect PublishContext return value!" ); |
|
1709 // Wait for correct context as answer. |
|
1710 iWait->Start(); |
|
1711 EUNIT_ASSERT_DESC( !iCheckSourceCommandHandled, "Source command was not checked" ); |
|
1712 EUNIT_ASSERT_DESC( iSourceCommandHandled, "Source command was not detected by plugin" ); |
|
1713 |
|
1714 // 8. Publish script1 deactivate |
|
1715 iExpectedSubscribersValue.Copy( KSourceCommandSignalContextValueDeactivated ); |
|
1716 iCheckSourceCommandHandled = ETrue; |
|
1717 iSourceCommandHandled = EFalse; |
|
1718 context->SetValueL( KSourceCommandScript1ContextValueDeactivate ); |
|
1719 err = iClient->PublishContext( *context ); |
|
1720 EUNIT_ASSERT_DESC( err == KErrNone, "Incorrect PublishContext return value!" ); |
|
1721 // Wait for correct context as answer. |
|
1722 iWait->Start(); |
|
1723 EUNIT_ASSERT_DESC( !iCheckSourceCommandHandled, "Source command was not checked" ); |
|
1724 EUNIT_ASSERT_DESC( iSourceCommandHandled, "Source command was not detected by plugin" ); |
|
1725 |
|
1726 // 9. Publish script2 deactivate |
|
1727 iExpectedSubscribersValue.Copy( KSourceCommandSignalContextValueDeactiveReqDeactivate ); |
|
1728 iCheckSourceCommandHandled = ETrue; |
|
1729 iSourceCommandHandled = EFalse; |
|
1730 context->SetValueL( KSourceCommandScript2ContextValueDeactivate ); |
|
1731 err = iClient->PublishContext( *context ); |
|
1732 EUNIT_ASSERT_DESC( err == KErrNone, "Incorrect PublishContext return value!" ); |
|
1733 // Wait for correct context as answer. |
|
1734 iWait->Start(); |
|
1735 EUNIT_ASSERT_DESC( !iCheckSourceCommandHandled, "Source command was not checked" ); |
|
1736 EUNIT_ASSERT_DESC( iSourceCommandHandled, "Source command was not detected by plugin" ); |
|
1737 |
|
1738 err = iClient->UnsubscribeContext( *sourceCmdSignalSub ); |
|
1739 EUNIT_ASSERT_DESC( err == KErrNone, "Incorrect UnsubscribeContext return value!" ); |
|
1740 |
|
1741 err = iClient->DeregisterScript( scriptId ); |
|
1742 EUNIT_ASSERT_DESC( err == KErrNone, "Error when de-registering script!" ); |
|
1743 err = iClient->DeregisterScript( scriptId2 ); |
|
1744 EUNIT_ASSERT_DESC( err == KErrNone, "Error when de-registering script!" ); |
|
1745 |
|
1746 CleanupStack::PopAndDestroy( context ); // CLEANUP>> context |
|
1747 CleanupStack::PopAndDestroy( sourceCmdSignalSub );//CLEANUP>> sourceCmdSignalSub |
|
1748 } |
|
1749 |
|
1750 void MT_CFClient::MT_CCFClient_ContextSourceCommandClientL( ) |
|
1751 { |
|
1752 TInt err = KErrNone; |
|
1753 |
|
1754 // Define context // CLEANUP<< context |
|
1755 CCFContextObject* context = CCFContextObject::NewLC( |
|
1756 KSourceCommandClientScriptContextSource, |
|
1757 KSourceCommandScriptContextType, |
|
1758 KSourceCommandScript1ContextValueDeactivate ); |
|
1759 err = iClient->DefineContext( context->Source(), context->Type(), |
|
1760 KPassSec, KPassSec ); |
|
1761 EUNIT_ASSERT_DESC( err == KErrNone, "Incorrect DefineContext return value! " ); |
|
1762 |
|
1763 // Registering scripts with context source command as action |
|
1764 HBufC8* script = LoadScriptFromFile(_L("test-sourceCommand.xml") ); |
|
1765 TInt scriptId( -1 ); |
|
1766 err = iClient->RegisterScript( _L("test-sourceCommand.xml"), |
|
1767 *script, |
|
1768 scriptId ); |
|
1769 EUNIT_ASSERT_DESC( err == KErrNone, "Error when registering script!" ); |
|
1770 delete script; |
|
1771 script = NULL; |
|
1772 |
|
1773 script = LoadScriptFromFile(_L("test-sourceCommand2.xml") ); |
|
1774 TInt scriptId2( -1 ); |
|
1775 err = iClient->RegisterScript( _L("test-sourceCommand2.xml"), |
|
1776 *script, |
|
1777 scriptId2 ); |
|
1778 EUNIT_ASSERT_DESC( err == KErrNone, "Error when registering script!" ); |
|
1779 delete script; |
|
1780 script = NULL; |
|
1781 |
|
1782 // 1. Publish script1 deactivate |
|
1783 iHandleCommandCalled = EFalse; |
|
1784 context->SetValueL( KSourceCommandScript1ContextValueDeactivate ); |
|
1785 err = iClient->PublishContext( *context ); |
|
1786 EUNIT_ASSERT_DESC( err == KErrNone, "Incorrect PublishContext return value!" ); |
|
1787 // Wait for call to handle command. |
|
1788 iWait->Start(); |
|
1789 EUNIT_ASSERT_DESC( iHandleCommandCalled, "Source command was not detected by client" ); |
|
1790 EUNIT_ASSERT_DESC( iActiveRequests.Count() == 0, "Client source active request count error" ); |
|
1791 |
|
1792 // 2. Publish script2 deactivate |
|
1793 iHandleCommandCalled = EFalse; |
|
1794 context->SetValueL( KSourceCommandScript2ContextValueDeactivate ); |
|
1795 err = iClient->PublishContext( *context ); |
|
1796 EUNIT_ASSERT_DESC( err == KErrNone, "Incorrect PublishContext return value!" ); |
|
1797 // Wait for call to handle command. |
|
1798 iWait->Start(); |
|
1799 EUNIT_ASSERT_DESC( iHandleCommandCalled, "Source command was not detected by client" ); |
|
1800 EUNIT_ASSERT_DESC( iActiveRequests.Count() == 0, "Client source active request count error" ); |
|
1801 |
|
1802 // 3. Publish script1 activate |
|
1803 iHandleCommandCalled = EFalse; |
|
1804 context->SetValueL( KSourceCommandScript1ContextValueActivate ); |
|
1805 err = iClient->PublishContext( *context ); |
|
1806 EUNIT_ASSERT_DESC( err == KErrNone, "Incorrect PublishContext return value!" ); |
|
1807 // Wait for call to handle command. |
|
1808 iWait->Start(); |
|
1809 EUNIT_ASSERT_DESC( iHandleCommandCalled, "Source command was not detected by client" ); |
|
1810 EUNIT_ASSERT_DESC( iActiveRequests.Count() == 1, "Client source active request count error" ); |
|
1811 |
|
1812 // 4. Publish script1 activate |
|
1813 iHandleCommandCalled = EFalse; |
|
1814 context->SetValueL( KSourceCommandScript1ContextValueActivate ); |
|
1815 err = iClient->PublishContext( *context ); |
|
1816 EUNIT_ASSERT_DESC( err == KErrNone, "Incorrect PublishContext return value!" ); |
|
1817 // Wait for call to handle command. |
|
1818 iWait->Start(); |
|
1819 EUNIT_ASSERT_DESC( iHandleCommandCalled, "Source command was not detected by client" ); |
|
1820 EUNIT_ASSERT_DESC( iActiveRequests.Count() == 1, "Client source active request count error" ); |
|
1821 |
|
1822 // 5. Publish script2 activate |
|
1823 iHandleCommandCalled = EFalse; |
|
1824 context->SetValueL( KSourceCommandScript2ContextValueActivate ); |
|
1825 err = iClient->PublishContext( *context ); |
|
1826 EUNIT_ASSERT_DESC( err == KErrNone, "Incorrect PublishContext return value!" ); |
|
1827 // Wait for call to handle command. |
|
1828 iWait->Start(); |
|
1829 EUNIT_ASSERT_DESC( iHandleCommandCalled, "Source command was not detected by client" ); |
|
1830 EUNIT_ASSERT_DESC( iActiveRequests.Count() == 2, "Client source active request count error" ); |
|
1831 |
|
1832 // 6. Publish script2 deactivate |
|
1833 iHandleCommandCalled = EFalse; |
|
1834 context->SetValueL( KSourceCommandScript2ContextValueDeactivate ); |
|
1835 err = iClient->PublishContext( *context ); |
|
1836 EUNIT_ASSERT_DESC( err == KErrNone, "Incorrect PublishContext return value!" ); |
|
1837 // Wait for call to handle command. |
|
1838 iWait->Start(); |
|
1839 EUNIT_ASSERT_DESC( iHandleCommandCalled, "Source command was not detected by client" ); |
|
1840 EUNIT_ASSERT_DESC( iActiveRequests.Count() == 1, "Client source active request count error" ); |
|
1841 |
|
1842 // 7. Publish script2 deactivate |
|
1843 iHandleCommandCalled = EFalse; |
|
1844 context->SetValueL( KSourceCommandScript2ContextValueDeactivate ); |
|
1845 err = iClient->PublishContext( *context ); |
|
1846 EUNIT_ASSERT_DESC( err == KErrNone, "Incorrect PublishContext return value!" ); |
|
1847 // Wait for call to handle command. |
|
1848 iWait->Start(); |
|
1849 EUNIT_ASSERT_DESC( iHandleCommandCalled, "Source command was not detected by client" ); |
|
1850 EUNIT_ASSERT_DESC( iActiveRequests.Count() == 1, "Client source active request count error" ); |
|
1851 |
|
1852 // 8. Publish script1 deactivate |
|
1853 iHandleCommandCalled = EFalse; |
|
1854 context->SetValueL( KSourceCommandScript1ContextValueDeactivate ); |
|
1855 err = iClient->PublishContext( *context ); |
|
1856 EUNIT_ASSERT_DESC( err == KErrNone, "Incorrect PublishContext return value!" ); |
|
1857 // Wait for call to handle command. |
|
1858 iWait->Start(); |
|
1859 EUNIT_ASSERT_DESC( iHandleCommandCalled, "Source command was not detected by client" ); |
|
1860 EUNIT_ASSERT_DESC( iActiveRequests.Count() == 0, "Client source active request count error" ); |
|
1861 |
|
1862 // 9. Publish script2 deactivate |
|
1863 iHandleCommandCalled = EFalse; |
|
1864 context->SetValueL( KSourceCommandScript2ContextValueDeactivate ); |
|
1865 err = iClient->PublishContext( *context ); |
|
1866 EUNIT_ASSERT_DESC( err == KErrNone, "Incorrect PublishContext return value!" ); |
|
1867 // Wait for call to handle command. |
|
1868 iWait->Start(); |
|
1869 EUNIT_ASSERT_DESC( iHandleCommandCalled, "Source command was not detected by client" ); |
|
1870 EUNIT_ASSERT_DESC( iActiveRequests.Count() == 0, "Client source active request count error" ); |
|
1871 |
|
1872 err = iClient->DeregisterScript( scriptId ); |
|
1873 EUNIT_ASSERT_DESC( err == KErrNone, "Error when de-registering script!" ); |
|
1874 err = iClient->DeregisterScript( scriptId2 ); |
|
1875 EUNIT_ASSERT_DESC( err == KErrNone, "Error when de-registering script!" ); |
|
1876 |
|
1877 CleanupStack::PopAndDestroy( context ); // CLEANUP>> context |
|
1878 } |
|
1879 |
|
1880 void MT_CFClient::MT_CCFClient_PublishContextL( ) |
|
1881 { |
|
1882 CCFContextObject* context = CCFContextObject::NewLC ( ); |
|
1883 CCFClient* client = CCFClient::NewLC ( *this ); |
|
1884 TInt err = KErrNone; |
|
1885 |
|
1886 // Try to publish context which has not been defined |
|
1887 ConfigureContextL ( *context ); |
|
1888 err = client->PublishContext ( *context ); |
|
1889 EUNIT_ASSERT_DESC( err == KErrNotFound, "Incorrect PublishContext return value!" ); |
|
1890 |
|
1891 // Define context and publish it |
|
1892 err = client->DefineContext ( context->Source ( ), context->Type ( ), |
|
1893 KPassSec ); |
|
1894 EUNIT_ASSERT_DESC( err == KErrNone, "Incorrect DefineContext return value!" ); |
|
1895 err = client->PublishContext ( *context ); |
|
1896 EUNIT_ASSERT_DESC( err == KErrNone, "Incorrect PublishContext return value!" ); |
|
1897 |
|
1898 // Delete client and publish same context |
|
1899 CleanupStack::PopAndDestroy ( client ); |
|
1900 client = CCFClient::NewLC ( *this ); |
|
1901 err = client->PublishContext ( *context ); |
|
1902 EUNIT_ASSERT_DESC( err == KErrNone, "Incorrect PublishContext return value!" ); |
|
1903 |
|
1904 // Define a new context and publish it |
|
1905 ConfigureContextL ( *context ); |
|
1906 err = client->DefineContext ( context->Source ( ), context->Type ( ), |
|
1907 KPassSec ); |
|
1908 EUNIT_ASSERT_DESC( err == KErrNone, "Incorrect DefineContext return value!" ); |
|
1909 err = client->PublishContext ( *context ); |
|
1910 EUNIT_ASSERT_DESC( err == KErrNone, "Incorrect PublishContext return value!" ); |
|
1911 |
|
1912 // Test incorrect context values |
|
1913 context->SetSourceL ( KNullDesC ); |
|
1914 err = client->PublishContext ( *context ); |
|
1915 EUNIT_ASSERT_DESC( err == KErrArgument, "Incorrect PublishContext return value!" ); |
|
1916 context->SetTypeL ( KNullDesC ); |
|
1917 err = client->PublishContext ( *context ); |
|
1918 EUNIT_ASSERT_DESC( err == KErrArgument, "Incorrect PublishContext return value!" ); |
|
1919 context->SetValueL ( KNullDesC ); |
|
1920 err = client->PublishContext ( *context ); |
|
1921 EUNIT_ASSERT_DESC( err == KErrArgument, "Incorrect PublishContext return value!" ); |
|
1922 |
|
1923 // Define context where we do not have access |
|
1924 ConfigureContextL ( *context ); |
|
1925 err = client->DefineContext ( context->Source ( ), context->Type ( ), |
|
1926 KFailSec ); |
|
1927 EUNIT_ASSERT_DESC( err == KErrNone, "Incorrect DefineContext return value!" ); |
|
1928 err = client->PublishContext ( *context ); |
|
1929 EUNIT_ASSERT_DESC( err == KErrAccessDenied, "Incorrect PublishContext return value!" ); |
|
1930 |
|
1931 // Clean up |
|
1932 CleanupStack::PopAndDestroy ( client ); |
|
1933 CleanupStack::PopAndDestroy ( context ); |
|
1934 } |
|
1935 |
|
1936 void MT_CFClient::MT_CCFClient_PublishContextWithDataL( ) |
|
1937 { |
|
1938 _LIT( KKey, "Key" ); |
|
1939 _LIT( KValue, "Value" ); |
|
1940 |
|
1941 CTestContextData* contextData = CTestContextData::NewLC ( KKey, KValue ); |
|
1942 CCFContextObject* context = CCFContextObject::NewLC ( ); |
|
1943 CCFClient* client = CCFClient::NewLC ( *this ); |
|
1944 TInt err = KErrNone; |
|
1945 |
|
1946 // Try to publish context which has not been defined |
|
1947 ConfigureContextL ( *context ); |
|
1948 err = client->PublishContext ( *context, *contextData ); |
|
1949 EUNIT_ASSERT_DESC( err == KErrNotFound, "Incorrect PublishContext return value!" ); |
|
1950 |
|
1951 // Define context and publish it |
|
1952 err = client->DefineContext ( context->Source ( ), context->Type ( ), |
|
1953 KPassSec ); |
|
1954 EUNIT_ASSERT_DESC( err == KErrNone, "Incorrect DefineContext return value!" ); |
|
1955 err = client->PublishContext ( *context, *contextData ); |
|
1956 EUNIT_ASSERT_DESC( err == KErrNone, "Incorrect PublishContext return value!" ); |
|
1957 |
|
1958 // Delete client and publish same context |
|
1959 CleanupStack::PopAndDestroy ( client ); |
|
1960 client = CCFClient::NewLC ( *this ); |
|
1961 err = client->PublishContext ( *context, *contextData ); |
|
1962 EUNIT_ASSERT_DESC( err == KErrNone, "Incorrect PublishContext return value!" ); |
|
1963 |
|
1964 // Define a new context and publish it |
|
1965 ConfigureContextL ( *context ); |
|
1966 err = client->DefineContext ( context->Source ( ), context->Type ( ), |
|
1967 KPassSec ); |
|
1968 EUNIT_ASSERT_DESC( err == KErrNone, "Incorrect DefineContext return value!" ); |
|
1969 err = client->PublishContext ( *context, *contextData ); |
|
1970 EUNIT_ASSERT_DESC( err == KErrNone, "Incorrect PublishContext return value!" ); |
|
1971 |
|
1972 // Test incorrect context values |
|
1973 context->SetSourceL ( KNullDesC ); |
|
1974 err = client->PublishContext ( *context, *contextData ); |
|
1975 EUNIT_ASSERT_DESC( err == KErrArgument, "Incorrect PublishContext return value!" ); |
|
1976 context->SetTypeL ( KNullDesC ); |
|
1977 err = client->PublishContext ( *context, *contextData ); |
|
1978 EUNIT_ASSERT_DESC( err == KErrArgument, "Incorrect PublishContext return value!" ); |
|
1979 context->SetValueL ( KNullDesC ); |
|
1980 err = client->PublishContext ( *context, *contextData ); |
|
1981 EUNIT_ASSERT_DESC( err == KErrArgument, "Incorrect PublishContext return value!" ); |
|
1982 |
|
1983 // Define context where we do not have access |
|
1984 ConfigureContextL ( *context ); |
|
1985 err = client->DefineContext ( context->Source ( ), context->Type ( ), |
|
1986 KFailSec ); |
|
1987 EUNIT_ASSERT_DESC( err == KErrNone, "Incorrect DefineContext return value!" ); |
|
1988 err = client->PublishContext ( *context, *contextData ); |
|
1989 EUNIT_ASSERT_DESC( err == KErrAccessDenied, "Incorrect PublishContext return value!" ); |
|
1990 |
|
1991 // Publish context data with invalid UID |
|
1992 ConfigureContextL ( *context ); |
|
1993 contextData->SetUid ( KNullUid ); |
|
1994 err = client->DefineContext ( context->Source ( ), context->Type ( ), |
|
1995 KFailSec ); |
|
1996 EUNIT_ASSERT_DESC( err == KErrNone, "Incorrect DefineContext return value!" ); |
|
1997 err = client->PublishContext ( *context, *contextData ); |
|
1998 EUNIT_ASSERT_DESC( err == KErrNotSupported, "Incorrect PublishContext return value!" ); |
|
1999 |
|
2000 // Publish too big context data |
|
2001 const TInt length = 16*1024; |
|
2002 HBufC* data = HBufC::NewLC ( length ); |
|
2003 TPtr dataPtr( data->Des ( )); |
|
2004 dataPtr.Fill ( 'z', length ); |
|
2005 contextData->SetKeyL ( dataPtr ); |
|
2006 contextData->SetValueL ( dataPtr ); |
|
2007 contextData->SetUid ( KTestContextDataUid ); |
|
2008 CleanupStack::PopAndDestroy ( data ); |
|
2009 ConfigureContextL ( *context ); |
|
2010 err = client->DefineContext ( context->Source ( ), context->Type ( ), |
|
2011 KPassSec ); |
|
2012 EUNIT_ASSERT_DESC( err == KErrNone, "Incorrect DefineContext return value!" ); |
|
2013 err = client->PublishContext ( *context, *contextData ); |
|
2014 EUNIT_ASSERT_DESC( err == KErrTooBig, "Incorrect PublishContext return value!" ); |
|
2015 |
|
2016 // Clean up |
|
2017 CleanupStack::PopAndDestroy ( client ); |
|
2018 CleanupStack::PopAndDestroy ( context ); |
|
2019 CleanupStack::PopAndDestroy ( contextData ); |
|
2020 } |
|
2021 |
|
2022 void MT_CFClient::MT_CCFClient_SubscribeContext1L( ) |
|
2023 { |
|
2024 CCFContextSubscription* subscription= NULL; |
|
2025 TInt err = KErrNone; |
|
2026 |
|
2027 // Define a context and subscribe it |
|
2028 ConfigureContextL ( *iContextA ); |
|
2029 err = iClient->DefineContext ( iContextA->Source ( ), iContextA->Type ( ), |
|
2030 KPassSec ); |
|
2031 EUNIT_ASSERT_DESC( err == KErrNone, "Incorrect DefineContext return value!" ); |
|
2032 subscription = CCFContextSubscription::NewLC ( ); |
|
2033 subscription->SetContextSourceL ( iContextA->Source ( ) ); |
|
2034 subscription->SetContextTypeL ( iContextA->Type ( ) ); |
|
2035 err = iClient->SubscribeContext ( *subscription ); |
|
2036 EUNIT_ASSERT_DESC( err == KErrNone, "Incorrect SubscribeContext return value!" ); |
|
2037 CleanupStack::PopAndDestroy ( subscription ); |
|
2038 |
|
2039 // Publish a new context value and wait for context indication |
|
2040 UpdateContextValueL ( *iContextA ); |
|
2041 err = iClient->PublishContext ( *iContextA ); |
|
2042 EUNIT_ASSERT_DESC( err == KErrNone, "Incorrect PublishContext return value!" ); |
|
2043 iCheckA = ETrue; |
|
2044 iWait->Start ( ); |
|
2045 |
|
2046 // Publish a new context value and wait for context indication |
|
2047 UpdateContextValueL ( *iContextA ); |
|
2048 err = iClient->PublishContext ( *iContextA ); |
|
2049 EUNIT_ASSERT_DESC( err == KErrNone, "Incorrect PublishContext return value!" ); |
|
2050 iCheckA = ETrue; |
|
2051 iWait->Start ( ); |
|
2052 } |
|
2053 |
|
2054 void MT_CFClient::MT_CCFClient_SubscribeContext2L( ) |
|
2055 { |
|
2056 CCFContextSubscription* subscription= NULL; |
|
2057 TInt err = KErrNone; |
|
2058 |
|
2059 // Define a new context with no access and wait for error message |
|
2060 ConfigureContextL ( *iContextB ); |
|
2061 err = iClient->DefineContext ( iContextB->Source ( ), iContextB->Type ( ), |
|
2062 KFailSec ); |
|
2063 EUNIT_ASSERT_DESC( err == KErrNone, "Incorrect DefineContext return value!" ); |
|
2064 subscription = CCFContextSubscription::NewLC ( ); |
|
2065 subscription->SetContextSourceL ( iContextB->Source ( ) ); |
|
2066 subscription->SetContextTypeL ( iContextB->Type ( ) ); |
|
2067 err = iClient->SubscribeContext ( *subscription ); |
|
2068 EUNIT_ASSERT_DESC( err == KErrNone, "Incorrect SubscribeContext return value!" ); |
|
2069 CleanupStack::PopAndDestroy ( subscription ); |
|
2070 iCheckB = ETrue; |
|
2071 iWait->Start ( ); |
|
2072 } |
|
2073 |
|
2074 void MT_CFClient::MT_CCFClient_SubscribeContext3L( ) |
|
2075 { |
|
2076 CCFContextSubscription* subscription= NULL; |
|
2077 TInt err = KErrNone; |
|
2078 |
|
2079 // Define two contexts with access and subscribe both of them |
|
2080 ConfigureContextL ( *iContextA ); |
|
2081 err = iClient->DefineContext ( iContextA->Source ( ), iContextA->Type ( ), |
|
2082 KPassSec ); |
|
2083 EUNIT_ASSERT_DESC( err == KErrNone, "Incorrect DefineContext return value!" ); |
|
2084 ConfigureContextL ( *iContextB ); |
|
2085 err = iClient->DefineContext ( iContextB->Source ( ), iContextB->Type ( ), |
|
2086 KPassSec ); |
|
2087 EUNIT_ASSERT_DESC( err == KErrNone, "Incorrect DefineContext return value!" ); |
|
2088 |
|
2089 subscription = CCFContextSubscription::NewLC ( ); |
|
2090 subscription->SetContextSourceL ( iContextA->Source ( ) ); |
|
2091 subscription->SetContextTypeL ( iContextA->Type ( ) ); |
|
2092 err = iClient->SubscribeContext ( *subscription ); |
|
2093 EUNIT_ASSERT_DESC( err == KErrNone, "Incorrect SubscribeContext return value!" ); |
|
2094 CleanupStack::PopAndDestroy ( subscription ); |
|
2095 |
|
2096 subscription = CCFContextSubscription::NewLC ( ); |
|
2097 subscription->SetContextSourceL ( iContextB->Source ( ) ); |
|
2098 subscription->SetContextTypeL ( iContextB->Type ( ) ); |
|
2099 err = iClient->SubscribeContext ( *subscription ); |
|
2100 EUNIT_ASSERT_DESC( err == KErrNone, "Incorrect SubscribeContext return value!" ); |
|
2101 CleanupStack::PopAndDestroy ( subscription ); |
|
2102 |
|
2103 // Publish both context at the same time and wait for two indications |
|
2104 UpdateContextValueL ( *iContextA ); |
|
2105 err = iClient->PublishContext ( *iContextA ); |
|
2106 EUNIT_ASSERT_DESC( err == KErrNone, "Incorrect PublishContext return value!" ); |
|
2107 iCheckA = ETrue; |
|
2108 UpdateContextValueL ( *iContextB ); |
|
2109 err = iClient->PublishContext ( *iContextB ); |
|
2110 EUNIT_ASSERT_DESC( err == KErrNone, "Incorrect PublishContext return value!" ); |
|
2111 iCheckB = ETrue; |
|
2112 iWait->Start ( ); |
|
2113 |
|
2114 // Publish both context at the same time and wait for two indications |
|
2115 UpdateContextValueL ( *iContextA ); |
|
2116 err = iClient->PublishContext ( *iContextA ); |
|
2117 EUNIT_ASSERT_DESC( err == KErrNone, "Incorrect PublishContext return value!" ); |
|
2118 iCheckA = ETrue; |
|
2119 UpdateContextValueL ( *iContextB ); |
|
2120 err = iClient->PublishContext ( *iContextB ); |
|
2121 EUNIT_ASSERT_DESC( err == KErrNone, "Incorrect PublishContext return value!" ); |
|
2122 iCheckB = ETrue; |
|
2123 iWait->Start ( ); |
|
2124 } |
|
2125 |
|
2126 void MT_CFClient::MT_CCFClient_SubscribeContext4L( ) |
|
2127 { |
|
2128 CCFContextSubscription* subscription= NULL; |
|
2129 TInt err = KErrNone; |
|
2130 |
|
2131 // Define two context where other we have access and other we don't |
|
2132 // Subscribe both contexts |
|
2133 ConfigureContextL ( *iContextA ); |
|
2134 err = iClient->DefineContext ( iContextA->Source ( ), iContextA->Type ( ), |
|
2135 KPassSec ); |
|
2136 EUNIT_ASSERT_DESC( err == KErrNone, "Incorrect DefineContext return value!" ); |
|
2137 ConfigureContextL ( *iContextB ); |
|
2138 err = iClient->DefineContext ( iContextB->Source ( ), iContextB->Type ( ), |
|
2139 KFailSec ); |
|
2140 EUNIT_ASSERT_DESC( err == KErrNone, "Incorrect DefineContext return value!" ); |
|
2141 |
|
2142 subscription = CCFContextSubscription::NewLC ( ); |
|
2143 subscription->SetContextSourceL ( iContextA->Source ( ) ); |
|
2144 subscription->SetContextTypeL ( iContextA->Type ( ) ); |
|
2145 err = iClient->SubscribeContext ( *subscription ); |
|
2146 EUNIT_ASSERT_DESC( err == KErrNone, "Incorrect SubscribeContext return value!" ); |
|
2147 CleanupStack::PopAndDestroy ( subscription ); |
|
2148 |
|
2149 subscription = CCFContextSubscription::NewLC ( ); |
|
2150 subscription->SetContextSourceL ( iContextB->Source ( ) ); |
|
2151 subscription->SetContextTypeL ( iContextB->Type ( ) ); |
|
2152 err = iClient->SubscribeContext ( *subscription ); |
|
2153 EUNIT_ASSERT_DESC( err == KErrNone, "Incorrect SubscribeContext return value!" ); |
|
2154 CleanupStack::PopAndDestroy ( subscription ); |
|
2155 |
|
2156 // Publish both context at the same time and wait for two indications |
|
2157 iCheckA = ETrue; |
|
2158 iCheckB = ETrue; |
|
2159 |
|
2160 UpdateContextValueL ( *iContextA ); |
|
2161 err = iClient->PublishContext ( *iContextA ); |
|
2162 EUNIT_ASSERT_DESC( err == KErrNone, "Incorrect PublishContext return value!" ); |
|
2163 UpdateContextValueL ( *iContextB ); |
|
2164 err = iClient->PublishContext ( *iContextB ); |
|
2165 EUNIT_ASSERT_DESC( err == KErrAccessDenied, "Incorrect PublishContext return value!" ); |
|
2166 if ( iCheckA || iCheckB ) |
|
2167 { |
|
2168 iWait->Start ( ); |
|
2169 } |
|
2170 } |
|
2171 |
|
2172 void MT_CFClient::MT_CCFClient_SubscribeContext5L( ) |
|
2173 { |
|
2174 CCFContextSubscription* subscription= NULL; |
|
2175 TInt err = KErrNone; |
|
2176 |
|
2177 // First subscribe a context |
|
2178 ConfigureContextL ( *iContextA ); |
|
2179 subscription = CCFContextSubscription::NewLC ( ); |
|
2180 subscription->SetContextSourceL ( iContextA->Source ( ) ); |
|
2181 subscription->SetContextTypeL ( iContextA->Type ( ) ); |
|
2182 err = iClient->SubscribeContext ( *subscription ); |
|
2183 EUNIT_ASSERT_DESC( err == KErrNone, "Incorrect SubscribeContext return value!" ); |
|
2184 CleanupStack::PopAndDestroy ( subscription ); |
|
2185 |
|
2186 // Define the context with access |
|
2187 err = iClient->DefineContext ( iContextA->Source ( ), iContextA->Type ( ), |
|
2188 KPassSec ); |
|
2189 EUNIT_ASSERT_DESC( err == KErrNone, "Incorrect DefineContext return value!" ); |
|
2190 |
|
2191 // Publish new context value and wait for indication |
|
2192 UpdateContextValueL ( *iContextA ); |
|
2193 err = iClient->PublishContext ( *iContextA ); |
|
2194 EUNIT_ASSERT_DESC( err == KErrNone, "Incorrect PublishContext return value!" ); |
|
2195 iCheckA = ETrue; |
|
2196 iWait->Start ( ); |
|
2197 } |
|
2198 |
|
2199 void MT_CFClient::MT_CCFClient_SubscribeContext6L( ) |
|
2200 { |
|
2201 CCFContextSubscription* subscription= NULL; |
|
2202 TInt err = KErrNone; |
|
2203 |
|
2204 // First subscribe a context |
|
2205 ConfigureContextL ( *iContextB ); |
|
2206 subscription = CCFContextSubscription::NewLC ( ); |
|
2207 subscription->SetContextSourceL ( iContextB->Source ( ) ); |
|
2208 subscription->SetContextTypeL ( iContextB->Type ( ) ); |
|
2209 err = iClient->SubscribeContext ( *subscription ); |
|
2210 EUNIT_ASSERT_DESC( err == KErrNone, "Incorrect SubscribeContext return value!" ); |
|
2211 CleanupStack::PopAndDestroy ( subscription ); |
|
2212 |
|
2213 // Define the context with no access and wait for error |
|
2214 err = iClient->DefineContext ( iContextB->Source ( ), iContextB->Type ( ), |
|
2215 KFailSec ); |
|
2216 EUNIT_ASSERT_DESC( err == KErrNone, "Incorrect DefineContext return value!" ); |
|
2217 iCheckB = ETrue; |
|
2218 iWait->Start ( ); |
|
2219 } |
|
2220 |
|
2221 void MT_CFClient::MT_CCFClient_SubscribeContext7L( ) |
|
2222 { |
|
2223 CCFContextSubscription* subscription= NULL; |
|
2224 TInt err = KErrNone; |
|
2225 |
|
2226 // Define two contexts with no access |
|
2227 ConfigureContextL ( *iContextB ); |
|
2228 err = iClient->DefineContext ( iContextB->Source ( ), iContextB->Type ( ), |
|
2229 KFailSec ); |
|
2230 EUNIT_ASSERT_DESC( err == KErrNone, "Incorrect DefineContext return value!" ); |
|
2231 ConfigureContextL ( *iContextC ); |
|
2232 err = iClient->DefineContext ( iContextC->Source ( ), iContextC->Type ( ), |
|
2233 KFailSec ); |
|
2234 EUNIT_ASSERT_DESC( err == KErrNone, "Incorrect DefineContext return value!" ); |
|
2235 |
|
2236 // subscribe both contexts and wait for errors |
|
2237 subscription = CCFContextSubscription::NewLC ( ); |
|
2238 subscription->SetContextSourceL ( iContextB->Source ( ) ); |
|
2239 subscription->SetContextTypeL ( iContextB->Type ( ) ); |
|
2240 err = iClient->SubscribeContext ( *subscription ); |
|
2241 EUNIT_ASSERT_DESC( err == KErrNone, "Incorrect SubscribeContext return value!" ); |
|
2242 CleanupStack::PopAndDestroy ( subscription ); |
|
2243 |
|
2244 subscription = CCFContextSubscription::NewLC ( ); |
|
2245 subscription->SetContextSourceL ( iContextC->Source ( ) ); |
|
2246 subscription->SetContextTypeL ( iContextC->Type ( ) ); |
|
2247 err = iClient->SubscribeContext ( *subscription ); |
|
2248 EUNIT_ASSERT_DESC( err == KErrNone, "Incorrect SubscribeContext return value!" ); |
|
2249 CleanupStack::PopAndDestroy ( subscription ); |
|
2250 iCheckB = ETrue; |
|
2251 iCheckC = ETrue; |
|
2252 iWait->Start ( ); |
|
2253 } |
|
2254 |
|
2255 void MT_CFClient::MT_CCFClient_SubscribeContext8L( ) |
|
2256 { |
|
2257 CCFContextSubscription* subscription= NULL; |
|
2258 TInt err = KErrNone; |
|
2259 |
|
2260 // Define two contexts |
|
2261 ConfigureContextL ( *iContextA ); |
|
2262 iContextA->SetTypeL ( KContextTypeFormatWild ); |
|
2263 err = iClient->DefineContext ( iContextA->Source ( ), iContextA->Type ( ), |
|
2264 KPassSec ); |
|
2265 EUNIT_ASSERT_DESC( err == KErrNone, "Incorrect DefineContext return value!" ); |
|
2266 iContextB->CopyL ( *iContextA ); |
|
2267 UpdateContextTypeL ( *iContextB ); |
|
2268 err = iClient->DefineContext ( iContextB->Source ( ), iContextB->Type ( ), |
|
2269 KPassSec ); |
|
2270 EUNIT_ASSERT_DESC( err == KErrNone, "Incorrect DefineContext return value!" ); |
|
2271 |
|
2272 // Subscribe with sub type match |
|
2273 subscription = CCFContextSubscription::NewLC ( ); |
|
2274 subscription->SetContextSourceL ( iContextA->Source ( ) ); |
|
2275 subscription->SetContextTypeL ( iContextA->Type ( ) ); |
|
2276 subscription->SetSubTypeMatch ( ETrue ); |
|
2277 err = iClient->SubscribeContext ( *subscription ); |
|
2278 EUNIT_ASSERT_DESC( err == KErrNone, "Incorrect SubscribeContext return value!" ); |
|
2279 CleanupStack::PopAndDestroy ( subscription ); |
|
2280 |
|
2281 // Publish contextB and wait for indication |
|
2282 UpdateContextValueL ( *iContextB ); |
|
2283 err = iClient->PublishContext ( *iContextB ); |
|
2284 EUNIT_ASSERT_DESC( err == KErrNone, "Incorrect PublishContext return value!" ); |
|
2285 iCheckB = ETrue; |
|
2286 iWait->Start ( ); |
|
2287 |
|
2288 // Publish contextA and wait for indication |
|
2289 UpdateContextValueL ( *iContextA ); |
|
2290 err = iClient->PublishContext ( *iContextA ); |
|
2291 EUNIT_ASSERT_DESC( err == KErrNone, "Incorrect PublishContext return value!" ); |
|
2292 iCheckA = ETrue; |
|
2293 iWait->Start ( ); |
|
2294 } |
|
2295 |
|
2296 void MT_CFClient::MT_CCFClient_SubscribeContext9L( ) |
|
2297 { |
|
2298 CCFContextSubscription* subscription= NULL; |
|
2299 TInt err = KErrNone; |
|
2300 |
|
2301 // Run this set twice to get regression |
|
2302 static const TInt KCount = 2; |
|
2303 for (TInt i = 0; i < KCount; i++ ) |
|
2304 { |
|
2305 // Define a context |
|
2306 ConfigureContextL ( *iContextA ); |
|
2307 err = iClient->DefineContext ( iContextA->Source ( ), |
|
2308 iContextA->Type ( ), KPassSec ); |
|
2309 EUNIT_ASSERT_DESC( err == KErrNone, "Incorrect DefineContext return value!" ); |
|
2310 |
|
2311 // Subscribe context but indicate only changes |
|
2312 subscription = CCFContextSubscription::NewLC ( ); |
|
2313 subscription->SetContextSourceL ( iContextA->Source ( ) ); |
|
2314 subscription->SetContextTypeL ( iContextA->Type ( ) ); |
|
2315 subscription->SetOnlyChangesIndicated ( ETrue ); |
|
2316 err = iClient->SubscribeContext ( *subscription ); |
|
2317 EUNIT_ASSERT_DESC( err == KErrNone, "Incorrect SubscribeContext return value!" ); |
|
2318 CleanupStack::PopAndDestroy ( subscription ); |
|
2319 |
|
2320 // Update context value, Publish context and wait for indication |
|
2321 UpdateContextValueL ( *iContextA ); |
|
2322 err = iClient->PublishContext ( *iContextA ); |
|
2323 EUNIT_ASSERT_DESC( err == KErrNone, "Incorrect PublishContext return value!" ); |
|
2324 iCheckA = ETrue; |
|
2325 iWait->Start ( ); |
|
2326 |
|
2327 // Publish same context, context indication should not happen |
|
2328 err = iClient->PublishContext ( *iContextA ); |
|
2329 EUNIT_ASSERT_DESC( err == KErrNone, "Incorrect PublishContext return value!" ); |
|
2330 iCheckA = ETrue; |
|
2331 Wait ( KDelay ); |
|
2332 EUNIT_ASSERT_DESC( iCheckA, "Context should not have been indicated!" ); |
|
2333 iCheckA = EFalse; |
|
2334 |
|
2335 // Define a context |
|
2336 ConfigureContextL ( *iContextA ); |
|
2337 err = iClient->DefineContext ( iContextA->Source ( ), |
|
2338 iContextA->Type ( ), KPassSec ); |
|
2339 EUNIT_ASSERT_DESC( err == KErrNone, "Incorrect DefineContext return value!" ); |
|
2340 |
|
2341 // Subscribe context but indicate only changes |
|
2342 subscription = CCFContextSubscription::NewLC ( ); |
|
2343 subscription->SetContextSourceL ( iContextA->Source ( ) ); |
|
2344 subscription->SetContextTypeL ( iContextA->Type ( ) ); |
|
2345 subscription->SetOnlyChangesIndicated ( EFalse ); |
|
2346 err = iClient->SubscribeContext ( *subscription ); |
|
2347 EUNIT_ASSERT_DESC( err == KErrNone, "Incorrect SubscribeContext return value!" ); |
|
2348 CleanupStack::PopAndDestroy ( subscription ); |
|
2349 |
|
2350 // Publish context and wait for indication |
|
2351 UpdateContextValueL ( *iContextA ); |
|
2352 err = iClient->PublishContext ( *iContextA ); |
|
2353 EUNIT_ASSERT_DESC( err == KErrNone, "Incorrect PublishContext return value!" ); |
|
2354 iCheckA = ETrue; |
|
2355 iWait->Start ( ); |
|
2356 |
|
2357 // Publish context and wait for indication |
|
2358 UpdateContextValueL ( *iContextA ); |
|
2359 err = iClient->PublishContext ( *iContextA ); |
|
2360 EUNIT_ASSERT_DESC( err == KErrNone, "Incorrect PublishContext return value!" ); |
|
2361 iCheckA = ETrue; |
|
2362 iDeleteClient = ETrue; |
|
2363 iWait->Start ( ); |
|
2364 |
|
2365 EUNIT_ASSERT_DESC( !iClient, "Client not deleted!" ); |
|
2366 iClient = CCFClient::NewL ( *this ); |
|
2367 } |
|
2368 } |
|
2369 |
|
2370 void MT_CFClient::MT_CCFClient_SubscribeContextFromDifferentClientsL( ) |
|
2371 { |
|
2372 CCFContextSubscription* subscription= NULL; |
|
2373 TInt err = KErrNone; |
|
2374 |
|
2375 // Define two contexts with access and subscribe both of them |
|
2376 ConfigureContextL ( *iContextA ); |
|
2377 err = iClient->DefineContext ( iContextA->Source ( ), iContextA->Type ( ), |
|
2378 KPassSec ); |
|
2379 EUNIT_ASSERT_DESC( err == KErrNone, "Incorrect DefineContext return value!" ); |
|
2380 ConfigureContextL ( *iContextB ); |
|
2381 err = iAnotherClient->DefineContext ( iContextB->Source ( ), |
|
2382 iContextB->Type ( ), KPassSec ); |
|
2383 EUNIT_ASSERT_DESC( err == KErrNone, "Incorrect DefineContext return value!" ); |
|
2384 |
|
2385 subscription = CCFContextSubscription::NewLC ( ); |
|
2386 subscription->SetContextSourceL ( iContextA->Source ( ) ); |
|
2387 subscription->SetContextTypeL ( iContextA->Type ( ) ); |
|
2388 err = iClient->SubscribeContext ( *subscription ); |
|
2389 EUNIT_ASSERT_DESC( err == KErrNone, "Incorrect SubscribeContext return value!" ); |
|
2390 CleanupStack::PopAndDestroy ( subscription ); |
|
2391 |
|
2392 subscription = CCFContextSubscription::NewLC ( ); |
|
2393 subscription->SetContextSourceL ( iContextB->Source ( ) ); |
|
2394 subscription->SetContextTypeL ( iContextB->Type ( ) ); |
|
2395 err = iAnotherClient->SubscribeContext ( *subscription ); |
|
2396 EUNIT_ASSERT_DESC( err == KErrNone, "Incorrect SubscribeContext return value!" ); |
|
2397 CleanupStack::PopAndDestroy ( subscription ); |
|
2398 |
|
2399 // Publish both context at the same time and wait for two indications |
|
2400 UpdateContextValueL ( *iContextA ); |
|
2401 err = iClient->PublishContext ( *iContextA ); |
|
2402 EUNIT_ASSERT_DESC( err == KErrNone, "Incorrect PublishContext return value!" ); |
|
2403 iCheckA = ETrue; |
|
2404 UpdateContextValueL ( *iContextB ); |
|
2405 err = iAnotherClient->PublishContext ( *iContextB ); |
|
2406 EUNIT_ASSERT_DESC( err == KErrNone, "Incorrect PublishContext return value!" ); |
|
2407 iCheckB = ETrue; |
|
2408 iWait->Start ( ); |
|
2409 |
|
2410 // Publish both context at the same time and wait for two indications |
|
2411 UpdateContextValueL ( *iContextA ); |
|
2412 err = iAnotherClient->PublishContext ( *iContextA ); |
|
2413 EUNIT_ASSERT_DESC( err == KErrNone, "Incorrect PublishContext return value!" ); |
|
2414 iCheckA = ETrue; |
|
2415 UpdateContextValueL ( *iContextB ); |
|
2416 err = iClient->PublishContext ( *iContextB ); |
|
2417 EUNIT_ASSERT_DESC( err == KErrNone, "Incorrect PublishContext return value!" ); |
|
2418 iCheckB = ETrue; |
|
2419 iWait->Start ( ); |
|
2420 } |
|
2421 |
|
2422 void MT_CFClient::MT_CCFClient_SubscribeContextCombinedL( ) |
|
2423 { |
|
2424 MT_CCFClient_SubscribeContext1L ( ); |
|
2425 Wait ( 5000 ); |
|
2426 MT_CCFClient_SubscribeContext2L ( ); |
|
2427 Wait ( 5000 ); |
|
2428 MT_CCFClient_SubscribeContext3L ( ); |
|
2429 Wait ( 5000 ); |
|
2430 MT_CCFClient_SubscribeContext4L ( ); |
|
2431 Wait ( 5000 ); |
|
2432 MT_CCFClient_SubscribeContext5L ( ); |
|
2433 Wait ( 5000 ); |
|
2434 MT_CCFClient_SubscribeContext6L ( ); |
|
2435 Wait ( 5000 ); |
|
2436 MT_CCFClient_SubscribeContext7L ( ); |
|
2437 Wait ( 5000 ); |
|
2438 MT_CCFClient_SubscribeContext8L ( ); |
|
2439 Wait ( 5000 ); |
|
2440 MT_CCFClient_SubscribeContext9L ( ); |
|
2441 } |
|
2442 |
|
2443 void MT_CFClient::MT_CCFClient_SubscribeContextData1L( ) |
|
2444 { |
|
2445 iCheckContextData = ETrue; |
|
2446 CCFContextSubscription* subscription= NULL; |
|
2447 TInt err = KErrNone; |
|
2448 |
|
2449 // Define a context |
|
2450 // Subscribe the context with data |
|
2451 // Publish new context value with data |
|
2452 ConfigureContextL ( *iContextA ); |
|
2453 err = iClient->DefineContext ( iContextA->Source ( ), iContextA->Type ( ), |
|
2454 KPassSec ); |
|
2455 EUNIT_ASSERT_DESC( err == KErrNone, "Incorrect DefineContext return value!" ); |
|
2456 |
|
2457 subscription = CCFContextSubscription::NewLC ( ); |
|
2458 subscription->SetDataObjectEnabled ( ETrue ); |
|
2459 subscription->SetContextSourceL ( iContextA->Source ( ) ); |
|
2460 subscription->SetContextTypeL ( iContextA->Type ( ) ); |
|
2461 err = iClient->SubscribeContext ( *subscription ); |
|
2462 EUNIT_ASSERT_DESC( err == KErrNone, "Incorrect SubscribeContext return value!" ); |
|
2463 |
|
2464 UpdateContextValueL ( *iContextA ); |
|
2465 err = iClient->PublishContext ( *iContextA, *iContextDataA ); |
|
2466 EUNIT_ASSERT_DESC( err == KErrNone, "Incorrect PublishContext return value!" ); |
|
2467 iCheckA = ETrue; |
|
2468 iWait->Start ( ); |
|
2469 |
|
2470 // Unsubscribe context |
|
2471 // Publish new context value, context indication should not happen |
|
2472 err = iClient->UnsubscribeContext ( *subscription ); |
|
2473 EUNIT_ASSERT_DESC( err == KErrNone, "Incorrect UnsubscribeContext return value!" ); |
|
2474 CleanupStack::PopAndDestroy ( subscription ); |
|
2475 |
|
2476 UpdateContextValueL ( *iContextA ); |
|
2477 err = iClient->PublishContext ( *iContextA, *iContextDataA ); |
|
2478 EUNIT_ASSERT_DESC( err == KErrNone, "Incorrect PublishContext return value!" ); |
|
2479 iCheckA = ETrue; |
|
2480 Wait ( KDelay ); |
|
2481 EUNIT_ASSERT_DESC( iCheckA, "Context should not have been indicated!" ); |
|
2482 } |
|
2483 |
|
2484 void MT_CFClient::MT_CCFClient_SubscribeContextData2L( ) |
|
2485 { |
|
2486 iCheckContextData = ETrue; |
|
2487 CCFContextSubscription* subscriptionA= NULL; |
|
2488 CCFContextSubscription* subscriptionB= NULL; |
|
2489 TInt err = KErrNone; |
|
2490 |
|
2491 // Define two contexts |
|
2492 // Subscribe the contexts with datas |
|
2493 // Publish new context values with datas |
|
2494 ConfigureContextL ( *iContextA ); |
|
2495 err = iClient->DefineContext ( iContextA->Source ( ), iContextA->Type ( ), |
|
2496 KPassSec ); |
|
2497 EUNIT_ASSERT_DESC( err == KErrNone, "Incorrect DefineContext return value!" ); |
|
2498 ConfigureContextL ( *iContextB ); |
|
2499 err = iClient->DefineContext ( iContextB->Source ( ), iContextB->Type ( ), |
|
2500 KPassSec ); |
|
2501 EUNIT_ASSERT_DESC( err == KErrNone, "Incorrect DefineContext return value!" ); |
|
2502 |
|
2503 subscriptionA = CCFContextSubscription::NewLC ( ); |
|
2504 subscriptionA->SetDataObjectEnabled ( ETrue ); |
|
2505 subscriptionA->SetContextSourceL ( iContextA->Source ( ) ); |
|
2506 subscriptionA->SetContextTypeL ( iContextA->Type ( ) ); |
|
2507 err = iClient->SubscribeContext ( *subscriptionA ); |
|
2508 EUNIT_ASSERT_DESC( err == KErrNone, "Incorrect SubscribeContext return value!" ); |
|
2509 CleanupStack::PopAndDestroy ( subscriptionA ); |
|
2510 subscriptionB = CCFContextSubscription::NewLC ( ); |
|
2511 subscriptionB->SetDataObjectEnabled ( ETrue ); |
|
2512 subscriptionB->SetContextSourceL ( iContextB->Source ( ) ); |
|
2513 subscriptionB->SetContextTypeL ( iContextB->Type ( ) ); |
|
2514 err = iClient->SubscribeContext ( *subscriptionB ); |
|
2515 EUNIT_ASSERT_DESC( err == KErrNone, "Incorrect SubscribeContext return value!" ); |
|
2516 CleanupStack::PopAndDestroy ( subscriptionB ); |
|
2517 |
|
2518 UpdateContextValueL ( *iContextA ); |
|
2519 err = iClient->PublishContext ( *iContextA, *iContextDataA ); |
|
2520 EUNIT_ASSERT_DESC( err == KErrNone, "Incorrect PublishContext return value!" ); |
|
2521 iCheckA = ETrue; |
|
2522 UpdateContextValueL ( *iContextB ); |
|
2523 err = iClient->PublishContext ( *iContextB, *iContextDataB ); |
|
2524 EUNIT_ASSERT_DESC( err == KErrNone, "Incorrect PublishContext return value!" ); |
|
2525 iCheckB = ETrue; |
|
2526 iWait->Start ( ); |
|
2527 } |
|
2528 |
|
2529 void MT_CFClient::MT_CCFClient_SubscribeContextData3L( ) |
|
2530 { |
|
2531 iCheckContextData = ETrue; |
|
2532 CCFContextSubscription* subscriptionA= NULL; |
|
2533 CCFContextSubscription* subscriptionB= NULL; |
|
2534 TInt err = KErrNone; |
|
2535 |
|
2536 // Define two contexts from different clients |
|
2537 // Subscribe the contexts with datas from different clients |
|
2538 // Publish new context values with datas from different clients |
|
2539 ConfigureContextL ( *iContextA ); |
|
2540 err = iClient->DefineContext ( iContextA->Source ( ), iContextA->Type ( ), |
|
2541 KPassSec ); |
|
2542 EUNIT_ASSERT_DESC( err == KErrNone, "Incorrect DefineContext return value!" ); |
|
2543 ConfigureContextL ( *iContextB ); |
|
2544 err = iAnotherClient->DefineContext ( iContextB->Source ( ), |
|
2545 iContextB->Type ( ), KPassSec ); |
|
2546 EUNIT_ASSERT_DESC( err == KErrNone, "Incorrect DefineContext return value!" ); |
|
2547 |
|
2548 subscriptionA = CCFContextSubscription::NewLC ( ); |
|
2549 subscriptionA->SetDataObjectEnabled ( ETrue ); |
|
2550 subscriptionA->SetContextSourceL ( iContextA->Source ( ) ); |
|
2551 subscriptionA->SetContextTypeL ( iContextA->Type ( ) ); |
|
2552 err = iClient->SubscribeContext ( *subscriptionA ); |
|
2553 EUNIT_ASSERT_DESC( err == KErrNone, "Incorrect SubscribeContext return value!" ); |
|
2554 CleanupStack::PopAndDestroy ( subscriptionA ); |
|
2555 subscriptionB = CCFContextSubscription::NewLC ( ); |
|
2556 subscriptionB->SetDataObjectEnabled ( ETrue ); |
|
2557 subscriptionB->SetContextSourceL ( iContextB->Source ( ) ); |
|
2558 subscriptionB->SetContextTypeL ( iContextB->Type ( ) ); |
|
2559 err = iAnotherClient->SubscribeContext ( *subscriptionB ); |
|
2560 EUNIT_ASSERT_DESC( err == KErrNone, "Incorrect SubscribeContext return value!" ); |
|
2561 CleanupStack::PopAndDestroy ( subscriptionB ); |
|
2562 |
|
2563 UpdateContextValueL ( *iContextA ); |
|
2564 err = iClient->PublishContext ( *iContextA, *iContextDataA ); |
|
2565 EUNIT_ASSERT_DESC( err == KErrNone, "Incorrect PublishContext return value!" ); |
|
2566 iCheckA = ETrue; |
|
2567 UpdateContextValueL ( *iContextB ); |
|
2568 err = iAnotherClient->PublishContext ( *iContextB, *iContextDataB ); |
|
2569 EUNIT_ASSERT_DESC( err == KErrNone, "Incorrect PublishContext return value!" ); |
|
2570 iCheckB = ETrue; |
|
2571 iWait->Start ( ); |
|
2572 } |
|
2573 |
|
2574 void MT_CFClient::MT_CCFClient_SubscribeContextData4L( ) |
|
2575 { |
|
2576 iCheckContextData = ETrue; |
|
2577 CCFContextSubscription* subscription= NULL; |
|
2578 TInt err = KErrNone; |
|
2579 |
|
2580 // Define a context |
|
2581 // Subscribe the context |
|
2582 // Publish new context value from context source plug-in |
|
2583 ConfigureContextL ( *iContextA ); |
|
2584 err = iClient->DefineContext ( iContextA->Source ( ), iContextA->Type ( ), |
|
2585 KPassSec ); |
|
2586 EUNIT_ASSERT_DESC( err == KErrNone, "Incorrect DefineContext return value!" ); |
|
2587 |
|
2588 subscription = CCFContextSubscription::NewLC ( ); |
|
2589 subscription->SetDataObjectEnabled ( ETrue ); |
|
2590 subscription->SetContextSourceL ( iContextA->Source ( ) ); |
|
2591 subscription->SetContextTypeL ( iContextA->Type ( ) ); |
|
2592 err = iClient->SubscribeContext ( *subscription ); |
|
2593 EUNIT_ASSERT_DESC( err == KErrNone, "Incorrect SubscribeContext return value!" ); |
|
2594 CleanupStack::PopAndDestroy ( subscription ); |
|
2595 |
|
2596 CCFContextObjectImpl* contextImpl = static_cast<CCFContextObjectImpl*>( iContextA ); |
|
2597 UpdateContextValueL ( *iContextA ); |
|
2598 HBufC8* buf = HBufC8::NewLC ( contextImpl->Size ( ) ); |
|
2599 TPtr8 bufPtr( buf->Des ( )); |
|
2600 RDesWriteStream stream( bufPtr); |
|
2601 stream.PushL ( ); |
|
2602 contextImpl->ExternalizeL ( stream ); |
|
2603 err = RProperty::Set ( KContextSourceTestCategory, KPublishContextKey, |
|
2604 bufPtr ); |
|
2605 EUNIT_ASSERT_DESC( err == KErrNone, "Failed to set property!" ); |
|
2606 CleanupStack::PopAndDestroy ( &stream ); |
|
2607 CleanupStack::PopAndDestroy ( buf ); |
|
2608 iCheckA = ETrue; |
|
2609 iWait->Start ( ); |
|
2610 } |
|
2611 |
|
2612 void MT_CFClient::MT_CCFClient_SubscribeContextDataCombinedL( ) |
|
2613 { |
|
2614 MT_CCFClient_SubscribeContextData1L ( ); |
|
2615 Wait ( 5000 ); |
|
2616 MT_CCFClient_SubscribeContextData2L ( ); |
|
2617 Wait ( 5000 ); |
|
2618 MT_CCFClient_SubscribeContextData3L ( ); |
|
2619 Wait ( 5000 ); |
|
2620 MT_CCFClient_SubscribeContextData4L ( ); |
|
2621 } |
|
2622 |
|
2623 void MT_CFClient::MT_CCFClient_UnsubscribeContext1L( ) |
|
2624 { |
|
2625 iCheckContextData = EFalse; |
|
2626 CCFContextSubscription* subscription= NULL; |
|
2627 TInt err = KErrNone; |
|
2628 |
|
2629 // Define a context |
|
2630 ConfigureContextL ( *iContextA ); |
|
2631 err = iClient->DefineContext ( iContextA->Source ( ), iContextA->Type ( ), |
|
2632 KPassSec ); |
|
2633 EUNIT_ASSERT_DESC( err == KErrNone, "Incorrect DefineContext return value!" ); |
|
2634 |
|
2635 // Subscribe context |
|
2636 subscription = CCFContextSubscription::NewLC ( ); |
|
2637 subscription->SetContextSourceL ( iContextA->Source ( ) ); |
|
2638 subscription->SetContextTypeL ( iContextA->Type ( ) ); |
|
2639 err = iClient->SubscribeContext ( *subscription ); |
|
2640 EUNIT_ASSERT_DESC( err == KErrNone, "Incorrect SubscribeContext return value!" ); |
|
2641 |
|
2642 // Publish context and wait for indication |
|
2643 iCheckA = ETrue; |
|
2644 UpdateContextValueL ( *iContextA ); |
|
2645 err = iClient->PublishContext ( *iContextA ); |
|
2646 EUNIT_ASSERT_DESC( err == KErrNone, "Incorrect PublishContext return value!" ); |
|
2647 if ( iCheckA ) |
|
2648 { |
|
2649 iWait->Start ( ); |
|
2650 } |
|
2651 |
|
2652 // Unsubscribe context |
|
2653 err = iClient->UnsubscribeContext ( *subscription ); |
|
2654 EUNIT_ASSERT_DESC( err == KErrNone, "Incorrect UnsubscribeContext return value!" ); |
|
2655 CleanupStack::PopAndDestroy ( subscription ); |
|
2656 |
|
2657 // Publish context, context indication should not happen |
|
2658 iCheckA = ETrue; |
|
2659 UpdateContextValueL ( *iContextA ); |
|
2660 err = iClient->PublishContext ( *iContextA ); |
|
2661 EUNIT_ASSERT_DESC( err == KErrNone, "Incorrect PublishContext return value!" ); |
|
2662 Wait ( KDelay ); |
|
2663 EUNIT_ASSERT_DESC( iCheckA, "Context should not have been indicated!" ); |
|
2664 iCheckA = EFalse; |
|
2665 } |
|
2666 |
|
2667 void MT_CFClient::MT_CCFClient_UnsubscribeContext2L( ) |
|
2668 { |
|
2669 CCFContextSubscription* subscription= NULL; |
|
2670 TInt err = KErrNone; |
|
2671 |
|
2672 // Define a context |
|
2673 ConfigureContextL ( *iContextA ); |
|
2674 err = iClient->DefineContext ( iContextA->Source ( ), iContextA->Type ( ), |
|
2675 KPassSec ); |
|
2676 EUNIT_ASSERT_DESC( err == KErrNone, "Incorrect DefineContext return value!" ); |
|
2677 |
|
2678 // Subscribe context |
|
2679 subscription = CCFContextSubscription::NewLC ( ); |
|
2680 subscription->SetContextSourceL ( iContextA->Source ( ) ); |
|
2681 subscription->SetContextTypeL ( iContextA->Type ( ) ); |
|
2682 err = iClient->SubscribeContext ( *subscription ); |
|
2683 EUNIT_ASSERT_DESC( err == KErrNone, "Incorrect SubscribeContext return value!" ); |
|
2684 CleanupStack::PopAndDestroy ( subscription ); |
|
2685 |
|
2686 // Publish context and wait for indication |
|
2687 UpdateContextValueL ( *iContextA ); |
|
2688 err = iClient->PublishContext ( *iContextA ); |
|
2689 EUNIT_ASSERT_DESC( err == KErrNone, "Incorrect PublishContext return value!" ); |
|
2690 iCheckA = ETrue; |
|
2691 iWait->Start ( ); |
|
2692 |
|
2693 // Delete client |
|
2694 delete iClient; |
|
2695 iClient = NULL; |
|
2696 iClient = CCFClient::NewL ( *this ); |
|
2697 |
|
2698 // Publish context, context indication should not happen |
|
2699 UpdateContextValueL ( *iContextA ); |
|
2700 err = iClient->PublishContext ( *iContextA ); |
|
2701 EUNIT_ASSERT_DESC( err == KErrNone, "Incorrect PublishContext return value!" ); |
|
2702 iCheckA = ETrue; |
|
2703 Wait ( KDelay ); |
|
2704 EUNIT_ASSERT_DESC( iCheckA, "Context should not have been indicated!" ); |
|
2705 iCheckA = EFalse; |
|
2706 |
|
2707 // Define a context |
|
2708 ConfigureContextL ( *iContextA ); |
|
2709 err = iClient->DefineContext ( iContextA->Source ( ), iContextA->Type ( ), |
|
2710 KPassSec ); |
|
2711 EUNIT_ASSERT_DESC( err == KErrNone, "Incorrect DefineContext return value!" ); |
|
2712 |
|
2713 // Subscribe context |
|
2714 subscription = CCFContextSubscription::NewLC ( ); |
|
2715 subscription->SetContextSourceL ( iContextA->Source ( ) ); |
|
2716 subscription->SetContextTypeL ( iContextA->Type ( ) ); |
|
2717 err = iClient->SubscribeContext ( *subscription ); |
|
2718 EUNIT_ASSERT_DESC( err == KErrNone, "Incorrect SubscribeContext return value!" ); |
|
2719 CleanupStack::PopAndDestroy ( subscription ); |
|
2720 |
|
2721 // Publish context and wait for indication |
|
2722 UpdateContextValueL ( *iContextA ); |
|
2723 err = iClient->PublishContext ( *iContextA ); |
|
2724 EUNIT_ASSERT_DESC( err == KErrNone, "Incorrect PublishContext return value!" ); |
|
2725 iCheckA = ETrue; |
|
2726 iWait->Start ( ); |
|
2727 } |
|
2728 |
|
2729 void MT_CFClient::MT_CCFClient_UnsubscribeContextCombinedL( ) |
|
2730 { |
|
2731 MT_CCFClient_UnsubscribeContext1L ( ); |
|
2732 Wait ( 5000 ); |
|
2733 MT_CCFClient_UnsubscribeContext2L ( ); |
|
2734 } |
|
2735 |
|
2736 void MT_CFClient::MT_CCFClient_RequestContext1L( ) |
|
2737 { |
|
2738 CCFContextQuery* query= NULL; |
|
2739 TInt err = KErrNone; |
|
2740 |
|
2741 // Define a context |
|
2742 ConfigureContextL ( *iContextA ); |
|
2743 err = iClient->DefineContext ( iContextA->Source ( ), iContextA->Type ( ), |
|
2744 KPassSec ); |
|
2745 EUNIT_ASSERT_DESC( err == KErrNone, "Incorrect DefineContext return value!" ); |
|
2746 |
|
2747 // Publish new context value |
|
2748 err = iClient->PublishContext ( *iContextA ); |
|
2749 EUNIT_ASSERT_DESC( err == KErrNone, "Incorrect PublishContext return value!" ); |
|
2750 |
|
2751 // Configure query to match published context and request context |
|
2752 query = CCFContextQuery::NewLC ( iContextA->Source ( ), iContextA->Type ( ) ); |
|
2753 RContextObjectArray array; |
|
2754 CleanupResetAndDestroyPushL ( array ); |
|
2755 err = iClient->RequestContext ( *query, array ); |
|
2756 EUNIT_ASSERT_DESC( err == KErrNone, "Incorrect RequestContext return value!" ); |
|
2757 EUNIT_ASSERT_DESC( array.Count() == 1, "Incorrect result array count!" ); |
|
2758 EUNIT_ASSERT_DESC( array[0]->Source() == iContextA->Source(), "Incorrect context source!" ); |
|
2759 EUNIT_ASSERT_DESC( array[0]->Type() == iContextA->Type(), "Incorrect context type!" ); |
|
2760 |
|
2761 // Request same context again |
|
2762 array.ResetAndDestroy ( ); |
|
2763 err = iClient->RequestContext ( *query, array ); |
|
2764 EUNIT_ASSERT_DESC( err == KErrNone, "Incorrect RequestContext return value!" ); |
|
2765 EUNIT_ASSERT_DESC( array.Count() == 1, "Incorrect result array count!" ); |
|
2766 EUNIT_ASSERT_DESC( array[0]->Source() == iContextA->Source(), "Incorrect context source!" ); |
|
2767 EUNIT_ASSERT_DESC( array[0]->Type() == iContextA->Type(), "Incorrect context type!" ); |
|
2768 |
|
2769 // Define a context |
|
2770 ConfigureContextL ( *iContextA ); |
|
2771 err = iClient->DefineContext ( iContextA->Source ( ), iContextA->Type ( ), |
|
2772 KPassSec ); |
|
2773 EUNIT_ASSERT_DESC( err == KErrNone, "Incorrect DefineContext return value!" ); |
|
2774 |
|
2775 // Publish new context value |
|
2776 err = iClient->PublishContext ( *iContextA ); |
|
2777 EUNIT_ASSERT_DESC( err == KErrNone, "Incorrect PublishContext return value!" ); |
|
2778 |
|
2779 // Configure query to match published context and request context |
|
2780 query->SetSourceL ( iContextA->Source ( ) ); |
|
2781 query->SetTypeL ( iContextA->Type ( ) ); |
|
2782 array.ResetAndDestroy ( ); |
|
2783 err = iClient->RequestContext ( *query, array ); |
|
2784 EUNIT_ASSERT_DESC( err == KErrNone, "Incorrect RequestContext return value!" ); |
|
2785 EUNIT_ASSERT_DESC( array.Count() == 1, "Incorrect result array count!" ); |
|
2786 EUNIT_ASSERT_DESC( array[0]->Source() == iContextA->Source(), "Incorrect context source!" ); |
|
2787 EUNIT_ASSERT_DESC( array[0]->Type() == iContextA->Type(), "Incorrect context type!" ); |
|
2788 |
|
2789 // Clean up |
|
2790 CleanupStack::PopAndDestroy ( &array ); |
|
2791 CleanupStack::PopAndDestroy ( query ); |
|
2792 } |
|
2793 |
|
2794 void MT_CFClient::MT_CCFClient_RequestContext2L( ) |
|
2795 { |
|
2796 CCFContextQuery* query= NULL; |
|
2797 TInt err = KErrNone; |
|
2798 |
|
2799 // Define a context where we have no access |
|
2800 ConfigureContextL ( *iContextA ); |
|
2801 err = iClient->DefineContext ( iContextA->Source ( ), iContextA->Type ( ), |
|
2802 KFailSec ); |
|
2803 EUNIT_ASSERT_DESC( err == KErrNone, "Incorrect DefineContext return value!" ); |
|
2804 |
|
2805 // Configure query to match the defined context and request context |
|
2806 query = CCFContextQuery::NewLC ( iContextA->Source ( ), iContextA->Type ( ) ); |
|
2807 RContextObjectArray array; |
|
2808 CleanupResetAndDestroyPushL ( array ); |
|
2809 err = iClient->RequestContext ( *query, array ); |
|
2810 EUNIT_ASSERT_DESC( err == KErrNone, "Incorrect RequestContext return value!" ); |
|
2811 EUNIT_ASSERT_DESC( array.Count() == 0, "Incorrect result array count!" ); |
|
2812 |
|
2813 // Define a context where we have no access |
|
2814 ConfigureContextL ( *iContextA ); |
|
2815 err = iClient->DefineContext ( iContextA->Source ( ), iContextA->Type ( ), |
|
2816 KFailSec ); |
|
2817 EUNIT_ASSERT_DESC( err == KErrNone, "Incorrect DefineContext return value!" ); |
|
2818 |
|
2819 // Configure query to match the defined context and request context |
|
2820 query->SetSourceL ( iContextA->Source ( ) ); |
|
2821 query->SetTypeL ( iContextA->Type ( ) ); |
|
2822 array.ResetAndDestroy ( ); |
|
2823 err = iClient->RequestContext ( *query, array ); |
|
2824 EUNIT_ASSERT_DESC( err == KErrNone, "Incorrect RequestContext return value!" ); |
|
2825 EUNIT_ASSERT_DESC( array.Count() == 0, "Incorrect result array count!" ); |
|
2826 |
|
2827 // Clean up |
|
2828 CleanupStack::PopAndDestroy ( &array ); |
|
2829 CleanupStack::PopAndDestroy ( query ); |
|
2830 } |
|
2831 |
|
2832 void MT_CFClient::MT_CCFClient_RequestContext3L( ) |
|
2833 { |
|
2834 CCFContextQuery* query= NULL; |
|
2835 TInt err = KErrNone; |
|
2836 |
|
2837 // Define a contextA |
|
2838 ConfigureContextL ( *iContextA ); |
|
2839 err = iClient->DefineContext ( iContextA->Source ( ), iContextA->Type ( ), |
|
2840 KPassSec ); |
|
2841 EUNIT_ASSERT_DESC( err == KErrNone, "Incorrect DefineContext return value!" ); |
|
2842 |
|
2843 // Publish new contextA value |
|
2844 err = iClient->PublishContext ( *iContextA ); |
|
2845 EUNIT_ASSERT_DESC( err == KErrNone, "Incorrect PublishContext return value!" ); |
|
2846 |
|
2847 // Define a contextB |
|
2848 iContextB->CopyL ( *iContextA ); |
|
2849 UpdateContextTypeL ( *iContextB ); |
|
2850 UpdateContextValueL ( *iContextB ); |
|
2851 err = iClient->DefineContext ( iContextB->Source ( ), iContextB->Type ( ), |
|
2852 KPassSec ); |
|
2853 EUNIT_ASSERT_DESC( err == KErrNone, "Incorrect DefineContext return value!" ); |
|
2854 |
|
2855 // Publish new contextB value |
|
2856 err = iClient->PublishContext ( *iContextB ); |
|
2857 EUNIT_ASSERT_DESC( err == KErrNone, "Incorrect PublishContext return value!" ); |
|
2858 |
|
2859 // Define a contextC |
|
2860 iContextC->CopyL ( *iContextA ); |
|
2861 UpdateContextTypeL ( *iContextC ); |
|
2862 err = iClient->DefineContext ( iContextC->Source ( ), iContextC->Type ( ), |
|
2863 KFailSec ); |
|
2864 EUNIT_ASSERT_DESC( err == KErrNone, "Incorrect DefineContext return value!" ); |
|
2865 |
|
2866 // Configure query to match the defined contexts and request contexts |
|
2867 query = CCFContextQuery::NewLC ( iContextA->Source ( ), |
|
2868 KContextTypeFormatWild ); |
|
2869 query->SetSubTypeMatch ( ETrue ); |
|
2870 RContextObjectArray array; |
|
2871 CleanupResetAndDestroyPushL ( array ); |
|
2872 err = iClient->RequestContext ( *query, array ); |
|
2873 TInt count = array.Count ( ); |
|
2874 EUNIT_ASSERT_DESC( err == KErrNone, "Incorrect RequestContext return value!" ); |
|
2875 EUNIT_ASSERT_DESC( count == 2, "Incorrect result array count!" ); |
|
2876 CCFContextObject* context= NULL; |
|
2877 for (TInt i = 0; i < count; i++ ) |
|
2878 { |
|
2879 context = array[i]; |
|
2880 EUNIT_ASSERT_DESC( context->Source() == iContextA->Source() || |
|
2881 context->Source() == iContextB->Source(), |
|
2882 "Incorrect context source!" ); |
|
2883 EUNIT_ASSERT_DESC( context->Type() == iContextA->Type() || |
|
2884 context->Type() == iContextB->Type(), |
|
2885 "Incorrect context type!" ); |
|
2886 EUNIT_ASSERT_DESC( context->Type() != iContextC->Type(), |
|
2887 "Incorrect context type!" ); |
|
2888 } |
|
2889 |
|
2890 // Clean up |
|
2891 CleanupStack::PopAndDestroy ( &array ); |
|
2892 CleanupStack::PopAndDestroy ( query ); |
|
2893 } |
|
2894 |
|
2895 void MT_CFClient::MT_CCFClient_RequestContextSetL( ) |
|
2896 { |
|
2897 CCFContextQuery* query= NULL; |
|
2898 TInt err = KErrNone; |
|
2899 |
|
2900 // Define a contextA |
|
2901 ConfigureContextL ( *iContextA ); |
|
2902 err = iClient->DefineContext ( iContextA->Source ( ), iContextA->Type ( ), |
|
2903 KPassSec ); |
|
2904 EUNIT_ASSERT_DESC( err == KErrNone, "Incorrect DefineContext return value!" ); |
|
2905 |
|
2906 // Publish new contextA value |
|
2907 err = iClient->PublishContext ( *iContextA ); |
|
2908 EUNIT_ASSERT_DESC( err == KErrNone, "Incorrect PublishContext return value!" ); |
|
2909 |
|
2910 // Define a contextB |
|
2911 iContextB->CopyL ( *iContextA ); |
|
2912 UpdateContextTypeL ( *iContextB ); |
|
2913 UpdateContextValueL ( *iContextB ); |
|
2914 err = iClient->DefineContext ( iContextB->Source ( ), iContextB->Type ( ), |
|
2915 KPassSec ); |
|
2916 EUNIT_ASSERT_DESC( err == KErrNone, "Incorrect DefineContext return value!" ); |
|
2917 |
|
2918 // Publish new contextB value |
|
2919 err = iClient->PublishContext ( *iContextB ); |
|
2920 EUNIT_ASSERT_DESC( err == KErrNone, "Incorrect PublishContext return value!" ); |
|
2921 |
|
2922 // Define a contextC |
|
2923 iContextC->CopyL ( *iContextA ); |
|
2924 UpdateContextTypeL ( *iContextC ); |
|
2925 err = iClient->DefineContext ( iContextC->Source ( ), iContextC->Type ( ), |
|
2926 KFailSec ); |
|
2927 EUNIT_ASSERT_DESC( err == KErrNone, "Incorrect DefineContext return value!" ); |
|
2928 |
|
2929 // Configure three queries to match the defined contexts and request contexts |
|
2930 RContextQueryArray queryArray; |
|
2931 CleanupResetAndDestroyPushL ( queryArray ); |
|
2932 query = CCFContextQuery::NewLC ( iContextA->Source ( ), iContextA->Type ( ) ); |
|
2933 queryArray.AppendL ( query ); |
|
2934 CleanupStack::Pop ( query ); |
|
2935 |
|
2936 query = CCFContextQuery::NewLC ( iContextB->Source ( ), iContextB->Type ( ) ); |
|
2937 queryArray.AppendL ( query ); |
|
2938 CleanupStack::Pop ( query ); |
|
2939 |
|
2940 query = CCFContextQuery::NewLC ( iContextC->Source ( ), iContextC->Type ( ) ); |
|
2941 queryArray.AppendL ( query ); |
|
2942 CleanupStack::Pop ( query ); |
|
2943 |
|
2944 // Request context and check results |
|
2945 RContextObjectArray resultArray; |
|
2946 CleanupResetAndDestroyPushL ( resultArray ); |
|
2947 err = iClient->RequestContextSet ( queryArray, resultArray ); |
|
2948 TInt count = resultArray.Count ( ); |
|
2949 EUNIT_ASSERT_DESC( err == KErrNone, "Incorrect RequestContext return value!" ); |
|
2950 EUNIT_ASSERT_DESC( count == 2, "Incorrect result array count!" ); |
|
2951 CCFContextObject* context= NULL; |
|
2952 for (TInt i = 0; i < count; i++ ) |
|
2953 { |
|
2954 context = resultArray[i]; |
|
2955 EUNIT_ASSERT_DESC( context->Source() == iContextA->Source() || |
|
2956 context->Source() == iContextB->Source(), |
|
2957 "Incorrect context source!" ); |
|
2958 EUNIT_ASSERT_DESC( context->Type() == iContextA->Type() || |
|
2959 context->Type() == iContextB->Type(), |
|
2960 "Incorrect context type!" ); |
|
2961 EUNIT_ASSERT_DESC( context->Type() != iContextC->Type(), |
|
2962 "Incorrect context type!" ); |
|
2963 } |
|
2964 |
|
2965 // Request same contexts again and check results |
|
2966 resultArray.ResetAndDestroy ( ); |
|
2967 err = iClient->RequestContextSet ( queryArray, resultArray ); |
|
2968 count = resultArray.Count ( ); |
|
2969 EUNIT_ASSERT_DESC( err == KErrNone, "Incorrect RequestContext return value!" ); |
|
2970 EUNIT_ASSERT_DESC( count == 2, "Incorrect result array count!" ); |
|
2971 context = NULL; |
|
2972 for (TInt i = 0; i < count; i++ ) |
|
2973 { |
|
2974 context = resultArray[i]; |
|
2975 EUNIT_ASSERT_DESC( context->Source() == iContextA->Source() || |
|
2976 context->Source() == iContextB->Source(), |
|
2977 "Incorrect context source!" ); |
|
2978 EUNIT_ASSERT_DESC( context->Type() == iContextA->Type() || |
|
2979 context->Type() == iContextB->Type(), |
|
2980 "Incorrect context type!" ); |
|
2981 EUNIT_ASSERT_DESC( context->Type() != iContextC->Type(), |
|
2982 "Incorrect context type!" ); |
|
2983 } |
|
2984 |
|
2985 // Clean up |
|
2986 CleanupStack::PopAndDestroy ( &resultArray ); |
|
2987 CleanupStack::PopAndDestroy ( &queryArray ); |
|
2988 } |
|
2989 |
|
2990 void MT_CFClient::MT_CCFClient_RequestContextCombinedL( ) |
|
2991 { |
|
2992 MT_CCFClient_RequestContext1L ( ); |
|
2993 MT_CCFClient_RequestContext2L ( ); |
|
2994 MT_CCFClient_RequestContext3L ( ); |
|
2995 MT_CCFClient_RequestContextSetL ( ); |
|
2996 } |
|
2997 |
|
2998 void MT_CFClient::MT_CCFClient_DefineActionL( ) |
|
2999 { |
|
3000 TInt err = KErrNone; |
|
3001 HBufC* actionId= NULL; |
|
3002 |
|
3003 // Define action with access |
|
3004 actionId = ConfigureActionIdLC ( ); |
|
3005 err = iClient->DefineAction ( *actionId, KPassSec ); |
|
3006 EUNIT_ASSERT_DESC( err == KErrNone, "Incorrect DefineAction return value!" ); |
|
3007 CleanupStack::PopAndDestroy ( actionId ); |
|
3008 |
|
3009 // Define another action with access |
|
3010 actionId = ConfigureActionIdLC ( ); |
|
3011 err = iClient->DefineAction ( *actionId, KPassSec ); |
|
3012 EUNIT_ASSERT_DESC( err == KErrNone, "Incorrect DefineAction return value!" ); |
|
3013 |
|
3014 // Try to define already defined action |
|
3015 err = iClient->DefineAction ( *actionId, KPassSec ); |
|
3016 EUNIT_ASSERT_DESC( err == KErrAlreadyExists, "Incorrect DefineAction return value!" ); |
|
3017 |
|
3018 // Delete client, re-instantiate and define the same action than above |
|
3019 delete iClient; |
|
3020 iClient = NULL; |
|
3021 iClient = CCFClient::NewL( *this ); |
|
3022 err = iClient->DefineAction ( *actionId, KPassSec ); |
|
3023 EUNIT_ASSERT_DESC( err == KErrNone, "Incorrect DefineAction return value!" ); |
|
3024 CleanupStack::PopAndDestroy ( actionId ); |
|
3025 |
|
3026 // Define action with no access |
|
3027 Wait ( KConfigDelay ); |
|
3028 actionId = ConfigureActionIdLC ( ); |
|
3029 err = iClient->DefineAction ( *actionId, KFailSec ); |
|
3030 EUNIT_ASSERT_DESC( err == KErrNone, "Incorrect DefineAction return value!" ); |
|
3031 CleanupStack::PopAndDestroy ( actionId ); |
|
3032 |
|
3033 // Try to define reserved action ids |
|
3034 err = iClient->DefineAction ( KReservedActionPublishContext, KPassSec ); |
|
3035 EUNIT_ASSERT_DESC( err == KErrAlreadyExists, "Incorrect DefineAction return value!" ); |
|
3036 err = iClient->DefineAction ( KReservedActionPublishContext2, KPassSec ); |
|
3037 EUNIT_ASSERT_DESC( err == KErrAlreadyExists, "Incorrect DefineAction return value!" ); |
|
3038 err = iClient->DefineAction ( KReservedActionSourceCommand, KPassSec ); |
|
3039 EUNIT_ASSERT_DESC( err == KErrAlreadyExists, "Incorrect DefineAction return value!" ); |
|
3040 err = iClient->DefineAction ( KReservedActionSourceCommand2, KPassSec ); |
|
3041 EUNIT_ASSERT_DESC( err == KErrAlreadyExists, "Incorrect DefineAction return value!" ); |
|
3042 } |
|
3043 |
|
3044 void MT_CFClient::MT_CCFClient_SubscribeAction1L( ) |
|
3045 { |
|
3046 TInt err = KErrNone; |
|
3047 HBufC* actionId= NULL; |
|
3048 CCFActionSubscription* subscription = CCFActionSubscription::NewLC ( ); |
|
3049 |
|
3050 // Define action with access and subscribe it |
|
3051 actionId = ConfigureActionIdLC ( ); |
|
3052 err = iClient->DefineAction ( *actionId, KPassSec ); |
|
3053 EUNIT_ASSERT_DESC( err == KErrNone, "Incorrect DefineAction return value!" ); |
|
3054 |
|
3055 subscription->SetActionIdentifierL ( *actionId ); |
|
3056 err = iClient->SubscribeAction ( *subscription ); |
|
3057 EUNIT_ASSERT_DESC( err == KErrNone, "Incorrect SubscribeAction return value!" ); |
|
3058 |
|
3059 // Delete client, re-define action and subscribe it |
|
3060 delete iClient; |
|
3061 iClient = NULL; |
|
3062 iClient = CCFClient::NewL( *this ); |
|
3063 |
|
3064 err = iClient->DefineAction ( *actionId, KPassSec ); |
|
3065 EUNIT_ASSERT_DESC( err == KErrNone, "Incorrect DefineAction return value!" ); |
|
3066 |
|
3067 subscription->SetActionIdentifierL ( *actionId ); |
|
3068 err = iClient->SubscribeAction ( *subscription ); |
|
3069 EUNIT_ASSERT_DESC( err == KErrNone, "Incorrect SubscribeAction return value!" ); |
|
3070 CleanupStack::PopAndDestroy ( actionId ); |
|
3071 |
|
3072 // Define action with no access and subscribe it |
|
3073 Wait ( KConfigDelay ); |
|
3074 actionId = ConfigureActionIdLC ( ); |
|
3075 err = iClient->DefineAction ( *actionId, KFailSec ); |
|
3076 EUNIT_ASSERT_DESC( err == KErrNone, "Incorrect DefineAction return value!" ); |
|
3077 |
|
3078 subscription->SetActionIdentifierL ( *actionId ); |
|
3079 err = iClient->SubscribeAction ( *subscription ); |
|
3080 EUNIT_ASSERT_DESC( err == KErrAccessDenied, "Incorrect SubscribeAction return value!" ); |
|
3081 CleanupStack::PopAndDestroy ( actionId ); |
|
3082 |
|
3083 // Try to subscribe an action which has not been defined |
|
3084 Wait ( KConfigDelay ); |
|
3085 actionId = ConfigureActionIdLC ( ); |
|
3086 subscription->SetActionIdentifierL ( *actionId ); |
|
3087 err = iClient->SubscribeAction ( *subscription ); |
|
3088 EUNIT_ASSERT_DESC( err == KErrNotFound, "Incorrect SubscribeAction return value!" ); |
|
3089 CleanupStack::PopAndDestroy ( actionId ); |
|
3090 |
|
3091 // Clean up |
|
3092 CleanupStack::PopAndDestroy ( subscription ); |
|
3093 } |
|
3094 |
|
3095 void MT_CFClient::MT_CCFClient_SubscribeAction2L( ) |
|
3096 { |
|
3097 TInt err = KErrNone; |
|
3098 CCFActionSubscription* subscription = CCFActionSubscription::NewLC ( ); |
|
3099 CCFContextObject* context = CCFContextObject::NewLC ( ); |
|
3100 |
|
3101 // Run following set twice to get regression |
|
3102 static const TInt KCount = 2; |
|
3103 for (TInt i = 0; i < KCount; i++ ) |
|
3104 { |
|
3105 // Define actions used in test-cfclient.rul |
|
3106 iClient->DefineAction ( KActionA, KPassSec ); |
|
3107 iClient->DefineAction ( KActionB, KPassSec ); |
|
3108 |
|
3109 // Define contexts used in test-cfclient.rul |
|
3110 iClient->DefineContext ( KContextSourceA, KContextTypeA, KPassSec ); |
|
3111 |
|
3112 // Subscribe both actions |
|
3113 subscription->SetActionIdentifierL ( KActionA ); |
|
3114 err = iClient->SubscribeAction ( *subscription ); |
|
3115 EUNIT_ASSERT_DESC( err == KErrNone, "Incorrect SubscribeAction return value!" ); |
|
3116 |
|
3117 subscription->SetActionIdentifierL ( KActionB ); |
|
3118 err = iClient->SubscribeAction ( *subscription ); |
|
3119 EUNIT_ASSERT_DESC( err == KErrNone, "Incorrect SubscribeAction return value!" ); |
|
3120 |
|
3121 // Publish context [SourceA: TypeA: ValueA] and wait for action indication |
|
3122 context->SetSourceL ( KContextSourceA ); |
|
3123 context->SetTypeL ( KContextTypeA ); |
|
3124 context->SetValueL ( KContextValueA ); |
|
3125 err = iClient->PublishContext ( *context ); |
|
3126 EUNIT_ASSERT_DESC( err == KErrNone, "Incorrect PublishContext return value!" ); |
|
3127 iCheckA = ETrue; |
|
3128 iWait->Start ( ); |
|
3129 |
|
3130 // Publish context [SourceA: TypeA: ValueB] and wait for action indications |
|
3131 context->SetSourceL ( KContextSourceA ); |
|
3132 context->SetTypeL ( KContextTypeA ); |
|
3133 context->SetValueL ( KContextValueB ); |
|
3134 err = iClient->PublishContext ( *context ); |
|
3135 EUNIT_ASSERT_DESC( err == KErrNone, "Incorrect PublishContext return value!" ); |
|
3136 iCheckA = ETrue; |
|
3137 iCheckB = ETrue; |
|
3138 iWait->Start ( ); |
|
3139 |
|
3140 // Publish context [SourceA: TypeA: ValueA] and wait for action indication |
|
3141 context->SetSourceL ( KContextSourceA ); |
|
3142 context->SetTypeL ( KContextTypeA ); |
|
3143 context->SetValueL ( KContextValueA ); |
|
3144 err = iClient->PublishContext ( *context ); |
|
3145 EUNIT_ASSERT_DESC( err == KErrNone, "Incorrect PublishContext return value!" ); |
|
3146 iCheckA = ETrue; |
|
3147 iWait->Start ( ); |
|
3148 |
|
3149 // Publish context [SourceA: TypeA: ValueB] and wait for action indications |
|
3150 context->SetSourceL ( KContextSourceA ); |
|
3151 context->SetTypeL ( KContextTypeA ); |
|
3152 context->SetValueL ( KContextValueB ); |
|
3153 err = iClient->PublishContext ( *context ); |
|
3154 EUNIT_ASSERT_DESC( err == KErrNone, "Incorrect PublishContext return value!" ); |
|
3155 iCheckA = ETrue; |
|
3156 iCheckB = ETrue; |
|
3157 iWait->Start ( ); |
|
3158 |
|
3159 // Publish context [SourceA: TypeA: ValueA] and wait for action indication |
|
3160 context->SetSourceL ( KContextSourceA ); |
|
3161 context->SetTypeL ( KContextTypeA ); |
|
3162 context->SetValueL ( KContextValueA ); |
|
3163 err = iClient->PublishContext ( *context ); |
|
3164 EUNIT_ASSERT_DESC( err == KErrNone, "Incorrect PublishContext return value!" ); |
|
3165 iCheckA = ETrue; |
|
3166 iDeleteClient = ETrue; |
|
3167 iWait->Start ( ); |
|
3168 EUNIT_ASSERT_DESC( !iClient, "Client instance not deleted!" ); |
|
3169 iClient = CCFClient::NewL ( *this ); |
|
3170 } |
|
3171 |
|
3172 // Clean up |
|
3173 CleanupStack::PopAndDestroy ( context ); |
|
3174 CleanupStack::PopAndDestroy ( subscription ); |
|
3175 } |
|
3176 |
|
3177 void MT_CFClient::MT_CCFClient_SubscribeAction3L( ) |
|
3178 { |
|
3179 // x. Preconditions |
|
3180 //-------------------------------------------------------------------------- |
|
3181 TInt err = KErrNone; |
|
3182 CCFActionSubscription* subscription = CCFActionSubscription::NewLC( ); |
|
3183 CCFContextObject* context = CCFContextObject::NewLC( ); |
|
3184 |
|
3185 // Define contexts used in test-cfclient.rul |
|
3186 iClient->DefineContext( KContextSourceA, KContextTypeA, KPassSec ); |
|
3187 |
|
3188 // Set context to "incorrect" state |
|
3189 context->SetSourceL( KContextSourceA ); |
|
3190 context->SetTypeL( KContextTypeA ); |
|
3191 context->SetValueL( KContextValueB ); |
|
3192 err = iClient->PublishContext ( *context ); |
|
3193 EUNIT_ASSERT_DESC( err == KErrNone, "Publish context failed" ); |
|
3194 |
|
3195 // x. Define action a and subscribe it, delete client and publish context |
|
3196 //-------------------------------------------------------------------------- |
|
3197 err = iClient->DefineAction ( KActionA, KPassSec ); |
|
3198 EUNIT_ASSERT_DESC( err == KErrNone, "Define action failed" ); |
|
3199 |
|
3200 subscription->SetActionIdentifierL( KActionA ); |
|
3201 err = iClient->SubscribeAction( *subscription ); |
|
3202 EUNIT_ASSERT_DESC( err == KErrNone, "Subscribe action failed" ); |
|
3203 |
|
3204 // Check that the action is indicatated |
|
3205 context->SetSourceL( KContextSourceA ); |
|
3206 context->SetTypeL( KContextTypeA ); |
|
3207 context->SetValueL( KContextValueA ); |
|
3208 err = iClient->PublishContext ( *context ); |
|
3209 EUNIT_ASSERT_DESC( err == KErrNone, "Publish context failed" ); |
|
3210 iCheckA = ETrue; |
|
3211 iWait->Start(); |
|
3212 |
|
3213 // Reset context value |
|
3214 context->SetSourceL( KContextSourceA ); |
|
3215 context->SetTypeL( KContextTypeA ); |
|
3216 context->SetValueL( KContextValueB ); |
|
3217 err = iClient->PublishContext ( *context ); |
|
3218 EUNIT_ASSERT_DESC( err == KErrNone, "Publish context failed" ); |
|
3219 |
|
3220 // Delete client and publish context |
|
3221 delete iClient; |
|
3222 iClient = NULL; |
|
3223 iClient = CCFClient::NewL( *this ); |
|
3224 context->SetSourceL( KContextSourceA ); |
|
3225 context->SetTypeL( KContextTypeA ); |
|
3226 context->SetValueL( KContextValueA ); |
|
3227 err = iClient->PublishContext ( *context ); |
|
3228 EUNIT_ASSERT_DESC( err == KErrNone, "Publish context failed" ); |
|
3229 iCheckA = ETrue; |
|
3230 Wait( KSecond ); |
|
3231 EUNIT_ASSERT_DESC( iCheckA, "Something went terribly wrong" ); |
|
3232 |
|
3233 // Reset context value |
|
3234 context->SetSourceL( KContextSourceA ); |
|
3235 context->SetTypeL( KContextTypeA ); |
|
3236 context->SetValueL( KContextValueB ); |
|
3237 err = iClient->PublishContext ( *context ); |
|
3238 EUNIT_ASSERT_DESC( err == KErrNone, "Publish context failed" ); |
|
3239 |
|
3240 // x. Re-define action a and subscribe it |
|
3241 //-------------------------------------------------------------------------- |
|
3242 err = iClient->DefineAction ( KActionA, KPassSec ); |
|
3243 EUNIT_ASSERT_DESC( err == KErrNone, "Define action failed" ); |
|
3244 |
|
3245 subscription->SetActionIdentifierL( KActionA ); |
|
3246 err = iClient->SubscribeAction( *subscription ); |
|
3247 EUNIT_ASSERT_DESC( err == KErrNone, "Subscribe action failed" ); |
|
3248 |
|
3249 // Check that the action is indicatated |
|
3250 context->SetSourceL( KContextSourceA ); |
|
3251 context->SetTypeL( KContextTypeA ); |
|
3252 context->SetValueL( KContextValueA ); |
|
3253 err = iClient->PublishContext ( *context ); |
|
3254 EUNIT_ASSERT_DESC( err == KErrNone, "Publish context failed" ); |
|
3255 iCheckA = ETrue; |
|
3256 iWait->Start(); |
|
3257 |
|
3258 // x. Clean up |
|
3259 //-------------------------------------------------------------------------- |
|
3260 CleanupStack::PopAndDestroy( context ); |
|
3261 CleanupStack::PopAndDestroy( subscription ); |
|
3262 } |
|
3263 |
|
3264 void MT_CFClient::MT_CCFClient_SubscribeAction4L( ) |
|
3265 { |
|
3266 // x. Pre-conditions |
|
3267 // ------------------------------------------------------------------------- |
|
3268 TInt err = KErrNone; |
|
3269 CCFActionSubscription* subscription = CCFActionSubscription::NewLC( ); |
|
3270 CCFContextObject* context = CCFContextObject::NewLC( ); |
|
3271 |
|
3272 // Define contexts used in test-cfclient.rul |
|
3273 iClient->DefineContext( KContextSourceA, KContextTypeA, KPassSec ); |
|
3274 |
|
3275 // Set context to "incorrect" state |
|
3276 context->SetSourceL( KContextSourceA ); |
|
3277 context->SetTypeL( KContextTypeA ); |
|
3278 context->SetValueL( KContextValueB ); |
|
3279 err = iClient->PublishContext ( *context ); |
|
3280 EUNIT_ASSERT_DESC( err == KErrNone, "Publish context failed" ); |
|
3281 |
|
3282 // x. Define action |
|
3283 // ------------------------------------------------------------------------- |
|
3284 err = iClient->DefineAction ( KActionA, KPassSec ); |
|
3285 EUNIT_ASSERT_DESC( err == KErrNone, "Define action failed" ); |
|
3286 |
|
3287 // x. Delete client and re-initialize |
|
3288 // ------------------------------------------------------------------------- |
|
3289 delete iClient; |
|
3290 iClient = NULL; |
|
3291 iClient = CCFClient::NewL( *this ); |
|
3292 |
|
3293 // x. Subscribe action |
|
3294 // ------------------------------------------------------------------------- |
|
3295 subscription->SetActionIdentifierL( KActionA ); |
|
3296 err = iClient->SubscribeAction( *subscription ); |
|
3297 EUNIT_ASSERT_DESC( err == KErrNone, "Subscribe action failed" ); |
|
3298 |
|
3299 // x. Publish context and wait for action indication |
|
3300 // ------------------------------------------------------------------------- |
|
3301 context->SetSourceL( KContextSourceA ); |
|
3302 context->SetTypeL( KContextTypeA ); |
|
3303 context->SetValueL( KContextValueA ); |
|
3304 err = iClient->PublishContext ( *context ); |
|
3305 EUNIT_ASSERT_DESC( err == KErrNone, "Publish context failed" ); |
|
3306 |
|
3307 // Wait for action indication |
|
3308 iCheckA = ETrue; |
|
3309 iWait->Start(); |
|
3310 |
|
3311 // x. Clean up |
|
3312 // ------------------------------------------------------------------------- |
|
3313 CleanupStack::PopAndDestroy( context ); |
|
3314 CleanupStack::PopAndDestroy( subscription ); |
|
3315 } |
|
3316 |
|
3317 void MT_CFClient::MT_CCFClient_SubscribeActionFromDifferentClientsL( ) |
|
3318 { |
|
3319 TInt err = KErrNone; |
|
3320 CCFActionSubscription* subscription = CCFActionSubscription::NewLC ( ); |
|
3321 CCFContextObject* context = CCFContextObject::NewLC ( ); |
|
3322 |
|
3323 // Define actions used in test-cfclient.rul |
|
3324 iClient->DefineAction ( KActionA, KPassSec ); |
|
3325 iClient->DefineAction ( KActionB, KPassSec ); |
|
3326 |
|
3327 // Define contexts used in test-cfclient.rul |
|
3328 iClient->DefineContext ( KContextSourceA, KContextTypeA, KPassSec ); |
|
3329 |
|
3330 // Subscribe both actions but from different clients |
|
3331 subscription->SetActionIdentifierL ( KActionA ); |
|
3332 err = iClient->SubscribeAction ( *subscription ); |
|
3333 EUNIT_ASSERT_DESC( err == KErrNone, "Incorrect SubscribeAction return value!" ); |
|
3334 |
|
3335 subscription->SetActionIdentifierL ( KActionB ); |
|
3336 err = iAnotherClient->SubscribeAction ( *subscription ); |
|
3337 EUNIT_ASSERT_DESC( err == KErrNone, "Incorrect SubscribeAction return value!" ); |
|
3338 |
|
3339 // Publish context [SourceA: TypeA: ValueA] and wait for action indication |
|
3340 context->SetSourceL ( KContextSourceA ); |
|
3341 context->SetTypeL ( KContextTypeA ); |
|
3342 context->SetValueL ( KContextValueA ); |
|
3343 err = iClient->PublishContext ( *context ); |
|
3344 EUNIT_ASSERT_DESC( err == KErrNone, "Incorrect PublishContext return value!" ); |
|
3345 iCheckA = ETrue; |
|
3346 iWait->Start ( ); |
|
3347 |
|
3348 // Publish context [SourceA: TypeA: ValueB] and wait for action indications |
|
3349 context->SetSourceL ( KContextSourceA ); |
|
3350 context->SetTypeL ( KContextTypeA ); |
|
3351 context->SetValueL ( KContextValueB ); |
|
3352 err = iAnotherClient->PublishContext ( *context ); |
|
3353 EUNIT_ASSERT_DESC( err == KErrNone, "Incorrect PublishContext return value!" ); |
|
3354 iCheckA = ETrue; |
|
3355 iCheckB = ETrue; |
|
3356 iWait->Start ( ); |
|
3357 |
|
3358 // Clean up |
|
3359 CleanupStack::PopAndDestroy ( context ); |
|
3360 CleanupStack::PopAndDestroy ( subscription ); |
|
3361 } |
|
3362 |
|
3363 void MT_CFClient::MT_CCFClient_SubscribeActionFromDifferentClients2L( ) |
|
3364 { |
|
3365 TInt err = KErrNone; |
|
3366 CCFActionSubscription* subscription = CCFActionSubscription::NewLC ( ); |
|
3367 CCFContextObject* context = CCFContextObject::NewLC ( ); |
|
3368 |
|
3369 // Define action used in test-cfclient.rul |
|
3370 iClient->DefineAction ( KActionA, KPassSec ); |
|
3371 |
|
3372 // Define contexts used in test-cfclient.rul |
|
3373 iClient->DefineContext ( KContextSourceA, KContextTypeA, KPassSec ); |
|
3374 |
|
3375 // Subscribe same action from different clients |
|
3376 subscription->SetActionIdentifierL ( KActionA ); |
|
3377 err = iClient->SubscribeAction ( *subscription ); |
|
3378 EUNIT_ASSERT_DESC( err == KErrNone, "Incorrect SubscribeAction return value!" ); |
|
3379 |
|
3380 err = iAnotherClient->SubscribeAction ( *subscription ); |
|
3381 EUNIT_ASSERT_DESC( err == KErrNone, "Incorrect SubscribeAction return value!" ); |
|
3382 |
|
3383 iCheckB = EFalse; |
|
3384 iCountActionAIndications = ETrue; |
|
3385 iExpectedActionAIndicationCount = 2; |
|
3386 // Publish context [SourceA: TypeA: ValueA] and wait for action indications |
|
3387 context->SetSourceL ( KContextSourceA ); |
|
3388 context->SetTypeL ( KContextTypeA ); |
|
3389 context->SetValueL ( KContextValueA ); |
|
3390 err = iClient->PublishContext ( *context ); |
|
3391 EUNIT_ASSERT_DESC( err == KErrNone, "Incorrect PublishContext return value!" ); |
|
3392 iCheckA = ETrue; |
|
3393 iWait->Start ( ); |
|
3394 EUNIT_ASSERT_DESC( iExpectedActionAIndicationCount == 0, "Unexpected amount of action indications!" ); |
|
3395 iCountActionAIndications = EFalse; |
|
3396 |
|
3397 // Clean up |
|
3398 CleanupStack::PopAndDestroy ( context ); |
|
3399 CleanupStack::PopAndDestroy ( subscription ); |
|
3400 } |
|
3401 |
|
3402 void MT_CFClient::MT_CCFClient_SubscribeActionCombinedL( ) |
|
3403 { |
|
3404 MT_CCFClient_SubscribeAction1L ( ); |
|
3405 Wait( KSecond ); |
|
3406 delete iClient; |
|
3407 iClient = NULL; |
|
3408 iClient = CCFClient::NewL( *this ); |
|
3409 |
|
3410 MT_CCFClient_SubscribeAction2L ( ); |
|
3411 Wait( KSecond ); |
|
3412 delete iClient; |
|
3413 iClient = NULL; |
|
3414 iClient = CCFClient::NewL( *this ); |
|
3415 |
|
3416 MT_CCFClient_SubscribeAction3L ( ); |
|
3417 Wait( KSecond ); |
|
3418 delete iClient; |
|
3419 iClient = NULL; |
|
3420 iClient = CCFClient::NewL( *this ); |
|
3421 |
|
3422 MT_CCFClient_SubscribeAction4L ( ); |
|
3423 } |
|
3424 |
|
3425 void MT_CFClient::MT_CCFClient_UnsubscribeActionL( ) |
|
3426 { |
|
3427 TInt err = KErrNone; |
|
3428 CCFActionSubscription* subscription = CCFActionSubscription::NewLC ( ); |
|
3429 CCFContextObject* context = CCFContextObject::NewLC ( ); |
|
3430 |
|
3431 // Define actions used in test-cfclient.rul |
|
3432 iClient->DefineAction ( KActionA, KPassSec ); |
|
3433 iClient->DefineAction ( KActionB, KPassSec ); |
|
3434 |
|
3435 // Define contexts used in test-cfclient.rul |
|
3436 iClient->DefineContext ( KContextSourceA, KContextTypeA, KPassSec ); |
|
3437 |
|
3438 // Subscribe both actions |
|
3439 subscription->SetActionIdentifierL ( KActionA ); |
|
3440 err = iClient->SubscribeAction ( *subscription ); |
|
3441 EUNIT_ASSERT_DESC( err == KErrNone, "Incorrect SubscribeAction return value!" ); |
|
3442 |
|
3443 subscription->SetActionIdentifierL ( KActionB ); |
|
3444 err = iClient->SubscribeAction ( *subscription ); |
|
3445 EUNIT_ASSERT_DESC( err == KErrNone, "Incorrect SubscribeAction return value!" ); |
|
3446 |
|
3447 // Publish context [SourceA: TypeA: ValueA] and wait for action indication |
|
3448 context->SetSourceL ( KContextSourceA ); |
|
3449 context->SetTypeL ( KContextTypeA ); |
|
3450 context->SetValueL ( KContextValueA ); |
|
3451 err = iClient->PublishContext ( *context ); |
|
3452 EUNIT_ASSERT_DESC( err == KErrNone, "Incorrect PublishContext return value!" ); |
|
3453 iCheckA = ETrue; |
|
3454 iWait->Start ( ); |
|
3455 |
|
3456 // Publish context [SourceA: TypeA: ValueB] and wait for action indications |
|
3457 context->SetSourceL ( KContextSourceA ); |
|
3458 context->SetTypeL ( KContextTypeA ); |
|
3459 context->SetValueL ( KContextValueB ); |
|
3460 err = iClient->PublishContext ( *context ); |
|
3461 EUNIT_ASSERT_DESC( err == KErrNone, "Incorrect PublishContext return value!" ); |
|
3462 iCheckA = ETrue; |
|
3463 iCheckB = ETrue; |
|
3464 iWait->Start ( ); |
|
3465 |
|
3466 // Unsubscribe actionA |
|
3467 subscription->SetActionIdentifierL ( KActionA ); |
|
3468 err = iClient->UnsubscribeAction ( *subscription ); |
|
3469 EUNIT_ASSERT_DESC( err == KErrNone, "Incorrect UnsubscribeAction return value!" ); |
|
3470 |
|
3471 // Publish context [SourceA: TypeA: ValueA], should not receive action indication |
|
3472 context->SetSourceL ( KContextSourceA ); |
|
3473 context->SetTypeL ( KContextTypeA ); |
|
3474 context->SetValueL ( KContextValueA ); |
|
3475 err = iClient->PublishContext ( *context ); |
|
3476 EUNIT_ASSERT_DESC( err == KErrNone, "Incorrect PublishContext return value!" ); |
|
3477 iCheckA = ETrue; |
|
3478 Wait ( KDelay ); |
|
3479 EUNIT_ASSERT_DESC( iCheckA, "Action indication received!" ); |
|
3480 iCheckA = EFalse; |
|
3481 |
|
3482 // Publish context [SourceA: TypeA: ValueB] and wait for action indication |
|
3483 context->SetSourceL ( KContextSourceA ); |
|
3484 context->SetTypeL ( KContextTypeA ); |
|
3485 context->SetValueL ( KContextValueB ); |
|
3486 err = iClient->PublishContext ( *context ); |
|
3487 EUNIT_ASSERT_DESC( err == KErrNone, "Incorrect PublishContext return value!" ); |
|
3488 iCheckB = ETrue; |
|
3489 iWait->Start ( ); |
|
3490 |
|
3491 // Unsubscribe actionB |
|
3492 subscription->SetActionIdentifierL ( KActionB ); |
|
3493 err = iClient->UnsubscribeAction ( *subscription ); |
|
3494 EUNIT_ASSERT_DESC( err == KErrNone, "Incorrect UnsubscribeAction return value!" ); |
|
3495 |
|
3496 // Publish context [SourceA: TypeA: ValueB], should not reveice action indication |
|
3497 context->SetSourceL ( KContextSourceA ); |
|
3498 context->SetTypeL ( KContextTypeA ); |
|
3499 context->SetValueL ( KContextValueB ); |
|
3500 err = iClient->PublishContext ( *context ); |
|
3501 EUNIT_ASSERT_DESC( err == KErrNone, "Incorrect PublishContext return value!" ); |
|
3502 iCheckB = ETrue; |
|
3503 Wait ( KDelay ); |
|
3504 EUNIT_ASSERT_DESC( iCheckB, "Action indication received!" ); |
|
3505 iCheckB = EFalse; |
|
3506 |
|
3507 // subscribe actionA again |
|
3508 subscription->SetActionIdentifierL ( KActionA ); |
|
3509 err = iClient->SubscribeAction ( *subscription ); |
|
3510 EUNIT_ASSERT_DESC( err == KErrNone, "Incorrect SubscribeAction return value!" ); |
|
3511 |
|
3512 // Publish context [SourceA: TypeA: ValueA] and wait for action indication |
|
3513 context->SetSourceL ( KContextSourceA ); |
|
3514 context->SetTypeL ( KContextTypeA ); |
|
3515 context->SetValueL ( KContextValueA ); |
|
3516 err = iClient->PublishContext ( *context ); |
|
3517 EUNIT_ASSERT_DESC( err == KErrNone, "Incorrect PublishContext return value!" ); |
|
3518 iCheckA = ETrue; |
|
3519 iWait->Start ( ); |
|
3520 |
|
3521 // subscribe actionB again |
|
3522 subscription->SetActionIdentifierL ( KActionB ); |
|
3523 err = iClient->SubscribeAction ( *subscription ); |
|
3524 EUNIT_ASSERT_DESC( err == KErrNone, "Incorrect SubscribeAction return value!" ); |
|
3525 |
|
3526 // Publish context [SourceA: TypeA: ValueB] and wait for action indications |
|
3527 context->SetSourceL ( KContextSourceA ); |
|
3528 context->SetTypeL ( KContextTypeA ); |
|
3529 context->SetValueL ( KContextValueB ); |
|
3530 err = iClient->PublishContext ( *context ); |
|
3531 EUNIT_ASSERT_DESC( err == KErrNone, "Incorrect PublishContext return value!" ); |
|
3532 iCheckA = ETrue; |
|
3533 iCheckB = ETrue; |
|
3534 iWait->Start ( ); |
|
3535 |
|
3536 // Clean up |
|
3537 CleanupStack::PopAndDestroy ( context ); |
|
3538 CleanupStack::PopAndDestroy ( subscription ); |
|
3539 } |
|
3540 |
|
3541 void MT_CFClient::MT_CCFClient_RegisterScriptL( ) |
|
3542 { |
|
3543 TInt err; |
|
3544 |
|
3545 // Define context |
|
3546 CCFContextObject* co = CCFContextObject::NewLC ( ); |
|
3547 co->SetSourceL (_L("RegisterScriptSource") ); |
|
3548 co->SetTypeL (_L("RegisterScriptType") ); |
|
3549 err = iClient->DefineContext ( co->Source ( ), co->Type ( ), KPassSec ); |
|
3550 //EUNIT_ASSERT( err == KErrNone ); |
|
3551 |
|
3552 // define context with no access |
|
3553 err = iClient->DefineContext ( _L("RegisterScriptSource"), |
|
3554 _L("RegisterScriptTypeNoAccess"), KFailSec ); |
|
3555 //EUNIT_ASSERT( err == KErrNone ); |
|
3556 |
|
3557 // Define action |
|
3558 iClient->DefineAction ( _L("RegisterScriptAction"), KPassSec ); |
|
3559 |
|
3560 // Define action with no access |
|
3561 iClient->DefineAction ( _L("RegisterScriptActionNoAccess"), KFailSec ); |
|
3562 |
|
3563 TInt scriptId; |
|
3564 |
|
3565 // 1. registering script fails because no context defined |
|
3566 err = iClient->RegisterScript ( |
|
3567 _L("z:\\data\\cftestdata\\testscripts\\test-registerscript-nocontextdefined.xml"), |
|
3568 scriptId ); |
|
3569 EUNIT_ASSERT_DESC( err == KErrNotFound, "No error when registering script!" ); |
|
3570 |
|
3571 // 2. registering script fails because no action defined |
|
3572 err = iClient->RegisterScript ( |
|
3573 _L("z:\\data\\cftestdata\\testscripts\\test-registerscript-noactiondefined.xml"), |
|
3574 scriptId ); |
|
3575 EUNIT_ASSERT_DESC( err == KErrNotFound, "No error when registering script!" ); |
|
3576 |
|
3577 // 3. registering script fails because no capabilities |
|
3578 err = iClient->RegisterScript ( |
|
3579 _L("z:\\data\\cftestdata\\testscripts\\test-registerscript-nocontextaccess.xml"), |
|
3580 scriptId ); |
|
3581 EUNIT_ASSERT_DESC( err == KErrPermissionDenied, "No error when registering script!" ); |
|
3582 |
|
3583 // 4. registering script fails because no action defined |
|
3584 err = iClient->RegisterScript ( |
|
3585 _L("z:\\data\\cftestdata\\testscripts\\test-registerscript-noactionaccess.xml"), |
|
3586 scriptId ); |
|
3587 EUNIT_ASSERT_DESC( err == KErrPermissionDenied, "No error when registering script!" ); |
|
3588 |
|
3589 // 5. registering script succeeds |
|
3590 err = iClient->RegisterScript ( |
|
3591 _L("z:\\data\\cftestdata\\testscripts\\test-registerscript.xml"), |
|
3592 scriptId ); |
|
3593 EUNIT_ASSERT_DESC( err == KErrNone, "Error when registering script!" ); |
|
3594 |
|
3595 // Subscribe both actions |
|
3596 CCFActionSubscription* subscription = CCFActionSubscription::NewLC ( ); |
|
3597 subscription->SetActionIdentifierL ( _L("RegisterScriptAction") ); |
|
3598 err = iClient->SubscribeAction ( *subscription ); |
|
3599 EUNIT_ASSERT_DESC( err == KErrNone, |
|
3600 "Incorrect SubscribeAction return value!" ); |
|
3601 |
|
3602 // 4. test that we will get action indications |
|
3603 co->SetValueL (_L("RegisterScriptValue") ); |
|
3604 err = iClient->PublishContext ( *co ); |
|
3605 EUNIT_ASSERT_DESC( err == KErrNone, |
|
3606 "Incorrect PublishContext return value!" ); |
|
3607 |
|
3608 iCheckRegisterScriptAction = ETrue; |
|
3609 iWait->Start ( ); |
|
3610 |
|
3611 CleanupStack::PopAndDestroy ( subscription ); |
|
3612 CleanupStack::PopAndDestroy ( co ); |
|
3613 |
|
3614 // 6. Deregister script |
|
3615 |
|
3616 err = iClient->DeregisterScript ( scriptId ); |
|
3617 EUNIT_ASSERT_DESC( err == KErrNone, "Deregistering script caused error!" ); |
|
3618 |
|
3619 } |
|
3620 |
|
3621 void MT_CFClient::MT_CCFClient_RegisterScriptDesL( ) |
|
3622 { |
|
3623 TInt err; |
|
3624 |
|
3625 // Define context |
|
3626 CCFContextObject* co = CCFContextObject::NewLC ( ); |
|
3627 co->SetSourceL (_L("RegisterScriptSource") ); |
|
3628 co->SetTypeL (_L("RegisterScriptType") ); |
|
3629 err = iClient->DefineContext ( co->Source ( ), co->Type ( ), KPassSec ); |
|
3630 //EUNIT_ASSERT( err == KErrNone ); |
|
3631 |
|
3632 // define context with no access |
|
3633 err = iClient->DefineContext ( _L("RegisterScriptSource"), |
|
3634 _L("RegisterScriptTypeNoAccess"), KFailSec ); |
|
3635 //EUNIT_ASSERT( err == KErrNone ); |
|
3636 |
|
3637 // Define action |
|
3638 iClient->DefineAction ( _L("RegisterScriptAction"), KPassSec ); |
|
3639 |
|
3640 // Define action with no access |
|
3641 iClient->DefineAction ( _L("RegisterScriptActionNoAccess"), KFailSec ); |
|
3642 |
|
3643 TInt scriptId; |
|
3644 |
|
3645 // 1. registering script fails because no context defined |
|
3646 HBufC8* script = LoadScriptFromFile (_L("test-registerscript-nocontextdefined.xml") ); |
|
3647 err = iClient->RegisterScript ( |
|
3648 _L("test-registerscript-nocontextdefined.xml"), *script, scriptId ); |
|
3649 EUNIT_ASSERT_DESC( err == KErrNotFound, "No error when registering script!" ); |
|
3650 delete script; |
|
3651 script = NULL; |
|
3652 |
|
3653 // 2. registering script fails because no action defined |
|
3654 script = LoadScriptFromFile (_L("test-registerscript-noactiondefined.xml") ); |
|
3655 err = iClient->RegisterScript ( |
|
3656 _L("test-registerscript-noactiondefined.xml"), *script, scriptId ); |
|
3657 EUNIT_ASSERT_DESC( err == KErrNotFound, "No error when registering script!" ); |
|
3658 delete script; |
|
3659 script = NULL; |
|
3660 |
|
3661 // 3. registering script fails because no capabilities |
|
3662 script = LoadScriptFromFile (_L("test-registerscript-nocontextaccess.xml") ); |
|
3663 err = iClient->RegisterScript ( |
|
3664 _L("test-registerscript-nocontextaccess.xml"), *script, scriptId ); |
|
3665 EUNIT_ASSERT_DESC( err == KErrPermissionDenied, "No error when registering script!" ); |
|
3666 delete script; |
|
3667 script = NULL; |
|
3668 |
|
3669 // 4. registering script fails because no action defined |
|
3670 script = LoadScriptFromFile (_L("test-registerscript-noactionaccess.xml") ); |
|
3671 err = iClient->RegisterScript ( |
|
3672 _L("test-registerscript-noactionaccess.xml"), *script, scriptId ); |
|
3673 EUNIT_ASSERT_DESC( err == KErrPermissionDenied, "No error when registering script!" ); |
|
3674 delete script; |
|
3675 script = NULL; |
|
3676 |
|
3677 // 5. registering script succeeds |
|
3678 script = LoadScriptFromFile (_L("test-registerscript.xml") ); |
|
3679 err = iClient->RegisterScript ( |
|
3680 _L("test-registerscript.xml"), *script, scriptId ); |
|
3681 EUNIT_ASSERT_DESC( err == KErrNone, "Error when registering script!" ); |
|
3682 delete script; |
|
3683 script = NULL; |
|
3684 |
|
3685 // Subscribe both actions |
|
3686 CCFActionSubscription* subscription = CCFActionSubscription::NewLC ( ); |
|
3687 subscription->SetActionIdentifierL ( _L("RegisterScriptAction") ); |
|
3688 err = iClient->SubscribeAction ( *subscription ); |
|
3689 EUNIT_ASSERT_DESC( err == KErrNone, |
|
3690 "Incorrect SubscribeAction return value!" ); |
|
3691 |
|
3692 // 6. test that we will get action indications |
|
3693 |
|
3694 co->SetValueL (_L("RegisterScriptValue") ); |
|
3695 err = iClient->PublishContext ( *co ); |
|
3696 EUNIT_ASSERT_DESC( err == KErrNone, |
|
3697 "Incorrect PublishContext return value!" ); |
|
3698 |
|
3699 iCheckRegisterScriptAction = ETrue; |
|
3700 iWait->Start ( ); |
|
3701 |
|
3702 CleanupStack::PopAndDestroy ( subscription ); |
|
3703 CleanupStack::PopAndDestroy ( co ); |
|
3704 |
|
3705 // 7. Deregister script |
|
3706 |
|
3707 err = iClient->DeregisterScript ( scriptId ); |
|
3708 EUNIT_ASSERT_DESC( err == KErrNone, "Deregistering script caused error!" ); |
|
3709 } |
|
3710 |
|
3711 void MT_CFClient::MT_CCFClient_DeregisterScriptL( ) |
|
3712 { |
|
3713 // 1. Try to remove script we did not register -> should fail |
|
3714 TInt err = iClient->DeregisterScript ( 1 ); |
|
3715 EUNIT_ASSERT_DESC( err != KErrNone, |
|
3716 "Succeeded to deregister script loaded by CF/registered by others" ); |
|
3717 } |
|
3718 |
|
3719 void MT_CFClient::MT_CCFClient_SaveContextSourceSettingL( ) |
|
3720 { |
|
3721 // 1. Install setting succeeds |
|
3722 TInt err = iClient->SaveContextSourceSetting ( |
|
3723 _L("z:\\data\\cftestdata\\testsettings\\testcontextsourcesetting3.xml"), |
|
3724 KTestContextSourcePluginImplUid ); |
|
3725 EUNIT_ASSERT_DESC( err == KErrNone, "Error when installing settings3!" ); |
|
3726 |
|
3727 TBool |
|
3728 fileExists = BaflUtils::FileExists ( |
|
3729 iFs, |
|
3730 _L( "C:\\Private\\10282BC4\\Settings\\10002001\\20000fb1_testcontextsourcesetting3.xml" ) ); |
|
3731 EUNIT_ASSERT_DESC( fileExists, "Error, cannot find settings3 file after install!" ); |
|
3732 |
|
3733 // 2. Uninstall setting succeeds |
|
3734 err = iClient->DeleteContextSourceSetting ( |
|
3735 _L("testcontextsourcesetting3.xml"), |
|
3736 KTestContextSourcePluginImplUid ); |
|
3737 EUNIT_ASSERT_DESC( err == KErrNone, "Error when uninstalling settings3!" ); |
|
3738 |
|
3739 fileExists = BaflUtils::FileExists ( |
|
3740 iFs, |
|
3741 _L( "C:\\Private\\10282BC4\\Settings\\10002001\\20000fb1_testcontextsourcesetting3.xml" ) ); |
|
3742 EUNIT_ASSERT_DESC( !fileExists, "Error, file settings3 still exists after uninstall!" ); |
|
3743 |
|
3744 if ( iTestDelay ) |
|
3745 { |
|
3746 iTestDelay->Start ( 100000 ); // 100 ms |
|
3747 } |
|
3748 } |
|
3749 |
|
3750 void MT_CFClient::MT_CCFClient_SaveContextSourceSetting2L( ) |
|
3751 { |
|
3752 // 1. Installing bogus setting file, fails |
|
3753 TInt |
|
3754 err = iClient->SaveContextSourceSetting ( |
|
3755 _L("z:\\data\\cftestdata\\testsettings\\testcontext_source_setting_4.xml"), |
|
3756 KTestContextSourcePluginImplUid ); |
|
3757 EUNIT_ASSERT_DESC( err == KErrNotFound, "Error when installing settings_4!" ); |
|
3758 |
|
3759 TBool |
|
3760 fileExists = BaflUtils::FileExists ( |
|
3761 iFs, |
|
3762 _L( "C:\\Private\\10282BC4\\Settings\\10002001\\20000fb1_testcontext_source_setting_4.xml" ) ); |
|
3763 EUNIT_ASSERT_DESC( !fileExists, "Error, settings_4 file exists after install!" ); |
|
3764 |
|
3765 // 2. Installing existing setting file not allowed by the plugin, fails |
|
3766 err = iClient->SaveContextSourceSetting ( |
|
3767 _L("z:\\data\\cftestdata\\testsettings\\testcontextsourcesetting4.xml"), |
|
3768 KTestContextSourcePluginImplUid ); |
|
3769 EUNIT_ASSERT_DESC( err == KErrPermissionDenied, "Error when installing settings4!" ); |
|
3770 |
|
3771 fileExists = BaflUtils::FileExists ( |
|
3772 iFs, |
|
3773 _L( "C:\\Private\\10282BC4\\Settings\\10002001\\20000fb1_testcontextsourcesetting4.xml" ) ); |
|
3774 EUNIT_ASSERT_DESC( !fileExists, "Error, settings4 file exists after install!" ); |
|
3775 |
|
3776 // 3. Installing existing setting file for bogus plugin, fails |
|
3777 err = iClient->SaveContextSourceSetting ( |
|
3778 _L("z:\\data\\cftestdata\\testsettings\\testcontextsourcesetting4.xml"), |
|
3779 KBogusContextSourcePluginImplUid ); |
|
3780 EUNIT_ASSERT_DESC( err == KErrBadHandle, "Error when installing settings4 for bogus source!" ); |
|
3781 |
|
3782 // 4. Installing setting passing from CheckValidity but leaving from |
|
3783 // UpdateSettingsL because of invalid settings! |
|
3784 // This should not happen for real source plugins. |
|
3785 err = iClient->SaveContextSourceSetting ( |
|
3786 _L("z:\\data\\cftestdata\\testsettings\\testcontextsourcesetting7.xml"), |
|
3787 KTestContextSourcePluginImplUid ); |
|
3788 EUNIT_ASSERT_DESC( err == KErrGeneral, "Error when installing settings7!" ); |
|
3789 |
|
3790 fileExists = BaflUtils::FileExists ( |
|
3791 iFs, |
|
3792 _L( "C:\\Private\\10282BC4\\Settings\\10002001\\20000fb1_testcontextsourcesetting7.xml" ) ); |
|
3793 EUNIT_ASSERT_DESC( fileExists, "Error, cannot find settings7 file after install!" ); |
|
3794 |
|
3795 // 5. Uninstall setting succeeds, must do this because setting file was |
|
3796 // stored by the above failing call. |
|
3797 err = iClient->DeleteContextSourceSetting ( |
|
3798 _L("testcontextsourcesetting7.xml"), |
|
3799 KTestContextSourcePluginImplUid ); |
|
3800 EUNIT_ASSERT_DESC( err == KErrNone, "Error when uninstalling settings3!" ); |
|
3801 |
|
3802 fileExists = BaflUtils::FileExists ( |
|
3803 iFs, |
|
3804 _L( "C:\\Private\\10282BC4\\Settings\\10002001\\20000fb1_testcontextsourcesetting7.xml" ) ); |
|
3805 EUNIT_ASSERT_DESC( !fileExists, "Error, file settings3 still exists after uninstall!" ); |
|
3806 |
|
3807 if ( iTestDelay ) |
|
3808 { |
|
3809 iTestDelay->Start ( 100000 ); // 100 ms |
|
3810 } |
|
3811 } |
|
3812 |
|
3813 void MT_CFClient::MT_CCFClient_DeleteContextSourceSettingL( ) |
|
3814 { |
|
3815 // 1. Uninstall bogus setting, fails |
|
3816 TBool |
|
3817 fileExists = BaflUtils::FileExists ( |
|
3818 iFs, |
|
3819 _L( "C:\\Private\\10282BC4\\Settings\\10002001\\20000fb1_testcontext_source_setting3.xml" ) ); |
|
3820 EUNIT_ASSERT_DESC( !fileExists, "Error, file testcontext_source_setting3 exists!" ); |
|
3821 |
|
3822 TInt err = iClient->DeleteContextSourceSetting ( |
|
3823 _L("testcontext_source_setting3.xml"), |
|
3824 KTestContextSourcePluginImplUid ); |
|
3825 EUNIT_ASSERT_DESC( err == KErrNotFound, "Error when uninstalling bogus setting!" ); |
|
3826 |
|
3827 // 2. Uninstall setting from bogus source, fails |
|
3828 err = iClient->DeleteContextSourceSetting ( |
|
3829 _L("testcontextsourcesetting3.xml"), |
|
3830 KBogusContextSourcePluginImplUid ); |
|
3831 EUNIT_ASSERT_DESC( err == KErrBadHandle, "Error when uninstalling setting from bogus source!" ); |
|
3832 |
|
3833 if ( iTestDelay ) |
|
3834 { |
|
3835 iTestDelay->Start ( 100000 ); // 100 ms |
|
3836 } |
|
3837 } |
|
3838 |
|
3839 void MT_CFClient::MT_CCFClient_DeleteContextSourceSetting2L( ) |
|
3840 { |
|
3841 // 1. Install setting succeeds |
|
3842 TInt err = iClient->SaveContextSourceSetting ( |
|
3843 _L("z:\\data\\cftestdata\\testsettings\\testcontextsourcesetting3.xml"), |
|
3844 KTestContextSourcePluginImplUid ); |
|
3845 EUNIT_ASSERT_DESC( err == KErrNone, "Error when installing settings3!" ); |
|
3846 |
|
3847 TBool |
|
3848 fileExists = BaflUtils::FileExists ( |
|
3849 iFs, |
|
3850 _L( "C:\\Private\\10282BC4\\Settings\\10002001\\20000fb1_testcontextsourcesetting3.xml" ) ); |
|
3851 EUNIT_ASSERT_DESC( fileExists, "Error, cannot find settings3 file after install!" ); |
|
3852 |
|
3853 // 2. Install 2nd setting succeeds |
|
3854 err = iClient->SaveContextSourceSetting ( |
|
3855 _L("z:\\data\\cftestdata\\testsettings\\testcontextsourcesetting5.xml"), |
|
3856 KTestContextSourcePluginImplUid ); |
|
3857 EUNIT_ASSERT_DESC( err == KErrNone, "Error when installing settings5!" ); |
|
3858 |
|
3859 fileExists = BaflUtils::FileExists ( |
|
3860 iFs, |
|
3861 _L( "C:\\Private\\10282BC4\\Settings\\10002001\\20000fb1_testcontextsourcesetting5.xml" ) ); |
|
3862 EUNIT_ASSERT_DESC( fileExists, "Error, cannot find settings5 file after install!" ); |
|
3863 |
|
3864 // 3. Uninstall all client settings succeeds |
|
3865 err = iClient->DeleteContextSourceSettings (KTestContextSourcePluginImplUid ); |
|
3866 EUNIT_ASSERT_DESC( err == KErrNone, "Error when uninstalling all client installed settings!" ); |
|
3867 |
|
3868 fileExists = BaflUtils::FileExists ( |
|
3869 iFs, |
|
3870 _L( "C:\\Private\\10282BC4\\Settings\\10002001\\20000fb1_testcontextsourcesetting3.xml" ) ); |
|
3871 EUNIT_ASSERT_DESC( !fileExists, "Error, file settings3 still exists after uninstall!" ); |
|
3872 |
|
3873 fileExists = BaflUtils::FileExists ( |
|
3874 iFs, |
|
3875 _L( "C:\\Private\\10282BC4\\Settings\\10002001\\20000fb1_testcontextsourcesetting5.xml" ) ); |
|
3876 EUNIT_ASSERT_DESC( !fileExists, "Error, file settings5 still exists after uninstall!" ); |
|
3877 |
|
3878 // 4. Uninstall all client settings, no exists, fails |
|
3879 err = iClient->DeleteContextSourceSettings (KTestContextSourcePluginImplUid ); |
|
3880 EUNIT_ASSERT_DESC( err == KErrNotFound, "Error when uninstalling all client installed settings!" ); |
|
3881 |
|
3882 if ( iTestDelay ) |
|
3883 { |
|
3884 iTestDelay->Start ( 100000 ); // 100 ms |
|
3885 } |
|
3886 } |
|
3887 |
|
3888 void MT_CFClient::MT_CCFClient_UpgradeContextSourceSettingL( ) |
|
3889 { |
|
3890 // 1. Install setting succeeds |
|
3891 TInt err = iClient->SaveContextSourceSetting ( |
|
3892 _L("z:\\data\\cftestdata\\testsettings\\testcontextsourcesetting3.xml"), |
|
3893 KTestContextSourcePluginImplUid ); |
|
3894 EUNIT_ASSERT_DESC( err == KErrNone, "Error when installing settings3!" ); |
|
3895 |
|
3896 TBool |
|
3897 fileExists = BaflUtils::FileExists ( |
|
3898 iFs, |
|
3899 _L( "C:\\Private\\10282BC4\\Settings\\10002001\\20000fb1_testcontextsourcesetting3.xml" ) ); |
|
3900 EUNIT_ASSERT_DESC( fileExists, "Error, cannot find settings3 file after install!" ); |
|
3901 |
|
3902 // 2. Upgrade setting succeeds |
|
3903 err = iClient->SaveContextSourceSetting ( |
|
3904 _L("z:\\data\\cftestdata\\testsettings\\settingupgrade\\testcontextsourcesetting3.xml"), |
|
3905 KTestContextSourcePluginImplUid ); |
|
3906 EUNIT_ASSERT_DESC( err == KErrNone, "Error when upgrading settings3!" ); |
|
3907 |
|
3908 fileExists = BaflUtils::FileExists ( |
|
3909 iFs, |
|
3910 _L( "C:\\Private\\10282BC4\\Settings\\10002001\\20000fb1_testcontextsourcesetting3.xml" ) ); |
|
3911 EUNIT_ASSERT_DESC( fileExists, "Error, cannot find settings3 file after install!" ); |
|
3912 |
|
3913 // 3. Uninstall setting succeeds |
|
3914 err = iClient->DeleteContextSourceSetting ( |
|
3915 _L("testcontextsourcesetting3.xml"), |
|
3916 KTestContextSourcePluginImplUid ); |
|
3917 EUNIT_ASSERT_DESC( err == KErrNone, "Error when uninstalling settings3!" ); |
|
3918 |
|
3919 fileExists = BaflUtils::FileExists ( |
|
3920 iFs, |
|
3921 _L( "C:\\Private\\10282BC4\\Settings\\10002001\\20000fb1_testcontextsourcesetting3.xml" ) ); |
|
3922 EUNIT_ASSERT_DESC( !fileExists, "Error, file settings3 still exists after uninstall!" ); |
|
3923 |
|
3924 if ( iTestDelay ) |
|
3925 { |
|
3926 iTestDelay->Start ( 100000 ); // 100 ms |
|
3927 } |
|
3928 } |
|
3929 |
|
3930 void MT_CFClient::MT_CCFClient_SaveScriptL( ) |
|
3931 { |
|
3932 // Change timestamp to yesterday |
|
3933 TTime currentTime; |
|
3934 currentTime.UniversalTime(); |
|
3935 TDateTime dateTime = currentTime.DateTime(); |
|
3936 dateTime.SetHour( dateTime.Hour() - 1 ); |
|
3937 |
|
3938 // Update new time |
|
3939 TTime entryTime( dateTime ); |
|
3940 |
|
3941 CCFContextObject* co = CCFContextObject::NewLC ( ); |
|
3942 CCFActionSubscription* actionSubscription = CCFActionSubscription::NewLC ( ); |
|
3943 |
|
3944 // Setup preconditions |
|
3945 // ------------------------------------------------------------------------- |
|
3946 co->SetSourceL ( _L("test") ); |
|
3947 co->SetTypeL (_L("save.script") ); |
|
3948 TInt err = iClient->DefineContext ( co->Source ( ), co->Type ( ), KPassSec ); |
|
3949 EUNIT_ASSERT_DESC( err == KErrNone || err == KErrAlreadyExists, |
|
3950 "Define context failed" ); |
|
3951 |
|
3952 co->SetSourceL ( _L("test") ); |
|
3953 co->SetTypeL (_L("save.script.2") ); |
|
3954 err = iClient->DefineContext ( co->Source ( ), co->Type ( ), KPassSec ); |
|
3955 EUNIT_ASSERT_DESC( err == KErrNone || err == KErrAlreadyExists, |
|
3956 "Define context failed" ); |
|
3957 |
|
3958 err = iClient->DefineAction ( _L("saveScript"), KPassSec ); |
|
3959 EUNIT_ASSERT_DESC( err == KErrNone || err == KErrAlreadyExists, |
|
3960 "Define action failed" ); |
|
3961 |
|
3962 actionSubscription->SetActionIdentifierL ( _L("saveScript") ); |
|
3963 err = iClient->SubscribeAction ( *actionSubscription ); |
|
3964 EUNIT_ASSERT_DESC( err == KErrNone, "Subscribe action failed" ); |
|
3965 |
|
3966 // x. Save script with full path |
|
3967 // ------------------------------------------------------------------------- |
|
3968 TInt scriptId = KErrNotFound; |
|
3969 err = iClient->SaveScript ( |
|
3970 _L("z:\\data\\cftestdata\\testscripts\\test-saveScript.xml"), |
|
3971 scriptId ); |
|
3972 EUNIT_ASSERT_DESC( err == KErrNone, "Save script failed" ); |
|
3973 EUNIT_ASSERT_DESC( scriptId > 0, "Script id incorrect" ); |
|
3974 TBool exists = BaflUtils::FileExists ( iFs, |
|
3975 _L("c:\\private\\10282bc4\\rules\\20000fb1\\test-saveScript.rul") ); |
|
3976 EUNIT_ASSERT_DESC( exists, "Script not saved" ); |
|
3977 |
|
3978 co->SetSourceL ( _L("test") ); |
|
3979 co->SetTypeL (_L("save.script") ); |
|
3980 co->SetValueL ( _L("trigger") ); |
|
3981 err = iClient->PublishContext ( *co ); |
|
3982 EUNIT_ASSERT_DESC( err == KErrNone, "Publish context failed" ); |
|
3983 iCheckCustomAction = ETrue; |
|
3984 iCustomActionId = _L("saveScript" ); |
|
3985 CCFKeyValuePair* keyValue = CCFKeyValuePair::NewLC ( |
|
3986 _L("id"), _L("triggered") ); |
|
3987 iCustomActionParams.AppendL ( keyValue ); |
|
3988 CleanupStack::Pop ( keyValue ); |
|
3989 iWait->Start ( ); |
|
3990 |
|
3991 // x. Save the same script and check that the time stamp changes |
|
3992 // ------------------------------------------------------------------------- |
|
3993 err = iFs.SetModified( |
|
3994 _L("c:\\private\\10282bc4\\rules\\20000fb1\\test-saveScript.rul"), entryTime ); |
|
3995 TEntry oldEntry; |
|
3996 err = iFs.Entry ( |
|
3997 _L("c:\\private\\10282bc4\\rules\\20000fb1\\test-saveScript.rul"), |
|
3998 oldEntry ); |
|
3999 EUNIT_ASSERT_DESC( err == KErrNone, "Entry get failed" ); |
|
4000 |
|
4001 User::After( 100000 ); |
|
4002 err = iClient->SaveScript ( |
|
4003 _L("z:\\data\\cftestdata\\testscripts\\test-saveScript.xml"), |
|
4004 scriptId ); |
|
4005 EUNIT_ASSERT_DESC( err == KErrNone, "Save script failed" ); |
|
4006 EUNIT_ASSERT_DESC( scriptId > 0, "Script id incorrect" ); |
|
4007 exists = BaflUtils::FileExists ( iFs, |
|
4008 _L("c:\\private\\10282bc4\\rules\\20000fb1\\test-saveScript.rul") ); |
|
4009 EUNIT_ASSERT_DESC( exists, "Script not saved" ); |
|
4010 |
|
4011 TEntry newEntry; |
|
4012 err = iFs.Entry ( |
|
4013 _L("c:\\private\\10282bc4\\rules\\20000fb1\\test-saveScript.rul"), |
|
4014 newEntry ); |
|
4015 EUNIT_ASSERT_DESC( err == KErrNone, "Entry get failed" ); |
|
4016 EUNIT_ASSERT_DESC( oldEntry.iModified < newEntry.iModified, |
|
4017 "Script not updated" ); |
|
4018 |
|
4019 co->SetSourceL ( _L("test") ); |
|
4020 co->SetTypeL (_L("save.script") ); |
|
4021 co->SetValueL ( _L("trigger") ); |
|
4022 err = iClient->PublishContext ( *co ); |
|
4023 EUNIT_ASSERT_DESC( err == KErrNone, "Publish context failed" ); |
|
4024 iCheckCustomAction = ETrue; |
|
4025 iCustomActionId = _L("saveScript" ); |
|
4026 keyValue = CCFKeyValuePair::NewLC ( _L("id"), _L("triggered") ); |
|
4027 iCustomActionParams.AppendL ( keyValue ); |
|
4028 CleanupStack::Pop ( keyValue ); |
|
4029 iWait->Start ( ); |
|
4030 |
|
4031 // x. Save a script update with the same name |
|
4032 // ------------------------------------------------------------------------- |
|
4033 HBufC8* script = LoadScriptFromFile ( _L("test-saveScript2.xml") ); |
|
4034 User::LeaveIfNull ( script ); |
|
4035 CleanupStack::PushL ( script ); |
|
4036 |
|
4037 err = iClient->SaveScript ( _L("test-saveScript"), *script, scriptId ); |
|
4038 EUNIT_ASSERT_DESC( err == KErrNone, "Save script failed" ); |
|
4039 |
|
4040 co->SetSourceL ( _L("test") ); |
|
4041 co->SetTypeL (_L("save.script.2") ); |
|
4042 co->SetValueL ( _L("trigger") ); |
|
4043 err = iClient->PublishContext ( *co ); |
|
4044 EUNIT_ASSERT_DESC( err == KErrNone, "Publish context failed" ); |
|
4045 iCheckCustomAction = ETrue; |
|
4046 iCustomActionId = _L("saveScript" ); |
|
4047 keyValue = CCFKeyValuePair::NewLC ( _L("id"), _L("updateTriggered") ); |
|
4048 iCustomActionParams.AppendL ( keyValue ); |
|
4049 CleanupStack::Pop ( keyValue ); |
|
4050 iWait->Start ( ); |
|
4051 |
|
4052 CleanupStack::PopAndDestroy ( script ); |
|
4053 |
|
4054 // x. Save a script update with the same name (regression) |
|
4055 // ------------------------------------------------------------------------- |
|
4056 script = LoadScriptFromFile ( _L("test-saveScript.xml") ); |
|
4057 User::LeaveIfNull ( script ); |
|
4058 CleanupStack::PushL ( script ); |
|
4059 |
|
4060 err = iClient->SaveScript ( _L("test-saveScript"), *script, scriptId ); |
|
4061 EUNIT_ASSERT_DESC( err == KErrNone, "Save script failed" ); |
|
4062 |
|
4063 co->SetSourceL ( _L("test") ); |
|
4064 co->SetTypeL (_L("save.script") ); |
|
4065 co->SetValueL ( _L("trigger") ); |
|
4066 err = iClient->PublishContext ( *co ); |
|
4067 EUNIT_ASSERT_DESC( err == KErrNone, "Publish context failed" ); |
|
4068 iCheckCustomAction = ETrue; |
|
4069 iCustomActionId = _L("saveScript" ); |
|
4070 keyValue = CCFKeyValuePair::NewLC ( _L("id"), _L("triggered") ); |
|
4071 iCustomActionParams.AppendL ( keyValue ); |
|
4072 CleanupStack::Pop ( keyValue ); |
|
4073 iWait->Start ( ); |
|
4074 |
|
4075 CleanupStack::PopAndDestroy ( script ); |
|
4076 |
|
4077 // x. Save a new script via full path |
|
4078 // ------------------------------------------------------------------------- |
|
4079 scriptId = KErrNotFound; |
|
4080 err = iClient->SaveScript ( |
|
4081 _L("z:\\data\\cftestdata\\testscripts\\test-saveScript2.xml"), |
|
4082 scriptId ); |
|
4083 EUNIT_ASSERT_DESC( err == KErrNone, "Save script failed" ); |
|
4084 EUNIT_ASSERT_DESC( scriptId > 0, "Script id incorrect" ); |
|
4085 exists = BaflUtils::FileExists ( iFs, |
|
4086 _L("c:\\private\\10282bc4\\rules\\20000fb1\\test-saveScript2.rul") ); |
|
4087 EUNIT_ASSERT_DESC( exists, "Script not saved" ); |
|
4088 |
|
4089 co->SetSourceL ( _L("test") ); |
|
4090 co->SetTypeL (_L("save.script.2") ); |
|
4091 co->SetValueL ( _L("trigger") ); |
|
4092 err = iClient->PublishContext ( *co ); |
|
4093 EUNIT_ASSERT_DESC( err == KErrNone, "Publish context failed" ); |
|
4094 iCheckCustomAction = ETrue; |
|
4095 iCustomActionId = _L("saveScript" ); |
|
4096 keyValue = CCFKeyValuePair::NewLC ( |
|
4097 _L("id"), _L("updateTriggered") ); |
|
4098 iCustomActionParams.AppendL ( keyValue ); |
|
4099 CleanupStack::Pop ( keyValue ); |
|
4100 iWait->Start ( ); |
|
4101 |
|
4102 // x. Save script with incorrect parameters |
|
4103 // ------------------------------------------------------------------------- |
|
4104 err = iClient->SaveScript ( KNullDesC, scriptId ); |
|
4105 EUNIT_ASSERT_DESC( err != KErrNone, "Save script failed" ); |
|
4106 err = iClient->SaveScript ( KNullDesC, KNullDesC8, scriptId ); |
|
4107 EUNIT_ASSERT_DESC( err != KErrNone, "Save script failed" ); |
|
4108 |
|
4109 // x. Delete all scripts, register script and then try to save the script |
|
4110 // ------------------------------------------------------------------------- |
|
4111 err = iClient->DeleteScripts(); |
|
4112 EUNIT_ASSERT_DESC( err == KErrNone, "Delete scripts failed" ); |
|
4113 exists = BaflUtils::FolderExists( iFs, |
|
4114 _L("c:\\private\\10282bc4\\rules\\20000fb1\\") ); |
|
4115 EUNIT_ASSERT_DESC( !exists, "Delete scripts failed" ); |
|
4116 |
|
4117 err = iClient->RegisterScript( |
|
4118 _L("z:\\data\\cftestdata\\testscripts\\test-saveScript.xml"), |
|
4119 scriptId ); |
|
4120 EUNIT_ASSERT_DESC( err == KErrNone, "Register script failed" ); |
|
4121 EUNIT_ASSERT_DESC( scriptId > 0, "Register script failed" ); |
|
4122 |
|
4123 TInt previousScriptId = scriptId; |
|
4124 err = iClient->SaveScript( |
|
4125 _L("z:\\data\\cftestdata\\testscripts\\test-saveScript.xml"), |
|
4126 scriptId ); |
|
4127 EUNIT_ASSERT_DESC( err == KErrNone, "Save script failed" ); |
|
4128 EUNIT_ASSERT_DESC( scriptId > 0, "Save script failed" ); |
|
4129 EUNIT_ASSERT_DESC( scriptId == previousScriptId, "Save script failed" ); |
|
4130 |
|
4131 co->SetSourceL ( _L("test") ); |
|
4132 co->SetTypeL (_L("save.script") ); |
|
4133 co->SetValueL ( _L("trigger") ); |
|
4134 err = iClient->PublishContext ( *co ); |
|
4135 EUNIT_ASSERT_DESC( err == KErrNone, "Publish context failed" ); |
|
4136 iCheckCustomAction = ETrue; |
|
4137 iCustomActionId = _L("saveScript" ); |
|
4138 keyValue = CCFKeyValuePair::NewLC ( _L("id"), _L("triggered") ); |
|
4139 iCustomActionParams.AppendL ( keyValue ); |
|
4140 CleanupStack::Pop ( keyValue ); |
|
4141 iWait->Start ( ); |
|
4142 |
|
4143 // Clean up |
|
4144 // ------------------------------------------------------------------------- |
|
4145 CleanupStack::PopAndDestroy ( actionSubscription ); |
|
4146 CleanupStack::PopAndDestroy ( co ); |
|
4147 } |
|
4148 |
|
4149 void MT_CFClient::MT_CCFClient_DeleteScriptL( ) |
|
4150 { |
|
4151 CCFContextObject* co = CCFContextObject::NewLC( ); |
|
4152 CCFActionSubscription* actionSubscription = CCFActionSubscription::NewLC( ); |
|
4153 |
|
4154 // Setup preconditions |
|
4155 // ------------------------------------------------------------------------- |
|
4156 co->SetSourceL ( _L("test") ); |
|
4157 co->SetTypeL (_L("save.script") ); |
|
4158 TInt err = iClient->DefineContext ( co->Source ( ), co->Type ( ), KPassSec ); |
|
4159 EUNIT_ASSERT_DESC( err == KErrNone || err == KErrAlreadyExists, |
|
4160 "Define context failed" ); |
|
4161 |
|
4162 co->SetSourceL ( _L("test") ); |
|
4163 co->SetTypeL (_L("save.script.2") ); |
|
4164 err = iClient->DefineContext ( co->Source ( ), co->Type ( ), KPassSec ); |
|
4165 EUNIT_ASSERT_DESC( err == KErrNone || err == KErrAlreadyExists, |
|
4166 "Define context failed" ); |
|
4167 |
|
4168 err = iClient->DefineAction ( _L("saveScript"), KPassSec ); |
|
4169 EUNIT_ASSERT_DESC( err == KErrNone || err == KErrAlreadyExists, |
|
4170 "Define action failed" ); |
|
4171 |
|
4172 actionSubscription->SetActionIdentifierL ( _L("saveScript") ); |
|
4173 err = iClient->SubscribeAction ( *actionSubscription ); |
|
4174 EUNIT_ASSERT_DESC( err == KErrNone, "Subscribe action failed" ); |
|
4175 |
|
4176 TInt scriptId = KErrNotFound; |
|
4177 err = iClient->SaveScript ( |
|
4178 _L("z:\\data\\cftestdata\\testscripts\\test-saveScript.xml"), |
|
4179 scriptId ); |
|
4180 EUNIT_ASSERT_DESC( err == KErrNone, "Save script failed" ); |
|
4181 TBool exists = BaflUtils::FileExists ( iFs, |
|
4182 _L("c:\\private\\10282bc4\\rules\\20000fb1\\test-saveScript.rul") ); |
|
4183 EUNIT_ASSERT_DESC( exists, "Script not saved" ); |
|
4184 |
|
4185 err = iClient->SaveScript ( |
|
4186 _L("z:\\data\\cftestdata\\testscripts\\test-saveScript2.xml"), |
|
4187 scriptId ); |
|
4188 EUNIT_ASSERT_DESC( err == KErrNone, "Save script failed" ); |
|
4189 exists = BaflUtils::FileExists ( iFs, |
|
4190 _L("c:\\private\\10282bc4\\rules\\20000fb1\\test-saveScript2.rul") ); |
|
4191 EUNIT_ASSERT_DESC( exists, "Script not saved" ); |
|
4192 |
|
4193 // x. Delete script and check that action is not indicated |
|
4194 // ------------------------------------------------------------------------- |
|
4195 err = iClient->DeleteScript ( _L("test-saveScript") ); |
|
4196 EUNIT_ASSERT_DESC( err == KErrNone, "Delete script failed" ); |
|
4197 exists = BaflUtils::FileExists ( iFs, |
|
4198 _L("c:\\private\\10282bc4\\rules\\20000fb1\\test-saveScript.rul") ); |
|
4199 EUNIT_ASSERT_DESC( !exists, "Script not deleted" ); |
|
4200 |
|
4201 co->SetSourceL ( _L("test") ); |
|
4202 co->SetTypeL (_L("save.script") ); |
|
4203 co->SetValueL ( _L("trigger") ); |
|
4204 err = iClient->PublishContext ( *co ); |
|
4205 EUNIT_ASSERT_DESC( err == KErrNone, "Publish context failed" ); |
|
4206 iCheckCustomAction = ETrue; |
|
4207 iCustomActionId = _L("saveScript" ); |
|
4208 CCFKeyValuePair* keyValue = CCFKeyValuePair::NewLC ( _L("id"), _L("triggered") ); |
|
4209 iCustomActionParams.AppendL ( keyValue ); |
|
4210 CleanupStack::Pop ( keyValue ); |
|
4211 Wait ( KDelay ); |
|
4212 EUNIT_ASSERT_DESC( iCheckCustomAction, "Delete script failed" ); |
|
4213 |
|
4214 // x. Delete script and check that action is not indicated |
|
4215 // ------------------------------------------------------------------------- |
|
4216 err = iClient->DeleteScript ( _L("test-saveScript2") ); |
|
4217 EUNIT_ASSERT_DESC( err == KErrNone, "Delete script failed" ); |
|
4218 exists = BaflUtils::FileExists ( iFs, |
|
4219 _L("c:\\private\\10282bc4\\rules\\20000fb1\\test-saveScript2.rul") ); |
|
4220 EUNIT_ASSERT_DESC( !exists, "Script not deleted" ); |
|
4221 exists = BaflUtils::FolderExists ( iFs, _L("c:\\private\\10282bc4\\rules\\20000fb1\\") ); |
|
4222 EUNIT_ASSERT_DESC( !exists, "Delete script failed" ); |
|
4223 |
|
4224 co->SetSourceL ( _L("test") ); |
|
4225 co->SetTypeL (_L("save.script.2") ); |
|
4226 co->SetValueL ( _L("trigger") ); |
|
4227 err = iClient->PublishContext ( *co ); |
|
4228 EUNIT_ASSERT_DESC( err == KErrNone, "Publish context failed" ); |
|
4229 iCheckCustomAction = ETrue; |
|
4230 iCustomActionId = _L("saveScript" ); |
|
4231 keyValue = CCFKeyValuePair::NewLC ( _L("id"), _L("updateTriggered") ); |
|
4232 iCustomActionParams.AppendL ( keyValue ); |
|
4233 CleanupStack::Pop ( keyValue ); |
|
4234 Wait ( KDelay ); |
|
4235 EUNIT_ASSERT_DESC( iCheckCustomAction, "Delete script failed" ); |
|
4236 |
|
4237 // x. Delete script after a saved script has been deregistered |
|
4238 // ------------------------------------------------------------------------- |
|
4239 scriptId = KErrNotFound; |
|
4240 err = iClient->SaveScript( |
|
4241 _L("z:\\data\\cftestdata\\testscripts\\test-saveScript.xml"), |
|
4242 scriptId ); |
|
4243 EUNIT_ASSERT_DESC( err == KErrNone, "Save script failed" ); |
|
4244 exists = BaflUtils::FileExists ( iFs, |
|
4245 _L("c:\\private\\10282bc4\\rules\\20000fb1\\test-saveScript.rul") ); |
|
4246 EUNIT_ASSERT_DESC( exists, "Script not saved" ); |
|
4247 |
|
4248 err = iClient->DeregisterScript( scriptId ); |
|
4249 EUNIT_ASSERT_DESC( err == KErrNone, "Deregister script failed" ); |
|
4250 |
|
4251 co->SetSourceL ( _L("test") ); |
|
4252 co->SetTypeL (_L("save.script") ); |
|
4253 co->SetValueL ( _L("trigger") ); |
|
4254 err = iClient->PublishContext ( *co ); |
|
4255 EUNIT_ASSERT_DESC( err == KErrNone, "Publish context failed" ); |
|
4256 iCheckCustomAction = ETrue; |
|
4257 iCustomActionId = _L("saveScript" ); |
|
4258 keyValue = CCFKeyValuePair::NewLC( _L("id"), _L("triggered") ); |
|
4259 iCustomActionParams.AppendL ( keyValue ); |
|
4260 CleanupStack::Pop ( keyValue ); |
|
4261 Wait ( KDelay ); |
|
4262 EUNIT_ASSERT_DESC( iCheckCustomAction, "Deregister script failed" ); |
|
4263 |
|
4264 err = iClient->DeleteScript ( _L("test-saveScript") ); |
|
4265 EUNIT_ASSERT_DESC( err == KErrNone, "Delete script failed" ); |
|
4266 exists = BaflUtils::FileExists ( iFs, |
|
4267 _L("c:\\private\\10282bc4\\rules\\20000fb1\\test-saveScript.rul") ); |
|
4268 EUNIT_ASSERT_DESC( !exists, "Script not deleted" ); |
|
4269 |
|
4270 // x. Delete with incorrect parameters |
|
4271 // ------------------------------------------------------------------------- |
|
4272 err = iClient->DeleteScript ( KNullDesC ); |
|
4273 EUNIT_ASSERT_DESC( err == KErrArgument, "Delete script failed" ); |
|
4274 err = iClient->DeleteScript ( _L("test-saveScript") ); |
|
4275 EUNIT_ASSERT_DESC( err == KErrNotFound, "Delete script failed" ); |
|
4276 err = iClient->DeleteScript ( _L("test-saveScript2") ); |
|
4277 EUNIT_ASSERT_DESC( err == KErrNotFound, "Delete script failed" ); |
|
4278 err = iClient->DeleteScript ( _L("dummyScript") ); |
|
4279 EUNIT_ASSERT_DESC( err == KErrNotFound, "Delete script failed" ); |
|
4280 |
|
4281 // Clean up |
|
4282 // ------------------------------------------------------------------------- |
|
4283 CleanupStack::PopAndDestroy ( actionSubscription ); |
|
4284 CleanupStack::PopAndDestroy ( co ); |
|
4285 } |
|
4286 |
|
4287 void MT_CFClient::MT_CCFClient_DeleteScriptsL( ) |
|
4288 { |
|
4289 CCFContextObject* co = CCFContextObject::NewLC ( ); |
|
4290 CCFActionSubscription* actionSubscription = CCFActionSubscription::NewLC ( ); |
|
4291 |
|
4292 // Setup preconditions |
|
4293 // ------------------------------------------------------------------------- |
|
4294 co->SetSourceL ( _L("test") ); |
|
4295 co->SetTypeL (_L("save.script") ); |
|
4296 TInt err = iClient->DefineContext ( co->Source ( ), co->Type ( ), KPassSec ); |
|
4297 EUNIT_ASSERT_DESC( err == KErrNone || err == KErrAlreadyExists, |
|
4298 "Define context failed" ); |
|
4299 |
|
4300 co->SetSourceL ( _L("test") ); |
|
4301 co->SetTypeL (_L("save.script.2") ); |
|
4302 err = iClient->DefineContext ( co->Source ( ), co->Type ( ), KPassSec ); |
|
4303 EUNIT_ASSERT_DESC( err == KErrNone || err == KErrAlreadyExists, |
|
4304 "Define context failed" ); |
|
4305 |
|
4306 err = iClient->DefineAction ( _L("saveScript"), KPassSec ); |
|
4307 EUNIT_ASSERT_DESC( err == KErrNone || err == KErrAlreadyExists, |
|
4308 "Define action failed" ); |
|
4309 |
|
4310 actionSubscription->SetActionIdentifierL ( _L("saveScript") ); |
|
4311 err = iClient->SubscribeAction ( *actionSubscription ); |
|
4312 EUNIT_ASSERT_DESC( err == KErrNone, "Subscribe action failed" ); |
|
4313 |
|
4314 TInt scriptId = KErrNotFound; |
|
4315 err = iClient->SaveScript ( |
|
4316 _L("z:\\data\\cftestdata\\testscripts\\test-saveScript.xml"), |
|
4317 scriptId ); |
|
4318 EUNIT_ASSERT_DESC( err == KErrNone, "Save script failed" ); |
|
4319 TBool exists = BaflUtils::FileExists ( iFs, |
|
4320 _L("c:\\private\\10282bc4\\rules\\20000fb1\\test-saveScript.rul") ); |
|
4321 EUNIT_ASSERT_DESC( exists, "Script not saved" ); |
|
4322 |
|
4323 err = iClient->SaveScript ( |
|
4324 _L("z:\\data\\cftestdata\\testscripts\\test-saveScript2.xml"), |
|
4325 scriptId ); |
|
4326 EUNIT_ASSERT_DESC( err == KErrNone, "Save script failed" ); |
|
4327 exists = BaflUtils::FileExists ( iFs, |
|
4328 _L("c:\\private\\10282bc4\\rules\\20000fb1\\test-saveScript2.rul") ); |
|
4329 EUNIT_ASSERT_DESC( exists, "Script not saved" ); |
|
4330 |
|
4331 // x. Delete all scripts by uid |
|
4332 // ------------------------------------------------------------------------- |
|
4333 err = iClient->DeleteScripts ( ); |
|
4334 EUNIT_ASSERT_DESC( err == KErrNone, "Delete scripts failed" ); |
|
4335 |
|
4336 exists = BaflUtils::FileExists ( iFs, |
|
4337 _L("c:\\private\\10282bc4\\rules\\20000fb1\\test-saveScript.rul") ); |
|
4338 EUNIT_ASSERT_DESC( !exists, "Script not deleted" ); |
|
4339 exists = BaflUtils::FileExists ( iFs, |
|
4340 _L("c:\\private\\10282bc4\\rules\\20000fb1\\test-saveScript2.rul") ); |
|
4341 EUNIT_ASSERT_DESC( !exists, "Script not deleted" ); |
|
4342 exists = BaflUtils::FolderExists ( iFs, _L("c:\\private\\10282bc4\\rules\\20000fb1\\") ); |
|
4343 EUNIT_ASSERT_DESC( !exists, "Delete script failed" ); |
|
4344 |
|
4345 co->SetSourceL ( _L("test") ); |
|
4346 co->SetTypeL (_L("save.script") ); |
|
4347 co->SetValueL ( _L("trigger") ); |
|
4348 err = iClient->PublishContext ( *co ); |
|
4349 EUNIT_ASSERT_DESC( err == KErrNone, "Publish context failed" ); |
|
4350 iCheckCustomAction = ETrue; |
|
4351 iCustomActionId = _L("saveScript" ); |
|
4352 CCFKeyValuePair* keyValue = CCFKeyValuePair::NewLC ( _L("id"), _L("triggered") ); |
|
4353 iCustomActionParams.AppendL ( keyValue ); |
|
4354 CleanupStack::Pop ( keyValue ); |
|
4355 Wait ( KDelay ); |
|
4356 EUNIT_ASSERT_DESC( iCheckCustomAction, "Delete scripts failed" ); |
|
4357 |
|
4358 co->SetSourceL ( _L("test") ); |
|
4359 co->SetTypeL (_L("save.script.2") ); |
|
4360 co->SetValueL ( _L("trigger") ); |
|
4361 err = iClient->PublishContext ( *co ); |
|
4362 EUNIT_ASSERT_DESC( err == KErrNone, "Publish context failed" ); |
|
4363 iCheckCustomAction = ETrue; |
|
4364 iCustomActionId = _L("saveScript" ); |
|
4365 keyValue = CCFKeyValuePair::NewLC ( _L("id"), _L("updateTriggered") ); |
|
4366 iCustomActionParams.AppendL ( keyValue ); |
|
4367 CleanupStack::Pop ( keyValue ); |
|
4368 Wait ( KDelay ); |
|
4369 EUNIT_ASSERT_DESC( iCheckCustomAction, "Delete scripts failed" ); |
|
4370 |
|
4371 // x. Try to delete all scripts if none found |
|
4372 // ------------------------------------------------------------------------- |
|
4373 err = iClient->DeleteScripts ( ); |
|
4374 EUNIT_PRINT( _L("DeleteScrips: err = %d"), err ); |
|
4375 EUNIT_ASSERT_DESC( err == KErrNotFound, "Delete scripts failed" ); |
|
4376 |
|
4377 // Clean up |
|
4378 // ------------------------------------------------------------------------- |
|
4379 CleanupStack::PopAndDestroy ( actionSubscription ); |
|
4380 CleanupStack::PopAndDestroy ( co ); |
|
4381 } |
|
4382 |
|
4383 void MT_CFClient::MT_CCFClient_UpgradeRomScriptL( ) |
|
4384 { |
|
4385 CCFContextObject* co = CCFContextObject::NewLC ( ); |
|
4386 CCFActionSubscription* actionSubscription = CCFActionSubscription::NewLC ( ); |
|
4387 |
|
4388 // Setup preconditions |
|
4389 // ------------------------------------------------------------------------- |
|
4390 co->SetSourceL ( _L("test") ); |
|
4391 co->SetTypeL (_L("upgrade") ); |
|
4392 TInt err = iClient->DefineContext ( co->Source ( ), co->Type ( ), KPassSec ); |
|
4393 EUNIT_ASSERT_DESC( err == KErrNone || err == KErrAlreadyExists, |
|
4394 "Define context failed" ); |
|
4395 |
|
4396 err = iClient->DefineAction ( _L("romUpgrade"), KPassSec ); |
|
4397 EUNIT_ASSERT_DESC( err == KErrNone || err == KErrAlreadyExists, |
|
4398 "Define action failed" ); |
|
4399 |
|
4400 actionSubscription->SetActionIdentifierL ( _L("romUpgrade") ); |
|
4401 err = iClient->SubscribeAction ( *actionSubscription ); |
|
4402 EUNIT_ASSERT_DESC( err == KErrNone, "Subscribe action failed" ); |
|
4403 |
|
4404 // x. Upgrade 'test-scriptUpgradeRom' script and check that the script |
|
4405 // really is upgraded |
|
4406 // ------------------------------------------------------------------------- |
|
4407 |
|
4408 // Upgrade with file name |
|
4409 err = iClient->UpgradeRomScript ( |
|
4410 _L("z:\\data\\cftestdata\\testscripts\\test-scriptUpgradeRom.xml") ); |
|
4411 EUNIT_PRINT( _L("UpgradeRomScript: err = %d"), err ); |
|
4412 EUNIT_ASSERT_DESC( err == KErrNone, "Upgrade rom script failed" ); |
|
4413 |
|
4414 co->SetValueL ( _L("true") ); |
|
4415 err = iClient->PublishContext ( *co ); |
|
4416 EUNIT_ASSERT_DESC( err == KErrNone, "Publish context failed" ); |
|
4417 iCheckCustomAction = ETrue; |
|
4418 iCustomActionId = _L("romUpgrade" ); |
|
4419 CCFKeyValuePair* keyValue = CCFKeyValuePair::NewLC ( |
|
4420 _L("id"), _L("true") ); |
|
4421 iCustomActionParams.AppendL ( keyValue ); |
|
4422 CleanupStack::Pop ( keyValue ); |
|
4423 iWait->Start ( ); |
|
4424 |
|
4425 // Restore original rom script |
|
4426 err = iClient->RestoreRomScript ( _L("test-scriptUpgradeRom") ); |
|
4427 EUNIT_PRINT( _L("RestoreRomScript: err = %d"), err ); |
|
4428 EUNIT_ASSERT_DESC( err == KErrNone, "Restore script failed" ); |
|
4429 |
|
4430 // Upgrade with file name and script |
|
4431 HBufC8* script = LoadScriptFromFile ( _L("test-scriptUpgradeRom.xml") ); |
|
4432 EUNIT_ASSERT_DESC( script, "Script not loaded" ); |
|
4433 CleanupStack::PushL ( script ); |
|
4434 |
|
4435 err = iClient->UpgradeRomScript ( _L("test-scriptUpgradeRom"), *script ); |
|
4436 EUNIT_ASSERT_DESC( err == KErrNone, "Upgrade rom script failed" ); |
|
4437 |
|
4438 co->SetValueL ( _L("true") ); |
|
4439 err = iClient->PublishContext ( *co ); |
|
4440 EUNIT_ASSERT_DESC( err == KErrNone, "Publish context failed" ); |
|
4441 iCheckCustomAction = ETrue; |
|
4442 iCustomActionId = _L("romUpgrade" ); |
|
4443 keyValue = CCFKeyValuePair::NewLC ( _L("id"), _L("true") ); |
|
4444 iCustomActionParams.AppendL ( keyValue ); |
|
4445 CleanupStack::Pop ( keyValue ); |
|
4446 iWait->Start ( ); |
|
4447 |
|
4448 CleanupStack::PopAndDestroy ( script ); |
|
4449 |
|
4450 // Restore original rom script |
|
4451 err = iClient->RestoreRomScript ( _L("test-scriptUpgradeRom") ); |
|
4452 EUNIT_ASSERT_DESC( err == KErrNone, "Restore script failed" ); |
|
4453 |
|
4454 co->SetValueL ( _L("false") ); |
|
4455 err = iClient->PublishContext ( *co ); |
|
4456 EUNIT_ASSERT_DESC( err == KErrNone, "Publish context failed" ); |
|
4457 iCheckCustomAction = ETrue; |
|
4458 iCustomActionId = _L("romUpgrade" ); |
|
4459 keyValue = CCFKeyValuePair::NewLC ( _L("id"), _L("false") ); |
|
4460 iCustomActionParams.AppendL ( keyValue ); |
|
4461 CleanupStack::Pop ( keyValue ); |
|
4462 iWait->Start ( ); |
|
4463 |
|
4464 // x. Upgrade 'test-scriptUpgradeRom' script and check that the upgrade |
|
4465 // fails with KErrAccessDenied (script is missing capability) |
|
4466 // ------------------------------------------------------------------------- |
|
4467 script = LoadScriptFromFile ( _L("test-scriptUpgradeRomCapabilitiesMissing.xml") ); |
|
4468 EUNIT_ASSERT_DESC( script, "Script not loaded" ); |
|
4469 CleanupStack::PushL ( script ); |
|
4470 |
|
4471 err = iClient->UpgradeRomScript ( _L("test-scriptUpgradeRom"), *script ); |
|
4472 EUNIT_ASSERT_DESC( err == KErrAccessDenied, "Upgrade rom script failed" ); |
|
4473 |
|
4474 co->SetValueL ( _L("false") ); |
|
4475 err = iClient->PublishContext ( *co ); |
|
4476 EUNIT_ASSERT_DESC( err == KErrNone, "Publish context failed" ); |
|
4477 iCheckCustomAction = ETrue; |
|
4478 iCustomActionId = _L("romUpgrade" ); |
|
4479 keyValue = CCFKeyValuePair::NewLC ( _L("id"), _L("false") ); |
|
4480 iCustomActionParams.AppendL ( keyValue ); |
|
4481 CleanupStack::Pop ( keyValue ); |
|
4482 iWait->Start ( ); |
|
4483 |
|
4484 CleanupStack::PopAndDestroy( script ); |
|
4485 |
|
4486 // x. Upgrade 'test-scriptUpgradeRom' script and check that the upgrade |
|
4487 // fails with KErrAccessDenied (script is missing upgrade security) |
|
4488 // ------------------------------------------------------------------------- |
|
4489 script = LoadScriptFromFile ( _L("test-scriptUpgradeRomNoUpgradeSecurity.xml") ); |
|
4490 EUNIT_ASSERT_DESC( script, "Script not loaded" ); |
|
4491 CleanupStack::PushL ( script ); |
|
4492 |
|
4493 err = iClient->UpgradeRomScript ( _L("test-scriptUpgradeRom"), *script ); |
|
4494 EUNIT_ASSERT_DESC( err == KErrAccessDenied, "Upgrade rom script failed" ); |
|
4495 |
|
4496 co->SetValueL ( _L("false") ); |
|
4497 err = iClient->PublishContext ( *co ); |
|
4498 EUNIT_ASSERT_DESC( err == KErrNone, "Publish context failed" ); |
|
4499 iCheckCustomAction = ETrue; |
|
4500 iCustomActionId = _L("romUpgrade" ); |
|
4501 keyValue = CCFKeyValuePair::NewLC ( _L("id"), _L("false") ); |
|
4502 iCustomActionParams.AppendL ( keyValue ); |
|
4503 CleanupStack::Pop ( keyValue ); |
|
4504 iWait->Start ( ); |
|
4505 |
|
4506 CleanupStack::PopAndDestroy( script ); |
|
4507 |
|
4508 // x. Upgrade 'test-scriptUpgradeRom' script and check that the upgrade |
|
4509 // fails with KErrAccessDenied (client is missing capabilities) |
|
4510 // ------------------------------------------------------------------------- |
|
4511 script = LoadScriptFromFile ( _L("test-scriptUpgradeRom.xml") ); |
|
4512 EUNIT_ASSERT_DESC( script, "Script not loaded" ); |
|
4513 CleanupStack::PushL ( script ); |
|
4514 |
|
4515 err = iClient->UpgradeRomScript ( |
|
4516 _L("test-scriptUpgradeRomClientMissingCapability"), *script ); |
|
4517 EUNIT_ASSERT_DESC( err == KErrAccessDenied, "Upgrade rom script failed" ); |
|
4518 |
|
4519 co->SetValueL ( _L("false") ); |
|
4520 err = iClient->PublishContext ( *co ); |
|
4521 EUNIT_ASSERT_DESC( err == KErrNone, "Publish context failed" ); |
|
4522 iCheckCustomAction = ETrue; |
|
4523 iCustomActionId = _L("romUpgrade" ); |
|
4524 keyValue = CCFKeyValuePair::NewLC ( _L("id"), _L("false") ); |
|
4525 iCustomActionParams.AppendL ( keyValue ); |
|
4526 CleanupStack::Pop ( keyValue ); |
|
4527 iWait->Start ( ); |
|
4528 |
|
4529 CleanupStack::PopAndDestroy( script ); |
|
4530 |
|
4531 // Clean up |
|
4532 // ------------------------------------------------------------------------- |
|
4533 CleanupStack::PopAndDestroy ( actionSubscription ); |
|
4534 CleanupStack::PopAndDestroy ( co ); |
|
4535 } |
|
4536 |
|
4537 void MT_CFClient::MT_CCFClient_RestoreRomScriptL( ) |
|
4538 { |
|
4539 CCFContextObject* co = CCFContextObject::NewLC ( ); |
|
4540 CCFActionSubscription* actionSubscription = CCFActionSubscription::NewLC ( ); |
|
4541 |
|
4542 // Setup preconditions |
|
4543 // ------------------------------------------------------------------------- |
|
4544 co->SetSourceL ( _L("test") ); |
|
4545 co->SetTypeL (_L("upgrade") ); |
|
4546 TInt err = iClient->DefineContext ( co->Source ( ), co->Type ( ), KPassSec ); |
|
4547 EUNIT_ASSERT_DESC( err == KErrNone || err == KErrAlreadyExists, |
|
4548 "Define context failed" ); |
|
4549 |
|
4550 err = iClient->DefineAction ( _L("romUpgrade"), KPassSec ); |
|
4551 EUNIT_ASSERT_DESC( err == KErrNone || err == KErrAlreadyExists, |
|
4552 "Define action failed" ); |
|
4553 |
|
4554 actionSubscription->SetActionIdentifierL ( _L("romUpgrade") ); |
|
4555 err = iClient->SubscribeAction ( *actionSubscription ); |
|
4556 EUNIT_ASSERT_DESC( err == KErrNone, "Subscribe action failed" ); |
|
4557 |
|
4558 // x. Check that rom script is currently registered |
|
4559 // ------------------------------------------------------------------------- |
|
4560 co->SetValueL ( _L("false") ); |
|
4561 err = iClient->PublishContext ( *co ); |
|
4562 EUNIT_ASSERT_DESC( err == KErrNone, "Publish context failed" ); |
|
4563 iCheckCustomAction = ETrue; |
|
4564 iCustomActionId = _L("romUpgrade" ); |
|
4565 CCFKeyValuePair* keyValue = CCFKeyValuePair::NewLC( _L("id"), _L("false") ); |
|
4566 iCustomActionParams.AppendL ( keyValue ); |
|
4567 CleanupStack::Pop ( keyValue ); |
|
4568 iWait->Start ( ); |
|
4569 |
|
4570 // x. Upgrade rom script and check, restore rom script and check |
|
4571 // ------------------------------------------------------------------------- |
|
4572 err = iClient->UpgradeRomScript ( |
|
4573 _L("z:\\data\\cftestdata\\testscripts\\test-scriptUpgradeRom.xml") ); |
|
4574 EUNIT_PRINT( _L("UpgradeRomScript: err = %d"), err ); |
|
4575 EUNIT_ASSERT_DESC( err == KErrNone, "Upgrade rom script failed" ); |
|
4576 |
|
4577 co->SetValueL ( _L("true") ); |
|
4578 err = iClient->PublishContext ( *co ); |
|
4579 EUNIT_ASSERT_DESC( err == KErrNone, "Publish context failed" ); |
|
4580 iCheckCustomAction = ETrue; |
|
4581 iCustomActionId = _L("romUpgrade" ); |
|
4582 keyValue = CCFKeyValuePair::NewLC ( _L("id"), _L("true") ); |
|
4583 iCustomActionParams.AppendL ( keyValue ); |
|
4584 CleanupStack::Pop ( keyValue ); |
|
4585 iWait->Start ( ); |
|
4586 |
|
4587 TBool exists = BaflUtils::FileExists ( iFs, |
|
4588 _L("c:\\private\\10282bc4\\rules\\test-scriptUpgradeRom.rul") ); |
|
4589 EUNIT_ASSERT_DESC( exists, "Script upgrade not found" ); |
|
4590 |
|
4591 err = iClient->RestoreRomScript ( _L("test-scriptUpgradeRom") ); |
|
4592 EUNIT_PRINT( _L("RestoreRomScript: err = %d"), err ); |
|
4593 EUNIT_ASSERT_DESC( err == KErrNone, "Restore script failed" ); |
|
4594 co->SetValueL ( _L("false") ); |
|
4595 err = iClient->PublishContext ( *co ); |
|
4596 EUNIT_ASSERT_DESC( err == KErrNone, "Publish context failed" ); |
|
4597 iCheckCustomAction = ETrue; |
|
4598 iCustomActionId = _L("romUpgrade" ); |
|
4599 keyValue = CCFKeyValuePair::NewLC ( _L("id"), _L("false") ); |
|
4600 iCustomActionParams.AppendL ( keyValue ); |
|
4601 CleanupStack::Pop ( keyValue ); |
|
4602 iWait->Start ( ); |
|
4603 |
|
4604 exists = BaflUtils::FileExists ( iFs, |
|
4605 _L("c:\\private\\10282bc4\\rules\\test-scriptUpgradeRom.rul") ); |
|
4606 EUNIT_ASSERT_DESC( !exists, "Script upgrade not deleted" ); |
|
4607 |
|
4608 // x. Try to restore a script which does not exist |
|
4609 // ------------------------------------------------------------------------- |
|
4610 err = iClient->RestoreRomScript ( _L("dummyRomScript") ); |
|
4611 EUNIT_ASSERT_DESC( err == KErrNotFound, "Restore script failed" ); |
|
4612 |
|
4613 // Clean up |
|
4614 // ------------------------------------------------------------------------- |
|
4615 CleanupStack::PopAndDestroy ( actionSubscription ); |
|
4616 CleanupStack::PopAndDestroy ( co ); |
|
4617 } |
|
4618 |
|
4619 void MT_CFClient::MT_CCFClient_OperationUnsubscribingL() |
|
4620 { |
|
4621 // Define context |
|
4622 CCFContextObject* co1 = CCFContextObject::NewLC(); |
|
4623 co1->SetSourceL(_L("Test")); |
|
4624 co1->SetTypeL(_L("Counting")); |
|
4625 TInt err = iClient->DefineContext( co1->Source(), co1->Type(), KPassSec ); |
|
4626 EUNIT_ASSERT_DESC( ( err == KErrNone || err == KErrAlreadyExists ), |
|
4627 "DefineContext failed!" ); |
|
4628 |
|
4629 // Define actions |
|
4630 err = iClient->DefineAction( _L("testAction"), KPassSec ); |
|
4631 EUNIT_ASSERT_DESC( ( err == KErrNone || err == KErrAlreadyExists ), |
|
4632 "Incorrect DefineAction return value!" ); |
|
4633 err = iClient->DefineAction( _L("testAction2"), KPassSec ); |
|
4634 EUNIT_ASSERT_DESC( ( err == KErrNone || err == KErrAlreadyExists ), |
|
4635 "Incorrect DefineAction return value!" ); |
|
4636 |
|
4637 // Subscribe both actions |
|
4638 CCFActionSubscription* actionSub = CCFActionSubscription::NewLC(); |
|
4639 actionSub->SetActionIdentifierL ( _L("testAction") ); |
|
4640 err = iClient->SubscribeAction ( *actionSub ); |
|
4641 EUNIT_ASSERT_DESC( err == KErrNone, "Incorrect SubscribeAction return value!" ); |
|
4642 |
|
4643 CCFActionSubscription* actionSub2 = CCFActionSubscription::NewLC(); |
|
4644 actionSub2->SetActionIdentifierL ( _L("testAction2") ); |
|
4645 err = iClient->SubscribeAction ( *actionSub2 ); |
|
4646 EUNIT_ASSERT_DESC( err == KErrNone, "Incorrect SubscribeAction return value!" ); |
|
4647 |
|
4648 DeleteLastActionId(); |
|
4649 |
|
4650 // Publish context before loading so that subscribing will find the initial |
|
4651 // value used to evaluate the operation |
|
4652 co1->SetValueL(_L("A")); |
|
4653 err = iClient->PublishContext( *co1 ); |
|
4654 EUNIT_ASSERT_DESC( err == KErrNone, "PublishContext failed!" ); |
|
4655 |
|
4656 EUNIT_ASSERT_DESC( !iLastActionId, "Action received although script not registered!" ); |
|
4657 |
|
4658 // Register script1 |
|
4659 TInt scriptId1; |
|
4660 err = iClient->RegisterScript ( |
|
4661 _L("z:\\data\\cftestdata\\testscripts\\test-countOneShotWithoutValue.xml"), |
|
4662 scriptId1 ); |
|
4663 EUNIT_ASSERT_DESC( err == KErrNone, "Error when registering script!" ); |
|
4664 EUNIT_ASSERT_DESC( scriptId1 >= 0, "Parse error!" ); |
|
4665 |
|
4666 // Register script2 |
|
4667 TInt scriptId2; |
|
4668 err = iClient->RegisterScript ( |
|
4669 _L("z:\\data\\cftestdata\\testscripts\\test-countOneShotWithoutValue2.xml"), |
|
4670 scriptId2 ); |
|
4671 EUNIT_ASSERT_DESC( err == KErrNone, "Error when registering script!" ); |
|
4672 EUNIT_ASSERT_DESC( scriptId2 >= scriptId1, "Parse error!" ); |
|
4673 |
|
4674 EUNIT_ASSERT_DESC( !iLastActionId, "Action should not have been received!" ); |
|
4675 |
|
4676 // Publish COUNTED context, no event should come |
|
4677 co1->SetValueL(_L("B")); |
|
4678 err = iClient->PublishContext( *co1 ); |
|
4679 EUNIT_ASSERT_DESC( err == KErrNone, "PublishContext failed!" ); |
|
4680 EUNIT_ASSERT_DESC( !iLastActionId, "Action should not have been received!" ); |
|
4681 |
|
4682 // Publish COUNTED context, event MUST come |
|
4683 co1->SetValueL(_L("A")); |
|
4684 err = iClient->PublishContext( *co1 ); |
|
4685 EUNIT_ASSERT_DESC( err == KErrNone, "PublishContext failed!" ); |
|
4686 iWait->Start(); |
|
4687 EUNIT_ASSERT_DESC( LastActionIdEquals( _L("testAction")), |
|
4688 "Script did not cause event!" ); |
|
4689 |
|
4690 DeleteLastActionId(); |
|
4691 |
|
4692 // Publish COUNTED context, event MUST come |
|
4693 co1->SetValueL(_L("B")); |
|
4694 err = iClient->PublishContext( *co1 ); |
|
4695 EUNIT_ASSERT_DESC( err == KErrNone, "PublishContext failed!" ); |
|
4696 iWait->Start(); |
|
4697 EUNIT_ASSERT_DESC( LastActionIdEquals( _L("testAction2")), |
|
4698 "Script did not cause event!" ); |
|
4699 |
|
4700 DeleteLastActionId(); |
|
4701 |
|
4702 // Publish COUNTED context, no event should come |
|
4703 co1->SetValueL(_L("A")); |
|
4704 err = iClient->PublishContext( *co1 ); |
|
4705 EUNIT_ASSERT_DESC( err == KErrNone, "PublishContext failed!" ); |
|
4706 EUNIT_ASSERT_DESC( !iLastActionId, "Action should not have been received!" ); |
|
4707 |
|
4708 // Publish COUNTED context, no event should come |
|
4709 co1->SetValueL(_L("B")); |
|
4710 err = iClient->PublishContext( *co1 ); |
|
4711 EUNIT_ASSERT_DESC( err == KErrNone, "PublishContext failed!" ); |
|
4712 EUNIT_ASSERT_DESC( !iLastActionId, "Action should not have been received!" ); |
|
4713 |
|
4714 // Publish COUNTED context, no event should come |
|
4715 co1->SetValueL(_L("A")); |
|
4716 err = iClient->PublishContext( *co1 ); |
|
4717 EUNIT_ASSERT_DESC( err == KErrNone, "PublishContext failed!" ); |
|
4718 EUNIT_ASSERT_DESC( !iLastActionId, "Action should not have been received!" ); |
|
4719 |
|
4720 // Publish COUNTED context, no event should come |
|
4721 co1->SetValueL(_L("B")); |
|
4722 err = iClient->PublishContext( *co1 ); |
|
4723 EUNIT_ASSERT_DESC( err == KErrNone, "PublishContext failed!" ); |
|
4724 EUNIT_ASSERT_DESC( !iLastActionId, "Action should not have been received!" ); |
|
4725 |
|
4726 // Publish COUNTED context, no event should come |
|
4727 co1->SetValueL(_L("A")); |
|
4728 err = iClient->PublishContext( *co1 ); |
|
4729 EUNIT_ASSERT_DESC( err == KErrNone, "PublishContext failed!" ); |
|
4730 EUNIT_ASSERT_DESC( !iLastActionId, "Action should not have been received!" ); |
|
4731 |
|
4732 CleanupStack::PopAndDestroy( actionSub2 ); |
|
4733 CleanupStack::PopAndDestroy( actionSub ); |
|
4734 CleanupStack::PopAndDestroy( co1 ); |
|
4735 |
|
4736 err = iClient->DeregisterScript ( scriptId1 ); |
|
4737 EUNIT_ASSERT_DESC( err == KErrNone, "Deregistering script caused error!" ); |
|
4738 err = iClient->DeregisterScript ( scriptId2 ); |
|
4739 EUNIT_ASSERT_DESC( err == KErrNone, "Deregistering script caused error!" ); |
|
4740 } |
|
4741 |
|
4742 void MT_CFClient::MT_CCFClient_RomScriptContextAutoDefineL() |
|
4743 { |
|
4744 // x. Preconditions |
|
4745 //-------------------------------------------------------------------------- |
|
4746 CCFContextObject* co = CCFContextObject::NewLC(); |
|
4747 CCFContextSubscription* subscription = CCFContextSubscription::NewLC(); |
|
4748 _LIT_SECURITY_POLICY_PASS( alwaysPass ); |
|
4749 |
|
4750 // x. Subscribe context which has not been defined and check |
|
4751 // that a context indication is received. |
|
4752 //-------------------------------------------------------------------------- |
|
4753 |
|
4754 // Subscribe context: |
|
4755 // source.romPublishContext |
|
4756 // type.romPublishContext.reply |
|
4757 subscription->SetContextSourceL( _L("source.romPublishContext") ); |
|
4758 subscription->SetContextTypeL( _L("type.romPublishContext.reply") ); |
|
4759 TInt err = iClient->SubscribeContext( *subscription ); |
|
4760 EUNIT_ASSERT_DESC( err == KErrNone, "Subscribe context failed!" ); |
|
4761 |
|
4762 // Define and publish context: |
|
4763 // source.romPublishContext |
|
4764 // type.romPublishContext |
|
4765 // true |
|
4766 err = iClient->DefineContext( |
|
4767 _L("source.romPublishContext"), |
|
4768 _L("type.romPublishContext"), |
|
4769 alwaysPass ); |
|
4770 EUNIT_ASSERT_DESC( err == KErrNone, "Define context failed!" ); |
|
4771 |
|
4772 co->SetSourceL( _L("source.romPublishContext") ); |
|
4773 co->SetTypeL( _L("type.romPublishContext") ); |
|
4774 co->SetValueL( _L("true") ); |
|
4775 err = iClient->PublishContext( *co ); |
|
4776 EUNIT_ASSERT_DESC( err == KErrNone, "Publish context failed!" ); |
|
4777 |
|
4778 // Wait for context indication, this should not happen |
|
4779 iCheckA = ETrue; |
|
4780 iContextA->SetSourceL( _L("source.romPublishContext") ); |
|
4781 iContextA->SetTypeL( _L("type.romPublishContext.reply") ); |
|
4782 iContextA->SetValueL( _L("true") ); |
|
4783 Wait( KSecond * 2 ); |
|
4784 EUNIT_ASSERT_DESC( iCheckA, "Context indication received!" ); |
|
4785 |
|
4786 // Double check that context is not defined: |
|
4787 // source.romPublishContext |
|
4788 // type.romPublishContext.reply |
|
4789 co->SetSourceL( _L("source.romPublishContext") ); |
|
4790 co->SetTypeL( _L("type.romPublishContext.reply") ); |
|
4791 co->SetValueL( _L("false") ); |
|
4792 err = iClient->PublishContext( *co ); |
|
4793 EUNIT_ASSERT_DESC( err == KErrNotFound, "Undefined context was published!" ); |
|
4794 |
|
4795 // x. Register script with auto define context, this should fail since the |
|
4796 // context is not auto defined. |
|
4797 //-------------------------------------------------------------------------- |
|
4798 HBufC8* script = LoadScriptFromFile( _L("test-romPublishContext.xml") ); |
|
4799 EUNIT_ASSERT_DESC( script, "Unable to load script 'test-romPublishContext.xml'!" ); |
|
4800 TInt scriptId( KErrNotFound ); |
|
4801 err = iClient->RegisterScript( _L("client-test-romPublishContext.xml"), |
|
4802 *script, scriptId ); |
|
4803 EUNIT_ASSERT_DESC( err == KErrNotFound, "Script register should fail with code KErrNotFound!" ); |
|
4804 EUNIT_ASSERT_DESC( scriptId == KErrNotFound, "Incorrect script ID!" ); |
|
4805 delete script; |
|
4806 |
|
4807 // x. Clean up |
|
4808 //-------------------------------------------------------------------------- |
|
4809 CleanupStack::PopAndDestroy( subscription ); |
|
4810 CleanupStack::PopAndDestroy( co ); |
|
4811 } |
|
4812 |
|
4813 void MT_CFClient::MT_CCFClient_RomScriptContextAutoDefine2L() |
|
4814 { |
|
4815 // x. Preconditions |
|
4816 //-------------------------------------------------------------------------- |
|
4817 CCFContextObject* co = CCFContextObject::NewLC(); |
|
4818 CCFContextSubscription* subscription = CCFContextSubscription::NewLC(); |
|
4819 _LIT_SECURITY_POLICY_PASS( alwaysPass ); |
|
4820 |
|
4821 // x. Subscribe context which has not been defined and check |
|
4822 // that a context indication is received. |
|
4823 //-------------------------------------------------------------------------- |
|
4824 |
|
4825 // Subscribe context: |
|
4826 // source.romPublishContext2 |
|
4827 // type.romPublishContext2.reply |
|
4828 subscription->SetContextSourceL( _L("source.romPublishContext2") ); |
|
4829 subscription->SetContextTypeL( _L("type.romPublishContext2.reply") ); |
|
4830 TInt err = iClient->SubscribeContext( *subscription ); |
|
4831 EUNIT_ASSERT_DESC( err == KErrNone, "Subscribe context failed!" ); |
|
4832 |
|
4833 // Define and publish context: |
|
4834 // source.romPublishContext2 |
|
4835 // type.romPublishContext2 |
|
4836 // true |
|
4837 err = iClient->DefineContext( |
|
4838 _L("source.romPublishContext2"), |
|
4839 _L("type.romPublishContext2"), |
|
4840 alwaysPass ); |
|
4841 EUNIT_ASSERT_DESC( err == KErrNone, "Define context failed!" ); |
|
4842 |
|
4843 co->SetSourceL( _L("source.romPublishContext2") ); |
|
4844 co->SetTypeL( _L("type.romPublishContext2") ); |
|
4845 co->SetValueL( _L("true") ); |
|
4846 err = iClient->PublishContext( *co ); |
|
4847 EUNIT_ASSERT_DESC( err == KErrNone, "Publish context failed!" ); |
|
4848 |
|
4849 // Wait for context indication |
|
4850 iCheckA = ETrue; |
|
4851 iContextA->SetSourceL( _L("source.romPublishContext2") ); |
|
4852 iContextA->SetTypeL( _L("type.romPublishContext2.reply") ); |
|
4853 iContextA->SetValueL( _L("true") ); |
|
4854 Wait( KSecond * 2 ); |
|
4855 EUNIT_ASSERT_DESC( !iCheckA, "Context indication not received!" ); |
|
4856 |
|
4857 // Double check that context is defined: |
|
4858 // source.romPublishContext2 |
|
4859 // type.romPublishContext2.reply |
|
4860 err = iClient->DefineContext( |
|
4861 _L("source.romPublishContext2"), |
|
4862 _L("type.romPublishContext2.reply"), |
|
4863 alwaysPass ); |
|
4864 EUNIT_ASSERT_DESC( err == KErrAlreadyExists, "Define context should fail with code KErrAlreadyExists!" ); |
|
4865 |
|
4866 // x. Register script with auto define context, this should fail with KErrPermissionDenied |
|
4867 // since the client can only read (subscribe) the context which is auto defined. |
|
4868 //-------------------------------------------------------------------------- |
|
4869 HBufC8* script = LoadScriptFromFile( _L("test-romPublishContext2.xml") ); |
|
4870 CleanupStack::PushL( script ); |
|
4871 EUNIT_ASSERT_DESC( script, "Unable to load script 'test-romPublishContext2.xml'!" ); |
|
4872 TInt scriptId( KErrNotFound ); |
|
4873 err = iClient->RegisterScript( _L("client-test-romPublishContext2.xml"), |
|
4874 *script, scriptId ); |
|
4875 EUNIT_PRINT( _L("RegisterScript completed with code: %d"), err ); |
|
4876 EUNIT_ASSERT_DESC( err == KErrPermissionDenied, "Script register should fail with code KErrPermissionDenied!" ); |
|
4877 EUNIT_ASSERT_DESC( scriptId == KErrNotFound, "Incorrect script ID!" ); |
|
4878 CleanupStack::PopAndDestroy( script ); |
|
4879 |
|
4880 // x. Clean up |
|
4881 //-------------------------------------------------------------------------- |
|
4882 CleanupStack::PopAndDestroy( subscription ); |
|
4883 CleanupStack::PopAndDestroy( co ); |
|
4884 } |
|
4885 |
|
4886 void MT_CFClient::MT_CCFClient_RomScriptContextAutoDefine3L() |
|
4887 { |
|
4888 // x. Preconditions |
|
4889 //-------------------------------------------------------------------------- |
|
4890 CCFContextObject* co = CCFContextObject::NewLC(); |
|
4891 CCFContextSubscription* subscription = CCFContextSubscription::NewLC(); |
|
4892 _LIT_SECURITY_POLICY_PASS( alwaysPass ); |
|
4893 |
|
4894 // x. Subscribe context which has not been defined and check |
|
4895 // that a context indication is received. |
|
4896 //-------------------------------------------------------------------------- |
|
4897 |
|
4898 // Subscribe context: |
|
4899 // source.romPublishContext3 |
|
4900 // type.romPublishContext3.reply |
|
4901 subscription->SetContextSourceL( _L("source.romPublishContext3") ); |
|
4902 subscription->SetContextTypeL( _L("type.romPublishContext3.reply") ); |
|
4903 TInt err = iClient->SubscribeContext( *subscription ); |
|
4904 EUNIT_ASSERT_DESC( err == KErrNone, "Subscribe context failed!" ); |
|
4905 |
|
4906 // Define and publish context: |
|
4907 // source.romPublishContext3 |
|
4908 // type.romPublishContext3 |
|
4909 // true |
|
4910 err = iClient->DefineContext( |
|
4911 _L("source.romPublishContext3"), |
|
4912 _L("type.romPublishContext3"), |
|
4913 alwaysPass ); |
|
4914 EUNIT_ASSERT_DESC( err == KErrNone, "Define context failed!" ); |
|
4915 |
|
4916 co->SetSourceL( _L("source.romPublishContext3") ); |
|
4917 co->SetTypeL( _L("type.romPublishContext3") ); |
|
4918 co->SetValueL( _L("true") ); |
|
4919 err = iClient->PublishContext( *co ); |
|
4920 EUNIT_ASSERT_DESC( err == KErrNone, "Publish context failed!" ); |
|
4921 |
|
4922 // Wait for context indication, this should not happen |
|
4923 iCheckA = ETrue; |
|
4924 iContextA->SetSourceL( _L("source.romPublishContext3") ); |
|
4925 iContextA->SetTypeL( _L("type.romPublishContext3.reply") ); |
|
4926 iContextA->SetValueL( _L("true") ); |
|
4927 Wait( KSecond * 2 ); |
|
4928 EUNIT_ASSERT_DESC( iCheckA, "Context indication received!" ); |
|
4929 |
|
4930 // Double check that context is not defined: |
|
4931 // source.romPublishContext3 |
|
4932 // type.romPublishContext3.reply |
|
4933 co->SetSourceL( _L("source.romPublishContext3") ); |
|
4934 co->SetTypeL( _L("type.romPublishContext3.reply") ); |
|
4935 co->SetValueL( _L("false") ); |
|
4936 err = iClient->PublishContext( *co ); |
|
4937 EUNIT_ASSERT_DESC( err == KErrNotFound, "Undefined context was published!" ); |
|
4938 |
|
4939 // x. Register script with auto define context, this should fail since the |
|
4940 // context is not auto defined. |
|
4941 //-------------------------------------------------------------------------- |
|
4942 HBufC8* script = LoadScriptFromFile( _L("test-romPublishContext3.xml") ); |
|
4943 CleanupStack::PushL( script ); |
|
4944 EUNIT_ASSERT_DESC( script, "Unable to load script 'test-romPublishContext3.xml'!" ); |
|
4945 TInt scriptId( KErrNotFound ); |
|
4946 err = iClient->RegisterScript( _L("client-test-romPublishContext3.xml"), |
|
4947 *script, scriptId ); |
|
4948 EUNIT_ASSERT_DESC( err == KErrNotFound, "Script register should fail with code KErrNotFound!" ); |
|
4949 EUNIT_ASSERT_DESC( scriptId == KErrNotFound, "Incorrect script ID!" ); |
|
4950 CleanupStack::PopAndDestroy( script ); |
|
4951 |
|
4952 // x. Clean up |
|
4953 //-------------------------------------------------------------------------- |
|
4954 CleanupStack::PopAndDestroy( subscription ); |
|
4955 CleanupStack::PopAndDestroy( co ); |
|
4956 } |
|
4957 |
|
4958 void MT_CFClient::MT_CCFClient_RomScriptContextAutoDefine4L() |
|
4959 { |
|
4960 // x. Preconditions |
|
4961 //-------------------------------------------------------------------------- |
|
4962 CCFContextObject* co = CCFContextObject::NewLC(); |
|
4963 CCFContextSubscription* subscription = CCFContextSubscription::NewLC(); |
|
4964 _LIT_SECURITY_POLICY_PASS( alwaysPass ); |
|
4965 |
|
4966 // x. Publish a context which triggers a publishContext action from a test-romPublishContext4.xml |
|
4967 // which will auto define a context. test-romPublishContext5.xml rule file |
|
4968 // has subscribed to this context. |
|
4969 // A new context is auto defined from test-romPublishContext4.xml |
|
4970 // which is subscribed by this test case. |
|
4971 // Check that the context indication is received. |
|
4972 //-------------------------------------------------------------------------- |
|
4973 |
|
4974 // Subscribe context: |
|
4975 // source.romPublishContext5 |
|
4976 // type.romPublishContext5.reply |
|
4977 subscription->SetContextSourceL( _L("source.romPublishContext5") ); |
|
4978 subscription->SetContextTypeL( _L("type.romPublishContext5.reply") ); |
|
4979 TInt err = iClient->SubscribeContext( *subscription ); |
|
4980 EUNIT_ASSERT_DESC( err == KErrNone, "Subscribe context failed!" ); |
|
4981 |
|
4982 // Define and publish context: |
|
4983 // source.romPublishContext4 |
|
4984 // type.romPublishContext4 |
|
4985 // true |
|
4986 err = iClient->DefineContext( |
|
4987 _L("source.romPublishContext4"), |
|
4988 _L("type.romPublishContext4"), |
|
4989 alwaysPass ); |
|
4990 EUNIT_ASSERT_DESC( err == KErrNone || err == KErrAlreadyExists, "Define context failed!" ); |
|
4991 |
|
4992 co->SetSourceL( _L("source.romPublishContext4") ); |
|
4993 co->SetTypeL( _L("type.romPublishContext4") ); |
|
4994 co->SetValueL( _L("true") ); |
|
4995 err = iClient->PublishContext( *co ); |
|
4996 EUNIT_ASSERT_DESC( err == KErrNone, "Define context failed!" ); |
|
4997 |
|
4998 // Wait for context indication |
|
4999 iCheckA = ETrue; |
|
5000 iContextA->SetSourceL( _L("source.romPublishContext5") ); |
|
5001 iContextA->SetTypeL( _L("type.romPublishContext5.reply") ); |
|
5002 iContextA->SetValueL( _L("true") ); |
|
5003 Wait( KSecond * 2 ); |
|
5004 EUNIT_ASSERT_DESC( !iCheckA, "Context indication not received!" ); |
|
5005 |
|
5006 // x. Register scripts with auto define context, this should fail since the |
|
5007 // client can only read (subscribe) the auto defined context. |
|
5008 //-------------------------------------------------------------------------- |
|
5009 HBufC8* script = LoadScriptFromFile( _L("test-romPublishContext4.xml") ); |
|
5010 CleanupStack::PushL( script ); |
|
5011 EUNIT_ASSERT_DESC( script, "Unable to load script 'test-romPublishContext4.xml'!" ); |
|
5012 TInt scriptId( KErrNotFound ); |
|
5013 err = iClient->RegisterScript( _L("client-test-romPublishContext4.xml"), |
|
5014 *script, scriptId ); |
|
5015 EUNIT_ASSERT_DESC( err == KErrPermissionDenied, "Script register should fail with code KErrPermissionDenied!" ); |
|
5016 EUNIT_ASSERT_DESC( scriptId == KErrNotFound, "Incorrect script ID!" ); |
|
5017 CleanupStack::PopAndDestroy( script ); |
|
5018 |
|
5019 script = LoadScriptFromFile( _L("test-romPublishContext5.xml") ); |
|
5020 CleanupStack::PushL( script ); |
|
5021 EUNIT_ASSERT_DESC( script, "Unable to load script 'test-romPublishContext5.xml'!" ); |
|
5022 scriptId = KErrNotFound; |
|
5023 err = iClient->RegisterScript( _L("client-test-romPublishContext5.xml"), |
|
5024 *script, scriptId ); |
|
5025 EUNIT_ASSERT_DESC( err == KErrPermissionDenied, "Script register should fail with code KErrPermissionDenied!" ); |
|
5026 EUNIT_ASSERT_DESC( scriptId == KErrNotFound, "Incorrect script ID!" ); |
|
5027 CleanupStack::PopAndDestroy( script ); |
|
5028 |
|
5029 // x. Clean up |
|
5030 //-------------------------------------------------------------------------- |
|
5031 CleanupStack::PopAndDestroy( subscription ); |
|
5032 CleanupStack::PopAndDestroy( co ); |
|
5033 } |
|
5034 |
|
5035 // TEST TABLE |
|
5036 |
|
5037 EUNIT_BEGIN_TEST_TABLE( |
|
5038 MT_CFClient, |
|
5039 "CFClient module test.", |
|
5040 "MODULE" ) |
|
5041 |
|
5042 EUNIT_TEST( |
|
5043 "NewL - test ", |
|
5044 "CCFClient", |
|
5045 "NewL", |
|
5046 "FUNCTIONALITY", |
|
5047 SetupL, MT_CCFClient_NewLL, Teardown) |
|
5048 |
|
5049 EUNIT_TEST( |
|
5050 "NewLC - test ", |
|
5051 "CCFClient", |
|
5052 "NewLC", |
|
5053 "FUNCTIONALITY", |
|
5054 SetupL, MT_CCFClient_NewLCL, Teardown) |
|
5055 |
|
5056 EUNIT_TEST( |
|
5057 "DefineContext - test ", |
|
5058 "CCFClient", |
|
5059 "DefineContext", |
|
5060 "FUNCTIONALITY", |
|
5061 SetupL, MT_CCFClient_DefineContextL, Teardown) |
|
5062 |
|
5063 EUNIT_TEST( |
|
5064 "Subscribers-NoSubscribers - test ", |
|
5065 "CCFClient", |
|
5066 "Subscribers-NoSubscribers", |
|
5067 "FUNCTIONALITY", |
|
5068 SetupNewClientL, MT_CCFClient_SubscribersNosubscribersL, Teardown) |
|
5069 |
|
5070 EUNIT_TEST( |
|
5071 "Subscribers-NoSubscribersPlugin - test ", |
|
5072 "CCFClient", |
|
5073 "Subscribers-NoSubscribers", |
|
5074 "FUNCTIONALITY", |
|
5075 SetupNewClientL, MT_CCFClient_SubscribersNosubscribersPluginL, Teardown) |
|
5076 |
|
5077 EUNIT_TEST( |
|
5078 "2 Subscribers-NoSubscribersPlugin - test ", |
|
5079 "CCFClient", |
|
5080 "Subscribers-NoSubscribers", |
|
5081 "FUNCTIONALITY", |
|
5082 SetupNewClientL, MT_CCFClient_SubscribersNosubscribersPlugin2L, Teardown) |
|
5083 |
|
5084 EUNIT_TEST( |
|
5085 "3 Subscribers-NoSubscribersPlugin - test ", |
|
5086 "CCFClient", |
|
5087 "Subscribers-NoSubscribers", |
|
5088 "FUNCTIONALITY", |
|
5089 SetupNewClientL, MT_CCFClient_SubscribersNosubscribersPlugin3L, Teardown) |
|
5090 |
|
5091 EUNIT_TEST( |
|
5092 "PluginHandleSourceCommand - test ", |
|
5093 "CCFClient", |
|
5094 "HandleCommand", |
|
5095 "FUNCTIONALITY", |
|
5096 SetupNewClientL, MT_CCFClient_ContextSourceCommandPluginL, Teardown) |
|
5097 |
|
5098 EUNIT_TEST( |
|
5099 "ClientHandleSourceCommand - test ", |
|
5100 "CCFClient", |
|
5101 "HandleCommand", |
|
5102 "FUNCTIONALITY", |
|
5103 SetupNewClientL, MT_CCFClient_ContextSourceCommandClientL, Teardown) |
|
5104 |
|
5105 EUNIT_TEST( |
|
5106 "PublishContext - test ", |
|
5107 "CCFClient", |
|
5108 "PublishContext", |
|
5109 "FUNCTIONALITY", |
|
5110 SetupL, MT_CCFClient_PublishContextL, Teardown) |
|
5111 |
|
5112 EUNIT_TEST( |
|
5113 "PublishContextWithData - test ", |
|
5114 "CCFClient", |
|
5115 "PublishContext", |
|
5116 "FUNCTIONALITY", |
|
5117 SetupL, MT_CCFClient_PublishContextWithDataL, Teardown) |
|
5118 |
|
5119 EUNIT_TEST( |
|
5120 "SubscribeContext 1 - test ", |
|
5121 "CCFClient", |
|
5122 "SubscribeContext", |
|
5123 "FUNCTIONALITY", |
|
5124 SetupClientL, MT_CCFClient_SubscribeContext1L, Teardown) |
|
5125 |
|
5126 EUNIT_TEST( |
|
5127 "SubscribeContext 2 - test ", |
|
5128 "CCFClient", |
|
5129 "SubscribeContext", |
|
5130 "FUNCTIONALITY", |
|
5131 SetupClientL, MT_CCFClient_SubscribeContext2L, Teardown) |
|
5132 |
|
5133 EUNIT_TEST( |
|
5134 "SubscribeContext 3 - test ", |
|
5135 "CCFClient", |
|
5136 "SubscribeContext", |
|
5137 "FUNCTIONALITY", |
|
5138 SetupClientL, MT_CCFClient_SubscribeContext3L, Teardown) |
|
5139 |
|
5140 EUNIT_TEST( |
|
5141 "SubscribeContext 4 - test ", |
|
5142 "CCFClient", |
|
5143 "SubscribeContext", |
|
5144 "FUNCTIONALITY", |
|
5145 SetupClientL, MT_CCFClient_SubscribeContext4L, Teardown) |
|
5146 |
|
5147 EUNIT_TEST( |
|
5148 "SubscribeContext 5 - test ", |
|
5149 "CCFClient", |
|
5150 "SubscribeContext", |
|
5151 "FUNCTIONALITY", |
|
5152 SetupClientL, MT_CCFClient_SubscribeContext5L, Teardown) |
|
5153 |
|
5154 EUNIT_TEST( |
|
5155 "SubscribeContext 6 - test ", |
|
5156 "CCFClient", |
|
5157 "SubscribeContext", |
|
5158 "FUNCTIONALITY", |
|
5159 SetupClientL, MT_CCFClient_SubscribeContext6L, Teardown) |
|
5160 |
|
5161 EUNIT_TEST( |
|
5162 "SubscribeContext 7 - test ", |
|
5163 "CCFClient", |
|
5164 "SubscribeContext", |
|
5165 "FUNCTIONALITY", |
|
5166 SetupClientL, MT_CCFClient_SubscribeContext7L, Teardown) |
|
5167 |
|
5168 EUNIT_TEST( |
|
5169 "SubscribeContext 8 - test ", |
|
5170 "CCFClient", |
|
5171 "SubscribeContext", |
|
5172 "FUNCTIONALITY", |
|
5173 SetupClientL, MT_CCFClient_SubscribeContext8L, Teardown) |
|
5174 |
|
5175 EUNIT_TEST( |
|
5176 "SubscribeContext 9 - test ", |
|
5177 "CCFClient", |
|
5178 "SubscribeContext", |
|
5179 "FUNCTIONALITY", |
|
5180 SetupClientL, MT_CCFClient_SubscribeContext9L, Teardown) |
|
5181 |
|
5182 EUNIT_TEST( |
|
5183 "SubscribeContext from separate clients - test ", |
|
5184 "CCFClient", |
|
5185 "SubscribeContext", |
|
5186 "FUNCTIONALITY", |
|
5187 SetupClientL, MT_CCFClient_SubscribeContextFromDifferentClientsL, Teardown) |
|
5188 |
|
5189 EUNIT_TEST( |
|
5190 "SubscribeContext combined - test ", |
|
5191 "CCFClient", |
|
5192 "SubscribeContext", |
|
5193 "FUNCTIONALITY", |
|
5194 SetupClientL, MT_CCFClient_SubscribeContextCombinedL, Teardown) |
|
5195 |
|
5196 EUNIT_TEST( |
|
5197 "SubscribeContext with data 1 - test ", |
|
5198 "CCFClient", |
|
5199 "SubscribeContext", |
|
5200 "FUNCTIONALITY", |
|
5201 SetupClientL, MT_CCFClient_SubscribeContextData1L, Teardown) |
|
5202 |
|
5203 EUNIT_TEST( |
|
5204 "SubscribeContext with data 2 - test ", |
|
5205 "CCFClient", |
|
5206 "SubscribeContext", |
|
5207 "FUNCTIONALITY", |
|
5208 SetupClientL, MT_CCFClient_SubscribeContextData2L, Teardown) |
|
5209 |
|
5210 EUNIT_TEST( |
|
5211 "SubscribeContext with data 3 - test ", |
|
5212 "CCFClient", |
|
5213 "SubscribeContext", |
|
5214 "FUNCTIONALITY", |
|
5215 SetupClientL, MT_CCFClient_SubscribeContextData3L, Teardown) |
|
5216 |
|
5217 EUNIT_TEST( |
|
5218 "SubscribeContext with data 4 - test ", |
|
5219 "CCFClient", |
|
5220 "SubscribeContext", |
|
5221 "FUNCTIONALITY", |
|
5222 SetupClientL, MT_CCFClient_SubscribeContextData4L, Teardown) |
|
5223 |
|
5224 EUNIT_TEST( |
|
5225 "SubscribeContext with data combined - test ", |
|
5226 "CCFClient", |
|
5227 "SubscribeContext", |
|
5228 "FUNCTIONALITY", |
|
5229 SetupClientL, MT_CCFClient_SubscribeContextDataCombinedL, Teardown) |
|
5230 |
|
5231 EUNIT_TEST( |
|
5232 "UnsubscribeContext 1 - test ", |
|
5233 "CCFClient", |
|
5234 "UnsubscribeContext", |
|
5235 "FUNCTIONALITY", |
|
5236 SetupClientL, MT_CCFClient_UnsubscribeContext1L, Teardown) |
|
5237 |
|
5238 EUNIT_TEST( |
|
5239 "UnsubscribeContext 2 - test ", |
|
5240 "CCFClient", |
|
5241 "UnsubscribeContext", |
|
5242 "FUNCTIONALITY", |
|
5243 SetupClientL, MT_CCFClient_UnsubscribeContext2L, Teardown) |
|
5244 |
|
5245 EUNIT_TEST( |
|
5246 "UnsubscribeContext combined - test ", |
|
5247 "CCFClient", |
|
5248 "UnsubscribeContext", |
|
5249 "FUNCTIONALITY", |
|
5250 SetupClientL, MT_CCFClient_UnsubscribeContextCombinedL, Teardown) |
|
5251 |
|
5252 EUNIT_TEST( |
|
5253 "RequestContext 1 - test ", |
|
5254 "CCFClient", |
|
5255 "RequestContext", |
|
5256 "FUNCTIONALITY", |
|
5257 SetupClientL, MT_CCFClient_RequestContext1L, Teardown) |
|
5258 |
|
5259 EUNIT_TEST( |
|
5260 "RequestContext 2 - test ", |
|
5261 "CCFClient", |
|
5262 "RequestContext", |
|
5263 "FUNCTIONALITY", |
|
5264 SetupClientL, MT_CCFClient_RequestContext2L, Teardown) |
|
5265 |
|
5266 EUNIT_TEST( |
|
5267 "RequestContext 3 - test ", |
|
5268 "CCFClient", |
|
5269 "RequestContext", |
|
5270 "FUNCTIONALITY", |
|
5271 SetupClientL, MT_CCFClient_RequestContext3L, Teardown) |
|
5272 |
|
5273 EUNIT_TEST( |
|
5274 "RequestContextSet - test ", |
|
5275 "CCFClient", |
|
5276 "RequestContextSet", |
|
5277 "FUNCTIONALITY", |
|
5278 SetupClientL, MT_CCFClient_RequestContextSetL, Teardown) |
|
5279 |
|
5280 EUNIT_TEST( |
|
5281 "RequestContext combined - test ", |
|
5282 "CCFClient", |
|
5283 "RequestContext", |
|
5284 "FUNCTIONALITY", |
|
5285 SetupClientL, MT_CCFClient_RequestContextCombinedL, Teardown) |
|
5286 |
|
5287 EUNIT_TEST( |
|
5288 "DefineAction - test ", |
|
5289 "CCFClient", |
|
5290 "DefineAction", |
|
5291 "FUNCTIONALITY", |
|
5292 SetupClientL, MT_CCFClient_DefineActionL, Teardown) |
|
5293 |
|
5294 EUNIT_TEST( |
|
5295 "SubscribeAction 1 - test ", |
|
5296 "CCFClient", |
|
5297 "SubscribeAction", |
|
5298 "FUNCTIONALITY", |
|
5299 SetupClientL, MT_CCFClient_SubscribeAction1L, Teardown) |
|
5300 |
|
5301 EUNIT_TEST( |
|
5302 "SubscribeAction 2 - test ", |
|
5303 "CCFClient", |
|
5304 "SubscribeAction", |
|
5305 "FUNCTIONALITY", |
|
5306 SetupClientL, MT_CCFClient_SubscribeAction2L, Teardown) |
|
5307 |
|
5308 EUNIT_TEST( |
|
5309 "SubscribeAction 3 - test ", |
|
5310 "CCFClient", |
|
5311 "SubscribeAction", |
|
5312 "FUNCTIONALITY", |
|
5313 SetupClientL, MT_CCFClient_SubscribeAction3L, Teardown) |
|
5314 |
|
5315 EUNIT_TEST( |
|
5316 "SubscribeAction 4 - test ", |
|
5317 "CCFClient", |
|
5318 "SubscribeAction", |
|
5319 "FUNCTIONALITY", |
|
5320 SetupClientL, MT_CCFClient_SubscribeAction4L, Teardown) |
|
5321 |
|
5322 EUNIT_TEST( |
|
5323 "SubscribeAction from different client - test ", |
|
5324 "CCFClient", |
|
5325 "SubscribeAction", |
|
5326 "FUNCTIONALITY", |
|
5327 SetupClientL, MT_CCFClient_SubscribeActionFromDifferentClientsL, Teardown) |
|
5328 |
|
5329 EUNIT_TEST( |
|
5330 "SubscribeAction (same) from different client 2 - test ", |
|
5331 "CCFClient", |
|
5332 "SubscribeAction", |
|
5333 "FUNCTIONALITY", |
|
5334 SetupClientL, MT_CCFClient_SubscribeActionFromDifferentClients2L, Teardown) |
|
5335 |
|
5336 EUNIT_TEST( |
|
5337 "SubscribeAction combined - test ", |
|
5338 "CCFClient", |
|
5339 "SubscribeAction", |
|
5340 "FUNCTIONALITY", |
|
5341 SetupClientL, MT_CCFClient_SubscribeActionCombinedL, Teardown) |
|
5342 |
|
5343 EUNIT_TEST( |
|
5344 "UnsubscribeAction - test ", |
|
5345 "CCFClient", |
|
5346 "UnsubscribeAction", |
|
5347 "FUNCTIONALITY", |
|
5348 SetupClientL, MT_CCFClient_UnsubscribeActionL, Teardown) |
|
5349 |
|
5350 EUNIT_TEST( |
|
5351 "RegisterScript - test ", |
|
5352 "CCFClient", |
|
5353 "RegisterScript", |
|
5354 "FUNCTIONALITY", |
|
5355 SetupClientL, MT_CCFClient_RegisterScriptL, Teardown) |
|
5356 |
|
5357 EUNIT_TEST( |
|
5358 "RegisterScript - test ", |
|
5359 "CCFClient", |
|
5360 "RegisterScript", |
|
5361 "FUNCTIONALITY", |
|
5362 SetupClientL, MT_CCFClient_RegisterScriptL, Teardown) |
|
5363 |
|
5364 EUNIT_TEST( |
|
5365 "DeregisterScript - test ", |
|
5366 "CCFClient", |
|
5367 "DeregisterScript", |
|
5368 "FUNCTIONALITY", |
|
5369 SetupClientL, MT_CCFClient_DeregisterScriptL, Teardown) |
|
5370 |
|
5371 EUNIT_TEST( |
|
5372 "SaveContextSourceSetting - test ", |
|
5373 "CCFClient", |
|
5374 "SaveContextSourceSetting", |
|
5375 "FUNCTIONALITY", |
|
5376 SetupSourceSettingTestClientL, MT_CCFClient_SaveContextSourceSettingL, Teardown) |
|
5377 |
|
5378 EUNIT_TEST( |
|
5379 "SaveContextSourceSetting - test2 ", |
|
5380 "CCFClient", |
|
5381 "SaveContextSourceSetting", |
|
5382 "FUNCTIONALITY", |
|
5383 SetupSourceSettingTestClientL, MT_CCFClient_SaveContextSourceSetting2L, Teardown) |
|
5384 |
|
5385 EUNIT_TEST( |
|
5386 "DeleteContextSourceSetting - test ", |
|
5387 "CCFClient", |
|
5388 "DeleteContextSourceSetting", |
|
5389 "FUNCTIONALITY", |
|
5390 SetupSourceSettingTestClientL, MT_CCFClient_DeleteContextSourceSettingL, Teardown) |
|
5391 |
|
5392 EUNIT_TEST( |
|
5393 "DeleteContextSourceSetting - test2 ", |
|
5394 "CCFClient", |
|
5395 "DeleteContextSourceSetting", |
|
5396 "FUNCTIONALITY", |
|
5397 SetupSourceSettingTestClientL, MT_CCFClient_DeleteContextSourceSetting2L, Teardown) |
|
5398 |
|
5399 EUNIT_TEST( |
|
5400 "UpgradeContextSourceSetting - test ", |
|
5401 "CCFClient", |
|
5402 "SaveContextSourceSetting", |
|
5403 "FUNCTIONALITY", |
|
5404 SetupSourceSettingTestClientL, MT_CCFClient_UpgradeContextSourceSettingL, Teardown) |
|
5405 |
|
5406 EUNIT_TEST( |
|
5407 "SaveScript - test ", |
|
5408 "CCFClient", |
|
5409 "SaveScript", |
|
5410 "FUNCTIONALITY", |
|
5411 SetupClientL, MT_CCFClient_SaveScriptL, TeardownAndScriptCleanup) |
|
5412 |
|
5413 EUNIT_TEST( |
|
5414 "DeleteScript - test ", |
|
5415 "CCFClient", |
|
5416 "DeleteScript", |
|
5417 "FUNCTIONALITY", |
|
5418 SetupClientL, MT_CCFClient_DeleteScriptL, TeardownAndScriptCleanup) |
|
5419 |
|
5420 EUNIT_TEST( |
|
5421 "DeleteScripts - test ", |
|
5422 "CCFClient", |
|
5423 "DeleteScripts", |
|
5424 "FUNCTIONALITY", |
|
5425 SetupClientL, MT_CCFClient_DeleteScriptsL, TeardownAndScriptCleanup) |
|
5426 |
|
5427 EUNIT_TEST( |
|
5428 "UpgradeRomScript - test ", |
|
5429 "CCFClient", |
|
5430 "UpgradeRomScript", |
|
5431 "FUNCTIONALITY", |
|
5432 SetupClientL, MT_CCFClient_UpgradeRomScriptL, TeardownAndScriptCleanup) |
|
5433 |
|
5434 EUNIT_TEST( |
|
5435 "RestoreRomScript - test ", |
|
5436 "CCFClient", |
|
5437 "RestoreRomScript", |
|
5438 "FUNCTIONALITY", |
|
5439 SetupClientL, MT_CCFClient_RestoreRomScriptL, TeardownAndScriptCleanup) |
|
5440 |
|
5441 EUNIT_TEST( |
|
5442 "Count op unsubscribing - test with two scripts without value", |
|
5443 "CCFClient", |
|
5444 "UnsubscribeContext", |
|
5445 "FUNCTIONALITY", |
|
5446 SetupClientL, MT_CCFClient_OperationUnsubscribingL, Teardown) |
|
5447 |
|
5448 EUNIT_TEST( |
|
5449 "RomRule AutoDef - test rom script context auto define", |
|
5450 "CCFClient", |
|
5451 "DefineContext", |
|
5452 "FUNCTIONALITY", |
|
5453 SetupNewClientL, MT_CCFClient_RomScriptContextAutoDefineL, Teardown) |
|
5454 |
|
5455 EUNIT_TEST( |
|
5456 "RomRul AutoDef 2 - test rom script context auto define", |
|
5457 "CCFClient", |
|
5458 "DefineContext", |
|
5459 "FUNCTIONALITY", |
|
5460 SetupNewClientL, MT_CCFClient_RomScriptContextAutoDefine2L, Teardown) |
|
5461 |
|
5462 EUNIT_TEST( |
|
5463 "RomRul AutoDef 3 - test rom script context auto define", |
|
5464 "CCFClient", |
|
5465 "DefineContext", |
|
5466 "FUNCTIONALITY", |
|
5467 SetupNewClientL, MT_CCFClient_RomScriptContextAutoDefine3L, Teardown) |
|
5468 |
|
5469 EUNIT_TEST( |
|
5470 "RomRul AutoDef 4 - test rom script context auto define", |
|
5471 "CCFClient", |
|
5472 "DefineContext", |
|
5473 "FUNCTIONALITY", |
|
5474 SetupNewClientL, MT_CCFClient_RomScriptContextAutoDefine4L, Teardown) |
|
5475 |
|
5476 EUNIT_END_TEST_TABLE |
|
5477 |
|
5478 // END OF FILE |