installationservices/swcomponentregistry/test/tscr/source/componentquerysteps.cpp
branchRCL_3
changeset 66 8b7f4e561641
parent 65 7333d7932ef7
child 70 e8965914fac7
equal deleted inserted replaced
65:7333d7932ef7 66:8b7f4e561641
     1 /*
       
     2 * Copyright (c) 2008-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 query APIs in the SCR
       
    16 *
       
    17 */
       
    18 
       
    19 
       
    20 #include "componentquerysteps.h"
       
    21 #include <scs/cleanuputils.h>
       
    22 #include <usif/scr/screntries.h>
       
    23 #include "tscrdefs.h"
       
    24 
       
    25 using namespace Usif;
       
    26 
       
    27 // -----------CScrGetComponentStep-----------------
       
    28 
       
    29 CScrGetComponentStep::CScrGetComponentStep(CScrTestServer& aParent)	: CScrTestStep(aParent)
       
    30 	{
       
    31 	}
       
    32 
       
    33 void CScrGetComponentStep::ImplTestStepPreambleL()
       
    34 	{
       
    35 	CScrTestStep::ImplTestStepPreambleL();
       
    36 	}
       
    37 
       
    38 void CScrGetComponentStep::ImplTestStepL()
       
    39 	{
       
    40 	CComponentEntry *componentExpected = GetComponentEntryFromConfigLC();	
       
    41 	CComponentEntry *componentRetrieved = CComponentEntry::NewL();
       
    42 	CleanupStack::PushL(componentRetrieved);
       
    43 	
       
    44 	TLanguage locale = KUnspecifiedLocale;
       
    45 	GetLocaleFromConfigL(KComponentLocaleName, locale);
       
    46 	// Start timer just before invocation of SCR API
       
    47 	StartTimer();
       
    48 	if(!iScrSession.GetComponentL(componentExpected->ComponentId(), *componentRetrieved, locale))
       
    49 		{
       
    50 		ERR_PRINTF2(_L("Component Id %d doesn't exist!."), componentExpected->ComponentId());
       
    51 		User::Leave(KErrNotFound);
       
    52 		}
       
    53 	
       
    54 	TTime time = componentRetrieved->InstallTimeL(); // For the sake of coverage print install time
       
    55 	INFO_PRINTF2(_L("Component InstallTime is %ld."), componentRetrieved->InstallTimeL().Int64());
       
    56 	
       
    57 	if(*componentExpected != *componentRetrieved)
       
    58 		{
       
    59 		ERR_PRINTF5(_L("Returned component entry values(%S,%S) don't match with the expected ones(%S,%S)."),&componentRetrieved->Name(),&componentRetrieved->Vendor(),&componentExpected->Name(),&componentExpected->Vendor());
       
    60 		SetTestStepResult(EFail);
       
    61 		}
       
    62 	
       
    63 	CleanupStack::PopAndDestroy(2, componentExpected); // componentExpected, componentRetrieved
       
    64 	}
       
    65 
       
    66 void CScrGetComponentStep::ImplTestStepPostambleL()
       
    67 	{
       
    68 	CScrTestStep::ImplTestStepPostambleL();
       
    69 	}
       
    70 
       
    71 // -----------CScrGetComponentLocalizedStep-----------------
       
    72 
       
    73 CScrGetComponentLocalizedStep::CScrGetComponentLocalizedStep(CScrTestServer& aParent) : CScrTestStep(aParent)
       
    74     {
       
    75     }
       
    76 
       
    77 void CScrGetComponentLocalizedStep::ImplTestStepPreambleL()
       
    78     {
       
    79     CScrTestStep::ImplTestStepPreambleL();
       
    80     }
       
    81 
       
    82 void CScrGetComponentLocalizedStep::ImplTestStepL()
       
    83     {
       
    84     TComponentId expectedComponentId = GetComponentIdL();
       
    85     RPointerArray<Usif::CLocalizableComponentInfo> compLocalizedInfoArrayExpected;
       
    86     CleanupResetAndDestroyPushL(compLocalizedInfoArrayExpected);
       
    87     
       
    88     GetLocalisedComponentsFromConfigL(compLocalizedInfoArrayExpected);
       
    89     
       
    90     RPointerArray<Usif::CLocalizableComponentInfo> compLocalizedInfoArrayRetrieved;
       
    91     // Start timer just before invocation of SCR API
       
    92     StartTimer();
       
    93     CleanupResetAndDestroyPushL(compLocalizedInfoArrayRetrieved);
       
    94     iScrSession.GetComponentLocalizedInfoL(expectedComponentId, compLocalizedInfoArrayRetrieved);
       
    95     if(compLocalizedInfoArrayExpected.Count()!=compLocalizedInfoArrayRetrieved.Count())
       
    96         {
       
    97         ERR_PRINTF1(_L("Returned component entry count doesnt match the expected count")); 
       
    98         SetTestStepResult(EFail);
       
    99         }
       
   100     else
       
   101         {
       
   102         for(TInt i=0;i<compLocalizedInfoArrayExpected.Count();i++)
       
   103             {
       
   104             if((compLocalizedInfoArrayExpected[i]->NameL()!=compLocalizedInfoArrayExpected[i]->NameL())||(compLocalizedInfoArrayExpected[i]->VendorL()!=compLocalizedInfoArrayExpected[i]->VendorL())||(compLocalizedInfoArrayExpected[i]->Locale()!=compLocalizedInfoArrayExpected[i]->Locale()))
       
   105                 {
       
   106                 ERR_PRINTF7(_L("Returned component entry values(%S,%S,%d) don't match with the expected ones(%S,%S,%d)."),&(compLocalizedInfoArrayRetrieved[i]->NameL()),&(compLocalizedInfoArrayRetrieved[i]->VendorL()),compLocalizedInfoArrayRetrieved[i]->Locale(),&(compLocalizedInfoArrayExpected[i]->NameL()),&(compLocalizedInfoArrayExpected[i]->VendorL()),compLocalizedInfoArrayExpected[i]->Locale());
       
   107                 SetTestStepResult(EFail);
       
   108                 }
       
   109             }
       
   110         }           
       
   111         
       
   112     CleanupStack::Pop(2,&compLocalizedInfoArrayExpected); //compLocalizedInfoArrayExpected ,compLocalizedInfoArrayRetrieved 
       
   113     compLocalizedInfoArrayRetrieved.ResetAndDestroy();
       
   114     compLocalizedInfoArrayExpected.ResetAndDestroy();
       
   115     }
       
   116     
       
   117 void CScrGetComponentLocalizedStep::ImplTestStepPostambleL()
       
   118     {
       
   119     CScrTestStep::ImplTestStepPostambleL();
       
   120     }
       
   121 
       
   122 
       
   123 
       
   124 // -----------CScrGetFilePropertiesStep-----------------
       
   125 
       
   126 CScrGetFilePropertiesStep::CScrGetFilePropertiesStep(CScrTestServer& aParent) : CScrTestStep(aParent)
       
   127 	{
       
   128 	}
       
   129 
       
   130 void CScrGetFilePropertiesStep::ImplTestStepPreambleL()
       
   131 	{
       
   132 	CScrTestStep::ImplTestStepPreambleL();
       
   133 	}
       
   134 
       
   135 void CScrGetFilePropertiesStep::ImplTestStepL()
       
   136 	{
       
   137 	TComponentId componentId = GetComponentIdL();
       
   138 	
       
   139 	TPtrC fileName;
       
   140 	GetFileNameFromConfigL(fileName);	
       
   141 	
       
   142 	RPointerArray<CPropertyEntry> expectedFileProperties;
       
   143 	CleanupResetAndDestroyPushL(expectedFileProperties);	
       
   144 	GetPropertiesFromConfigL(expectedFileProperties);	
       
   145 
       
   146 	RPointerArray<CPropertyEntry> retrievedFileProperties;
       
   147 	CleanupResetAndDestroyPushL(retrievedFileProperties);
       
   148 	// Start timer just before invocation of SCR API
       
   149 	StartTimer();
       
   150 	iScrSession.GetFilePropertiesL(componentId, fileName, retrievedFileProperties);
       
   151 	
       
   152 	if(!ComparePropertiesL(expectedFileProperties, retrievedFileProperties))
       
   153 		{
       
   154 		ERR_PRINTF1(_L("Retrieved file properties don't match with the expected ones."));
       
   155 		SetTestStepResult(EFail);	
       
   156 		}
       
   157 	CleanupStack::PopAndDestroy(2, &expectedFileProperties); // expectedFileProperties, retrievedFileProperties
       
   158 	}
       
   159 
       
   160 void CScrGetFilePropertiesStep::ImplTestStepPostambleL()
       
   161 	{
       
   162 	CScrTestStep::ImplTestStepPostambleL();
       
   163 	}
       
   164 
       
   165 
       
   166 // -----------CScrGetFilePropertyStep-----------------
       
   167 
       
   168 CScrGetFilePropertyStep::CScrGetFilePropertyStep(CScrTestServer& aParent) : CScrTestStep(aParent)
       
   169 	{
       
   170 	}
       
   171 
       
   172 void CScrGetFilePropertyStep::ImplTestStepPreambleL()
       
   173 	{
       
   174 	CScrTestStep::ImplTestStepPreambleL();
       
   175 	}
       
   176 
       
   177 void CScrGetFilePropertyStep::ImplTestStepL()
       
   178 	{
       
   179 	TComponentId componentId = GetComponentIdL();
       
   180 	
       
   181 	CPropertyEntry *expectedProperty = GetPropertyFromConfigLC(ETrue);
       
   182 	
       
   183 	TPtrC fileName;
       
   184 	GetFileNameFromConfigL(fileName);	
       
   185 	// Start timer just before invocation of SCR API
       
   186 	StartTimer();	
       
   187 	CPropertyEntry *retrievedProperty = iScrSession.GetFilePropertyL(componentId, fileName, expectedProperty->PropertyName());
       
   188 	
       
   189 	if(!retrievedProperty)
       
   190 		{
       
   191 		ERR_PRINTF1(_L("The requested file property couldn't be found!"));
       
   192 		User::Leave(KErrNotFound);
       
   193 		}
       
   194 	CleanupStack::PushL(retrievedProperty);
       
   195 		
       
   196 	if(*retrievedProperty != *expectedProperty)
       
   197 		{
       
   198 		ERR_PRINTF3(_L("The retrieved property(%S) doesn't match with the expected one(%S)."), &retrievedProperty->PropertyName(), &expectedProperty->PropertyName());
       
   199 		SetTestStepResult(EFail);
       
   200 		}
       
   201 	CleanupStack::PopAndDestroy(2, expectedProperty); // expectedProperty, retrievedProperty
       
   202 	}
       
   203 
       
   204 void CScrGetFilePropertyStep::ImplTestStepPostambleL()
       
   205 	{
       
   206 	CScrTestStep::ImplTestStepPostambleL();
       
   207 	}
       
   208 
       
   209 // -----------CScrGetFileComponentsStep-----------------
       
   210 
       
   211 CScrGetFileComponentsStep::CScrGetFileComponentsStep(CScrTestServer& aParent) : CScrTestStep(aParent)
       
   212 	{
       
   213 	}
       
   214 
       
   215 void CScrGetFileComponentsStep::ImplTestStepPreambleL()
       
   216 	{
       
   217 	CScrTestStep::ImplTestStepPreambleL();
       
   218 	}
       
   219 
       
   220 void CScrGetFileComponentsStep::ImplTestStepL()
       
   221 	{
       
   222 	TPtrC fileName;
       
   223 	GetFileNameFromConfigL(fileName);
       
   224 
       
   225 	RArray<TComponentId> expectedComponents;
       
   226 	CleanupClosePushL(expectedComponents);
       
   227 	GetComponentIdsFromConfigL(expectedComponents);
       
   228 	
       
   229 	RArray<TComponentId> foundComponents;
       
   230 	CleanupClosePushL(foundComponents);
       
   231 	// Start timer just before invocation of SCR API
       
   232 	StartTimer();
       
   233 	iScrSession.GetComponentsL(fileName, foundComponents);
       
   234 	
       
   235 	CompareComponentIdsL(foundComponents, expectedComponents);
       
   236 	
       
   237 	CleanupStack::PopAndDestroy(2, &expectedComponents); // expectedComponents, foundComponents
       
   238 	}
       
   239 
       
   240 void CScrGetFileComponentsStep::ImplTestStepPostambleL()
       
   241 	{
       
   242 	CScrTestStep::ImplTestStepPostambleL();
       
   243 	}
       
   244 
       
   245 // -----------CScrGetComponentPropertyStep-----------------
       
   246 
       
   247 CScrGetComponentPropertyStep::CScrGetComponentPropertyStep(CScrTestServer& aParent) : CScrTestStep(aParent)
       
   248 	{
       
   249 	}
       
   250 
       
   251 void CScrGetComponentPropertyStep::ImplTestStepPreambleL()
       
   252 	{
       
   253 	CScrTestStep::ImplTestStepPreambleL();
       
   254 	}
       
   255 
       
   256 void CScrGetComponentPropertyStep::ImplTestStepL()
       
   257 	{
       
   258 	TComponentId componentId = GetComponentIdL();
       
   259 	
       
   260 	CPropertyEntry *expectedProperty = GetPropertyFromConfigLC(ETrue,0,ETrue);
       
   261 	CPropertyEntry *retrievedProperty(0);
       
   262 	// Start timer just before invocation of SCR API
       
   263 	StartTimer();
       
   264 	switch(expectedProperty->PropertyType())
       
   265 		{
       
   266 		case CPropertyEntry::EBinaryProperty:
       
   267 		case CPropertyEntry::EIntProperty:
       
   268 			{
       
   269 			retrievedProperty = iScrSession.GetComponentPropertyL(componentId, expectedProperty->PropertyName());
       
   270 			break;
       
   271 			}
       
   272 		case CPropertyEntry::ELocalizedProperty:
       
   273 			{
       
   274 			CLocalizablePropertyEntry *locProperty = static_cast<CLocalizablePropertyEntry*>(expectedProperty);
       
   275 			retrievedProperty = iScrSession.GetComponentPropertyL(componentId, locProperty->PropertyName(), locProperty->LocaleL());
       
   276 			break;
       
   277 			}
       
   278 		}// switch
       
   279 	
       
   280 	if(!retrievedProperty)
       
   281 		{
       
   282 		ERR_PRINTF1(_L("The requested component property couldn't be found!"));
       
   283 		User::Leave(KErrNotFound);
       
   284 		}
       
   285 	CleanupStack::PushL(retrievedProperty);
       
   286 	
       
   287 	if(*retrievedProperty != *expectedProperty)
       
   288 		{
       
   289 		ERR_PRINTF3(_L("The retrieved property(%S) doesn't match with the expected one(%S)."), &retrievedProperty->PropertyName(), &expectedProperty->PropertyName());
       
   290 		SetTestStepResult(EFail);
       
   291 		}
       
   292 	CleanupStack::PopAndDestroy(2, expectedProperty); // expectedProperty, retrievedProperty
       
   293 	}
       
   294 
       
   295 void CScrGetComponentPropertyStep::ImplTestStepPostambleL()
       
   296 	{
       
   297 	CScrTestStep::ImplTestStepPostambleL();
       
   298 	}
       
   299 
       
   300 
       
   301 // -----------CScrGetComponentPropertiesStep-----------------
       
   302 
       
   303 CScrGetComponentPropertiesStep::CScrGetComponentPropertiesStep(CScrTestServer& aParent) : CScrTestStep(aParent)
       
   304 	{
       
   305 	}
       
   306 
       
   307 void CScrGetComponentPropertiesStep::ImplTestStepPreambleL()
       
   308 	{
       
   309 	CScrTestStep::ImplTestStepPreambleL();
       
   310 	}
       
   311 
       
   312 void CScrGetComponentPropertiesStep::ImplTestStepL()
       
   313 	{
       
   314 	TComponentId componentId = GetComponentIdL();
       
   315 
       
   316 	RPointerArray<CPropertyEntry> expectedProperties;
       
   317 	CleanupResetAndDestroyPushL(expectedProperties);	
       
   318 	GetPropertiesFromConfigL(expectedProperties, ETrue); // ETrue means that localizable properties are supported
       
   319 	
       
   320 	RPointerArray<CPropertyEntry> foundProperties;
       
   321 	CleanupResetAndDestroyPushL(foundProperties);
       
   322 	
       
   323 	TLanguage locale = static_cast<TLanguage>(0);
       
   324 	// Start timer just before invocation of SCR API
       
   325 	StartTimer();
       
   326 	if(GetLocaleFromConfigL(locale))
       
   327 		{
       
   328 		iScrSession.GetComponentPropertiesL(componentId, foundProperties, locale);
       
   329 		}
       
   330 	else
       
   331 		{
       
   332 		iScrSession.GetComponentPropertiesL(componentId, foundProperties);
       
   333 		}
       
   334 
       
   335 	if (!ComparePropertiesL(foundProperties, expectedProperties))
       
   336 		{
       
   337 		ERR_PRINTF1(_L("The retrieved properties are different from the expected ones."));
       
   338 		SetTestStepResult(EFail);
       
   339 		}
       
   340 	
       
   341 	CleanupStack::PopAndDestroy(2, &expectedProperties); // expectedProperties, foundProperties	
       
   342 	}
       
   343 
       
   344 void CScrGetComponentPropertiesStep::ImplTestStepPostambleL()
       
   345 	{
       
   346 	CScrTestStep::ImplTestStepPostambleL();
       
   347 	}
       
   348 
       
   349 // -----------CScrGetComponentIdsStep-----------------
       
   350 
       
   351 CScrGetComponentIdsStep::CScrGetComponentIdsStep(CScrTestServer& aParent)	: CScrTestStep(aParent)
       
   352 	{
       
   353 	}
       
   354 
       
   355 void CScrGetComponentIdsStep::ImplTestStepPreambleL()
       
   356 	{
       
   357 	CScrTestStep::ImplTestStepPreambleL();
       
   358 	}
       
   359 
       
   360 void CScrGetComponentIdsStep::ImplTestStepL()
       
   361 	{
       
   362 	CComponentFilter *componentFilter = ReadComponentFilterFromConfigLC();
       
   363 	INFO_PRINTF1(_L("Read component filter from configuration"));
       
   364 	
       
   365 	// Get expected list of component ids from config
       
   366 	RArray<TComponentId> expectedComponentIds;
       
   367 	CleanupClosePushL(expectedComponentIds);
       
   368 	GetComponentIdsFromConfigL(expectedComponentIds);
       
   369 			
       
   370 	RArray<TComponentId> foundComponentIds;
       
   371 	CleanupClosePushL(foundComponentIds);
       
   372 	// Start timer just before invocation of SCR API
       
   373 	StartTimer();
       
   374 	iScrSession.GetComponentIdsL(foundComponentIds, componentFilter);
       
   375 		
       
   376 	CompareComponentIdsL(foundComponentIds, expectedComponentIds);
       
   377 		
       
   378 	CleanupStack::PopAndDestroy(3, componentFilter); // foundComponentIds, expectedComponentIds, componentFilter
       
   379 	}
       
   380 
       
   381 void CScrGetComponentIdsStep::ImplTestStepPostambleL()
       
   382 	{
       
   383 	CScrTestStep::ImplTestStepPostambleL();
       
   384 	}
       
   385 
       
   386 // -----------CScrGetComponentFilesCountStep-----------------
       
   387 
       
   388 CScrGetComponentFilesCountStep::CScrGetComponentFilesCountStep(CScrTestServer& aParent)	: CScrTestStep(aParent)
       
   389 	{
       
   390 	}
       
   391 
       
   392 void CScrGetComponentFilesCountStep::ImplTestStepPreambleL()
       
   393 	{
       
   394 	CScrTestStep::ImplTestStepPreambleL();
       
   395 	}
       
   396 
       
   397 void CScrGetComponentFilesCountStep::ImplTestStepL()
       
   398 	{
       
   399 	TComponentId componentId = GetComponentIdL();
       
   400 	TInt expectedFilesCountTmp(0);
       
   401 	if (!GetIntFromConfig(ConfigSection(), _L("ExpectedFilesCount"), expectedFilesCountTmp))
       
   402 		{
       
   403 		PrintErrorL(_L("ExpectedFilesCount property was not found!"), KErrNotFound);
       
   404 		}
       
   405 	if (expectedFilesCountTmp < 0)
       
   406 		{
       
   407 		PrintErrorL(_L("ExpectedFilesCount is negative!"), KErrArgument);
       
   408 		}
       
   409 	TUint expectedFilesCount = static_cast<TUint>(expectedFilesCountTmp);
       
   410 	
       
   411 	// Start timer just before invocation of SCR API
       
   412 	StartTimer();
       
   413 	TUint foundFilesCount = iScrSession.GetComponentFilesCountL(componentId);
       
   414 	
       
   415 	if (foundFilesCount != expectedFilesCount)
       
   416 		{
       
   417 		ERR_PRINTF4(_L("The retrieved files count is different from the expected one for component %d. Expected %d, but found %d"),
       
   418 				componentId, foundFilesCount, expectedFilesCount);
       
   419 		SetTestStepResult(EFail);
       
   420 		}
       
   421 	}
       
   422 
       
   423 void CScrGetComponentFilesCountStep::ImplTestStepPostambleL()
       
   424 	{
       
   425 	CScrTestStep::ImplTestStepPostambleL();
       
   426 	}
       
   427 
       
   428 
       
   429 // -----------CScrGetComponentWithGlobalIdStep-----------------
       
   430 
       
   431 CScrGetComponentWithGlobalIdStep::CScrGetComponentWithGlobalIdStep(CScrTestServer& aParent)	: CScrTestStep(aParent)
       
   432 	{
       
   433 	}
       
   434 
       
   435 void CScrGetComponentWithGlobalIdStep::ImplTestStepPreambleL()
       
   436 	{
       
   437 	CScrTestStep::ImplTestStepPreambleL();
       
   438 	}
       
   439 
       
   440 void CScrGetComponentWithGlobalIdStep::ImplTestStepL()
       
   441 	{
       
   442 	CComponentEntry *componentExpected = GetComponentEntryFromConfigLC();	
       
   443 	TLanguage locale = KUnspecifiedLocale;
       
   444 	GetLocaleFromConfigL(KComponentLocaleName, locale);
       
   445 	
       
   446 	// Start timer just before invocation of SCR API
       
   447 	StartTimer();
       
   448 	CComponentEntry *componentRetrieved = iScrSession.GetComponentL(componentExpected->GlobalId(), componentExpected->SoftwareType());
       
   449 	if(!componentRetrieved)
       
   450 		{
       
   451 		INFO_PRINTF3(_L("Global Id (%S,%S) doesn't exist!."), &componentExpected->GlobalId(), &componentExpected->SoftwareType());
       
   452 		User::Leave(KErrNotFound);
       
   453 		}
       
   454 	CleanupStack::PushL(componentRetrieved);
       
   455 	
       
   456 	if(*componentExpected != *componentRetrieved)
       
   457 		{
       
   458 		ERR_PRINTF5(_L("Returned component entry values(%S,%S) don't match with the expected ones(%S,%S)."),&componentRetrieved->Name(),&componentRetrieved->Vendor(),&componentExpected->Name(),&componentExpected->Vendor());
       
   459 		SetTestStepResult(EFail);
       
   460 		}
       
   461 	
       
   462 	CleanupStack::PopAndDestroy(2, componentExpected); // componentExpected, componentRetrieved
       
   463 	}
       
   464 
       
   465 void CScrGetComponentWithGlobalIdStep::ImplTestStepPostambleL()
       
   466 	{
       
   467 	CScrTestStep::ImplTestStepPostambleL();
       
   468 	}
       
   469 
       
   470 // -----------CScrGetComponentIdStep-----------------
       
   471 
       
   472 CScrGetComponentIdStep::CScrGetComponentIdStep(CScrTestServer& aParent)	: CScrTestStep(aParent)
       
   473 	{
       
   474 	}
       
   475 
       
   476 void CScrGetComponentIdStep::ImplTestStepPreambleL()
       
   477 	{
       
   478 	CScrTestStep::ImplTestStepPreambleL();
       
   479 	}
       
   480 
       
   481 void CScrGetComponentIdStep::ImplTestStepL()
       
   482 	{
       
   483 	CGlobalComponentId *globalId = GetGlobalComponentIdLC();
       
   484 	TComponentId expectedCompId = GetComponentIdL();
       
   485 	
       
   486 	// Start timer just before invocation of SCR API
       
   487 	StartTimer();
       
   488 	TComponentId retrievedCompId = iScrSession.GetComponentIdL(globalId->GlobalIdName(), globalId->SoftwareTypeName());
       
   489 	CleanupStack::PopAndDestroy(globalId);
       
   490 	
       
   491 	if(expectedCompId != retrievedCompId)
       
   492 		{
       
   493 		ERR_PRINTF3(_L("Returned component id (%d) don't match with the expected one(%d)."), retrievedCompId, expectedCompId);
       
   494 		SetTestStepResult(EFail);
       
   495 		}
       
   496 	}
       
   497 
       
   498 void CScrGetComponentIdStep::ImplTestStepPostambleL()
       
   499 	{
       
   500 	CScrTestStep::ImplTestStepPostambleL();
       
   501 	}
       
   502 
       
   503 // -----------CScrGetGlobalIdListStep-----------------
       
   504 
       
   505 CScrGetGlobalIdListStep::CScrGetGlobalIdListStep(CScrTestServer& aParent)	: CScrTestStep(aParent)
       
   506 	{
       
   507 	}
       
   508 
       
   509 void CScrGetGlobalIdListStep::ImplTestStepPreambleL()
       
   510 	{
       
   511 	CScrTestStep::ImplTestStepPreambleL();
       
   512 	}
       
   513 
       
   514 void CScrGetGlobalIdListStep::ImplTestStepL()
       
   515 	{
       
   516 	CGlobalComponentId *globalId = GetGlobalComponentIdLC();
       
   517 	
       
   518 	TBool noVerification = EFalse;
       
   519 	GetBoolFromConfig(ConfigSection(), _L("NoVerification"), noVerification);
       
   520 	RPointerArray<CVersionedComponentId> expectedVerCompIdList;
       
   521 	CleanupResetAndDestroyPushL(expectedVerCompIdList);
       
   522 	if(!noVerification)
       
   523 		{
       
   524 		GetExpectedVersionedComponentIdListL(expectedVerCompIdList);
       
   525 		}
       
   526 	
       
   527 	RPointerArray<CVersionedComponentId> retrievedVerCompIdList;
       
   528 	CleanupResetAndDestroyPushL(retrievedVerCompIdList);
       
   529 	
       
   530 	TPtrC globalIdType;
       
   531 	if (!GetStringFromConfig(ConfigSection(), KGlobalIdType, globalIdType))
       
   532 		PrintErrorL(_L("Global Id Type was not found!"), KErrNotFound);
       
   533 
       
   534 	// Start timer just before invocation of SCR API
       
   535     StartTimer();
       
   536 	
       
   537 	if(!globalIdType.CompareF(_L("Dependant")))
       
   538 		iScrSession.GetSupplierComponentsL(*globalId, retrievedVerCompIdList);
       
   539 	else if (!globalIdType.CompareF(_L("Supplier")))
       
   540 		iScrSession.GetDependantComponentsL(*globalId, retrievedVerCompIdList);
       
   541 	else {
       
   542 		 ERR_PRINTF1(_L("The global Id type couldn't be identified."));
       
   543 		 SetTestStepResult(EFail);
       
   544 		 }
       
   545 	
       
   546 	if (!noVerification && !CompareVersionedComponentIdsL(retrievedVerCompIdList, expectedVerCompIdList))
       
   547 		{
       
   548 		ERR_PRINTF1(_L("The retrieved global Ids are different from the expected ones."));
       
   549 		SetTestStepResult(EFail);
       
   550 		}
       
   551 
       
   552 	CleanupStack::PopAndDestroy(3, globalId); // depGlobalId, expectedGlobalIdList, retrievedGlobalIdList
       
   553 	}
       
   554 
       
   555 void CScrGetGlobalIdListStep::ImplTestStepPostambleL()
       
   556 	{
       
   557 	CScrTestStep::ImplTestStepPostambleL();
       
   558 	}
       
   559 
       
   560 	
       
   561 // -----------CScrValuesNegativeStep-----------------
       
   562 CScrValuesNegativeStep::CScrValuesNegativeStep(CScrTestServer& aParent)	: CScrTestStep(aParent)
       
   563 	{
       
   564 	}
       
   565 
       
   566 void CScrValuesNegativeStep::ImplTestStepPreambleL()
       
   567 	{
       
   568 	CScrTestStep::ImplTestStepPreambleL();
       
   569 	}
       
   570 
       
   571 void CScrValuesNegativeStep::ImplTestStepL()
       
   572 	{
       
   573 	CComponentFilter* componentFilter = CComponentFilter::NewLC();
       
   574 	TDriveList driveList;
       
   575 	// Set an empty drive list
       
   576 	componentFilter->SetInstalledDrivesL(driveList);
       
   577 	RSoftwareComponentRegistryView subSession;
       
   578 	CleanupClosePushL(subSession);	
       
   579 	// Start timer just before invocation of SCR API
       
   580 	StartTimer();
       
   581 	TRAPD(err, subSession.OpenViewL(iScrSession, componentFilter));	
       
   582 	if (err != KErrArgument)
       
   583 		{
       
   584 		ERR_PRINTF2(_L("Received incorrect error %d on missing param in filter."), err);
       
   585 		SetTestStepResult(EFail);
       
   586 		}
       
   587 	CleanupStack::PopAndDestroy(2, componentFilter); // subSession
       
   588 	}
       
   589 
       
   590 void CScrValuesNegativeStep::ImplTestStepPostambleL()
       
   591 	{
       
   592 	CScrTestStep::ImplTestStepPostambleL();
       
   593 	}
       
   594 
       
   595 // -----------CScrOom-----------------
       
   596 SCROufOfMemory::SCROufOfMemory(CScrTestServer& aParent)	: CScrTestStep(aParent)
       
   597 	{
       
   598 	iFailRate = 0;		
       
   599 	}
       
   600 
       
   601 void SCROufOfMemory::ImplTestStepPreambleL()
       
   602 	{
       
   603 	CScrTestStep::ImplTestStepPreambleL();
       
   604 	}
       
   605 
       
   606 void SCROufOfMemory::ImplTestStepL()
       
   607 	{
       
   608 	TInt i = 5000;		
       
   609 	while(i--)
       
   610 		{    
       
   611 		iScrSession.SetServerHeapFail(++iFailRate);
       
   612 		TRAPD(err, ExecuteL());
       
   613 		if (err != KErrNone || err != KErrNoMemory)		    
       
   614 			{
       
   615 			INFO_PRINTF2(_L("Error in oom Test : %d "),err);
       
   616 			}	
       
   617 		iScrSession.ResetServerHeapFail();		
       
   618 		}
       
   619 	
       
   620 	}
       
   621 
       
   622 void SCROufOfMemory::ImplTestStepPostambleL()
       
   623 	{
       
   624 	CScrTestStep::ImplTestStepPostambleL();
       
   625 	}
       
   626 
       
   627 void SCROufOfMemory::ApplicationRegistrationOperationsL(Usif::RSoftwareComponentRegistry& aScrSession)
       
   628     {    
       
   629     TComponentId compId = 0;
       
   630     TBool newComponentAdded(EFalse);
       
   631    
       
   632     // Checking if have already inserted the component
       
   633     TBool isMultiApp(EFalse);
       
   634     GetBoolFromConfig(ConfigSection(), _L("IsMultiApp"), isMultiApp);
       
   635     if (isMultiApp)
       
   636         {
       
   637         INFO_PRINTF1(_L("Checking if the component is already present"));
       
   638         CGlobalComponentId *globalId = GetGlobalComponentIdLC();
       
   639         TRAP_IGNORE(compId = aScrSession.GetComponentIdL(globalId->GlobalIdName(), globalId->SoftwareTypeName()););
       
   640         CleanupStack::PopAndDestroy(globalId);
       
   641         }
       
   642 
       
   643     // Try adding the app to a component. The add operation will fail if the component is not present.
       
   644     if (!compId) 
       
   645         {
       
   646         if (GetIntFromConfig(ConfigSection(), _L("UseComponentId"), compId))
       
   647             INFO_PRINTF2(_L("Adding a new AppRegInfo to component %d"), compId);
       
   648         }
       
   649     
       
   650     // The component is not present already
       
   651     if (!compId)   
       
   652         {
       
   653         INFO_PRINTF1(_L("Adding a new component."));
       
   654         compId = AddNonLocalisableComponentL(aScrSession);
       
   655         newComponentAdded = ETrue;
       
   656         }
       
   657 
       
   658     INFO_PRINTF1(_L("Get reg info from config file."));
       
   659     const CApplicationRegistrationData* appRegData = GetAppRegInfoFromConfigLC();
       
   660     TRAPD(err, aScrSession.AddApplicationEntryL(compId, *appRegData));  
       
   661     
       
   662     if (err != KErrNone && err != KErrAlreadyExists )
       
   663         {
       
   664         if (newComponentAdded)
       
   665             {
       
   666             // We are going to delete the component with no apps
       
   667             aScrSession.DeleteComponentL(compId);
       
   668             }
       
   669         User::Leave(err);
       
   670         }
       
   671 
       
   672     CleanupStack::PopAndDestroy();
       
   673     
       
   674     //Read from DB the AppRegInfo
       
   675     CAppInfoFilter* appInfoFilter=NULL ;
       
   676     INFO_PRINTF1(_L("Read appinfo filter from configuration"));
       
   677     TRAP(err, ReadAppInfoFilterFromConfigL(&appInfoFilter));    
       
   678     if (KErrNotFound==err)
       
   679         {
       
   680         delete appInfoFilter;
       
   681         appInfoFilter=NULL;
       
   682         }   
       
   683     
       
   684     CleanupStack::PushL(appInfoFilter);
       
   685     RApplicationInfoView  subSession;
       
   686     CleanupClosePushL(subSession);
       
   687     subSession.OpenViewL(aScrSession,appInfoFilter);
       
   688     if(appInfoFilter)
       
   689         {        
       
   690         delete appInfoFilter;
       
   691         appInfoFilter = NULL;
       
   692         }
       
   693     
       
   694     RPointerArray<Usif::TAppRegInfo> appRegInfoSet;   
       
   695     do
       
   696       {
       
   697       subSession.GetNextAppInfoL(5, appRegInfoSet);       
       
   698       appRegInfoSet.ResetAndDestroy();
       
   699       }while(0 != appRegInfoSet.Count()); 
       
   700     
       
   701     CleanupStack::Pop(&subSession);
       
   702     subSession.Close();
       
   703     CleanupStack::Pop();
       
   704         
       
   705     // Delete the component
       
   706     aScrSession.DeleteComponentL(compId);
       
   707     }
       
   708 
       
   709 
       
   710 void SCROufOfMemory::ExecuteL()
       
   711 	{
       
   712 	TBool isAppInfoOomTest(EFalse);
       
   713 	GetBoolFromConfig(ConfigSection(), _L("IsAppInfoOomTest"), isAppInfoOomTest);
       
   714 	//Connect to the SCR server
       
   715     Usif::RSoftwareComponentRegistry scr;
       
   716     TInt err = scr.Connect();
       
   717     
       
   718     if (err != KErrNone)
       
   719         {
       
   720         INFO_PRINTF1(_L("Failed to connect to the SCR server"));
       
   721         User::Leave(err);
       
   722         }
       
   723     CleanupClosePushL(scr);
       
   724 
       
   725 	INFO_PRINTF2(_L("HeapFail set for %d allocation"),iFailRate);
       
   726 
       
   727     if(isAppInfoOomTest)
       
   728         {
       
   729         ApplicationRegistrationOperationsL(scr);
       
   730         }
       
   731     else
       
   732         {
       
   733         // Create an SCR view
       
   734         RSoftwareComponentRegistryView scrView;
       
   735         scrView.OpenViewL(scr);
       
   736         CleanupClosePushL(scrView);
       
   737     
       
   738         // Iterate over the matching components
       
   739         CComponentEntry* entry = CComponentEntry::NewLC();
       
   740         while (scrView.NextComponentL(*entry))
       
   741             {
       
   742             RPointerArray<Usif::CLocalizableComponentInfo> compLocalizedInfoArray;
       
   743             CleanupResetAndDestroyPushL(compLocalizedInfoArray);
       
   744             scr.GetComponentLocalizedInfoL(entry->ComponentId(), compLocalizedInfoArray);
       
   745             CleanupStack::Pop(&compLocalizedInfoArray);
       
   746             compLocalizedInfoArray.ResetAndDestroy();
       
   747             }
       
   748         
       
   749         scrView.Close();
       
   750         CleanupStack::PopAndDestroy();
       
   751         CleanupStack::Pop();
       
   752         }	
       
   753     CleanupStack::PopAndDestroy();
       
   754 	}
       
   755