sl@0: // Copyright (c) 2002-2009 Nokia Corporation and/or its subsidiary(-ies). sl@0: // All rights reserved. sl@0: // This component and the accompanying materials are made available sl@0: // under the terms of the License "Eclipse Public License v1.0" sl@0: // which accompanies this distribution, and is available sl@0: // at the URL "http://www.eclipse.org/legal/epl-v10.html". sl@0: // sl@0: // Initial Contributors: sl@0: // Nokia Corporation - initial contribution. sl@0: // sl@0: // Contributors: sl@0: // sl@0: // Description: sl@0: // Overview: sl@0: // Test the RProperty and RPropertyRef classes sl@0: // API Information: sl@0: // RProperty, RPropertyRef sl@0: // Details: sl@0: // - Test and verify the RProperty methods: Delete, Define, Attach and sl@0: // Subscribe work as expected. sl@0: // - Test the RPropery::Define() method. sl@0: // Define the attributes and access control for a property. Verify results sl@0: // are as expected. Verify property redefinition does not change security sl@0: // settings. Perform various additional tests associated with the Define sl@0: // method. Verify results are as expected. sl@0: // - Test the RPropery::Delete() method. sl@0: // Verify that if the property has not been defined, Delete fails with sl@0: // KErrNotFound. Verify pending subscriptions will be completed with sl@0: // KErrNotFound if the property is deleted. Verify new requests will not sl@0: // complete until the property is defined and published again. sl@0: // - Test the RPropery::Get() and Set() methods. sl@0: // Verify failure if the property has not been defined, can set property sl@0: // to zero length, failure if the property is larger than KMaxPropertySize. sl@0: // Verify operation mismatch with property type fails as expected. Verify sl@0: // various get/set operations work as expected. sl@0: // - Test the RPropery::Subscribe() and Cancel() methods. sl@0: // Verify failure if the property has not been defined, request will not sl@0: // complete. Cancel outstanding subscription request, verify results are as sl@0: // expected. sl@0: // - Test the platform security settings, verify results are as expected. sl@0: // Verify that RProperty::Delete() can only succeed when called by the sl@0: // property owner. Verify Define, Subscribe, Get caller must have read sl@0: // capabilities or error as expected. Verify Set caller must have write sl@0: // capabilities or error as expected. sl@0: // - Perform multiple Set, Get, Subscribe and Cancel operations between sl@0: // multiple threads, verify results are as expected. sl@0: // - Create multiple slave threads, verify Set, Get, Subscribe and Cancel sl@0: // operations work as expected. sl@0: // - Using a loadable device driver, test the basic functionality of an sl@0: // RPropertyRef object. Perform many of the same tests as above except sl@0: // on a RPropertyRef object. Verify results are as expected. sl@0: // - Perform all the above multithreaded tests in parallel. Verify results sl@0: // are as expected. sl@0: // Platforms/Drives/Compatibility: sl@0: // All. sl@0: // Assumptions/Requirement/Pre-requisites: sl@0: // Failures and causes: sl@0: // Base Port information: sl@0: // sl@0: // sl@0: sl@0: #include sl@0: #include "t_property.h" sl@0: sl@0: static const TInt32 KUidPropTestCategoryValue = 0x101f75b7; sl@0: static const TUid KPropTestCategory = { KUidPropTestCategoryValue }; sl@0: sl@0: GLDEF_C TInt E32Main() sl@0: { sl@0: TInt iter = 10000; sl@0: sl@0: TInt len = User::CommandLineLength(); sl@0: if (len) sl@0: { sl@0: // sl@0: // Copy the command line in a buffer sl@0: // sl@0: HBufC* hb = HBufC::NewMax(len); sl@0: __ASSERT_ALWAYS(hb, User::Panic(_L("t_property: no memory"), 0)); sl@0: TPtr cmd((TUint16*) hb->Ptr(), len); sl@0: User::CommandLine(cmd); sl@0: sl@0: TLex l(cmd); sl@0: TInt r = l.Val(iter); sl@0: __ASSERT_ALWAYS((r == KErrNone), User::Panic(_L("Usage: t_property \n"), 0)); sl@0: delete hb; sl@0: } sl@0: sl@0: CTestProgram::Start(); sl@0: sl@0: CTestProgram* panic = new CPropPanic(KPropTestCategory, 01); sl@0: panic->Launch(1); sl@0: delete panic; sl@0: sl@0: { sl@0: // Tests to be executed in order sl@0: CTestProgram* progs[] = sl@0: { sl@0: new CPropDefine(KPropTestCategory, 11, RProperty::EInt), sl@0: new CPropDefine(KPropTestCategory, 22, RProperty::EByteArray), sl@0: new CPropDefine(KPropTestCategory, 28, RProperty::ELargeByteArray), sl@0: new CPropDelete(KPropTestCategory, 33, RProperty::EInt), sl@0: new CPropDelete(KPropTestCategory, 44, RProperty::EByteArray), sl@0: new CPropDelete(KPropTestCategory, 50, RProperty::ELargeByteArray), sl@0: new CPropSetGet(KPropTestCategory, 55, RProperty::EInt), sl@0: new CPropSetGet(KPropTestCategory, 66, RProperty::EByteArray), sl@0: new CPropSetGet(KPropTestCategory, 78, RProperty::ELargeByteArray), sl@0: new CPropSubsCancel(KPropTestCategory, 73, RProperty::ELargeByteArray), sl@0: new CPropSubsCancel(KPropTestCategory, 77, RProperty::EByteArray), sl@0: new CPropSubsCancel(KPropTestCategory, 88, RProperty::EInt), sl@0: new CPropSecurity(KPropTestCategory, 99, RProperty::EInt, 1000), sl@0: new CPropSetGetRace(KPropTestCategory, 111), sl@0: new CPropCancelRace(KPropTestCategory, 122), sl@0: new CPropBroadcast(KPropTestCategory, 133, 2000, 8, 0), sl@0: new CPropBroadcast(KPropTestCategory, 144, 3000, 8, 4), sl@0: new CPropBroadcast(KPropTestCategory, 155, 4000, 8, 8), sl@0: new CPropLddClient(KPropTestCategory, 166, RProperty::EInt), sl@0: new CPropLddClient(KPropTestCategory, 177, RProperty::EByteArray), sl@0: new CPropLddClient(KPropTestCategory, 188, RProperty::ELargeByteArray), sl@0: sl@0: NULL sl@0: }; sl@0: sl@0: TInt i; sl@0: TInt n = (sizeof(progs)/sizeof(*progs)) - 1; sl@0: sl@0: for (i = 0; i < n; ++i) sl@0: { sl@0: __ASSERT_ALWAYS(progs[i], User::Panic(_L("t_property: no memory"), 0)); sl@0: } sl@0: sl@0: // 2 - just to be sure that we can execute the program twice sl@0: CTestProgram::LaunchGroup(progs, 2); sl@0: sl@0: for (i = 0; i < n; ++i) sl@0: { sl@0: delete progs[i]; sl@0: } sl@0: } sl@0: sl@0: { sl@0: // Tests to be executed in parallel sl@0: CTestProgram* progs[] = sl@0: { sl@0: new CPropSetGetRace(KPropTestCategory, 111), sl@0: new CPropCancelRace(KPropTestCategory, 122), sl@0: new CPropBroadcast(KPropTestCategory, 133, 2000, 8, 0), sl@0: new CPropBroadcast(KPropTestCategory, 144, 3000, 8, 4), sl@0: new CPropBroadcast(KPropTestCategory, 155, 4000, 8, 8), sl@0: sl@0: NULL sl@0: }; sl@0: sl@0: TInt i; sl@0: TInt n = (sizeof(progs)/sizeof(*progs)) - 1; sl@0: for (i = 0; i < n; ++i) sl@0: { sl@0: __ASSERT_ALWAYS(progs[i], User::Panic(_L("t_property: no memory"), 0)); sl@0: } sl@0: sl@0: CTestProgram::SpawnGroup(progs, iter); sl@0: sl@0: for (i = 0; i < n; ++i) sl@0: { sl@0: delete progs[i]; sl@0: } sl@0: } sl@0: sl@0: CTestProgram::End(); sl@0: sl@0: return KErrNone; sl@0: }