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.
16 #include "t_property.h"
18 _LIT(KPropSetGetRaceName, "RProperty::Set/Get() Race");
20 CPropSetGetRace::CPropSetGetRace(TUid aCategory, TUint aKey) :
21 CTestProgram(KPropSetGetRaceName), iCategory(aCategory), iKey(aKey),
22 iBuf1(RProperty::KMaxPropertySize), iBuf2(RProperty::KMaxPropertySize)
26 void CPropSetGetRace::Trublemaker(TDes8& aBuf)
29 TInt r = prop.Attach(iCategory, iKey, EOwnerThread);
30 TF_ERROR(r, r == KErrNone);
31 TBool attached = ETrue;
34 TBuf8<RProperty::KMaxPropertySize> buf;
38 TF_ERROR(r, r == KErrNone);
40 TF_ERROR(r, r == KErrNone);
44 r = prop.Set(iCategory, iKey, aBuf);
45 TF_ERROR(r, r == KErrNone);
46 r = prop.Get(iCategory, iKey, buf);
47 TF_ERROR(r, r == KErrNone);
49 TF_ERROR(KErrGeneral, !(buf.Compare(iBuf1) && buf.Compare(iBuf2)));
55 TInt CPropSetGetRace::TrublemakerThreadEntry(TAny* ptr)
57 CPropSetGetRace* prog = (CPropSetGetRace*) ptr;
58 prog->Trublemaker(prog->iBuf2);
62 void CPropSetGetRace::Run(TUint aCount)
66 TInt r = prop.Define(iCategory, iKey, RProperty::EByteArray, KPassPolicy, KPassPolicy);
67 TF_ERROR(r, r == KErrNone);
68 r = prop.Attach(iCategory,iKey);
69 TF_ERROR(r, r == KErrNone);
72 for(i = 0; i < RProperty::KMaxPropertySize; ++i)
78 TRequestStatus status;
80 r = thr.Create(KNullDesC, TrublemakerThreadEntry, 0x2000, NULL, this);
81 TF_ERROR(r, r == KErrNone);
83 thr.SetPriority(EPriorityMore);
86 TBool attached = ETrue;
87 for (i = 0; i < aCount; ++i)
89 TBuf8<RProperty::KMaxPropertySize> buf;
93 TF_ERROR(r, r == KErrNone);
95 TF_ERROR(r, r == KErrNone);
99 r = prop.Set(iCategory, iKey, iBuf1);
100 TF_ERROR(r, r == KErrNone);
101 r = prop.Get(iCategory, iKey, buf);
102 TF_ERROR(r, r == KErrNone);
104 TF_ERROR(KErrGeneral, !(buf.Compare(iBuf1) && buf.Compare(iBuf2)));
105 attached = !attached;
111 User::WaitForRequest(status);
112 TF_ERROR(status.Int(), status.Int() == EExitKill);
114 prop.Delete(iCategory, iKey);
119 _LIT(KPropCancelRaceName, "RProperty::Cancel() Race");
121 CPropCancelRace::CPropCancelRace(TUid aCategory, TUint aKey) :
122 CTestProgram(KPropCancelRaceName), iCategory(aCategory), iKey(aKey)
126 void CPropCancelRace::Trublemaker()
135 TInt CPropCancelRace::TrublemakerThreadEntry(TAny* ptr)
137 CPropCancelRace* prog = (CPropCancelRace*) ptr;
142 void CPropCancelRace::Run(TUint aCount)
144 TInt r = iProp.Define(iCategory, iKey, RProperty::EInt, KPassPolicy, KPassPolicy);
145 TF_ERROR(r, r == KErrNone);
146 r = iProp.Attach(iCategory,iKey);
147 TF_ERROR(r, r == KErrNone);
149 TRequestStatus thrStatus;
151 r = thr.Create(KNullDesC, TrublemakerThreadEntry, 0x2000, NULL, this);
152 TF_ERROR(r, r == KErrNone);
153 thr.Logon(thrStatus);
154 thr.SetPriority(EPriorityMore);
157 for (TUint i = 0; i < aCount; ++i)
159 TRequestStatus status;
160 iProp.Subscribe(status);
161 TInt st = status.Int();
162 TF_ERROR(st, (st == KRequestPending) || (st == KErrCancel));
164 User::WaitForRequest(status);
166 TF_ERROR(st, (st == KErrNone) || (st == KErrCancel));
170 User::WaitForRequest(thrStatus);
171 TF_ERROR(thrStatus.Int(), thrStatus.Int() == EExitKill);
174 iProp.Delete(iCategory, iKey);