sl@0: // Copyright (c) 2007-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: // e32test\resourceman\t_rescontrolcli.cpp sl@0: // TestCase Description: sl@0: // This tests is intended to test the generic layer of PRM. It consists of unit testing and regression testing. sl@0: // Unit testing validates each of the API's. Regression testing performs random operation on random resource and sl@0: // currently executes 500 operations and returns. sl@0: // To run regression testing, test must be invoked with -R option. sl@0: // Testing runs only on simulated PSL. sl@0: // sl@0: // sl@0: sl@0: #include sl@0: #include sl@0: #include sl@0: #include sl@0: #include sl@0: #include "d_rescontrolcli.h" sl@0: sl@0: #define MAX_STATIC_RESOURCE_NUM 24 //Maximum number of static resources in simulated PSL sl@0: #define MAX_STATIC_DEPENDENCY_RESOURCE_NUM 7 //Maximum number of static dependency resources in simulated PSL sl@0: #define DEPENDENCY_RESOURCE_BIT_MASK 0x00010000 sl@0: #define DYNAMIC_RESOURCE_BIT_MASK 0x00020000 sl@0: #define CUSTOM_RESOURCE_NUMBER 20 sl@0: sl@0: /** Macro to push the item into the specified list. Item are pushed to the head of the list. */ sl@0: #define LIST_PUSH(list,item,link) \ sl@0: { \ sl@0: (item)->link = (list); \ sl@0: (list) = (item); \ sl@0: } sl@0: sl@0: /** Macro to pop the item from the specified list. Item are poped from the head of the list. */ sl@0: #define LIST_POP(list,item,link) \ sl@0: { \ sl@0: (item) = (list); \ sl@0: if ((item)) \ sl@0: { \ sl@0: (list) = (item)->link; \ sl@0: (item)->link = NULL; \ sl@0: } \ sl@0: } sl@0: sl@0: /** Macro to remove the item from the list. */ sl@0: #define LIST_REMOVE(list,item,link,className) \ sl@0: if (list) \ sl@0: { \ sl@0: className* current = (list); \ sl@0: if (current==(item)) \ sl@0: { \ sl@0: (list) = (item)->link; \ sl@0: (item)->link = NULL; \ sl@0: } \ sl@0: else \ sl@0: { \ sl@0: className* next = current->link; \ sl@0: while (next) \ sl@0: { \ sl@0: if ((item)==next) \ sl@0: { \ sl@0: current->link=next->link; \ sl@0: next->link = NULL; \ sl@0: break; \ sl@0: } \ sl@0: current = next; \ sl@0: next = next->link; \ sl@0: } \ sl@0: } \ sl@0: } sl@0: sl@0: #ifndef PRM_ENABLE_EXTENDED_VERSION sl@0: _LIT(KLddFileName, "D_RESCONTROLCLI.LDD"); sl@0: _LIT(KPddFileName, "resourcecontroller.pdd"); sl@0: #else sl@0: _LIT(KExtLddFileName, "D_EXTENDEDRESCONTROLCLI.LDD"); sl@0: _LIT(KExtPddFileName, "resourcecontrollerextended.pdd"); sl@0: #endif sl@0: sl@0: LOCAL_D RTest test(_L("RESOURCE_MANAGER_TEST")); sl@0: TBuf8<32> SpecialResName(_L8("SymbianSimulResource")); sl@0: sl@0: //Enum definition for resource classification. sl@0: enum TType {EMultiLevel = 0x1, EMultiProperty}; sl@0: enum TUsage {ESingle, EShared}; sl@0: enum TLatency {EInstantaneous, ELongLatency}; sl@0: enum TClass {EPhysical, ELogical}; sl@0: enum TSense {EPositive, ENegative, ECustom}; sl@0: sl@0: //Structure to get resource information sl@0: class TPowerResourceInfoV01 sl@0: { sl@0: public: sl@0: TClass iClass; sl@0: TLatency iLatencyGet; sl@0: TLatency iLatencySet; sl@0: TType iType; sl@0: TUsage iUsage; sl@0: TSense iSense; sl@0: TDesC8* iResourceName; sl@0: TUint iResourceId; sl@0: TInt iDefaultLevel; sl@0: TInt iMinLevel; sl@0: TInt iMaxLevel; sl@0: TInt iReserved1; sl@0: TInt iReserved2; sl@0: TInt iReserved3; sl@0: TInt iPslReserved1; sl@0: TInt iPslReserved2; sl@0: TInt iPslReserved3; sl@0: }; sl@0: sl@0: //Structure to get client information sl@0: struct TPowerClientInfoV01 sl@0: { sl@0: TUint iClientId; sl@0: TDesC8* iClientName; sl@0: }; sl@0: sl@0: //Structure for holding client information sl@0: struct RMClientInfo sl@0: { sl@0: TUint iClientId; sl@0: TUint iNumResources; sl@0: TUint iResourceIds[MAX_STATIC_RESOURCE_NUM]; //Each bit corresponds to a static resource. sl@0: }; sl@0: sl@0: //Structure for holding notification information sl@0: struct NotiInfo sl@0: { sl@0: TUint iClientId; sl@0: TInt iThreshold; sl@0: TInt iDirection; sl@0: TInt iPreviousLevel; sl@0: NotiInfo *iNext; sl@0: }; sl@0: sl@0: // Structure for holding client level sl@0: struct SPowerResourceClientLevel sl@0: { sl@0: TUint iClientId; sl@0: TUint iResourceId; sl@0: TInt iLevel; sl@0: SPowerResourceClientLevel* iNextInList; sl@0: }; sl@0: sl@0: //Structure for capturing resource information to be used by Idle thread. sl@0: struct SIdleResourceInfo sl@0: { sl@0: TUint iResourceId; sl@0: TInt iLevelOwnerId; sl@0: TInt iCurrentLevel; sl@0: TInt iReserved1; //Reserved for future use. sl@0: TInt iReserved2; //Reserved for future use. sl@0: TInt iReserved3; //Reserved for future use. sl@0: }; sl@0: sl@0: //Structure for holding resource information sl@0: struct RMResInfo sl@0: { sl@0: TBuf8<32> iName; sl@0: TUint iResourceId; sl@0: TInt iMaxLevel; sl@0: TInt iMinLevel; sl@0: TInt iDefaultLevel; sl@0: TInt iCurrentLevel; sl@0: TInt iCurrentClient; sl@0: TUint iNumClients; sl@0: TSense iSense; sl@0: TType iType; sl@0: TLatency iLatencyGet; sl@0: TLatency iLatencySet; sl@0: TUsage iUsage; sl@0: TUint iUnCondNotiCount; sl@0: NotiInfo *iCondNoti; sl@0: NotiInfo *iUncondNoti; sl@0: SPowerResourceClientLevel *iLevel; sl@0: }; sl@0: sl@0: //Test class. sl@0: class TestRM sl@0: { sl@0: private: sl@0: //Possible resource operation. sl@0: enum Operation sl@0: { sl@0: ERegisterClient = 0, sl@0: EGetClientName = 1, sl@0: EGetAllClientName = 2, sl@0: EGetClientId = 3, sl@0: EGetResourceId = 4, sl@0: EGetResourceInfo = 5, sl@0: EGetNumReosourceInUseByClient = 6, sl@0: EGetInfoOnResourceInUseByClient = 7, sl@0: EGetNumClientsUsingResource = 8, sl@0: EGetInfoOnClientsUsingResource = 9, sl@0: EChangeResourceStateSync = 10, sl@0: EChangeResourceStateAsync = 11, sl@0: EGetResourceStateSync = 12, sl@0: EGetResourceStateAsync = 13, sl@0: ERequestNotificationCond = 14, sl@0: ERequestNotificationUnCond = 15, sl@0: ECancelNotificationCond = 16, sl@0: ECancelNotificationUnCond = 17, sl@0: EOperationEnd = 18 sl@0: }; sl@0: public: sl@0: TestRM(); sl@0: void RegisterClient(); sl@0: void DeRegisterClient(TUint aClientId); sl@0: void GetClientName(TUint aClientId); sl@0: void GetClientId(TUint aClientId); sl@0: void GetResourceId(TUint aResId); sl@0: void GetResourceInfo(TUint aResId); sl@0: void GetNumResourcesInUseByClient(TInt aClientId); sl@0: void GetInfoOnResourcesInUseByClient(TInt aClientId, TUint aNumRes); sl@0: void GetNumClientsUsingResource(TUint aClientId, TUint aResId); sl@0: void GetInfoOnClientsUsingResource(TUint aResId, TUint aNumCli); sl@0: void AllocReserve(TUint aClientId); sl@0: void CheckNotification(TUint aResId, TInt newState); sl@0: void AddClientLevel(TUint aResId, TInt newState); sl@0: void UpdateClientInformation(TUint aResId, TInt aNewState); sl@0: void ChangeResourceStateSync(TUint aResId); sl@0: void ChangeResourceStateAsync(TUint aResId, TBool aReqCancel=EFalse); sl@0: void GetResourceStateSync(TUint aResId); sl@0: void GetResourceStateAsync(TUint aResId, TBool aReqCancel=EFalse); sl@0: void RequestNotification(TUint aResId); sl@0: void RequestNotificationCon(TUint aResId); sl@0: void ValidateClient(TUint aNumClients, TOwnerType aContext); sl@0: void CancelNotification(TUint aResId, TBool Cond); sl@0: void APIValidationTest(); sl@0: void SharedBinaryPositiveResourceTesting(TUint aResId); sl@0: void SharedBinaryNegativeResourceTesting(TUint aResId); sl@0: void CustomResourceTesting(TUint aResId); sl@0: void DeRegisterClientLevelFromResource(TInt aClientId, TUint aResId); sl@0: void RegressionTest(); sl@0: void TestStaticResourceWithDependency(); sl@0: void GetExtendedResStateAsyncAndVerify(TUint aResId, TInt aState, TInt aLevelOwnerId, TBool aReqCancel = EFalse); sl@0: void GetExtendedResStateAndVerify(TUint aResId, TInt aState, TInt aLevelOwnerId); sl@0: void TestDynamicResource(); sl@0: void TestDynamicResourceDependency(); sl@0: void CheckForDependencyInformation(TUint aClientId, TUint aResourceId, TUint aNumDependents, SResourceDependencyInfo* aDepResIdArray); sl@0: void SharedMultilevelNegativeResourceTesting(TUint aResId); sl@0: void SharedMultilevelPositiveResourceTesting(TUint aResId); sl@0: private: sl@0: RArray Clients; sl@0: RMResInfo Resources[MAX_STATIC_RESOURCE_NUM]; sl@0: TUint iStaticDependencyResources[MAX_STATIC_DEPENDENCY_RESOURCE_NUM]; sl@0: TInt iCurrentClientId; sl@0: TUint iMaxClientId; sl@0: TUint iMaxClients; sl@0: TUint iMaxStaticResources; sl@0: TUint iMaxStaticDependentResources; sl@0: TUint iPowerControllerId; sl@0: TUint iTestingExtendedVersion; sl@0: }; sl@0: sl@0: TBool NegativeTesting; //If true enables negative testing of API's sl@0: TInt r = KErrNone; sl@0: TBuf8<32> ClientName(_L8("Client?")); sl@0: RTestResMan lddChan; sl@0: TestRM RmTest; sl@0: sl@0: //Class constructor sl@0: TestRM::TestRM(): iCurrentClientId(-1),iMaxClientId(0), iMaxClients(0),iMaxStaticResources(0), iMaxStaticDependentResources(0), iTestingExtendedVersion(0) sl@0: { sl@0: test.Printf(_L("TestRM::TestRM()\n")); sl@0: } sl@0: sl@0: //---------------------------------------------------------------------------------------------- sl@0: //! @SYMTestCaseID KBASE-T_RESCONTROLCLI-0573 sl@0: //! @SYMTestType UT sl@0: //! @SYMPREQ PREQ1398 sl@0: //! @SYMTestCaseDesc This test case tests the client registeration functionality of resource sl@0: //! manager.It registeres a client with resource manager and stores the relevant sl@0: //! information in Clients array. Currently allows only maximum of 50 client sl@0: //! registration. sl@0: //! @SYMTestActions 0 Returns if already maximum allowable clients are registered. sl@0: //! 1 Register a client with the resource manager with a unique name. sl@0: //! 2 Appends the client information to an array for futher reference. sl@0: //! sl@0: //! @SYMTestExpectedResults client registration is successful, panics otherwise. sl@0: //! @SYMTestPriority High sl@0: //! @SYMTestStatus Implemented sl@0: //---------------------------------------------------------------------------------------------- sl@0: void TestRM::RegisterClient() sl@0: { sl@0: TUint clientId = 0; sl@0: RMClientInfo info; sl@0: if(iMaxClientId > MAX_CLIENTS) sl@0: { sl@0: test.Printf(_L("Reached maximum client allocation. Can't allocate more\n")); sl@0: return; sl@0: } sl@0: ClientName[6] = (TUint8)('0' + iMaxClientId); sl@0: r = lddChan.RegisterClient(clientId, (const TDesC*)&ClientName); sl@0: if(r != KErrNone) sl@0: test.Printf(_L("Register Client failed with %d\n"), r); sl@0: test(r == KErrNone); sl@0: info.iClientId = clientId; sl@0: info.iNumResources = 0; sl@0: for(TUint c = 0; c< MAX_STATIC_RESOURCE_NUM; c++) sl@0: info.iResourceIds[c] = 0; sl@0: iMaxClientId++; sl@0: iMaxClients++; sl@0: r = Clients.Append(info); sl@0: if(r != KErrNone) sl@0: test.Printf(_L("Client Append failed with %d\n"), r); sl@0: test(r == KErrNone); sl@0: } sl@0: sl@0: //---------------------------------------------------------------------------------------------- sl@0: //! @SYMTestCaseID KBASE-T_RESCONTROLCLI-0574 sl@0: //! @SYMTestType UT sl@0: //! @SYMPREQ PREQ1398 sl@0: //! @SYMTestCaseDesc This test case tests the client deregisteration functionality of resource sl@0: //! manager.It deregisteres a client with the resource manager, calculates sl@0: //! the resource level of each resource that the client was having requirement and sl@0: //! checks the resource level change after client deregistration. sl@0: //! @SYMTestActions 0 Deregister a client from resource manager sl@0: //! 1 Calculates the resource level of each resource the client was having requirement. sl@0: //! 2 Checks the resource level change of each resource for correctness. sl@0: //! 3 Zeros the clientId stored internally to make sure it is not referenced again. sl@0: //! sl@0: //! @SYMTestExpectedResults client deregistration is successful and also the resource level of sl@0: //! each resource the client was holding the resource level is checked sl@0: //! for correctness, panics otherwise sl@0: //! @SYMTestPriority High sl@0: //! @SYMTestStatus Implemented sl@0: //---------------------------------------------------------------------------------------------- sl@0: void TestRM::DeRegisterClient(TUint aClientId) sl@0: { sl@0: r = lddChan.DeRegisterClient(Clients[aClientId].iClientId); sl@0: if(r != KErrNone) sl@0: test.Printf(_L("Client deregistration of %d failed with %d\n"), Clients[aClientId].iClientId, r); sl@0: test(r == KErrNone); sl@0: TUint count; sl@0: for(count = 0; count < iMaxStaticResources; count++) sl@0: { sl@0: RMResInfo *pR = &Resources[count]; sl@0: NotiInfo* pI = pR->iCondNoti; sl@0: NotiInfo* ptr = NULL; sl@0: //Remove any conditional notification that this client has on resource. sl@0: while(pI != NULL) sl@0: { sl@0: if(pI->iClientId == aClientId) sl@0: { sl@0: ptr = pI; sl@0: pI = pI->iNext; sl@0: LIST_REMOVE(pR->iCondNoti, ptr, iNext, NotiInfo); sl@0: delete ptr; sl@0: } sl@0: else sl@0: pI = pI->iNext; sl@0: } sl@0: sl@0: //Remove any unconditional notification that this client has on resource. sl@0: pI = pR->iUncondNoti; sl@0: ptr = NULL; sl@0: while(pI != NULL) sl@0: { sl@0: if(pI->iClientId == aClientId) sl@0: { sl@0: ptr = pI; sl@0: pI = pI->iNext; sl@0: LIST_REMOVE(pR->iUncondNoti, ptr, iNext, NotiInfo); sl@0: delete ptr; sl@0: } sl@0: else sl@0: pI = pI->iNext; sl@0: } sl@0: } sl@0: //Remove client level sl@0: TUint res = 0; sl@0: for(count = 0; count < Clients[aClientId].iNumResources; count++) sl@0: { sl@0: res = Clients[aClientId].iResourceIds[count]; sl@0: if(res == 0) sl@0: continue; sl@0: for(TUint c = 0; c< iMaxStaticResources; c++) sl@0: { sl@0: if(Resources[c].iResourceId == res) sl@0: { sl@0: res = c; sl@0: break; sl@0: } sl@0: } sl@0: if(Resources[res].iCurrentClient == (TInt)aClientId) sl@0: { sl@0: if(!Resources[res].iUsage) sl@0: { sl@0: Resources[res].iCurrentLevel = Resources[res].iDefaultLevel; sl@0: Resources[res].iCurrentClient = -1; sl@0: Resources[res].iNumClients = 0; sl@0: } sl@0: else if(Resources[res].iSense == ECustom) sl@0: continue; sl@0: else sl@0: { sl@0: TInt maxLevel = KMinTInt; sl@0: TInt id = -1; sl@0: for(SPowerResourceClientLevel* pCL = Resources[res].iLevel; pCL != NULL; pCL = pCL->iNextInList) sl@0: { sl@0: if(pCL->iClientId == aClientId) sl@0: continue; sl@0: if((maxLevel == KMinTInt) || (maxLevel == pCL->iLevel)) sl@0: { sl@0: maxLevel = pCL->iLevel; sl@0: id = pCL->iClientId; sl@0: continue; sl@0: } sl@0: if(Resources[res].iSense == EPositive && pCL->iLevel > maxLevel) sl@0: { sl@0: maxLevel = pCL->iLevel; sl@0: id = pCL->iClientId; sl@0: } sl@0: else if(Resources[res].iSense == ENegative && pCL->iLevel < maxLevel) sl@0: { sl@0: maxLevel = pCL->iLevel; sl@0: id = pCL->iClientId; sl@0: } sl@0: } sl@0: if(id == -1) sl@0: { sl@0: Resources[res].iCurrentLevel = Resources[res].iDefaultLevel; sl@0: Resources[res].iCurrentClient = -1; sl@0: Resources[res].iNumClients = 0; sl@0: } sl@0: else sl@0: { sl@0: Resources[res].iCurrentLevel = maxLevel; sl@0: Resources[res].iCurrentClient = id; sl@0: Resources[res].iNumClients--; sl@0: } sl@0: } sl@0: } sl@0: //Remove client list entry from resource sl@0: for(SPowerResourceClientLevel* pCL = Resources[res].iLevel; pCL != NULL; pCL = pCL->iNextInList) sl@0: { sl@0: if(pCL->iClientId == aClientId) sl@0: { sl@0: LIST_REMOVE(Resources[res].iLevel, pCL, iNextInList, SPowerResourceClientLevel); sl@0: delete pCL; sl@0: break; sl@0: } sl@0: } sl@0: } sl@0: //Verify the resource state consistency sl@0: res = 0; sl@0: TInt newState; sl@0: TInt levelOwnerId; sl@0: if(iMaxClients > 1) sl@0: { sl@0: for(TUint id = 0; id < Clients[aClientId].iNumResources; id++) sl@0: { sl@0: res = Clients[aClientId].iResourceIds[id]; sl@0: if(res == 0) sl@0: continue; sl@0: for(TUint c = 0; c< iMaxStaticResources; c++) sl@0: { sl@0: if(Resources[c].iResourceId == res) sl@0: { sl@0: res = c; sl@0: break; sl@0: } sl@0: } sl@0: r = lddChan.GetResourceStateSync(Clients[0].iClientId, Resources[res].iResourceId, ETrue, newState, levelOwnerId); sl@0: if(r != KErrNone) sl@0: test.Printf(_L("GetResourceStateSync returned with %d"), r); sl@0: test(r == KErrNone); sl@0: if(newState != Resources[res].iCurrentLevel) sl@0: test.Printf(_L("newState = %d, Resources[%d].iCurrentLevel = %d"), newState, Resources[res].iResourceId, Resources[res].iCurrentLevel); sl@0: test(newState == Resources[res].iCurrentLevel); sl@0: if(Resources[res].iCurrentClient == -1) sl@0: test(levelOwnerId == -1); sl@0: else if (levelOwnerId != (TInt)Clients[Resources[res].iCurrentClient].iClientId) sl@0: { sl@0: test.Printf(_L("levelOwnerId = 0x%x, iCurrentClient = 0x%x\n"), levelOwnerId, Resources[res].iCurrentClient); sl@0: test(0); sl@0: } sl@0: } sl@0: } sl@0: Clients[aClientId].iClientId = 0; sl@0: iMaxClients--; sl@0: } sl@0: sl@0: //---------------------------------------------------------------------------------------------- sl@0: //! @SYMTestCaseID KBASE-T_RESCONTROLCLI-0575 sl@0: //! @SYMTestType UT sl@0: //! @SYMPREQ PREQ1398 sl@0: //! @SYMTestCaseDesc This test case tests the retrieval of client name functionality of resource sl@0: //! manager and compares for correctness. There are negative and positive tests. sl@0: //! @SYMTestActions If negative testing is enabled then following tests are done sl@0: //! 0 Call the API with invalid client Id (calling client Id). sl@0: //! 1 Call the API with invalid instance count of calling client Id. sl@0: //! 2 Call the API with invalid target client Id. sl@0: //! 3 Call the API with invalid instance count of target client Id. sl@0: //! Positive tests sl@0: //! 4 Call the API with valid client Ids (both calling and target client ID) sl@0: //! sl@0: //! @SYMTestExpectedResults 0 API should return with KErrAccessDenied, panics otherwise sl@0: //! 1 API should return with KErrAccessDenied, panics otherwise sl@0: //! 2 API should return with KErrNotFound, panics otherwise sl@0: //! 3 API should return with KErrNotFound, panics otherwise sl@0: //! 4 API should return KErrNone with name updated and also name sl@0: //! is checked for correctness, panics otherwise sl@0: //! @SYMTestPriority High sl@0: //! @SYMTestStatus Implemented sl@0: //---------------------------------------------------------------------------------------------- sl@0: void TestRM::GetClientName(TUint aClientId) sl@0: { sl@0: ClientName[6] = (TUint8)('0' + aClientId); sl@0: TBuf8<32> name; sl@0: if(NegativeTesting) sl@0: { sl@0: //Pass illegal client Id sl@0: r = lddChan.GetClientName(0, Clients[aClientId].iClientId, (TDes8*)&name); sl@0: test(r == KErrAccessDenied); sl@0: sl@0: //Pass illegal instance count sl@0: TUint id = Clients[aClientId].iClientId; sl@0: id = id ^ (3<<16); sl@0: r = lddChan.GetClientName(id, Clients[aClientId].iClientId, (TDes8*)&name); sl@0: test(r == KErrAccessDenied); sl@0: sl@0: //Pass illegal target client id sl@0: r = lddChan.GetClientName(Clients[aClientId].iClientId, iMaxClients, (TDes8*)&name); sl@0: test(r == KErrNotFound); sl@0: sl@0: //Pass illegal instance count of target client id sl@0: id = id ^ (1<<16); sl@0: r = lddChan.GetClientName(Clients[aClientId].iClientId, 0 ,(TDes8*)&name); sl@0: test(r == KErrNotFound); sl@0: } sl@0: r = lddChan.GetClientName(Clients[aClientId].iClientId, Clients[aClientId].iClientId, (TDes8*)&name); sl@0: if(r != KErrNone) sl@0: test.Printf(_L("GetClientName of ClientId 0x%x returned with %d"), Clients[aClientId].iClientId, r); sl@0: test(r == KErrNone); sl@0: if(name.Compare(ClientName)) sl@0: test(0); sl@0: } sl@0: sl@0: sl@0: //---------------------------------------------------------------------------------------------- sl@0: //! @SYMTestCaseID KBASE-T_RESCONTROLCLI-0576 sl@0: //! @SYMTestType UT sl@0: //! @SYMPREQ PREQ1398 sl@0: //! @SYMTestCaseDesc This test case tests the retrieval of client ID functionality of resource sl@0: //! manager and compares for correctness. There are negative and positive tests. sl@0: //! @SYMTestActions If negative testing is enabled then following tests are done sl@0: //! 0 Call the API with invalid client Id (calling client Id). sl@0: //! 1 Call the API with invalid instance count of calling client Id. sl@0: //! 2 Call the API with client name greater than maximum allowable sl@0: //! client name (32 characters). sl@0: //! 3 Call the API with name not registered with resource manager sl@0: //! (non-existing name). sl@0: //! Positive tests sl@0: //! 4 Call the API with valid client Id. sl@0: //! sl@0: //! @SYMTestExpectedResults 0 API should return with KErrAccessDenied, panics otherwise sl@0: //! 1 API should return with KErrAccessDenied, panics otherwise sl@0: //! 2 API should return with KErrTooBig, panics otherwise sl@0: //! 3 API should return with KErrNotFound, panics otherwise sl@0: //! 4 API should return KErrNone with client Id updated and also Id sl@0: //! is checked for correctness, panics otherwise sl@0: //! @SYMTestPriority High sl@0: //! @SYMTestStatus Implemented sl@0: //---------------------------------------------------------------------------------------------- sl@0: void TestRM::GetClientId(TUint aClientId) sl@0: { sl@0: TUint clientId; sl@0: ClientName[6] = (TUint8)('0' + aClientId); sl@0: if(NegativeTesting) sl@0: { sl@0: //Pass illegial client Id sl@0: r = lddChan.GetClientId(0, (TDesC8&)ClientName, Clients[aClientId].iClientId); sl@0: test(r == KErrAccessDenied); sl@0: sl@0: //Pass illegal instance count sl@0: TUint id = Clients[aClientId].iClientId; sl@0: id = id ^ (3<<16); sl@0: r = lddChan.GetClientId(id, (TDesC8&)ClientName, Clients[aClientId].iClientId); sl@0: test(r == KErrAccessDenied); sl@0: sl@0: TBuf8<50> badName = _L8("Clientnamegreaterthan32characters"); sl@0: r = lddChan.GetClientId(Clients[aClientId].iClientId, (TDesC8&)badName, clientId); sl@0: test(r == KErrTooBig); sl@0: sl@0: ClientName[6] = (TUint8)('0' + iMaxClients + 1); sl@0: r = lddChan.GetClientId(Clients[aClientId].iClientId, (TDesC8&)ClientName, clientId); sl@0: test(r == KErrNotFound); sl@0: } sl@0: ClientName[6] = (TUint8)('0' + aClientId); sl@0: r = lddChan.GetClientId(Clients[aClientId].iClientId, (TDesC8&)ClientName, clientId); sl@0: if(r != KErrNone) sl@0: test.Printf(_L("GetClientId returned with %d"), r); sl@0: test(r == KErrNone); sl@0: if(clientId != Clients[aClientId].iClientId) sl@0: test.Printf(_L("ClientId = 0x%x, Expected ClientId = 0x%x"), clientId, Clients[aClientId].iClientId); sl@0: test(clientId == Clients[aClientId].iClientId); sl@0: } sl@0: sl@0: //---------------------------------------------------------------------------------------------- sl@0: //! @SYMTestCaseID KBASE-T_RESCONTROLCLI-0577 sl@0: //! @SYMTestType UT sl@0: //! @SYMPREQ PREQ1398 sl@0: //! @SYMTestCaseDesc This test case tests the retrieval of resource ID functionality of resource sl@0: //! manager and compares for correctness. There are negative and positive tests. sl@0: //! @SYMTestActions If negative testing is enabled then following tests are done sl@0: //! 0 Call the API with invalid client Id (calling client Id). sl@0: //! 1 Call the API with invalid instance count of calling client Id. sl@0: //! 2 Call the API with resource name greater than maximum allowable sl@0: //! resource name (32 characters). sl@0: //! 3 Call the API with name not registered with resource manager sl@0: //! (non-existing name). sl@0: //! Positive tests sl@0: //! 4 Call the API with valid client Id and resource name. sl@0: //! sl@0: //! @SYMTestExpectedResults 0 API should return with KErrAccessDenied, panics otherwise sl@0: //! 1 API should return with KErrAccessDenied, panics otherwise sl@0: //! 2 API should return with KErrTooBig, panics otherwise sl@0: //! 3 API should return with KErrNotFound, panics otherwise sl@0: //! 4 API should return KErrNone with resource Id updated and also Id sl@0: //! is checked for correctness, panics otherwise sl@0: //! @SYMTestPriority High sl@0: //! @SYMTestStatus Implemented sl@0: //---------------------------------------------------------------------------------------------- sl@0: void TestRM::GetResourceId(TUint aResId) sl@0: { sl@0: TUint resId; sl@0: if(NegativeTesting) sl@0: { sl@0: r = lddChan.GetResourceId(iMaxClients, Resources[aResId].iName, resId); sl@0: test(r == KErrAccessDenied); sl@0: sl@0: //Pass illegal instance count sl@0: TUint id = Clients[iCurrentClientId].iClientId; sl@0: id = id ^ (3<<17); sl@0: r = lddChan.GetResourceId(id, (TDesC8&)Resources[aResId].iName, resId); sl@0: test(r == KErrAccessDenied); sl@0: sl@0: TBuf8<50> badName = _L8("Resourcenamegreaterthen32characters"); sl@0: r = lddChan.GetResourceId(Clients[iCurrentClientId].iClientId, (TDesC8&)badName, resId); sl@0: test(r == KErrTooBig); sl@0: badName = Resources[aResId].iName; sl@0: badName[0] = '0' + 1; sl@0: r = lddChan.GetResourceId(Clients[iCurrentClientId].iClientId, (TDesC8&)badName, resId); sl@0: test(r == KErrNotFound); sl@0: } sl@0: r = lddChan.GetResourceId(Clients[iCurrentClientId].iClientId, (TDesC8&)Resources[aResId].iName, resId); sl@0: if(r != KErrNone) sl@0: test.Printf(_L("Return value of GetResourceId %d"), r); sl@0: test(r == KErrNone); sl@0: if(resId != Resources[aResId].iResourceId) sl@0: test.Printf(_L("resId = %d ... aResId = %d"), resId, Resources[aResId].iResourceId); sl@0: test(resId == Resources[aResId].iResourceId); sl@0: } sl@0: sl@0: sl@0: //---------------------------------------------------------------------------------------------- sl@0: //! @SYMTestCaseID KBASE-T_RESCONTROLCLI-0578 sl@0: //! @SYMTestType UT sl@0: //! @SYMPREQ PREQ1398 sl@0: //! @SYMTestCaseDesc This test case tests the retrieval of resource information of a specified sl@0: //! resource functionality of resource manager and compares each info for correctness. sl@0: //! There are negative and positive tests. sl@0: //! @SYMTestActions If negative testing is enabled then following tests are done sl@0: //! 0 Call the API with invalid client Id (calling client Id). sl@0: //! 1 Call the API with invalid instance count of calling client Id. sl@0: //! 2 Call the API with invalid resource id. sl@0: //! Positive tests sl@0: //! 3 Call the API with valid client Id and resource id. sl@0: //! sl@0: //! @SYMTestExpectedResults 0 API should return with KErrAccessDenied, panics otherwise sl@0: //! 1 API should return with KErrAccessDenied, panics otherwise sl@0: //! 2 API should return with KErrNotFound, panics otherwise sl@0: //! 3 API should return KErrNone with resource information updated and also sl@0: //! each information is checked for correctness, panics otherwise sl@0: //! @SYMTestPriority High sl@0: //! @SYMTestStatus Implemented sl@0: //---------------------------------------------------------------------------------------------- sl@0: void TestRM::GetResourceInfo(TUint aResId) sl@0: { sl@0: RBuf8 infoBuf; sl@0: infoBuf.Create(sizeof(TPowerResourceInfoV01)); sl@0: if(NegativeTesting) sl@0: { sl@0: r = lddChan.GetResourceInfo(iMaxClients-5, aResId+1, (TAny*)(TDes8*)&infoBuf); sl@0: test(r == KErrAccessDenied); sl@0: sl@0: //Pass illegal instance count sl@0: TUint id = Clients[iCurrentClientId].iClientId; sl@0: id = id ^ (5<<17); sl@0: r = lddChan.GetResourceInfo(id, aResId+1, (TAny*)infoBuf.Ptr()); sl@0: test(r == KErrAccessDenied); sl@0: sl@0: r = lddChan.GetResourceInfo(Clients[iCurrentClientId].iClientId, iMaxStaticResources + 30, (TAny*)(TDes8*)&infoBuf); sl@0: test(r == KErrNotFound); sl@0: r = lddChan.GetResourceInfo(Clients[iCurrentClientId].iClientId, 26, (TAny*)(TDes8*)&infoBuf); sl@0: test(r == KErrNotFound); sl@0: } sl@0: r = lddChan.GetResourceInfo(Clients[iCurrentClientId].iClientId, Resources[aResId].iResourceId, (TAny*)(TDes8*)&infoBuf); sl@0: if(r != KErrNone) sl@0: test.Printf(_L("GetResourceInfo returned with %d"), r); sl@0: test(r == KErrNone); sl@0: TPowerResourceInfoV01 *ptr = (TPowerResourceInfoV01*)infoBuf.Ptr(); sl@0: //Compare results. sl@0: test(ptr->iResourceId == Resources[aResId].iResourceId); sl@0: test(ptr->iLatencyGet == Resources[aResId].iLatencyGet); sl@0: test(ptr->iLatencySet == Resources[aResId].iLatencySet); sl@0: test(ptr->iType == Resources[aResId].iType); sl@0: test(ptr->iUsage == Resources[aResId].iUsage); sl@0: test(ptr->iSense == Resources[aResId].iSense); sl@0: test(ptr->iMaxLevel == Resources[aResId].iMaxLevel); sl@0: test(ptr->iMinLevel == Resources[aResId].iMinLevel); sl@0: test(ptr->iDefaultLevel == Resources[aResId].iDefaultLevel); sl@0: if(ptr->iUsage == ESingle && Resources[aResId].iNumClients >1) //Single user resource cannot have more than 1 client. sl@0: test(0); sl@0: infoBuf.Close(); sl@0: } sl@0: sl@0: //---------------------------------------------------------------------------------------------- sl@0: //! @SYMTestCaseID KBASE-T_RESCONTROLCLI-0579 sl@0: //! @SYMTestType UT sl@0: //! @SYMPREQ PREQ1398 sl@0: //! @SYMTestCaseDesc This test case tests retrieval of number of resources the requested client has sl@0: //! requirement functionality of resource manager and compares with stored information sl@0: //! for correctness.There are negative and positive tests. sl@0: //! @SYMTestActions If negative testing is enabled then following tests are done sl@0: //! 0 Call the API with invalid client Id (calling client Id). sl@0: //! 1 Call the API with invalid instance count of calling client Id. sl@0: //! 2 Call the API with invalid target client Id. sl@0: //! 3 Call the API with invalid instance count of target client Id. sl@0: //! Positive tests sl@0: //! 4 Call the API with valid calling and target client Id. sl@0: //! sl@0: //! @SYMTestExpectedResults 0 API should return with KErrAccessDenied, panics otherwise sl@0: //! 1 API should return with KErrAccessDenied, panics otherwise sl@0: //! 2 API should return with KErrNotFound, panics otherwise sl@0: //! 3 API should return with KErrNotFound, panics otherwise sl@0: //! 4 API should return KErrNone with number of resources the requested client has sl@0: //! requirement updated and also is checked for correctness, panics otherwise sl@0: //! @SYMTestPriority High sl@0: //! @SYMTestStatus Implemented sl@0: //---------------------------------------------------------------------------------------------- sl@0: void TestRM::GetNumResourcesInUseByClient(TInt aClientId) sl@0: { sl@0: TUint numRes; sl@0: if(NegativeTesting) sl@0: { sl@0: //Pass illegial client Id sl@0: r = lddChan.GetNumResourcesInUseByClient(23, Clients[aClientId].iClientId, numRes); sl@0: test(r == KErrAccessDenied); sl@0: sl@0: //Pass illegal instance count sl@0: TUint id = Clients[aClientId].iClientId; sl@0: id = id ^ (1<<16); sl@0: r = lddChan.GetNumResourcesInUseByClient(id, Clients[aClientId].iClientId, numRes); sl@0: test(r == KErrAccessDenied); sl@0: sl@0: //Pass illegal target client id sl@0: r = lddChan.GetNumResourcesInUseByClient(Clients[aClientId].iClientId, iMaxClients, numRes); sl@0: test(r == KErrNotFound); sl@0: sl@0: //Pass illegal instance count of target client id sl@0: id = id ^ (3<<16); sl@0: r = lddChan.GetNumResourcesInUseByClient(Clients[aClientId].iClientId, id ,numRes); sl@0: test(r == KErrNotFound); sl@0: } sl@0: sl@0: if(aClientId == -1) sl@0: { sl@0: r = lddChan.GetNumResourcesInUseByClient(Clients[0].iClientId, 0, numRes); sl@0: if(r != KErrNone) sl@0: test.Printf(_L("GetNumResourcesInUseByClient returned with %d"), r); sl@0: test(r == KErrNone); sl@0: if((!iTestingExtendedVersion) && (numRes > MAX_STATIC_RESOURCE_NUM)) sl@0: test(0); sl@0: if(iMaxStaticResources == 0) sl@0: iMaxStaticResources = numRes; sl@0: else sl@0: test(numRes == (iMaxStaticResources + iMaxStaticDependentResources)); sl@0: } sl@0: else sl@0: { sl@0: r = lddChan.GetNumResourcesInUseByClient(Clients[aClientId].iClientId, Clients[aClientId].iClientId, numRes); sl@0: if(r != KErrNone) sl@0: test.Printf(_L("GetNumResourceInUseByClient returned with %d"), r); sl@0: test(r == KErrNone); sl@0: if(numRes != Clients[aClientId].iNumResources) sl@0: test.Printf(_L("numRes = %d, iNumResources = %d"), numRes, Clients[aClientId].iNumResources); sl@0: test(numRes == Clients[aClientId].iNumResources); sl@0: } sl@0: } sl@0: sl@0: //---------------------------------------------------------------------------------------------- sl@0: //! @SYMTestCaseID KBASE-T_RESCONTROLCLI-0580 sl@0: //! @SYMTestType UT sl@0: //! @SYMPREQ PREQ1398 sl@0: //! @SYMTestCaseDesc This test case tests retrieval of information about resources the requested client has sl@0: //! requirement functionality of resource manager and compares with stored information sl@0: //! for correctness.There are negative and positive tests. sl@0: //! @SYMTestActions If negative testing is enabled then following tests are done sl@0: //! 0 Call the API with invalid client Id (calling client Id). sl@0: //! 1 Call the API with invalid instance count of calling client Id. sl@0: //! 2 Call the API with invalid target client Id. sl@0: //! 3 Call the API with invalid instance count of target client Id. sl@0: //! 4 Call the API with null buffer (buffer where the resource information will be updated). sl@0: //! 5 Call the API with the number of resource information to be updated as 0 (specifies the sl@0: //! size of the buffer). sl@0: //! Positive tests sl@0: //! 6 Call the API with valid calling and target client Id, buffer and its size. sl@0: //! sl@0: //! @SYMTestExpectedResults 0 API should return with KErrAccessDenied, panics otherwise sl@0: //! 1 API should return with KErrAccessDenied, panics otherwise sl@0: //! 2 API should return with KErrNotFound, panics otherwise sl@0: //! 3 API should return with KErrNotFound, panics otherwise sl@0: //! 4 API should return with KErrArgument, panics otherwise sl@0: //! 5 API should return with KErrArgument, panics otherwise sl@0: //! 6 API should return KErrNone with resource information about resources the requested sl@0: //! client has requirement updated and also is checked for correctness, panics otherwise sl@0: //! @SYMTestPriority High sl@0: //! @SYMTestStatus Implemented sl@0: //---------------------------------------------------------------------------------------------- sl@0: void TestRM::GetInfoOnResourcesInUseByClient(TInt aClientId, TUint aNumRes) sl@0: { sl@0: RBuf8 info; sl@0: info.Create(aNumRes * sizeof(TPowerResourceInfoV01)); sl@0: if(NegativeTesting) sl@0: { sl@0: //Pass illegial client Id sl@0: r = lddChan.GetInfoOnResourcesInUseByClient(32, Clients[aClientId].iClientId, aNumRes, (TAny*)(TDes8*)&info); sl@0: test(r == KErrAccessDenied); sl@0: sl@0: //Pass illegal instance count sl@0: TUint id = Clients[aClientId].iClientId; sl@0: id = id ^ (1<<16); sl@0: r = lddChan.GetInfoOnResourcesInUseByClient(id, Clients[aClientId].iClientId, aNumRes, (TAny*)(TDes8*)&info); sl@0: test(r == KErrAccessDenied); sl@0: sl@0: //Pass illegal target client id sl@0: r = lddChan.GetInfoOnResourcesInUseByClient(Clients[aClientId].iClientId, iMaxClients, aNumRes, (TAny*)(TDes8*)&info); sl@0: test(r == KErrNotFound); sl@0: sl@0: //Pass illegal instance count of target client id sl@0: id = id ^ (3<<16); sl@0: r = lddChan.GetInfoOnResourcesInUseByClient(Clients[aClientId].iClientId, id ,aNumRes,(TAny*)(TDes8*)&info); sl@0: test(r == KErrNotFound); sl@0: sl@0: //Pass null buffer sl@0: r = lddChan.GetInfoOnResourcesInUseByClient(Clients[aClientId].iClientId, Clients[aClientId].iClientId ,aNumRes, (TAny*)NULL); sl@0: test(r == KErrArgument); sl@0: sl@0: //Pass required resources as 0 sl@0: TUint tempRes = 0; sl@0: r = lddChan.GetInfoOnResourcesInUseByClient(Clients[aClientId].iClientId, Clients[aClientId].iClientId, tempRes, (TAny*)(TDes8*)&info); sl@0: test(r == KErrArgument); sl@0: } sl@0: sl@0: if(aClientId == -1) sl@0: { sl@0: r = lddChan.GetInfoOnResourcesInUseByClient(Clients[0].iClientId, 0, aNumRes, (TAny*)(TDes8*)&info); sl@0: if(r != KErrNone) sl@0: test.Printf(_L("GetInfoOnResourceInUseByClient returned with %d"), r); sl@0: test(r == KErrNone); sl@0: if(aNumRes != (iMaxStaticResources + iMaxStaticDependentResources)) sl@0: test.Printf(_L("aNumRes = %d, iMaxStaticResources = %d"), aNumRes, iMaxStaticResources); sl@0: test(aNumRes == (iMaxStaticResources + iMaxStaticDependentResources)); sl@0: sl@0: //Fill in the resource information sl@0: TInt newState, levelOwnerId; sl@0: TPowerResourceInfoV01 *ptr = (TPowerResourceInfoV01*)info.Ptr(); sl@0: sl@0: TUint extCount = 0; sl@0: for(TUint count = 0; count < aNumRes; count++) sl@0: { sl@0: r = lddChan.GetResourceStateSync(Clients[0].iClientId, ptr->iResourceId, ETrue, newState, levelOwnerId); sl@0: if(r != KErrNone) sl@0: test.Printf(_L("GetResourceStateSync failed for ClientId = %d, resourceId = %d with return value %d\n"), Clients[0].iClientId, count+1, r); sl@0: test(r == KErrNone); sl@0: test.Printf(_L("Info of Resource %d\n"), count+1); sl@0: test.Printf(_L("Resource Id %d\n"), ptr->iResourceId); sl@0: test.Printf(_L("Resource Type %d\n"), ptr->iType); sl@0: test.Printf(_L("Resource Sense %d\n"), ptr->iSense); sl@0: test.Printf(_L("Resource Latency Get %d\n"), ptr->iLatencyGet); sl@0: test.Printf(_L("Resource Latency Set %d\n"), ptr->iLatencySet); sl@0: test.Printf(_L("Resource usage %d\n"), ptr->iUsage); sl@0: test.Printf(_L("Resource MinLevel %d\n"), ptr->iMinLevel); sl@0: test.Printf(_L("Resource MaxLevel %d\n"), ptr->iMaxLevel); sl@0: test.Printf(_L("Resource DefaultLevel %d\n"), ptr->iDefaultLevel); sl@0: sl@0: if(iTestingExtendedVersion && (ptr->iResourceId & DEPENDENCY_RESOURCE_BIT_MASK)) sl@0: { sl@0: iStaticDependencyResources[extCount++] = ptr->iResourceId; sl@0: ptr++; sl@0: continue; sl@0: } sl@0: if(iTestingExtendedVersion && (ptr->iResourceId & DYNAMIC_RESOURCE_BIT_MASK)) sl@0: { sl@0: ptr++; sl@0: continue; sl@0: } sl@0: Resources[count].iName.Copy(*ptr->iResourceName); sl@0: Resources[count].iResourceId = ptr->iResourceId; sl@0: Resources[count].iMaxLevel = ptr->iMaxLevel; sl@0: Resources[count].iMinLevel = ptr->iMinLevel; sl@0: Resources[count].iDefaultLevel = ptr->iDefaultLevel; sl@0: Resources[count].iNumClients = 0; sl@0: Resources[count].iCurrentClient = -1; sl@0: Resources[count].iCurrentLevel = newState; sl@0: Resources[count].iType = ptr->iType; sl@0: Resources[count].iSense = ptr->iSense; sl@0: Resources[count].iLatencyGet = ptr->iLatencyGet; sl@0: Resources[count].iLatencySet = ptr->iLatencySet; sl@0: Resources[count].iUsage = ptr->iUsage; sl@0: Resources[count].iUnCondNotiCount = 0; sl@0: Resources[count].iCondNoti = NULL; sl@0: Resources[count].iUncondNoti = NULL; sl@0: Resources[count].iLevel = NULL; sl@0: ptr++; sl@0: } sl@0: iMaxStaticResources -= extCount; sl@0: iMaxStaticDependentResources = extCount; sl@0: info.Close(); sl@0: return; sl@0: } sl@0: r = lddChan.GetInfoOnResourcesInUseByClient(Clients[aClientId].iClientId, Clients[aClientId].iClientId, aNumRes, (TAny*)&info); sl@0: if(aNumRes != Clients[aClientId].iNumResources) sl@0: { sl@0: test.Printf(_L("Expected Resource Num = %d, Returned = %d\n"), Clients[aClientId].iNumResources, aNumRes); sl@0: test(0); sl@0: } sl@0: if(aNumRes == 0) sl@0: { sl@0: test((r == KErrArgument) || (r == KErrNone)); sl@0: info.Close(); sl@0: return; sl@0: } sl@0: else sl@0: test(r == KErrNone); sl@0: TPowerResourceInfoV01 *ptr = (TPowerResourceInfoV01*)info.Ptr(); sl@0: for(TUint count = 0; count < Clients[aClientId].iNumResources; count++) sl@0: { sl@0: if(Clients[aClientId].iResourceIds[count] == 0) sl@0: continue; sl@0: TUint c; sl@0: for(c = 0; c < Clients[aClientId].iNumResources; c++) sl@0: { sl@0: if(Clients[aClientId].iResourceIds[c] == ptr->iResourceId) sl@0: break; sl@0: } sl@0: if(c == Clients[aClientId].iNumResources) sl@0: test(0); sl@0: //Find the resource from resource list sl@0: for(c = 0; c < iMaxStaticResources; c++) sl@0: { sl@0: if(Resources[c].iResourceId == ptr->iResourceId) sl@0: break; sl@0: } sl@0: if(c == iMaxStaticResources) sl@0: test(0); sl@0: test(Resources[c].iResourceId == ptr->iResourceId); sl@0: test(Resources[c].iMaxLevel == ptr->iMaxLevel); sl@0: test(Resources[c].iMinLevel == ptr->iMinLevel); sl@0: test(Resources[c].iDefaultLevel == ptr->iDefaultLevel); sl@0: test(Resources[c].iType == ptr->iType); sl@0: test(Resources[c].iSense == ptr->iSense); sl@0: test(Resources[c].iLatencyGet == ptr->iLatencyGet); sl@0: test(Resources[c].iLatencySet == ptr->iLatencySet); sl@0: test(Resources[c].iUsage == ptr->iUsage); sl@0: test(!Resources[c].iName.Compare(*ptr->iResourceName)); sl@0: ptr++; sl@0: } sl@0: info.Close(); sl@0: } sl@0: sl@0: //---------------------------------------------------------------------------------------------- sl@0: //! @SYMTestCaseID KBASE-T_RESCONTROLCLI-0581 sl@0: //! @SYMTestType UT sl@0: //! @SYMPREQ PREQ1398 sl@0: //! @SYMTestCaseDesc This test case tests retrieval of number of clients holding requirement on sl@0: //! the requested resource functionality of resource manager and compares with stored sl@0: //! information for correctness.There are negative and positive tests. sl@0: //! @SYMTestActions If negative testing is enabled then following tests are done sl@0: //! 0 Call the API with invalid client Id (calling client Id). sl@0: //! 1 Call the API with invalid instance count of calling client Id. sl@0: //! 2 Call the API with invalid resource Id. sl@0: //! Positive tests sl@0: //! 3 Call the API with valid calling client Id and resource Id. sl@0: //! sl@0: //! @SYMTestExpectedResults 0 API should return with KErrAccessDenied, panics otherwise sl@0: //! 1 API should return with KErrAccessDenied, panics otherwise sl@0: //! 2 API should return with KErrNotFound, panics otherwise sl@0: //! 3 API should return KErrNone with number of clients holding requirement on sl@0: //! the requested resource updated and also is checked for correctness, panics otherwise sl@0: //! @SYMTestPriority High sl@0: //! @SYMTestStatus Implemented sl@0: //---------------------------------------------------------------------------------------------- sl@0: void TestRM::GetNumClientsUsingResource(TUint aClientId, TUint aResId) sl@0: { sl@0: TUint clientNum = 0; sl@0: if(NegativeTesting) sl@0: { sl@0: //Pass illegial client Id sl@0: r = lddChan.GetNumClientsUsingResource(32, 1, clientNum); sl@0: test(r == KErrAccessDenied); sl@0: sl@0: //Pass illegal instance count sl@0: TUint id = Clients[aClientId].iClientId; sl@0: id = id ^ (1<<16); sl@0: r = lddChan.GetNumClientsUsingResource(id, 1, clientNum); sl@0: test(r == KErrAccessDenied); sl@0: sl@0: //Invalid resource id sl@0: r = lddChan.GetNumClientsUsingResource(Clients[aClientId].iClientId, iMaxStaticResources+40, clientNum); sl@0: test(r == KErrNotFound); sl@0: } sl@0: if((TInt)aResId == -1) sl@0: r = lddChan.GetNumClientsUsingResource(Clients[aClientId].iClientId, 0, clientNum); sl@0: else sl@0: r = lddChan.GetNumClientsUsingResource(Clients[aClientId].iClientId, Resources[aResId].iResourceId, clientNum); sl@0: if(r != KErrNone) sl@0: test.Printf(_L("GetNumClientsUsingResource for client 0x%x failed with %d"), Clients[aClientId].iClientId, r); sl@0: test(r==KErrNone); sl@0: if((TInt)aResId == -1) sl@0: { sl@0: if(clientNum != (TUint)(Clients.Count() + 1)) sl@0: test.Printf(_L("ClientNum = %d, Expected clientNum = %d"), clientNum, Clients.Count()+1); sl@0: test(clientNum == (TUint)(Clients.Count() + 1)); sl@0: } sl@0: else sl@0: { sl@0: test(Resources[aResId].iNumClients == clientNum); sl@0: if(!Resources[aResId].iUsage && clientNum > 1) //Single user resource cannot have more that one client sl@0: test(0); sl@0: } sl@0: } sl@0: sl@0: //---------------------------------------------------------------------------------------------- sl@0: //! @SYMTestCaseID KBASE-T_RESCONTROLCLI-0582 sl@0: //! @SYMTestType UT sl@0: //! @SYMPREQ PREQ1398 sl@0: //! @SYMTestCaseDesc This test case tests retrieval of information about clients holding requirement on sl@0: //! the passed resource functionality of resource manager and compares with stored information sl@0: //! for correctness.There are negative and positive tests. sl@0: //! @SYMTestActions If negative testing is enabled then following tests are done sl@0: //! 0 Call the API with invalid client Id (calling client Id). sl@0: //! 1 Call the API with invalid instance count of calling client Id. sl@0: //! 2 Call the API with invalid resource Id. sl@0: //! 3 Call the API with null buffer (buffer where the resource information will be updated). sl@0: //! 4 Call the API with the number of resource information to be updated as 0 (specifies the sl@0: //! size of the buffer). sl@0: //! Positive tests sl@0: //! 5 Call the API with valid calling and target client Id, buffer and its size. sl@0: //! sl@0: //! @SYMTestExpectedResults 0 API should return with KErrAccessDenied, panics otherwise sl@0: //! 1 API should return with KErrAccessDenied, panics otherwise sl@0: //! 2 API should return with KErrNotFound, panics otherwise sl@0: //! 3 API should return with KErrArgument, panics otherwise sl@0: //! 4 API should return with KErrArgument, panics otherwise sl@0: //! 5 API should return KErrNone with resource information about clients holding requirement sl@0: //! on the passed resource and also is checked for correctness, panics otherwise sl@0: //! @SYMTestPriority High sl@0: //! @SYMTestStatus Implemented sl@0: //---------------------------------------------------------------------------------------------- sl@0: void TestRM::GetInfoOnClientsUsingResource(TUint aResId, TUint aNumCli) sl@0: { sl@0: RBuf8 info; sl@0: info.Create(aNumCli * sizeof(TPowerClientInfoV01)); sl@0: if(NegativeTesting) sl@0: { sl@0: //Pass illegial client Id sl@0: r = lddChan.GetInfoOnClientsUsingResource(2, 1, aNumCli, (TAny*)(TDes8*)&info); sl@0: test(r == KErrAccessDenied); sl@0: sl@0: //Pass illegal instance count sl@0: TUint id = Clients[iCurrentClientId].iClientId; sl@0: id = id ^ (1<<16); sl@0: r = lddChan.GetInfoOnClientsUsingResource(id, 1, aNumCli, (TAny*)(TDes8*)&info); sl@0: test(r == KErrAccessDenied); sl@0: sl@0: //Invalid resource id sl@0: r = lddChan.GetInfoOnClientsUsingResource(Clients[iCurrentClientId].iClientId, iMaxStaticResources+40, aNumCli, (TAny*)(TDes8*)&info); sl@0: test(r == KErrNotFound); sl@0: sl@0: //Pass null buffer sl@0: r = lddChan.GetInfoOnClientsUsingResource(Clients[iCurrentClientId].iClientId, 1 ,aNumCli, (TAny*)NULL); sl@0: test(r == KErrArgument); sl@0: sl@0: //Pass required resources as 0 sl@0: TUint tempCli = 0; sl@0: r = lddChan.GetInfoOnClientsUsingResource(Clients[iCurrentClientId].iClientId, 1 ,tempCli, (TAny*)(TDes8*)&info); sl@0: test(r == KErrArgument); sl@0: } sl@0: if((TInt)aResId == -1) sl@0: r = lddChan.GetInfoOnClientsUsingResource(Clients[iCurrentClientId].iClientId, 0, aNumCli, (TAny*)(TDes8*)&info); sl@0: else sl@0: r = lddChan.GetInfoOnClientsUsingResource(Clients[iCurrentClientId].iClientId, Resources[aResId].iResourceId, aNumCli, (TAny*)(TDes8*)&info); sl@0: if(r == KErrArgument) sl@0: { sl@0: if(aResId != 0) sl@0: test(Resources[aResId].iNumClients == 0); sl@0: info.Close(); sl@0: return; sl@0: } sl@0: test(r == KErrNone); sl@0: TPowerClientInfoV01 *ptr = (TPowerClientInfoV01*)info.Ptr(); sl@0: if((TInt)aResId == -1) sl@0: { sl@0: test(aNumCli == (TUint)(Clients.Count() + 1)); sl@0: TUint c = 0; sl@0: for(TUint count = 0; count < aNumCli; count++) sl@0: { sl@0: //Skip comparision of first client as that will be PowerController. sl@0: if(ptr->iClientId == iPowerControllerId) sl@0: { sl@0: ptr++; sl@0: continue; sl@0: } sl@0: for(c = 0; c< iMaxClients; c++) sl@0: { sl@0: if(ptr->iClientId == Clients[c].iClientId) sl@0: break; sl@0: } sl@0: if(c == iMaxClients) sl@0: test(0); sl@0: ptr++; sl@0: } sl@0: } sl@0: else sl@0: { sl@0: if(aNumCli != Resources[aResId].iNumClients) sl@0: test.Printf(_L("aNumCli = %d, Expected numClients = %d\n"), aNumCli, Resources[aResId].iNumClients); sl@0: test(aNumCli == Resources[aResId].iNumClients); sl@0: //Compare results sl@0: SPowerResourceClientLevel *level = Resources[aResId].iLevel; sl@0: TUint c = 0; sl@0: for(TUint count = 0; count < aNumCli; count++) sl@0: { sl@0: SPowerResourceClientLevel *pL = Resources[aResId].iLevel; sl@0: for(c =0;ciClientId].iClientId == ptr->iClientId) sl@0: break; sl@0: pL = pL->iNextInList; sl@0: } sl@0: if(c == aNumCli) sl@0: { sl@0: test.Printf(_L("Client Id %d is not in the resource clientlevel list\n"), Clients[level->iClientId].iClientId); sl@0: test(0); sl@0: } sl@0: level = level->iNextInList; sl@0: ptr++; sl@0: } sl@0: } sl@0: info.Close(); sl@0: } sl@0: sl@0: //---------------------------------------------------------------------------------------------- sl@0: //! @SYMTestCaseID KBASE-T_RESCONTROLCLI-0583 sl@0: //! @SYMTestType UT sl@0: //! @SYMPREQ PREQ1398 sl@0: //! @SYMTestCaseDesc This test case tests preallocation of memory for resource manager internal sl@0: //! structure.There are negative and positive tests. sl@0: //! @SYMTestActions If negative testing is enabled then following tests are done sl@0: //! 0 Call the API with invalid client Id sl@0: //! 1 Call the API with invalid instance count of client Id. sl@0: //! Positive tests sl@0: //! 2 Call the API with valid client Id. sl@0: //! sl@0: //! @SYMTestExpectedResults 0 API should return with KErrAccessDenied, panics otherwise sl@0: //! 1 API should return with KErrAccessDenied, panics otherwise sl@0: //! 2 API should return with KErrNone, panic otherwise. Really cannot sl@0: //! test this for correctness. sl@0: //! @SYMTestPriority High sl@0: //! @SYMTestStatus Implemented sl@0: //---------------------------------------------------------------------------------------------- sl@0: void TestRM::AllocReserve(TUint aClientId) sl@0: { sl@0: if(NegativeTesting) sl@0: { sl@0: //Pass illegial client Id sl@0: r = lddChan.AllocReserve(11, 0, 3); sl@0: test(r == KErrAccessDenied); sl@0: sl@0: //Pass illegal instance count sl@0: TUint id = Clients[aClientId].iClientId; sl@0: id = id ^ (1<<16); sl@0: r = lddChan.AllocReserve(id, 0, 0); sl@0: test(r == KErrAccessDenied); sl@0: sl@0: } sl@0: r = lddChan.AllocReserve(Clients[iCurrentClientId].iClientId, 1, 0); sl@0: if(r != KErrNone) sl@0: test.Printf(_L("Alloc Reserve failed with %d"), r); sl@0: test(r == KErrNone); sl@0: } sl@0: sl@0: //This function validates the conditional and unconditional notification for the sl@0: //specified resource state change. sl@0: void TestRM::CheckNotification(TUint aResId, TInt newState) sl@0: { sl@0: if(newState == Resources[aResId].iCurrentLevel) sl@0: return; sl@0: //Return if the newState is in decreasing order with respect to sense. sl@0: if(Resources[aResId].iUsage == EShared && Resources[aResId].iCurrentClient != -1) sl@0: { sl@0: if(Resources[aResId].iSense == EPositive) sl@0: { sl@0: if(newState <= Resources[aResId].iCurrentLevel && Resources[aResId].iCurrentClient != iCurrentClientId) sl@0: return; sl@0: } sl@0: else sl@0: { sl@0: if(newState >= Resources[aResId].iCurrentLevel && Resources[aResId].iCurrentClient != iCurrentClientId) sl@0: return; sl@0: } sl@0: } sl@0: TUint notificationUnCon = Resources[aResId].iUnCondNotiCount; sl@0: TUint notificationCon =0; sl@0: for(NotiInfo* info = Resources[aResId].iCondNoti; info != NULL; info = info->iNext) sl@0: { sl@0: if((info->iDirection && (info->iPreviousLevel < info->iThreshold) && (newState >= info->iThreshold)) || sl@0: (!info->iDirection && (info->iPreviousLevel > info->iThreshold) && (newState <= info->iThreshold))) sl@0: notificationCon++; sl@0: info->iPreviousLevel = newState; sl@0: } sl@0: r = lddChan.CheckNotifications(Resources[aResId].iResourceId, notificationUnCon, notificationCon); sl@0: if(r != KErrNone) sl@0: test.Printf(_L("Check Notifications failed with %d"), r); sl@0: test(r == KErrNone); sl@0: } sl@0: sl@0: //This function updates the client level.This will be used by other functions for validation. sl@0: void TestRM::AddClientLevel(TUint aResId, TInt newState) sl@0: { sl@0: SPowerResourceClientLevel *pCL = NULL; sl@0: if(Resources[aResId].iUsage == EShared) sl@0: { sl@0: for(pCL = Resources[aResId].iLevel;pCL != NULL; pCL = pCL->iNextInList) sl@0: { sl@0: if((TInt)pCL->iClientId == iCurrentClientId) sl@0: { sl@0: pCL->iLevel = newState; sl@0: return; sl@0: } sl@0: } sl@0: pCL = new SPowerResourceClientLevel; sl@0: test(pCL != NULL); sl@0: pCL->iClientId = iCurrentClientId; sl@0: pCL->iResourceId = Resources[aResId].iResourceId; sl@0: pCL->iLevel = newState; sl@0: LIST_PUSH(Resources[aResId].iLevel, pCL, iNextInList); sl@0: Resources[aResId].iNumClients++; sl@0: } sl@0: else sl@0: { sl@0: if(Resources[aResId].iCurrentClient == -1) sl@0: { sl@0: pCL = new SPowerResourceClientLevel; sl@0: test(pCL != NULL); sl@0: pCL->iClientId = iCurrentClientId; sl@0: pCL->iResourceId = Resources[aResId].iResourceId; sl@0: pCL->iLevel = newState; sl@0: LIST_PUSH(Resources[aResId].iLevel, pCL, iNextInList); sl@0: Resources[aResId].iNumClients++; sl@0: } sl@0: else sl@0: { sl@0: SPowerResourceClientLevel* pCL = Resources[aResId].iLevel; sl@0: pCL->iLevel = newState; sl@0: } sl@0: } sl@0: } sl@0: sl@0: //This function updates the current level and client information in corresponding resource array. sl@0: void TestRM::UpdateClientInformation(TUint aResId, TInt aNewState) sl@0: { sl@0: if(Resources[aResId].iCurrentClient == -1) sl@0: { sl@0: Resources[aResId].iCurrentLevel = aNewState; sl@0: Resources[aResId].iCurrentClient = iCurrentClientId; sl@0: return; sl@0: } sl@0: if(!Resources[aResId].iUsage) sl@0: { sl@0: Resources[aResId].iCurrentLevel = aNewState; sl@0: return; sl@0: } sl@0: if(Resources[aResId].iSense == EPositive) sl@0: { sl@0: if(aNewState > Resources[aResId].iCurrentLevel) sl@0: { sl@0: Resources[aResId].iCurrentLevel = aNewState; sl@0: Resources[aResId].iCurrentClient = iCurrentClientId; sl@0: } sl@0: else if(Resources[aResId].iCurrentClient == iCurrentClientId) sl@0: { sl@0: SPowerResourceClientLevel *pCL = NULL; sl@0: for(pCL = Resources[aResId].iLevel;pCL != NULL; pCL = pCL->iNextInList) sl@0: { sl@0: if(pCL->iLevel > aNewState) sl@0: { sl@0: Resources[aResId].iCurrentLevel = pCL->iLevel; sl@0: Resources[aResId].iCurrentClient = pCL->iClientId; sl@0: return; sl@0: } sl@0: } sl@0: Resources[aResId].iCurrentLevel = aNewState; sl@0: Resources[aResId].iCurrentClient = iCurrentClientId; sl@0: } sl@0: return; sl@0: } sl@0: if(Resources[aResId].iSense == ENegative) sl@0: { sl@0: if(aNewState < Resources[aResId].iCurrentLevel) sl@0: { sl@0: Resources[aResId].iCurrentLevel = aNewState; sl@0: Resources[aResId].iCurrentClient = iCurrentClientId; sl@0: } sl@0: else if(Resources[aResId].iCurrentClient == iCurrentClientId) sl@0: { sl@0: SPowerResourceClientLevel *pCL = NULL; sl@0: for(pCL = Resources[aResId].iLevel;pCL != NULL; pCL = pCL->iNextInList) sl@0: { sl@0: if(pCL->iLevel < aNewState) sl@0: { sl@0: Resources[aResId].iCurrentLevel = pCL->iLevel; sl@0: Resources[aResId].iCurrentClient = pCL->iClientId; sl@0: return; sl@0: } sl@0: } sl@0: Resources[aResId].iCurrentLevel = aNewState; sl@0: Resources[aResId].iCurrentClient = iCurrentClientId; sl@0: } sl@0: } sl@0: return; sl@0: } sl@0: sl@0: //---------------------------------------------------------------------------------------------- sl@0: //! @SYMTestCaseID KBASE-T_RESCONTROLCLI-0584 sl@0: //! @SYMTestType UT sl@0: //! @SYMPREQ PREQ1398 sl@0: //! @SYMTestCaseDesc This test case tests change resource state functionality of resource manager sl@0: //! by changing the state of the resource to random value between resource minimum sl@0: //! and maximum value synchronously.This function will add the client level if required sl@0: //! and update resource information and will check notification for correctness.There are sl@0: //! postive and negative tests. sl@0: //! @SYMTestActions If negative testing is enabled then following tests are done sl@0: //! 0 Call the API with invalid client Id sl@0: //! 1 Call the API with invalid instance count of client Id. sl@0: //! 2 Call the API with invalid resource Id sl@0: //! Positive tests sl@0: //! 3 Call the API with valid client and resource Id. sl@0: //! sl@0: //! @SYMTestExpectedResults 0 API should return with KErrAccessDenied, panics otherwise sl@0: //! 1 API should return with KErrAccessDenied, panics otherwise sl@0: //! 2 API should return with KErrNotFound, panic otherwise. sl@0: //! 3 API should return with KErrNone, panic otherwise. sl@0: //! This also checks for notifications revceived as a result of this sl@0: //! resource change and checks for correctness. sl@0: //! @SYMTestPriority High sl@0: //! @SYMTestStatus Implemented sl@0: //---------------------------------------------------------------------------------------------- sl@0: void TestRM::ChangeResourceStateSync(TUint aResId) sl@0: { sl@0: TInt newState = 0; sl@0: if(NegativeTesting) sl@0: { sl@0: //Pass illegial client Id sl@0: r = lddChan.ChangeResourceStateSync(434224, Resources[aResId].iResourceId, newState); sl@0: test(r == KErrAccessDenied); sl@0: sl@0: //Pass illegal instance count sl@0: TUint id = Clients[iCurrentClientId].iClientId; sl@0: id = id ^ (1<<16); sl@0: r = lddChan.ChangeResourceStateSync(id, Resources[aResId].iResourceId, newState); sl@0: test(r == KErrAccessDenied); sl@0: sl@0: //Invalid resource id sl@0: r = lddChan.ChangeResourceStateSync(Clients[iCurrentClientId].iClientId, iMaxStaticResources+40, newState); sl@0: test(r == KErrNotFound); sl@0: sl@0: r = lddChan.ChangeResourceStateSync(Clients[iCurrentClientId].iClientId, 26, newState); sl@0: test(r == KErrNotFound); sl@0: } sl@0: TInt maxLevel = Resources[aResId].iMaxLevel; sl@0: TInt minLevel = Resources[aResId].iNumClients? Resources[aResId].iCurrentLevel : Resources[aResId].iMinLevel; sl@0: //Toggle current state for binary resources sl@0: if(!Resources[aResId].iType) sl@0: newState = !Resources[aResId].iCurrentLevel; sl@0: else if (Resources[aResId].iType == EMultiLevel) sl@0: { sl@0: TInt diff = Abs(maxLevel - minLevel); sl@0: if(Resources[aResId].iSense == EPositive) sl@0: { sl@0: if(minLevel == maxLevel) sl@0: newState = maxLevel - Math::Random() % diff; sl@0: else sl@0: newState = minLevel + Math::Random() % diff; sl@0: } sl@0: else sl@0: { sl@0: if(minLevel == maxLevel) sl@0: newState = maxLevel + Math::Random() % diff; sl@0: else sl@0: newState = minLevel - Math::Random() % diff; sl@0: } sl@0: } sl@0: TInt reqState = newState; sl@0: r = lddChan.ChangeResourceStateSync(Clients[iCurrentClientId].iClientId, Resources[aResId].iResourceId, newState); sl@0: if(r == KErrAccessDenied) sl@0: return; sl@0: if(r != KErrNone) sl@0: test.Printf(_L("Synchronous resource change returned with %d"), r); sl@0: test(r == KErrNone); sl@0: if(newState != reqState) sl@0: test.Printf(_L("NewState = %d, Expected state = %d"), newState, reqState); sl@0: if(!Resources[aResId].iUsage) sl@0: test(newState == reqState); sl@0: CheckNotification(aResId, reqState); sl@0: AddClientLevel(aResId, reqState); sl@0: UpdateClientInformation(aResId, reqState); sl@0: TUint c = 0; sl@0: for(c = 0; c< Clients[iCurrentClientId].iNumResources; c++) sl@0: { sl@0: if(Clients[iCurrentClientId].iResourceIds[c] == Resources[aResId].iResourceId) sl@0: return; sl@0: } sl@0: Clients[iCurrentClientId].iResourceIds[c] = Resources[aResId].iResourceId; sl@0: Clients[iCurrentClientId].iNumResources++; sl@0: return; sl@0: } sl@0: sl@0: //---------------------------------------------------------------------------------------------- sl@0: //! @SYMTestCaseID KBASE-T_RESCONTROLCLI-0585 sl@0: //! @SYMTestType UT sl@0: //! @SYMPREQ PREQ1398 sl@0: //! @SYMTestCaseDesc This test case tests change resource state functionality of resource manager sl@0: //! by changing the state of the resource to random value between resource minimum sl@0: //! and maximum value asynchronously.This function will add the client level if required sl@0: //! and update resource information and will check notification for correctness.This sl@0: //! also tests the cancellation of asynchronous function by immediately cancelling the sl@0: //! operation after requesting resource state change. This is taken care in the driver. sl@0: //! There are postive and negative tests. sl@0: //! @SYMTestActions If negative testing is enabled then following tests are done sl@0: //! 0 Call the API with invalid client Id sl@0: //! 1 Call the API with invalid instance count of client Id. sl@0: //! 2 Call the API with invalid resource Id sl@0: //! Positive tests sl@0: //! 3 Call the API with valid client and resource Id. sl@0: //! sl@0: //! @SYMTestExpectedResults 0 API should return with KErrAccessDenied, panics otherwise sl@0: //! 1 API should return with KErrAccessDenied, panics otherwise sl@0: //! 2 API should return with KErrNotFound, panic otherwise. sl@0: //! 3 API should return with KErrNone or if cancellation of this sl@0: //! API is tested then will return with KErrCancel, panic otherwise. sl@0: //! This also checks for notifications received as a result of this sl@0: //! resource change and checks for correctness. sl@0: //! @SYMTestPriority High sl@0: //! @SYMTestStatus Implemented sl@0: //---------------------------------------------------------------------------------------------- sl@0: void TestRM::ChangeResourceStateAsync(TUint aResId, TBool aReqCancel) sl@0: { sl@0: TRequestStatus resChange; sl@0: TInt newState = 0; sl@0: if(NegativeTesting) sl@0: { sl@0: //Pass illegial client Id sl@0: lddChan.ChangeResourceStateAsync(434224, Resources[aResId].iResourceId, newState, resChange); sl@0: User::WaitForRequest(resChange); sl@0: test(resChange.Int() == KErrAccessDenied); sl@0: sl@0: //Pass illegal instance count sl@0: TUint id = Clients[iCurrentClientId].iClientId; sl@0: id = id ^ (1<<16); sl@0: lddChan.ChangeResourceStateAsync(id, Resources[aResId].iResourceId, newState, resChange); sl@0: User::WaitForRequest(resChange); sl@0: test(resChange.Int() == KErrAccessDenied); sl@0: sl@0: //Invalid resource id sl@0: lddChan.ChangeResourceStateAsync(Clients[iCurrentClientId].iClientId, iMaxStaticResources+40, newState, resChange); sl@0: User::WaitForRequest(resChange); sl@0: test(resChange.Int() == KErrNotFound); sl@0: sl@0: lddChan.ChangeResourceStateAsync(Clients[iCurrentClientId].iClientId, 19, newState, resChange); sl@0: User::WaitForRequest(resChange); sl@0: test(resChange.Int() == KErrNotFound); sl@0: } sl@0: TInt maxLevel = Resources[aResId].iMaxLevel; sl@0: TInt minLevel = (Resources[aResId].iCurrentClient != -1)? Resources[aResId].iCurrentLevel : Resources[aResId].iMinLevel; sl@0: //Check if the resource is positive sl@0: if(!Resources[aResId].iType) sl@0: newState = !Resources[aResId].iCurrentLevel; sl@0: else if (Resources[aResId].iType == EMultiLevel) sl@0: { sl@0: TInt diff = Abs(maxLevel - minLevel); sl@0: if( diff == 0) sl@0: diff = Abs(Resources[aResId].iMaxLevel - Resources[aResId].iMinLevel); sl@0: if(Resources[aResId].iSense == EPositive) sl@0: { sl@0: if(minLevel == maxLevel) sl@0: newState = maxLevel - Math::Random() % diff; sl@0: else sl@0: newState = minLevel + Math::Random() % diff; sl@0: } sl@0: else sl@0: { sl@0: if(minLevel == maxLevel) sl@0: newState = maxLevel + Math::Random() % diff; sl@0: else sl@0: newState = minLevel - Math::Random() % diff; sl@0: } sl@0: } sl@0: TInt reqState = newState; sl@0: //Long latency resource sl@0: lddChan.ChangeResourceStateAsync(Clients[iCurrentClientId].iClientId, Resources[aResId].iResourceId, newState, resChange, aReqCancel); sl@0: User::WaitForRequest(resChange); sl@0: if(aReqCancel && (resChange.Int() != KErrNone)) sl@0: { sl@0: test(resChange.Int() == KErrCancel || resChange.Int() == KErrCompletion); sl@0: return; sl@0: } sl@0: if(resChange.Int() == KErrAccessDenied) sl@0: return; sl@0: if(!Resources[aResId].iUsage) sl@0: test(newState == reqState); sl@0: CheckNotification(aResId, reqState); sl@0: AddClientLevel(aResId, reqState); sl@0: UpdateClientInformation(aResId, reqState); sl@0: TUint c = 0; sl@0: for(c = 0; c< Clients[iCurrentClientId].iNumResources; c++) sl@0: { sl@0: if(Clients[iCurrentClientId].iResourceIds[c] == Resources[aResId].iResourceId) sl@0: return; sl@0: } sl@0: Clients[iCurrentClientId].iResourceIds[c] = Resources[aResId].iResourceId; sl@0: Clients[iCurrentClientId].iNumResources++; sl@0: return; sl@0: } sl@0: sl@0: //---------------------------------------------------------------------------------------------- sl@0: //! @SYMTestCaseID KBASE-T_RESCONTROLCLI-0586 sl@0: //! @SYMTestType UT sl@0: //! @SYMPREQ PREQ1398 sl@0: //! @SYMTestCaseDesc This test case tests synchronous version of get resource state functionality of sl@0: //! resource manager by getting the state of the resource checks for correctness. sl@0: //! There are positive and negative tests. sl@0: //! @SYMTestActions If negative testing is enabled then following tests are done sl@0: //! 0 Call the API with invalid client Id sl@0: //! 1 Call the API with invalid instance count of client Id. sl@0: //! 2 Call the API with invalid resource Id sl@0: //! Positive tests sl@0: //! 3 Call the API with valid client and resource Id. sl@0: //! sl@0: //! @SYMTestExpectedResults 0 API should return with KErrAccessDenied, panics otherwise sl@0: //! 1 API should return with KErrAccessDenied, panics otherwise sl@0: //! 2 API should return with KErrNotFound, panic otherwise. sl@0: //! 3 API should return with KErrNone and also the state and Owner Id are checked sl@0: //! for correctness, panic otherwise. sl@0: //! @SYMTestPriority High sl@0: //! @SYMTestStatus Implemented sl@0: //---------------------------------------------------------------------------------------------- sl@0: void TestRM::GetResourceStateSync(TUint aResId) sl@0: { sl@0: static TBool Cached; sl@0: TInt state = 0, levelOwnerId = 0; sl@0: if(NegativeTesting) sl@0: { sl@0: //Pass illegial client Id sl@0: r = lddChan.GetResourceStateSync(4342241, Resources[aResId].iResourceId, Cached, state, levelOwnerId); sl@0: test(r == KErrAccessDenied); sl@0: sl@0: //Pass illegal instance count sl@0: TUint id = Clients[iCurrentClientId].iClientId; sl@0: id = id ^ (1<<30); sl@0: r = lddChan.GetResourceStateSync(id, Resources[aResId].iResourceId, Cached, state, levelOwnerId); sl@0: test(r == KErrAccessDenied); sl@0: sl@0: //Invalid resource id sl@0: r = lddChan.GetResourceStateSync(Clients[iCurrentClientId].iClientId, iMaxStaticResources+40, Cached, state, levelOwnerId); sl@0: test(r == KErrNotFound); sl@0: sl@0: r = lddChan.GetResourceStateSync(Clients[iCurrentClientId].iClientId, 20, Cached, state, levelOwnerId); sl@0: test(r == KErrNotFound); sl@0: } sl@0: r = lddChan.GetResourceStateSync(Clients[iCurrentClientId].iClientId, Resources[aResId].iResourceId, Cached, state, levelOwnerId); sl@0: test(r == KErrNone); sl@0: test(state == Resources[aResId].iCurrentLevel); sl@0: if(Resources[aResId].iCurrentClient == -1) sl@0: test(levelOwnerId == -1); sl@0: else if (levelOwnerId != (TInt)Clients[Resources[aResId].iCurrentClient].iClientId) sl@0: { sl@0: test.Printf(_L("Expected ClientId = 0x%x, Returned ClientId = 0x%x\n"), Resources[aResId].iCurrentClient, levelOwnerId); sl@0: test(0); sl@0: } sl@0: Cached = !Cached; sl@0: return; sl@0: } sl@0: sl@0: //---------------------------------------------------------------------------------------------- sl@0: //! @SYMTestCaseID KBASE-T_RESCONTROLCLI-0587 sl@0: //! @SYMTestType UT sl@0: //! @SYMPREQ PREQ1398 sl@0: //! @SYMTestCaseDesc This test case tests get resource state functionality of resource manager sl@0: //! by getting the state of the resource asynchronously and checking for correctness. sl@0: //! This also tests the cancellation of asynchronous function by immediately cancelling the sl@0: //! operation after requesting get resource state. This is taken care in the driver. sl@0: //! There are positive and negative tests. sl@0: //! @SYMTestActions If negative testing is enabled then following tests are done sl@0: //! 0 Call the API with invalid client Id sl@0: //! 1 Call the API with invalid instance count of client Id. sl@0: //! 2 Call the API with invalid resource Id sl@0: //! Positive tests sl@0: //! 3 Call the API with valid client and resource Id. sl@0: //! sl@0: //! @SYMTestExpectedResults 0 API should return with KErrAccessDenied, panics otherwise sl@0: //! 1 API should return with KErrAccessDenied, panics otherwise sl@0: //! 2 API should return with KErrNotFound, panic otherwise. sl@0: //! 3 API should return with KErrNone or if cancellation of this sl@0: //! API is tested then will return with KErrCancel, panic otherwise. sl@0: //! This also checks the updated level and owner Id for correctness, sl@0: //! panics otherwise. sl@0: //! @SYMTestPriority High sl@0: //! @SYMTestStatus Implemented sl@0: //---------------------------------------------------------------------------------------------- sl@0: void TestRM::GetResourceStateAsync(TUint aResId, TBool aReqCancel) sl@0: { sl@0: static TBool Cached; sl@0: TRequestStatus resGet; sl@0: TInt state, levelOwnerId; sl@0: if(NegativeTesting) sl@0: { sl@0: //Pass illegial client Id sl@0: lddChan.GetResourceStateAsync(4342241, Resources[aResId].iResourceId, Cached, resGet, state, levelOwnerId); sl@0: User::WaitForRequest(resGet); sl@0: test(resGet.Int() == KErrAccessDenied); sl@0: sl@0: //Pass illegal instance count sl@0: TUint id = Clients[iCurrentClientId].iClientId; sl@0: id = id ^ (1<<30); sl@0: lddChan.GetResourceStateAsync(id, Resources[aResId].iResourceId, Cached, resGet, state, levelOwnerId); sl@0: User::WaitForRequest(resGet); sl@0: test(resGet.Int() == KErrAccessDenied); sl@0: sl@0: //Invalid resource id sl@0: lddChan.GetResourceStateAsync(Clients[iCurrentClientId].iClientId, iMaxStaticResources+48, Cached, resGet, state, levelOwnerId); sl@0: User::WaitForRequest(resGet); sl@0: test(resGet.Int() == KErrNotFound); sl@0: sl@0: lddChan.GetResourceStateAsync(Clients[iCurrentClientId].iClientId, 20, Cached, resGet, state, levelOwnerId); sl@0: User::WaitForRequest(resGet); sl@0: test(resGet.Int() == KErrNotFound); sl@0: } sl@0: lddChan.GetResourceStateAsync(Clients[iCurrentClientId].iClientId, Resources[aResId].iResourceId, Cached, resGet, state, levelOwnerId, aReqCancel); sl@0: User::WaitForRequest(resGet); sl@0: if(aReqCancel && (resGet.Int() != KErrNone)) sl@0: { sl@0: test(resGet.Int() == KErrCancel || resGet.Int() == KErrCompletion); sl@0: return; sl@0: } sl@0: test(state == Resources[aResId].iCurrentLevel); sl@0: if(Resources[aResId].iCurrentClient == -1) sl@0: test(levelOwnerId == -1); sl@0: else if (levelOwnerId != (TInt)Clients[Resources[aResId].iCurrentClient].iClientId) sl@0: { sl@0: test.Printf(_L("Expected ClientId = 0x%x, Returned ClientId = 0x%x\n"), Resources[aResId].iCurrentClient, levelOwnerId); sl@0: test(0); sl@0: } sl@0: Cached = !Cached; sl@0: } sl@0: sl@0: //---------------------------------------------------------------------------------------------- sl@0: //! @SYMTestCaseID KBASE-T_RESCONTROLCLI-0588 sl@0: //! @SYMTestType UT sl@0: //! @SYMPREQ PREQ1398 sl@0: //! @SYMTestCaseDesc This test case tests unconditional notification request functionality of resource manager. sl@0: //! @SYMTestActions Call the API with valid client and resource Id. sl@0: //! sl@0: //! @SYMTestExpectedResults API should return with KErrNone, panics otherwise. sl@0: //! @SYMTestPriority High sl@0: //! @SYMTestStatus Implemented sl@0: //---------------------------------------------------------------------------------------------- sl@0: void TestRM::RequestNotification(TUint aResId) sl@0: { sl@0: //If unconditional notification is already queued for this client then dont request another one. sl@0: for(NotiInfo *pN = Resources[aResId].iUncondNoti; pN != NULL; pN = pN->iNext) sl@0: { sl@0: if((TInt)pN->iClientId == iCurrentClientId) sl@0: return; sl@0: } sl@0: r = lddChan.RequestNotification(Clients[iCurrentClientId].iClientId, Resources[aResId].iResourceId); sl@0: if(r != KErrNone) sl@0: test.Printf(_L("Request Notification returned with %d"), r); sl@0: test(r == KErrNone); sl@0: //Add to resource list sl@0: NotiInfo *info = new NotiInfo; sl@0: test(info != NULL); sl@0: info->iClientId = iCurrentClientId; sl@0: LIST_PUSH(Resources[aResId].iUncondNoti, info, iNext); sl@0: Resources[aResId].iUnCondNotiCount++; sl@0: } sl@0: sl@0: //---------------------------------------------------------------------------------------------- sl@0: //! @SYMTestCaseID KBASE-T_RESCONTROLCLI-0589 sl@0: //! @SYMTestType UT sl@0: //! @SYMPREQ PREQ1398 sl@0: //! @SYMTestCaseDesc This test case tests conditional notification request functionality of resource manager. sl@0: //! Threshold and direction are chosen randomly for each resource based on the resource information. sl@0: //! @SYMTestActions Call the API with valid client and resource Id. sl@0: //! sl@0: //! @SYMTestExpectedResults API should return with KErrNone, panics otherwise. sl@0: //! @SYMTestPriority High sl@0: //! @SYMTestStatus Implemented sl@0: //---------------------------------------------------------------------------------------------- sl@0: void TestRM::RequestNotificationCon(TUint aResId) sl@0: { sl@0: //Allow only one notification per client. sl@0: static TBool direction; sl@0: TInt threshold = direction; sl@0: for(NotiInfo *pN = Resources[aResId].iCondNoti; pN != NULL; pN = pN->iNext) sl@0: { sl@0: if((TInt)pN->iClientId == iCurrentClientId) sl@0: return; sl@0: } sl@0: if(Resources[aResId].iType) sl@0: { sl@0: if(Resources[aResId].iSense == EPositive) sl@0: { sl@0: threshold = Math::Random() % Resources[aResId].iMaxLevel; sl@0: if(threshold < Resources[aResId].iMinLevel) sl@0: threshold += Resources[aResId].iMinLevel; sl@0: } sl@0: else if(Resources[aResId].iSense == ENegative) sl@0: { sl@0: threshold = Math::Random() % Resources[aResId].iMinLevel; sl@0: if(threshold < Resources[aResId].iMaxLevel) sl@0: threshold += Resources[aResId].iMaxLevel; sl@0: } sl@0: } sl@0: r = lddChan.RequestNotification(Clients[iCurrentClientId].iClientId, Resources[aResId].iResourceId, direction, threshold); sl@0: if(r != KErrNone) sl@0: test.Printf(_L("Request Notification returned with %d for direction = %d, threshold = %d"), r, direction, threshold); sl@0: test(r == KErrNone); sl@0: NotiInfo *info = new NotiInfo; sl@0: test(info != NULL); sl@0: info->iClientId = iCurrentClientId; sl@0: info->iThreshold = threshold; sl@0: info->iDirection = direction; sl@0: info->iPreviousLevel = Resources[aResId].iCurrentLevel; sl@0: LIST_PUSH(Resources[aResId].iCondNoti, info, iNext); sl@0: direction = !direction; sl@0: } sl@0: sl@0: //---------------------------------------------------------------------------------------------- sl@0: //! @SYMTestCaseID KBASE-T_RESCONTROLCLI-0590 sl@0: //! @SYMTestType UT sl@0: //! @SYMPREQ PREQ1398 sl@0: //! @SYMTestCaseDesc This test case tests cancellation of notification functionality of resource manager. sl@0: //! @SYMTestActions Call the API with valid client and resource Id. sl@0: //! sl@0: //! @SYMTestExpectedResults API should return with KErrCancel, panics otherwise. sl@0: //! @SYMTestPriority High sl@0: //! @SYMTestStatus Implemented sl@0: //---------------------------------------------------------------------------------------------- sl@0: void TestRM::CancelNotification(TUint aResId, TBool Cond) sl@0: { sl@0: RMResInfo *pR = &Resources[aResId]; sl@0: TBool found = EFalse; sl@0: if(Cond) sl@0: { sl@0: //Remove any conditional notification this client has on resource. sl@0: for(NotiInfo* pI = pR->iCondNoti; pI != NULL; pI = pI->iNext) sl@0: { sl@0: if((TInt)pI->iClientId == iCurrentClientId) sl@0: { sl@0: LIST_REMOVE(pR->iCondNoti, pI, iNext, NotiInfo); sl@0: delete pI; sl@0: found = ETrue; sl@0: break; sl@0: } sl@0: } sl@0: } sl@0: else sl@0: { sl@0: //Remove any unconditional notification this client has on resource. sl@0: for(NotiInfo* pI = pR->iUncondNoti; pI != NULL; pI = pI->iNext) sl@0: { sl@0: if((TInt)pI->iClientId == iCurrentClientId) sl@0: { sl@0: LIST_REMOVE(pR->iUncondNoti, pI, iNext, NotiInfo); sl@0: pR->iUnCondNotiCount--; sl@0: delete pI; sl@0: found = ETrue; sl@0: break; sl@0: } sl@0: } sl@0: } sl@0: if(found) sl@0: { sl@0: r = lddChan.CancelNotification(Clients[iCurrentClientId].iClientId, Resources[aResId].iResourceId, Cond); sl@0: if(r != KErrCancel) sl@0: test.Printf(_L("CancelNotification Clients %d, return value = %d"), iCurrentClientId, r); sl@0: test(r == KErrCancel); sl@0: } sl@0: } sl@0: sl@0: //---------------------------------------------------------------------------------------------- sl@0: //! @SYMTestCaseID KBASE-T_RESCONTROLCLI-0591 sl@0: //! @SYMTestType UT sl@0: //! @SYMPREQ PREQ1398 sl@0: //! @SYMTestCaseDesc This test case tests client registration and deregistration API of resource manager. sl@0: //! There are positive and negative tests. sl@0: //! @SYMTestActions 0 Call the client registration API with valid client name to register sl@0: //! 1 Call the client name updation API with valid client Id to get the client name sl@0: //! 2 Call the client name updation API with invalid client id. sl@0: //! 3 Call the client registration API with client name greater than maximum sl@0: //! allowable name length (32 characters) sl@0: //! 4 Call the client deregistration API by passing invalid client Id. sl@0: //! 5 Call the client deregistration API by passing invalid instance count. sl@0: //! 6 Call the client deregistration API by passing valid client Id. sl@0: //! sl@0: //! @SYMTestExpectedResults 0 API should return with KErrNone, panics otherwise. sl@0: //! 1 API should return with KErrNone and updated name is checked for sl@0: //! correctness, panics otherwise. sl@0: //! 2 API should return with KErrAccessDenied, panics otherwise. sl@0: //! 3 API should return with KErrTooBig, panics otherwise. sl@0: //! 4 API should return with KErrNotFound, panics otherwise. sl@0: //! 5 API should return with KErrNotFound, panics otherwise. sl@0: //! 6 API should return with KErrNone, panics otherwise. sl@0: //! @SYMTestPriority High sl@0: //! @SYMTestStatus Implemented sl@0: //---------------------------------------------------------------------------------------------- sl@0: void TestRM::ValidateClient(TUint aNumClients, TOwnerType aContext) sl@0: { sl@0: TInt r = KErrNone; sl@0: TBuf8<32> ClientName; sl@0: ClientName.Zero(); sl@0: ClientName.Append(_L8("Clients?")); sl@0: TUint clientId[MAX_CLIENTS]; sl@0: if(aNumClients > MAX_CLIENTS) sl@0: return; sl@0: TUint c; sl@0: for(c = 0; c < aNumClients; c++) sl@0: { sl@0: ClientName[7] = (TUint8)('0' + c); sl@0: r = lddChan.RegisterClient(clientId[c], (const TDesC*)&ClientName, aContext); sl@0: if(r != KErrNone) sl@0: { sl@0: test.Printf(_L("Client registration failed with %d"), r); sl@0: test(0); sl@0: } sl@0: } sl@0: sl@0: //Validate Client sl@0: TBuf8<32> aName; sl@0: sl@0: for(c = 0; c < aNumClients; c++) sl@0: { sl@0: ClientName[7] = (TUint8)('0' + c); sl@0: r = lddChan.GetClientName(clientId[c], clientId[c], (TDes8*)&aName); sl@0: if(r != KErrNone) sl@0: { sl@0: test.Printf(_L("GetClientName API failed with error %d"), r); sl@0: test(0); sl@0: } sl@0: r = aName.Compare(ClientName); sl@0: if(r != KErrNone) sl@0: { sl@0: test.Printf(_L("Client Name is not as expected")); sl@0: test(0); sl@0: } sl@0: } sl@0: //Invalid tests sl@0: ClientName[7] = (TUint8)('0' + aNumClients+1); sl@0: r = lddChan.GetClientName(aNumClients, clientId[0], &aName); sl@0: if(r != KErrAccessDenied) sl@0: { sl@0: test.Printf(_L("RM allows illegal clients")); sl@0: test(0); sl@0: } sl@0: sl@0: //Long filename sl@0: TBuf8<50> name; sl@0: name.Zero(); sl@0: name.Append(_L8("RegisteringClientNameGreaterThan32Characters")); sl@0: TUint id =0; sl@0: r = lddChan.RegisterClient(id, (const TDesC*)&name, aContext); sl@0: if(r != KErrTooBig) sl@0: { sl@0: test.Printf(_L("RM allows big names !!!")); sl@0: test(0); sl@0: } sl@0: test.Printf(_L("Client Deregistration")); sl@0: //Deregistration of non-existing client sl@0: id = 0; sl@0: r = lddChan.DeRegisterClient(id); sl@0: if(r != KErrNotFound) sl@0: { sl@0: test.Printf(_L("RM allows invalid client ID deregistration!!!")); sl@0: test(0); sl@0: } sl@0: sl@0: //Get client Name by passing invalid client Id (changing a bit in instance count) sl@0: id = clientId[0] ^ (1<<16); sl@0: r = lddChan.DeRegisterClient(id); sl@0: if(r != KErrNotFound) sl@0: { sl@0: test.Printf(_L("RM allows invalid client ID deregistation!!!")); sl@0: test(0); sl@0: } sl@0: sl@0: //Deregister the client registered at the start of this function sl@0: for(c = 0; c < aNumClients; c++) sl@0: { sl@0: r = lddChan.DeRegisterClient(clientId[c]); sl@0: if(r != KErrNone) sl@0: { sl@0: test.Printf(_L("Deregistration of client id 0x%x failed"), clientId[c]); sl@0: test(0); sl@0: } sl@0: } sl@0: return; sl@0: } sl@0: sl@0: #ifdef PRM_ENABLE_EXTENDED_VERSION sl@0: //---------------------------------------------------------------------------------------------- sl@0: //! @SYMTestCaseID KBASE-T_RESCONTROLCLI-0597 sl@0: //! @SYMTestType UT sl@0: //! @SYMPREQ PREQ1398 sl@0: //! @SYMTestCaseDesc This test case tests dynamic resources with dependency. sl@0: //! @SYMTestActions 0 Register clients sl@0: //! 1 Register dynamic resource with dependency sl@0: //! 2 Establish dependency between resources sl@0: //! 3 Register notifications sl@0: //! 4 Check dependency information for correctness sl@0: //! 5 Change Resource State of each resource sl@0: //! 6 Get state of the resources and verify them for correctness sl@0: //! 7 Check notification count for correctness sl@0: //! 8 Deregister dependency between resources sl@0: //! 9 Deregister client level sl@0: //! 10 Deregister dynamic resource with dependency sl@0: //! 11 Deregister clients sl@0: //! sl@0: //! @SYMTestExpectedResults 0 API should return with KErrNone, panics otherwise. sl@0: //! 1 API should return with KErrNone, panics otherwise. sl@0: //! 2 API should return with KErrNone, panics otherwise. sl@0: //! 3 API should return with KErrNone, panics otherwise. sl@0: //! 4 API should return with KErrNone, panics otherwise. sl@0: //! 5 API should return with KErrNone, panics otherwise. sl@0: //! 6 API should return with KErrNone, panics otherwise. sl@0: //! 7 API should return with KErrNone, panics otherwise. sl@0: //! 8 API should return with KErrNone, panics otherwise. sl@0: //! 9 API should return with KErrNone, panics otherwise. sl@0: //! 10 API should return with KErrNone, panics otherwise. sl@0: //! 11 API should return with KErrNone, panics otherwise. sl@0: //! @SYMTestPriority High sl@0: //! @SYMTestStatus Implemented sl@0: //---------------------------------------------------------------------------------------------- sl@0: /*This tests dynamic dependency resource. It also creates a dependency between static resource. sl@0: Below is the dependency tree sl@0: ResourceA <----------------> ResourceD <------------->ResourceE <--------------> ResourceC sl@0: | | sl@0: | | sl@0: | | sl@0: | | sl@0: | | sl@0: | | sl@0: ResourceF ResourceG <-------------> Resource H <------->Resource I sl@0: ¦ (Dynamic) (Dynamic) sl@0: ¦ sl@0: ¦ sl@0: ¦ sl@0: Resource J <-------->Resource K sl@0: (Dynamic) (Dynamic) sl@0: */ sl@0: void TestRM::TestDynamicResourceDependency() sl@0: { sl@0: TInt state; sl@0: TRequestStatus req; sl@0: SResourceDependencyInfo info1, info2; sl@0: SResourceDependencyInfo sResDepInfo; sl@0: RArraydepResArray; sl@0: sl@0: TUint dynamicDepResId[4]; sl@0: sl@0: test.Next(_L("Testing Dynamic + static resource dependency")); sl@0: RmTest.RegisterClient(); /* Register Client 1 */ sl@0: sl@0: //Register dependency resource sl@0: dynamicDepResId[0] = 5; sl@0: r = lddChan.RegisterDynamicResource(Clients[0].iClientId, dynamicDepResId[0]); sl@0: test(r == KErrNone); sl@0: sl@0: info1.iResourceId = iStaticDependencyResources[5]; sl@0: info1.iDependencyPriority = 3; sl@0: sl@0: info2.iResourceId = dynamicDepResId[0]; sl@0: info2.iDependencyPriority = 2; sl@0: sl@0: r = lddChan.RegisterResourceDependency(Clients[0].iClientId, info1, info2); sl@0: test(r == KErrNone); sl@0: sl@0: //Check for correctness of dependency resource information sl@0: sResDepInfo.iResourceId = iStaticDependencyResources[3]; sl@0: sResDepInfo.iDependencyPriority = 1; sl@0: depResArray.Append(sResDepInfo); sl@0: sResDepInfo.iResourceId = dynamicDepResId[0]; sl@0: sResDepInfo.iDependencyPriority = 2; sl@0: depResArray.Append(sResDepInfo); sl@0: RmTest.CheckForDependencyInformation(Clients[0].iClientId, iStaticDependencyResources[5], 2, &depResArray[0]); sl@0: sl@0: depResArray[0].iResourceId = iStaticDependencyResources[5]; sl@0: depResArray[0].iDependencyPriority = 3; sl@0: RmTest.CheckForDependencyInformation(Clients[0].iClientId, dynamicDepResId[0], 1, &depResArray[0]); sl@0: sl@0: //Change Static dependency resource to -50 sl@0: RmTest.RegisterClient(); /* Register Client 2 */ sl@0: state = -50; sl@0: lddChan.ChangeResourceStateAsync(Clients[1].iClientId, iStaticDependencyResources[0], state, req); sl@0: User::WaitForRequest(req); sl@0: test(req.Int() == KErrNone); sl@0: sl@0: GetExtendedResStateAsyncAndVerify(iStaticDependencyResources[0], -50, Clients[1].iClientId, EFalse); sl@0: GetExtendedResStateAndVerify(iStaticDependencyResources[1], -11, iStaticDependencyResources[0]); sl@0: GetExtendedResStateAsyncAndVerify(iStaticDependencyResources[2], 1, iStaticDependencyResources[0], EFalse); sl@0: GetExtendedResStateAndVerify(iStaticDependencyResources[3], 13, iStaticDependencyResources[0]); sl@0: GetExtendedResStateAsyncAndVerify(iStaticDependencyResources[4], 0, iStaticDependencyResources[3], EFalse); sl@0: GetExtendedResStateAndVerify(iStaticDependencyResources[5], 73, iStaticDependencyResources[3]); sl@0: GetExtendedResStateAndVerify(dynamicDepResId[0], 80, iStaticDependencyResources[5]); sl@0: sl@0: //Register dynamic dependency resource I sl@0: dynamicDepResId[1] = 6; sl@0: r = lddChan.RegisterDynamicResource(Clients[0].iClientId, dynamicDepResId[1]); sl@0: test(r == KErrNone); sl@0: sl@0: //Register dynamic dependency resource J sl@0: dynamicDepResId[2] = 7; sl@0: r = lddChan.RegisterDynamicResource(Clients[0].iClientId, dynamicDepResId[2]); sl@0: test(r == KErrNone); sl@0: sl@0: //Register dynamic dependency resource K sl@0: dynamicDepResId[3] = 8; sl@0: r = lddChan.RegisterDynamicResource(Clients[0].iClientId, dynamicDepResId[3]); sl@0: test(r == KErrNone); sl@0: sl@0: RmTest.RegisterClient(); /* Register Client3 */ sl@0: RmTest.RegisterClient(); /* Register Client4 */ sl@0: sl@0: //Register notifications sl@0: r = lddChan.RequestNotification(Clients[1].iClientId, iStaticDependencyResources[5]); sl@0: test(r == KErrNone); sl@0: r = lddChan.RequestNotification(Clients[2].iClientId, dynamicDepResId[0]); sl@0: test(r == KErrNone); sl@0: r = lddChan.RequestNotification(Clients[1].iClientId, dynamicDepResId[1]); sl@0: test(r == KErrNone); sl@0: r = lddChan.RequestNotification(Clients[2].iClientId, dynamicDepResId[2]); sl@0: test(r == KErrNone); sl@0: r = lddChan.RequestNotification(Clients[1].iClientId, dynamicDepResId[3]); sl@0: test(r == KErrNone); sl@0: sl@0: //Create depedency between H and I sl@0: info1.iResourceId = dynamicDepResId[0]; sl@0: info1.iDependencyPriority = 1; sl@0: sl@0: info2.iResourceId = dynamicDepResId[1]; sl@0: info2.iDependencyPriority = 1; sl@0: sl@0: //Register dependency between resource H and I sl@0: r = lddChan.RegisterResourceDependency(Clients[0].iClientId, info1, info2); sl@0: test(r == KErrNone); sl@0: //Validate dependency information sl@0: depResArray[0].iResourceId = dynamicDepResId[1]; sl@0: depResArray[0].iDependencyPriority = 1; sl@0: depResArray[1].iResourceId = iStaticDependencyResources[5]; sl@0: depResArray[1].iDependencyPriority = 3; sl@0: RmTest.CheckForDependencyInformation(Clients[0].iClientId, dynamicDepResId[0], 2, &depResArray[0]); sl@0: sl@0: depResArray[0].iResourceId = dynamicDepResId[0]; sl@0: depResArray[0].iDependencyPriority = 1; sl@0: RmTest.CheckForDependencyInformation(Clients[0].iClientId, dynamicDepResId[1], 1, &depResArray[0]); sl@0: sl@0: //Create depedency between H and J sl@0: info1.iResourceId = dynamicDepResId[0]; sl@0: info1.iDependencyPriority = 1; sl@0: sl@0: info2.iResourceId = dynamicDepResId[2]; sl@0: info2.iDependencyPriority = 2; sl@0: sl@0: //Register dependency between resource H and J sl@0: r = lddChan.RegisterResourceDependency(Clients[0].iClientId, info1, info2); sl@0: test(r == KErrNone); sl@0: sl@0: depResArray[0].iResourceId = dynamicDepResId[1]; sl@0: depResArray[0].iDependencyPriority = 1; sl@0: depResArray[1].iResourceId = dynamicDepResId[2]; sl@0: depResArray[1].iDependencyPriority = 2; sl@0: sResDepInfo.iResourceId = iStaticDependencyResources[5]; sl@0: sResDepInfo.iDependencyPriority = 3; sl@0: depResArray.Append(sResDepInfo); sl@0: RmTest.CheckForDependencyInformation(Clients[0].iClientId, dynamicDepResId[0], 3, &depResArray[0]); sl@0: sl@0: depResArray[0].iResourceId = dynamicDepResId[0]; sl@0: depResArray[0].iDependencyPriority = 1; sl@0: RmTest.CheckForDependencyInformation(Clients[0].iClientId, dynamicDepResId[2], 1, &depResArray[0]); sl@0: sl@0: // Check if the priority for a new dependency is already existing. sl@0: //Create dependency between J and K sl@0: info1.iResourceId = dynamicDepResId[2]; sl@0: info1.iDependencyPriority = 1; sl@0: sl@0: info2.iResourceId = dynamicDepResId[3]; sl@0: info2.iDependencyPriority = 1; sl@0: sl@0: //Register dependency between resource J and K sl@0: r = lddChan.RegisterResourceDependency(Clients[0].iClientId, info1, info2); sl@0: test(r == KErrAlreadyExists); sl@0: sl@0: //Create depedency between J and K sl@0: info1.iResourceId = dynamicDepResId[2]; sl@0: info1.iDependencyPriority = 1; sl@0: sl@0: info2.iResourceId = dynamicDepResId[3]; sl@0: info2.iDependencyPriority = 2; sl@0: sl@0: //Register dependency between resource J and K sl@0: r = lddChan.RegisterResourceDependency(Clients[0].iClientId, info1, info2); sl@0: test(r == KErrNone); sl@0: sl@0: depResArray[0].iResourceId = dynamicDepResId[2]; sl@0: depResArray[0].iDependencyPriority = 1; sl@0: RmTest.CheckForDependencyInformation(Clients[0].iClientId, dynamicDepResId[3], 1, &depResArray[0]); sl@0: sl@0: depResArray[0].iResourceId = dynamicDepResId[0]; sl@0: depResArray[0].iDependencyPriority = 1; sl@0: depResArray[1].iResourceId = dynamicDepResId[3]; sl@0: depResArray[1].iDependencyPriority = 2; sl@0: RmTest.CheckForDependencyInformation(Clients[0].iClientId, dynamicDepResId[2], 2, &depResArray[0]); sl@0: sl@0: RmTest.RegisterClient(); /* Client5 registration */ sl@0: //Change H to 85 sl@0: r = lddChan.ChangeResourceStateSync(Clients[2].iClientId, dynamicDepResId[0], 85); sl@0: test(r == KErrNone); sl@0: sl@0: GetExtendedResStateAsyncAndVerify(iStaticDependencyResources[0], -50, Clients[1].iClientId, EFalse); sl@0: GetExtendedResStateAndVerify(iStaticDependencyResources[1], -11, iStaticDependencyResources[0]); sl@0: GetExtendedResStateAsyncAndVerify(iStaticDependencyResources[2], 1, iStaticDependencyResources[0], EFalse); sl@0: GetExtendedResStateAndVerify(iStaticDependencyResources[3], 13, iStaticDependencyResources[0]); sl@0: GetExtendedResStateAsyncAndVerify(iStaticDependencyResources[4], 0, iStaticDependencyResources[3], EFalse); sl@0: GetExtendedResStateAndVerify(iStaticDependencyResources[5], 71, dynamicDepResId[0]); sl@0: GetExtendedResStateAndVerify(dynamicDepResId[0], 85, Clients[2].iClientId); sl@0: GetExtendedResStateAsyncAndVerify(dynamicDepResId[1], 1, dynamicDepResId[0]); sl@0: GetExtendedResStateAsyncAndVerify(dynamicDepResId[2], 18, dynamicDepResId[0], EFalse); sl@0: GetExtendedResStateAndVerify(dynamicDepResId[3], 1, dynamicDepResId[2]); sl@0: sl@0: //Check notifications sl@0: r = lddChan.CheckNotifications(iStaticDependencyResources[5], 1, 0); sl@0: test(r == KErrNone); sl@0: r = lddChan.CheckNotifications(dynamicDepResId[0], 1, 0); sl@0: test(r == KErrNone); sl@0: r = lddChan.CheckNotifications(dynamicDepResId[1], 1, 0); sl@0: test(r == KErrNone); sl@0: r = lddChan.CheckNotifications(dynamicDepResId[2], 1, 0); sl@0: test(r == KErrNone); sl@0: sl@0: //Change K to 1 sl@0: state= 1; sl@0: lddChan.ChangeResourceStateAsync(Clients[2].iClientId, dynamicDepResId[3], state, req); sl@0: User::WaitForRequest(req); sl@0: test(req.Int() == KErrNone); sl@0: sl@0: GetExtendedResStateAsyncAndVerify(dynamicDepResId[2], 18, dynamicDepResId[0], EFalse); sl@0: GetExtendedResStateAsyncAndVerify(dynamicDepResId[3], 1, Clients[2].iClientId, EFalse); sl@0: sl@0: //Check notifications sl@0: r = lddChan.CheckNotifications(dynamicDepResId[2], 0, 0); sl@0: test(r == KErrNone); sl@0: r = lddChan.CheckNotifications(dynamicDepResId[3], 0, 0); sl@0: test(r == KErrNone); sl@0: sl@0: //Change J to 12 sl@0: r = lddChan.ChangeResourceStateSync(Clients[2].iClientId, dynamicDepResId[2],12); sl@0: test(r == KErrNone); sl@0: sl@0: GetExtendedResStateAsyncAndVerify(dynamicDepResId[2], 12, Clients[2].iClientId, EFalse); sl@0: sl@0: //Check notifications sl@0: r = lddChan.CheckNotifications(dynamicDepResId[0], 0, 0); sl@0: test(r == KErrNone); sl@0: r = lddChan.CheckNotifications(dynamicDepResId[2], 1, 0); sl@0: test(r == KErrNone); sl@0: r = lddChan.CheckNotifications(dynamicDepResId[3], 0, 0); sl@0: test(r == KErrNone); sl@0: sl@0: //Change H to 90 sl@0: TRequestStatus reqSet; sl@0: state = 90; sl@0: lddChan.CheckParallelExecutionForChangeResState(Clients[2].iClientId, sl@0: dynamicDepResId[0],state, sl@0: 5, 0, reqSet); sl@0: User::WaitForRequest(reqSet); sl@0: test(reqSet.Int() == KErrNone); sl@0: sl@0: GetExtendedResStateAsyncAndVerify(iStaticDependencyResources[0], -50, Clients[1].iClientId, EFalse); sl@0: GetExtendedResStateAndVerify(iStaticDependencyResources[1], -11, iStaticDependencyResources[0]); sl@0: GetExtendedResStateAsyncAndVerify(iStaticDependencyResources[2], 1, iStaticDependencyResources[0], EFalse); sl@0: GetExtendedResStateAndVerify(iStaticDependencyResources[3], 13, iStaticDependencyResources[0]); sl@0: GetExtendedResStateAsyncAndVerify(iStaticDependencyResources[4], 0, iStaticDependencyResources[3], EFalse); sl@0: GetExtendedResStateAndVerify(iStaticDependencyResources[5], 69, dynamicDepResId[0]); sl@0: GetExtendedResStateAndVerify(dynamicDepResId[0], 90, Clients[2].iClientId); sl@0: GetExtendedResStateAsyncAndVerify(dynamicDepResId[1], 1, dynamicDepResId[0]); sl@0: GetExtendedResStateAsyncAndVerify(dynamicDepResId[2], 11, dynamicDepResId[0], EFalse); sl@0: GetExtendedResStateAndVerify(dynamicDepResId[3], 1, Clients[2].iClientId); sl@0: sl@0: //Check notifications sl@0: r = lddChan.CheckNotifications(iStaticDependencyResources[5], 1, 0); sl@0: test(r == KErrNone); sl@0: r = lddChan.CheckNotifications(dynamicDepResId[0], 1, 0); sl@0: test(r == KErrNone); sl@0: r = lddChan.CheckNotifications(dynamicDepResId[1], 0, 0); sl@0: test(r == KErrNone); sl@0: r = lddChan.CheckNotifications(dynamicDepResId[2], 1, 0); sl@0: test(r == KErrNone); sl@0: r = lddChan.CheckNotifications(dynamicDepResId[3], 0, 0); sl@0: test(r == KErrNone); sl@0: sl@0: state = 9; sl@0: lddChan.ChangeResourceStateAsync(Clients[1].iClientId, dynamicDepResId[2], state, req); sl@0: User::WaitForRequest(req); sl@0: test(req.Int() == KErrNone); sl@0: sl@0: GetExtendedResStateAndVerify(dynamicDepResId[0], 90, Clients[2].iClientId); sl@0: GetExtendedResStateAsyncAndVerify(dynamicDepResId[1], 1, dynamicDepResId[0]); sl@0: GetExtendedResStateAsyncAndVerify(dynamicDepResId[2], 9, Clients[1].iClientId, EFalse); sl@0: GetExtendedResStateAndVerify(dynamicDepResId[3], 1, Clients[2].iClientId); sl@0: sl@0: //Check notifications sl@0: r = lddChan.CheckNotifications(dynamicDepResId[0], 0, 0); sl@0: test(r == KErrNone); sl@0: r = lddChan.CheckNotifications(dynamicDepResId[1], 0, 0); sl@0: test(r == KErrNone); sl@0: r = lddChan.CheckNotifications(dynamicDepResId[2], 1, 0); sl@0: test(r == KErrNone); sl@0: r = lddChan.CheckNotifications(dynamicDepResId[3], 0, 0); sl@0: test(r == KErrNone); sl@0: sl@0: //Change D to 50 sl@0: state = 50; sl@0: lddChan.ChangeResourceStateAsync(Clients[1].iClientId, iStaticDependencyResources[0], state, req); sl@0: User::WaitForRequest(req); sl@0: test(req.Int() == KErrNone); sl@0: sl@0: GetExtendedResStateAsyncAndVerify(iStaticDependencyResources[0], 50, Clients[1].iClientId, EFalse); sl@0: GetExtendedResStateAsyncAndVerify(iStaticDependencyResources[1], -12, iStaticDependencyResources[0], EFalse); sl@0: GetExtendedResStateAsyncAndVerify(iStaticDependencyResources[2], 1, iStaticDependencyResources[0], EFalse); sl@0: GetExtendedResStateAsyncAndVerify(iStaticDependencyResources[3], 16, iStaticDependencyResources[0], EFalse); sl@0: GetExtendedResStateAsyncAndVerify(iStaticDependencyResources[4], 0, iStaticDependencyResources[3], EFalse); sl@0: GetExtendedResStateAsyncAndVerify(iStaticDependencyResources[5], 67, iStaticDependencyResources[3], EFalse); sl@0: GetExtendedResStateAndVerify(dynamicDepResId[0], 90, Clients[2].iClientId); sl@0: GetExtendedResStateAsyncAndVerify(dynamicDepResId[1], 1, dynamicDepResId[0]); sl@0: GetExtendedResStateAsyncAndVerify(dynamicDepResId[2], 9, Clients[1].iClientId, EFalse); sl@0: GetExtendedResStateAndVerify(dynamicDepResId[3], 1, Clients[2].iClientId); sl@0: sl@0: //Check notifications sl@0: r = lddChan.CheckNotifications(iStaticDependencyResources[5], 1, 0); sl@0: test(r == KErrNone); sl@0: //DeRegister dependency between J and K sl@0: r = lddChan.DeRegisterResourceDependency(Clients[0].iClientId, dynamicDepResId[3], dynamicDepResId[2]); sl@0: test(r == KErrNone); sl@0: sl@0: RmTest.CheckForDependencyInformation(Clients[0].iClientId, dynamicDepResId[3], 0, &depResArray[0]); sl@0: sl@0: depResArray[0].iResourceId = dynamicDepResId[0]; sl@0: depResArray[0].iDependencyPriority = 1; sl@0: RmTest.CheckForDependencyInformation(Clients[0].iClientId, dynamicDepResId[2], 1, &depResArray[0]); sl@0: sl@0: //Change J t0 13 sl@0: r = lddChan.ChangeResourceStateSync(Clients[1].iClientId, dynamicDepResId[2], 13); sl@0: test(r == KErrNone); sl@0: sl@0: GetExtendedResStateAsyncAndVerify(iStaticDependencyResources[0], 50, Clients[1].iClientId, EFalse); sl@0: GetExtendedResStateAsyncAndVerify(iStaticDependencyResources[1], -12, iStaticDependencyResources[0], EFalse); sl@0: GetExtendedResStateAsyncAndVerify(iStaticDependencyResources[2], 1, iStaticDependencyResources[0], EFalse); sl@0: GetExtendedResStateAsyncAndVerify(iStaticDependencyResources[3], 16, iStaticDependencyResources[0], EFalse); sl@0: GetExtendedResStateAsyncAndVerify(iStaticDependencyResources[4], 0, iStaticDependencyResources[3], EFalse); sl@0: GetExtendedResStateAsyncAndVerify(iStaticDependencyResources[5], 67, iStaticDependencyResources[3], EFalse); sl@0: GetExtendedResStateAndVerify(dynamicDepResId[0], 90, Clients[2].iClientId); sl@0: GetExtendedResStateAsyncAndVerify(dynamicDepResId[1], 1, dynamicDepResId[0]); sl@0: GetExtendedResStateAsyncAndVerify(dynamicDepResId[2], 12, Clients[2].iClientId, EFalse); sl@0: GetExtendedResStateAndVerify(dynamicDepResId[3], 1, Clients[2].iClientId); sl@0: //Check notifications sl@0: r = lddChan.CheckNotifications(dynamicDepResId[2], 1, 0); sl@0: test(r == KErrNone); sl@0: /* Remove client level from resource 7 */ sl@0: r = lddChan.DeRegisterClientLevelFromResource(Clients[2].iClientId, dynamicDepResId[3]); sl@0: test(r == KErrNone); sl@0: sl@0: GetExtendedResStateAndVerify(dynamicDepResId[3], 0, -1); sl@0: //Check notifications sl@0: r = lddChan.CheckNotifications(dynamicDepResId[3], 1, 0); sl@0: test(r == KErrNone); sl@0: sl@0: r = lddChan.DeRegisterDynamicResource(Clients[0].iClientId, dynamicDepResId[3], NULL); sl@0: test(r == KErrNone); sl@0: //Check notifications sl@0: r = lddChan.CheckNotifications(dynamicDepResId[3], 1, 0); sl@0: test(r == KErrNone); sl@0: sl@0: //Deregister dependency between H and J sl@0: r = lddChan.DeRegisterResourceDependency(Clients[0].iClientId, dynamicDepResId[2], dynamicDepResId[0]); sl@0: test(r == KErrNone); sl@0: sl@0: RmTest.CheckForDependencyInformation(Clients[0].iClientId, dynamicDepResId[2], 0, &depResArray[0]); sl@0: sl@0: depResArray[0].iResourceId = dynamicDepResId[1]; sl@0: depResArray[0].iDependencyPriority = 1; sl@0: depResArray[1].iResourceId = iStaticDependencyResources[5]; sl@0: depResArray[1].iDependencyPriority = 3; sl@0: RmTest.CheckForDependencyInformation(Clients[0].iClientId, dynamicDepResId[0], 2, &depResArray[0]); sl@0: sl@0: /* Remove client level from resource 7 */ sl@0: r = lddChan.DeRegisterClientLevelFromResource(Clients[1].iClientId, dynamicDepResId[2]); sl@0: test(r == KErrNone); sl@0: sl@0: GetExtendedResStateAndVerify(dynamicDepResId[2], 12, Clients[2].iClientId); sl@0: //Check notifications sl@0: r = lddChan.CheckNotifications(dynamicDepResId[2], 0, 0); sl@0: test(r == KErrNone); sl@0: sl@0: r = lddChan.DeRegisterClient(Clients[2].iClientId); sl@0: test(r == KErrNone); sl@0: sl@0: GetExtendedResStateAsyncAndVerify(dynamicDepResId[2], 19, -1, EFalse); sl@0: sl@0: //Deregister dependency between G and H sl@0: r = lddChan.DeRegisterResourceDependency(Clients[1].iClientId, iStaticDependencyResources[5], dynamicDepResId[0]); sl@0: test(r == KErrNone); sl@0: sl@0: depResArray[0].iResourceId = dynamicDepResId[1]; sl@0: depResArray[0].iDependencyPriority = 1; sl@0: RmTest.CheckForDependencyInformation(Clients[0].iClientId, dynamicDepResId[0], 1, &depResArray[0]); sl@0: sl@0: depResArray[0].iResourceId = iStaticDependencyResources[3]; sl@0: depResArray[0].iDependencyPriority = 1; sl@0: RmTest.CheckForDependencyInformation(Clients[0].iClientId, iStaticDependencyResources[5], 1, &depResArray[0]); sl@0: sl@0: GetExtendedResStateAndVerify(dynamicDepResId[0], 75, -1); sl@0: GetExtendedResStateAsyncAndVerify(dynamicDepResId[1], 0, dynamicDepResId[0]); sl@0: GetExtendedResStateAsyncAndVerify(iStaticDependencyResources[5], 67, iStaticDependencyResources[3], EFalse); sl@0: sl@0: //Deregister dependency between I and H sl@0: r = lddChan.DeRegisterResourceDependency(Clients[1].iClientId, dynamicDepResId[1], dynamicDepResId[0]); sl@0: test(r == KErrNone); sl@0: sl@0: RmTest.CheckForDependencyInformation(Clients[0].iClientId, dynamicDepResId[0], 0, &depResArray[0]); sl@0: sl@0: RmTest.CheckForDependencyInformation(Clients[0].iClientId, dynamicDepResId[1], 0, &depResArray[0]); sl@0: sl@0: GetExtendedResStateAndVerify(dynamicDepResId[0], 75, -1); sl@0: GetExtendedResStateAsyncAndVerify(dynamicDepResId[1], 0, -1); sl@0: GetExtendedResStateAsyncAndVerify(iStaticDependencyResources[5], 67, iStaticDependencyResources[3], EFalse); sl@0: //Check notifications sl@0: r = lddChan.CheckNotifications(iStaticDependencyResources[5], 0, 0); sl@0: test(r == KErrNone); sl@0: r = lddChan.CheckNotifications(dynamicDepResId[1], 1, 0); sl@0: test(r == KErrNone); sl@0: sl@0: r = lddChan.DeRegisterDynamicResource(Clients[0].iClientId, dynamicDepResId[2], NULL); sl@0: test(r == KErrNone); sl@0: r = lddChan.DeRegisterDynamicResource(Clients[0].iClientId, dynamicDepResId[1], NULL); sl@0: test(r == KErrNone); sl@0: //Check notifications sl@0: r = lddChan.CheckNotifications(dynamicDepResId[1], 1, 0); sl@0: test(r == KErrNone); sl@0: r = lddChan.DeRegisterDynamicResource(Clients[0].iClientId, dynamicDepResId[0], NULL); sl@0: test(r == KErrNone); sl@0: r = lddChan.DeRegisterClient(Clients[1].iClientId); sl@0: test(r == KErrNone); sl@0: GetExtendedResStateAsyncAndVerify(iStaticDependencyResources[0], -100, -1, EFalse); sl@0: GetExtendedResStateAsyncAndVerify(iStaticDependencyResources[1], -10, iStaticDependencyResources[0], EFalse); sl@0: GetExtendedResStateAsyncAndVerify(iStaticDependencyResources[2], 0, iStaticDependencyResources[0], EFalse); sl@0: GetExtendedResStateAsyncAndVerify(iStaticDependencyResources[3], 10, iStaticDependencyResources[0], EFalse); sl@0: GetExtendedResStateAsyncAndVerify(iStaticDependencyResources[4], 1, iStaticDependencyResources[3], EFalse); sl@0: GetExtendedResStateAsyncAndVerify(iStaticDependencyResources[5], 75, iStaticDependencyResources[3], EFalse); sl@0: r = lddChan.DeRegisterClient(Clients[3].iClientId); sl@0: test(r == KErrNone); sl@0: sl@0: r = lddChan.DeRegisterClient(Clients[0].iClientId); sl@0: test(r == KErrNone); sl@0: sl@0: r = lddChan.DeRegisterClient(Clients[4].iClientId); sl@0: test(r == KErrNone); sl@0: sl@0: depResArray.Close(); sl@0: return; sl@0: } sl@0: sl@0: //---------------------------------------------------------------------------------------------- sl@0: //! @SYMTestCaseID KBASE-T_RESCONTROLCLI-0596 sl@0: //! @SYMTestType UT sl@0: //! @SYMPREQ PREQ1398 sl@0: //! @SYMTestCaseDesc This test case tests dynamic resources which does not support dependency sl@0: //! @SYMTestActions 0 Register clients sl@0: //! 1 Register dynamic resource sl@0: //! 2 Register notifications sl@0: //! 3 Change Resource State of each static resource with dependency sl@0: //! 4 Get state of the resource and check for correctness sl@0: //! 5 Check notification count for correctness sl@0: //! 6 Deregister client level sl@0: //! 7 Deregister dynamic resource sl@0: //! 8 Deregister clients sl@0: //! sl@0: //! @SYMTestExpectedResults 0 API should return with KErrNone, panics otherwise. sl@0: //! 1 API should return with KErrNone, panics otherwise. sl@0: //! 2 API should return with KErrNone, panics otherwise. sl@0: //! 3 API should return with KErrNone, panics otherwise. sl@0: //! 4 API should return with KErrNone, panics otherwise. sl@0: //! 5 API should return with KErrNone, panics otherwise. sl@0: //! 6 API should return with KErrNone, panics otherwise. sl@0: //! 7 API should return with KErrNone, panics otherwise. sl@0: //! 8 API should return with KErrNone, panics otherwise. sl@0: //! @SYMTestPriority High sl@0: //! @SYMTestStatus Implemented sl@0: //---------------------------------------------------------------------------------------------- sl@0: void TestRM::TestDynamicResource() sl@0: { sl@0: TInt state; sl@0: TRequestStatus req; sl@0: TUint dynamicResId[4]; sl@0: sl@0: test.Next(_L("Testing dynamic resource")); sl@0: //Register client 1 sl@0: RmTest.RegisterClient(); sl@0: //Register client 2 sl@0: RmTest.RegisterClient(); sl@0: //Register client 3 sl@0: RmTest.RegisterClient(); sl@0: sl@0: NegativeTesting = EFalse; sl@0: dynamicResId[0] = 1; sl@0: //Register dynamic resource 1 sl@0: r = lddChan.RegisterDynamicResource(Clients[0].iClientId, dynamicResId[0]); sl@0: test(r == KErrNone); sl@0: //Deregister dynamic resource with different client id sl@0: r = lddChan.DeRegisterDynamicResource(Clients[1].iClientId, dynamicResId[0], NULL); sl@0: test(r == KErrAccessDenied); sl@0: dynamicResId[1] = 2; sl@0: //Register dynamic resource 2 sl@0: r = lddChan.RegisterDynamicResource(Clients[1].iClientId, dynamicResId[1]); sl@0: test(r == KErrNone); sl@0: RmTest.GetNumResourcesInUseByClient(iCurrentClientId); sl@0: RmTest.GetInfoOnResourcesInUseByClient(iCurrentClientId, iMaxStaticResources); sl@0: sl@0: TUint numClients; sl@0: r = lddChan.GetNumClientsUsingResource(Clients[0].iClientId, dynamicResId[0], numClients); sl@0: test(r == KErrNone); sl@0: test(numClients == 0); sl@0: sl@0: r = lddChan.RequestNotification(Clients[1].iClientId, dynamicResId[0]); sl@0: test(r == KErrNone); sl@0: //Register client 4 sl@0: RmTest.RegisterClient(); sl@0: r = lddChan.RequestNotification(Clients[2].iClientId, dynamicResId[0], 1, 1); sl@0: test(r == KErrNone); sl@0: //Change state of dynamic resource 1 and verify sl@0: state = 1; sl@0: lddChan.ChangeResourceStateAsync(Clients[0].iClientId, dynamicResId[0], state, req); sl@0: User::WaitForRequest(req); sl@0: test(req.Int() == KErrNone); sl@0: sl@0: r = lddChan.CheckNotifications(dynamicResId[0], 1, 1); sl@0: test(r == KErrNone); sl@0: sl@0: GetExtendedResStateAsyncAndVerify(dynamicResId[0], 1, Clients[0].iClientId, EFalse); sl@0: sl@0: r = lddChan.GetNumClientsUsingResource(Clients[0].iClientId, dynamicResId[0], numClients); sl@0: test(r == KErrNone); sl@0: test(numClients == 1); sl@0: //Change state of dynamic resource 1. sl@0: r = lddChan.ChangeResourceStateSync(Clients[1].iClientId, dynamicResId[0], 0); sl@0: test(r == KErrAccessDenied); sl@0: //Deregister dynamic resource 1 and set the resource to 1. sl@0: state = 1; sl@0: r = lddChan.DeRegisterDynamicResource(Clients[0].iClientId, dynamicResId[0], &state); sl@0: test(r == KErrNone); sl@0: sl@0: r = lddChan.CheckNotifications(dynamicResId[0], 1, 1); sl@0: test(r == KErrNone); sl@0: sl@0: r = lddChan.GetNumClientsUsingResource(Clients[0].iClientId, dynamicResId[0], numClients); sl@0: test(r == KErrNotFound); sl@0: //Register client 5 sl@0: RmTest.RegisterClient(); sl@0: sl@0: GetExtendedResStateAndVerify(dynamicResId[1], -5, -1); sl@0: sl@0: r = lddChan.RequestNotification(Clients[1].iClientId, dynamicResId[1]); sl@0: test(r == KErrNone); sl@0: sl@0: r = lddChan.RequestNotification(Clients[2].iClientId, dynamicResId[1], 0, -8); sl@0: test(r == KErrNone); sl@0: //Change state of dynamic resource 1 and verify sl@0: state = -7; sl@0: lddChan.ChangeResourceStateAsync(Clients[2].iClientId, dynamicResId[1], state, req); sl@0: User::WaitForRequest(req); sl@0: test(req.Int() == KErrNone); sl@0: sl@0: r = lddChan.CheckNotifications(dynamicResId[1], 1, 0); sl@0: test(r == KErrNone); sl@0: sl@0: GetExtendedResStateAndVerify(dynamicResId[1], -7, Clients[2].iClientId); sl@0: //Register client 6 sl@0: RmTest.RegisterClient(); sl@0: //Register client 7 sl@0: RmTest.RegisterClient(); sl@0: //Change state of dynamic resource 2 and verify sl@0: state = -9; sl@0: lddChan.ChangeResourceStateAsync(Clients[3].iClientId, dynamicResId[1], state, req); sl@0: User::WaitForRequest(req); sl@0: test(req.Int() == KErrNone); sl@0: sl@0: r = lddChan.CheckNotifications(dynamicResId[1], 1, 1); sl@0: test(r == KErrNone); sl@0: sl@0: GetExtendedResStateAsyncAndVerify(dynamicResId[1], -9, Clients[3].iClientId, EFalse); sl@0: //Change state of dynamic resource 1 and verify sl@0: state = -10; sl@0: lddChan.ChangeResourceStateAsync(Clients[4].iClientId, dynamicResId[1], state, req); sl@0: User::WaitForRequest(req); sl@0: test(req.Int() == KErrNone); sl@0: sl@0: r = lddChan.CheckNotifications(dynamicResId[1], 1, 0); sl@0: test(r == KErrNone); sl@0: sl@0: GetExtendedResStateAsyncAndVerify(dynamicResId[1], -10, Clients[4].iClientId, EFalse); sl@0: sl@0: lddChan.ChangeResourceStateSync(Clients[5].iClientId, dynamicResId[1], state); sl@0: test(r == KErrNone); sl@0: sl@0: r = lddChan.CheckNotifications(dynamicResId[1], 0, 0); sl@0: test(r == KErrNone); sl@0: sl@0: GetExtendedResStateAsyncAndVerify(dynamicResId[1], -10, Clients[4].iClientId, EFalse); sl@0: //Change state of dynamic resource 1 and verify sl@0: state = -6; sl@0: lddChan.ChangeResourceStateSync(Clients[6].iClientId, dynamicResId[1], state); sl@0: test(r == KErrNone); sl@0: sl@0: r = lddChan.CheckNotifications(dynamicResId[1], 0, 0); sl@0: test(r == KErrNone); sl@0: sl@0: GetExtendedResStateAsyncAndVerify(dynamicResId[1], -10, Clients[4].iClientId, EFalse); sl@0: sl@0: r = lddChan.DeRegisterClientLevelFromResource(Clients[4].iClientId, dynamicResId[1]); sl@0: test(r == KErrNone); sl@0: sl@0: GetExtendedResStateAsyncAndVerify(dynamicResId[1], -10, Clients[5].iClientId, EFalse); sl@0: sl@0: r = lddChan.DeRegisterClientLevelFromResource(Clients[5].iClientId, dynamicResId[1]); sl@0: test(r == KErrNone); sl@0: sl@0: r = lddChan.CheckNotifications(dynamicResId[1], 1, 0); sl@0: test(r == KErrNone); sl@0: GetExtendedResStateAsyncAndVerify(dynamicResId[1], -9, Clients[3].iClientId, EFalse); sl@0: //Deregister client 4 sl@0: r = lddChan.DeRegisterClient(Clients[3].iClientId); sl@0: test(r == KErrNone); sl@0: sl@0: r = lddChan.CheckNotifications(dynamicResId[1], 1, 0); sl@0: test(r == KErrNone); sl@0: GetExtendedResStateAsyncAndVerify(dynamicResId[1], -7, Clients[2].iClientId, EFalse); sl@0: sl@0: r = lddChan.DeRegisterClientLevelFromResource(Clients[2].iClientId, dynamicResId[1]); sl@0: test(r == KErrNone); sl@0: sl@0: r = lddChan.CheckNotifications(dynamicResId[1], 1, 0); sl@0: test(r == KErrNone); sl@0: GetExtendedResStateAsyncAndVerify(dynamicResId[1], -6, Clients[6].iClientId, EFalse); sl@0: sl@0: r = lddChan.DeRegisterClientLevelFromResource(Clients[6].iClientId, dynamicResId[1]); sl@0: test(r == KErrNone); sl@0: sl@0: r = lddChan.CheckNotifications(dynamicResId[1], 1, 0); sl@0: test(r == KErrNone); sl@0: GetExtendedResStateAsyncAndVerify(dynamicResId[1], -5, -1, EFalse); sl@0: //Deregister dynamic resource 2 sl@0: r = lddChan.DeRegisterDynamicResource(Clients[1].iClientId, dynamicResId[1], NULL); sl@0: test(r == KErrNone); sl@0: sl@0: r = lddChan.CheckNotifications(dynamicResId[1], 1, 1); sl@0: test(r == KErrNone); sl@0: //Register dynamic resource 3 sl@0: dynamicResId[2] = 3; sl@0: r = lddChan.RegisterDynamicResource(Clients[2].iClientId, dynamicResId[2]); sl@0: test(r == KErrNone); sl@0: //Register dynamic resource 4 sl@0: dynamicResId[3] = 4; sl@0: r = lddChan.RegisterDynamicResource(Clients[6].iClientId, dynamicResId[3]); sl@0: test(r == KErrNone); sl@0: //Change state of dynamic resource 3 to 0 sl@0: r = lddChan.ChangeResourceStateSync(Clients[4].iClientId, dynamicResId[2], 0); sl@0: test(r == KErrNone); sl@0: GetExtendedResStateAndVerify(dynamicResId[2], 0, Clients[4].iClientId); sl@0: //Change state of dynamic resource 3 to 1 sl@0: r = lddChan.ChangeResourceStateSync(Clients[5].iClientId, dynamicResId[2], 1); sl@0: test(r == KErrNone); sl@0: GetExtendedResStateAndVerify(dynamicResId[2], 0, Clients[4].iClientId); sl@0: //Deregister client 5 sl@0: r = lddChan.DeRegisterClient(Clients[4].iClientId); sl@0: test(r == KErrNone); sl@0: GetExtendedResStateAndVerify(dynamicResId[2], 1, Clients[5].iClientId); sl@0: //Deregister dynamic resource 3 sl@0: r = lddChan.DeRegisterDynamicResource(Clients[2].iClientId, dynamicResId[2], NULL); sl@0: test(r == KErrInUse); sl@0: //Deregister client 6 sl@0: r = lddChan.DeRegisterClient(Clients[5].iClientId); sl@0: test(r == KErrNone); sl@0: GetExtendedResStateAndVerify(dynamicResId[2], 1, -1); sl@0: //Deregister dynamic resource 3 sl@0: r = lddChan.DeRegisterDynamicResource(Clients[2].iClientId, dynamicResId[2], NULL); sl@0: test(r == KErrNone); sl@0: //Change state of dynamic resource 4 to 15 sl@0: r = lddChan.ChangeResourceStateSync(Clients[6].iClientId, dynamicResId[3], 15); sl@0: test(r == KErrNone); sl@0: GetExtendedResStateAndVerify(dynamicResId[3], 15, Clients[6].iClientId); sl@0: //Change state of resource and try to deregister the resource while the change is taking place sl@0: state = 17; sl@0: lddChan.ChangeResStateAndDeRegisterDynamicRes(Clients[6].iClientId, dynamicResId[3], state, req); sl@0: User::WaitForRequest(req); sl@0: test(req.Int() == KErrNone); sl@0: test(state == 17); sl@0: GetExtendedResStateAndVerify(dynamicResId[3], 17, Clients[6].iClientId); sl@0: //Deregister dynamic resource 4 with some other client which is not owner sl@0: r = lddChan.DeRegisterDynamicResource(Clients[2].iClientId, dynamicResId[3], NULL); sl@0: test(r == KErrAccessDenied); sl@0: //Deregister dynamic resource 4 sl@0: r = lddChan.DeRegisterDynamicResource(Clients[6].iClientId, dynamicResId[3], NULL); sl@0: test(r == KErrNone); sl@0: //Deregister client 7 sl@0: r = lddChan.DeRegisterClient(Clients[6].iClientId); sl@0: test(r == KErrNone); sl@0: //Deregister client 3 sl@0: r = lddChan.DeRegisterClient(Clients[2].iClientId); sl@0: test(r == KErrNone); sl@0: //Deregister client 2 sl@0: r = lddChan.DeRegisterClient(Clients[1].iClientId); sl@0: test(r == KErrNone); sl@0: //Deregister client 1 sl@0: r = lddChan.DeRegisterClient(Clients[0].iClientId); sl@0: test(r == KErrNone); sl@0: Clients.Close(); sl@0: } sl@0: sl@0: //This function gets extended resource state synchronously and verifies for correctness sl@0: void TestRM::GetExtendedResStateAndVerify(TUint aResId, TInt aState, TInt aLevelOwnerId) sl@0: { sl@0: static TBool cached = ETrue; sl@0: TInt state; sl@0: TInt levelOwnerId; sl@0: r = lddChan.GetResourceStateSync(Clients[0].iClientId, aResId, cached, state, levelOwnerId); sl@0: test(r == KErrNone); sl@0: test(state == aState); sl@0: test(levelOwnerId == aLevelOwnerId); sl@0: return; sl@0: } sl@0: sl@0: //This function gets extended resource state asynchronously and verifies for correctness sl@0: void TestRM::GetExtendedResStateAsyncAndVerify(TUint aResId, TInt aState, TInt aLevelOwnerId, TBool aReqCancel) sl@0: { sl@0: static TBool cached = ETrue; sl@0: TRequestStatus resGet; sl@0: TInt levelOwnerId; sl@0: TInt state; sl@0: lddChan.GetResourceStateAsync(Clients[0].iClientId, aResId, cached, resGet, state, levelOwnerId, aReqCancel); sl@0: User::WaitForRequest(resGet); sl@0: if(aReqCancel && (resGet.Int() != KErrNone)) sl@0: { sl@0: test((resGet.Int() == KErrCompletion) || (resGet.Int() == KErrCancel)); sl@0: return; sl@0: } sl@0: test(resGet.Int() == KErrNone); sl@0: test(state == aState); sl@0: test(levelOwnerId == aLevelOwnerId); sl@0: } sl@0: sl@0: //This function validates number of dependency resource and their id's for correctness sl@0: void TestRM::CheckForDependencyInformation(TUint aClientId, TUint aResourceId, TUint aNumDependents, SResourceDependencyInfo* aDepResIdArray) sl@0: { sl@0: TUint numDepResources; sl@0: sl@0: //Get the number of dependent's for the resource sl@0: r = lddChan.GetNumDependentsForResource(aClientId, aResourceId, numDepResources); sl@0: if(r != KErrNone) sl@0: test.Printf(_L("GetNumDependentsForResource returned with %d\n"), r); sl@0: test(r == KErrNone); sl@0: if(aNumDependents != numDepResources) sl@0: test.Printf(_L("aNumDependents = %d, numDepResource = %d\n"), aNumDependents, numDepResources); sl@0: test(aNumDependents == numDepResources); sl@0: if(numDepResources == 0) sl@0: return; sl@0: //Get the dependent's id sl@0: RBuf8 info; sl@0: info.Create(aNumDependents * sizeof(SResourceDependencyInfo)); sl@0: r = lddChan.GetDependentsIdForResource(aClientId, aResourceId, (TAny*)&info, numDepResources); sl@0: if(r != KErrNone) sl@0: { sl@0: test.Printf(_L("GetDependentsIdForResource returned with %d\n"), r); sl@0: info.Close(); sl@0: } sl@0: test(r == KErrNone); sl@0: if(aNumDependents != numDepResources) sl@0: { sl@0: test.Printf(_L("aNumDependents = %d, numDepResource = %d\n"), aNumDependents, numDepResources); sl@0: info.Close(); sl@0: } sl@0: test(aNumDependents == numDepResources); sl@0: SResourceDependencyInfo* sResDepInfoPtr = (SResourceDependencyInfo*)info.Ptr(); sl@0: for(TUint count = 0; count < aNumDependents; count++, sResDepInfoPtr++) sl@0: { sl@0: if(sResDepInfoPtr->iResourceId != aDepResIdArray[count].iResourceId) sl@0: { sl@0: test.Printf(_L("Expected resourceId : %d, Returned ResourceId = %d\n"),sResDepInfoPtr->iResourceId, sl@0: aDepResIdArray[count].iResourceId); sl@0: info.Close(); sl@0: test(0); sl@0: } sl@0: if(sResDepInfoPtr->iDependencyPriority != aDepResIdArray[count].iDependencyPriority) sl@0: { sl@0: test.Printf(_L("Expected resource priority : %d, Returned resource priority = %d\n"),sResDepInfoPtr->iDependencyPriority, sl@0: aDepResIdArray[count].iDependencyPriority); sl@0: info.Close(); sl@0: test(0); sl@0: } sl@0: } sl@0: info.Close(); sl@0: return; sl@0: } sl@0: sl@0: //---------------------------------------------------------------------------------------------- sl@0: //! @SYMTestCaseID KBASE-T_RESCONTROLCLI-0595 sl@0: //! @SYMTestType UT sl@0: //! @SYMPREQ PREQ1398 sl@0: //! @SYMTestCaseDesc This test case tests static resources with dependency. sl@0: //! @SYMTestActions 0 Register clients sl@0: //! 1 Check dependency information of each resource sl@0: //! 2 Register notifications sl@0: //! 3 Change Resource State of each static resource with dependency sl@0: //! 4 Get state of the resources and verify them for correctness sl@0: //! 5 Check notification count for correctness sl@0: //! 6 Deregister client level sl@0: //! 7 Deregister clients sl@0: //! sl@0: //! @SYMTestExpectedResults 0 API should return with KErrNone, panics otherwise. sl@0: //! 1 API should return with KErrNone, panics otherwise. sl@0: //! 2 API should return with KErrNone, panics otherwise. sl@0: //! 3 API should return with KErrNone, panics otherwise. sl@0: //! 4 API should return with KErrNone, panics otherwise. sl@0: //! 5 API should return with KErrNone, panics otherwise. sl@0: //! 6 API should return with KErrNone, panics otherwise. sl@0: //! 7 API should return with KErrNone, panics otherwise. sl@0: //! @SYMTestPriority High sl@0: //! @SYMTestStatus Implemented sl@0: //---------------------------------------------------------------------------------------------- sl@0: void TestRM::TestStaticResourceWithDependency() sl@0: { sl@0: TUint count; sl@0: RArraydepResArray; sl@0: SResourceDependencyInfo sResDepInfo; sl@0: TUint numClients; // The maximum no. of dependents in the dependency tree. sl@0: sl@0: sl@0: //Register client 1. sl@0: RmTest.RegisterClient(); sl@0: iCurrentClientId = -1; sl@0: TInt state; sl@0: TRequestStatus reqSet; sl@0: sl@0: NegativeTesting = EFalse; sl@0: test.Next(_L("\nTesting static resource with dependency....")); sl@0: sl@0: //Check for resource dependency information of Resource D sl@0: sResDepInfo.iResourceId = iStaticDependencyResources[1]; sl@0: sResDepInfo.iDependencyPriority = 1; sl@0: depResArray.Append(sResDepInfo); sl@0: sResDepInfo.iResourceId = iStaticDependencyResources[3]; sl@0: sResDepInfo.iDependencyPriority = 2; sl@0: depResArray.Append(sResDepInfo); sl@0: sResDepInfo.iResourceId = iStaticDependencyResources[2]; sl@0: sResDepInfo.iDependencyPriority = 3; sl@0: depResArray.Append(sResDepInfo); sl@0: RmTest.CheckForDependencyInformation(Clients[0].iClientId, iStaticDependencyResources[0], 3, &depResArray[0]); sl@0: sl@0: //Check for resource dependency information of Resource E sl@0: depResArray[0].iResourceId = iStaticDependencyResources[4]; sl@0: depResArray[0].iDependencyPriority = 1; sl@0: depResArray[1].iResourceId = iStaticDependencyResources[5]; sl@0: depResArray[1].iDependencyPriority = 2; sl@0: depResArray[2].iResourceId = iStaticDependencyResources[0]; sl@0: depResArray[2].iDependencyPriority = 3; sl@0: RmTest.CheckForDependencyInformation(Clients[0].iClientId, iStaticDependencyResources[3], 3, &depResArray[0]); sl@0: sl@0: //Check for resource dependency information of Resource C sl@0: depResArray[0].iResourceId = iStaticDependencyResources[3]; sl@0: depResArray[0].iDependencyPriority = 1; sl@0: RmTest.CheckForDependencyInformation(Clients[0].iClientId, iStaticDependencyResources[4], 1, &depResArray[0]); sl@0: sl@0: //Check for resource dependency information of Resource G sl@0: RmTest.CheckForDependencyInformation(Clients[0].iClientId, iStaticDependencyResources[5], 1, &depResArray[0]); sl@0: sl@0: //Check for resource dependency information of Resource F sl@0: depResArray[0].iResourceId = iStaticDependencyResources[0]; sl@0: depResArray[0].iDependencyPriority = 1; sl@0: RmTest.CheckForDependencyInformation(Clients[0].iClientId, iStaticDependencyResources[2], 1, &depResArray[0]); sl@0: sl@0: //Check for resource dependency information of Resource A sl@0: RmTest.CheckForDependencyInformation(Clients[0].iClientId, iStaticDependencyResources[1], 1, &depResArray[0]); sl@0: sl@0: RmTest.GetNumResourcesInUseByClient(iCurrentClientId); sl@0: RmTest.GetInfoOnResourcesInUseByClient(iCurrentClientId, iMaxStaticResources + iMaxStaticDependentResources); sl@0: iCurrentClientId = 0; sl@0: //Get resource state of all dependent resource and verify sl@0: GetExtendedResStateAndVerify(iStaticDependencyResources[0], -50, -1); sl@0: GetExtendedResStateAsyncAndVerify(iStaticDependencyResources[1], -11, iStaticDependencyResources[0]); sl@0: GetExtendedResStateAndVerify(iStaticDependencyResources[2], 1, iStaticDependencyResources[0]); sl@0: GetExtendedResStateAsyncAndVerify(iStaticDependencyResources[3], 13, iStaticDependencyResources[0]); sl@0: GetExtendedResStateAsyncAndVerify(iStaticDependencyResources[4], 0, iStaticDependencyResources[3]); sl@0: GetExtendedResStateAndVerify(iStaticDependencyResources[5], 73, iStaticDependencyResources[3]); sl@0: sl@0: r = lddChan.GetNumClientsUsingResource(Clients[0].iClientId, iStaticDependencyResources[3], numClients); sl@0: test(r == KErrNone); sl@0: test(numClients == 0); sl@0: //Request notification sl@0: for(count = 0; count < iMaxStaticDependentResources; count++) sl@0: { sl@0: r = lddChan.RequestNotification(Clients[0].iClientId, iStaticDependencyResources[count]); sl@0: test(r == KErrNone); sl@0: } sl@0: //Change state of resource A to -11 and verify sl@0: r = lddChan.ChangeResourceStateSync(Clients[0].iClientId, iStaticDependencyResources[1], -11); sl@0: test(r == KErrNone); sl@0: GetExtendedResStateAsyncAndVerify(iStaticDependencyResources[1], -11, Clients[0].iClientId); sl@0: //Change state of resource A to -12 and verify sl@0: state = -12; sl@0: lddChan.ChangeResourceStateAsync(Clients[0].iClientId, iStaticDependencyResources[1], state, reqSet); sl@0: User::WaitForRequest(reqSet); sl@0: test(reqSet.Int() == KErrNone); sl@0: r = lddChan.CheckNotifications(iStaticDependencyResources[1], 1, 0); sl@0: test(r == KErrNone); sl@0: //Register client2 sl@0: RmTest.RegisterClient(); sl@0: //Change state of resource D to -49 and verify sl@0: state = -49; sl@0: lddChan.ChangeResourceStateAsync(Clients[1].iClientId, iStaticDependencyResources[0], state, reqSet); sl@0: User::WaitForRequest(reqSet); sl@0: test(reqSet.Int() == KErrNone); sl@0: //Check for notifications sl@0: r = lddChan.CheckNotifications(iStaticDependencyResources[0], 1, 0); sl@0: test(r == KErrNone); sl@0: r = lddChan.CheckNotifications(iStaticDependencyResources[1], 1, 0); sl@0: test(r == KErrNone); sl@0: r = lddChan.CheckNotifications(iStaticDependencyResources[3], 1, 0); sl@0: test(r == KErrNone); sl@0: r = lddChan.CheckNotifications(iStaticDependencyResources[5], 1, 0); sl@0: test(r == KErrNone); sl@0: //Get the state and verify for correctness sl@0: GetExtendedResStateAndVerify(iStaticDependencyResources[0], -49, Clients[1].iClientId); sl@0: GetExtendedResStateAsyncAndVerify(iStaticDependencyResources[1], -13, iStaticDependencyResources[0]); sl@0: GetExtendedResStateAsyncAndVerify(iStaticDependencyResources[2], 1, iStaticDependencyResources[0]); sl@0: GetExtendedResStateAndVerify(iStaticDependencyResources[3], 16, iStaticDependencyResources[0]); sl@0: GetExtendedResStateAsyncAndVerify(iStaticDependencyResources[4], 0, iStaticDependencyResources[3]); sl@0: GetExtendedResStateAndVerify(iStaticDependencyResources[5], 71, iStaticDependencyResources[3]); sl@0: //Change state of resource F to 1 and verify sl@0: r = lddChan.ChangeResourceStateSync(Clients[1].iClientId, iStaticDependencyResources[2], 1); sl@0: test(r == KErrNone); sl@0: r = lddChan.CheckNotifications(iStaticDependencyResources[2], 0, 0); sl@0: test(r == KErrNone); sl@0: GetExtendedResStateAndVerify(iStaticDependencyResources[2], 1, Clients[1].iClientId); sl@0: //Register client 3 sl@0: RmTest.RegisterClient(); sl@0: //Change state of resource E to 19 and verify sl@0: r = lddChan.ChangeResourceStateSync(Clients[2].iClientId, iStaticDependencyResources[3], 19); sl@0: test(r == KErrNone); sl@0: r = lddChan.CheckNotifications(iStaticDependencyResources[3], 1, 0); sl@0: test(r == KErrNone); sl@0: r = lddChan.CheckNotifications(iStaticDependencyResources[5], 1, 0); sl@0: test(r == KErrNone); sl@0: GetExtendedResStateAndVerify(iStaticDependencyResources[0], -49, Clients[1].iClientId); sl@0: GetExtendedResStateAsyncAndVerify(iStaticDependencyResources[1], -13, iStaticDependencyResources[0]); sl@0: GetExtendedResStateAsyncAndVerify(iStaticDependencyResources[2], 1, Clients[1].iClientId); sl@0: GetExtendedResStateAndVerify(iStaticDependencyResources[3], 19, Clients[2].iClientId); sl@0: GetExtendedResStateAsyncAndVerify(iStaticDependencyResources[4], 0, iStaticDependencyResources[3]); sl@0: GetExtendedResStateAndVerify(iStaticDependencyResources[5], 69, iStaticDependencyResources[3]); sl@0: //Register client 4 sl@0: RmTest.RegisterClient(); sl@0: //Change state of resource C to 0 and verify sl@0: r = lddChan.ChangeResourceStateSync(Clients[3].iClientId, iStaticDependencyResources[4], 0); sl@0: test(r == KErrNone); sl@0: r = lddChan.CheckNotifications(iStaticDependencyResources[4], 0, 0); sl@0: test(r == KErrNone); sl@0: GetExtendedResStateAsyncAndVerify(iStaticDependencyResources[4], 0, iStaticDependencyResources[3]); sl@0: //Change state of resource C to 1 and verify sl@0: r = lddChan.ChangeResourceStateSync(Clients[2].iClientId, iStaticDependencyResources[4], 1); sl@0: test(r == KErrNone); sl@0: r = lddChan.CheckNotifications(iStaticDependencyResources[4], 0, 0); sl@0: test(r == KErrNone); sl@0: GetExtendedResStateAsyncAndVerify(iStaticDependencyResources[4], 0, iStaticDependencyResources[3]); sl@0: //Change state of resource G to 67 and verify sl@0: r = lddChan.ChangeResourceStateSync(Clients[2].iClientId, iStaticDependencyResources[5], 67); sl@0: test(r == KErrNone); sl@0: r = lddChan.CheckNotifications(iStaticDependencyResources[5], 1, 0); sl@0: test(r == KErrNone); sl@0: GetExtendedResStateAndVerify(iStaticDependencyResources[0], -49, Clients[1].iClientId); sl@0: GetExtendedResStateAsyncAndVerify(iStaticDependencyResources[1], -13, iStaticDependencyResources[0]); sl@0: GetExtendedResStateAsyncAndVerify(iStaticDependencyResources[2], 1, Clients[1].iClientId); sl@0: GetExtendedResStateAndVerify(iStaticDependencyResources[3], 19, Clients[2].iClientId); sl@0: GetExtendedResStateAsyncAndVerify(iStaticDependencyResources[4], 0, iStaticDependencyResources[3]); sl@0: GetExtendedResStateAndVerify(iStaticDependencyResources[5], 67, Clients[2].iClientId); sl@0: //Change state of resource G to 67 and verify sl@0: r = lddChan.ChangeResourceStateSync(Clients[3].iClientId, iStaticDependencyResources[5], 67); sl@0: test(r == KErrNone); sl@0: r = lddChan.CheckNotifications(iStaticDependencyResources[5], 0, 0); sl@0: test(r == KErrNone); sl@0: GetExtendedResStateAndVerify(iStaticDependencyResources[0], -49, Clients[1].iClientId); sl@0: GetExtendedResStateAsyncAndVerify(iStaticDependencyResources[1], -13, iStaticDependencyResources[0]); sl@0: GetExtendedResStateAsyncAndVerify(iStaticDependencyResources[2], 1, Clients[1].iClientId); sl@0: GetExtendedResStateAndVerify(iStaticDependencyResources[3], 19, Clients[2].iClientId); sl@0: GetExtendedResStateAsyncAndVerify(iStaticDependencyResources[4], 0, iStaticDependencyResources[3]); sl@0: GetExtendedResStateAndVerify(iStaticDependencyResources[5], 67, Clients[2].iClientId); sl@0: sl@0: //Change the state of the resource E to 24 sl@0: state = 24; sl@0: //Register client 5 sl@0: RmTest.RegisterClient(); sl@0: lddChan.ChangeResourceStateAsync(Clients[4].iClientId, iStaticDependencyResources[3], state, reqSet); sl@0: User::WaitForRequest(reqSet); sl@0: test(reqSet.Int() == KErrNone); sl@0: r = lddChan.CheckNotifications(iStaticDependencyResources[3], 1, 0); sl@0: test(r == KErrNone); sl@0: r = lddChan.CheckNotifications(iStaticDependencyResources[5], 1, 0); sl@0: test(r == KErrNone); sl@0: GetExtendedResStateAndVerify(iStaticDependencyResources[0], -49, Clients[1].iClientId); sl@0: GetExtendedResStateAsyncAndVerify(iStaticDependencyResources[1], -13, iStaticDependencyResources[0]); sl@0: GetExtendedResStateAsyncAndVerify(iStaticDependencyResources[2], 1, Clients[1].iClientId); sl@0: GetExtendedResStateAndVerify(iStaticDependencyResources[3], 24, Clients[4].iClientId); sl@0: GetExtendedResStateAsyncAndVerify(iStaticDependencyResources[4], 0, iStaticDependencyResources[3]); sl@0: GetExtendedResStateAndVerify(iStaticDependencyResources[5], 65, iStaticDependencyResources[3]); sl@0: sl@0: //Change resource state of Resource D to -51 sl@0: r = lddChan.ChangeResourceStateSync(Clients[2].iClientId, iStaticDependencyResources[0], -51); sl@0: test(r == KErrAccessDenied); sl@0: GetExtendedResStateAndVerify(iStaticDependencyResources[0], -49, Clients[1].iClientId); sl@0: sl@0: //DeregisterClient 5 sl@0: r = lddChan.DeRegisterClient(Clients[4].iClientId); sl@0: test(r == KErrNone); sl@0: sl@0: r = lddChan.CheckNotifications(iStaticDependencyResources[3], 1, 0); sl@0: test(r == KErrNone); sl@0: r = lddChan.CheckNotifications(iStaticDependencyResources[5], 1, 0); sl@0: test(r == KErrNone); sl@0: sl@0: GetExtendedResStateAndVerify(iStaticDependencyResources[3], 19, Clients[2].iClientId); sl@0: GetExtendedResStateAndVerify(iStaticDependencyResources[5], 63, iStaticDependencyResources[3]); sl@0: sl@0: //Change resource state of resource D to 50 sl@0: state = 50; sl@0: lddChan.ChangeResourceStateAsync(Clients[1].iClientId, iStaticDependencyResources[0], state, reqSet); sl@0: User::WaitForRequest(reqSet); sl@0: test(reqSet.Int() == KErrNone); sl@0: r = lddChan.CheckNotifications(iStaticDependencyResources[0], 1, 0); sl@0: test(r == KErrNone); sl@0: r = lddChan.CheckNotifications(iStaticDependencyResources[1], 1, 0); sl@0: test(r == KErrNone); sl@0: r = lddChan.CheckNotifications(iStaticDependencyResources[3], 1, 0); sl@0: test(r == KErrNone); sl@0: r = lddChan.CheckNotifications(iStaticDependencyResources[5], 1, 0); sl@0: test(r == KErrNone); sl@0: sl@0: GetExtendedResStateAndVerify(iStaticDependencyResources[0], 50, Clients[1].iClientId); sl@0: GetExtendedResStateAsyncAndVerify(iStaticDependencyResources[1], -14, iStaticDependencyResources[0]); sl@0: GetExtendedResStateAsyncAndVerify(iStaticDependencyResources[2], 1, Clients[1].iClientId); sl@0: GetExtendedResStateAndVerify(iStaticDependencyResources[3], 22, iStaticDependencyResources[0]); sl@0: GetExtendedResStateAsyncAndVerify(iStaticDependencyResources[4], 0, iStaticDependencyResources[3]); sl@0: GetExtendedResStateAndVerify(iStaticDependencyResources[5], 61, iStaticDependencyResources[3]); sl@0: sl@0: //Change resource state of resource G to 61 sl@0: r = lddChan.ChangeResourceStateSync(Clients[3].iClientId, iStaticDependencyResources[5], 61); sl@0: test(r == KErrNone); sl@0: sl@0: r = lddChan.CheckNotifications(iStaticDependencyResources[5], 0, 0); sl@0: test(r == KErrNone); sl@0: sl@0: GetExtendedResStateAndVerify(iStaticDependencyResources[0], 50, Clients[1].iClientId); sl@0: GetExtendedResStateAsyncAndVerify(iStaticDependencyResources[1], -14, iStaticDependencyResources[0]); sl@0: GetExtendedResStateAsyncAndVerify(iStaticDependencyResources[2], 1, Clients[1].iClientId); sl@0: GetExtendedResStateAndVerify(iStaticDependencyResources[3], 22, iStaticDependencyResources[0]); sl@0: GetExtendedResStateAsyncAndVerify(iStaticDependencyResources[4], 0, iStaticDependencyResources[3]); sl@0: GetExtendedResStateAndVerify(iStaticDependencyResources[5], 61, iStaticDependencyResources[3]); sl@0: sl@0: //Deregister client 4; sl@0: r = lddChan.DeRegisterClient(Clients[3].iClientId); sl@0: test(r == KErrNone); sl@0: sl@0: r = lddChan.CheckNotifications(iStaticDependencyResources[5], 0, 0); sl@0: test(r == KErrNone); sl@0: sl@0: GetExtendedResStateAndVerify(iStaticDependencyResources[0], 50, Clients[1].iClientId); sl@0: GetExtendedResStateAsyncAndVerify(iStaticDependencyResources[1], -14, iStaticDependencyResources[0]); sl@0: GetExtendedResStateAsyncAndVerify(iStaticDependencyResources[2], 1, Clients[1].iClientId); sl@0: GetExtendedResStateAndVerify(iStaticDependencyResources[3], 22, iStaticDependencyResources[0]); sl@0: GetExtendedResStateAsyncAndVerify(iStaticDependencyResources[4], 0, iStaticDependencyResources[3]); sl@0: GetExtendedResStateAndVerify(iStaticDependencyResources[5], 61, iStaticDependencyResources[3]); sl@0: sl@0: //Deregister client 3. sl@0: r = lddChan.DeRegisterClient(Clients[2].iClientId); sl@0: test(r == KErrNone); sl@0: sl@0: GetExtendedResStateAndVerify(iStaticDependencyResources[0], 50, Clients[1].iClientId); sl@0: GetExtendedResStateAsyncAndVerify(iStaticDependencyResources[1], -14, iStaticDependencyResources[0]); sl@0: GetExtendedResStateAsyncAndVerify(iStaticDependencyResources[2], 1, Clients[1].iClientId); sl@0: GetExtendedResStateAndVerify(iStaticDependencyResources[3], 22, iStaticDependencyResources[0]); sl@0: GetExtendedResStateAsyncAndVerify(iStaticDependencyResources[4], 0, iStaticDependencyResources[3]); sl@0: GetExtendedResStateAndVerify(iStaticDependencyResources[5], 61, iStaticDependencyResources[3]); sl@0: sl@0: //Deregister client 0 from Resource A sl@0: r = lddChan.DeRegisterClientLevelFromResource(Clients[0].iClientId, iStaticDependencyResources[1]); sl@0: test(r == KErrNone); sl@0: sl@0: r = lddChan.CheckNotifications(iStaticDependencyResources[1], 0, 0); sl@0: test(r == KErrNone); sl@0: sl@0: GetExtendedResStateAndVerify(iStaticDependencyResources[0], 50, Clients[1].iClientId); sl@0: GetExtendedResStateAsyncAndVerify(iStaticDependencyResources[1], -14, iStaticDependencyResources[0]); sl@0: GetExtendedResStateAsyncAndVerify(iStaticDependencyResources[2], 1, Clients[1].iClientId); sl@0: GetExtendedResStateAndVerify(iStaticDependencyResources[3], 22, iStaticDependencyResources[0]); sl@0: GetExtendedResStateAsyncAndVerify(iStaticDependencyResources[4], 0, iStaticDependencyResources[3]); sl@0: GetExtendedResStateAndVerify(iStaticDependencyResources[5], 61, iStaticDependencyResources[3]); sl@0: sl@0: //Move Resource D to default sl@0: r = lddChan.ChangeResourceStateSync(Clients[1].iClientId, iStaticDependencyResources[0], -100); sl@0: test(r == KErrPermissionDenied); sl@0: sl@0: //Deregister client 1 from Resource F sl@0: r = lddChan.DeRegisterClientLevelFromResource(Clients[1].iClientId, iStaticDependencyResources[2]); sl@0: test(r == KErrNone); sl@0: sl@0: r = lddChan.CheckNotifications(iStaticDependencyResources[1], 0, 0); sl@0: test(r == KErrNone); sl@0: sl@0: GetExtendedResStateAndVerify(iStaticDependencyResources[0], 50, Clients[1].iClientId); sl@0: GetExtendedResStateAsyncAndVerify(iStaticDependencyResources[1], -14, iStaticDependencyResources[0]); sl@0: GetExtendedResStateAsyncAndVerify(iStaticDependencyResources[2], 1, iStaticDependencyResources[0]); sl@0: GetExtendedResStateAndVerify(iStaticDependencyResources[3], 22, iStaticDependencyResources[0]); sl@0: GetExtendedResStateAsyncAndVerify(iStaticDependencyResources[4], 0, iStaticDependencyResources[3]); sl@0: GetExtendedResStateAndVerify(iStaticDependencyResources[5], 61, iStaticDependencyResources[3]); sl@0: sl@0: //Deregister client 2 sl@0: r = lddChan.DeRegisterClient(Clients[1].iClientId); sl@0: test(r == KErrNone); sl@0: sl@0: GetExtendedResStateAndVerify(iStaticDependencyResources[0], -100, -1); sl@0: GetExtendedResStateAsyncAndVerify(iStaticDependencyResources[1], -10, iStaticDependencyResources[0]); sl@0: GetExtendedResStateAsyncAndVerify(iStaticDependencyResources[2], 0, iStaticDependencyResources[0]); sl@0: GetExtendedResStateAndVerify(iStaticDependencyResources[3], 10, iStaticDependencyResources[0]); sl@0: GetExtendedResStateAsyncAndVerify(iStaticDependencyResources[4], 1, iStaticDependencyResources[3]); sl@0: GetExtendedResStateAndVerify(iStaticDependencyResources[5], 75, iStaticDependencyResources[3]); sl@0: //Deregister client 1 sl@0: r = lddChan.DeRegisterClient(Clients[0].iClientId); sl@0: test(r == KErrNone); sl@0: Clients.Close(); //Close the array and release memory sl@0: sl@0: //Test parallel execution of RC and Dependency resource DFC's sl@0: //Register client 1 sl@0: RmTest.RegisterClient(); sl@0: //Register client 2 sl@0: RmTest.RegisterClient(); sl@0: sl@0: state = 50; sl@0: /* CheckParallelExecutionForResChageStateWithDependency */ sl@0: lddChan.CheckParallelExecutionForChangeResState(Clients[1].iClientId, sl@0: iStaticDependencyResources[0],state,5,0,reqSet); sl@0: sl@0: User::WaitForRequest(reqSet); sl@0: test(reqSet.Int() == KErrNone); sl@0: sl@0: GetExtendedResStateAndVerify(iStaticDependencyResources[0], 50, Clients[1].iClientId); sl@0: GetExtendedResStateAsyncAndVerify(iStaticDependencyResources[1], -11, iStaticDependencyResources[0]); sl@0: GetExtendedResStateAndVerify(iStaticDependencyResources[2], 1, iStaticDependencyResources[0]); sl@0: GetExtendedResStateAsyncAndVerify(iStaticDependencyResources[3], 13, iStaticDependencyResources[0]); sl@0: GetExtendedResStateAsyncAndVerify(iStaticDependencyResources[4], 0, iStaticDependencyResources[3]); sl@0: GetExtendedResStateAndVerify(iStaticDependencyResources[5], 73, iStaticDependencyResources[3]); sl@0: sl@0: TInt owner; sl@0: TBool cached = ETrue; sl@0: r = lddChan.GetResourceStateSync(Clients[1].iClientId, 4, cached, state, owner); sl@0: test(r == KErrNone); sl@0: test(state == 75); sl@0: test(owner == -1); sl@0: sl@0: r = lddChan.DeRegisterClient(Clients[1].iClientId); sl@0: test(r == KErrNone); sl@0: sl@0: GetExtendedResStateAndVerify(iStaticDependencyResources[0], -100, -1); sl@0: GetExtendedResStateAsyncAndVerify(iStaticDependencyResources[1], -10, iStaticDependencyResources[0]); sl@0: GetExtendedResStateAsyncAndVerify(iStaticDependencyResources[2], 0, iStaticDependencyResources[0]); sl@0: GetExtendedResStateAndVerify(iStaticDependencyResources[3], 10, iStaticDependencyResources[0]); sl@0: GetExtendedResStateAsyncAndVerify(iStaticDependencyResources[4], 1, iStaticDependencyResources[3]); sl@0: GetExtendedResStateAndVerify(iStaticDependencyResources[5], 75, iStaticDependencyResources[3]); sl@0: sl@0: r = lddChan.GetResourceStateSync(Clients[0].iClientId, 4, cached, state, owner); sl@0: test(r == KErrNone); sl@0: test(state == 75); sl@0: test(owner == -1); sl@0: sl@0: r = lddChan.DeRegisterClient(Clients[0].iClientId); sl@0: test(r == KErrNone); sl@0: sl@0: Clients.Close(); //Close the array and release memory sl@0: depResArray.Close(); //Close the array and release memory sl@0: } sl@0: #endif sl@0: sl@0: //This function validates each of the resource manager API's sl@0: void TestRM::APIValidationTest() sl@0: { sl@0: test.Next(_L("\nStarting API validation Test....")); sl@0: RmTest.RegisterClient(); sl@0: r = lddChan.GetResourceControllerVersion(Clients[0].iClientId, iTestingExtendedVersion); sl@0: test(r == KErrNone); sl@0: if(!iTestingExtendedVersion) sl@0: test.Printf(_L("Testing Basic Version only....")); sl@0: else sl@0: test.Printf(_L("Testing basic & extended version....")); sl@0: RmTest.ValidateClient(5, EOwnerProcess); sl@0: iCurrentClientId = -1; sl@0: RmTest.GetNumResourcesInUseByClient(iCurrentClientId); sl@0: RmTest.GetInfoOnResourcesInUseByClient(iCurrentClientId, iMaxStaticResources); sl@0: iCurrentClientId = 0; sl@0: NegativeTesting = ETrue; sl@0: if(Resources[0].iName.Compare(*(const TDesC8*)&SpecialResName)) sl@0: { sl@0: test.Printf(_L("Test runs only on simulated PSL\n")); sl@0: RmTest.DeRegisterClient(Clients[0].iClientId); sl@0: return; sl@0: } sl@0: TBuf8<32> PowerController = _L8("PowerController"); sl@0: r = lddChan.GetClientId(Clients[0].iClientId, (TDesC8&)PowerController, iPowerControllerId); sl@0: test(r == KErrNone); sl@0: sl@0: RBuf8 info; sl@0: TUint c; sl@0: r = info.Create((iMaxStaticResources) * sizeof(SIdleResourceInfo)); sl@0: test(r == KErrNone); sl@0: SIdleResourceInfo* pI = (SIdleResourceInfo*)info.Ptr(); sl@0: for(c = 0; c < iMaxStaticResources; c++) sl@0: { sl@0: pI->iResourceId = Resources[c].iResourceId; sl@0: pI++; sl@0: } sl@0: pI = (SIdleResourceInfo*)info.Ptr(); sl@0: sl@0: r = lddChan.RegisterForIdleResourcesInfo(iPowerControllerId, iMaxStaticResources, (TAny*)info.Ptr()); sl@0: sl@0: test(r == KErrNone); sl@0: RmTest.GetClientName(iCurrentClientId); sl@0: RmTest.GetClientId(iCurrentClientId); sl@0: RmTest.GetResourceId(2); sl@0: RmTest.GetResourceInfo(19); sl@0: RmTest.GetNumResourcesInUseByClient(iCurrentClientId); sl@0: RmTest.GetInfoOnResourcesInUseByClient(iCurrentClientId, 3); sl@0: RmTest.GetNumClientsUsingResource(iCurrentClientId, (TUint)-1); sl@0: RmTest.GetNumClientsUsingResource(iCurrentClientId, 10); sl@0: RmTest.GetInfoOnClientsUsingResource((TUint)-1, 4); sl@0: RmTest.GetInfoOnClientsUsingResource(5, 3); sl@0: sl@0: for(c = 0; c < iMaxStaticResources; c++) sl@0: { sl@0: if(Resources[c].iSense == ECustom) sl@0: continue; sl@0: RmTest.GetResourceStateAsync(c, ETrue); sl@0: } sl@0: User::After(2000000); //Add delay to make sure that the asynchronous request is processed in controller thread sl@0: sl@0: for(c = 0; c < iMaxStaticResources; c++) sl@0: { sl@0: if(Resources[c].iSense == ECustom) sl@0: continue; sl@0: iCurrentClientId = c; sl@0: RmTest.RegisterClient(); sl@0: RmTest.AllocReserve(c); sl@0: RmTest.GetResourceStateAsync(c); sl@0: RmTest.RequestNotification(c); sl@0: RmTest.RequestNotificationCon(c); sl@0: } sl@0: sl@0: for(c=0; c< iMaxStaticResources; c++) sl@0: { sl@0: if(Resources[c].iSense == ECustom) sl@0: continue; sl@0: iCurrentClientId = c; sl@0: RmTest.ChangeResourceStateAsync(c); sl@0: RmTest.GetResourceStateAsync(c); sl@0: RmTest.GetResourceStateSync(c); sl@0: RmTest.ChangeResourceStateSync(c); sl@0: } sl@0: for(c = 0; c < iMaxStaticResources; c++) sl@0: { sl@0: if(Resources[c].iSense == ECustom) sl@0: continue; sl@0: iCurrentClientId = c; sl@0: RmTest.GetClientName(c); sl@0: RmTest.GetClientId(c); sl@0: RmTest.GetResourceId(c); sl@0: RmTest.GetResourceInfo(c); sl@0: RmTest.GetNumResourcesInUseByClient(c); sl@0: RmTest.GetInfoOnResourcesInUseByClient(c, Clients[c].iNumResources); sl@0: RmTest.GetNumClientsUsingResource(c, c); sl@0: RmTest.GetInfoOnClientsUsingResource(c, Resources[c].iNumClients); sl@0: RmTest.CancelNotification(c, ETrue); sl@0: RmTest.CancelNotification(c, EFalse); sl@0: } sl@0: sl@0: TInt clientCount = Clients.Count(); sl@0: for(c = clientCount-1; ((TInt)c) >=0; c--) sl@0: { sl@0: test.Printf(_L("DeRegister ClientId %d\n"), Clients[c].iClientId); sl@0: RmTest.DeRegisterClient(c); sl@0: } sl@0: Clients.Close(); sl@0: //Find any shared binary resource sl@0: for(c = 0; c < iMaxStaticResources; c++) sl@0: { sl@0: if(Resources[c].iSense == ECustom) sl@0: continue; sl@0: if((Resources[c].iUsage == EShared) && (Resources[c].iSense == ENegative)) sl@0: { sl@0: if(Resources[c].iType == 0x0) //Binary Resource sl@0: RmTest.SharedBinaryNegativeResourceTesting(c); sl@0: else sl@0: RmTest.SharedMultilevelNegativeResourceTesting(c); sl@0: } sl@0: else if((Resources[c].iUsage == EShared) && (Resources[c].iSense == EPositive)) sl@0: { sl@0: if(Resources[c].iType == 0x0) //Binary Resource sl@0: RmTest.SharedBinaryPositiveResourceTesting(c); sl@0: else sl@0: RmTest.SharedMultilevelPositiveResourceTesting(c); sl@0: } sl@0: } sl@0: sl@0: RmTest.CustomResourceTesting(CUSTOM_RESOURCE_NUMBER); sl@0: sl@0: //Testing of Deregistration of client level for binary resource sl@0: RmTest.RegisterClient(); sl@0: for(c = 0; c < iMaxStaticResources; c++) sl@0: { sl@0: if(Resources[c].iSense == ECustom) sl@0: continue; sl@0: RmTest.DeRegisterClientLevelFromResource(-1, c); sl@0: } sl@0: for(c = 0; c < iMaxStaticResources; c++) sl@0: { sl@0: iCurrentClientId = 0; sl@0: RmTest.ChangeResourceStateSync(c); sl@0: RmTest.DeRegisterClientLevelFromResource(0, c); sl@0: } sl@0: RmTest.RegisterClient(); sl@0: for(c = 0; c < iMaxStaticResources; c++) //Test valid only for shared resources. sl@0: { sl@0: if((Resources[c].iSense == ECustom) || (Resources[c].iUsage == ESingle)) sl@0: continue; sl@0: iCurrentClientId = 0; sl@0: RmTest.ChangeResourceStateSync(c); sl@0: iCurrentClientId = 1; sl@0: RmTest.ChangeResourceStateSync(c); sl@0: if(Resources[c].iCurrentClient == 0) sl@0: { sl@0: RmTest.DeRegisterClientLevelFromResource(0, c); sl@0: RmTest.DeRegisterClientLevelFromResource(1, c); sl@0: } sl@0: else sl@0: { sl@0: RmTest.DeRegisterClientLevelFromResource(1, c); sl@0: RmTest.DeRegisterClientLevelFromResource(0, c); sl@0: } sl@0: } sl@0: //Testing of Deregistration of client level for shared resource sl@0: for(c = 0; c < iMaxStaticResources; c++) sl@0: { sl@0: if((Resources[c].iSense == ECustom) || (!Resources[c].iUsage)) sl@0: continue; sl@0: RmTest.DeRegisterClientLevelFromResource(-1, c); sl@0: } sl@0: sl@0: RmTest.DeRegisterClient(1); sl@0: RmTest.DeRegisterClient(0); sl@0: info.Create(15 * sizeof(SIdleResourceInfo)); sl@0: r = lddChan.GetIdleResourcesInfo(15, (TAny*)(TDes8*)&info); sl@0: test(r == KErrNone); sl@0: pI = (SIdleResourceInfo*)info.Ptr(); sl@0: for(c = 0; c< 15; c++) sl@0: { sl@0: test(Resources[c].iCurrentClient == pI->iLevelOwnerId); sl@0: test(Resources[c].iCurrentLevel == pI->iCurrentLevel); sl@0: test(Resources[c].iResourceId == pI->iResourceId); sl@0: pI++; sl@0: } sl@0: info.Close(); sl@0: Clients.Close(); sl@0: #ifdef PRM_ENABLE_EXTENDED_VERSION sl@0: if(iTestingExtendedVersion) sl@0: { sl@0: TestStaticResourceWithDependency(); sl@0: TestDynamicResource(); sl@0: TestDynamicResourceDependency(); sl@0: } sl@0: #endif sl@0: Clients.Close(); sl@0: return; sl@0: } sl@0: sl@0: //---------------------------------------------------------------------------------------------- sl@0: //! @SYMTestCaseID KBASE-T_RESCONTROLCLI-0592 sl@0: //! @SYMTestType UT sl@0: //! @SYMPREQ PREQ1398 sl@0: //! @SYMTestCaseDesc This test case tests deregistration of client level functionality. sl@0: //! @SYMTestActions 0 Register client sl@0: //! 1 Change Resource State sl@0: //! 2 Deregister client level sl@0: //! 3 Deregister client sl@0: //! sl@0: //! @SYMTestExpectedResults 0 API should return with KErrNone, panics otherwise. sl@0: //! 1 API should return with KErrNone, panics otherwise. sl@0: //! 2 API should return with KErrNone, panics otherwise. sl@0: //! 3 API should return with KErrNone, panics otherwise. sl@0: //! @SYMTestPriority High sl@0: //! @SYMTestStatus Implemented sl@0: //---------------------------------------------------------------------------------------------- sl@0: void TestRM::DeRegisterClientLevelFromResource(TInt aClientId, TUint aResId) sl@0: { sl@0: TInt state; sl@0: TInt newState; sl@0: TInt levelOwnerId; sl@0: r = lddChan.GetResourceStateSync(Clients[0].iClientId, Resources[aResId].iResourceId, ETrue, newState, levelOwnerId); sl@0: test(r == KErrNone); sl@0: if((levelOwnerId != -1) && (levelOwnerId != (TInt)Clients[aClientId].iClientId)) sl@0: { sl@0: test.Printf(_L("Client Id does not match so not testing Deregistration of client level\n")); sl@0: return; sl@0: } sl@0: if(Resources[aResId].iUsage == ESingle) //Single user resource sl@0: { sl@0: if(levelOwnerId == -1) sl@0: { sl@0: TUint ClientId; sl@0: ClientName[6] = (TUint8)('0' + iMaxClientId+1); sl@0: r = lddChan.RegisterClient(ClientId, (const TDesC*)&ClientName); sl@0: test(r == KErrNone); sl@0: newState = Resources[aResId].iMaxLevel; sl@0: r = lddChan.ChangeResourceStateSync(ClientId, Resources[aResId].iResourceId, newState); sl@0: test(r == KErrNone); sl@0: r = lddChan.GetResourceStateSync(ClientId, Resources[aResId].iResourceId, ETrue, state, levelOwnerId); sl@0: test(r == KErrNone); sl@0: test(state == newState); sl@0: test(levelOwnerId == (TInt)ClientId); sl@0: r = lddChan.DeRegisterClientLevelFromResource(ClientId, Resources[aResId].iResourceId); sl@0: test(r == KErrNone); sl@0: r = lddChan.GetResourceStateSync(ClientId, Resources[aResId].iResourceId, ETrue, state, levelOwnerId); sl@0: test(r == KErrNone); sl@0: test(levelOwnerId == -1); sl@0: r = lddChan.DeRegisterClient(ClientId); sl@0: test(r == KErrNone); sl@0: return; sl@0: } sl@0: r = lddChan.DeRegisterClientLevelFromResource(Clients[aClientId].iClientId, Resources[aResId].iResourceId); sl@0: test(r == KErrNone); sl@0: r = lddChan.GetResourceStateSync(Clients[aClientId].iClientId, Resources[aResId].iResourceId, ETrue, state, levelOwnerId); sl@0: test(r == KErrNone); sl@0: test(levelOwnerId == -1); sl@0: //Update the local sl@0: Resources[aResId].iCurrentClient = -1; sl@0: Resources[aResId].iCurrentLevel = state; sl@0: Resources[aResId].iNumClients = 0; sl@0: delete Resources[aResId].iLevel; sl@0: Resources[aResId].iLevel = NULL; sl@0: return; sl@0: } sl@0: //Handle for Shared resources sl@0: if(levelOwnerId == -1) sl@0: { sl@0: TUint ClientId[2]; sl@0: ClientName[6] = (TUint8)('0' + iMaxClientId+1); sl@0: r = lddChan.RegisterClient(ClientId[0], (const TDesC*)&ClientName); sl@0: test(r == KErrNone); sl@0: ClientName[6] = (TUint8)('0' + iMaxClientId+2); sl@0: r = lddChan.RegisterClient(ClientId[1], (const TDesC*)&ClientName); sl@0: test(r == KErrNone); sl@0: newState = Resources[aResId].iMinLevel; sl@0: r = lddChan.ChangeResourceStateSync(ClientId[0], Resources[aResId].iResourceId, newState); sl@0: test(r == KErrNone); sl@0: r = lddChan.GetResourceStateSync(ClientId[0], Resources[aResId].iResourceId, ETrue, state, levelOwnerId); sl@0: test(r == KErrNone); sl@0: test(levelOwnerId == (TInt)ClientId[0]); sl@0: r = lddChan.ChangeResourceStateSync(ClientId[1], Resources[aResId].iResourceId, newState); sl@0: test(r == KErrNone); sl@0: r = lddChan.DeRegisterClientLevelFromResource(ClientId[0], Resources[aResId].iResourceId); sl@0: test(r == KErrNone); sl@0: r = lddChan.GetResourceStateSync(ClientId[0], Resources[aResId].iResourceId, ETrue, state, levelOwnerId); sl@0: test(r == KErrNone); sl@0: test(levelOwnerId == (TInt)ClientId[1]); sl@0: r = lddChan.DeRegisterClientLevelFromResource(ClientId[1], Resources[aResId].iResourceId); sl@0: test(r == KErrNone); sl@0: r = lddChan.GetResourceStateSync(ClientId[0], Resources[aResId].iResourceId, ETrue, state, levelOwnerId); sl@0: test(r == KErrNone); sl@0: test(levelOwnerId == -1); sl@0: r = lddChan.DeRegisterClient(ClientId[0]); sl@0: test(r == KErrNone); sl@0: r = lddChan.DeRegisterClient(ClientId[1]); sl@0: test(r == KErrNone); sl@0: return; sl@0: } sl@0: r = lddChan.DeRegisterClientLevelFromResource(Clients[aClientId].iClientId, Resources[aResId].iResourceId); sl@0: test(r == KErrNone); sl@0: r = lddChan.GetResourceStateSync(Clients[aClientId].iClientId, Resources[aResId].iResourceId, ETrue, state, levelOwnerId); sl@0: test(r == KErrNone); sl@0: test(levelOwnerId != (TInt)Clients[aClientId].iClientId); sl@0: if(Resources[aResId].iNumClients == 1) sl@0: { sl@0: Resources[aResId].iNumClients--; sl@0: Resources[aResId].iCurrentClient = -1; sl@0: r = lddChan.GetResourceStateSync(Clients[aClientId].iClientId, Resources[aResId].iResourceId, ETrue, state, levelOwnerId); sl@0: test(r == KErrNone); sl@0: Resources[aResId].iCurrentLevel = state; sl@0: delete Resources[aResId].iLevel; sl@0: Resources[aResId].iLevel = NULL; sl@0: } sl@0: else sl@0: { sl@0: Resources[aResId].iNumClients--; sl@0: SPowerResourceClientLevel *pCL = NULL; sl@0: TInt level = KMinTInt; sl@0: TInt clientId = 0; sl@0: for(SPowerResourceClientLevel* pL = Resources[aResId].iLevel; pL != NULL; pL = pL->iNextInList) sl@0: { sl@0: if(pL->iClientId == Clients[aClientId].iClientId) sl@0: { sl@0: pCL = pL; sl@0: continue; sl@0: } sl@0: if(level == KMinTInt) sl@0: { sl@0: level = pL->iLevel; sl@0: clientId = pL->iClientId; sl@0: continue; sl@0: } sl@0: if(((Resources[aResId].iSense == EPositive) && (pL->iLevel > level)) || ((Resources[aResId].iSense == ENegative) && (pL->iLevel < level))) sl@0: { sl@0: level = pL->iLevel; sl@0: clientId = pL->iClientId; sl@0: } sl@0: } sl@0: delete pCL; sl@0: Resources[aResId].iCurrentClient = clientId; sl@0: Resources[aResId].iCurrentLevel = level; sl@0: } sl@0: return; sl@0: } sl@0: sl@0: //---------------------------------------------------------------------------------------------- sl@0: //! @SYMTestCaseID KBASE-T_RESCONTROLCLI-0593 sl@0: //! @SYMTestType UT sl@0: //! @SYMPREQ PREQ1398 sl@0: //! @SYMTestCaseDesc This test case tests changing resource state of shared positive resource. sl@0: //! @SYMTestActions 0 Register client1 sl@0: //! 1 Register client2 sl@0: //! 2 Register client3 sl@0: //! 3 Register client4 sl@0: //! 4 Client1 change resource state. sl@0: //! 5 Client2 change resource state. sl@0: //! 6 Client3 change resource state. sl@0: //! 7 Client4 change resource state. sl@0: //! 8 Client1 change resource state. sl@0: //! 9 Client2 change resource state. sl@0: //! 10 Deregister client2 sl@0: //! 11 Client3 change resource state. sl@0: //! 12 Deregister client1 sl@0: //! 13 Deregister client3 sl@0: //! 14 Deregister client4 sl@0: //! sl@0: //! @SYMTestExpectedResults 0 Client registered sl@0: //! 1 Client registered sl@0: //! 2 Client registered sl@0: //! 3 Client registered sl@0: //! 4 Resource state changed sl@0: //! 5 Resource state changed sl@0: //! 6 Resource state changed sl@0: //! 7 Resource state changed sl@0: //! 8 Resource state changed sl@0: //! 9 Resource state changed sl@0: //! 10 Client2 deregistered sl@0: //! 11 Resource state changed sl@0: //! 12 Client1 deregistered sl@0: //! 13 Client3 deregistered sl@0: //! 14 Client4 deregistered sl@0: //! @SYMTestPriority High sl@0: //! @SYMTestStatus Implemented sl@0: //---------------------------------------------------------------------------------------------- sl@0: void TestRM::SharedBinaryPositiveResourceTesting(TUint aResId) sl@0: { sl@0: TInt newState, levelOwnerId; sl@0: TRequestStatus req; sl@0: TUint ClientId[5]; sl@0: sl@0: ClientName[6] = (TUint8)('0' + iMaxClientId+1); sl@0: r = lddChan.RegisterClient(ClientId[0], (const TDesC*)&ClientName); sl@0: test(r == KErrNone); sl@0: sl@0: r = lddChan.GetResourceStateSync(ClientId[0], Resources[aResId].iResourceId, ETrue, newState, levelOwnerId); sl@0: test(r == KErrNone); sl@0: if(levelOwnerId != -1) sl@0: { sl@0: test.Printf(_L("Not testing the shared resource as some other client is currently holding the resource\n")); sl@0: r = lddChan.DeRegisterClient(ClientId[0]); sl@0: test(r == KErrNone); sl@0: return; sl@0: } sl@0: sl@0: ClientName[6] = (TUint8)('0' + iMaxClientId +2); sl@0: r = lddChan.RegisterClient(ClientId[1], (const TDesC*)&ClientName); sl@0: test(r == KErrNone); sl@0: ClientName[6] = (TUint8)('0' + iMaxClientId +3); sl@0: r = lddChan.RegisterClient(ClientId[2], (const TDesC*)&ClientName); sl@0: test(r == KErrNone); sl@0: ClientName[6] = (TUint8)('0' + iMaxClientId +4); sl@0: r = lddChan.RegisterClient(ClientId[3], (const TDesC*)&ClientName); sl@0: test(r == KErrNone); sl@0: ClientName[6] = (TUint8)('0' + iMaxClientId +5); sl@0: r = lddChan.RegisterClient(ClientId[4], (const TDesC*)&ClientName); sl@0: test(r == KErrNone); sl@0: sl@0: newState = 1; sl@0: r = lddChan.ChangeResourceStateSync(ClientId[0], Resources[aResId].iResourceId, newState); sl@0: test(r == KErrNone); sl@0: r = lddChan.CheckNotifications(Resources[aResId].iResourceId, 0, 0); sl@0: test(r == KErrNone); sl@0: r = lddChan.RequestNotification(ClientId[1], Resources[aResId].iResourceId); sl@0: test(r == KErrNone); sl@0: r = lddChan.RequestNotification(ClientId[2], Resources[aResId].iResourceId); sl@0: test(r == KErrNone); sl@0: r = lddChan.RequestNotification(ClientId[3], Resources[aResId].iResourceId, 1, ETrue); sl@0: test(r == KErrNone); sl@0: r = lddChan.RequestNotification(ClientId[2], Resources[aResId].iResourceId, 0, EFalse); sl@0: test(r == KErrNone); sl@0: newState = !newState; //State 0 sl@0: r = lddChan.ChangeResourceStateSync(ClientId[0], Resources[aResId].iResourceId, newState); sl@0: test(r == KErrNone); sl@0: r = lddChan.CheckNotifications(Resources[aResId].iResourceId, 2, 1); sl@0: test(r == KErrNone); sl@0: newState = !newState; //State 1 sl@0: r = lddChan.ChangeResourceStateSync(ClientId[1], Resources[aResId].iResourceId, newState); sl@0: test(r == KErrNone); sl@0: r = lddChan.CheckNotifications(Resources[aResId].iResourceId, 2, 1); sl@0: test(r == KErrNone); sl@0: lddChan.ChangeResourceStateAsync(ClientId[2], Resources[aResId].iResourceId, newState, req); sl@0: User::WaitForRequest(req); //State 1 sl@0: test(req.Int() == KErrNone); sl@0: r = lddChan.CheckNotifications(Resources[aResId].iResourceId, 0, 0); sl@0: test(r == KErrNone); sl@0: newState = !newState; //State 0 sl@0: r = lddChan.ChangeResourceStateSync(ClientId[3], Resources[aResId].iResourceId, newState); sl@0: test(r == KErrNone); sl@0: r = lddChan.CheckNotifications(Resources[aResId].iResourceId, 0, 0); sl@0: test(r == KErrNone); sl@0: newState = !newState; //state 1 sl@0: r = lddChan.ChangeResourceStateSync(ClientId[0], Resources[aResId].iResourceId, newState); sl@0: test(r == KErrNone); sl@0: r = lddChan.CheckNotifications(Resources[aResId].iResourceId, 0, 0); sl@0: newState = !newState; //state 0 sl@0: r = lddChan.ChangeResourceStateSync(ClientId[1], Resources[aResId].iResourceId, newState); sl@0: test(r == KErrNone); sl@0: r = lddChan.CheckNotifications(Resources[aResId].iResourceId, 0,0); sl@0: test(r == KErrNone); sl@0: r = lddChan.DeRegisterClient(ClientId[1]); sl@0: test(r == KErrNone); sl@0: newState = 0; sl@0: r = lddChan.ChangeResourceStateSync(ClientId[2], Resources[aResId].iResourceId, newState); sl@0: test(r == KErrNone); sl@0: r = lddChan.CheckNotifications(Resources[aResId].iResourceId, 0,0); sl@0: test(r == KErrNone); sl@0: r = lddChan.ChangeResourceStateSync(ClientId[0], Resources[aResId].iResourceId, newState); sl@0: test(r == KErrNone); sl@0: r = lddChan.CheckNotifications(Resources[aResId].iResourceId, 1,1); sl@0: test(r == KErrNone); sl@0: r = lddChan.CancelNotification(ClientId[2], Resources[aResId].iResourceId, EFalse); sl@0: test(r == KErrCancel); sl@0: r = lddChan.CancelNotification(ClientId[3], Resources[aResId].iResourceId, ETrue); sl@0: test(r == KErrCancel); sl@0: newState = 1; sl@0: r = lddChan.ChangeResourceStateSync(ClientId[0], Resources[aResId].iResourceId, newState); sl@0: test(r == KErrNone); sl@0: r = lddChan.CheckNotifications(Resources[aResId].iResourceId, 0, 0); sl@0: test(r == KErrNone); sl@0: r = lddChan.CancelNotification(ClientId[2], Resources[aResId].iResourceId, ETrue); sl@0: test(r == KErrCancel); sl@0: newState = 1; sl@0: r = lddChan.ChangeResourceStateSync(ClientId[0], Resources[aResId].iResourceId, newState); sl@0: test(r == KErrNone); sl@0: r = lddChan.CheckNotifications(Resources[aResId].iResourceId, 0, 0); sl@0: test(r == KErrNone); sl@0: r = lddChan.DeRegisterClient(ClientId[0]); sl@0: test(r == KErrNone); sl@0: r = lddChan.DeRegisterClient(ClientId[2]); sl@0: test(r == KErrNone); sl@0: r = lddChan.DeRegisterClient(ClientId[3]); sl@0: test(r == KErrNone); sl@0: r = lddChan.GetResourceStateSync(ClientId[4], Resources[aResId].iResourceId, ETrue, newState, levelOwnerId); sl@0: test(r == KErrNone); sl@0: test(levelOwnerId == -1); sl@0: r = lddChan.DeRegisterClient(ClientId[4]); sl@0: test(r == KErrNone); sl@0: return; sl@0: } sl@0: sl@0: //---------------------------------------------------------------------------------------------- sl@0: //! @SYMTestCaseID KBASE-T_RESCONTROLCLI-0594 sl@0: //! @SYMTestType UT sl@0: //! @SYMPREQ PREQ1398 sl@0: //! @SYMTestCaseDesc This test case tests changing resource state of shared negative resource. sl@0: //! @SYMTestActions 0 Register client1 sl@0: //! 1 Register client2 sl@0: //! 2 Register client3 sl@0: //! 3 Register client4 sl@0: //! 4 Client1 change resource state. sl@0: //! 5 Client2 change resource state. sl@0: //! 6 Client3 change resource state. sl@0: //! 7 Client4 change resource state. sl@0: //! 8 Client1 change resource state. sl@0: //! 9 Client2 change resource state. sl@0: //! 10 Deregister client2 sl@0: //! 11 Client3 change resource state. sl@0: //! 12 Deregister client1 sl@0: //! 13 Deregister client3 sl@0: //! 14 Deregister client4 sl@0: //! sl@0: //! @SYMTestExpectedResults 0 Client registered sl@0: //! 1 Client registered sl@0: //! 2 Client registered sl@0: //! 3 Client registered sl@0: //! 4 Resource state changed sl@0: //! 5 Resource state changed sl@0: //! 6 Resource state changed sl@0: //! 7 Resource state changed sl@0: //! 8 Resource state changed sl@0: //! 9 Resource state changed sl@0: //! 10 Client2 deregistered sl@0: //! 11 Resource state changed sl@0: //! 12 Client1 deregistered sl@0: //! 13 Client3 deregistered sl@0: //! 14 Client4 deregistered sl@0: //! @SYMTestPriority High sl@0: //! @SYMTestStatus Implemented sl@0: //---------------------------------------------------------------------------------------------- sl@0: void TestRM::SharedBinaryNegativeResourceTesting(TUint aResId) sl@0: { sl@0: TInt newState; sl@0: TInt levelOwnerId; sl@0: TRequestStatus req; sl@0: TUint ClientId[5]; sl@0: sl@0: ClientName[6] = (TUint8)('0' + iMaxClientId+1); sl@0: r = lddChan.RegisterClient(ClientId[0], (const TDesC*)&ClientName); sl@0: test(r == KErrNone); sl@0: sl@0: r = lddChan.GetResourceStateSync(ClientId[0], Resources[aResId].iResourceId, ETrue, newState, levelOwnerId); sl@0: test(r == KErrNone); sl@0: if(levelOwnerId != -1) sl@0: { sl@0: test.Printf(_L("Not testing the shared resource as some other client is currently holding the resource\n")); sl@0: r = lddChan.DeRegisterClient(ClientId[0]); sl@0: test(r == KErrNone); sl@0: return; sl@0: } sl@0: sl@0: ClientName[6] = (TUint8)('0' + iMaxClientId +2); sl@0: r = lddChan.RegisterClient(ClientId[1], (const TDesC*)&ClientName); sl@0: test(r == KErrNone); sl@0: ClientName[6] = (TUint8)('0' + iMaxClientId +3); sl@0: r = lddChan.RegisterClient(ClientId[2], (const TDesC*)&ClientName); sl@0: test(r == KErrNone); sl@0: ClientName[6] = (TUint8)('0' + iMaxClientId +4); sl@0: r = lddChan.RegisterClient(ClientId[3], (const TDesC*)&ClientName); sl@0: test(r == KErrNone); sl@0: ClientName[6] = (TUint8)('0' + iMaxClientId +5); sl@0: r = lddChan.RegisterClient(ClientId[4], (const TDesC*)&ClientName); sl@0: test(r == KErrNone); sl@0: sl@0: newState = 0; sl@0: r = lddChan.ChangeResourceStateSync(ClientId[0], Resources[aResId].iResourceId, newState); sl@0: test(r == KErrNone); sl@0: r = lddChan.CheckNotifications(Resources[aResId].iResourceId, 0, 0); sl@0: test(r == KErrNone); sl@0: r = lddChan.RequestNotification(ClientId[1], Resources[aResId].iResourceId); sl@0: test(r == KErrNone); sl@0: r = lddChan.RequestNotification(ClientId[2], Resources[aResId].iResourceId); sl@0: test(r == KErrNone); sl@0: r = lddChan.RequestNotification(ClientId[3], Resources[aResId].iResourceId, 1, ETrue); sl@0: test(r == KErrNone); sl@0: r = lddChan.RequestNotification(ClientId[2], Resources[aResId].iResourceId, 0, EFalse); sl@0: test(r == KErrNone); sl@0: newState = !newState; //State 1 sl@0: r = lddChan.ChangeResourceStateSync(ClientId[0], Resources[aResId].iResourceId, newState); sl@0: test(r == KErrNone); sl@0: r = lddChan.CheckNotifications(Resources[aResId].iResourceId, 2, 1); sl@0: test(r == KErrNone); sl@0: newState = !newState; //State 0 sl@0: r = lddChan.ChangeResourceStateSync(ClientId[1], Resources[aResId].iResourceId, newState); sl@0: test(r == KErrNone); sl@0: r = lddChan.CheckNotifications(Resources[aResId].iResourceId, 2, 1); sl@0: test(r == KErrNone); sl@0: lddChan.ChangeResourceStateAsync(ClientId[2], Resources[aResId].iResourceId, newState, req); sl@0: User::WaitForRequest(req); //State 0 sl@0: test(req.Int() == KErrNone); sl@0: r = lddChan.CheckNotifications(Resources[aResId].iResourceId, 0, 0); sl@0: test(r == KErrNone); sl@0: newState = !newState; //State 1 sl@0: r = lddChan.ChangeResourceStateSync(ClientId[3], Resources[aResId].iResourceId, newState); sl@0: test(r == KErrNone); sl@0: r = lddChan.CheckNotifications(Resources[aResId].iResourceId, 0, 0); sl@0: test(r == KErrNone); sl@0: newState = !newState; //state 0 sl@0: r = lddChan.ChangeResourceStateSync(ClientId[0], Resources[aResId].iResourceId, newState); sl@0: test(r == KErrNone); sl@0: r = lddChan.CheckNotifications(Resources[aResId].iResourceId, 0, 0); sl@0: newState = !newState; //state 1 sl@0: r = lddChan.ChangeResourceStateSync(ClientId[1], Resources[aResId].iResourceId, newState); sl@0: test(r == KErrNone); sl@0: r = lddChan.CheckNotifications(Resources[aResId].iResourceId, 0,0); sl@0: test(r == KErrNone); sl@0: r = lddChan.DeRegisterClient(ClientId[1]); sl@0: test(r == KErrNone); sl@0: newState = 1; sl@0: r = lddChan.ChangeResourceStateSync(ClientId[2], Resources[aResId].iResourceId, newState); sl@0: test(r == KErrNone); sl@0: r = lddChan.CheckNotifications(Resources[aResId].iResourceId, 0,0); sl@0: test(r == KErrNone); sl@0: r = lddChan.ChangeResourceStateSync(ClientId[0], Resources[aResId].iResourceId, newState); sl@0: test(r == KErrNone); sl@0: r = lddChan.CheckNotifications(Resources[aResId].iResourceId, 1,1); sl@0: test(r == KErrNone); sl@0: r = lddChan.CancelNotification(ClientId[2], Resources[aResId].iResourceId, EFalse); sl@0: test(r == KErrCancel); sl@0: r = lddChan.CancelNotification(ClientId[3], Resources[aResId].iResourceId, ETrue); sl@0: test(r == KErrCancel); sl@0: newState = 1; sl@0: r = lddChan.ChangeResourceStateSync(ClientId[0], Resources[aResId].iResourceId, newState); sl@0: test(r == KErrNone); sl@0: r = lddChan.CheckNotifications(Resources[aResId].iResourceId, 0, 0); sl@0: test(r == KErrNone); sl@0: r = lddChan.CancelNotification(ClientId[2], Resources[aResId].iResourceId, ETrue); sl@0: test(r == KErrCancel); sl@0: newState = 1; sl@0: r = lddChan.ChangeResourceStateSync(ClientId[0], Resources[aResId].iResourceId, newState); sl@0: test(r == KErrNone); sl@0: r = lddChan.CheckNotifications(Resources[aResId].iResourceId, 0, 0); sl@0: test(r == KErrNone); sl@0: r = lddChan.DeRegisterClient(ClientId[0]); sl@0: test(r == KErrNone); sl@0: r = lddChan.DeRegisterClient(ClientId[2]); sl@0: test(r == KErrNone); sl@0: r = lddChan.DeRegisterClient(ClientId[3]); sl@0: test(r == KErrNone); sl@0: r = lddChan.GetResourceStateSync(ClientId[4], Resources[aResId].iResourceId, ETrue, newState, levelOwnerId); sl@0: test(r == KErrNone); sl@0: test(levelOwnerId == -1); sl@0: r = lddChan.DeRegisterClient(ClientId[4]); sl@0: test(r == KErrNone); sl@0: return; sl@0: } sl@0: sl@0: //Test cases to test the shared multilevel negative resources sl@0: void TestRM::SharedMultilevelNegativeResourceTesting(TUint aResId) sl@0: { sl@0: TInt newState; sl@0: TInt levelOwnerId; sl@0: TRequestStatus req; sl@0: TUint ClientId[2]; sl@0: sl@0: //Register 1st client sl@0: ClientName[6] = (TUint8)('0' + iMaxClientId+1); sl@0: r = lddChan.RegisterClient(ClientId[0], (const TDesC*)&ClientName); sl@0: test(r == KErrNone); sl@0: sl@0: r = lddChan.GetResourceStateSync(ClientId[0], Resources[aResId].iResourceId, ETrue, newState, levelOwnerId); sl@0: test(r == KErrNone); sl@0: if(levelOwnerId != -1) sl@0: { sl@0: test.Printf(_L("Not testing the shared resource as some other client is currently holding the resource\n")); sl@0: r = lddChan.DeRegisterClient(ClientId[0]); sl@0: test(r == KErrNone); sl@0: return; sl@0: } sl@0: sl@0: test.Printf(_L("Testing %d Shared Multilevel Negative Resource\n"), Resources[aResId].iResourceId); sl@0: sl@0: //Register 2nd client sl@0: ClientName[6] = (TUint8)('0' + iMaxClientId+2); sl@0: r = lddChan.RegisterClient(ClientId[1], (const TDesC*)&ClientName); sl@0: test(r == KErrNone); sl@0: sl@0: //Change the resource and ClientId[0] becomes the owner of the resource sl@0: newState = Resources[aResId].iMaxLevel + 10; sl@0: sl@0: r = lddChan.ChangeResourceStateSync(ClientId[0], Resources[aResId].iResourceId, newState); sl@0: test(r == KErrNone); sl@0: sl@0: TInt state; sl@0: r = lddChan.GetResourceStateSync(ClientId[0], Resources[aResId].iResourceId, ETrue, state, levelOwnerId); sl@0: test(r == KErrNone); sl@0: test(state == newState); sl@0: test(levelOwnerId = (TInt)ClientId[0]); sl@0: sl@0: //Second client(clientId[1]) trying to change the resource, but still sl@0: newState = state +5; sl@0: lddChan.ChangeResourceStateAsync(ClientId[1], Resources[aResId].iResourceId, newState, req); sl@0: User::WaitForRequest(req); sl@0: test(req.Int() == KErrNone); sl@0: sl@0: lddChan.GetResourceStateAsync(ClientId[0], Resources[aResId].iResourceId, EFalse, req, newState, levelOwnerId); sl@0: User::WaitForRequest(req); sl@0: test(req.Int() == KErrNone); sl@0: test(state = newState); sl@0: test(levelOwnerId == (TInt)ClientId[0]); sl@0: sl@0: newState = state + 10; sl@0: r = lddChan.ChangeResourceStateSync(ClientId[0], Resources[aResId].iResourceId, newState); sl@0: test(r == KErrNone); sl@0: sl@0: r = lddChan.GetResourceStateSync(ClientId[0], Resources[aResId].iResourceId, EFalse, state, levelOwnerId); sl@0: test(r == KErrNone); sl@0: newState = Resources[aResId].iMaxLevel + 15; sl@0: test(state == newState); sl@0: test(levelOwnerId == (TInt)ClientId[1]); sl@0: sl@0: r = lddChan.DeRegisterClientLevelFromResource(ClientId[1], Resources[aResId].iResourceId); sl@0: test(r == KErrNone); sl@0: sl@0: state = Resources[aResId].iMaxLevel + 20; sl@0: lddChan.GetResourceStateAsync(ClientId[1], Resources[aResId].iResourceId, ETrue, req, newState, levelOwnerId); sl@0: User::WaitForRequest(req); sl@0: test(req.Int() == KErrNone); sl@0: test(state == newState); sl@0: test(levelOwnerId == (TInt)ClientId[0]); sl@0: sl@0: newState = Resources[aResId].iMaxLevel + 10; sl@0: lddChan.ChangeResourceStateAsync(ClientId[1], Resources[aResId].iResourceId, newState, req); sl@0: User::WaitForRequest(req); sl@0: test(req.Int() == KErrNone); sl@0: sl@0: sl@0: lddChan.GetResourceStateAsync(ClientId[0], Resources[aResId].iResourceId, EFalse, req, state, levelOwnerId); sl@0: User::WaitForRequest(req); sl@0: test(req.Int() == KErrNone); sl@0: test(state == newState); sl@0: test(levelOwnerId == (TInt)ClientId[1]); sl@0: sl@0: r = lddChan.DeRegisterClient(ClientId[1]); sl@0: test(r == KErrNone); sl@0: sl@0: r = lddChan.DeRegisterClientLevelFromResource(ClientId[0], Resources[aResId].iResourceId); sl@0: test(r == KErrNone); sl@0: sl@0: r = lddChan.GetResourceStateSync(ClientId[0], Resources[aResId].iResourceId, EFalse, state, levelOwnerId); sl@0: test(r == KErrNone); sl@0: test(state == Resources[aResId].iDefaultLevel); sl@0: test(levelOwnerId == -1); sl@0: sl@0: r = lddChan.DeRegisterClient(ClientId[0]); sl@0: test(r == KErrNone); sl@0: sl@0: return; sl@0: } sl@0: sl@0: //Test cases to test the shared multilevel positive resources sl@0: void TestRM::SharedMultilevelPositiveResourceTesting(TUint aResId) sl@0: { sl@0: TInt newState; sl@0: TInt levelOwnerId; sl@0: TRequestStatus req; sl@0: TUint ClientId[2]; sl@0: sl@0: //Register 1st client sl@0: ClientName[6] = (TUint8)('0' + iMaxClientId+1); sl@0: r = lddChan.RegisterClient(ClientId[0], (const TDesC*)&ClientName); sl@0: test(r == KErrNone); sl@0: sl@0: r = lddChan.GetResourceStateSync(ClientId[0], Resources[aResId].iResourceId, ETrue, newState, levelOwnerId); sl@0: test(r == KErrNone); sl@0: if(levelOwnerId != -1) sl@0: { sl@0: test.Printf(_L("Not testing the shared resource as some other client is currently holding the resource\n")); sl@0: r = lddChan.DeRegisterClient(ClientId[0]); sl@0: test(r == KErrNone); sl@0: return; sl@0: } sl@0: sl@0: test.Printf(_L("Testing %d Shared Multilevel positive Resource\n"), Resources[aResId].iResourceId); sl@0: sl@0: //Register 2nd client sl@0: ClientName[6] = (TUint8)('0' + iMaxClientId+2); sl@0: r = lddChan.RegisterClient(ClientId[1], (const TDesC*)&ClientName); sl@0: test(r == KErrNone); sl@0: sl@0: //Change the resource and ClientId[0] becomes the owner of the resource sl@0: newState = Resources[aResId].iMinLevel + 20; sl@0: sl@0: r = lddChan.ChangeResourceStateSync(ClientId[0], Resources[aResId].iResourceId, newState); sl@0: test(r == KErrNone); sl@0: sl@0: TInt state; sl@0: r = lddChan.GetResourceStateSync(ClientId[0], Resources[aResId].iResourceId, ETrue, state, levelOwnerId); sl@0: test(r == KErrNone); sl@0: test(state == newState); sl@0: test(levelOwnerId = (TInt)ClientId[0]); sl@0: sl@0: //Second client(clientId[1]) trying to change the resource, but still sl@0: newState = Resources[aResId].iMinLevel +10; sl@0: lddChan.ChangeResourceStateAsync(ClientId[1], Resources[aResId].iResourceId, newState, req); sl@0: User::WaitForRequest(req); sl@0: test(req.Int() == KErrNone); sl@0: sl@0: lddChan.GetResourceStateAsync(ClientId[0], Resources[aResId].iResourceId, EFalse, req, newState, levelOwnerId); sl@0: User::WaitForRequest(req); sl@0: test(req.Int() == KErrNone); sl@0: test(state = newState); sl@0: test(levelOwnerId == (TInt)ClientId[0]); sl@0: sl@0: newState = Resources[aResId].iMinLevel + 5; sl@0: r = lddChan.ChangeResourceStateSync(ClientId[0], Resources[aResId].iResourceId, newState); sl@0: test(r == KErrNone); sl@0: sl@0: r = lddChan.GetResourceStateSync(ClientId[0], Resources[aResId].iResourceId, EFalse, state, levelOwnerId); sl@0: test(r == KErrNone); sl@0: test(state == Resources[aResId].iMinLevel+10); sl@0: test(levelOwnerId == (TInt)ClientId[1]); sl@0: sl@0: r = lddChan.DeRegisterClientLevelFromResource(ClientId[1], Resources[aResId].iResourceId); sl@0: test(r == KErrNone); sl@0: sl@0: newState = Resources[aResId].iMinLevel + 5; sl@0: lddChan.GetResourceStateAsync(ClientId[1], Resources[aResId].iResourceId, ETrue, req, state, levelOwnerId); sl@0: User::WaitForRequest(req); sl@0: test(req.Int() == KErrNone); sl@0: test(state == newState); sl@0: test(levelOwnerId == (TInt)ClientId[0]); sl@0: sl@0: newState = Resources[aResId].iMinLevel + 10; sl@0: lddChan.ChangeResourceStateAsync(ClientId[1], Resources[aResId].iResourceId, newState, req); sl@0: User::WaitForRequest(req); sl@0: test(req.Int() == KErrNone); sl@0: sl@0: sl@0: lddChan.GetResourceStateAsync(ClientId[0], Resources[aResId].iResourceId, EFalse, req, state, levelOwnerId); sl@0: User::WaitForRequest(req); sl@0: test(req.Int() == KErrNone); sl@0: test(state == newState); sl@0: test(levelOwnerId == (TInt)ClientId[1]); sl@0: sl@0: r = lddChan.DeRegisterClient(ClientId[1]); sl@0: test(r == KErrNone); sl@0: sl@0: r = lddChan.DeRegisterClientLevelFromResource(ClientId[0], Resources[aResId].iResourceId); sl@0: test(r == KErrNone); sl@0: sl@0: r = lddChan.GetResourceStateSync(ClientId[0], Resources[aResId].iResourceId, EFalse, state, levelOwnerId); sl@0: test(r == KErrNone); sl@0: test(state == Resources[aResId].iDefaultLevel); sl@0: test(levelOwnerId == -1); sl@0: sl@0: r = lddChan.DeRegisterClient(ClientId[0]); sl@0: test(r == KErrNone); sl@0: sl@0: return; sl@0: } sl@0: sl@0: //Custom resource testing. This testing is done only with simulated resources. sl@0: //Testing of shared binary positive resource. sl@0: //---------------------------------------------------------------------------------------------- sl@0: //! @SYMTestCaseID KBASE-T_RESCONTROLCLI-0593 sl@0: //! @SYMTestType UT sl@0: //! @SYMPREQ PREQ1398 sl@0: //! @SYMTestCaseDesc This test case tests changing resource state of shared positive resource. sl@0: //! @SYMTestActions 0 Register client1 sl@0: //! 1 Register client2 sl@0: //! 2 Register client3 sl@0: //! 3 Register client4 sl@0: //! 4 Client1 change resource state. sl@0: //! 5 Client2 change resource state. sl@0: //! 6 Client3 get resource state. sl@0: //! 7 Client4 get resource state. sl@0: //! 8 Client1 change resource state. sl@0: //! 9 Client2 get resource state. sl@0: //! 10 Deregister client2 sl@0: //! 11 Deregister client1 sl@0: //! 12 Deregister client3 sl@0: //! 13 Deregister client4 sl@0: //! sl@0: //! @SYMTestExpectedResults 0 Client registered sl@0: //! 1 Client registered sl@0: //! 2 Client registered sl@0: //! 3 Client registered sl@0: //! 4 Resource state changed sl@0: //! 5 Resource state changed sl@0: //! 6 Resource state read and compared for correctness sl@0: //! 7 Resource state read and compared for correctness sl@0: //! 8 Resource state changed sl@0: //! 9 Resource state read and compared for correctness sl@0: //! 10 Client2 deregistered sl@0: //! 11 Client1 deregistered sl@0: //! 12 Client3 deregistered sl@0: //! 13 Client4 deregistered sl@0: //! @SYMTestPriority High sl@0: //! @SYMTestStatus Implemented sl@0: //---------------------------------------------------------------------------------------------- sl@0: void TestRM::CustomResourceTesting(TUint aResId) sl@0: { sl@0: test.Printf(_L("Testing custom function\n")); sl@0: TInt r = KErrNone; sl@0: TRequestStatus req; sl@0: TInt state; sl@0: TInt newState; sl@0: TInt levelOwnerId; sl@0: TUint ClientId[4]; sl@0: ClientName[6] = (TUint8)('0' + iMaxClientId +1); sl@0: r = lddChan.RegisterClient(ClientId[0], (const TDesC*)&ClientName); sl@0: test(r == KErrNone); sl@0: ClientName[6] = (TUint8)('0' + iMaxClientId +2); sl@0: r = lddChan.RegisterClient(ClientId[1], (const TDesC*)&ClientName); sl@0: test(r == KErrNone); sl@0: ClientName[6] = (TUint8)('0' + iMaxClientId +3); sl@0: r = lddChan.RegisterClient(ClientId[2], (const TDesC*)&ClientName); sl@0: test(r == KErrNone); sl@0: ClientName[6] = (TUint8)('0' + iMaxClientId +4); sl@0: r = lddChan.RegisterClient(ClientId[3], (const TDesC*)&ClientName); sl@0: test(r == KErrNone); sl@0: r = lddChan.RequestNotification(ClientId[0], Resources[aResId].iResourceId); sl@0: test(r == KErrNone); sl@0: r = lddChan.RequestNotification(ClientId[1], Resources[aResId].iResourceId); sl@0: test(r == KErrNone); sl@0: newState = 1; sl@0: state = 1; sl@0: lddChan.ChangeResourceStateAsync(ClientId[2], Resources[aResId].iResourceId, state, req); sl@0: User::WaitForRequest(req); //State 1 sl@0: test(req.Int() == KErrNone); sl@0: test(state == newState); sl@0: test(r == KErrNone); sl@0: r = lddChan.CheckNotifications(Resources[aResId].iResourceId, 2, 0); sl@0: test(r == KErrNone); sl@0: state = 0; sl@0: lddChan.ChangeResourceStateAsync(ClientId[1], Resources[aResId].iResourceId, state, req); sl@0: User::WaitForRequest(req); sl@0: test(req.Int() == KErrNone); sl@0: test(state == newState); sl@0: r = lddChan.GetResourceStateSync(ClientId[0], Resources[aResId].iResourceId, EFalse, state, levelOwnerId); sl@0: test(r == KErrNone); sl@0: test(state == 1); sl@0: lddChan.ChangeResourceStateAsync(ClientId[0], Resources[aResId].iResourceId, state, req); sl@0: User::WaitForRequest(req); sl@0: test(req.Int() == KErrNone); sl@0: test(state == newState); sl@0: r = lddChan.GetResourceStateSync(ClientId[0], Resources[aResId].iResourceId, ETrue, state, levelOwnerId); sl@0: test(r == KErrNone); sl@0: test((TUint)levelOwnerId == ClientId[2]); sl@0: r = lddChan.ChangeResourceStateSync(ClientId[2], Resources[aResId].iResourceId, 0); sl@0: test(r == KErrNone); sl@0: r = lddChan.GetResourceStateSync(ClientId[0], Resources[aResId].iResourceId, EFalse, state, levelOwnerId); sl@0: test(r == KErrNone); sl@0: test(state == 1); sl@0: test((TUint)levelOwnerId == ClientId[0]); sl@0: r = lddChan.DeRegisterClient(ClientId[0]); sl@0: test(r == KErrNone); sl@0: r = lddChan.DeRegisterClientLevelFromResource(ClientId[1], Resources[aResId].iResourceId); sl@0: test(r == KErrNone); sl@0: r= lddChan.DeRegisterClient(ClientId[2]); sl@0: test(r == KErrNone); sl@0: r = lddChan.GetResourceStateSync(ClientId[3], Resources[aResId].iResourceId, ETrue, state, levelOwnerId); sl@0: test(r == KErrNone); sl@0: test(levelOwnerId == -1); sl@0: r = lddChan.DeRegisterClient(ClientId[3]); sl@0: test(r == KErrNone); sl@0: r = lddChan.DeRegisterClient(ClientId[1]); sl@0: test(r == KErrNone); sl@0: return; sl@0: } sl@0: sl@0: //Resource manager operations are chosen randomly and tested for correctness. This is done only in sl@0: //simulated resources. Currently this runs for 500 iteration. sl@0: //NOTE: Increasing the iteration to more than 500 may fail due to insufficient internal buffers. sl@0: void TestRM::RegressionTest() sl@0: { sl@0: TUint operation = 0; sl@0: TUint resourceId; sl@0: TUint count; sl@0: NegativeTesting = 0; sl@0: iMaxClientId = 0; sl@0: iMaxStaticResources = 0; sl@0: iMaxStaticDependentResources = 0; sl@0: iMaxClients = 0; sl@0: RmTest.RegisterClient(); sl@0: iCurrentClientId = -1; sl@0: r = lddChan.GetResourceControllerVersion(Clients[0].iClientId, iTestingExtendedVersion); sl@0: if(r != KErrNone) sl@0: test.Printf(_L("Return value of GetResourceControllerVersion %d\n"), r); sl@0: test(r == KErrNone); sl@0: if(!iTestingExtendedVersion) sl@0: test.Printf(_L("Testing Basic Version only....")); sl@0: else sl@0: test.Printf(_L("Testing basic & extended version....")); sl@0: RmTest.GetNumResourcesInUseByClient(iCurrentClientId); sl@0: RmTest.GetInfoOnResourcesInUseByClient(iCurrentClientId, iMaxStaticResources); sl@0: if(!(Resources[0].iName.Compare(*(const TDesC8*)&SpecialResName))) sl@0: { sl@0: TBuf8<32> PowerController = _L8("PowerController"); sl@0: r = lddChan.GetClientId(Clients[0].iClientId, (TDesC8&)PowerController, iPowerControllerId); sl@0: test(r == KErrNone); sl@0: } sl@0: else sl@0: { sl@0: test.Printf(_L("Regression testing is run only on simulator")); sl@0: return; sl@0: } sl@0: sl@0: for(count = 0; count < 500; count++) sl@0: { sl@0: operation = Math::Random() % EOperationEnd; sl@0: iCurrentClientId = Math::Random() % iMaxClients; sl@0: resourceId = Math::Random() % iMaxStaticResources; sl@0: if(operation != ERegisterClient) sl@0: { sl@0: if(Clients[iCurrentClientId].iClientId == 0) //Not a valid client sl@0: continue; sl@0: } sl@0: if(Resources[resourceId].iSense == ECustom) sl@0: continue; sl@0: test.Printf(_L("\nOperation = %d, ClientId = %d, ResourceId = %d\n"), operation, iCurrentClientId, resourceId); sl@0: switch (operation) sl@0: { sl@0: case ERegisterClient: sl@0: RmTest.RegisterClient(); sl@0: break; sl@0: case EGetClientName: sl@0: RmTest.GetClientName(iCurrentClientId); sl@0: break; sl@0: case EGetAllClientName: sl@0: RmTest.GetClientName(0); sl@0: break; sl@0: case EGetClientId: sl@0: RmTest.GetClientId(iCurrentClientId); sl@0: break; sl@0: case EGetResourceId: sl@0: RmTest.GetResourceId(resourceId); sl@0: break; sl@0: case EGetResourceInfo: sl@0: RmTest.GetResourceInfo(resourceId); sl@0: break; sl@0: case EGetNumReosourceInUseByClient: sl@0: RmTest.GetNumResourcesInUseByClient(iCurrentClientId); sl@0: break; sl@0: case EGetInfoOnResourceInUseByClient: sl@0: test.Printf(_L("NumResources = %d\n"), Clients[iCurrentClientId].iNumResources); sl@0: RmTest.GetInfoOnResourcesInUseByClient(iCurrentClientId, Clients[iCurrentClientId].iNumResources); sl@0: break; sl@0: case EGetNumClientsUsingResource: sl@0: if(resourceId == 0) sl@0: { sl@0: RmTest.GetNumClientsUsingResource(iCurrentClientId, (TUint)-1); sl@0: } sl@0: else sl@0: { sl@0: RmTest.GetNumClientsUsingResource(iCurrentClientId, resourceId); sl@0: } sl@0: break; sl@0: case EGetInfoOnClientsUsingResource: sl@0: if(resourceId == 0) sl@0: RmTest.GetInfoOnClientsUsingResource((TUint)-1, iMaxClients+1); sl@0: else sl@0: { sl@0: test.Printf(_L("NumResources = %d\n"), Resources[resourceId].iNumClients); sl@0: RmTest.GetInfoOnClientsUsingResource(resourceId, Resources[resourceId].iNumClients); sl@0: } sl@0: break; sl@0: case EChangeResourceStateSync: sl@0: RmTest.ChangeResourceStateSync(resourceId); sl@0: break; sl@0: case EChangeResourceStateAsync: sl@0: RmTest.ChangeResourceStateAsync(resourceId); sl@0: break; sl@0: case EGetResourceStateSync: sl@0: RmTest.GetResourceStateSync(resourceId); sl@0: break; sl@0: case EGetResourceStateAsync: sl@0: RmTest.GetResourceStateAsync(resourceId); sl@0: break; sl@0: case ERequestNotificationCond: sl@0: RmTest.RequestNotificationCon(resourceId); sl@0: break; sl@0: case ERequestNotificationUnCond: sl@0: RmTest.RequestNotification(resourceId); sl@0: break; sl@0: case ECancelNotificationCond: sl@0: RmTest.CancelNotification(resourceId, ETrue); sl@0: break; sl@0: case ECancelNotificationUnCond: sl@0: RmTest.CancelNotification(resourceId, EFalse); sl@0: break; sl@0: } sl@0: } sl@0: //CleanUp sl@0: test.Printf(_L("Cleanup of all Clients\n")); sl@0: TInt clientCount = Clients.Count(); sl@0: for(count = clientCount-1; ((TInt)count) >=0; count--) sl@0: { sl@0: if(Clients[count].iClientId == 0) sl@0: continue; sl@0: test.Printf(_L("ClientId deregistration of %d\n"), Clients[count].iClientId); sl@0: RmTest.DeRegisterClient(count); sl@0: } sl@0: Clients.Close(); sl@0: } sl@0: sl@0: GLDEF_C TInt E32Main() sl@0: { sl@0: test.Title(); sl@0: test.Start(_L("Testing Resource Manager...\n")); sl@0: test.Next(_L("Load Physical device")); sl@0: #ifndef PRM_ENABLE_EXTENDED_VERSION sl@0: r = User::LoadPhysicalDevice(KPddFileName); sl@0: test(r==KErrNone || r==KErrAlreadyExists); sl@0: test.Next(_L("Load Logical Device")); sl@0: r=User::LoadLogicalDevice(KLddFileName); sl@0: test(r==KErrNone || r==KErrAlreadyExists); sl@0: __KHEAP_MARK; //Heap testing is done only for basic version sl@0: #else sl@0: r = User::LoadPhysicalDevice(KExtPddFileName); sl@0: test(r==KErrNone || r==KErrAlreadyExists); sl@0: test.Next(_L("Load Logical Device")); sl@0: r=User::LoadLogicalDevice(KExtLddFileName); sl@0: test(r==KErrNone || r==KErrAlreadyExists); sl@0: #endif sl@0: r = lddChan.Open(); sl@0: test(r==KErrNone || r==KErrAlreadyExists); sl@0: //Check whether the notifications recieved as a result of postboot level setting is as expected. sl@0: r = lddChan.CheckPostBootLevelNotifications(); sl@0: test(r == KErrNone); sl@0: TBool regressionTesting = EFalse; sl@0: //Parse the command line arguments. sl@0: TBuf<0x50> cmd; sl@0: User::CommandLine(cmd); sl@0: TLex lex(cmd); sl@0: lex.SkipSpace(); sl@0: if(lex.Get() == '-') sl@0: { sl@0: TChar letter = lex.Get(); sl@0: if((letter == 'R') || (letter == 'r')) sl@0: regressionTesting = ETrue; sl@0: } sl@0: if(regressionTesting) sl@0: RmTest.RegressionTest(); sl@0: else sl@0: RmTest.APIValidationTest(); sl@0: test.Printf(_L("Closing the channel\n")); sl@0: lddChan.Close(); sl@0: test.Printf(_L("Freeing logical device\n")); sl@0: #ifndef PRM_ENABLE_EXTENDED_VERSION sl@0: __KHEAP_MARKEND; sl@0: r = User::FreeLogicalDevice(KLddFileName); sl@0: test(r==KErrNone); sl@0: r = User::FreePhysicalDevice(KPddFileName); sl@0: test(r==KErrNone); sl@0: #else sl@0: r = User::FreeLogicalDevice(KExtLddFileName); sl@0: test(r==KErrNone); sl@0: r = User::FreePhysicalDevice(KExtPddFileName); sl@0: test(r==KErrNone); sl@0: #endif sl@0: User::After(100000); sl@0: test.End(); sl@0: test.Close(); sl@0: return KErrNone; sl@0: } sl@0: