os/ossrv/lowlevellibsandfws/pluginfw/TestExecute/EComSWITests/src/installstep.cpp
changeset 0 bde4ae8d615e
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/os/ossrv/lowlevellibsandfws/pluginfw/TestExecute/EComSWITests/src/installstep.cpp	Fri Jun 15 03:10:57 2012 +0200
     1.3 @@ -0,0 +1,667 @@
     1.4 +// Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
     1.5 +// All rights reserved.
     1.6 +// This component and the accompanying materials are made available
     1.7 +// under the terms of "Eclipse Public License v1.0"
     1.8 +// which accompanies this distribution, and is available
     1.9 +// at the URL "http://www.eclipse.org/legal/epl-v10.html".
    1.10 +//
    1.11 +// Initial Contributors:
    1.12 +// Nokia Corporation - initial contribution.
    1.13 +//
    1.14 +// Contributors:
    1.15 +//
    1.16 +// Description:
    1.17 +// SWIS test step implementation
    1.18 +// 
    1.19 +//
    1.20 +
    1.21 +/**
    1.22 + @file
    1.23 +*/
    1.24 +
    1.25 +#include "installStep.h"
    1.26 +#include "common.h"
    1.27 +#include "tui.h"
    1.28 +#include <e32std.h>
    1.29 +#include <test/testexecutelog.h>
    1.30 +#include <swi/launcher.h>
    1.31 +#include <bautils.h>
    1.32 +#include "swi/sisregistrysession.h"
    1.33 +#include "swi/sisregistrypackage.h"
    1.34 +#include "swi/sisregistryentry.h"
    1.35 +#include "cleanuputils.h"
    1.36 +
    1.37 +using namespace Swi;
    1.38 +
    1.39 +//
    1.40 +// CinstallStep
    1.41 +//
    1.42 +
    1.43 +CinstallStep::~CinstallStep()
    1.44 +    {
    1.45 +    delete iUi;
    1.46 +    }
    1.47 +    
    1.48 +
    1.49 +CinstallStep::CinstallStep(TInstallType aInstallType, TBool aDoCancelTest)
    1.50 +    : iInstallType(aInstallType), iDoCancelTest(aDoCancelTest),
    1.51 +	  iInstallSuccess(EFalse)
    1.52 +    {
    1.53 +    // Call base class method to set up the human readable name for logging
    1.54 +    
    1.55 +    switch (aInstallType)
    1.56 +        {
    1.57 +        case EUseFileHandle:
    1.58 +            SetTestStepName(KInstallFHStep);
    1.59 +            break;
    1.60 +        
    1.61 +        case EUseMemory:
    1.62 +            SetTestStepName(KInstallMemStep);
    1.63 +            break;
    1.64 +
    1.65 +        case EUseFileName:
    1.66 +            SetTestStepName(KInstallStep);
    1.67 +            break;
    1.68 +        
    1.69 +        case EUseCAF:
    1.70 +            SetTestStepName(KInstallCAFStep);
    1.71 +            break;
    1.72 +
    1.73 +        case EUseOpenFileName:
    1.74 +            SetTestStepName(KInstallOpenFileStep);
    1.75 +            break;
    1.76 +            
    1.77 +        case ECheckExitValue:
    1.78 +            SetTestStepName(KCheckedInstallStep);
    1.79 +            break;     
    1.80 +            
    1.81 +        }
    1.82 +    }
    1.83 +
    1.84 +/**
    1.85 + * Override of base class virtual. Prepares for the test run of SWIS
    1.86 + * @return TVerdict code
    1.87 + */
    1.88 +TVerdict CinstallStep::doTestStepPreambleL()
    1.89 +    {
    1.90 +    SetTestStepResult(EPass);
    1.91 +    // get step parameters
    1.92 +    TPtrC str;
    1.93 +    if (!GetStringFromConfig(ConfigSection(), _L("sis"), str))
    1.94 +        {
    1.95 +        INFO_PRINTF1(HTML_RED);
    1.96 +        ERR_PRINTF1(_L("FAIL: Missing SIS file name"));
    1.97 +        INFO_PRINTF1(HTML_RED_OFF);
    1.98 +        SetTestStepResult(EFail);
    1.99 +        return TestStepResult();
   1.100 +        }
   1.101 +    iSisFileName.Copy(str);
   1.102 +    INFO_PRINTF2(_L("Installing '%S'"), &iSisFileName);
   1.103 +            
   1.104 +    // create UI handler and populate the answers from XML file
   1.105 +    iUi = new(ELeave) TUI();
   1.106 +   
   1.107 +	return TestStepResult();
   1.108 +    }
   1.109 +
   1.110 +
   1.111 +
   1.112 +
   1.113 +/**
   1.114 + * Override of base class pure virtual
   1.115 + * Demonstrates reading configuration parameters fom an ini file section
   1.116 + * @return TVerdict code
   1.117 + */
   1.118 +TVerdict CinstallStep::doTestStepL()
   1.119 +    {
   1.120 +    INFO_PRINTF1(KInstallStep);
   1.121 +
   1.122 +    // Try to set up a repository object, we'll need this if any
   1.123 +    // NotifyRequests are listed. Only open the repository if there are
   1.124 +    // notifys.
   1.125 +  	
   1.126 + 	TInt bRet;
   1.127 +
   1.128 +    // First find out if the install step is supposed to be successful.
   1.129 +    TInt insterr=KErrNone;
   1.130 +    bRet = GetIntFromConfig(ConfigSection(), KExpectedError, insterr );
   1.131 +    if(bRet!=1) insterr=KErrNone;
   1.132 +
   1.133 +    CInstallPrefs* prefs = CInstallPrefs::NewLC();
   1.134 +    TInt err = DoInstallL(*prefs);        
   1.135 +	iInstallSuccess = (err == KErrNone);
   1.136 +    
   1.137 +    // Expected error?
   1.138 +    if(insterr != err)
   1.139 +        {
   1.140 +        INFO_PRINTF1(HTML_RED);
   1.141 +        ERR_PRINTF3( _L("Installation return wrong error code, expected %d, got %d."), insterr, err );
   1.142 +        INFO_PRINTF1(HTML_RED_OFF);
   1.143 +        SetTestStepResult(EFail);
   1.144 +        }
   1.145 +   else
   1.146 +        {
   1.147 +        INFO_PRINTF2( _L("Installation error code %d (expected)."), err );
   1.148 +        }
   1.149 + 
   1.150 + 
   1.151 +    CleanupStack::PopAndDestroy(prefs);
   1.152 +
   1.153 +    return TestStepResult();
   1.154 +    
   1.155 +    }
   1.156 +
   1.157 +TInt CinstallStep::DoInstallL(CInstallPrefs& aInstallPrefs)
   1.158 +    {
   1.159 +    TInt err=KErrNone;
   1.160 +    RFs fs;
   1.161 +    RFile file;
   1.162 +    switch (iInstallType)
   1.163 +        {
   1.164 +        case EUseFileName:
   1.165 +            err = Launcher::Install(*iUi, iSisFileName, aInstallPrefs);
   1.166 +            INFO_PRINTF2(_L("EUseFileName: Install return code was %d"), err);
   1.167 +            return err;
   1.168 +
   1.169 +        case EUseOpenFileName:
   1.170 +        // open the file as a shared for readers only
   1.171 +            {
   1.172 +            User::LeaveIfError(fs.Connect());
   1.173 +            fs.ShareProtected();
   1.174 +            CleanupClosePushL(fs);
   1.175 +            RFile file;
   1.176 +            User::LeaveIfError(file.Open(fs, iSisFileName, EFileShareReadersOnly));
   1.177 +            CleanupClosePushL(file);
   1.178 +            TInt error = Launcher::Install(*iUi, iSisFileName, aInstallPrefs);
   1.179 +            CleanupStack::PopAndDestroy(2, &fs);
   1.180 +            return error;            
   1.181 +            }
   1.182 +
   1.183 +        case EUseFileHandle:
   1.184 +            {
   1.185 +            RFs fs;
   1.186 +            User::LeaveIfError(fs.Connect());
   1.187 +            fs.ShareProtected();
   1.188 +            CleanupClosePushL(fs);
   1.189 +            RFile file;
   1.190 +            User::LeaveIfError(file.Open(fs, iSisFileName, 0));
   1.191 +            CleanupClosePushL(file);
   1.192 +            TInt error=Launcher::Install(*iUi, file, aInstallPrefs);
   1.193 +            CleanupStack::PopAndDestroy(2, &fs);
   1.194 +            return error;
   1.195 +            }
   1.196 +
   1.197 +        case ECheckExitValue:
   1.198 +            {
   1.199 +            // This test case does an install and checks for pass or failure
   1.200 +            // TInt err = Launcher::Install(*iUi, iSisFileName, *prefs);
   1.201 +            TInt err = Launcher::Install(*iUi, iSisFileName, aInstallPrefs);
   1.202 +            INFO_PRINTF2(_L("Install return code was %d"), err);
   1.203 +            
   1.204 +            TPtrC expected;
   1.205 +            if (!GetStringFromConfig(ConfigSection(), _L("result"), expected))
   1.206 +                {
   1.207 +                return ETestSuiteError;
   1.208 +                }
   1.209 +            else 
   1.210 +                {
   1.211 +                _LIT(KSucess, "sucess");
   1.212 +                _LIT(KFailure, "failure");
   1.213 +                
   1.214 +                TVerdict result;
   1.215 +                
   1.216 +                if (expected.CompareF(KSucess) == 0)
   1.217 +                    {
   1.218 +                    result = (err == KErrNone ? EPass : EFail);
   1.219 +                    }
   1.220 +                else if (expected.CompareF(KFailure) == 0)
   1.221 +                    {
   1.222 +                    result = (err != KErrNone ? EPass : EFail);
   1.223 +                    }
   1.224 +                else 
   1.225 +                    {
   1.226 +                    result = ETestSuiteError;
   1.227 +                    }
   1.228 +                return result;
   1.229 +                }
   1.230 +            }
   1.231 +            // Unreachable.
   1.232 +//          break;    
   1.233 +        }
   1.234 +    
   1.235 +    // Shouldn't get here
   1.236 +    return KErrGeneral;
   1.237 +    }
   1.238 +
   1.239 +/**
   1.240 + * Override of base class virtual
   1.241 + * @return TVerdict code
   1.242 + */
   1.243 +TVerdict CinstallStep::doTestStepPostambleL()
   1.244 +    {
   1.245 +    CheckFilesExistL();
   1.246 +    CheckFilesNonExistL();
   1.247 +    return TestStepResult();
   1.248 +    }
   1.249 +
   1.250 +/** Need to wait a few seconds for ECOM to
   1.251 +discover the change. Otherwise the next step may fail.
   1.252 +@pre caller has checked the install/uninstall
   1.253 +is successful. Otherwise will waste 30 s.
   1.254 +*/
   1.255 +void Cinstallers::WaitForEComReDiscoveryL()
   1.256 +	{
   1.257 +    REComSession& ecomSession = REComSession::OpenL();
   1.258 +	CleanupClosePushL(ecomSession);
   1.259 +	TRequestStatus ecomstatus;
   1.260 +	ecomSession.NotifyOnChange(ecomstatus);
   1.261 +
   1.262 +	RTimer timer;
   1.263 +	User::LeaveIfError(timer.CreateLocal());
   1.264 +	CleanupClosePushL(timer);
   1.265 +	const TInt KInterval = 30000000; // 30 s
   1.266 +	TRequestStatus timerstatus;
   1.267 +	timer.After(timerstatus, KInterval);
   1.268 +
   1.269 +	User::WaitForRequest(ecomstatus, timerstatus);
   1.270 +
   1.271 +	if (ecomstatus == KRequestPending)
   1.272 +		{
   1.273 +		ecomSession.CancelNotifyOnChange(ecomstatus);
   1.274 +		User::WaitForRequest(ecomstatus);
   1.275 +
   1.276 +        INFO_PRINTF1(HTML_RED);
   1.277 +        ERR_PRINTF1(_L("No notification from ECOM"));
   1.278 +        INFO_PRINTF1(HTML_RED_OFF);
   1.279 +		// does not affect test result as this is the equivalent of
   1.280 +		// DELAY 30000 in the script.
   1.281 +		}
   1.282 +	else
   1.283 +		{
   1.284 +		timer.Cancel();
   1.285 +		User::WaitForRequest(timerstatus);
   1.286 +        INFO_PRINTF1(_L("ECOM has discovered the change"));
   1.287 +		}
   1.288 +
   1.289 +	CleanupStack::PopAndDestroy(2); // ecomsession, RTimer
   1.290 +	REComSession::FinalClose();
   1.291 +	}
   1.292 +
   1.293 +/** Resolver installation step */
   1.294 +
   1.295 +/** constructor */
   1.296 +CResolverInstallStep::CResolverInstallStep(CinstallStep::TInstallType aInstallType)
   1.297 +	: CinstallStep(aInstallType)
   1.298 +	{
   1.299 +	}
   1.300 +
   1.301 +/** destructor */
   1.302 +CResolverInstallStep::~CResolverInstallStep()
   1.303 +	{
   1.304 +	iLibrary.Close();
   1.305 +	}
   1.306 +
   1.307 +/** uses CinstallStep::dotestStepL to do the install.
   1.308 +But adds an optional step of loading a DLL before, and
   1.309 +a step to wait for ECom rediscovery after.
   1.310 +*/
   1.311 +TVerdict CResolverInstallStep::doTestStepL()
   1.312 +	{
   1.313 +	TPtrC libraryPath;
   1.314 +    if (GetStringFromConfig(ConfigSection(), _L("loadresolver"), libraryPath))
   1.315 +		{
   1.316 +		TUidType nullUid;
   1.317 +		TInt err = iLibrary.Load(libraryPath, nullUid);
   1.318 +        if (err != KErrNone)
   1.319 +	        {
   1.320 +	        ERR_PRINTF2(_L("Preload resolver failed %d"), err);
   1.321 +	        return EFail;
   1.322 +	        }
   1.323 +		}
   1.324 +
   1.325 +	// continue to do the actual install.
   1.326 +	TVerdict ret = CinstallStep::doTestStepL();
   1.327 +
   1.328 +	if (iInstallSuccess)
   1.329 +		{
   1.330 +		WaitForEComReDiscoveryL();
   1.331 +		}
   1.332 +
   1.333 +	return ret;
   1.334 +	}
   1.335 +
   1.336 +/* *******************************************************************************
   1.337 + *  Code below was copies from
   1.338 + *       \master\common\generic\security\swi\test\tuiscriptadaptors\tswisstep.cpp
   1.339 + *
   1.340 + *  If there are any problems with this code, it may be worth contacting the
   1.341 + *  Security team.
   1.342 + * *******************************************************************************/
   1.343 +
   1.344 +//
   1.345 +// CuninstallStep
   1.346 +//
   1.347 +
   1.348 +CuninstallStep::~CuninstallStep()
   1.349 +    {
   1.350 +    delete iUi;
   1.351 +    }
   1.352 +
   1.353 +CuninstallStep::CuninstallStep(TUninstallType aType, TBool aDoCancelTest)
   1.354 +    : iType(aType), iDoCancelTest(aDoCancelTest)
   1.355 +    {
   1.356 +    // Call base class method to set up the human readable name for logging
   1.357 +    SetTestStepName(KUninstallStep);
   1.358 +    }
   1.359 +
   1.360 +    
   1.361 +    
   1.362 +    
   1.363 +/**
   1.364 + * Override of base class virtual. Prepares for the test run of SWIS
   1.365 + * @return TVerdict code
   1.366 + */
   1.367 +TVerdict CuninstallStep::doTestStepPreambleL()
   1.368 +    {
   1.369 +    // get step parameters
   1.370 +    TInt uid=0;
   1.371 +
   1.372 +    TPtrC str;
   1.373 +
   1.374 +    if (!GetHexFromConfig(ConfigSection(), _L("uid"), uid))
   1.375 +        {
   1.376 +        INFO_PRINTF1(HTML_RED);
   1.377 +        ERR_PRINTF1(_L("Missing uid"));
   1.378 +        INFO_PRINTF1(HTML_RED_OFF);
   1.379 +        SetTestStepResult(EFail);
   1.380 +        return TestStepResult();
   1.381 +        }
   1.382 +
   1.383 +    iUid.iUid=uid;
   1.384 +        
   1.385 +    if (iType == EByPackage)
   1.386 +        {
   1.387 +        TPtrC vendorName;
   1.388 +        if (!GetStringFromConfig(ConfigSection(), _L("vendorName"), vendorName))
   1.389 +            {
   1.390 +            INFO_PRINTF1(HTML_RED);
   1.391 +            ERR_PRINTF1(_L("Missing Vendor Name"));
   1.392 +            INFO_PRINTF1(HTML_RED_OFF);
   1.393 +            SetTestStepResult(EFail);
   1.394 +            return TestStepResult();
   1.395 +            }
   1.396 +        iVendorName.Set(vendorName);
   1.397 +        
   1.398 +        TPtrC packageName;
   1.399 +        if (!GetStringFromConfig(ConfigSection(), _L("packageName"), packageName))
   1.400 +            {
   1.401 +            INFO_PRINTF1(HTML_RED);
   1.402 +            ERR_PRINTF1(_L("Missing Package Name"));
   1.403 +            INFO_PRINTF1(HTML_RED_OFF);
   1.404 +            SetTestStepResult(EFail);
   1.405 +            return TestStepResult();
   1.406 +            }
   1.407 +        iPackageName.Set(packageName);
   1.408 +            
   1.409 +        INFO_PRINTF4(_L("Uninstalling %D, %S, %S"), 
   1.410 +            iUid.iUid, &iPackageName, &iVendorName);
   1.411 +        // create UI handler and populate the answers from XML file
   1.412 +        iUi = new(ELeave) TUI;
   1.413 +        
   1.414 +        }
   1.415 +    else if (iType== EByUid)
   1.416 +        {
   1.417 +        INFO_PRINTF2(_L("Uninstalling '%D'"), iUid.iUid);
   1.418 +        // create UI handler and populate the answers from XML file
   1.419 +        iUi = new(ELeave) TUI;
   1.420 +        
   1.421 +        }
   1.422 +
   1.423 +    return TestStepResult();
   1.424 +    }
   1.425 +
   1.426 +/**
   1.427 + * Override of base class pure virtual
   1.428 + * Demonstrates reading configuration parameters fom an ini file section
   1.429 + * @return TVerdict code
   1.430 + */
   1.431 +
   1.432 +TInt CuninstallStep::DoUninstallL()
   1.433 +    {
   1.434 +    TInt err=0;
   1.435 +    
   1.436 +    INFO_PRINTF1(KUninstallStep);
   1.437 +
   1.438 +    if (iType == EByUid)
   1.439 +        {
   1.440 +        // launch the installation
   1.441 +        err = Launcher::Uninstall(*iUi, iUid); 
   1.442 +        return err; 
   1.443 +        }
   1.444 +    else if (iType == EByPackage)
   1.445 +        {
   1.446 +        err = 0;
   1.447 +        
   1.448 +        // Go through list of packages from base package to get augmentations.
   1.449 +        CSisRegistryPackage* uninstallPackage=CSisRegistryPackage::NewLC(iUid, iPackageName, iVendorName);
   1.450 +        INFO_PRINTF3(_L("UnInstalling '%S', '%S'"), &iPackageName, &iVendorName);
   1.451 +        
   1.452 +        // err=Launcher::Uninstall(*iUi, *uninstallPackage);
   1.453 +         
   1.454 +		RSisRegistrySession registrySession;
   1.455 +        User::LeaveIfError(registrySession.Connect());
   1.456 +        CleanupClosePushL(registrySession);
   1.457 +
   1.458 +        RSisRegistryEntry registryEntry;
   1.459 +    
   1.460 +        User::LeaveIfError(registryEntry.Open(registrySession, iUid));
   1.461 +        CleanupClosePushL(registryEntry);
   1.462 +
   1.463 +        CSisRegistryPackage* package=registryEntry.PackageL();
   1.464 +        CleanupStack::PushL(package);
   1.465 +        
   1.466 +        if (*package == *uninstallPackage)
   1.467 +            {
   1.468 +            err=Launcher::Uninstall(*iUi, *package); 
   1.469 +            }
   1.470 +        else
   1.471 +            {
   1.472 +            // check augmenations
   1.473 +            RPointerArray<CSisRegistryPackage> augmentationPackages;
   1.474 +	        CleanupResetAndDestroy<RPointerArray<CSisRegistryPackage> >::PushL(augmentationPackages);
   1.475 +
   1.476 +            registryEntry.AugmentationsL(augmentationPackages);
   1.477 +            
   1.478 +            for (TInt i=0; i < augmentationPackages.Count(); ++i)
   1.479 +                {
   1.480 +                if (*augmentationPackages[i] == *uninstallPackage)
   1.481 +                    {
   1.482 +                    err=User::LeaveIfError(Launcher::Uninstall(*iUi, *augmentationPackages[i])); 
   1.483 +                    break;
   1.484 +                    }
   1.485 +                }
   1.486 +                
   1.487 +            if (err != 0)
   1.488 +	        	{
   1.489 +	        	INFO_PRINTF1(HTML_RED);
   1.490 +	            ERR_PRINTF2(_L("Package Augmentation Not found for '%s' "), &iPackageName);
   1.491 +	            INFO_PRINTF1(HTML_RED_OFF);
   1.492 +	            SetTestStepResult(EFail);
   1.493 +	            return TestStepResult();
   1.494 +	        	}
   1.495 +
   1.496 +            CleanupStack::PopAndDestroy(&augmentationPackages);
   1.497 +            }    
   1.498 +        
   1.499 +        CleanupStack::PopAndDestroy(3, &registrySession);
   1.500 +        CleanupStack::PopAndDestroy(uninstallPackage);
   1.501 +        }
   1.502 +    return err;
   1.503 +    }
   1.504 +
   1.505 +/* ******************************************************************************
   1.506 + *  End of copied code.
   1.507 + * ******************************************************************************/
   1.508 +
   1.509 +TVerdict CuninstallStep::doTestStepL()
   1.510 +    {
   1.511 +    INFO_PRINTF1(KUninstallStep);
   1.512 +
   1.513 +
   1.514 +
   1.515 +    // Wait a fraction over a second. This is necessary because we may just
   1.516 +    // have been messing about with repository settings and if the install
   1.517 +    // happens really quickly we might not see a datestamp change (esp. on
   1.518 +    // hardware where the timestamp granularity is poor).
   1.519 +    User::After(1100000);
   1.520 +    User::LeaveIfError(DoUninstallL());
   1.521 +
   1.522 +    return TestStepResult();
   1.523 +    }
   1.524 +
   1.525 +/**
   1.526 + * Override of base class virtual
   1.527 + * @return TVerdict code
   1.528 + */
   1.529 +TVerdict CuninstallStep::doTestStepPostambleL()
   1.530 +    {
   1.531 +    CheckFilesExistL();
   1.532 +    CheckFilesNonExistL();
   1.533 +    return TestStepResult();
   1.534 +    }
   1.535 +
   1.536 +// CResolverUninstallStep class
   1.537 +
   1.538 +/** constructor */
   1.539 +CResolverUninstallStep::CResolverUninstallStep(CuninstallStep::TUninstallType aType)
   1.540 +	: CuninstallStep(aType)
   1.541 +	{
   1.542 +	}
   1.543 +
   1.544 +/** nothing to do in destructor */
   1.545 +CResolverUninstallStep::~CResolverUninstallStep()
   1.546 +	{
   1.547 +	}
   1.548 +
   1.549 +/** runs CuninstallStep::doTestStepL and then
   1.550 +do a WaitForEComReDiscoveryL */
   1.551 +TVerdict CResolverUninstallStep::doTestStepL()
   1.552 +	{
   1.553 +	TVerdict ret = CuninstallStep::doTestStepL();
   1.554 +	if (ret == EPass)
   1.555 +		{
   1.556 +		WaitForEComReDiscoveryL();
   1.557 +		}
   1.558 +    return ret;
   1.559 +	}
   1.560 +
   1.561 +Cinstallers::~Cinstallers()
   1.562 +/**
   1.563 + * Destructor
   1.564 + */
   1.565 +    {
   1.566 +    }
   1.567 +
   1.568 +Cinstallers::Cinstallers()
   1.569 +/**
   1.570 + * Constructor
   1.571 + */
   1.572 +    {
   1.573 +    }
   1.574 +
   1.575 +void Cinstallers::CheckFilesL(const TDesC& aNumEntries,
   1.576 +                                   const TDesC& aEntryBase, TBool aCheckExist)
   1.577 +    {
   1.578 +    TInt numEntries=0;
   1.579 +    TInt nErr=0;
   1.580 +
   1.581 +    _LIT(Report_CheckFiles, "CheckFilesL");
   1.582 +    INFO_PRINTF1(Report_CheckFiles);
   1.583 +
   1.584 +    RFs fs;
   1.585 +    User::LeaveIfError(fs.Connect());
   1.586 +    fs.ShareProtected();
   1.587 +    CleanupClosePushL(fs);
   1.588 +
   1.589 +    if (GetIntFromConfig(ConfigSection(), aNumEntries, numEntries) && numEntries!=0)
   1.590 +        {
   1.591 +        INFO_PRINTF1(Report_CheckFiles);
   1.592 +        TPtrC fname;
   1.593 +        for (TInt i=0; i<numEntries; i++)
   1.594 +            {
   1.595 +            // construct name of the key
   1.596 +            const TInt KKeyBufSize=64;
   1.597 +            TBuf<KKeyBufSize> keyBuf(aEntryBase);
   1.598 +            keyBuf.AppendNum(i);
   1.599 +            
   1.600 +            if (GetStringFromConfig(ConfigSection(), keyBuf, fname))
   1.601 +                {            
   1.602 +                TInt timeout=1e7;
   1.603 +                TInt wait=2.5e5;
   1.604 +                // check if the file (doesn't) exist. Give it some time if
   1.605 +                // we see a failure in case there's a race with the
   1.606 +                // (un)installer 
   1.607 +                
   1.608 +                if (aCheckExist)
   1.609 +                    {
   1.610 +                    TInt sec=timeout;
   1.611 +                    while (!BaflUtils::FileExists(fs, fname) && (sec>0))
   1.612 +                        {
   1.613 +                        User::After(wait);
   1.614 +                        sec -= wait;
   1.615 +                        };
   1.616 +                    if (!BaflUtils::FileExists(fs, fname))
   1.617 +                        {
   1.618 +                        INFO_PRINTF1(HTML_RED);
   1.619 +                        ERR_PRINTF2(_L("File missing: %S"), &fname);
   1.620 +                        INFO_PRINTF1(HTML_RED_OFF);
   1.621 +                        nErr++;
   1.622 +                        }
   1.623 +                    }
   1.624 +                else
   1.625 +                    {
   1.626 +                    TInt sec=timeout;
   1.627 +                    while (BaflUtils::FileExists(fs, fname) && (sec>0))
   1.628 +                        {
   1.629 +                        User::After(wait);
   1.630 +                        sec -= wait;
   1.631 +                        };
   1.632 +                    if (BaflUtils::FileExists(fs, fname))
   1.633 +                        {
   1.634 +                        INFO_PRINTF1(HTML_RED);
   1.635 +                        ERR_PRINTF2(_L("File exists (but shouldn't): %S"), &fname);
   1.636 +                        INFO_PRINTF1(HTML_RED_OFF);
   1.637 +                        nErr++;
   1.638 +                        }
   1.639 +                    }
   1.640 +                }
   1.641 +            else
   1.642 +                {
   1.643 +                // the string must exist, otherwise the config is invalid
   1.644 +                INFO_PRINTF1(HTML_RED);
   1.645 +                ERR_PRINTF2(_L("Missing file name for key '%S'"), &keyBuf);
   1.646 +                INFO_PRINTF1(HTML_RED_OFF);
   1.647 +                nErr++;
   1.648 +                }
   1.649 +            }
   1.650 +        }
   1.651 +
   1.652 +        if (nErr)
   1.653 +            SetTestStepResult(EFail);
   1.654 +        CleanupStack::PopAndDestroy(1, &fs);
   1.655 +    }
   1.656 +
   1.657 +void Cinstallers::CheckFilesExistL()
   1.658 +    {
   1.659 +    _LIT(KNumExist, "numexist"); // this specifies how many files to check for
   1.660 +    _LIT(KExistBase, "exist");   // + number (0-based) = file to check for
   1.661 +    CheckFilesL(KNumExist, KExistBase, ETrue);
   1.662 +    }
   1.663 +
   1.664 +void Cinstallers::CheckFilesNonExistL()
   1.665 +    {
   1.666 +    _LIT(KNumNonExist, "numnonexist"); // this specifies how many files to check for
   1.667 +    _LIT(KNonExistBase, "nonexist"); // + number (0-based) = file to check for
   1.668 +    CheckFilesL(KNumNonExist, KNonExistBase, EFalse);
   1.669 +    }
   1.670 +