Update contrib.
1 // Copyright (c) 2002-2009 Nokia Corporation and/or its subsidiary(-ies).
2 // All rights reserved.
3 // This component and the accompanying materials are made available
4 // under the terms of the License "Eclipse Public License v1.0"
5 // which accompanies this distribution, and is available
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
8 // Initial Contributors:
9 // Nokia Corporation - initial contribution.
17 #include "t_property.h"
19 _LIT(KDefineName, "RProperty::Define() Basics");
21 CPropDefine::CPropDefine(TUid aCategory, TUint aKey, RProperty::TType aType) :
22 CTestProgram(KDefineName), iCategory(aCategory), iKey(aKey), iType(aType)
26 void CPropDefine::Run(TUint aCount)
29 mySid.iUid = RProcess().SecureId();
31 for(TUint i = 0; i < aCount; ++i)
35 // Defines the attributes and access control for a property. This can only be done
36 // once for each property. Subsequent attempts to define the same property will return
38 TInt r = prop.Define(iCategory, iKey, iType, KPassPolicy, KPassPolicy);
39 TF_ERROR(r, r == KErrNone);
40 r = prop.Define(iCategory, iKey, iType, KPassPolicy, KPassPolicy);
41 TF_ERROR(r, r == KErrAlreadyExists);
42 r = prop.Delete(iCategory, iKey);
43 TF_ERROR(r, r == KErrNone);
45 // Test defining properties in the default category (==our SID)
46 r = prop.Define(iKey, iType, KFailPolicy, KFailPolicy);
47 TF_ERROR(r, r == KErrNone);
48 r = prop.Define(iKey, iType, KFailPolicy, KFailPolicy);
49 TF_ERROR(r, r == KErrAlreadyExists);
50 r = prop.Define(mySid, iKey, iType, KFailPolicy, KFailPolicy);
51 TF_ERROR(r, r == KErrAlreadyExists);
52 r = prop.Delete(mySid, iKey);
53 TF_ERROR(r, r == KErrNone);
55 // Test re-definition doesn't change security settings
56 // Defect DEF050961 - Re-defining an RProperty causes the security policy to be overwritten
58 TInt expectedResult = PlatSec::ConfigSetting(PlatSec::EPlatSecEnforcement)?KErrPermissionDenied:KErrNone;
59 _LIT(KTestBytes,"abcd");
60 r = prop.Define(iCategory, iKey, iType, KFailPolicy, KFailPolicy);
61 TF_ERROR(r, r == KErrNone);
62 r = prop.Attach(iCategory, iKey);
63 TF_ERROR(r, r == KErrNone);
64 if (iType == RProperty::EInt)
67 r = prop.Set(KTestBytes);
68 TF_ERROR(r, r == expectedResult);
69 r = prop.Define(iCategory, iKey, iType, KPassPolicy, KPassPolicy);
70 TF_ERROR(r, r == KErrAlreadyExists);
71 if (iType == RProperty::EInt)
74 r = prop.Set(KTestBytes);
75 TF_ERROR(r, r == expectedResult);
76 r = prop.Delete(iCategory, iKey);
77 TF_ERROR(r, r == KErrNone);
81 // Define fails with KErrArgument if wrong type or attribute was specified.
82 r = prop.Define(iCategory, iKey, RProperty::ETypeLimit, KPassPolicy, KPassPolicy);
83 TF_ERROR(r, r == KErrArgument);
84 const TInt removed_KPersistent_attribute = 0x100;
85 r = prop.Define(iCategory, iKey, iType | removed_KPersistent_attribute, KPassPolicy, KPassPolicy);
86 TF_ERROR(r, r == KErrArgument);
88 TSecurityPolicy badPolicy;
89 *(TInt*)&badPolicy = -1;
90 r = prop.Define(iCategory, iKey, iType, badPolicy, KPassPolicy);
91 TF_ERROR(r, r == KErrArgument);
92 r = prop.Define(iCategory, iKey, iType, KPassPolicy, badPolicy);
93 TF_ERROR(r, r == KErrArgument);
95 if (iType == RProperty::EInt)
97 // Define fails with KErrArgument if aType is TInt and aPreallocate is not 0
98 r = prop.Define(iCategory, iKey, RProperty::EInt, KPassPolicy, KPassPolicy, 16);
99 TF_ERROR(r, r == KErrArgument);
101 // Following defintion the property has a default value, 0 for integer properties
102 r = prop.Define(iCategory, iKey, RProperty::EInt, KPassPolicy, KPassPolicy);
103 TF_ERROR(r, r == KErrNone);
105 r = prop.Get(iCategory, iKey, value);
106 TF_ERROR(r, r == KErrNone);
107 TF_ERROR(value, value == 0);
108 r = prop.Delete(iCategory, iKey);
109 TF_ERROR(r, r == KErrNone);
113 // Defne fails with KErrTooBig if aPeallocate is grater than KMaxPropertySize.
114 r = prop.Define(iCategory, iKey, RProperty::EByteArray, KPassPolicy, KPassPolicy, RProperty::KMaxPropertySize);
115 TF_ERROR(r, r == KErrNone);
116 r = prop.Delete(iCategory, iKey);
117 TF_ERROR(r, r == KErrNone);
118 r = prop.Define(iCategory, iKey, RProperty::EByteArray, KPassPolicy, KPassPolicy, RProperty::KMaxPropertySize + 1);
119 TF_ERROR(r, r == KErrTooBig);
121 // Following defintion the property has a default value, zero-length data for byte-array and text
123 r = prop.Define(iCategory, iKey, RProperty::EByteArray, KPassPolicy, KPassPolicy);
124 TF_ERROR(r, r == KErrNone);
126 r = prop.Get(iCategory, iKey, buf);
127 TF_ERROR(r, r == KErrNone);
128 TF_ERROR(buf.Size(), buf.Size() == 0);
131 r = prop.Get(iCategory, iKey, buf8);
132 TF_ERROR(r, r == KErrNone);
133 TF_ERROR(buf8.Size(), buf8.Size() == 0);
134 r = prop.Delete(iCategory, iKey);
135 TF_ERROR(r, r == KErrNone);
138 // Pending subscriptions for this property will not be completed until a new value is published.
139 r = prop.Attach(iCategory, iKey);
140 TF_ERROR(r, r == KErrNone);
141 TRequestStatus status;
142 prop.Subscribe(status);
143 TF_ERROR(status.Int(), status.Int() == KRequestPending);
144 r = prop.Define(iCategory, iKey, iType, KPassPolicy, KPassPolicy);
145 TF_ERROR(r, r == KErrNone);
146 TF_ERROR(status.Int(), status.Int() == KRequestPending);
147 r = prop.Delete(iCategory, iKey);
148 TF_ERROR(r, r == KErrNone);
149 User::WaitForRequest(status);
150 TF_ERROR(status.Int(), status.Int() == KErrNotFound);
155 _LIT(KDeleteName, "RProperty::Delete() Basics");
157 CPropDelete::CPropDelete(TUid aCategory, TUint aKey, RProperty::TType aType) :
158 CTestProgram(KDeleteName), iCategory(aCategory), iKey(aKey), iType(aType)
162 void CPropDelete::Run(TUint aCount)
165 mySid.iUid = RProcess().SecureId();
166 for(TUint i = 0; i < aCount; ++i)
170 // If the property has not been defined Delete fails with KErrNotFound.
171 TInt r = prop.Delete(iCategory, iKey);
172 TF_ERROR(r, r == KErrNotFound);
174 // Test deleting properties in the default category (==our SID)
175 //deleting of property in the default category (==our SID) should fail until the property is defined
176 r = prop.Delete(iKey);
177 TF_ERROR(r, r == KErrNotFound);
179 r = prop.Define(iKey, iType, KFailPolicy, KFailPolicy);
180 TF_ERROR(r, r == KErrNone);
181 r = prop.Delete(iKey);
182 TF_ERROR(r, r == KErrNone);
184 r = prop.Define(mySid, iKey, iType, KFailPolicy, KFailPolicy);
185 TF_ERROR(r, r == KErrNone);
186 r = prop.Delete(mySid, iKey);
187 TF_ERROR(r, r == KErrNone);
188 r = prop.Delete( iKey);
189 TF_ERROR(r, r == KErrNotFound);
191 r = prop.Define(mySid, iKey, iType, KFailPolicy, KFailPolicy);
192 TF_ERROR(r, r == KErrNone);
193 r = prop.Delete( iKey);
194 TF_ERROR(r, r == KErrNone);
195 r = prop.Delete(mySid, iKey);
196 TF_ERROR(r, r == KErrNotFound);
198 // Any pending subscriptions for this property will be completed with KErrNotFound.
199 r = prop.Define(iCategory, iKey, iType, KPassPolicy, KPassPolicy);
200 TF_ERROR(r, r == KErrNone);
201 r = prop.Attach(iCategory, iKey);
202 TF_ERROR(r, r == KErrNone);
203 TRequestStatus status;
204 prop.Subscribe(status);
205 TF_ERROR(status.Int(), status.Int() == KRequestPending);
206 r = prop.Delete(iCategory, iKey);
207 TF_ERROR(r, r == KErrNone);
208 User::WaitForRequest(status);
209 TF_ERROR(status.Int(), status.Int() == KErrNotFound);
211 // Any new request will not complete until the property is defined and published again.
212 prop.Subscribe(status);
213 TF_ERROR(status.Int(), status.Int() == KRequestPending);
214 r = prop.Define(iCategory, iKey, iType, KPassPolicy, KPassPolicy);
215 TF_ERROR(r, r == KErrNone);
216 TF_ERROR(status.Int(), status.Int() == KRequestPending);
217 if (iType == RProperty::EInt)
220 TF_ERROR(r, r == KErrNone);
224 r = prop.Set(_L("Foo"));
225 TF_ERROR(r, r == KErrNone);
227 User::WaitForRequest(status);
228 TF_ERROR(status.Int(), status.Int() == KErrNone);
229 r = prop.Delete(iCategory, iKey);
230 TF_ERROR(r, r == KErrNone);
235 _LIT(KPanicName, "RProperty Panics");
237 CPropPanic::CPropPanic(TUid aCategory, TUint aKey) :
238 CTestProgram(KPanicName), iCategory(aCategory), iKey(aKey)
242 TInt CPropPanic::DoubleSubscribeThreadEntry(TAny* ptr)
244 CPropPanic* prog = (CPropPanic*) ptr;
246 TInt r = prop.Attach(prog->iCategory, prog->iKey, EOwnerThread);
247 TF_ERROR_PROG(prog, r, r == KErrNone);
248 TRequestStatus status;
249 prop.Subscribe(status);
250 // Next statement shall Panic.
251 prop.Subscribe(status);
256 TInt CPropPanic::BadHandleSubscribeThreadEntry(TAny* /*ptr*/)
259 TRequestStatus status;
260 prop.Subscribe(status);
264 TInt CPropPanic::BadHandleCancelThreadEntry(TAny* /*ptr*/)
271 TInt CPropPanic::BadHandleGetIThreadEntry(TAny* /*ptr*/)
279 TInt CPropPanic::BadHandleGetBThreadEntry(TAny* /*ptr*/)
287 TInt CPropPanic::BadHandleSetIThreadEntry(TAny* /*ptr*/)
295 TInt CPropPanic::BadHandleSetBThreadEntry(TAny* /*ptr*/)
303 TThreadFunction CPropPanic::BadHandles[] = {
304 CPropPanic::BadHandleSubscribeThreadEntry,
305 CPropPanic::BadHandleCancelThreadEntry,
306 CPropPanic::BadHandleGetIThreadEntry,
307 CPropPanic::BadHandleGetBThreadEntry,
308 CPropPanic::BadHandleSetIThreadEntry,
309 CPropPanic::BadHandleSetBThreadEntry,
313 void CPropPanic::Run(TUint /* aCount */)
315 // Only one subscriptoin per RProperty object is allowed, the caller will be paniced if
316 // there is already a subscription on this object.
317 TRequestStatus status;
320 TInt r = thr.Create(KNullDesC, DoubleSubscribeThreadEntry, 0x2000, NULL, this);
321 TF_ERROR(r, r == KErrNone);
324 TBool jit = User::JustInTime();
325 User::SetJustInTime(EFalse);
328 User::WaitForRequest(status);
331 User::SetJustInTime(jit);
333 TF_ERROR(status.Int(), status.Int() == ERequestAlreadyPending);
335 for (TInt i = 0; BadHandles[i]; ++i)
337 r = thr.Create(KNullDesC, BadHandles[i], 0x2000, NULL, this);
338 TF_ERROR(r, r == KErrNone);
341 jit = User::JustInTime();
342 User::SetJustInTime(EFalse);
345 User::WaitForRequest(status);
346 exit = thr.ExitType();
349 User::SetJustInTime(jit);
351 TF_ERROR(status.Int(), status.Int() == EBadHandle);
352 TF_ERROR(exit, exit == EExitPanic);
356 _LIT(KSetGetName, "RProperty::Set()/Get() Basics");
358 CPropSetGet::CPropSetGet(TUid aCategory, TUint aKey, RProperty::TType aType) :
359 CTestProgram(KSetGetName), iCategory(aCategory), iKey(aKey), iType(aType)
363 void CPropSetGet::Run(TUint aCount)
365 for(TUint i = 0; i < aCount; ++i)
370 r = prop.Attach(iCategory, iKey);
371 TF_ERROR(r, r == KErrNone);
373 // If the property has not been defined this fails with KErrNotFound.
378 if (iType == RProperty::EInt)
380 r = prop.Get(iCategory, iKey, value);
381 TF_ERROR(r, r == KErrNotFound);
382 r = prop.Set(iCategory, iKey, value);
383 TF_ERROR(r, r == KErrNotFound);
387 r = prop.Get(iCategory, iKey, buf);
388 TF_ERROR(r, r == KErrNotFound);
389 r = prop.Set(iCategory, iKey, buf);
390 TF_ERROR(r, r == KErrNotFound);
391 r = prop.Get(iCategory, iKey, buf8);
392 TF_ERROR(r, r == KErrNotFound);
393 r = prop.Set(iCategory, iKey, buf8);
394 TF_ERROR(r, r == KErrNotFound);
397 if (iType == RProperty::EInt)
400 TF_ERROR(r, r == KErrNotFound);
402 TF_ERROR(r, r == KErrNotFound);
407 TF_ERROR(r, r == KErrNotFound);
409 TF_ERROR(r, r == KErrNotFound);
411 TF_ERROR(r, r == KErrNotFound);
413 TF_ERROR(r, r == KErrNotFound);
417 r = prop.Define(iCategory, iKey, iType, KPassPolicy, KPassPolicy);
418 TF_ERROR(r, r == KErrNone);
420 // Can set property to zero length
422 if (iType == RProperty::EByteArray)
425 r = prop.Set(iCategory, iKey, KNullDesC8);
426 TF_ERROR(r, r == KErrNone);
427 r = prop.Get(iCategory, iKey, buf8);
428 TF_ERROR(r, r == KErrNone);
429 TF_ERROR(buf8.Length(), buf8.Length() == 0);
433 // If the property is larger than KMaxPropertySize this fails with KErrTooBig
435 if (iType == RProperty::EByteArray)
437 TBuf<RProperty::KMaxPropertySize/2 + 1> buf(RProperty::KMaxPropertySize/2 + 1);
438 TBuf8<RProperty::KMaxPropertySize + 1> buf8(RProperty::KMaxPropertySize + 1);
439 r = prop.Set(iCategory, iKey, buf);
440 TF_ERROR(r, r == KErrTooBig);
441 r = prop.Set(iCategory, iKey, buf8);
442 TF_ERROR(r, r == KErrTooBig);
444 TF_ERROR(r, r == KErrTooBig);
446 TF_ERROR(r, r == KErrTooBig);
450 // When type of operation mismatch with the property type this fails with KErrArgument.
455 if (iType != RProperty::EInt)
457 r = prop.Get(iCategory, iKey, value);
458 TF_ERROR(r, r == KErrArgument);
459 r = prop.Set(iCategory, iKey, value);
460 TF_ERROR(r, r == KErrArgument);
462 TF_ERROR(r, r == KErrArgument);
464 TF_ERROR(r, r == KErrArgument);
468 r = prop.Get(iCategory, iKey, buf);
469 TF_ERROR(r, r == KErrArgument);
470 r = prop.Set(iCategory, iKey, buf);
471 TF_ERROR(r, r == KErrArgument);
472 r = prop.Get(iCategory, iKey, buf8);
473 TF_ERROR(r, r == KErrArgument);
474 r = prop.Set(iCategory, iKey, buf8);
475 TF_ERROR(r, r == KErrArgument);
477 TF_ERROR(r, r == KErrArgument);
479 TF_ERROR(r, r == KErrArgument);
481 TF_ERROR(r, r == KErrArgument);
483 TF_ERROR(r, r == KErrArgument);
488 if (iType == RProperty::EInt)
492 TF_ERROR(r, r == KErrNone);
495 TF_ERROR(r, r == KErrNone);
496 TF_ERROR(value, value == 1);
500 r = prop.Set(iCategory, iKey, 1);
501 TF_ERROR(r, r == KErrNone);
502 r = prop.Get(iCategory, iKey, value);
503 TF_ERROR(r, r == KErrNone);
504 TF_ERROR(value, value == 1);
510 TBuf<16> ibuf(_L("Foo"));
513 TF_ERROR(r, r == KErrNone);
515 TF_ERROR(r, r == KErrNone);
516 r = obuf.Compare(ibuf);
520 TBuf8<16> ibuf8((TUint8*)"Foo");
523 TF_ERROR(r, r == KErrNone);
525 TF_ERROR(r, r == KErrNone);
526 r = obuf8.Compare(ibuf8);
530 TBuf<16> ibuf(_L("Foo"));
532 r = prop.Set(iCategory, iKey, ibuf);
533 TF_ERROR(r, r == KErrNone);
534 r = prop.Get(iCategory, iKey, obuf);
535 TF_ERROR(r, r == KErrNone);
536 r = obuf.Compare(ibuf);
540 TBuf8<16> ibuf8((TUint8*)"Foo");
542 r = prop.Set(iCategory, iKey, ibuf8);
543 TF_ERROR(r, r == KErrNone);
544 r = prop.Get(iCategory, iKey, obuf8);
545 TF_ERROR(r, r == KErrNone);
546 r = obuf8.Compare(ibuf8);
551 // If the supplied buffer is too small this fails with KErrOverflow and the truncated value is reported.
552 if (iType == RProperty::EByteArray)
555 TBuf<16> ibuf(_L("0123456789012345"));
556 TBuf<16> obuf(_L("abcdefghigklmnop"));
557 TPtr optr((TUint16*) obuf.Ptr(), 0, 15);
558 r = prop.Set(iCategory, iKey, ibuf);
559 TF_ERROR(r, r == KErrNone);
560 r = prop.Get(iCategory, iKey, optr);
561 TF_ERROR(r, r == KErrOverflow);
562 TF_ERROR(optr.Length(), optr.Length() == 15);
563 TF_ERROR(obuf[14], obuf[14] == TText('4'));
564 TF_ERROR(obuf[15], obuf[15] == TText('p'));
567 TBuf8<16> ibuf8((TUint8*) "0123456789012345");
568 TBuf8<16> obuf8((TUint8*) "abcdefghigklmnop");
569 TPtr8 optr8((TUint8*) obuf8.Ptr(), 0, 15);
570 r = prop.Set(iCategory, iKey, ibuf8);
571 TF_ERROR(r, r == KErrNone);
572 r = prop.Get(iCategory, iKey, optr8);
573 TF_ERROR(r, r == KErrOverflow);
574 TF_ERROR(optr8.Length(), optr8.Length() == 15);
575 TF_ERROR(obuf8[14], obuf8[14] == '4');
576 TF_ERROR(obuf8[15], obuf8[15] == 'p');
579 TBuf<16> ibuf(_L("0123456789012345"));
580 TBuf<16> obuf(_L("abcdefghigklmnop"));
581 TPtr optr((TUint16*) obuf.Ptr(), 0, 15);
583 TF_ERROR(r, r == KErrNone);
585 TF_ERROR(r, r == KErrOverflow);
586 TF_ERROR(optr.Length(), optr.Length() == 15);
587 TF_ERROR(obuf[14], obuf[14] == TText('4'));
588 TF_ERROR(obuf[15], obuf[15] == TText('p'));
591 TBuf8<16> ibuf8((TUint8*) "0123456789012345");
592 TBuf8<16> obuf8((TUint8*) "abcdefghigklmnop");
593 TPtr8 optr8((TUint8*) obuf8.Ptr(), 0, 15);
595 TF_ERROR(r, r == KErrNone);
597 TF_ERROR(r, r == KErrOverflow);
598 TF_ERROR(optr8.Length(), optr8.Length() == 15);
599 TF_ERROR(obuf8[14], obuf8[14] == '4');
600 TF_ERROR(obuf8[15], obuf8[15] == 'p');
604 // Get/Set zero-length data
605 if (iType == RProperty::EByteArray)
608 TBuf<16> ibuf(_L("Foo"));
610 TPtr nullbuf(NULL, 0);
613 TF_ERROR(r, r == KErrNone);
614 r = prop.Get(nullbuf);
615 TF_ERROR(r, r == KErrOverflow);
616 TF_ERROR(nullbuf.Length(), (nullbuf.Length() == 0));
618 r = prop.Set(nullbuf);
619 TF_ERROR(r, r == KErrNone);
621 TF_ERROR(r, r == KErrNone);
622 TF_ERROR(obuf.Length(), (obuf.Length() == 0));
625 TBuf8<16> ibuf((TUint8*) "Foo");
627 TPtr8 nullbuf(NULL, 0);
630 TF_ERROR(r, r == KErrNone);
631 r = prop.Get(nullbuf);
632 TF_ERROR(r, r == KErrOverflow);
633 TF_ERROR(nullbuf.Length(), (nullbuf.Length() == 0));
635 r = prop.Set(nullbuf);
636 TF_ERROR(r, r == KErrNone);
638 TF_ERROR(r, r == KErrNone);
639 TF_ERROR(obuf.Length(), (obuf.Length() == 0));
643 r = prop.Delete(iCategory, iKey);
644 TF_ERROR(r, r == KErrNone);
650 _LIT(KSubsCancelName, "RProperty::Subscribe()/Cancel() Basics");
652 CPropSubsCancel::CPropSubsCancel(TUid aCategory, TUint aKey, RProperty::TType aType) :
653 CTestProgram(KSubsCancelName), iCategory(aCategory), iKey(aKey), iType(aType)
658 void CPropSubsCancel::Run(TUint aCount)
661 for(TUint i = 0; i < aCount; ++i)
663 TRequestStatus status;
666 TInt r = prop.Attach(iCategory, iKey);
667 TF_ERROR(r, r == KErrNone);
669 // The calling thread will have the specified request status signalled when the property is next updated.
670 r = prop.Define(iCategory, iKey, iType, KPassPolicy, KPassPolicy);
671 TF_ERROR(r, r == KErrNone);
672 prop.Subscribe(status);
673 TF_ERROR(status.Int(), status.Int() == KRequestPending);
674 if (iType == RProperty::EInt)
677 TF_ERROR(r, r == KErrNone);
681 r = prop.Set(_L("Foo"));
682 TF_ERROR(r, r == KErrNone);
684 User::WaitForRequest(status);
685 TF_ERROR(status.Int(), status.Int() == KErrNone);
686 r = prop.Delete(iCategory, iKey);
687 TF_ERROR(r, r == KErrNone);
689 // If the property has not been defined, the request will not complete until the property
690 // is defined and published.
691 prop.Subscribe(status);
692 TF_ERROR(status.Int(), status.Int() == KRequestPending);
693 r = prop.Define(iCategory, iKey, iType, KPassPolicy, KPassPolicy);
694 TF_ERROR(r, r == KErrNone);
695 TF_ERROR(status.Int(), status.Int() == KRequestPending);
696 if (iType == RProperty::EInt)
699 TF_ERROR(r, r == KErrNone);
703 r = prop.Set(_L("Foo"));
704 TF_ERROR(r, r == KErrNone);
706 User::WaitForRequest(status);
707 TF_ERROR(status.Int(), status.Int() == KErrNone);
708 r = prop.Delete(iCategory, iKey);
709 TF_ERROR(r, r == KErrNone);
711 // Cancel an outstanding subscription request for this property handle.
712 // If it has not already completed, the request is completed with KErrCancelled.
713 prop.Subscribe(status);
714 TF_ERROR(status.Int(), status.Int() == KRequestPending);
716 User::WaitForRequest(status);
717 TF_ERROR(status.Int(), status.Int() == KErrCancel);
719 r = prop.Define(iCategory, iKey, iType, KPassPolicy, KPassPolicy);
720 TF_ERROR(r, r == KErrNone);
721 prop.Subscribe(status);
722 TF_ERROR(status.Int(), status.Int() == KRequestPending);
723 if (iType == RProperty::EInt)
726 TF_ERROR(r, r == KErrNone);
730 r = prop.Set(_L("Foo"));
731 TF_ERROR(r, r == KErrNone);
733 User::WaitForRequest(status);
734 TF_ERROR(status.Int(), status.Int() == KErrNone);
736 TF_ERROR(status.Int(), status.Int() == KErrNone);
738 prop.Subscribe(status);
739 TF_ERROR(status.Int(), status.Int() == KRequestPending);
741 User::WaitForRequest(status);
742 TF_ERROR(status.Int(), status.Int() == KErrCancel);
744 r = prop.Delete(iCategory, iKey);
745 TF_ERROR(r, r == KErrNone);
751 _LIT(KSecurityName, "RProperty Security Basics (Master)");
753 CPropSecurity::CPropSecurity(TUid aCategory, TUint aMasterKey, RProperty::TType aType, TUint aSlaveKeySlot) :
754 CTestProgram(KSecurityName), iCategory(aCategory), iMasterKey(aMasterKey),
755 iSlaveKeySlot(aSlaveKeySlot), iType(aType)
759 _LIT(KSecuritySlavePath, "t_prop_sec.exe");
761 void CPropSecurity::Run(TUint aCount)
763 for(TInt i=0; i<ECapability_Limit; i++)
764 if(!PlatSec::IsCapabilityEnforced((TCapability)i))
766 // System isn't configured with platform security enforced
767 // so don't bother running tests
772 args.iCount = aCount;
773 args.iCategory = iCategory;
774 args.iMasterKey = iMasterKey;
775 args.iSlaveKeySlot = iSlaveKeySlot;
779 TInt r = prop.Define(iCategory, iMasterKey, iType, KPassPolicy, KPassPolicy);
780 TF_ERROR(r, r == KErrNone);
782 Exec(KSecuritySlavePath, &args, sizeof(args));
784 Exec(_L("t_prop_define0.exe"), &args, sizeof(args));
785 Exec(_L("t_prop_define1.exe"), &args, sizeof(args));
786 Exec(_L("t_prop_define2.exe"), &args, sizeof(args));
787 Exec(_L("t_prop_define3.exe"), &args, sizeof(args));
789 r = prop.Delete(iCategory, iMasterKey);
790 TF_ERROR(r, r == KErrNone);