installationservices/swcomponentregistry/test/tscr/source/appreginfosteps.cpp
branchRCL_3
changeset 26 8b7f4e561641
parent 25 7333d7932ef7
child 27 e8965914fac7
equal deleted inserted replaced
25:7333d7932ef7 26:8b7f4e561641
     1 /*
       
     2 * Copyright (c) 2009-2010 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of the License "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description: 
       
    15 * Implements test steps for component management APIs in the SCR
       
    16 *
       
    17 */
       
    18 
       
    19 #include "appreginfosteps.h"
       
    20 #include "tscrdefs.h"
       
    21 #include <scs/cleanuputils.h>
       
    22 #include <usif/usiferror.h>
       
    23 
       
    24 using namespace Usif;
       
    25 
       
    26 // -----------CScrAddApplicationEntryStep-----------------
       
    27 
       
    28 CScrAddApplicationEntryStep::CScrAddApplicationEntryStep(CScrTestServer& aParent) : CScrTestStep(aParent)
       
    29     {
       
    30     }
       
    31 
       
    32 void CScrAddApplicationEntryStep::ImplTestStepPreambleL()
       
    33     {
       
    34     User::LeaveIfError(iScrSession.Connect());    
       
    35     }
       
    36 
       
    37 void CScrAddApplicationEntryStep::ImplTestStepL()
       
    38     {
       
    39     TComponentId compId = 0;
       
    40     TBool newComponentAdded(EFalse);
       
    41    
       
    42     // Checking if have already inserted the component
       
    43     TBool isMultiApp(EFalse);
       
    44     GetBoolFromConfig(ConfigSection(), _L("IsMultiApp"), isMultiApp);
       
    45     if (isMultiApp)
       
    46         {
       
    47         INFO_PRINTF1(_L("Checking if the component is already present"));
       
    48         CGlobalComponentId *globalId = GetGlobalComponentIdLC();
       
    49         TRAP_IGNORE(compId = iScrSession.GetComponentIdL(globalId->GlobalIdName(), globalId->SoftwareTypeName()););
       
    50         CleanupStack::PopAndDestroy(globalId);
       
    51         }
       
    52 
       
    53 	// Try adding the app to a component. The add operation will fail if the component is not present.
       
    54 	if (!compId) 
       
    55 		{
       
    56 		if (GetIntFromConfig(ConfigSection(), _L("UseComponentId"), compId))
       
    57 			INFO_PRINTF2(_L("Adding a new AppRegInfo to component %d"), compId);
       
    58 		}
       
    59     
       
    60     // The component is not present already
       
    61     if (!compId)   
       
    62         {
       
    63         INFO_PRINTF1(_L("Adding a new component."));
       
    64         compId = AddNonLocalisableComponentL(iScrSession);
       
    65         newComponentAdded = ETrue;
       
    66         }
       
    67 
       
    68 	INFO_PRINTF1(_L("Get reg info from config file."));
       
    69 	const CApplicationRegistrationData* appRegData = GetAppRegInfoFromConfigLC();
       
    70 	
       
    71 	if (iIsPerformanceTest)
       
    72         StartTimer(); // Start the timer in the case of a performance tests        
       
    73 	TRAPD(err, iScrSession.AddApplicationEntryL(compId, *appRegData));
       
    74     if (iIsPerformanceTest)
       
    75         StopTimerAndPrintResultL(); // Stop the timer and analyze the time taken after performance tests
       
    76         
       
    77 	if (err != KErrNone)
       
    78 	    {
       
    79 		if (newComponentAdded)
       
    80 			{
       
    81 			// We are going to delete the component with no apps
       
    82 			iScrSession.DeleteComponentL(compId);
       
    83 			}
       
    84 		User::Leave(err);
       
    85 	    }
       
    86 
       
    87 	CleanupStack::PopAndDestroy();
       
    88 	}
       
    89     
       
    90 void CScrAddApplicationEntryStep::ImplTestStepPostambleL()
       
    91     {
       
    92    
       
    93     }
       
    94 
       
    95 
       
    96 // -----------CScrDeleteApplicationEntriesStep-----------------
       
    97 
       
    98 CScrDeleteApplicationEntriesStep::CScrDeleteApplicationEntriesStep(CScrTestServer& aParent) : CScrTestStep(aParent)
       
    99     {
       
   100     }
       
   101 
       
   102 void CScrDeleteApplicationEntriesStep::ImplTestStepPreambleL()
       
   103     {
       
   104     CScrTestStep::ImplTestStepPreambleL();
       
   105     }
       
   106 
       
   107 void CScrDeleteApplicationEntriesStep::ImplTestStepL()
       
   108     {
       
   109     TComponentId compId = 0;
       
   110    
       
   111     INFO_PRINTF1(_L("Fetching the component Id."));
       
   112     
       
   113     TUid appUid = TUid::Null();
       
   114     TRAP_IGNORE(GetAppUidL(appUid));
       
   115     
       
   116     if(appUid == TUid::Null())
       
   117         {
       
   118         SetTestStepResult(EPass);
       
   119         CGlobalComponentId *globalId = GetGlobalComponentIdLC();
       
   120         compId = iScrSession.GetComponentIdL(globalId->GlobalIdName(), globalId->SoftwareTypeName());
       
   121         CleanupStack::PopAndDestroy(globalId);
       
   122         }
       
   123     else
       
   124         {
       
   125         compId = iScrSession.GetComponentIdForAppL(appUid);
       
   126         }
       
   127 
       
   128     INFO_PRINTF2(_L("Deleting app entries for component %d"), compId);
       
   129     iScrSession.DeleteApplicationEntriesL(compId);
       
   130     INFO_PRINTF2(_L("Deleting component %d"), compId);
       
   131     iScrSession.DeleteComponentL(compId);    
       
   132     }
       
   133     
       
   134 void CScrDeleteApplicationEntriesStep::ImplTestStepPostambleL()
       
   135     {
       
   136     CScrTestStep::ImplTestStepPostambleL();
       
   137     }
       
   138 
       
   139 CSCRGetAppServicesUids::CSCRGetAppServicesUids(CScrTestServer& aParent) : CScrTestStep(aParent)
       
   140     {
       
   141     }
       
   142 
       
   143 void CSCRGetAppServicesUids::ImplTestStepPreambleL()
       
   144     {
       
   145     CScrTestStep::ImplTestStepPreambleL();
       
   146     }
       
   147 
       
   148 void CSCRGetAppServicesUids::ImplTestStepL()
       
   149     {
       
   150 	TUid appUid, serviceUid;
       
   151 	TInt noOfServiceUids = 0;
       
   152 	RArray<TUid> expectedServiceUids;
       
   153 	RArray<TUid> obtainedServiceUids;
       
   154 	TBuf<20> serviceUidName;
       
   155     CleanupClosePushL(expectedServiceUids);
       
   156     CleanupClosePushL(obtainedServiceUids);
       
   157     GetIntFromConfig(ConfigSection(), _L("NoOfServiceUids"), noOfServiceUids);
       
   158     for (TUint i = 0; i < noOfServiceUids; ++i)
       
   159         {                
       
   160         serviceUidName = KServiceUid;
       
   161         GenerateIndexedAttributeNameL(serviceUidName, i);
       
   162         GetUidFromConfig(ConfigSection(), serviceUidName, serviceUid);
       
   163         expectedServiceUids.AppendL(serviceUid);
       
   164         }
       
   165         
       
   166 	GetAppUidL(appUid);
       
   167 	RRegistrationInfoForApplication InfoQuerySubSession;
       
   168 	CleanupClosePushL(InfoQuerySubSession);	
       
   169 	
       
   170 	InfoQuerySubSession.OpenL(iScrSession, appUid);
       
   171 
       
   172 	TRAPD(err,InfoQuerySubSession.GetAppServicesUidsL(obtainedServiceUids));
       
   173 	
       
   174 	TInt noOfExpectedServiceUids = expectedServiceUids.Count();
       
   175 	TInt noOfObtainedServiceUids = obtainedServiceUids.Count();
       
   176 	 if(err != KErrNone && err !=KErrNotFound)
       
   177          {
       
   178          INFO_PRINTF2(_L("Failed to Get App Uid , error: %d"), err);
       
   179          SetTestStepResult(EFail);        
       
   180          }      
       
   181 	         	              
       
   182 	    
       
   183 	if(noOfExpectedServiceUids != noOfObtainedServiceUids)
       
   184 	    {
       
   185 	    INFO_PRINTF3(_L("Service Uid's Count doesn't match: expected/obtained Uid count: %d/%d"), noOfExpectedServiceUids, noOfObtainedServiceUids);
       
   186 	    SetTestStepResult(EFail);	 
       
   187 	    }
       
   188 	else
       
   189 	    {
       
   190         //Comparing expected result and Obtained Result
       
   191         for(TInt i=0 ; i < noOfExpectedServiceUids ; i++)
       
   192             {
       
   193             if(expectedServiceUids[i] != obtainedServiceUids[i])
       
   194                 {
       
   195                 INFO_PRINTF3(_L("Service Uid doesn't match: expected/obtained Uid: 0x%08x/0x%08x"), expectedServiceUids[i].iUid, obtainedServiceUids[i].iUid);
       
   196                 SetTestStepResult(EFail);           
       
   197                 }
       
   198             }	
       
   199 	    }
       
   200 	InfoQuerySubSession.Close();	
       
   201 	obtainedServiceUids.Close();
       
   202 	expectedServiceUids.Close();
       
   203 	CleanupStack::Pop(3, &expectedServiceUids);	    
       
   204     }
       
   205     
       
   206 void CSCRGetAppServicesUids::ImplTestStepPostambleL()
       
   207     {
       
   208     CScrTestStep::ImplTestStepPostambleL();
       
   209     }
       
   210 
       
   211 CSCRGetAppForDataType::CSCRGetAppForDataType(CScrTestServer& aParent) : CScrTestStep(aParent)
       
   212     {
       
   213     }
       
   214 
       
   215 void CSCRGetAppForDataType::ImplTestStepPreambleL()
       
   216     {
       
   217     CScrTestStep::ImplTestStepPreambleL();
       
   218     }
       
   219 
       
   220 void CSCRGetAppForDataType::ImplTestStepL()
       
   221     {
       
   222     TUid obtainedAppUid,expectedAppUid;
       
   223         
       
   224     TPtrC dataType;
       
   225     if(!GetStringFromConfig(ConfigSection(), KServiceDataType, dataType))
       
   226         {
       
   227         INFO_PRINTF1(_L("Failed to Get Data Type from ini"));
       
   228         SetTestStepResult(EFail);      
       
   229         }
       
   230     
       
   231     TBool uidExists = EFalse;
       
   232     GetUidFromConfig(ConfigSection(), KAppUid, expectedAppUid);
       
   233     GetBoolFromConfig(ConfigSection(), _L("UidExists"), uidExists);
       
   234 
       
   235     RApplicationRegistrationInfo InfoQuerySubSession;
       
   236     CleanupClosePushL(InfoQuerySubSession);
       
   237     
       
   238     
       
   239     InfoQuerySubSession.OpenL(iScrSession);
       
   240 
       
   241     TRAPD(err,obtainedAppUid = InfoQuerySubSession.GetAppForDataTypeL(dataType));        
       
   242          
       
   243      if(err != KErrNone && uidExists)
       
   244          {
       
   245          INFO_PRINTF2(_L("Failed to Get App Uid , error: %d"), err);
       
   246          SetTestStepResult(EFail);        
       
   247          }      
       
   248          
       
   249      //Comparing expected result and Obtained Result
       
   250      if(expectedAppUid != obtainedAppUid && uidExists)
       
   251          {
       
   252          INFO_PRINTF3(_L("App Uid doesn't match: expected/obtained Uid: 0x%08x/0x%08x"), expectedAppUid, obtainedAppUid);
       
   253          SetTestStepResult(EFail);        
       
   254          }         
       
   255     
       
   256     InfoQuerySubSession.Close();        
       
   257     CleanupStack::PopAndDestroy();        
       
   258     }
       
   259     
       
   260 void CSCRGetAppForDataType::ImplTestStepPostambleL()
       
   261     {
       
   262     CScrTestStep::ImplTestStepPostambleL();
       
   263     }
       
   264 
       
   265 CSCRGetAppForDataTypeAndService::CSCRGetAppForDataTypeAndService(CScrTestServer& aParent) : CScrTestStep(aParent)
       
   266     {
       
   267     }
       
   268 
       
   269 void CSCRGetAppForDataTypeAndService::ImplTestStepPreambleL()
       
   270     {
       
   271     CScrTestStep::ImplTestStepPreambleL();
       
   272     }
       
   273 
       
   274 void CSCRGetAppForDataTypeAndService::ImplTestStepL()
       
   275     {
       
   276     TUid obtainedAppUid, expectedAppUid, serviceUid;    
       
   277         
       
   278     TPtrC dataType;
       
   279     if(!GetStringFromConfig(ConfigSection(), KServiceDataType, dataType))
       
   280         {
       
   281         INFO_PRINTF1(_L("Failed to Get Data Type from ini"));
       
   282         SetTestStepResult(EFail);      
       
   283         }
       
   284     
       
   285     //Get serviceUid from ini
       
   286     if(!GetUidFromConfig(ConfigSection(), KServiceUid, serviceUid))
       
   287         {
       
   288         INFO_PRINTF1(_L("Failed to Service uid from ini"));
       
   289         SetTestStepResult(EFail);
       
   290         }
       
   291     
       
   292     //Get expected Appuid from ini
       
   293     GetUidFromConfig(ConfigSection(), KAppUid, expectedAppUid);
       
   294     
       
   295     TBool uidExists = EFalse;
       
   296     GetBoolFromConfig(ConfigSection(), _L("UidExists"), uidExists);
       
   297     
       
   298     RApplicationRegistrationInfo InfoQuerySubSession;
       
   299     CleanupClosePushL(InfoQuerySubSession);
       
   300     InfoQuerySubSession.OpenL(iScrSession);
       
   301     
       
   302     TRAPD(err,obtainedAppUid = InfoQuerySubSession.GetAppForDataTypeAndServiceL(dataType,serviceUid));
       
   303         
       
   304     if(err != KErrNone && uidExists)
       
   305         {
       
   306         INFO_PRINTF2(_L("Failed to Get App Uid , error: %d"), err);
       
   307         SetTestStepResult(EFail);        
       
   308         }      
       
   309         
       
   310     //Comparing expected result and Obtained Result
       
   311     if(expectedAppUid != obtainedAppUid && uidExists)
       
   312         {
       
   313         INFO_PRINTF3(_L("App Uid doesn't match: expected/obtained Uid: 0x%08x/0x%08x"), expectedAppUid, obtainedAppUid);
       
   314         SetTestStepResult(EFail);        
       
   315         }    
       
   316     
       
   317     InfoQuerySubSession.Close();        
       
   318     CleanupStack::PopAndDestroy();        
       
   319     }
       
   320     
       
   321 void CSCRGetAppForDataTypeAndService::ImplTestStepPostambleL()
       
   322     {
       
   323     CScrTestStep::ImplTestStepPostambleL();
       
   324     }
       
   325 
       
   326 CSCRGetDefaultScreenNumber::CSCRGetDefaultScreenNumber(CScrTestServer& aParent) : CScrTestStep(aParent)
       
   327     {
       
   328     }
       
   329 
       
   330 void CSCRGetDefaultScreenNumber::ImplTestStepPreambleL()
       
   331     {
       
   332     CScrTestStep::ImplTestStepPreambleL();
       
   333     }
       
   334 
       
   335 void CSCRGetDefaultScreenNumber::ImplTestStepL()
       
   336     {
       
   337     TUid appUid;
       
   338     TInt obtaineddefaultScreenNumber = 0 , expecteddefaultScreenNumber = 0;
       
   339     
       
   340     //Get the Default screen Number from the ini to compare
       
   341     GetIntFromConfig(ConfigSection(), _L("DefaultScreenNumber"), expecteddefaultScreenNumber);
       
   342                
       
   343     GetAppUidL(appUid);
       
   344     RRegistrationInfoForApplication InfoQuerySubSession;
       
   345     CleanupClosePushL(InfoQuerySubSession);
       
   346     INFO_PRINTF1(_L("After subsession creation"));
       
   347     
       
   348     InfoQuerySubSession.OpenL(iScrSession, appUid);
       
   349     TRAPD(err, obtaineddefaultScreenNumber = InfoQuerySubSession.DefaultScreenNumberL());
       
   350 
       
   351     if(err != KErrNone && expecteddefaultScreenNumber != 0)
       
   352        {
       
   353        INFO_PRINTF2(_L("Failed to Get Default Screen Number, error: %d"), err);
       
   354        SetTestStepResult(EFail);        
       
   355        }      
       
   356        
       
   357    //Comparing expected result and Obtained Result
       
   358    if(expecteddefaultScreenNumber != obtaineddefaultScreenNumber && expecteddefaultScreenNumber != 0)
       
   359        {
       
   360        INFO_PRINTF3(_L("Screen Number doesn't match: expected/obtained Uid: %d/%d"), expecteddefaultScreenNumber, obtaineddefaultScreenNumber);
       
   361        SetTestStepResult(EFail);        
       
   362        }    
       
   363     
       
   364     InfoQuerySubSession.Close();        
       
   365     CleanupStack::PopAndDestroy();
       
   366     }
       
   367     
       
   368 void CSCRGetDefaultScreenNumber::ImplTestStepPostambleL()
       
   369     {
       
   370     CScrTestStep::ImplTestStepPostambleL();
       
   371     }
       
   372 
       
   373 CSCRGetNumberOfDefinedIcons::CSCRGetNumberOfDefinedIcons(CScrTestServer& aParent) : CScrTestStep(aParent)
       
   374     {
       
   375     }
       
   376 
       
   377 void CSCRGetNumberOfDefinedIcons::ImplTestStepPreambleL()
       
   378     {
       
   379     CScrTestStep::ImplTestStepPreambleL();
       
   380     }
       
   381 
       
   382 void CSCRGetNumberOfDefinedIcons::ImplTestStepL()
       
   383     {
       
   384     TUid appUid;
       
   385     TInt obtainedIconcount = 0, expectedIconcount = 0;
       
   386     
       
   387     //Get the Expected Number of App Icons from the ini to compare
       
   388     GetIntFromConfig(ConfigSection(), KLocNumberOfAppIcons, expectedIconcount);
       
   389     GetAppUidL(appUid);
       
   390     RRegistrationInfoForApplication InfoQuerySubSession;    
       
   391     CleanupClosePushL(InfoQuerySubSession);
       
   392     
       
   393     InfoQuerySubSession.OpenL(iScrSession, appUid);
       
   394             
       
   395     TRAPD(err,obtainedIconcount = InfoQuerySubSession.NumberOfOwnDefinedIconsL());
       
   396     
       
   397     if(err != KErrNone && expectedIconcount != 0)
       
   398        {
       
   399        INFO_PRINTF2(_L("Failed to Get Deafult Screen Number, error: %d"), err);
       
   400        SetTestStepResult(EFail);        
       
   401        }      
       
   402        
       
   403     //Comparing expected result and Obtained Result
       
   404     if(expectedIconcount != obtainedIconcount && expectedIconcount != -1)
       
   405        {
       
   406        INFO_PRINTF3(_L("Number of Defined Icons for App doesn't match: expected/obtained Uid: %d/%d"), expectedIconcount, obtainedIconcount);
       
   407        SetTestStepResult(EFail);        
       
   408        } 
       
   409     
       
   410     InfoQuerySubSession.Close();        
       
   411     CleanupStack::PopAndDestroy();
       
   412         
       
   413     }
       
   414     
       
   415 void CSCRGetNumberOfDefinedIcons::ImplTestStepPostambleL()
       
   416     {
       
   417     CScrTestStep::ImplTestStepPostambleL();
       
   418     }
       
   419 
       
   420 CSCRGetApplicationLanguage::CSCRGetApplicationLanguage(CScrTestServer& aParent) : CScrTestStep(aParent)
       
   421     {
       
   422     }
       
   423 
       
   424 void CSCRGetApplicationLanguage::ImplTestStepPreambleL()
       
   425     {
       
   426     CScrTestStep::ImplTestStepPreambleL();
       
   427     }
       
   428 
       
   429 void CSCRGetApplicationLanguage::ImplTestStepL()
       
   430     {
       
   431     TUid appUid;    
       
   432     TInt obtainedCurrentLanguage = 0, expectedCurrentLanguage = 0;
       
   433     
       
   434     //Get the Expected Current application Language from the ini to compare
       
   435     GetIntFromConfig(ConfigSection(), KLocAppLanguage, expectedCurrentLanguage);
       
   436     
       
   437     GetAppUidL(appUid);
       
   438     INFO_PRINTF1(_L("Before subsession creation"));
       
   439 
       
   440     RRegistrationInfoForApplication InfoQuerySubSession;
       
   441     CleanupClosePushL(InfoQuerySubSession);
       
   442     
       
   443     InfoQuerySubSession.OpenL(iScrSession, appUid);
       
   444     
       
   445     TRAPD(err, obtainedCurrentLanguage = (TInt)InfoQuerySubSession.ApplicationLanguageL());
       
   446     
       
   447     if(err != KErrNone && expectedCurrentLanguage != 0)
       
   448        {
       
   449        INFO_PRINTF2(_L("Failed to Get Current App Language, error: %d"), err);
       
   450        SetTestStepResult(EFail);        
       
   451        }      
       
   452        
       
   453     //Comparing expected result and Obtained Result
       
   454     if(expectedCurrentLanguage != obtainedCurrentLanguage && expectedCurrentLanguage != 0)
       
   455        {
       
   456        INFO_PRINTF3(_L("Number of Defined Icons for App doesn't match: expected/obtained Uid: %d/%d"), expectedCurrentLanguage, obtainedCurrentLanguage);
       
   457        SetTestStepResult(EFail);        
       
   458        } 
       
   459         
       
   460     InfoQuerySubSession.Close();     
       
   461     CleanupStack::PopAndDestroy(&InfoQuerySubSession);
       
   462     }
       
   463     
       
   464 void CSCRGetApplicationLanguage::ImplTestStepPostambleL()
       
   465     {
       
   466     CScrTestStep::ImplTestStepPostambleL();
       
   467     }
       
   468 
       
   469 // -----------CScrGetAppOwnedFilesEntryStep-----------------
       
   470 
       
   471 CScrGetAppOwnedFilesEntryStep::CScrGetAppOwnedFilesEntryStep(CScrTestServer& aParent) : CScrTestStep(aParent)
       
   472     {
       
   473     }
       
   474 
       
   475 void CScrGetAppOwnedFilesEntryStep::ImplTestStepPreambleL()
       
   476     {
       
   477     CScrTestStep::ImplTestStepPreambleL();
       
   478     }
       
   479 
       
   480 void CScrGetAppOwnedFilesEntryStep::ImplTestStepL()
       
   481     {
       
   482     INFO_PRINTF1(_L("Get the UID from the ini for which the sub session is to be opened"));
       
   483     TUid  appUid;
       
   484     GetAppUidL(appUid);
       
   485     
       
   486     INFO_PRINTF1(_L("Get the expected App owned files from ini"));
       
   487     RPointerArray<HBufC> appOwnedFilesFromIni;
       
   488     GetAppOwnedFilesL(appOwnedFilesFromIni);
       
   489    
       
   490     INFO_PRINTF1(_L("Open the sub session for the UID"));
       
   491     RRegistrationInfoForApplication AppRegInfoQueryAppSubSession;    
       
   492     TRAPD(sessionerr,AppRegInfoQueryAppSubSession.OpenL(iScrSession,appUid));
       
   493     if(KErrNone != sessionerr)
       
   494            {
       
   495            INFO_PRINTF2(_L("Failed to create the subsession to the SCR server (Error:%d)."), sessionerr);
       
   496            User::Leave(sessionerr);
       
   497            }    
       
   498     
       
   499     INFO_PRINTF1(_L("Retrieving the App Owned Files form db."));
       
   500     RPointerArray<HBufC> appOwnedFilesArray;     
       
   501     TInt err = KErrNone;
       
   502     TRAP(err, AppRegInfoQueryAppSubSession.GetAppOwnedFilesL(appOwnedFilesArray));
       
   503     if(KErrNone == err)
       
   504         {
       
   505         INFO_PRINTF1(_L("Comparing the retrieved AppOwned files with the expected files within the ini"));
       
   506         if(CompareAppOwnedFileNamesL(appOwnedFilesArray,appOwnedFilesFromIni))
       
   507             SetTestStepResult(EPass);
       
   508         else
       
   509             SetTestStepResult(EFail);
       
   510         }
       
   511     else
       
   512         {
       
   513         appOwnedFilesArray.ResetAndDestroy();    
       
   514         appOwnedFilesFromIni.ResetAndDestroy();
       
   515         AppRegInfoQueryAppSubSession.Close();
       
   516         User::Leave(err);
       
   517         }               
       
   518    
       
   519     //closing the resource handles
       
   520     appOwnedFilesArray.ResetAndDestroy();    
       
   521     appOwnedFilesFromIni.ResetAndDestroy();
       
   522     AppRegInfoQueryAppSubSession.Close();
       
   523     }
       
   524     
       
   525 TBool CScrGetAppOwnedFilesEntryStep::CompareAppOwnedFileNamesL(RPointerArray<HBufC>& aActualValue,RPointerArray<HBufC>& aExpetedValue)
       
   526     {
       
   527     TInt expectedCount = aExpetedValue.Count();
       
   528     TInt actualCount = aActualValue.Count();
       
   529     TBool result = ETrue;
       
   530     if(  expectedCount != actualCount )
       
   531         return EFalse;
       
   532         
       
   533     for(TInt i = 0 ; i < actualCount ; i++)            
       
   534         {
       
   535         if(!aExpetedValue.Find(aActualValue[i]))
       
   536              {
       
   537              result = EFalse;
       
   538              break;
       
   539              }
       
   540         }
       
   541     
       
   542     return result;
       
   543     }
       
   544 
       
   545 void CScrGetAppOwnedFilesEntryStep::ImplTestStepPostambleL()
       
   546     {
       
   547     CScrTestStep::ImplTestStepPostambleL();
       
   548     }
       
   549 
       
   550 
       
   551 
       
   552 // -----------CScrGetAppCharacteristicsEntryStep-----------------
       
   553 
       
   554 CScrGetAppCharacteristicsEntryStep::CScrGetAppCharacteristicsEntryStep(CScrTestServer& aParent) : CScrTestStep(aParent)
       
   555     {
       
   556     }
       
   557 
       
   558 void CScrGetAppCharacteristicsEntryStep::ImplTestStepPreambleL()
       
   559     {
       
   560     CScrTestStep::ImplTestStepPreambleL();    
       
   561     }
       
   562 
       
   563 void CScrGetAppCharacteristicsEntryStep::ImplTestStepL()
       
   564     {
       
   565     INFO_PRINTF1(_L("Get the UID from the ini for which the sub session is to be opened"));
       
   566     TUid  appUid;
       
   567     GetAppUidL(appUid);
       
   568     
       
   569     INFO_PRINTF1(_L("Get the expected capabilty for an app from ini"));
       
   570     TInt attributes, hidden, embeddability, newFile, launch;
       
   571     TPtrC groupName;
       
   572     if(GetIntFromConfig(ConfigSection(), _L("Attributes"), attributes) == EFalse)
       
   573         PrintErrorL(_L("AppUid was not found!"), KErrNotFound);
       
   574     if(GetIntFromConfig(ConfigSection(), _L("Hidden"), hidden) == EFalse)
       
   575         PrintErrorL(_L("AppUid was not found!"), KErrNotFound);
       
   576     if(GetIntFromConfig(ConfigSection(), _L("Embeddability"), embeddability) == EFalse)
       
   577         PrintErrorL(_L("AppUid was not found!"), KErrNotFound);
       
   578     if(GetIntFromConfig(ConfigSection(), _L("NewFile"), newFile) == EFalse)
       
   579         PrintErrorL(_L("AppUid was not found!"), KErrNotFound);
       
   580     if(GetIntFromConfig(ConfigSection(), _L("Launch"), launch) == EFalse)
       
   581         PrintErrorL(_L("AppUid was not found!"), KErrNotFound);
       
   582     GetStringFromConfig(ConfigSection(), _L("GroupName"), groupName);
       
   583     
       
   584     INFO_PRINTF1(_L("Open the sub session for the UID"));
       
   585     RRegistrationInfoForApplication AppRegInfoQueryAppSubSession;
       
   586     TRAPD(sessionerr,AppRegInfoQueryAppSubSession.OpenL(iScrSession,appUid));
       
   587     if(KErrNone != sessionerr)
       
   588                {
       
   589                INFO_PRINTF2(_L("Failed to create the subsession to the SCR server (Error:%d)."), sessionerr);
       
   590                User::Leave(sessionerr);
       
   591                }    
       
   592     
       
   593     INFO_PRINTF1(_L("Retrieving characteristics for an app form db."));
       
   594     Usif::TApplicationCharacteristics appCharacteristics ;
       
   595     TInt err = KErrNone;
       
   596     TRAP(err, AppRegInfoQueryAppSubSession.GetAppCharacteristicsL(appCharacteristics));
       
   597     if(KErrNone ==err)
       
   598         {
       
   599         INFO_PRINTF1(_L("Comparing the retrieved App characteristics with the expected app characteristics within the ini"));
       
   600   
       
   601         if(appCharacteristics.iEmbeddability != embeddability || appCharacteristics.iAppIsHidden != hidden || appCharacteristics.iSupportsNewFile != newFile || appCharacteristics.iLaunchInBackground != launch || appCharacteristics.iGroupName.Compare(groupName))
       
   602             SetTestStepResult(EFail);   
       
   603         else
       
   604             SetTestStepResult(EPass);
       
   605         }
       
   606     else
       
   607         {
       
   608         AppRegInfoQueryAppSubSession.Close();        
       
   609         User::Leave(err);
       
   610         }  
       
   611     //closing the resource handles    
       
   612     AppRegInfoQueryAppSubSession.Close();
       
   613     }
       
   614     
       
   615 
       
   616 void CScrGetAppCharacteristicsEntryStep::ImplTestStepPostambleL()
       
   617     {
       
   618     CScrTestStep::ImplTestStepPostambleL();    
       
   619     }
       
   620 
       
   621 
       
   622 // -----------CScrGetAppIconFileNameEntryStep-----------------
       
   623 
       
   624 CScrGetAppIconEntryStep::CScrGetAppIconEntryStep(CScrTestServer& aParent) : CScrTestStep(aParent)
       
   625     {
       
   626     }
       
   627 
       
   628 void CScrGetAppIconEntryStep::ImplTestStepPreambleL()
       
   629     {
       
   630     CScrTestStep::ImplTestStepPreambleL();    
       
   631     }
       
   632 
       
   633 void CScrGetAppIconEntryStep::ImplTestStepL()
       
   634     {        
       
   635     TVerdict result = EFail;
       
   636     INFO_PRINTF1(_L("Get the UID from the ini for which the sub session is to be opened"));
       
   637     TUid  appUid;
       
   638     GetAppUidL(appUid);
       
   639     
       
   640     INFO_PRINTF1(_L("Get the expected filename of the Icon for an app from ini"));
       
   641     TPtrC IconFileName;
       
   642     if(GetStringFromConfig(ConfigSection(), _L("LocIconFileName"), IconFileName) == EFalse)
       
   643             {           
       
   644             PrintErrorL(_L("AppUid was not found!"), KErrNotFound);
       
   645             }
       
   646     
       
   647     INFO_PRINTF1(_L("Open the sub session for the UID"));
       
   648     RRegistrationInfoForApplication AppRegInfoQueryAppSubSession;
       
   649     TRAPD(sessionerr,AppRegInfoQueryAppSubSession.OpenL(iScrSession,appUid));
       
   650     if(KErrNone != sessionerr)
       
   651             {
       
   652             INFO_PRINTF2(_L("Failed to create the subsession to the SCR server (Error:%d)."), sessionerr);
       
   653             User::Leave(sessionerr);
       
   654             }      
       
   655     
       
   656     
       
   657     HBufC* filename = NULL;        
       
   658     INFO_PRINTF1(_L("Retrieving the Icon for an app form db."));
       
   659    
       
   660     TInt err = KErrNotFound;
       
   661     TRAP(err, AppRegInfoQueryAppSubSession.GetAppIconL(filename));    
       
   662     if(KErrNone == err)
       
   663       {
       
   664       INFO_PRINTF1(_L("Comparing the retrieved App Icon with the expected app capability within the ini"));               
       
   665             if(!IconFileName.Compare(*filename))
       
   666             {
       
   667             result = EPass;            
       
   668             }            
       
   669        }
       
   670     else
       
   671       {
       
   672       if(NULL != filename)
       
   673           delete filename;
       
   674       AppRegInfoQueryAppSubSession.Close();      
       
   675       User::Leave(err);
       
   676       }     
       
   677        
       
   678   
       
   679     SetTestStepResult(result);   
       
   680     if(NULL != filename)
       
   681         delete filename;
       
   682     
       
   683     //closing the resource handles    
       
   684     AppRegInfoQueryAppSubSession.Close(); 
       
   685     }
       
   686     
       
   687 
       
   688 void CScrGetAppIconEntryStep::ImplTestStepPostambleL()
       
   689     {
       
   690     CScrTestStep::ImplTestStepPostambleL();    
       
   691     }
       
   692 
       
   693 
       
   694 // -----------CScrGetAppViewIconEntryStep-----------------
       
   695 
       
   696 CScrGetAppViewIconEntryStep::CScrGetAppViewIconEntryStep(CScrTestServer& aParent) : CScrTestStep(aParent)
       
   697     {
       
   698     }
       
   699 
       
   700 void CScrGetAppViewIconEntryStep::ImplTestStepPreambleL()
       
   701     {
       
   702     CScrTestStep::ImplTestStepPreambleL();    
       
   703     }
       
   704 
       
   705 void CScrGetAppViewIconEntryStep::ImplTestStepL()
       
   706     {
       
   707     INFO_PRINTF1(_L("Get the App UID and View Uid from the ini for which the sub session is to be opened"));
       
   708     TUid  appUid;
       
   709     TInt viewUid;
       
   710     GetAppUidL(appUid);
       
   711     
       
   712     if(GetIntFromConfig(ConfigSection(), _L("VwUid"), viewUid) == EFalse)
       
   713         {
       
   714         PrintErrorL(_L("View Uid was not found!"), KErrNotFound);
       
   715         }
       
   716     
       
   717     INFO_PRINTF1(_L("Get the expected filename of the View Icon for an app from ini"));
       
   718     TPtrC appFileName; 
       
   719     if(GetStringFromConfig(ConfigSection(), _L("VwIconFileName"), appFileName)== EFalse)
       
   720        {
       
   721        PrintErrorL(_L("View Icon file Name was not found!"), KErrNotFound);
       
   722        }
       
   723     
       
   724     INFO_PRINTF1(_L("Open the sub session for the UID"));
       
   725     RRegistrationInfoForApplication AppRegInfoQueryAppSubSession;
       
   726     TRAPD(sessionerr,AppRegInfoQueryAppSubSession.OpenL(iScrSession,appUid));
       
   727     if(KErrNone != sessionerr)
       
   728           {
       
   729           INFO_PRINTF2(_L("Failed to create the subsession to the SCR server (Error:%d)."), sessionerr);
       
   730           User::Leave(sessionerr);
       
   731           }    
       
   732     
       
   733     INFO_PRINTF1(_L("Retrieving the view icon file for an app form db."));   
       
   734     
       
   735     HBufC* filename = NULL;     
       
   736     TUid viewId = TUid::Uid(viewUid);
       
   737     
       
   738     TInt err = KErrNotFound;
       
   739     TRAP(err, AppRegInfoQueryAppSubSession.GetAppViewIconL(viewId,filename));
       
   740     if(KErrNone == err)
       
   741         {
       
   742         INFO_PRINTF1(_L("Comparing the retrieved view icon file with the expected view icon file within the ini"));
       
   743        
       
   744         if(!appFileName.Compare(*filename))
       
   745             {
       
   746             SetTestStepResult(EPass);           
       
   747             }
       
   748         else
       
   749             {
       
   750             SetTestStepResult(EFail);    
       
   751             }
       
   752         }
       
   753     else
       
   754         {
       
   755         if(NULL != filename)
       
   756             delete filename;        
       
   757         AppRegInfoQueryAppSubSession.Close();
       
   758         User::Leave(err);
       
   759         }
       
   760     if(NULL != filename)
       
   761         delete filename; 
       
   762     //closing the resource handles    
       
   763     AppRegInfoQueryAppSubSession.Close();
       
   764     }
       
   765     
       
   766 
       
   767 void CScrGetAppViewIconEntryStep::ImplTestStepPostambleL()
       
   768     {
       
   769     CScrTestStep::ImplTestStepPostambleL();    
       
   770     }
       
   771 
       
   772 
       
   773 // -----------CScrGetAppViewsStep-----------------
       
   774 
       
   775 CScrGetAppViewsStep::CScrGetAppViewsStep(CScrTestServer& aParent) : CScrTestStep(aParent)
       
   776     {
       
   777     }
       
   778 
       
   779 void CScrGetAppViewsStep::ImplTestStepPreambleL()
       
   780     {
       
   781     CScrTestStep::ImplTestStepPreambleL();
       
   782     }
       
   783 
       
   784 void CScrGetAppViewsStep::ImplTestStepL()
       
   785     {
       
   786     TUid appUid;    
       
   787     GetAppUidL(appUid);
       
   788     RPointerArray<Usif::CAppViewData> appViewInfoArrayExpected;
       
   789     CleanupResetAndDestroyPushL(appViewInfoArrayExpected);
       
   790     GetViewDataInfoFromConfigL(appViewInfoArrayExpected);
       
   791         
       
   792     RPointerArray<Usif::CAppViewData> appViewInfoArrayRetrieved;
       
   793     CleanupResetAndDestroyPushL(appViewInfoArrayRetrieved);   
       
   794       
       
   795     RRegistrationInfoForApplication infoQuerySubSession;
       
   796     CleanupClosePushL(infoQuerySubSession); 
       
   797             
       
   798     infoQuerySubSession.OpenL(iScrSession, appUid);
       
   799     
       
   800     // Start timer just before invocation of SCR API
       
   801     StartTimer();
       
   802     infoQuerySubSession.GetAppViewsL(appViewInfoArrayRetrieved);
       
   803             
       
   804     if(appViewInfoArrayExpected.Count()!=appViewInfoArrayRetrieved.Count())
       
   805         {
       
   806         ERR_PRINTF1(_L("Returned view data entry count doesnt match the expected count")); 
       
   807         SetTestStepResult(EFail);
       
   808         }
       
   809     else
       
   810         {
       
   811         for(TInt i=0;i<appViewInfoArrayExpected.Count();i++)
       
   812                 {
       
   813                 const CCaptionAndIconInfo *captionAndIconInfoExpected = appViewInfoArrayExpected[i]->CaptionAndIconInfo();
       
   814                 const CCaptionAndIconInfo *captionAndIconInfoRetrieved = appViewInfoArrayRetrieved[i]->CaptionAndIconInfo();
       
   815                 if((appViewInfoArrayExpected[i]->Uid()!= appViewInfoArrayRetrieved[i]->Uid())||(appViewInfoArrayExpected[i]->ScreenMode()!= appViewInfoArrayRetrieved[i]->ScreenMode())||(NotEqual(captionAndIconInfoExpected, captionAndIconInfoRetrieved)))  
       
   816                     {
       
   817                     ERR_PRINTF1(_L("Returned view data entry values don't match with the expected ones."));
       
   818                     SetTestStepResult(EFail);
       
   819                     }
       
   820                 else
       
   821                     {
       
   822                     INFO_PRINTF2(_L("View details associated with view data entry %d"), i);
       
   823                     INFO_PRINTF3(_L("ViewData Expected: Uid-%d, ScreenMode-%d"), (appViewInfoArrayExpected[i]->Uid()).iUid, appViewInfoArrayExpected[i]->ScreenMode());
       
   824                     INFO_PRINTF3(_L("ViewData Retrieved: Uid-%d, ScreenMode-%d"), (appViewInfoArrayRetrieved[i]->Uid()).iUid, appViewInfoArrayRetrieved[i]->ScreenMode());
       
   825                     if(captionAndIconInfoExpected!=NULL)
       
   826                         {
       
   827                         INFO_PRINTF4(_L("Associated caption details Expected: Caption-%S, No.of Icons-%d, IconFilename-%S"),&(captionAndIconInfoExpected->Caption()), captionAndIconInfoExpected->NumOfAppIcons(), &(captionAndIconInfoExpected->IconFileName()));
       
   828                         INFO_PRINTF4(_L("Associated caption details Retrieved: Caption-%S, No.of Icons-%d, IconFilename-%S"), &(captionAndIconInfoRetrieved->Caption()), captionAndIconInfoRetrieved->NumOfAppIcons(), &(captionAndIconInfoRetrieved->IconFileName()));
       
   829                         }
       
   830                     else
       
   831                         {
       
   832                         INFO_PRINTF1(_L("No expected caption and icon info. No retrieved caption and icon info."));
       
   833                         }
       
   834                     }
       
   835                 }
       
   836             }    
       
   837             infoQuerySubSession.Close();
       
   838             CleanupStack::PopAndDestroy(1, &infoQuerySubSession); 
       
   839             CleanupStack::Pop(2,&appViewInfoArrayExpected); 
       
   840             appViewInfoArrayRetrieved.ResetAndDestroy();
       
   841             appViewInfoArrayExpected.ResetAndDestroy();
       
   842             
       
   843         }
       
   844     
       
   845 void CScrGetAppViewsStep::ImplTestStepPostambleL()
       
   846     {
       
   847     CScrTestStep::ImplTestStepPostambleL();
       
   848     }
       
   849 
       
   850 
       
   851 // -----------CScrGetAppServiceInfoStep-----------------
       
   852 
       
   853 CScrGetAppServiceInfoStep::CScrGetAppServiceInfoStep(CScrTestServer& aParent) : CScrTestStep(aParent)
       
   854     {
       
   855     }
       
   856 
       
   857 void CScrGetAppServiceInfoStep::ImplTestStepPreambleL()
       
   858     {
       
   859     CScrTestStep::ImplTestStepPreambleL();
       
   860     }
       
   861 
       
   862 void CScrGetAppServiceInfoStep::ImplTestStepL()
       
   863     {
       
   864     RApplicationRegistrationInfo infoQuerySubSession;
       
   865     CleanupClosePushL(infoQuerySubSession);
       
   866     infoQuerySubSession.OpenL(iScrSession);    
       
   867     
       
   868     TUid serviceUid, appUid;      
       
   869     RPointerArray<Usif::CServiceInfo> appServiceInfoArrayExpected;
       
   870     CleanupResetAndDestroyPushL(appServiceInfoArrayExpected);
       
   871                
       
   872     RPointerArray<Usif::CServiceInfo> appServiceInfoArrayRetrieved;
       
   873     CleanupResetAndDestroyPushL(appServiceInfoArrayRetrieved);   
       
   874 
       
   875     CAppServiceInfoFilter* appServiceInfoFilter = CAppServiceInfoFilter::NewLC();
       
   876     
       
   877     TInt filterToSet(0);
       
   878     if (!GetIntFromConfig(ConfigSection(), _L("FilterToSet"), filterToSet))
       
   879         PrintErrorL(_L("Filter to be set was not found!"), KErrNotFound);
       
   880     
       
   881     switch(filterToSet)
       
   882         {
       
   883         case 1:
       
   884             {
       
   885             
       
   886             //Testing GetAppServiceInfo given the appUid
       
   887             if (!GetUidFromConfig(ConfigSection(), _L("AppUid"), appUid))
       
   888                 PrintErrorL(_L("AppUid was not found!"), KErrNotFound);
       
   889             INFO_PRINTF2(_L("AppUid is 0x%x"), appUid.iUid);
       
   890             
       
   891             appServiceInfoFilter->SetAppUidForServiceInfo(appUid);
       
   892             
       
   893             GetAppServiceInfoL(appServiceInfoArrayExpected);
       
   894             
       
   895             infoQuerySubSession.GetServiceInfoL(appServiceInfoFilter, appServiceInfoArrayRetrieved);
       
   896             break;
       
   897             }
       
   898         case 2:
       
   899             {
       
   900             //Testing GetAppServiceInfo given the serviceUid
       
   901            
       
   902             if(!GetUidFromConfig(ConfigSection(), _L("ServiceUid"), serviceUid))
       
   903                 PrintErrorL(_L("ServiceUid was not found!"), KErrNotFound);            
       
   904             INFO_PRINTF2(_L("ServiceUid is 0x%x"), serviceUid.iUid);
       
   905             
       
   906             appServiceInfoFilter->SetServiceUidForServiceImplementations(serviceUid);
       
   907             
       
   908             GetAppServiceInfoL(appServiceInfoArrayExpected);
       
   909                                     
       
   910             infoQuerySubSession.GetServiceInfoL(appServiceInfoFilter, appServiceInfoArrayRetrieved);
       
   911             break;
       
   912             }
       
   913         case 3:
       
   914             {
       
   915             //Testing GetAppServiceInfo given the serviceUid and dataType
       
   916             TPtrC dataType;
       
   917             if (!GetUidFromConfig(ConfigSection(), _L("ServiceUid"), serviceUid))
       
   918                 PrintErrorL(_L("ServiceUid was not found!"), KErrNotFound);            
       
   919             INFO_PRINTF2(_L("ServiceUid is 0x%x"), serviceUid.iUid);
       
   920             
       
   921             if(!GetStringFromConfig(ConfigSection(), _L("ServiceDataType"), dataType))
       
   922                 PrintErrorL(_L("DataType was not found!"), KErrNotFound);
       
   923             INFO_PRINTF2(_L("DataType is %S"), &dataType);
       
   924             
       
   925             appServiceInfoFilter->SetServiceUidAndDatatTypeForServiceImplementationsL(serviceUid, dataType);
       
   926             
       
   927             GetAppServiceInfoL(appServiceInfoArrayExpected);
       
   928             
       
   929             infoQuerySubSession.GetServiceInfoL(appServiceInfoFilter, appServiceInfoArrayRetrieved);
       
   930             break;
       
   931             }
       
   932         case 4:
       
   933             {
       
   934             //Testing GetAppServiceInfo given the appUid and serviceUid
       
   935             if (!GetUidFromConfig(ConfigSection(), _L("AppUid"), appUid))
       
   936                 PrintErrorL(_L("AppUid was not found!"), KErrNotFound);
       
   937             INFO_PRINTF2(_L("AppUid is 0x%x"), appUid.iUid);
       
   938             
       
   939             if (!GetUidFromConfig(ConfigSection(), _L("ServiceUid"), serviceUid))
       
   940                 PrintErrorL(_L("ServiceUid was not found!"), KErrNotFound);            
       
   941             INFO_PRINTF2(_L("ServiceUid is 0x%x"), serviceUid.iUid);
       
   942             
       
   943             appServiceInfoFilter->SetAppUidAndServiceUidForOpaqueData(appUid, serviceUid);
       
   944             
       
   945             GetAppServiceInfoL(appServiceInfoArrayExpected);
       
   946             
       
   947             infoQuerySubSession.GetServiceInfoL(appServiceInfoFilter, appServiceInfoArrayRetrieved);
       
   948             break;
       
   949             }
       
   950         default:
       
   951             ERR_PRINTF1(_L("Incorrect value for filterToSet, values range from 1-4"));
       
   952             SetTestStepResult(EFail);
       
   953             break;
       
   954         }
       
   955     
       
   956     //check if they r equal
       
   957     if(NotEqualL(appServiceInfoArrayExpected, appServiceInfoArrayRetrieved))
       
   958         {
       
   959         ERR_PRINTF1(_L("Returned service data entry doesnt match the expected values")); 
       
   960         SetTestStepResult(EFail);
       
   961         }
       
   962     
       
   963     //clean up
       
   964     CleanupStack::PopAndDestroy(4,&infoQuerySubSession); //appServiceInfoFilter, appServiceInfoArrayRetrieved, appServiceInfoArrayExpected, infoQuerySubSession 
       
   965     }
       
   966     
       
   967 void CScrGetAppServiceInfoStep::ImplTestStepPostambleL()
       
   968     {
       
   969     CScrTestStep::ImplTestStepPostambleL();
       
   970     }
       
   971 
       
   972 
       
   973 // -----------CScrGetComponentIdForApp-----------------
       
   974 
       
   975 CScrGetComponentIdForApp::CScrGetComponentIdForApp(CScrTestServer& aParent) : CScrTestStep(aParent)
       
   976     {
       
   977     }
       
   978 
       
   979 void CScrGetComponentIdForApp::ImplTestStepPreambleL()
       
   980     {
       
   981     CScrTestStep::ImplTestStepPreambleL();
       
   982     }
       
   983 
       
   984 void CScrGetComponentIdForApp::ImplTestStepL()
       
   985     {
       
   986     TUid appUid;
       
   987     CGlobalComponentId *globalId = GetGlobalComponentIdLC();
       
   988     TComponentId expectedCompId, retrievedCompId;
       
   989     if (!GetUidFromConfig(ConfigSection(), _L("AppUid"), appUid))
       
   990         PrintErrorL(_L("AppUid was not found!"), KErrNotFound);
       
   991     
       
   992     //Given the GlobalIdName and software type of the component anticipated, fetch the value of the expected ComponentId value.
       
   993     expectedCompId = iScrSession.GetComponentIdL(globalId->GlobalIdName(), globalId->SoftwareTypeName());    
       
   994     CleanupStack::PopAndDestroy(globalId);
       
   995 
       
   996     //Fetch the ComponentId associated to the given App.
       
   997     retrievedCompId = iScrSession.GetComponentIdForAppL(appUid);
       
   998     
       
   999     INFO_PRINTF3(_L("Retrieved ComponentId is %d, and Expected componentId is %d "), retrievedCompId, expectedCompId);
       
  1000     if(retrievedCompId != expectedCompId)
       
  1001         {
       
  1002         ERR_PRINTF1(_L("Retrieved componentId  doesnot match the expected values")); 
       
  1003         SetTestStepResult(EFail);
       
  1004         }
       
  1005     }
       
  1006     
       
  1007 void CScrGetComponentIdForApp::ImplTestStepPostambleL()
       
  1008     {
       
  1009     CScrTestStep::ImplTestStepPostambleL();
       
  1010     }
       
  1011 
       
  1012 
       
  1013 // -----------CScrGetAppUidsForComponent-----------------
       
  1014 
       
  1015 CScrGetAppUidsForComponent::CScrGetAppUidsForComponent(CScrTestServer& aParent) : CScrTestStep(aParent)
       
  1016     {
       
  1017     }
       
  1018 
       
  1019 void CScrGetAppUidsForComponent::ImplTestStepPreambleL()
       
  1020     {
       
  1021     CScrTestStep::ImplTestStepPreambleL();
       
  1022     }
       
  1023 
       
  1024 void CScrGetAppUidsForComponent::ImplTestStepL()
       
  1025     {
       
  1026     TComponentId compId;
       
  1027     TInt appCount = 0;
       
  1028     RArray<TUid> expectedAppUid, retrievedAppUid;
       
  1029     CleanupClosePushL(expectedAppUid);
       
  1030     CleanupClosePushL(retrievedAppUid);
       
  1031     TUid appUid;
       
  1032     TBuf<20> appUidTxt;
       
  1033     CGlobalComponentId *globalId = GetGlobalComponentIdLC();
       
  1034     
       
  1035     //Given the GlobalIdName and software type of the component, fetch the value of the componentId value whose associated apps have to be subsequently fetched.
       
  1036     compId = iScrSession.GetComponentIdL(globalId->GlobalIdName(), globalId->SoftwareTypeName());
       
  1037     CleanupStack::PopAndDestroy(globalId);
       
  1038 
       
  1039     if (!GetIntFromConfig(ConfigSection(), _L("AppCount"), appCount))
       
  1040         PrintErrorL(_L("AppCount was not found!"), KErrNotFound);
       
  1041   
       
  1042     for(TInt i=0; i<appCount; i++)
       
  1043         {
       
  1044         appUidTxt = KAppUid; 
       
  1045         GenerateIndexedAttributeNameL(appUidTxt, i);
       
  1046         if(!GetUidFromConfig(ConfigSection(), appUidTxt, appUid))
       
  1047             PrintErrorL(_L("%S was not found!"), KErrNotFound, &appUidTxt);
       
  1048         expectedAppUid.AppendL(appUid);
       
  1049         }
       
  1050     
       
  1051     //Get the apps associated to the given componentId.
       
  1052     INFO_PRINTF2(_L("Fetching apps asssociated to ComponentId %d"), compId);
       
  1053     iScrSession.GetAppUidsForComponentL(compId, retrievedAppUid);
       
  1054     if(expectedAppUid.Count()!= retrievedAppUid.Count())
       
  1055         {
       
  1056         ERR_PRINTF1(_L("Count of the retrieved appUids doesnt match the expected count")); 
       
  1057         SetTestStepResult(EFail);
       
  1058         }
       
  1059     retrievedAppUid.SortSigned();
       
  1060     expectedAppUid.SortSigned();
       
  1061     
       
  1062     for(TInt i=0; i<expectedAppUid.Count();i++)
       
  1063         {
       
  1064         if(retrievedAppUid[i].iUid != expectedAppUid[i].iUid)
       
  1065             {
       
  1066             ERR_PRINTF3(_L("Mismatch in expected and retrieved AppUids! Expected Uid: %d, Retrieved Uid: %d"), expectedAppUid[i].iUid, retrievedAppUid[i].iUid); 
       
  1067             SetTestStepResult(EFail);
       
  1068             break;
       
  1069             }
       
  1070         }
       
  1071     
       
  1072     CleanupStack::PopAndDestroy(2, &expectedAppUid);     //retrievedAppUid, expectedAppUid     
       
  1073     }
       
  1074     
       
  1075 void CScrGetAppUidsForComponent::ImplTestStepPostambleL()
       
  1076     {
       
  1077     CScrTestStep::ImplTestStepPostambleL();
       
  1078     }
       
  1079 
       
  1080 // -----------CScrAddConcurrentApplicationEntryStep-----------------
       
  1081 
       
  1082 CScrAddConcurrentApplicationEntryStep::CScrAddConcurrentApplicationEntryStep(CScrTestServer& aParent) : CScrTestStep(aParent)
       
  1083     {
       
  1084     }
       
  1085 
       
  1086 void CScrAddConcurrentApplicationEntryStep::ImplTestStepPreambleL()
       
  1087     {
       
  1088     CScrTestStep::ImplTestStepPreambleL();
       
  1089     }
       
  1090 
       
  1091 void CScrAddConcurrentApplicationEntryStep::ImplTestStepL()
       
  1092     {
       
  1093     TBool isSimultaneousCreateTransaction = EFalse;
       
  1094     TBool isSimultaneousWriteReadAppInfoSameSession = EFalse;
       
  1095     TBool isSimultaneousWriteAppInfoDiffSession = EFalse;
       
  1096     TBool isSimultaneousReadAppInfoDiffSessionWithoutTransaction = EFalse;
       
  1097         
       
  1098     GetBoolFromConfig(ConfigSection(), _L("SimultaneousCreateTransaction"), isSimultaneousCreateTransaction);
       
  1099     GetBoolFromConfig(ConfigSection(), _L("SimultaneousWriteReadAppInfoSameSession"), isSimultaneousWriteReadAppInfoSameSession);
       
  1100     GetBoolFromConfig(ConfigSection(), _L("SimultaneousWriteAppInfoDiffSession"), isSimultaneousWriteAppInfoDiffSession);
       
  1101     GetBoolFromConfig(ConfigSection(), _L("SimultaneousReadAppInfoDiffSessionWithoutTransaction"), isSimultaneousReadAppInfoDiffSessionWithoutTransaction);
       
  1102     
       
  1103     Usif::RSoftwareComponentRegistry scrSession1, scrSession2;    
       
  1104     TBool newComponentAdded(EFalse);
       
  1105     // connect to the SCR
       
  1106     scrSession1.Connect();
       
  1107     scrSession2.Connect();
       
  1108         
       
  1109     if(isSimultaneousCreateTransaction)
       
  1110         {         
       
  1111         // Create two transactions using two diffrent Scr Sessions, transactrion creation for 
       
  1112         // second scr session will fail( KErrScrWriteOperationInProgress)
       
  1113         TRAPD(err, scrSession1.CreateTransactionL());
       
  1114         if(KErrNone != err)
       
  1115             {
       
  1116             INFO_PRINTF2(_L("Failed to Create Transaction , error: %d"), err);
       
  1117             SetTestStepResult(EFail);        
       
  1118             }
       
  1119         else
       
  1120             {
       
  1121             //it will fail with KErrScrWriteOperationInProgress since two simultaneous transactions are not allowed.
       
  1122             scrSession2.CreateTransactionL();            
       
  1123             }
       
  1124         }
       
  1125     else if(isSimultaneousWriteReadAppInfoSameSession)
       
  1126         {        
       
  1127         //Create a transaction for the scr session , add the application info, then using the same scr session
       
  1128         //create a subsession to read the app Info, will successfuly read the app info(fron SCR Journal)
       
  1129         TComponentId compId = 0;        
       
  1130         CAppInfoFilter* appinfoFilter=NULL ;
       
  1131         TBool isMultiApp(EFalse);
       
  1132         
       
  1133         // Create transaction 
       
  1134         TRAPD(err, scrSession1.CreateTransactionL());
       
  1135         if(KErrNone != err)
       
  1136             {
       
  1137             INFO_PRINTF2(_L("Failed to Create Transaction , error: %d"), err);
       
  1138             SetTestStepResult(EFail);        
       
  1139             }
       
  1140         
       
  1141         //WRITE INTO THE DB(Add App Info)
       
  1142         GetBoolFromConfig(ConfigSection(), _L("IsMultiApp"), isMultiApp);
       
  1143         if (isMultiApp)
       
  1144             {
       
  1145             INFO_PRINTF1(_L("Checking if the component is already present"));
       
  1146             CGlobalComponentId *globalId = GetGlobalComponentIdLC();
       
  1147             TRAP_IGNORE(compId = iScrSession.GetComponentIdL(globalId->GlobalIdName(), globalId->SoftwareTypeName()););
       
  1148             CleanupStack::PopAndDestroy(globalId);
       
  1149             }
       
  1150         
       
  1151         // Try adding the app to a component. The add operation will fail if the component is not present.
       
  1152         if (!compId) 
       
  1153             {
       
  1154             if (GetIntFromConfig(ConfigSection(), _L("UseComponentId"), compId))
       
  1155                 INFO_PRINTF2(_L("Adding a new AppRegInfo to component %d"), compId);
       
  1156             }
       
  1157         
       
  1158         // The component is not present already
       
  1159         if (!compId)   
       
  1160             {
       
  1161             INFO_PRINTF1(_L("Adding a new component."));
       
  1162             compId = AddNonLocalisableComponentL(iScrSession);
       
  1163             newComponentAdded = ETrue;
       
  1164             }
       
  1165         
       
  1166         INFO_PRINTF1(_L("Get reg info from config file."));
       
  1167         const CApplicationRegistrationData* appRegData = GetAppRegInfoFromConfigLC();
       
  1168         TRAP(err, scrSession1.AddApplicationEntryL(compId, *appRegData));  
       
  1169         if(KErrNone != err)
       
  1170            {
       
  1171            INFO_PRINTF2(_L("Failed to Create Transaction , error: %d"), err);
       
  1172            SetTestStepResult(EFail); 
       
  1173            if (newComponentAdded)
       
  1174                {
       
  1175                // We are going to delete the component with no apps
       
  1176                scrSession1.DeleteComponentL(compId);
       
  1177                }
       
  1178            }
       
  1179 
       
  1180         INFO_PRINTF1(_L("Read appinfo filter from configuration"));
       
  1181         TRAP(err, ReadAppInfoFilterFromConfigL(&appinfoFilter));
       
  1182         if (KErrNotFound==err)
       
  1183             {
       
  1184             delete appinfoFilter;
       
  1185             appinfoFilter=NULL;
       
  1186             }
       
  1187         
       
  1188         //READ FROM th DB the AppRegInfo
       
  1189         RApplicationInfoView  subSession;
       
  1190         CleanupClosePushL(subSession);
       
  1191         subSession.OpenViewL(scrSession1,appinfoFilter);
       
  1192         if(appinfoFilter)
       
  1193                 delete appinfoFilter;
       
  1194         
       
  1195         RPointerArray<Usif::TAppRegInfo> appRegInfoSet;               
       
  1196         subSession.GetNextAppInfoL(5, appRegInfoSet);                      
       
  1197         
       
  1198         //No Need To Commit The Transaction as we only need to check whether we can read while the transaction(Write) is Alive.
       
  1199         
       
  1200         appRegInfoSet.ResetAndDestroy();
       
  1201         CleanupStack::PopAndDestroy(&subSession);        
       
  1202         CleanupStack::Pop();
       
  1203         delete appRegData;
       
  1204         }
       
  1205     
       
  1206     else if(isSimultaneousWriteAppInfoDiffSession)
       
  1207         {
       
  1208         //Using two scr sessions ,create a transaction for only the first scr session(because creation of transaction for the second will result into an error)
       
  1209         //, add the application info using both the scr sessions ,the second addition will result into an error( KErrScrWriteOperationInProgress) 
       
  1210         TComponentId compId = 0;             
       
  1211         TBool isMultiApp(EFalse);
       
  1212         
       
  1213         // Create transaction 
       
  1214         TRAPD(err, scrSession1.CreateTransactionL());
       
  1215         if(KErrNone != err)
       
  1216             {
       
  1217             INFO_PRINTF2(_L("Failed to Create Transaction , error: %d"), err);
       
  1218             SetTestStepResult(EFail);        
       
  1219             }
       
  1220         
       
  1221         //WRITE INTO THE DB(Add App Info)
       
  1222         GetBoolFromConfig(ConfigSection(), _L("IsMultiApp"), isMultiApp);
       
  1223         if (isMultiApp)
       
  1224             {
       
  1225             INFO_PRINTF1(_L("Checking if the component is already present"));
       
  1226             CGlobalComponentId *globalId = GetGlobalComponentIdLC();
       
  1227             TRAP_IGNORE(compId = iScrSession.GetComponentIdL(globalId->GlobalIdName(), globalId->SoftwareTypeName()););
       
  1228             CleanupStack::PopAndDestroy(globalId);
       
  1229             }
       
  1230         
       
  1231         // Try adding the app to a component. The add operation will fail if the component is not present.
       
  1232         if (!compId) 
       
  1233             {
       
  1234             if (GetIntFromConfig(ConfigSection(), _L("UseComponentId"), compId))
       
  1235                 INFO_PRINTF2(_L("Adding a new AppRegInfo to component %d"), compId);
       
  1236             }
       
  1237         
       
  1238         // The component is not present already
       
  1239         if (!compId)   
       
  1240             {
       
  1241             INFO_PRINTF1(_L("Adding a new component."));
       
  1242             compId = AddNonLocalisableComponentL(iScrSession);
       
  1243             newComponentAdded = ETrue;
       
  1244             }
       
  1245         
       
  1246         INFO_PRINTF1(_L("Get reg info from config file."));
       
  1247         const CApplicationRegistrationData* appRegData = GetAppRegInfoFromConfigLC();
       
  1248         TRAP(err, scrSession1.AddApplicationEntryL(compId, *appRegData));  
       
  1249         if(KErrNone != err)
       
  1250             {
       
  1251             INFO_PRINTF2(_L("Failed to Create Transaction , error: %d"), err);
       
  1252             SetTestStepResult(EFail); 
       
  1253             if (newComponentAdded)
       
  1254                {
       
  1255                // We are going to delete the component with no apps
       
  1256                scrSession1.DeleteComponentL(compId);
       
  1257                }
       
  1258             }
       
  1259         
       
  1260         //Trying to write(app app info) to the db while scrSession1 is alredy in process of writing. 
       
  1261         //It will fail with KErrScrWriteOperationInProgress since a transaction is alredy alive.
       
  1262         scrSession2.AddApplicationEntryL(compId, *appRegData);
       
  1263         CleanupStack::Pop();
       
  1264         delete appRegData;        
       
  1265         }
       
  1266     
       
  1267     else if(isSimultaneousReadAppInfoDiffSessionWithoutTransaction)
       
  1268         {
       
  1269         //Two subsessions without a transaction simultaneously reading the db. 
       
  1270         CAppInfoFilter* appinfoFilter=NULL ;                   
       
  1271        
       
  1272         INFO_PRINTF1(_L("Read appinfo filter from configuration"));
       
  1273         TRAPD(err, ReadAppInfoFilterFromConfigL(&appinfoFilter));
       
  1274         if (KErrNotFound==err)
       
  1275            {
       
  1276            delete appinfoFilter;
       
  1277            appinfoFilter=NULL;
       
  1278            }
       
  1279         CleanupStack::PushL(appinfoFilter);
       
  1280         
       
  1281      
       
  1282         //READ the AppRegInfo for (scrSession1/subSession) and (scrSession2/subSession2)
       
  1283         RApplicationInfoView  subSession, subSession2;
       
  1284         CleanupClosePushL(subSession);
       
  1285         CleanupClosePushL(subSession2);
       
  1286         
       
  1287         subSession.OpenViewL(scrSession1,appinfoFilter);
       
  1288         subSession2.OpenViewL(scrSession2,appinfoFilter);        
       
  1289                 
       
  1290         
       
  1291         RPointerArray<Usif::TAppRegInfo> appRegInfoSet, appRegInfoSet2;
       
  1292                
       
  1293         subSession.GetNextAppInfoL(5, appRegInfoSet);        
       
  1294         subSession2.GetNextAppInfoL(5, appRegInfoSet2);
       
  1295              
       
  1296         appRegInfoSet.ResetAndDestroy();
       
  1297         appRegInfoSet2.ResetAndDestroy();
       
  1298         
       
  1299         CleanupStack::PopAndDestroy(2, &subSession); 
       
  1300         CleanupStack::PopAndDestroy(appinfoFilter);
       
  1301         }    
       
  1302 
       
  1303     //Close the sessions
       
  1304     scrSession1.Close();
       
  1305     scrSession2.Close();    
       
  1306     }
       
  1307     
       
  1308 void CScrAddConcurrentApplicationEntryStep::ImplTestStepPostambleL()
       
  1309     {
       
  1310     CScrTestStep::ImplTestStepPostambleL();
       
  1311     }
       
  1312 
       
  1313 // -----------CScrGetAppInfoStep-----------------
       
  1314 
       
  1315 CScrGetAppInfoStep::CScrGetAppInfoStep(CScrTestServer& aParent) : CScrTestStep(aParent)
       
  1316     {
       
  1317     }
       
  1318 
       
  1319 void CScrGetAppInfoStep::ImplTestStepPreambleL()
       
  1320     {
       
  1321     CScrTestStep::ImplTestStepPreambleL();
       
  1322     }
       
  1323 
       
  1324 void CScrGetAppInfoStep::ImplTestStepL()
       
  1325     {
       
  1326     TLanguage locale;
       
  1327     TBool result;
       
  1328     TAppRegInfo retrievedAppRegEntry;
       
  1329     TUid uid;
       
  1330     TPtrC fullName, caption, shortCaption;
       
  1331 
       
  1332     _LIT(KAppInfoUid, "AppUid");
       
  1333     if (!GetUidFromConfig(ConfigSection(), KAppInfoUid, uid))
       
  1334         {
       
  1335          ERR_PRINTF2(_L("The application Uid type param %S could not be found in configuration."), &KAppInfoUid);
       
  1336          User::Leave(KErrNotFound);
       
  1337         }
       
  1338         
       
  1339     _LIT(KAppInfoApplicationFilename, "AppFile");
       
  1340     if(!GetStringFromConfig(ConfigSection(), KAppInfoApplicationFilename, fullName))
       
  1341        {
       
  1342        fullName.Set(KNull);
       
  1343        }
       
  1344  
       
  1345     _LIT(KAppInfoCaption, "Caption");
       
  1346     if(!GetStringFromConfig(ConfigSection(), KAppInfoCaption, caption))
       
  1347        {
       
  1348        caption.Set(KNull);
       
  1349        }
       
  1350  
       
  1351     _LIT(KAppInfoShortCaption, "ShortCaption");
       
  1352     if(!GetStringFromConfig(ConfigSection(), KAppInfoShortCaption, shortCaption))
       
  1353        {
       
  1354        shortCaption.Set(KNull);
       
  1355        }
       
  1356 
       
  1357     RApplicationRegistrationInfo infoQuerySubSession;
       
  1358     CleanupClosePushL(infoQuerySubSession);
       
  1359     infoQuerySubSession.OpenL(iScrSession);    
       
  1360 
       
  1361     _LIT(KLocaleParam, "Locale");
       
  1362     if(GetLocaleFromConfigL(KLocaleParam,locale))
       
  1363         {
       
  1364         result = infoQuerySubSession.GetAppInfoL(uid, retrievedAppRegEntry, locale);
       
  1365         }
       
  1366     else
       
  1367         {
       
  1368         result = infoQuerySubSession.GetAppInfoL(uid, retrievedAppRegEntry);
       
  1369         }
       
  1370     
       
  1371     if(result)
       
  1372         {
       
  1373         INFO_PRINTF3(_L("Expected Uid:0x%x Retrieved Uid:0x%x"), uid, retrievedAppRegEntry.Uid()); 
       
  1374         INFO_PRINTF3(_L("Expected filename:%S Retrieved Filename: %s"), &fullName, retrievedAppRegEntry.FullName().PtrZ());
       
  1375         INFO_PRINTF3(_L("Expected caption:%S Retrieved caption: %s"), &caption, retrievedAppRegEntry.Caption().PtrZ());
       
  1376         INFO_PRINTF3(_L("Expected short caption:%S Retrieved caption: %s"), &shortCaption, retrievedAppRegEntry.ShortCaption().PtrZ());
       
  1377         }
       
  1378     else
       
  1379         {
       
  1380         INFO_PRINTF1(_L("The given application Uid is absent in the database.")); 
       
  1381         }
       
  1382     
       
  1383     if(fullName!=retrievedAppRegEntry.FullName() ||caption!=retrievedAppRegEntry.Caption()|| shortCaption!=retrievedAppRegEntry.ShortCaption())
       
  1384         {
       
  1385         ERR_PRINTF1(_L("Mismatch in expected and retrieved values! ")); 
       
  1386         SetTestStepResult(EFail);
       
  1387         }
       
  1388     else
       
  1389         {
       
  1390         INFO_PRINTF1(_L("Expected and retrieved results match."));
       
  1391         }
       
  1392 
       
  1393     CleanupStack::PopAndDestroy(&infoQuerySubSession);    
       
  1394     }
       
  1395  
       
  1396 void CScrGetAppInfoStep::ImplTestStepPostambleL()
       
  1397     {
       
  1398     CScrTestStep::ImplTestStepPostambleL();
       
  1399     }