25 #include <e32hal.h> |
25 #include <e32hal.h> |
26 #include <e32math.h> |
26 #include <e32math.h> |
27 #include <e32def.h> |
27 #include <e32def.h> |
28 #include <e32def_private.h> |
28 #include <e32def_private.h> |
29 #include "d_rescontrolcli.h" |
29 #include "d_rescontrolcli.h" |
30 |
|
31 #include <drivers/resourcecontrol_clientsettings.h> |
|
32 #include <drivers/resourcecontrol_settings.h> |
|
33 |
30 |
34 #define MAX_STATIC_RESOURCE_NUM 24 //Maximum number of static resources in simulated PSL |
31 #define MAX_STATIC_RESOURCE_NUM 24 //Maximum number of static resources in simulated PSL |
35 #define MAX_STATIC_DEPENDENCY_RESOURCE_NUM 7 //Maximum number of static dependency resources in simulated PSL |
32 #define MAX_STATIC_DEPENDENCY_RESOURCE_NUM 7 //Maximum number of static dependency resources in simulated PSL |
36 #define DEPENDENCY_RESOURCE_BIT_MASK 0x00010000 |
33 #define DEPENDENCY_RESOURCE_BIT_MASK 0x00010000 |
37 #define DYNAMIC_RESOURCE_BIT_MASK 0x00020000 |
34 #define DYNAMIC_RESOURCE_BIT_MASK 0x00020000 |
4238 RmTest.DeRegisterClient(count); |
4235 RmTest.DeRegisterClient(count); |
4239 } |
4236 } |
4240 Clients.Close(); |
4237 Clients.Close(); |
4241 } |
4238 } |
4242 |
4239 |
4243 void TestClientSettings(TInt aClientToken, TUint aExpectedBase) |
|
4244 { |
|
4245 TUint clientBase = ElementId_ClientSettingBase(aClientToken); |
|
4246 test(clientBase == aExpectedBase); |
|
4247 |
|
4248 HCR::TElementId Id; |
|
4249 |
|
4250 Id = ElementId_ClientName(aClientToken); |
|
4251 test(Id == aExpectedBase); |
|
4252 |
|
4253 Id = ElementId_ClientPropertyFlag(aClientToken); |
|
4254 test(Id == (aExpectedBase + 1)); |
|
4255 |
|
4256 Id = ElementId_ClientPreallocation(aClientToken); |
|
4257 test(Id == (aExpectedBase + 2)); |
|
4258 |
|
4259 TInt firstResource = 0; |
|
4260 Id = ElementId_ClientStaticResource(aClientToken, firstResource); |
|
4261 test(Id == (aExpectedBase + 3)); |
|
4262 |
|
4263 TInt thirdResource = 2; |
|
4264 Id = ElementId_ClientStaticResource(aClientToken, thirdResource); |
|
4265 test(Id == (aExpectedBase + 5)); |
|
4266 } |
|
4267 |
|
4268 void TestDynamicResourceSettings(TInt aDynamicResource, TUint aExpectedBase) |
|
4269 { |
|
4270 TUint dynamicResourceBase = ElementId_DynamicResourceBase(aDynamicResource); |
|
4271 test(dynamicResourceBase == aExpectedBase); |
|
4272 |
|
4273 HCR::TElementId Id; |
|
4274 |
|
4275 Id = ElementId_DynamicResourceName(aDynamicResource); |
|
4276 test(Id == aExpectedBase); |
|
4277 |
|
4278 Id = ElementId_DynamicResourcePropertyFlag(aDynamicResource); |
|
4279 test(Id == (aExpectedBase + 1)); |
|
4280 |
|
4281 Id = ElementId_DynamicResourceMaxLevel(aDynamicResource); |
|
4282 test(Id == (aExpectedBase + 2)); |
|
4283 |
|
4284 Id = ElementId_DynamicResourceMinLevel(aDynamicResource); |
|
4285 test(Id == (aExpectedBase + 3)); |
|
4286 |
|
4287 Id = ElementId_DynamicResourceDefaultLevel(aDynamicResource); |
|
4288 test(Id == (aExpectedBase + 4)); |
|
4289 |
|
4290 Id = ElementId_DynamicResourceDependencyMask1(aDynamicResource); |
|
4291 test(Id == (aExpectedBase + 5)); |
|
4292 |
|
4293 Id = ElementId_DynamicResourceDependencyMask2(aDynamicResource); |
|
4294 test(Id == (aExpectedBase + 6)); |
|
4295 |
|
4296 Id = ElementId_DynamicResourceDependencyMask3(aDynamicResource); |
|
4297 test(Id == (aExpectedBase + 7)); |
|
4298 } |
|
4299 |
|
4300 void TestClientHCRSettingMacros() |
|
4301 { |
|
4302 TInt clientToken = 2; // Random token number |
|
4303 TUint expectedBase = 80; // refer resourcecontrol_clientsettings.h for calculations |
|
4304 TestClientSettings(clientToken, expectedBase); |
|
4305 |
|
4306 clientToken = 0; |
|
4307 expectedBase = 16; // refer resourcecontrol_clientsettings.h for calculations |
|
4308 TestClientSettings(clientToken, expectedBase); |
|
4309 |
|
4310 // Dynamic Resource settings |
|
4311 TUint dynamicResource = 3; // Random token number |
|
4312 expectedBase = 131168; // refer resourcecontrol_clientsettings.h for calculations |
|
4313 TestDynamicResourceSettings(dynamicResource, expectedBase); |
|
4314 |
|
4315 test.Printf(_L("Testing HCR client setting Macro's for Resource Manager successful \n")); |
|
4316 } |
|
4317 |
|
4318 GLDEF_C TInt E32Main() |
4240 GLDEF_C TInt E32Main() |
4319 { |
4241 { |
4320 test.Title(); |
4242 test.Title(); |
4321 test.Start(_L("Testing Resource Manager...\n")); |
4243 test.Start(_L("Testing Resource Manager...\n")); |
4322 test.Printf(_L("Testing HCR client setting Macro's for Resource Manager \n")); |
|
4323 TestClientHCRSettingMacros(); |
|
4324 test.Next(_L("Load Physical device")); |
4244 test.Next(_L("Load Physical device")); |
4325 #ifndef PRM_ENABLE_EXTENDED_VERSION |
4245 #ifndef PRM_ENABLE_EXTENDED_VERSION |
4326 r = User::LoadPhysicalDevice(KPddFileName); |
4246 r = User::LoadPhysicalDevice(KPddFileName); |
4327 test(r==KErrNone || r==KErrAlreadyExists); |
4247 test(r==KErrNone || r==KErrAlreadyExists); |
4328 test.Next(_L("Load Logical Device")); |
4248 test.Next(_L("Load Logical Device")); |
4334 test(r==KErrNone || r==KErrAlreadyExists); |
4254 test(r==KErrNone || r==KErrAlreadyExists); |
4335 test.Next(_L("Load Logical Device")); |
4255 test.Next(_L("Load Logical Device")); |
4336 r=User::LoadLogicalDevice(KExtLddFileName); |
4256 r=User::LoadLogicalDevice(KExtLddFileName); |
4337 test(r==KErrNone || r==KErrAlreadyExists); |
4257 test(r==KErrNone || r==KErrAlreadyExists); |
4338 #endif |
4258 #endif |
4339 |
|
4340 RDevice d; |
|
4341 TPckgBuf<RTestResMan::TCaps> caps; |
|
4342 r = d.Open(KLddName); |
|
4343 test(r == KErrNone); |
|
4344 d.GetCaps(caps); |
|
4345 d.Close(); |
|
4346 |
|
4347 TVersion ver = caps().iVersion; |
|
4348 test(ver.iMajor == 1); |
|
4349 test(ver.iMinor == 0); |
|
4350 test(ver.iBuild == KE32BuildVersionNumber); |
|
4351 |
|
4352 r = lddChan.Open(); |
4259 r = lddChan.Open(); |
4353 test(r==KErrNone || r==KErrAlreadyExists); |
4260 test(r==KErrNone || r==KErrAlreadyExists); |
4354 |
|
4355 //Check whether the notifications recieved as a result of postboot level setting is as expected. |
4261 //Check whether the notifications recieved as a result of postboot level setting is as expected. |
4356 r = lddChan.CheckPostBootLevelNotifications(); |
4262 r = lddChan.CheckPostBootLevelNotifications(); |
4357 test(r == KErrNone); |
4263 test(r == KErrNone); |
4358 TBool regressionTesting = EFalse; |
4264 TBool regressionTesting = EFalse; |
4359 //Parse the command line arguments. |
4265 //Parse the command line arguments. |