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.
15 // Test the RProperty and RPropertyRef classes
17 // RProperty, RPropertyRef
19 // - Test and verify the RProperty methods: Delete, Define, Attach and
20 // Subscribe work as expected.
21 // - Test the RPropery::Define() method.
22 // Define the attributes and access control for a property. Verify results
23 // are as expected. Verify property redefinition does not change security
24 // settings. Perform various additional tests associated with the Define
25 // method. Verify results are as expected.
26 // - Test the RPropery::Delete() method.
27 // Verify that if the property has not been defined, Delete fails with
28 // KErrNotFound. Verify pending subscriptions will be completed with
29 // KErrNotFound if the property is deleted. Verify new requests will not
30 // complete until the property is defined and published again.
31 // - Test the RPropery::Get() and Set() methods.
32 // Verify failure if the property has not been defined, can set property
33 // to zero length, failure if the property is larger than KMaxPropertySize.
34 // Verify operation mismatch with property type fails as expected. Verify
35 // various get/set operations work as expected.
36 // - Test the RPropery::Subscribe() and Cancel() methods.
37 // Verify failure if the property has not been defined, request will not
38 // complete. Cancel outstanding subscription request, verify results are as
40 // - Test the platform security settings, verify results are as expected.
41 // Verify that RProperty::Delete() can only succeed when called by the
42 // property owner. Verify Define, Subscribe, Get caller must have read
43 // capabilities or error as expected. Verify Set caller must have write
44 // capabilities or error as expected.
45 // - Perform multiple Set, Get, Subscribe and Cancel operations between
46 // multiple threads, verify results are as expected.
47 // - Create multiple slave threads, verify Set, Get, Subscribe and Cancel
48 // operations work as expected.
49 // - Using a loadable device driver, test the basic functionality of an
50 // RPropertyRef object. Perform many of the same tests as above except
51 // on a RPropertyRef object. Verify results are as expected.
52 // - Perform all the above multithreaded tests in parallel. Verify results
54 // Platforms/Drives/Compatibility:
56 // Assumptions/Requirement/Pre-requisites:
57 // Failures and causes:
58 // Base Port information:
63 #include "t_property.h"
65 static const TInt32 KUidPropTestCategoryValue = 0x101f75b7;
66 static const TUid KPropTestCategory = { KUidPropTestCategoryValue };
68 GLDEF_C TInt E32Main()
72 TInt len = User::CommandLineLength();
76 // Copy the command line in a buffer
78 HBufC* hb = HBufC::NewMax(len);
79 __ASSERT_ALWAYS(hb, User::Panic(_L("t_property: no memory"), 0));
80 TPtr cmd((TUint16*) hb->Ptr(), len);
81 User::CommandLine(cmd);
85 __ASSERT_ALWAYS((r == KErrNone), User::Panic(_L("Usage: t_property <iteration number>\n"), 0));
89 CTestProgram::Start();
91 CTestProgram* panic = new CPropPanic(KPropTestCategory, 01);
96 // Tests to be executed in order
97 CTestProgram* progs[] =
99 new CPropDefine(KPropTestCategory, 11, RProperty::EInt),
100 new CPropDefine(KPropTestCategory, 22, RProperty::EByteArray),
101 new CPropDefine(KPropTestCategory, 28, RProperty::ELargeByteArray),
102 new CPropDelete(KPropTestCategory, 33, RProperty::EInt),
103 new CPropDelete(KPropTestCategory, 44, RProperty::EByteArray),
104 new CPropDelete(KPropTestCategory, 50, RProperty::ELargeByteArray),
105 new CPropSetGet(KPropTestCategory, 55, RProperty::EInt),
106 new CPropSetGet(KPropTestCategory, 66, RProperty::EByteArray),
107 new CPropSetGet(KPropTestCategory, 78, RProperty::ELargeByteArray),
108 new CPropSubsCancel(KPropTestCategory, 73, RProperty::ELargeByteArray),
109 new CPropSubsCancel(KPropTestCategory, 77, RProperty::EByteArray),
110 new CPropSubsCancel(KPropTestCategory, 88, RProperty::EInt),
111 new CPropSecurity(KPropTestCategory, 99, RProperty::EInt, 1000),
112 new CPropSetGetRace(KPropTestCategory, 111),
113 new CPropCancelRace(KPropTestCategory, 122),
114 new CPropBroadcast(KPropTestCategory, 133, 2000, 8, 0),
115 new CPropBroadcast(KPropTestCategory, 144, 3000, 8, 4),
116 new CPropBroadcast(KPropTestCategory, 155, 4000, 8, 8),
117 new CPropLddClient(KPropTestCategory, 166, RProperty::EInt),
118 new CPropLddClient(KPropTestCategory, 177, RProperty::EByteArray),
119 new CPropLddClient(KPropTestCategory, 188, RProperty::ELargeByteArray),
125 TInt n = (sizeof(progs)/sizeof(*progs)) - 1;
127 for (i = 0; i < n; ++i)
129 __ASSERT_ALWAYS(progs[i], User::Panic(_L("t_property: no memory"), 0));
132 // 2 - just to be sure that we can execute the program twice
133 CTestProgram::LaunchGroup(progs, 2);
135 for (i = 0; i < n; ++i)
142 // Tests to be executed in parallel
143 CTestProgram* progs[] =
145 new CPropSetGetRace(KPropTestCategory, 111),
146 new CPropCancelRace(KPropTestCategory, 122),
147 new CPropBroadcast(KPropTestCategory, 133, 2000, 8, 0),
148 new CPropBroadcast(KPropTestCategory, 144, 3000, 8, 4),
149 new CPropBroadcast(KPropTestCategory, 155, 4000, 8, 8),
155 TInt n = (sizeof(progs)/sizeof(*progs)) - 1;
156 for (i = 0; i < n; ++i)
158 __ASSERT_ALWAYS(progs[i], User::Panic(_L("t_property: no memory"), 0));
161 CTestProgram::SpawnGroup(progs, iter);
163 for (i = 0; i < n; ++i)