featuremgmt/featuremgr/test/rtest/src/t_fmgrapi.cpp
branchRCL_3
changeset 24 cc28652e0254
parent 23 26645d81f48d
equal deleted inserted replaced
23:26645d81f48d 24:cc28652e0254
    26 const TUid KInvalidFeatureUid1  = {KInvalidFeatureId1};
    26 const TUid KInvalidFeatureUid1  = {KInvalidFeatureId1};
    27 
    27 
    28 ///////////////////////////////////////////////////////////////////////////////////////
    28 ///////////////////////////////////////////////////////////////////////////////////////
    29 
    29 
    30 static RTest TheTest(_L("t_fmgrapi"));
    30 static RTest TheTest(_L("t_fmgrapi"));
    31 TUid SupportedFeature   = KConnectivity;  //Defaulted to KConnectivity, but we will re-assign it in FeatureTestPreparation().
       
    32 TUid SupportedFeature2  = KSip;          //Defaulted to KSip, but we will re-assign it in FeatureTestPreparation().
       
    33 
    31 
    34 ///////////////////////////////////////////////////////////////////////////////////////
    32 ///////////////////////////////////////////////////////////////////////////////////////
    35 
    33 
    36 //Deletes all created test files.
    34 //Deletes all created test files.
    37 void DestroyTestEnv()
    35 void DestroyTestEnv()
   284 */
   282 */
   285 void FeatureDiscoveryTest1L()
   283 void FeatureDiscoveryTest1L()
   286     {
   284     {
   287     TBool rc = CFeatureDiscovery::IsFeatureSupportedL(KInvalidFeatureId1);
   285     TBool rc = CFeatureDiscovery::IsFeatureSupportedL(KInvalidFeatureId1);
   288     TEST(!rc);
   286     TEST(!rc);
   289     rc = CFeatureDiscovery::IsFeatureSupportedL(SupportedFeature.iUid);
   287     rc = CFeatureDiscovery::IsFeatureSupportedL(KLocationManagement.iUid);
   290     TEST(rc);
   288     TEST(rc);
   291     
   289     
   292     rc = CFeatureDiscovery::IsFeatureSupportedL(KInvalidFeatureUid1);
   290     rc = CFeatureDiscovery::IsFeatureSupportedL(KInvalidFeatureUid1);
   293     TEST(!rc);
   291     TEST(!rc);
   294     rc = CFeatureDiscovery::IsFeatureSupportedL(SupportedFeature);
   292     rc = CFeatureDiscovery::IsFeatureSupportedL(KLocationManagement);
   295     TEST(rc);
   293     TEST(rc);
   296 
   294 
   297     CFeatureDiscovery* fdiscovery = CFeatureDiscovery::NewLC();
   295     CFeatureDiscovery* fdiscovery = CFeatureDiscovery::NewLC();
   298     
   296     
   299     rc = fdiscovery->IsSupported(KInvalidFeatureId1);
   297     rc = fdiscovery->IsSupported(KInvalidFeatureId1);
   300     TEST(!rc);
   298     TEST(!rc);
   301     rc = fdiscovery->IsSupported(SupportedFeature.iUid);
   299     rc = fdiscovery->IsSupported(KLocationManagement.iUid);
   302     TEST(rc);
   300     TEST(rc);
   303 
   301 
   304     rc = fdiscovery->IsSupported(KInvalidFeatureUid1);
   302     rc = fdiscovery->IsSupported(KInvalidFeatureUid1);
   305     TEST(!rc);
   303     TEST(!rc);
   306     rc = fdiscovery->IsSupported(SupportedFeature);
   304     rc = fdiscovery->IsSupported(KLocationManagement);
   307     TEST(rc);
   305     TEST(rc);
   308     
   306     
   309     CleanupStack::PopAndDestroy(fdiscovery);
   307     CleanupStack::PopAndDestroy(fdiscovery);
   310     }
   308     }
   311 
   309 
   317         fdiscovery = CFeatureDiscovery::NewL();
   315         fdiscovery = CFeatureDiscovery::NewL();
   318         }
   316         }
   319     //////////////////////////////////////////////////////////
   317     //////////////////////////////////////////////////////////
   320     //A test with a set: one valid and one invalid feature 
   318     //A test with a set: one valid and one invalid feature 
   321     TFeatureSet fset;
   319     TFeatureSet fset;
   322     TInt err = fset.Append(SupportedFeature);
   320     TInt err = fset.Append(KConnectivity);
   323     TEST2(err, KErrNone);
   321     TEST2(err, KErrNone);
   324     err = fset.Append(KInvalidFeatureUid1);
   322     err = fset.Append(KInvalidFeatureUid1);
   325     TEST2(err, KErrNone);
   323     TEST2(err, KErrNone);
   326     TBool rc = fset.IsFeatureSupported(SupportedFeature);
   324     TBool rc = fset.IsFeatureSupported(KConnectivity);
   327     TEST(!rc);
   325     TEST(!rc);
   328     rc = fset.IsFeatureSupported(KInvalidFeatureUid1);
   326     rc = fset.IsFeatureSupported(KInvalidFeatureUid1);
   329     TEST(!rc);
   327     TEST(!rc);
   330     if(aStaticMethodsUsed)
   328     if(aStaticMethodsUsed)
   331         {
   329         {
   334     else
   332     else
   335         {
   333         {
   336         err = fdiscovery->FeaturesSupported(fset);
   334         err = fdiscovery->FeaturesSupported(fset);
   337         }
   335         }
   338     TEST2(err, KErrNone);
   336     TEST2(err, KErrNone);
   339     rc = fset.IsFeatureSupported(SupportedFeature);
   337     rc = fset.IsFeatureSupported(KConnectivity);
   340     TEST(rc);
   338     TEST(rc);
   341     rc = fset.IsFeatureSupported(KInvalidFeatureUid1);
   339     rc = fset.IsFeatureSupported(KInvalidFeatureUid1);
   342     TEST(!rc);
   340     TEST(!rc);
   343     rc = fset.AreAllFeaturesSupported();
   341     rc = fset.AreAllFeaturesSupported();
   344     TEST(!rc);
   342     TEST(!rc);
   345     //////////////////////////////////////////////////////////
   343     //////////////////////////////////////////////////////////
   346     //A test with an empty set 
   344     //A test with an empty set 
   347     TFeatureSet fset2;
   345     TFeatureSet fset2;
   348     rc = fset2.IsFeatureSupported(SupportedFeature);
   346     rc = fset2.IsFeatureSupported(KConnectivity);
   349     TEST(!rc);
   347     TEST(!rc);
   350     rc = fset2.IsFeatureSupported(KInvalidFeatureUid1);
   348     rc = fset2.IsFeatureSupported(KInvalidFeatureUid1);
   351     TEST(!rc);
   349     TEST(!rc);
   352     if(aStaticMethodsUsed)
   350     if(aStaticMethodsUsed)
   353         {
   351         {
   356     else
   354     else
   357         {
   355         {
   358         err = fdiscovery->FeaturesSupported(fset2);
   356         err = fdiscovery->FeaturesSupported(fset2);
   359         }
   357         }
   360     TEST2(err, KErrArgument);
   358     TEST2(err, KErrArgument);
   361     rc = fset2.IsFeatureSupported(SupportedFeature);
   359     rc = fset2.IsFeatureSupported(KConnectivity);
   362     TEST(!rc);
   360     TEST(!rc);
   363     rc = fset2.IsFeatureSupported(KInvalidFeatureUid1);
   361     rc = fset2.IsFeatureSupported(KInvalidFeatureUid1);
   364     TEST(!rc);
   362     TEST(!rc);
   365     rc = fset2.AreAllFeaturesSupported();
   363     rc = fset2.AreAllFeaturesSupported();
   366     TEST(rc);//because fset2 is empty
   364     TEST(rc);//because fset2 is empty
   367     //////////////////////////////////////////////////////////
   365     //////////////////////////////////////////////////////////
   368     //A test with a set: two valid features 
   366     //A test with a set: two valid features 
   369     TFeatureSet fset3;
   367     TFeatureSet fset3;
   370     err = fset3.Append(SupportedFeature);
   368     err = fset3.Append(KConnectivity);
   371     TEST2(err, KErrNone);
   369     TEST2(err, KErrNone);
   372     err = fset3.Append(SupportedFeature2);
   370     err = fset3.Append(KSip);
   373     TEST2(err, KErrNone);
   371     TEST2(err, KErrNone);
   374     if(aStaticMethodsUsed)
   372     if(aStaticMethodsUsed)
   375         {
   373         {
   376         TRAP(err, CFeatureDiscovery::FeaturesSupportedL(fset3));
   374         TRAP(err, CFeatureDiscovery::FeaturesSupportedL(fset3));
   377         }
   375         }
   378     else
   376     else
   379         {
   377         {
   380         err = fdiscovery->FeaturesSupported(fset3);
   378         err = fdiscovery->FeaturesSupported(fset3);
   381         }
   379         }
   382     TEST2(err, KErrNone);
   380     TEST2(err, KErrNone);
   383     rc = fset3.IsFeatureSupported(SupportedFeature);
   381     rc = fset3.IsFeatureSupported(KConnectivity);
   384     TEST(rc);
   382     TEST(rc);
   385     rc = fset3.IsFeatureSupported(SupportedFeature2);
   383     rc = fset3.IsFeatureSupported(KSip);
   386     TEST(rc);
   384     TEST(rc);
   387     rc = fset3.AreAllFeaturesSupported();
   385     rc = fset3.AreAllFeaturesSupported();
   388     TEST(rc);
   386     TEST(rc);
   389     //////////////////////////////////////////////////////////
   387     //////////////////////////////////////////////////////////
   390     delete fdiscovery;
   388     delete fdiscovery;
   402     {
   400     {
   403     DoFeatureDiscoveryTest2L(ETrue);
   401     DoFeatureDiscoveryTest2L(ETrue);
   404     DoFeatureDiscoveryTest2L(EFalse);
   402     DoFeatureDiscoveryTest2L(EFalse);
   405     }
   403     }
   406 
   404 
   407 void FeatureTestPreparation()
       
   408     {
       
   409     RFeatureControl ctrl;
       
   410     TInt err = ctrl.Open();
       
   411     TEST2(err, KErrNone);
       
   412     /////////////////////////////////////////////////////////////
       
   413     RFeatureUidArray farray;
       
   414     TheTest.Printf(_L("Getting supported feature for CFeatureDiscovery test\r\n"));
       
   415     err = ctrl.ListSupportedFeatures(farray);
       
   416     if (err == KErrNone && farray.Count() > 1)
       
   417         {
       
   418         SupportedFeature = farray[0]; //Take the first supported value
       
   419         SupportedFeature2 = farray[1]; //Take the first supported value
       
   420         }
       
   421     else
       
   422         {
       
   423         TheTest.Printf(_L("Warning: Failed to get supported feature for testing. CFeatureDiscovery tests are going to fail\r\n"));
       
   424         }
       
   425     farray.Close();
       
   426     ctrl.Close();
       
   427     }
       
   428 
       
   429 void DoTestsL()
   405 void DoTestsL()
   430     {
   406     {
   431     FeatureTestPreparation(); //Preparation for the test.
       
   432     TheTest.Start(_L("@SYMTestCaseID:PDS-EFM-CT-4059 FeatureManager::FeatureSupported() test"));
   407     TheTest.Start(_L("@SYMTestCaseID:PDS-EFM-CT-4059 FeatureManager::FeatureSupported() test"));
   433     FeatureSupportedTestL();
   408     FeatureSupportedTestL();
   434     TheTest.Next(_L("@SYMTestCaseID:PDS-EFM-CT-4060 RFeatureControl tests-1"));
   409     TheTest.Next(_L("@SYMTestCaseID:PDS-EFM-CT-4060 RFeatureControl tests-1"));
   435     FeatureControlTest1();
   410     FeatureControlTest1();
   436     TheTest.Next(_L("@SYMTestCaseID:PDS-EFM-CT-4061 RFeatureControl tests-2"));
   411     TheTest.Next(_L("@SYMTestCaseID:PDS-EFM-CT-4061 RFeatureControl tests-2"));