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