featuremgmt/featuremgr/test/rtest/src/t_fmgrapi.cpp
branchRCL_3
changeset 23 26645d81f48d
parent 10 31a8f755b7fe
child 24 cc28652e0254
equal deleted inserted replaced
21:28839de615b4 23:26645d81f48d
    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().
    31 
    33 
    32 ///////////////////////////////////////////////////////////////////////////////////////
    34 ///////////////////////////////////////////////////////////////////////////////////////
    33 
    35 
    34 //Deletes all created test files.
    36 //Deletes all created test files.
    35 void DestroyTestEnv()
    37 void DestroyTestEnv()
   282 */
   284 */
   283 void FeatureDiscoveryTest1L()
   285 void FeatureDiscoveryTest1L()
   284     {
   286     {
   285     TBool rc = CFeatureDiscovery::IsFeatureSupportedL(KInvalidFeatureId1);
   287     TBool rc = CFeatureDiscovery::IsFeatureSupportedL(KInvalidFeatureId1);
   286     TEST(!rc);
   288     TEST(!rc);
   287     rc = CFeatureDiscovery::IsFeatureSupportedL(KLocationManagement.iUid);
   289     rc = CFeatureDiscovery::IsFeatureSupportedL(SupportedFeature.iUid);
   288     TEST(rc);
   290     TEST(rc);
   289     
   291     
   290     rc = CFeatureDiscovery::IsFeatureSupportedL(KInvalidFeatureUid1);
   292     rc = CFeatureDiscovery::IsFeatureSupportedL(KInvalidFeatureUid1);
   291     TEST(!rc);
   293     TEST(!rc);
   292     rc = CFeatureDiscovery::IsFeatureSupportedL(KLocationManagement);
   294     rc = CFeatureDiscovery::IsFeatureSupportedL(SupportedFeature);
   293     TEST(rc);
   295     TEST(rc);
   294 
   296 
   295     CFeatureDiscovery* fdiscovery = CFeatureDiscovery::NewLC();
   297     CFeatureDiscovery* fdiscovery = CFeatureDiscovery::NewLC();
   296     
   298     
   297     rc = fdiscovery->IsSupported(KInvalidFeatureId1);
   299     rc = fdiscovery->IsSupported(KInvalidFeatureId1);
   298     TEST(!rc);
   300     TEST(!rc);
   299     rc = fdiscovery->IsSupported(KLocationManagement.iUid);
   301     rc = fdiscovery->IsSupported(SupportedFeature.iUid);
   300     TEST(rc);
   302     TEST(rc);
   301 
   303 
   302     rc = fdiscovery->IsSupported(KInvalidFeatureUid1);
   304     rc = fdiscovery->IsSupported(KInvalidFeatureUid1);
   303     TEST(!rc);
   305     TEST(!rc);
   304     rc = fdiscovery->IsSupported(KLocationManagement);
   306     rc = fdiscovery->IsSupported(SupportedFeature);
   305     TEST(rc);
   307     TEST(rc);
   306     
   308     
   307     CleanupStack::PopAndDestroy(fdiscovery);
   309     CleanupStack::PopAndDestroy(fdiscovery);
   308     }
   310     }
   309 
   311 
   315         fdiscovery = CFeatureDiscovery::NewL();
   317         fdiscovery = CFeatureDiscovery::NewL();
   316         }
   318         }
   317     //////////////////////////////////////////////////////////
   319     //////////////////////////////////////////////////////////
   318     //A test with a set: one valid and one invalid feature 
   320     //A test with a set: one valid and one invalid feature 
   319     TFeatureSet fset;
   321     TFeatureSet fset;
   320     TInt err = fset.Append(KConnectivity);
   322     TInt err = fset.Append(SupportedFeature);
   321     TEST2(err, KErrNone);
   323     TEST2(err, KErrNone);
   322     err = fset.Append(KInvalidFeatureUid1);
   324     err = fset.Append(KInvalidFeatureUid1);
   323     TEST2(err, KErrNone);
   325     TEST2(err, KErrNone);
   324     TBool rc = fset.IsFeatureSupported(KConnectivity);
   326     TBool rc = fset.IsFeatureSupported(SupportedFeature);
   325     TEST(!rc);
   327     TEST(!rc);
   326     rc = fset.IsFeatureSupported(KInvalidFeatureUid1);
   328     rc = fset.IsFeatureSupported(KInvalidFeatureUid1);
   327     TEST(!rc);
   329     TEST(!rc);
   328     if(aStaticMethodsUsed)
   330     if(aStaticMethodsUsed)
   329         {
   331         {
   332     else
   334     else
   333         {
   335         {
   334         err = fdiscovery->FeaturesSupported(fset);
   336         err = fdiscovery->FeaturesSupported(fset);
   335         }
   337         }
   336     TEST2(err, KErrNone);
   338     TEST2(err, KErrNone);
   337     rc = fset.IsFeatureSupported(KConnectivity);
   339     rc = fset.IsFeatureSupported(SupportedFeature);
   338     TEST(rc);
   340     TEST(rc);
   339     rc = fset.IsFeatureSupported(KInvalidFeatureUid1);
   341     rc = fset.IsFeatureSupported(KInvalidFeatureUid1);
   340     TEST(!rc);
   342     TEST(!rc);
   341     rc = fset.AreAllFeaturesSupported();
   343     rc = fset.AreAllFeaturesSupported();
   342     TEST(!rc);
   344     TEST(!rc);
   343     //////////////////////////////////////////////////////////
   345     //////////////////////////////////////////////////////////
   344     //A test with an empty set 
   346     //A test with an empty set 
   345     TFeatureSet fset2;
   347     TFeatureSet fset2;
   346     rc = fset2.IsFeatureSupported(KConnectivity);
   348     rc = fset2.IsFeatureSupported(SupportedFeature);
   347     TEST(!rc);
   349     TEST(!rc);
   348     rc = fset2.IsFeatureSupported(KInvalidFeatureUid1);
   350     rc = fset2.IsFeatureSupported(KInvalidFeatureUid1);
   349     TEST(!rc);
   351     TEST(!rc);
   350     if(aStaticMethodsUsed)
   352     if(aStaticMethodsUsed)
   351         {
   353         {
   354     else
   356     else
   355         {
   357         {
   356         err = fdiscovery->FeaturesSupported(fset2);
   358         err = fdiscovery->FeaturesSupported(fset2);
   357         }
   359         }
   358     TEST2(err, KErrArgument);
   360     TEST2(err, KErrArgument);
   359     rc = fset2.IsFeatureSupported(KConnectivity);
   361     rc = fset2.IsFeatureSupported(SupportedFeature);
   360     TEST(!rc);
   362     TEST(!rc);
   361     rc = fset2.IsFeatureSupported(KInvalidFeatureUid1);
   363     rc = fset2.IsFeatureSupported(KInvalidFeatureUid1);
   362     TEST(!rc);
   364     TEST(!rc);
   363     rc = fset2.AreAllFeaturesSupported();
   365     rc = fset2.AreAllFeaturesSupported();
   364     TEST(rc);//because fset2 is empty
   366     TEST(rc);//because fset2 is empty
   365     //////////////////////////////////////////////////////////
   367     //////////////////////////////////////////////////////////
   366     //A test with a set: two valid features 
   368     //A test with a set: two valid features 
   367     TFeatureSet fset3;
   369     TFeatureSet fset3;
   368     err = fset3.Append(KConnectivity);
   370     err = fset3.Append(SupportedFeature);
   369     TEST2(err, KErrNone);
   371     TEST2(err, KErrNone);
   370     err = fset3.Append(KSip);
   372     err = fset3.Append(SupportedFeature2);
   371     TEST2(err, KErrNone);
   373     TEST2(err, KErrNone);
   372     if(aStaticMethodsUsed)
   374     if(aStaticMethodsUsed)
   373         {
   375         {
   374         TRAP(err, CFeatureDiscovery::FeaturesSupportedL(fset3));
   376         TRAP(err, CFeatureDiscovery::FeaturesSupportedL(fset3));
   375         }
   377         }
   376     else
   378     else
   377         {
   379         {
   378         err = fdiscovery->FeaturesSupported(fset3);
   380         err = fdiscovery->FeaturesSupported(fset3);
   379         }
   381         }
   380     TEST2(err, KErrNone);
   382     TEST2(err, KErrNone);
   381     rc = fset3.IsFeatureSupported(KConnectivity);
   383     rc = fset3.IsFeatureSupported(SupportedFeature);
   382     TEST(rc);
   384     TEST(rc);
   383     rc = fset3.IsFeatureSupported(KSip);
   385     rc = fset3.IsFeatureSupported(SupportedFeature2);
   384     TEST(rc);
   386     TEST(rc);
   385     rc = fset3.AreAllFeaturesSupported();
   387     rc = fset3.AreAllFeaturesSupported();
   386     TEST(rc);
   388     TEST(rc);
   387     //////////////////////////////////////////////////////////
   389     //////////////////////////////////////////////////////////
   388     delete fdiscovery;
   390     delete fdiscovery;
   400     {
   402     {
   401     DoFeatureDiscoveryTest2L(ETrue);
   403     DoFeatureDiscoveryTest2L(ETrue);
   402     DoFeatureDiscoveryTest2L(EFalse);
   404     DoFeatureDiscoveryTest2L(EFalse);
   403     }
   405     }
   404 
   406 
       
   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 
   405 void DoTestsL()
   429 void DoTestsL()
   406     {
   430     {
       
   431     FeatureTestPreparation(); //Preparation for the test.
   407     TheTest.Start(_L("@SYMTestCaseID:PDS-EFM-CT-4059 FeatureManager::FeatureSupported() test"));
   432     TheTest.Start(_L("@SYMTestCaseID:PDS-EFM-CT-4059 FeatureManager::FeatureSupported() test"));
   408     FeatureSupportedTestL();
   433     FeatureSupportedTestL();
   409     TheTest.Next(_L("@SYMTestCaseID:PDS-EFM-CT-4060 RFeatureControl tests-1"));
   434     TheTest.Next(_L("@SYMTestCaseID:PDS-EFM-CT-4060 RFeatureControl tests-1"));
   410     FeatureControlTest1();
   435     FeatureControlTest1();
   411     TheTest.Next(_L("@SYMTestCaseID:PDS-EFM-CT-4061 RFeatureControl tests-2"));
   436     TheTest.Next(_L("@SYMTestCaseID:PDS-EFM-CT-4061 RFeatureControl tests-2"));