diff -r 28839de615b4 -r 26645d81f48d featuremgmt/featuremgr/test/rtest/src/t_fmgrapi.cpp --- a/featuremgmt/featuremgr/test/rtest/src/t_fmgrapi.cpp Thu Aug 19 11:36:21 2010 +0300 +++ b/featuremgmt/featuremgr/test/rtest/src/t_fmgrapi.cpp Tue Aug 31 16:57:14 2010 +0300 @@ -28,6 +28,8 @@ /////////////////////////////////////////////////////////////////////////////////////// static RTest TheTest(_L("t_fmgrapi")); +TUid SupportedFeature = KConnectivity; //Defaulted to KConnectivity, but we will re-assign it in FeatureTestPreparation(). +TUid SupportedFeature2 = KSip; //Defaulted to KSip, but we will re-assign it in FeatureTestPreparation(). /////////////////////////////////////////////////////////////////////////////////////// @@ -284,24 +286,24 @@ { TBool rc = CFeatureDiscovery::IsFeatureSupportedL(KInvalidFeatureId1); TEST(!rc); - rc = CFeatureDiscovery::IsFeatureSupportedL(KLocationManagement.iUid); + rc = CFeatureDiscovery::IsFeatureSupportedL(SupportedFeature.iUid); TEST(rc); rc = CFeatureDiscovery::IsFeatureSupportedL(KInvalidFeatureUid1); TEST(!rc); - rc = CFeatureDiscovery::IsFeatureSupportedL(KLocationManagement); + rc = CFeatureDiscovery::IsFeatureSupportedL(SupportedFeature); TEST(rc); CFeatureDiscovery* fdiscovery = CFeatureDiscovery::NewLC(); rc = fdiscovery->IsSupported(KInvalidFeatureId1); TEST(!rc); - rc = fdiscovery->IsSupported(KLocationManagement.iUid); + rc = fdiscovery->IsSupported(SupportedFeature.iUid); TEST(rc); rc = fdiscovery->IsSupported(KInvalidFeatureUid1); TEST(!rc); - rc = fdiscovery->IsSupported(KLocationManagement); + rc = fdiscovery->IsSupported(SupportedFeature); TEST(rc); CleanupStack::PopAndDestroy(fdiscovery); @@ -317,11 +319,11 @@ ////////////////////////////////////////////////////////// //A test with a set: one valid and one invalid feature TFeatureSet fset; - TInt err = fset.Append(KConnectivity); + TInt err = fset.Append(SupportedFeature); TEST2(err, KErrNone); err = fset.Append(KInvalidFeatureUid1); TEST2(err, KErrNone); - TBool rc = fset.IsFeatureSupported(KConnectivity); + TBool rc = fset.IsFeatureSupported(SupportedFeature); TEST(!rc); rc = fset.IsFeatureSupported(KInvalidFeatureUid1); TEST(!rc); @@ -334,7 +336,7 @@ err = fdiscovery->FeaturesSupported(fset); } TEST2(err, KErrNone); - rc = fset.IsFeatureSupported(KConnectivity); + rc = fset.IsFeatureSupported(SupportedFeature); TEST(rc); rc = fset.IsFeatureSupported(KInvalidFeatureUid1); TEST(!rc); @@ -343,7 +345,7 @@ ////////////////////////////////////////////////////////// //A test with an empty set TFeatureSet fset2; - rc = fset2.IsFeatureSupported(KConnectivity); + rc = fset2.IsFeatureSupported(SupportedFeature); TEST(!rc); rc = fset2.IsFeatureSupported(KInvalidFeatureUid1); TEST(!rc); @@ -356,7 +358,7 @@ err = fdiscovery->FeaturesSupported(fset2); } TEST2(err, KErrArgument); - rc = fset2.IsFeatureSupported(KConnectivity); + rc = fset2.IsFeatureSupported(SupportedFeature); TEST(!rc); rc = fset2.IsFeatureSupported(KInvalidFeatureUid1); TEST(!rc); @@ -365,9 +367,9 @@ ////////////////////////////////////////////////////////// //A test with a set: two valid features TFeatureSet fset3; - err = fset3.Append(KConnectivity); + err = fset3.Append(SupportedFeature); TEST2(err, KErrNone); - err = fset3.Append(KSip); + err = fset3.Append(SupportedFeature2); TEST2(err, KErrNone); if(aStaticMethodsUsed) { @@ -378,9 +380,9 @@ err = fdiscovery->FeaturesSupported(fset3); } TEST2(err, KErrNone); - rc = fset3.IsFeatureSupported(KConnectivity); + rc = fset3.IsFeatureSupported(SupportedFeature); TEST(rc); - rc = fset3.IsFeatureSupported(KSip); + rc = fset3.IsFeatureSupported(SupportedFeature2); TEST(rc); rc = fset3.AreAllFeaturesSupported(); TEST(rc); @@ -402,8 +404,31 @@ DoFeatureDiscoveryTest2L(EFalse); } +void FeatureTestPreparation() + { + RFeatureControl ctrl; + TInt err = ctrl.Open(); + TEST2(err, KErrNone); + ///////////////////////////////////////////////////////////// + RFeatureUidArray farray; + TheTest.Printf(_L("Getting supported feature for CFeatureDiscovery test\r\n")); + err = ctrl.ListSupportedFeatures(farray); + if (err == KErrNone && farray.Count() > 1) + { + SupportedFeature = farray[0]; //Take the first supported value + SupportedFeature2 = farray[1]; //Take the first supported value + } + else + { + TheTest.Printf(_L("Warning: Failed to get supported feature for testing. CFeatureDiscovery tests are going to fail\r\n")); + } + farray.Close(); + ctrl.Close(); + } + void DoTestsL() { + FeatureTestPreparation(); //Preparation for the test. TheTest.Start(_L("@SYMTestCaseID:PDS-EFM-CT-4059 FeatureManager::FeatureSupported() test")); FeatureSupportedTestL(); TheTest.Next(_L("@SYMTestCaseID:PDS-EFM-CT-4060 RFeatureControl tests-1"));