1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/os/ossrv/lowlevellibsandfws/pluginfw/Framework/DiscovererTest/t_discoverer.cpp Fri Jun 15 03:10:57 2012 +0200
1.3 @@ -0,0 +1,2485 @@
1.4 +// Copyright (c) 2004-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 +// This file contains test classes and their implementations
1.18 +// to test production class CDiscoverer. Where necessary stubs
1.19 +// are implemented to help in writing test harness using RTest.
1.20 +//
1.21 +//
1.22 +
1.23 +#include "Discoverer.h"
1.24 +#include "EComErrorCodes.h"
1.25 +#include "ImplementationInformation.h"
1.26 +#include "DiscovererObserver.h"
1.27 +#include "../EcomTestUtils/EcomTestUtils.h"
1.28 +#include "EComUidCodes.h"
1.29 +#include "RegistryData.h"
1.30 +#include "DriveInfo.h"
1.31 +
1.32 +#include <ecom/ecompanics.h>
1.33 +#include <e32test.h>
1.34 +#include <bautils.h>
1.35 +#include <s32file.h>
1.36 +#include <barsread2.h>
1.37 +#include <e32uid.h>
1.38 +#include <startup.hrh>
1.39 +#include "baspi.h"
1.40 +#include <sacls.h>
1.41 +
1.42 +
1.43 +//New RSC based plugins
1.44 +_LIT(KNewResourceFileName, "C:\\resource\\plugins\\EComExample5.rsc");
1.45 +_LIT(KNewExampleDllFileName, "C:\\sys\\bin\\EComExample5.dll");
1.46 +_LIT(KNewResourceFileNameOnZ, "z:\\RAMOnly\\EComExample5.rsc");
1.47 +_LIT(KNewExampleDllFileNameOnZ, "z:\\RAMOnly\\EComExample5.dll");
1.48 +_LIT(KNewExampleDllFileNameOnly, "EComExample5.dll");
1.49 +_LIT(KNewResourceSearchPath, "\\resource\\plugins\\*");
1.50 +//PlugIn3 RSC based plugins
1.51 +_LIT(KPlugIn3ResourceFileName, "C:\\resource\\plugins\\EComExample12.rsc");
1.52 +_LIT(KPlugIn3ExampleDllFileName, "C:\\sys\\bin\\EComExample12.dll");
1.53 +_LIT(KPlugIn3ResourceFileNameOnZ, "z:\\RAMOnly\\EComExample12.rsc");
1.54 +_LIT(KPlugIn3ExampleDllFileNameOnZ, "z:\\RAMOnly\\EComExample12.dll");
1.55 +_LIT(KPlugIn3ExampleDllFileNameOnly, "EComExample12.dll");
1.56 +
1.57 +//Old DLL based plugins
1.58 +
1.59 +// spi test file
1.60 +_LIT(KEComSpiTestFilePathAndName, "Z:\\Test\\Data\\EcomTest.spi");
1.61 +_LIT(KEComSpiTestFilePlugIn3PathAndName, "Z:\\Test\\Data\\EcomTestType3.spi");
1.62 +// file name detremined from example spi file
1.63 +_LIT(KEComSpiTestFileDllPathAndName, "Z:\\sys\\bin\\EComExample5.dll");
1.64 +_LIT(KEComSpiTestFilePlugIn3DllPathAndName, "Z:\\sys\\bin\\EComExample12.dll");
1.65 +
1.66 +// spi file
1.67 +_LIT(KEComSPIFilePathAndName, "Z:\\private\\10009D8F\\Ecom.spi");
1.68 +
1.69 +const TInt KOneSecond = 1000000;
1.70 +
1.71 +LOCAL_D RFs TheFs;
1.72 +
1.73 +LOCAL_D RTest test(_L("t_discoverer.exe"));
1.74 +
1.75 +LOCAL_D CTrapCleanup* TheTrapCleanup = NULL;
1.76 +
1.77 +LOCAL_D CActiveScheduler* TheActiveScheduler = NULL;
1.78 +
1.79 +// Used for supressing warning in OOM tests
1.80 +#define __UNUSED_VAR(var) var = var
1.81 +
1.82 +// Used for OOM test
1.83 +#define TEST_OOM_ERR if(err == KErrNoMemory) User::Leave(err)
1.84 +
1.85 +/**
1.86 +Stub classes are provided to act as replacement members for the class
1.87 +under test. This ensures the test class is constructed correctly and its
1.88 +behaviour is also correct within the context of the test. It allows the
1.89 +class to be tested in isolation. Other tests are available that test the
1.90 +interoperability of the class
1.91 +*/
1.92 +class CObserverStub : public CBase, public MDiscovererObserver
1.93 +{
1.94 +public:
1.95 + enum OSState
1.96 + {
1.97 + OSS_Undefined,
1.98 + OSS_NoPlugins,
1.99 + OSS_CriticalPlugins,
1.100 + OSS_DiscoverNonCriticalPlugins,
1.101 + OSS_AllPlugins
1.102 + };
1.103 + static CObserverStub* NewL();
1.104 + virtual ~CObserverStub();
1.105 +
1.106 + // Inherited from MDiscovererObserver
1.107 + virtual void DiscoveriesBegin();
1.108 + virtual void RegisterDiscoveryL(const TDriveName& aDrive,CPluginBase*& aDirEntry,TBool aDatFileExists);
1.109 + virtual void DiscoveriesComplete(TBool aSuccessful, TPluginProcessingTypeIdentifier aProcessingType);
1.110 + virtual void DriveRemovedL(TDriveUnit aDrive);
1.111 + virtual void DriveReinstatedL(TDriveUnit aDrive);
1.112 + virtual void DriveIsSpiBasedL(const TDriveUnit& /*aDrive*/){}
1.113 + virtual TBool NotifiedWithErrorCode(TInt aError);
1.114 + virtual TBool IsAnyDllRegisteredWithDriveL(const TDriveUnit aDrive) const;
1.115 + virtual void SetDiscoveryFlagL(const TDriveUnit &aDrive);
1.116 + virtual void LanguageChangedL(TBool& aLanguageChanged);
1.117 +
1.118 +
1.119 + // Result verifing methods
1.120 + TBool IsDriveMounted(const TDriveUnit aDrive);
1.121 + TBool IsEntryProcessed(CPluginBase*& aDirEntry);
1.122 + //TBool IsSpiEntryProcessed(const TEntry& aEntry);
1.123 + TBool IsDiscoveriesCompleteSuccessfully();
1.124 + void SetDiscoverer(CDiscoverer* aDiscoverer);
1.125 + OSState GetState();
1.126 +
1.127 +private:
1.128 + CObserverStub();
1.129 +
1.130 +private:
1.131 + /** Base class ecom entry */
1.132 + CPluginBase* iEntryBase;
1.133 +
1.134 + /** Information of the dll which contains interface implementations */
1.135 + //TEComEntryDetails iEntry;
1.136 +
1.137 + /** Information of the spi file which contains interface implementations */
1.138 + //TEComSpiResourceEntryDetails iSpiEntry;
1.139 +
1.140 + /** iDriveUnit is drive mounted */
1.141 + TDriveUnit iDriveUnit;
1.142 +
1.143 + /** Flag to indicate whether iDriveUnit is mounted or not */
1.144 + TBool iDriveMounted;
1.145 +
1.146 + /** Flag to indicate whether iEntry is processed or not */
1.147 + TBool iEntryProcessed;
1.148 +
1.149 + /** Flag to indicate whether iSpiEntry is processed or not */
1.150 + TBool iSpiEntryProcessed;
1.151 +
1.152 + /** Flag to indicate whether Discovery process is Complete or not */
1.153 + TBool iDiscoveriesComplete;
1.154 +
1.155 + /** The current start-up state of this object */
1.156 + OSState iState;
1.157 +
1.158 + /** A reference to the CDiscoverer object that this class is observing*/
1.159 + CDiscoverer* iDiscoverer;
1.160 +}; // End of CObserverStub declaration
1.161 +
1.162 +
1.163 +/**
1.164 +The TDiscoverer_StateAccessor class allows to access the private and protected
1.165 +members of production code class CDiscoverer, as its a friend class.
1.166 +*/
1.167 +class TDiscoverer_StateAccessor
1.168 + {
1.169 +public:
1.170 +
1.171 + // Auxiliary functions that provide access to
1.172 + // CDiscoverer private/protected members
1.173 + void ScanDirectoryL(CDiscoverer& aDiscoverer, TDriveUnit aDriveUnit);
1.174 + void ScanDirectoryCancel(CDiscoverer& aDiscoverer);
1.175 + void CompleteNotificationProcessing(CDiscoverer& aDiscoverer);
1.176 + void ValidateEntryL(CDiscoverer& aDiscoverer,
1.177 + const TEntry& aEntry,
1.178 + const TDriveName& aDriveName,
1.179 + CPluginBase*& aEntryToFill,
1.180 + TBool aIsRO);
1.181 + void ValidateEntryL(CDiscoverer& aDiscoverer,
1.182 + RResourceArchive& aRscArchive,
1.183 + CPluginBase*& aEntryToFill);
1.184 + void ProcessEntryL(CDiscoverer& aDiscoverer,const TDriveName& aDrive, CPluginBase*& aEntry, TBool aDatFileExists);
1.185 + void DriveMountedL(CDiscoverer& aDiscoverer, const TDriveUnit aDrive);
1.186 + void DriveUnmountedL(CDiscoverer& aDiscoverer, const TDriveUnit aDrive);
1.187 + void SwiChangeNotificationL(CDiscoverer& aDiscoverer, TInt aSwiOperation);
1.188 + void IdleScanningTimerRunErrorL(CDiscoverer& aDiscoverer, TInt aError);
1.189 + void DirChangeNotifierRunErrorL(CDiscoverer& aDiscoverer, TInt aError);
1.190 + void SwiChangeNotifierRunError(CDiscoverer& aDiscoverer, TInt aError);
1.191 +
1.192 + // Verification functions to check the state of CDiscoverer object against tests
1.193 + TBool IsDriveMounted(CDiscoverer& aDiscoverer, const TDriveUnit aDrive);
1.194 + TBool IsDiscovererActive(CDiscoverer& aDiscoverer);
1.195 + TBool IsDirectoryScanCancelled(CDiscoverer& aDiscoverer);
1.196 + TBool IsScanDirectoryComplete(CDiscoverer& aDiscoverer);
1.197 + TBool IsScanDirectoryPending(CDiscoverer& aDiscoverer, TDriveUnit aDrive);
1.198 + TUint PendingDriveListCount(CDiscoverer& aDiscoverer);
1.199 + CDiscoverer::TDiscovererState State(CDiscoverer& aDiscoverer);
1.200 + CObserverStub::OSState GetDiscovererObserverState(CDiscoverer& aDiscoverer);
1.201 + void ScanDriveL(CDiscoverer& aDiscoverer, TDriveUnit aDrive, TBool aIsRO);
1.202 + void LanguageChangedL(CDiscoverer& aDiscoverer);
1.203 + };
1.204 +
1.205 +/**
1.206 +Scans plugin directories
1.207 +
1.208 +@param aDiscoverer The CDiscoverer class object under test
1.209 +@return void
1.210 +*/
1.211 +void TDiscoverer_StateAccessor::ScanDirectoryL(CDiscoverer& aDiscoverer, TDriveUnit aDriveUnit)
1.212 + {
1.213 + aDiscoverer.RediscoveryScanDirectoryL(aDriveUnit);
1.214 + }
1.215 +
1.216 +/**
1.217 +Stops scanning of the plugin directories
1.218 +
1.219 +@param aDiscoverer The CDiscoverer class object under test
1.220 +*/
1.221 +void TDiscoverer_StateAccessor::ScanDirectoryCancel(CDiscoverer& aDiscoverer)
1.222 + {
1.223 + aDiscoverer.ScanDirectoryCancel();
1.224 + }
1.225 +
1.226 +/**
1.227 +Signals that the directory change has been fully processed.
1.228 +
1.229 +@param aDiscoverer The CDiscoverer class object under test
1.230 +*/
1.231 +void TDiscoverer_StateAccessor::CompleteNotificationProcessing(CDiscoverer& aDiscoverer)
1.232 + {
1.233 + aDiscoverer.CompleteNotificationProcessing();
1.234 + }
1.235 +
1.236 +/**
1.237 +Verifies that the discovered entry is valid.
1.238 +Used to test the Interface Implementation Collection entry
1.239 +
1.240 +@param aDiscoverer The CDiscoverer class object under test
1.241 +@param aEntry The plugin name
1.242 +@param aDriveName The drive containing the entry
1.243 +@param aEntryToFill On return points to complete
1.244 + plugin file name(with path) i.e. aPath + aEntry
1.245 +*/
1.246 +void TDiscoverer_StateAccessor::ValidateEntryL(CDiscoverer& aDiscoverer,
1.247 + const TEntry& aEntry,
1.248 + const TDriveName& aDriveName,
1.249 + CPluginBase*& aEntryToFill,
1.250 + TBool aIsRO)
1.251 + {
1.252 + aDiscoverer.ValidateEntryL(aEntry, aDriveName, aEntryToFill, aIsRO);
1.253 + }
1.254 +
1.255 +/**
1.256 +Verifies that the discovered entry is valid.
1.257 +Used to test the Interface Implementation Collection entry
1.258 +
1.259 +@param aDiscoverer The CDiscoverer class object under test
1.260 +@param aRscArchive reference to the resource archive
1.261 +@param aEntryToFill On return points to complete
1.262 + plugin file name(with path) i.e. aPath + aEntry
1.263 +*/
1.264 +void TDiscoverer_StateAccessor::ValidateEntryL(CDiscoverer& aDiscoverer,
1.265 + RResourceArchive& aRscArchive,
1.266 + CPluginBase*& aEntryToFill)
1.267 + {
1.268 + aDiscoverer.ValidateEntryL(aRscArchive,aEntryToFill);
1.269 + }
1.270 +/**
1.271 +Registers an Interface Implementation Collection
1.272 +
1.273 +@param aDiscoverer The CDiscoverer class object under test
1.274 +@param aEntry This is the plugin name that needs to be registered
1.275 +*/
1.276 +void TDiscoverer_StateAccessor::ProcessEntryL(CDiscoverer& aDiscoverer,const TDriveName& aDrive,
1.277 + CPluginBase*& aEntry, TBool aDatFileExists)
1.278 + {
1.279 + aDiscoverer.ProcessEntryL(aDrive,aEntry,aDatFileExists);
1.280 + }
1.281 +
1.282 +/**
1.283 +Notifies the discoverer of an SWI operation change
1.284 +
1.285 +@param aDiscoverer The CDiscoverer class object under test
1.286 +@param aSwiOperation This new SWI state
1.287 +*/
1.288 +void TDiscoverer_StateAccessor::SwiChangeNotificationL(CDiscoverer& aDiscoverer, TInt aSwiOperation)
1.289 + {
1.290 + aDiscoverer.SwiChangeNotificationL(aSwiOperation);
1.291 + }
1.292 +
1.293 +/**
1.294 +Signals that a drive is available
1.295 +
1.296 +@param aDiscoverer The CDiscoverer class object under test
1.297 +@param aDrive Drive that needs to be mounted
1.298 +*/
1.299 +void TDiscoverer_StateAccessor::DriveMountedL(CDiscoverer& aDiscoverer,
1.300 + const TDriveUnit aDrive)
1.301 + {
1.302 + aDiscoverer.DriveMountedL(aDrive);
1.303 + }
1.304 +
1.305 +/**
1.306 +Signals that a drive is unavailable
1.307 +
1.308 +@param aDiscoverer The CDiscoverer class object under test
1.309 +@param aDrive Drive that needs to be unmounted/removed
1.310 +*/
1.311 +void TDiscoverer_StateAccessor::DriveUnmountedL(CDiscoverer& aDiscoverer,
1.312 + const TDriveUnit aDrive)
1.313 + {
1.314 + aDiscoverer.DriveUnmountedL(aDrive);
1.315 + }
1.316 +
1.317 +/**
1.318 +Checks whether CDiscoverer object has successfully completed with
1.319 +the scanning of the plugin directories on all drives
1.320 +
1.321 +@param aDiscoverer The CDiscoverer class object under test
1.322 +@return true if notification has been processed on all drives.
1.323 + false if there is notification processing pending on any drive
1.324 +*/
1.325 +TBool TDiscoverer_StateAccessor::IsScanDirectoryComplete(CDiscoverer& aDiscoverer)
1.326 + {
1.327 + // check state of discoverer to see if all pending drives have been scanned.
1.328 + return(aDiscoverer.State() == CDiscoverer::EDisc_AllPluginsDisc);
1.329 + }
1.330 +
1.331 +/**
1.332 +Checks whether a notification has been signaled but not processed on specified drive.
1.333 +
1.334 +Error Condition : Leaves with KErrNotFound if the drive is not registered.
1.335 +@param aDiscoverer The CDiscoverer class object under test
1.336 +@param aDrive The drive to check
1.337 +@return true if notification has been processed on the specified drive.
1.338 + false if notification processing is pending
1.339 +*/
1.340 +TBool TDiscoverer_StateAccessor::IsScanDirectoryPending(CDiscoverer& aDiscoverer, TDriveUnit aDrive)
1.341 + {
1.342 + if(aDiscoverer.iScanningTimer->iPendingDriveList.Find(aDrive)!=KErrNotFound)
1.343 + {
1.344 + return ETrue;
1.345 + }
1.346 + else
1.347 + {
1.348 + return EFalse;
1.349 + }
1.350 + }
1.351 +
1.352 +/**
1.353 +Checks the current count of drives in the list waiting for processing.
1.354 +
1.355 +@param aDiscoverer The CDiscoverer class object under test
1.356 +@return TUint
1.357 +*/
1.358 +TUint TDiscoverer_StateAccessor::PendingDriveListCount(CDiscoverer& aDiscoverer)
1.359 + {
1.360 + return(aDiscoverer.iScanningTimer->iPendingDriveList.Count());
1.361 + }
1.362 +
1.363 +/**
1.364 +Checks that CDiscoverer object is not scanning the plugin directories.
1.365 +
1.366 +@param aDiscoverer The CDiscoverer class object under test
1.367 +@return true if plugin dirctory scanning is stopped.
1.368 +*/
1.369 +TBool TDiscoverer_StateAccessor::IsDirectoryScanCancelled(CDiscoverer& aDiscoverer)
1.370 + {
1.371 + if(!aDiscoverer.iDirScanner)
1.372 + {
1.373 + return ETrue;
1.374 + }
1.375 + return EFalse;
1.376 + }
1.377 +
1.378 +/**
1.379 +Checks that CDiscoverer object is currently activated for the plugin dir scanning
1.380 +
1.381 +@param aDiscoverer The CDiscoverer class object under test
1.382 +@return true if Discoverer object is tracking changes in the plugin directories in each drive.
1.383 +*/
1.384 +TBool TDiscoverer_StateAccessor::IsDiscovererActive(CDiscoverer& aDiscoverer)
1.385 + {
1.386 + //Return ETrue if both iScanningTimer & directory notifier(s) are active
1.387 + TBool isActive = ETrue;
1.388 +
1.389 + for(TInt index = 0; index <aDiscoverer.iRscDirNotifierList.Count(); index++)
1.390 + {
1.391 + if(!(aDiscoverer.iRscDirNotifierList[index]&& aDiscoverer.iRscDirNotifierList[index]->IsActive()))
1.392 + {
1.393 + // iRscDirNotifierList should be active, as each active object on list is constantly
1.394 + // looking for changes in the plugin directories in each drive.
1.395 + isActive = EFalse;
1.396 + break;
1.397 + }
1.398 + }
1.399 + return isActive;
1.400 + }
1.401 +
1.402 +/**
1.403 +Verifies whether given drive is registered
1.404 +
1.405 +@param aDiscoverer The CDiscoverer class object under test
1.406 +@param aDrive Drive that needs to be verified for registration
1.407 +@return return true if given drive is installed
1.408 +*/
1.409 +TBool TDiscoverer_StateAccessor::IsDriveMounted(CDiscoverer& aDiscoverer,
1.410 + const TDriveUnit aDrive)
1.411 + {
1.412 + TBool isMounted = ETrue;
1.413 + if(aDiscoverer.iDrivesDiscovered.Find(aDrive) == KErrNotFound)
1.414 + {
1.415 + isMounted = EFalse;
1.416 + }
1.417 + return isMounted;
1.418 + }
1.419 +
1.420 +/**
1.421 +Scans plugin directories
1.422 +
1.423 +@param aDiscoverer The CDiscoverer class object under test
1.424 +@param aDrive The drive which is scanned
1.425 +@param aIsRO Whether the drive is ready-only
1.426 +@return true if plugin directorie in each drive get scaned successfully
1.427 +*/
1.428 +void TDiscoverer_StateAccessor::ScanDriveL(CDiscoverer& aDiscoverer, TDriveUnit aDrive, TBool aIsRO)
1.429 + {
1.430 + return aDiscoverer.iDirScanner->ScanDriveL(aDrive, aIsRO);
1.431 + }
1.432 +void TDiscoverer_StateAccessor::LanguageChangedL(CDiscoverer& aDiscoverer)
1.433 + {
1.434 + aDiscoverer.LanguageChangeNotificationL();
1.435 + }
1.436 +/**
1.437 +Retrieve the object's current state.
1.438 +
1.439 +@param aDiscoverer The CDiscoverer class object under test
1.440 +@return TDiscovererState the current state of the CDiscoverer
1.441 +class object under test
1.442 +*/
1.443 +CDiscoverer::TDiscovererState TDiscoverer_StateAccessor::State(CDiscoverer& aDiscoverer)
1.444 + {
1.445 + return aDiscoverer.State();
1.446 + }
1.447 +
1.448 +CObserverStub::OSState TDiscoverer_StateAccessor::GetDiscovererObserverState(CDiscoverer& aDiscoverer)
1.449 + {
1.450 + CObserverStub* discovererObserver =
1.451 + static_cast<CObserverStub*>(&aDiscoverer.iDiscovererObserver);
1.452 + return discovererObserver->GetState();
1.453 + }
1.454 +
1.455 +/**
1.456 +Call the CIdleScanningTimer RunError funtion
1.457 +
1.458 +@param aDiscoverer The CDiscoverer class object under test
1.459 +@param aError The error code to pass to the RunError function
1.460 +*/
1.461 +void TDiscoverer_StateAccessor::IdleScanningTimerRunErrorL(CDiscoverer& aDiscoverer, TInt aError)
1.462 + {
1.463 + aDiscoverer.iScanningTimer->RunError(aError);
1.464 + }
1.465 +
1.466 +/**
1.467 +Call the CDirChangeNotifier RunError funtion
1.468 +
1.469 +@param aDiscoverer The CDiscoverer class object under test
1.470 +@param aError The error code to pass to the RunError function
1.471 +*/
1.472 +void TDiscoverer_StateAccessor::DirChangeNotifierRunErrorL(CDiscoverer& aDiscoverer, TInt aError)
1.473 + {
1.474 + aDiscoverer.iRscDirNotifierList[0]->RunError(aError);
1.475 + }
1.476 +
1.477 +/**
1.478 +Call the CSwiChangeNotifier RunError funtion
1.479 +
1.480 +@param aDiscoverer The CDiscoverer class object under test
1.481 +@param aError The error code to pass to the RunError function
1.482 +*/
1.483 +void TDiscoverer_StateAccessor::SwiChangeNotifierRunError(CDiscoverer& aDiscoverer, TInt aError)
1.484 + {
1.485 + aDiscoverer.iSwiChangeNotifier->RunError(aError);
1.486 + }
1.487 +
1.488 +/**
1.489 +Creates an instance of CObserverStub class.
1.490 +
1.491 +@return The new'ed object.
1.492 +*/
1.493 +CObserverStub* CObserverStub::NewL()
1.494 + {
1.495 + return new(ELeave) CObserverStub();
1.496 + }
1.497 +
1.498 +/**
1.499 +Destructor
1.500 +
1.501 +@post This object is properly destroyed.
1.502 +*/
1.503 +CObserverStub::~CObserverStub()
1.504 + {
1.505 + // do nothing;
1.506 + }
1.507 +
1.508 +/**
1.509 +Default constructor.
1.510 +
1.511 +@post The object is properly constructed.
1.512 +*/
1.513 +CObserverStub::CObserverStub()
1.514 + :CBase(),
1.515 + iDriveUnit(EDriveC),
1.516 + iDriveMounted(EFalse),
1.517 + iEntryProcessed(EFalse),
1.518 + iSpiEntryProcessed(EFalse),
1.519 + iDiscoveriesComplete(EFalse),
1.520 + iState(OSS_NoPlugins)
1.521 + {
1.522 + // do nothing;
1.523 + }
1.524 +
1.525 +/**
1.526 +MDiscovererObserver callback method, to signal that a discovery
1.527 +session is starting.
1.528 +*/
1.529 +void CObserverStub::DiscoveriesBegin()
1.530 + {
1.531 + iDiscoveriesComplete = EFalse;
1.532 + }
1.533 +
1.534 +void CObserverStub::SetDiscoveryFlagL(const TDriveUnit & /*aDrive*/)
1.535 + {
1.536 + iDiscoveriesComplete = ETrue;
1.537 + }
1.538 +/**
1.539 +MDiscovererObserver callback method to register an Ecom Spi file.
1.540 +
1.541 +@param aEntry The Ecom file that needs to be registered
1.542 +*/
1.543 +void CObserverStub::RegisterDiscoveryL(const TDriveName& /* aDriveName */,CPluginBase*& aEntry,TBool /* aDatFileExists*/)
1.544 + {
1.545 + iEntryBase = aEntry;
1.546 + iSpiEntryProcessed = ETrue;
1.547 + }
1.548 +
1.549 +/**
1.550 +MDiscovererObserver callback method, to signal that a discovery
1.551 +session is complete.
1.552 +
1.553 +@param aSuccessful Indicates discoveries process completed successfully or not
1.554 +@param aProcessingType indicates the type of processing for plugins
1.555 + for ensuring that plugins are not processed multiple times
1.556 + during start-up phase
1.557 +*/
1.558 +void CObserverStub::DiscoveriesComplete(TBool aSuccessful, TPluginProcessingTypeIdentifier aProcessingType)
1.559 + {
1.560 + iDiscoveriesComplete = aSuccessful;
1.561 +
1.562 + switch(iState)
1.563 + {
1.564 + case OSS_NoPlugins:
1.565 + if(aProcessingType == EPluginProcessingTypeCriticalOnly &&
1.566 + iDiscoverer->State() == CDiscoverer::EDisc_CriticalPluginsDisc)
1.567 + {
1.568 + iState = OSS_CriticalPlugins;
1.569 + }
1.570 + else if(aProcessingType == EPluginProcessingTypeAll &&
1.571 + iDiscoverer->State() == CDiscoverer::EDisc_AllPluginsDisc)
1.572 + {
1.573 + iState = OSS_AllPlugins;
1.574 + }
1.575 + break;
1.576 + case OSS_CriticalPlugins:
1.577 + if(aProcessingType == EPluginProcessingTypeNonCriticalOnly &&
1.578 + iDiscoverer->State() == CDiscoverer::EDisc_AllPluginsDisc)
1.579 + {
1.580 + iState = OSS_AllPlugins;
1.581 + }
1.582 + break;
1.583 + }
1.584 + }
1.585 +
1.586 +/**
1.587 +Verifies whether given plugin entry is registered
1.588 +
1.589 +@param aDirEntry The Ecom plugin that to be checked for registration.
1.590 +@return true if given plugin is registered
1.591 +*/
1.592 +TBool CObserverStub::IsEntryProcessed(CPluginBase*& aDirEntry)
1.593 + {
1.594 + if(iEntryProcessed && (iEntryBase->iDllThirdUid == aDirEntry->iDllThirdUid))
1.595 + {
1.596 + return ETrue;
1.597 + }
1.598 +
1.599 + return EFalse;
1.600 + }
1.601 +
1.602 +/**
1.603 +MDiscovererObserver callback method, to signal that a Drive
1.604 +is removed/dismounted.
1.605 +
1.606 +@param aDrive The drive that is removed.
1.607 +*/
1.608 +void CObserverStub::DriveRemovedL(TDriveUnit aDrive)
1.609 + {
1.610 + iDriveMounted = EFalse;
1.611 + iDriveUnit = aDrive;
1.612 + }
1.613 +
1.614 +/**
1.615 +MDiscovererObserver callback method, to signal that a Drive
1.616 +is reinstalled.
1.617 +
1.618 +@param aDrive The drive that is available now.
1.619 +*/
1.620 +void CObserverStub::DriveReinstatedL(TDriveUnit aDrive)
1.621 + {
1.622 + iDriveMounted = ETrue;
1.623 + iDriveUnit = aDrive;
1.624 + }
1.625 +
1.626 +/**
1.627 +MDiscovererObserver callback method, to signal that
1.628 +during a discovery session an error has occured.
1.629 +
1.630 +@param aError The notification error code.
1.631 +@return true if aError is one of the acceptable error codes
1.632 +*/
1.633 +TBool CObserverStub::NotifiedWithErrorCode(TInt aError)
1.634 + {
1.635 + // Test the safe error codes
1.636 + return (aError == KErrNotReady || // Drive removed
1.637 + aError == KErrPathNotFound); // Directory deleted
1.638 + }
1.639 +
1.640 +/**
1.641 +MDiscovererObserver callback method,to retrieve the drive unit's DAT
1.642 +file infor.
1.643 +
1.644 +@param aDrive the identifier of the drive to retrieve DAT file infor from.
1.645 +@return ETrue if DAT file exists on the drive unit, otherwise EFlase.
1.646 +
1.647 +*/
1.648 +TBool CObserverStub::IsAnyDllRegisteredWithDriveL(const TDriveUnit /*aDrive*/) const
1.649 + {
1.650 + // To pass the build always returns EFalse to mean no Dll is discovered in the drive,
1.651 + // it is not used in this test.
1.652 + return EFalse;
1.653 + }
1.654 +
1.655 +/**
1.656 +Verification method that checks whether given drive is available
1.657 +
1.658 +@param aDrive The drive that to be checked.
1.659 +@return true if given drive is registered
1.660 +*/
1.661 +TBool CObserverStub::IsDriveMounted(const TDriveUnit aDrive)
1.662 + {
1.663 + TBool mounted = EFalse;
1.664 + if(iDriveMounted && (aDrive == iDriveUnit))
1.665 + {
1.666 + mounted = ETrue;
1.667 + }
1.668 + return mounted;
1.669 + }
1.670 +
1.671 +/**
1.672 +Verification method that checks whether discovery process is completed successfully
1.673 +
1.674 +@return true if discovery process is completed successfully
1.675 +*/
1.676 +TBool CObserverStub::IsDiscoveriesCompleteSuccessfully()
1.677 + {
1.678 + return iDiscoveriesComplete;
1.679 + }
1.680 +
1.681 +/**
1.682 +Returns the current start-up state of this object
1.683 +
1.684 +@return The current start-up state of this object
1.685 +*/
1.686 +CObserverStub::OSState CObserverStub::GetState()
1.687 + {
1.688 + return iState;
1.689 + }
1.690 +
1.691 +void CObserverStub::SetDiscoverer(CDiscoverer* aDiscoverer)
1.692 + {
1.693 + iDiscoverer = aDiscoverer;
1.694 + }
1.695 +
1.696 +void CObserverStub::LanguageChangedL(TBool& aLanguageChanged)
1.697 + {
1.698 + aLanguageChanged = EFalse;
1.699 + }
1.700 +class CDiscovererTestShutdown : public CTimer
1.701 + {
1.702 +public:
1.703 + inline CDiscovererTestShutdown();
1.704 + inline void ConstructL();
1.705 + inline void StartAfter(TTimeIntervalMicroSeconds32 aTimeInterval);
1.706 +
1.707 +private:
1.708 + void RunL();
1.709 + };
1.710 +
1.711 +inline CDiscovererTestShutdown::CDiscovererTestShutdown()
1.712 +:CTimer(EPriorityHigh)// Priority set higher than CIdleScanningTimer
1.713 + {
1.714 + CActiveScheduler::Add(this);
1.715 + }
1.716 +
1.717 +inline void CDiscovererTestShutdown::ConstructL()
1.718 + {
1.719 + CTimer::ConstructL();
1.720 + }
1.721 +
1.722 +inline void CDiscovererTestShutdown::StartAfter(TTimeIntervalMicroSeconds32 aTimeInterval)
1.723 + {
1.724 + After(aTimeInterval);
1.725 + }
1.726 +void CDiscovererTestShutdown::RunL()
1.727 + {
1.728 + CActiveScheduler::Stop();
1.729 + }
1.730 +
1.731 +/**
1.732 +Test class for object CDiscoverer.
1.733 +This class provides the parameters and behaviour that
1.734 +allows this class to behave normally under a test
1.735 +scenario.
1.736 +*/
1.737 +class CDiscovererTest : public CBase
1.738 + {
1.739 +public:
1.740 + static CDiscovererTest* NewL();
1.741 + virtual ~CDiscovererTest();
1.742 +
1.743 + void ResumeSuspendTestL();
1.744 + void DriveMountUnmountTestL();
1.745 + void ProcessEntryTestL();
1.746 + void ProcessSpiEntryTestL();
1.747 + void ValidateSpiEntryTestL();
1.748 + void ValidateSpiPluginsTestL();
1.749 + void ValidateEntryTestL();
1.750 + void ProcessEntryPlugIn3TestL();
1.751 + void ProcessSpiEntryPlugIn3TestL();
1.752 + void ValidateSpiEntryPlugIn3TestL();
1.753 + void ValidateEntryPlugIn3TestL();
1.754 + void ScanDirectoryIncrementTestL();
1.755 + void ScanDirectoryTestL();
1.756 + void ScanDirectoryCancelTestL();
1.757 + void StagedDiscoveryStateTransitionTestL();
1.758 + void AllAtOnceDiscoveryStateTransitionTestL();
1.759 + void MultipleNotificationProcessingTestL();
1.760 + void SWINotificationProcessingTestL();
1.761 + void IdleScanningTimerRunErrorL();
1.762 + void DirChangeNotifierRunErrorL();
1.763 + void SwiChangeNotifierRunError();
1.764 + void LanguageChangedNotificationTestL();
1.765 +
1.766 +private:
1.767 + CDiscovererTest();
1.768 + void ConstructL();
1.769 +
1.770 +public:
1.771 + /** The instance of the class under test */
1.772 + CDiscoverer* iDiscoverer;
1.773 +
1.774 + /** The instance of the state accessor interface */
1.775 + TDiscoverer_StateAccessor* iStateAccessor;
1.776 +
1.777 + /** The instance of the observer stub of the CDiscoverer */
1.778 + CObserverStub* iDiscovererObserver;
1.779 +
1.780 + /** Unique Id of the ECOM dll */
1.781 + TUid iDllUid;
1.782 +
1.783 + /** The drive on which interface implementations can be found */
1.784 + TDriveUnit iDriveUnit;
1.785 +
1.786 + /** Information on a dll which contains interface implementations */
1.787 + TEntry iDllEntry;
1.788 +
1.789 + /** A shutdown timer to manipulate the Active Scheduler of testing server */
1.790 + CDiscovererTestShutdown iShutdown;
1.791 +
1.792 + CEComCachedDriveInfo* iCachedDriveInfo;
1.793 + };
1.794 +
1.795 +/**
1.796 +Standardised safe construction which
1.797 +leaves nothing on the cleanup stack.
1.798 +
1.799 +@post CDiscovererTest is fully constructed and initialised
1.800 +@return The new'ed object.
1.801 +*/
1.802 +CDiscovererTest* CDiscovererTest::NewL()
1.803 + {
1.804 + CDiscovererTest* self = new (ELeave) CDiscovererTest();
1.805 + CleanupStack::PushL( self );
1.806 + self->ConstructL();
1.807 + CleanupStack::Pop(self);
1.808 + return self;
1.809 + }
1.810 +
1.811 +/**
1.812 +Default constructor.
1.813 +
1.814 +@post The object is properly constructed.
1.815 +*/
1.816 +CDiscovererTest::CDiscovererTest()
1.817 + :CBase(),
1.818 + iDriveUnit(EDriveC)
1.819 + {
1.820 + TUid uid1 = {0};
1.821 + TUid uid2 = {0};
1.822 +
1.823 + iDllUid.iUid = 0x10009DB6; // Dll Uid for EComRomOnlyExampleOnC.dll
1.824 + iDllEntry.iType = TUidType(uid1, uid2, iDllUid);
1.825 + }
1.826 +
1.827 +/**
1.828 +Destructor.
1.829 +
1.830 +@post This object is properly destroyed.
1.831 +*/
1.832 +CDiscovererTest::~CDiscovererTest()
1.833 + {
1.834 + delete iDiscoverer;
1.835 + delete iStateAccessor;
1.836 + delete iDiscovererObserver;
1.837 + delete iCachedDriveInfo;
1.838 + }
1.839 +
1.840 +/**
1.841 +Standardized 2nd(Initialization) phase of two phase construction.
1.842 +Creates supporting class objects for the execution of test.
1.843 +
1.844 +@post CDiscovererTest is fully constructed.
1.845 +*/
1.846 +void CDiscovererTest::ConstructL()
1.847 + {
1.848 + iStateAccessor = new(ELeave) TDiscoverer_StateAccessor;
1.849 + iDiscovererObserver = CObserverStub::NewL();
1.850 + iDiscoverer = CDiscoverer::NewL(*iDiscovererObserver, TheFs);
1.851 + iDiscovererObserver->SetDiscoverer(iDiscoverer);
1.852 + iShutdown.ConstructL();
1.853 + iCachedDriveInfo = CEComCachedDriveInfo::NewL(TheFs);
1.854 + }
1.855 +
1.856 +/**
1.857 +The test executes by first suspending the discoverer then by
1.858 +resuming it.
1.859 +
1.860 +@SYMTestCaseID SYSLIB-ECOM-CT-0716
1.861 +@SYMTestCaseDesc Tests for resuming and suspending Discoverer
1.862 +@SYMTestPriority High
1.863 +@SYMTestActions Suspend if Discoverer is active and then resume. Check for the error conditions(OOM)
1.864 +@SYMTestExpectedResults The test must not fail.
1.865 +@SYMREQ REQ0000
1.866 +*/
1.867 +void CDiscovererTest::ResumeSuspendTestL()
1.868 + {
1.869 + test.Next(_L(" @SYMTestCaseID:SYSLIB-ECOM-CT-0716 "));
1.870 + // Perform an initial discovery and start the notifiers.
1.871 + iDiscoverer->ProcessSSAEventL(EStartupStateNonCritical);
1.872 +
1.873 + TBool isDiscActive = iStateAccessor->IsDiscovererActive(*iDiscoverer);
1.874 + // Notifiers should be active.
1.875 + test(isDiscActive);
1.876 +
1.877 + TInt err = iDiscoverer->Suspend();
1.878 + TEST_OOM_ERR;
1.879 + test(err == KErrNone);
1.880 +
1.881 + // Notifiers should still be active.
1.882 + isDiscActive = iStateAccessor->IsDiscovererActive(*iDiscoverer);
1.883 + test(isDiscActive);
1.884 +
1.885 + // Test that there are no drives pending a scan before we copy the plugin.
1.886 + test(!iStateAccessor->IsScanDirectoryPending(*iDiscoverer, EDriveC));
1.887 +
1.888 + // Raise a plugin change notification on C: drive. This simulates a plugin being copied.
1.889 + iDiscoverer->ProcessDNEventL(CDiscoverer::EPluginsModified, EDriveC);
1.890 + iDiscoverer->ProcessDNEventL(CDiscoverer::EPluginsRediscover, EDriveC);
1.891 +
1.892 + // Test that the drive we copied the plugin to still has a scan pending.
1.893 + test(iStateAccessor->IsScanDirectoryPending(*iDiscoverer, EDriveC));
1.894 +
1.895 + isDiscActive = iStateAccessor->IsDiscovererActive(*iDiscoverer);
1.896 + // Notifiers should still be active.
1.897 + test(isDiscActive);
1.898 +
1.899 + // Start Active Scheduler and shut it down in 3 secs, it will launch RunL of timer to process
1.900 + // all pending notification.
1.901 + iShutdown.StartAfter(KOneSecond * 3);
1.902 + CActiveScheduler::Start();
1.903 +
1.904 + // Check that notifications have not been processed.
1.905 + test(!iStateAccessor->IsScanDirectoryComplete(*iDiscoverer));
1.906 +
1.907 + err = iDiscoverer->Resume();
1.908 + TEST_OOM_ERR;
1.909 + test(err == KErrNone);
1.910 +
1.911 + isDiscActive = iStateAccessor->IsDiscovererActive(*iDiscoverer);
1.912 + // Notifiers should still be active.
1.913 + test(isDiscActive);
1.914 +
1.915 + // Start Active Scheduler and shut it down in 3 secs, it will launch RunL of timer to process
1.916 + // all pending notification.
1.917 + iShutdown.StartAfter(KOneSecond * 3);
1.918 + CActiveScheduler::Start();
1.919 +
1.920 + // Check if notifications have been processed on all drives.
1.921 + test(iStateAccessor->IsScanDirectoryComplete(*iDiscoverer));
1.922 + }
1.923 +
1.924 +/**
1.925 +The test executes by first making the test drive unmounted and
1.926 +then testing for Mount and Unmount.
1.927 +
1.928 +@SYMTestCaseID SYSLIB-ECOM-CT-0717
1.929 +@SYMTestCaseDesc Tests for drive mount and unmount
1.930 +@SYMTestPriority High
1.931 +@SYMTestActions First remove the drive if its already there, then test for Mount then for unmount
1.932 +@SYMTestExpectedResults The test must not fail.
1.933 +@SYMREQ REQ0000
1.934 +*/
1.935 +void CDiscovererTest::DriveMountUnmountTestL()
1.936 + {
1.937 + test.Next(_L(" @SYMTestCaseID:SYSLIB-ECOM-CT-0717 "));
1.938 + TInt err;
1.939 + TDriveUnit drive(EDriveC);
1.940 + //First remove the drive if its already there, then test for Mount then for unmount
1.941 + if(iStateAccessor->IsDriveMounted(*iDiscoverer, drive))
1.942 + {
1.943 + TRAP(err, iStateAccessor->DriveUnmountedL(*iDiscoverer, drive));
1.944 + TEST_OOM_ERR;
1.945 + test(err == KErrNone);
1.946 + }
1.947 +
1.948 + // Drive should not be present
1.949 + test(!iStateAccessor->IsDriveMounted(*iDiscoverer, drive));
1.950 +
1.951 + // Test Mount
1.952 + TRAP(err, iStateAccessor->DriveMountedL(*iDiscoverer, drive));
1.953 + TEST_OOM_ERR;
1.954 + test(err == KErrNone);
1.955 +
1.956 + // CDiscoverer->DriveMountedL/DriveUnmountedL updates both itself and
1.957 + // DiscovererObserver class for Mount/Unmount of drives. So testing for both
1.958 + test(iStateAccessor->IsDriveMounted(*iDiscoverer, drive));
1.959 + test(iDiscovererObserver->IsDriveMounted(drive));
1.960 +
1.961 + // Test Unmount
1.962 + TRAP(err, iStateAccessor->DriveUnmountedL(*iDiscoverer, drive));
1.963 + TEST_OOM_ERR;
1.964 + test(err == KErrNone );
1.965 +
1.966 + // CDiscoverer->DriveMountedL/DriveUnmountedL updates both itself and
1.967 + // DiscovererObserver class for Mount/Unmount of drives. So testing for both
1.968 + test(!iStateAccessor->IsDriveMounted(*iDiscoverer, drive));
1.969 + test(!iDiscovererObserver->IsDriveMounted(drive));
1.970 + }
1.971 +
1.972 +
1.973 +/**
1.974 +@SYMTestCaseID SYSLIB-ECOM-UT-3559
1.975 +@SYMTestCaseDesc Tests for process entry of PLUGIN3 type.
1.976 +@SYMTestPriority High
1.977 +@SYMTestActions Call CDiscoverer::ProcessEntryL().
1.978 +@SYMTestExpectedResults The entry is registered successfully and no leave occurred.
1.979 +@SYMEC EC43
1.980 +*/
1.981 +void CDiscovererTest::ProcessEntryPlugIn3TestL()
1.982 + {
1.983 + test.Next(_L(" @SYMTestCaseID:SYSLIB-ECOM-UT-3559 "));
1.984 + CPluginBase* entryBase = NULL;
1.985 + TInt err = KErrNone;
1.986 +
1.987 + //This part refers to testing of the entry containing the RSC
1.988 + _LIT(KExampleRscFileNameOnly,"EComExample12.rsc");
1.989 + TDriveName driveName1(iDriveUnit.Name());
1.990 + TParse path1;
1.991 + path1.Set(KNewResourceSearchPath(),NULL,&driveName1);
1.992 + //Creating a entry that represents the Rsc disovered during scanning of \\resource\\plugins
1.993 + TEntry rscEntry;
1.994 + rscEntry.iName = KExampleRscFileNameOnly;
1.995 + rscEntry.iType = TUidType(KNullUid,KUidInterfaceImplementationCollectionInfo,KNullUid);
1.996 + entryBase = CSecurePlugin::NewL(TheFs,rscEntry,driveName1, EFalse);
1.997 + CleanupStack::PushL(entryBase);
1.998 +
1.999 + // ProcessEntryL() updates entryToFill with information on a rsc specified by the other params.
1.1000 + TRAP(err, iStateAccessor->ProcessEntryL(*iDiscoverer,driveName1,entryBase,ETrue));
1.1001 + TEST_OOM_ERR;
1.1002 + test(err == KErrNone);
1.1003 + CleanupStack::PopAndDestroy(entryBase);
1.1004 + }
1.1005 +
1.1006 +/**
1.1007 +@SYMTestCaseID SYSLIB-ECOM-UT-3560
1.1008 +@SYMTestCaseDesc Check that the ProcessEntryL for spi data works correctly when using PLUGIN3 entries in the spi file.
1.1009 +@SYMTestPriority High
1.1010 +@SYMTestActions Call CDiscoverer::ProcessEntryL().
1.1011 +@SYMTestExpectedResults ecomtesttype3.spi is processed successfully and no leave occurred.
1.1012 +@SYMEC EC43
1.1013 +*/
1.1014 +void CDiscovererTest::ProcessSpiEntryPlugIn3TestL()
1.1015 + {
1.1016 + test.Next(_L(" @SYMTestCaseID:SYSLIB-ECOM-UT-3560 "));
1.1017 + TEntry spiEntry;
1.1018 + test(TheFs.Entry(KEComSpiTestFilePlugIn3PathAndName, spiEntry) == KErrNone);
1.1019 + TParse spiPath;
1.1020 + spiPath.Set(KEComSpiTestFilePlugIn3PathAndName, NULL, NULL);
1.1021 +
1.1022 + RResourceArchive resourceArchive;
1.1023 + resourceArchive.OpenL(TheFs, KEComSpiTestFilePlugIn3PathAndName);
1.1024 + CleanupClosePushL(resourceArchive);
1.1025 +
1.1026 + // check SPI file type
1.1027 + TUid type = resourceArchive.Type();
1.1028 + test(type == KEcomSpiFileTypeUid);
1.1029 +
1.1030 + // there is only 1 resource file
1.1031 + while(!resourceArchive.End())
1.1032 + {
1.1033 + CPluginBase* entry = CSpiPlugin::NewL(resourceArchive);
1.1034 + CleanupStack::PushL(entry);
1.1035 +
1.1036 + TRAPD(err, iStateAccessor->ProcessEntryL(*iDiscoverer,spiPath.Drive(), entry,ETrue));
1.1037 + TEST_OOM_ERR;
1.1038 + test(err == KErrNone);
1.1039 +
1.1040 + CleanupStack::PopAndDestroy(entry);
1.1041 + entry = NULL;
1.1042 + }
1.1043 + CleanupStack::PopAndDestroy(&resourceArchive);
1.1044 + }
1.1045 +/**
1.1046 +@SYMTestCaseID SYSLIB-ECOM-UT-3561
1.1047 +@SYMTestCaseDesc Tests for the reference of the entry containing the DLL of PLUGIN3 type.
1.1048 +@SYMTestPriority High
1.1049 +@SYMTestActions Call CDiscoverer::ValidateEntryL(). Check the entry returned.
1.1050 +@SYMTestExpectedResults The entry is validated successfully and no leave occurred.
1.1051 +@SYMEC EC43
1.1052 +*/
1.1053 +void CDiscovererTest::ValidateEntryPlugIn3TestL()
1.1054 + {
1.1055 + test.Next(_L(" @SYMTestCaseID:SYSLIB-ECOM-UT-3561 "));
1.1056 + TInt err = KErrNone;
1.1057 +
1.1058 + //This part refers to testing of the entry containing the RSC
1.1059 + _LIT(KExampleRscFileNameOnly,"EComExample12.rsc");
1.1060 + TDriveName driveName1(iDriveUnit.Name());
1.1061 + CPluginBase *entryToFill1 = NULL;
1.1062 + //Creating an entry that represents the Rsc disovered during scanning of \\resource\\plugins
1.1063 + TEntry rscEntry;
1.1064 + rscEntry.iName = KExampleRscFileNameOnly;
1.1065 + rscEntry.iType = TUidType(KNullUid,KUidInterfaceImplementationCollectionInfo,KNullUid);
1.1066 +
1.1067 + TUid dllUid1 = {KDynamicLibraryUidValue};
1.1068 + TUid example12Uid = {0x10009E3E};
1.1069 + TUidType dllUidType = TUidType(dllUid1,KUidInterfaceImplementationCollection,example12Uid);
1.1070 +
1.1071 + //Now call ValidateEntryL() with this entry containg the rsc
1.1072 + TRAP(err,iStateAccessor->ValidateEntryL(*iDiscoverer,rscEntry,driveName1,entryToFill1, EFalse));
1.1073 + TEST_OOM_ERR;
1.1074 + test(err == KErrNone);
1.1075 + test(entryToFill1->iDllThirdUid == dllUidType[2]);
1.1076 + TParse dllParse;
1.1077 + dllParse.Set(KPlugIn3ExampleDllFileName,NULL,NULL);
1.1078 + test(entryToFill1->iDllName->CompareF(dllParse.NameAndExt()) == 0);
1.1079 +
1.1080 + delete entryToFill1;
1.1081 + }
1.1082 +
1.1083 +/**
1.1084 +@SYMTestCaseID SYSLIB-ECOM-UT-3562
1.1085 +@SYMTestCaseDesc Check that the ValidateEntryL for spi data works correctly when using PLUGIN3 entries in the spi file.
1.1086 +@SYMTestPriority High
1.1087 +@SYMTestActions Call CDiscoverer::ValidateEntryL(). Check the entry returned.
1.1088 +@SYMTestExpectedResults ecomtesttype3.spi file is validated successfully and no leave occurred.
1.1089 +@SYMEC EC43
1.1090 +*/
1.1091 +void CDiscovererTest::ValidateSpiEntryPlugIn3TestL()
1.1092 + {
1.1093 + test.Next(_L(" @SYMTestCaseID:SYSLIB-ECOM-UT-3562 "));
1.1094 + TEntry spiEntry;
1.1095 + test(TheFs.Entry(KEComSpiTestFilePlugIn3PathAndName, spiEntry) == KErrNone);
1.1096 + TParse spiPath;
1.1097 + spiPath.Set(KEComSpiTestFilePlugIn3PathAndName, NULL, NULL);
1.1098 +
1.1099 + TEntry TestEntry;
1.1100 + TUid uid1 = {0x10000079};
1.1101 + TUid uid2 = {0x10009D93};
1.1102 + TUid uid3 = {0x10009E3E}; // Uid for EComExample12.dll
1.1103 + TestEntry.iType = TUidType(uid1, uid2, uid3);
1.1104 + TestEntry.iName = KPlugIn3ExampleDllFileNameOnly;
1.1105 +
1.1106 + RResourceArchive resourceArchive;
1.1107 + resourceArchive.OpenL(TheFs, KEComSpiTestFilePlugIn3PathAndName);
1.1108 + CleanupClosePushL(resourceArchive);
1.1109 +
1.1110 + // check SPI file type
1.1111 + TUid type = resourceArchive.Type();
1.1112 + test(type == KEcomSpiFileTypeUid);
1.1113 +
1.1114 + // there is only 1 resource file
1.1115 + while(!resourceArchive.End())
1.1116 + {
1.1117 + CPluginBase* entryToFill = NULL;
1.1118 + TRAPD(err, iStateAccessor->ValidateEntryL(*iDiscoverer,resourceArchive,entryToFill));
1.1119 + CleanupStack::PushL(entryToFill);
1.1120 +
1.1121 + TEST_OOM_ERR;
1.1122 + test(err == KErrNone);
1.1123 + test(entryToFill->iDllThirdUid == TestEntry.iType[2]);
1.1124 +
1.1125 + TFileName name1(KEComSpiTestFilePlugIn3DllPathAndName);
1.1126 + TFileName name2(*(entryToFill->iDllName));
1.1127 + name1.LowerCase();
1.1128 + name2.LowerCase();
1.1129 + TParse dllparse;
1.1130 + dllparse.Set(name1,NULL,NULL);
1.1131 + test(dllparse.NameAndExt()== name2);
1.1132 +
1.1133 + CleanupStack::PopAndDestroy(entryToFill); // resourceFile, resourceName, entryToFill
1.1134 + entryToFill = NULL;
1.1135 + }
1.1136 + CleanupStack::PopAndDestroy(&resourceArchive);
1.1137 + }
1.1138 +
1.1139 +/**
1.1140 +The test executes by Registering an Interface Implementation Collection
1.1141 +and later verifing it
1.1142 +
1.1143 +@SYMTestCaseID SYSLIB-ECOM-CT-0718
1.1144 +@SYMTestCaseDesc Tests for process entry.
1.1145 +@SYMTestPriority High
1.1146 +@SYMTestActions Register an interface implementation collection and later verifies it.
1.1147 + Check for OOM error.
1.1148 +@SYMTestExpectedResults The test must not fail.
1.1149 +@SYMREQ REQ0000
1.1150 +*/
1.1151 +void CDiscovererTest::ProcessEntryTestL()
1.1152 + {
1.1153 + test.Next(_L(" @SYMTestCaseID:SYSLIB-ECOM-CT-0718 "));
1.1154 + CPluginBase* entryBase=NULL;
1.1155 + TInt err=KErrNone;
1.1156 +
1.1157 + //This part refers to testing of the entry containing the RSC
1.1158 + _LIT(KExampleRscFileNameOnly,"EComExample5.rsc");
1.1159 + TDriveName driveName1(iDriveUnit.Name());
1.1160 + TParse path1;
1.1161 + path1.Set(KNewResourceSearchPath(),NULL,&driveName1);
1.1162 + //Creating a entry that represents the Rsc disovered during scanning of \\resource\\plugins
1.1163 + TEntry rscEntry;
1.1164 + rscEntry.iName=KExampleRscFileNameOnly;
1.1165 + rscEntry.iType=TUidType(KNullUid,KUidInterfaceImplementationCollectionInfo,KNullUid);
1.1166 + TUid dllUid1 = {KDynamicLibraryUidValue};
1.1167 + TUid example5Uid={0x101F847B};
1.1168 + TUidType dllUidType=TUidType(dllUid1,KUidInterfaceImplementationCollection,example5Uid);
1.1169 + entryBase=CSecurePlugin::NewL(TheFs,rscEntry,driveName1, EFalse);
1.1170 + CleanupStack::PushL(entryBase);
1.1171 +
1.1172 + // ProcessEntryL() updates entryToFill with information on a rsc specified by the other params.
1.1173 + TRAP(err, iStateAccessor->ProcessEntryL(*iDiscoverer,driveName1,entryBase,ETrue));
1.1174 + TEST_OOM_ERR;
1.1175 + test(err == KErrNone);
1.1176 + CleanupStack::PopAndDestroy(entryBase);
1.1177 + entryBase=NULL;
1.1178 +
1.1179 + }
1.1180 +
1.1181 +/**
1.1182 +@SYMTestCaseID SYSLIB-ECOM-CT-0091
1.1183 +@SYMTestCaseDesc Check that the ProcessEntryL for spi data works correctly.
1.1184 +@SYMTestPriority High
1.1185 +@SYMTestActions Ensure ecomtest.spi can be processed successfully
1.1186 + and no leave occurred.
1.1187 +@SYMTestExpectedResults The test must not fail.
1.1188 +@SYMREQ REQ3655
1.1189 +*/
1.1190 +void CDiscovererTest::ProcessSpiEntryTestL()
1.1191 + {
1.1192 + test.Next(_L(" @SYMTestCaseID:SYSLIB-ECOM-CT-0091 "));
1.1193 + TEntry spiEntry;
1.1194 + test(TheFs.Entry(KEComSpiTestFilePathAndName, spiEntry) == KErrNone);
1.1195 + TParse spiPath;
1.1196 + spiPath.Set(KEComSpiTestFilePathAndName, NULL, NULL);
1.1197 +
1.1198 + RResourceArchive resourceArchive;
1.1199 + resourceArchive.OpenL(TheFs, KEComSpiTestFilePathAndName);
1.1200 + CleanupClosePushL(resourceArchive);
1.1201 +
1.1202 + // check SPI file type
1.1203 + TUid type = resourceArchive.Type();
1.1204 + test(type == KEcomSpiFileTypeUid);
1.1205 +
1.1206 + // there is only 1 resource file
1.1207 + while(!resourceArchive.End())
1.1208 + {
1.1209 + CPluginBase* entry = CSpiPlugin::NewL(resourceArchive);
1.1210 + CleanupStack::PushL(entry);
1.1211 +
1.1212 + TRAPD(err, iStateAccessor->ProcessEntryL(*iDiscoverer,spiPath.Drive(), entry,ETrue));
1.1213 + TEST_OOM_ERR;
1.1214 + test(err == KErrNone);
1.1215 +
1.1216 + CleanupStack::PopAndDestroy(entry);
1.1217 + entry = NULL;
1.1218 + }
1.1219 + CleanupStack::PopAndDestroy(&resourceArchive);
1.1220 + }
1.1221 +/**
1.1222 +The test executes by checking whether discovered plugin entry is valid
1.1223 +
1.1224 +@SYMTestCaseID SYSLIB-ECOM-CT-0719
1.1225 +@SYMTestCaseDesc Tests for plugin that resides on C drive
1.1226 +@SYMTestPriority High
1.1227 +@SYMTestActions Tests for the reference of the entry containing in the DLL
1.1228 + Check for OOM error.
1.1229 +@SYMTestExpectedResults The test must not fail.
1.1230 +@SYMREQ REQ0000
1.1231 +*/
1.1232 +void CDiscovererTest::ValidateEntryTestL()
1.1233 + {
1.1234 + test.Next(_L(" @SYMTestCaseID:SYSLIB-ECOM-CT-0719 "));
1.1235 + TInt err=KErrNone;
1.1236 +
1.1237 + //This part refers to testing of the entry containing the RSC
1.1238 + _LIT(KExampleRscFileNameOnly,"EComExample5.rsc");
1.1239 + TDriveName driveName1(iDriveUnit.Name());
1.1240 + TParse path1;
1.1241 + CPluginBase *entryToFill1 = NULL;
1.1242 + path1.Set(KNewResourceSearchPath(),NULL,&driveName1);
1.1243 + //Creating a entry that represents the Rsc disovered during scanning of \\resource\\plugins
1.1244 + TEntry rscEntry;
1.1245 + rscEntry.iName=KExampleRscFileNameOnly;
1.1246 + rscEntry.iType=TUidType(KNullUid,KUidInterfaceImplementationCollectionInfo,KNullUid);
1.1247 +
1.1248 + TUid dllUid1 = {KDynamicLibraryUidValue};
1.1249 + TUid example5Uid={0x101F847B};
1.1250 + TUidType dllUidType=TUidType(dllUid1,KUidInterfaceImplementationCollection,example5Uid);
1.1251 +
1.1252 + //Now call ValidateEntryL() with this entry containg the rsc
1.1253 + TRAP(err,iStateAccessor->ValidateEntryL(*iDiscoverer,rscEntry,driveName1,entryToFill1, EFalse));
1.1254 + TEST_OOM_ERR;
1.1255 + test(err==KErrNone);
1.1256 + test(entryToFill1->iDllThirdUid==dllUidType[2]);
1.1257 + TParse dllParse;
1.1258 + dllParse.Set(KNewExampleDllFileName,NULL,NULL);
1.1259 + test(entryToFill1->iDllName->CompareF(dllParse.NameAndExt())==0);
1.1260 +
1.1261 + delete entryToFill1;
1.1262 + }
1.1263 +
1.1264 +/**
1.1265 +@SYMTestCaseID SYSLIB-ECOM-CT-0092
1.1266 +@SYMTestCaseDesc Check that the ValidateEntryL for spi data works correctly.
1.1267 +@SYMTestPriority High
1.1268 +@SYMTestActions Ensure ecomtest.spi can be validated successfully
1.1269 + and no leave occurred.
1.1270 +@SYMTestExpectedResults The test must not fail.
1.1271 +@SYMREQ REQ3655
1.1272 +*/
1.1273 +void CDiscovererTest::ValidateSpiEntryTestL()
1.1274 + {
1.1275 + test.Next(_L(" @SYMTestCaseID:SYSLIB-ECOM-CT-0092 "));
1.1276 + TEntry spiEntry;
1.1277 + test(TheFs.Entry(KEComSpiTestFilePathAndName, spiEntry) == KErrNone);
1.1278 + TParse spiPath;
1.1279 + spiPath.Set(KEComSpiTestFilePathAndName, NULL, NULL);
1.1280 +
1.1281 + TEntry TestEntry;
1.1282 + TUid uid1 = {0x10000079};
1.1283 + TUid uid2 = {0x10009D8D};
1.1284 + TUid uid3 = {0x101F847B}; // Uid for EComExample5.dll
1.1285 + TestEntry.iType = TUidType(uid1, uid2, uid3);
1.1286 + TestEntry.iName = KNewExampleDllFileNameOnly;
1.1287 +
1.1288 + RResourceArchive resourceArchive;
1.1289 + resourceArchive.OpenL(TheFs, KEComSpiTestFilePathAndName);
1.1290 + CleanupClosePushL(resourceArchive);
1.1291 +
1.1292 + // check SPI file type
1.1293 + TUid type = resourceArchive.Type();
1.1294 + test(type == KEcomSpiFileTypeUid);
1.1295 +
1.1296 + // there is only 1 resource file
1.1297 + while(!resourceArchive.End())
1.1298 + {
1.1299 + CPluginBase* entryToFill = NULL;
1.1300 + TRAPD(err, iStateAccessor->ValidateEntryL(*iDiscoverer,resourceArchive,entryToFill));
1.1301 + CleanupStack::PushL(entryToFill);
1.1302 +
1.1303 + TEST_OOM_ERR;
1.1304 + test(err == KErrNone);
1.1305 + test(entryToFill->iDllThirdUid == TestEntry.iType[2]);
1.1306 +
1.1307 + TFileName name1(KEComSpiTestFileDllPathAndName);
1.1308 + TFileName name2(*(entryToFill->iDllName));
1.1309 + name1.LowerCase();
1.1310 + name2.LowerCase();
1.1311 + TParse dllparse;
1.1312 + dllparse.Set(name1,NULL,NULL);
1.1313 + test(dllparse.NameAndExt()== name2);
1.1314 +
1.1315 + CleanupStack::PopAndDestroy(entryToFill); // resourceFile, resourceName, entryToFill
1.1316 + entryToFill = NULL;
1.1317 + }
1.1318 + CleanupStack::PopAndDestroy(&resourceArchive);
1.1319 + }
1.1320 +
1.1321 +/**
1.1322 +@SYMTestCaseID SYSLIB-ECOM-CT-0093
1.1323 +@SYMTestCaseDesc Check that there is DLL for each resource in SPI file
1.1324 +@SYMTestPriority High
1.1325 +@SYMTestActions Ensure ecom.spi contents i.e, rsc, actually exist on drive
1.1326 +@SYMTestExpectedResults The test must not fail.
1.1327 +@SYMREQ REQ3655
1.1328 +*/
1.1329 +void CDiscovererTest::ValidateSpiPluginsTestL()
1.1330 + {
1.1331 + test.Next(_L(" @SYMTestCaseID:SYSLIB-ECOM-CT-0093 "));
1.1332 + __UHEAP_MARK;
1.1333 +
1.1334 + TEntry spiEntry;
1.1335 + TBool err = TheFs.Entry(KEComSPIFilePathAndName, spiEntry);
1.1336 + // It is possible for ecom.spi file not to exist. If it does not then no testing can be done.
1.1337 + if(err != KErrNone)
1.1338 + return;
1.1339 +
1.1340 + TParse spiPath;
1.1341 + spiPath.Set(KEComSPIFilePathAndName, NULL, NULL);
1.1342 +
1.1343 + //To read the SPI file
1.1344 + RResourceArchive resourceArchive;
1.1345 + resourceArchive.OpenL(TheFs, KEComSPIFilePathAndName);
1.1346 + CleanupClosePushL(resourceArchive);
1.1347 + CRegistryData::CDriveData* driveData = NULL;
1.1348 + //Check spi file type
1.1349 + TUid spiType = resourceArchive.Type();
1.1350 + test(spiType == KEcomSpiFileTypeUid);
1.1351 +
1.1352 + while(!resourceArchive.End())
1.1353 + {
1.1354 + CPluginBase* entryToFill = NULL;
1.1355 + TRAPD(err, iStateAccessor->ValidateEntryL(*iDiscoverer,resourceArchive,entryToFill));
1.1356 + CleanupStack::PushL(entryToFill);
1.1357 +
1.1358 + TEST_OOM_ERR;
1.1359 + test(err == KErrNone);
1.1360 +
1.1361 + CRegistryData::CDllData * dllData=CRegistryData::CDllData::NewLC(*(entryToFill->iDllName),entryToFill->iDllModifiedTime,entryToFill->iDllSecondUid, entryToFill->iDllThirdUid,driveData);
1.1362 +
1.1363 + TBool successful=dllData->ProcessSecurityCheckL();
1.1364 + if(!successful)
1.1365 + {
1.1366 + _LIT(KMessage,"ERROR: Plugin SID Mismatch ERROR for %S.");
1.1367 + RDebug::Print(KMessage, entryToFill->iDllName);
1.1368 + }
1.1369 + test(successful);
1.1370 +
1.1371 + CleanupStack::PopAndDestroy(dllData);
1.1372 + CleanupStack::PopAndDestroy(entryToFill);
1.1373 + entryToFill=NULL;
1.1374 + }
1.1375 +
1.1376 + CleanupStack::PopAndDestroy(&resourceArchive);
1.1377 + __UHEAP_MARKEND;
1.1378 + }
1.1379 +
1.1380 +
1.1381 +/**
1.1382 +Scans plugin directories and verifies successfull completion
1.1383 +
1.1384 +@SYMTestCaseID SYSLIB-ECOM-CT-0720
1.1385 +@SYMTestCaseDesc Tests for scanning plugin directories and verifies successfull completion
1.1386 +@SYMTestPriority High
1.1387 +@SYMTestActions Scans registered plugin directories from A to Z drive
1.1388 +@SYMTestExpectedResults The test must not fail.
1.1389 +@SYMREQ REQ0000
1.1390 +*/
1.1391 +void CDiscovererTest::ScanDirectoryIncrementTestL()
1.1392 + {
1.1393 + test.Next(_L(" @SYMTestCaseID:SYSLIB-ECOM-CT-0720 "));
1.1394 + TInt err;
1.1395 + // Scans registered plugin directories from A to Z drive
1.1396 + TEComCachedDriveInfoIterator iter(*iCachedDriveInfo);
1.1397 + for(iter.Last(); iter.InRange(); iter.Prev())
1.1398 + {
1.1399 + TRAP(err, iStateAccessor->ScanDirectoryL(*iDiscoverer,iter.DriveNumber()));
1.1400 + TEST_OOM_ERR;
1.1401 + test(err == KErrNone);
1.1402 + }
1.1403 + // After successful completion of ScanDirectoryL, DiscovererObserver is updated
1.1404 + // with DiscoveriesComplete successful
1.1405 + // DiscovererObserver is a stub class used in place of CRegistrar. Flags are used for the
1.1406 + // successfull execution of API
1.1407 + test(iDiscovererObserver->IsDiscoveriesCompleteSuccessfully());
1.1408 + }
1.1409 +
1.1410 +/**
1.1411 +Stops scaning of plugin directories
1.1412 +
1.1413 +@SYMTestCaseID SYSLIB-ECOM-CT-0722
1.1414 +@SYMTestCaseDesc Tests for stopping of scanning plugin directories
1.1415 +@SYMTestPriority High
1.1416 +@SYMTestActions Stops scaning of plugin directories. Check for OOM error.
1.1417 +@SYMTestExpectedResults The test must not fail.
1.1418 +@SYMREQ REQ0000
1.1419 +*/
1.1420 +void CDiscovererTest::ScanDirectoryCancelTestL()
1.1421 + {
1.1422 + test.Next(_L(" @SYMTestCaseID:SYSLIB-ECOM-CT-0722 "));
1.1423 + TRAPD(err, iStateAccessor->ScanDirectoryCancel(*iDiscoverer));
1.1424 + TEST_OOM_ERR;
1.1425 + test(err == KErrNone);
1.1426 + test(iStateAccessor->IsDirectoryScanCancelled(*iDiscoverer));
1.1427 + }
1.1428 +
1.1429 +/**
1.1430 +Scaning of plugin directories in Z: drive and C:drive, check these two drives is in drive list
1.1431 +
1.1432 +@SYMTestCaseID SYSLIB-ECOM-UT-1859
1.1433 +@SYMTestCaseDesc Tests for scanning plugin directories in specific drives.
1.1434 +@SYMTestPriority High
1.1435 +@SYMTestActions scaning of plugin directories. Check for OOM error.
1.1436 +@SYMTestExpectedResults The test must not fail.
1.1437 +@SYMDEF DEF088454
1.1438 +*/
1.1439 +
1.1440 +void CDiscovererTest::ScanDirectoryTestL()
1.1441 + {
1.1442 + test.Next(_L(" @SYMTestCaseID:SYSLIB-ECOM-UT-1859 "));
1.1443 + EComPerformance::ResetEComPerfTimeRecords();
1.1444 +
1.1445 + // Do scan on specific drive
1.1446 + TRAPD(err, iStateAccessor->ScanDriveL(*iDiscoverer, EDriveZ, ETrue));
1.1447 + TEST_OOM_ERR;
1.1448 + test(err == KErrNone);
1.1449 +
1.1450 + TRAP(err, iStateAccessor->ScanDriveL(*iDiscoverer, EDriveC, EFalse));
1.1451 + TEST_OOM_ERR;
1.1452 + test(err == KErrNone);
1.1453 +
1.1454 + // Test record information correct
1.1455 + test(EComPerformance::iEComPerfTimeRecordCount == 4);
1.1456 + test(EComPerformance::iEComPerfTimeRecords[0].iType == ECDiscovererRediscoveryScanDirectoryL);
1.1457 + test(EComPerformance::iEComPerfTimeRecords[0].iInfo == EDriveZ);
1.1458 + test(EComPerformance::iEComPerfTimeRecords[1].iType == ECDiscovererRediscoveryScanDirectoryL);
1.1459 + test(EComPerformance::iEComPerfTimeRecords[1].iInfo == EDriveZ);
1.1460 +
1.1461 + test(EComPerformance::iEComPerfTimeRecords[2].iType == ECDiscovererRediscoveryScanDirectoryL);
1.1462 + test(EComPerformance::iEComPerfTimeRecords[2].iInfo == EDriveC);
1.1463 + test(EComPerformance::iEComPerfTimeRecords[3].iType == ECDiscovererRediscoveryScanDirectoryL);
1.1464 + test(EComPerformance::iEComPerfTimeRecords[3].iInfo == EDriveC);
1.1465 + }
1.1466 +
1.1467 +/**
1.1468 +@SYMTestCaseID SYSLIB-ECOM-CT-0185
1.1469 +@SYMTestCaseDesc Check that SSA related states transition as expected when discovery is staged
1.1470 +@SYMTestPriority High
1.1471 +@SYMTestActions Use CDiscoverer::ProcessSSAEventL to start discovery in stages i.e. rom only
1.1472 +then non rom only. Check that the
1.1473 +CDiscoverer state is transitioning correctly at every step.
1.1474 +@SYMTestExpectedResults The test must not fail.
1.1475 +@SYMREQ REQ3655
1.1476 +*/
1.1477 +void CDiscovererTest::StagedDiscoveryStateTransitionTestL()
1.1478 + {
1.1479 + test.Next(_L(" @SYMTestCaseID:SYSLIB-ECOM-CT-0185 "));
1.1480 + //After construction check that:
1.1481 + //- current state is EDisc_NoPluginsDisc
1.1482 + //- registry is empty. i.e. no plugins discovered
1.1483 + test(iStateAccessor->State(*iDiscoverer) == CDiscoverer::EDisc_NoPluginsDisc);
1.1484 +
1.1485 + //Call ProcessSSAEvent with state set to various states that will
1.1486 + //not cause a transition. Check that:
1.1487 + //- current state has not changed
1.1488 + iDiscoverer->ProcessSSAEventL(EStartupStateUndefined);
1.1489 + test(iStateAccessor->State(*iDiscoverer) == CDiscoverer::EDisc_NoPluginsDisc);
1.1490 +
1.1491 + //Call ProcessSSAEventL with EStartupStateCriticalStatic state.
1.1492 + //Check that
1.1493 + //- current state is EDisc_CriticalPluginsDisc
1.1494 + //- discoverer observer has processed RO plugins
1.1495 + iDiscoverer->ProcessSSAEventL(EStartupStateCriticalStatic);
1.1496 + test(iStateAccessor->GetDiscovererObserverState(*iDiscoverer) == CObserverStub::OSS_CriticalPlugins);
1.1497 + test(iStateAccessor->State(*iDiscoverer) == CDiscoverer::EDisc_CriticalPluginsDisc);
1.1498 +
1.1499 + //Call ProcessSSAEvent with state set to various states that will
1.1500 + //not cause a transition. Check that:
1.1501 + //- current state has not changed
1.1502 + iDiscoverer->ProcessSSAEventL(EStartupStateUndefined);
1.1503 + test(iStateAccessor->State(*iDiscoverer) == CDiscoverer::EDisc_CriticalPluginsDisc);
1.1504 + iDiscoverer->ProcessSSAEventL(EStartupStateCriticalStatic);
1.1505 + test(iStateAccessor->State(*iDiscoverer) == CDiscoverer::EDisc_CriticalPluginsDisc);
1.1506 +
1.1507 + //Call ProcessSSAEventL with EStartupStateNonCritical state. Check that
1.1508 + //- current state is EDisc_AllPluginsDisc
1.1509 + //- discoverer observer has processed non-RO plugins
1.1510 + iDiscoverer->ProcessSSAEventL(EStartupStateNonCritical);
1.1511 + test(iStateAccessor->GetDiscovererObserverState(*iDiscoverer) == CObserverStub::OSS_AllPlugins);
1.1512 + test(iStateAccessor->State(*iDiscoverer) == CDiscoverer::EDisc_AllPluginsDisc);
1.1513 +
1.1514 + //Call ProcessSSAEvent with state set to various states that will
1.1515 + //not cause a transition. Check that:
1.1516 + //- current state has not changed
1.1517 + iDiscoverer->ProcessSSAEventL(EStartupStateUndefined);
1.1518 + test(iStateAccessor->State(*iDiscoverer) == CDiscoverer::EDisc_AllPluginsDisc);
1.1519 + iDiscoverer->ProcessSSAEventL(EStartupStateCriticalStatic);
1.1520 + test(iStateAccessor->State(*iDiscoverer) == CDiscoverer::EDisc_AllPluginsDisc);
1.1521 + iDiscoverer->ProcessSSAEventL(EStartupStateCriticalDynamic);
1.1522 + test(iStateAccessor->State(*iDiscoverer) == CDiscoverer::EDisc_AllPluginsDisc);
1.1523 + iDiscoverer->ProcessSSAEventL(EStartupStateNonCritical);
1.1524 + test(iStateAccessor->State(*iDiscoverer) == CDiscoverer::EDisc_AllPluginsDisc);
1.1525 +
1.1526 + //Call ProcessDNEventL to indicate that current set of plugins is dirty.
1.1527 + //Check that:
1.1528 + //- current state is EDisc_PluginsDirty
1.1529 + iDiscoverer->ProcessDNEventL(CDiscoverer::EPluginsModified, EDriveC);
1.1530 + test(iStateAccessor->State(*iDiscoverer) == CDiscoverer::EDisc_PluginsDirty);
1.1531 +
1.1532 + //Call ProcessDNEventL to indicate that a rediscovery should take place.
1.1533 + //Check that:
1.1534 + //- current state is EDisc_AllPluginsDisc
1.1535 + iDiscoverer->ProcessDNEventL(CDiscoverer::EPluginsRediscover, EDriveC);
1.1536 + iStateAccessor->CompleteNotificationProcessing(*iDiscoverer);
1.1537 + test(iStateAccessor->State(*iDiscoverer) == CDiscoverer::EDisc_AllPluginsDisc);
1.1538 + }
1.1539 +
1.1540 +/**
1.1541 +@SYMTestCaseID SYSLIB-ECOM-CT-0186
1.1542 +@SYMTestCaseDesc Check that SSA related states transition as expected when discovery is all at once
1.1543 +@SYMTestPriority High
1.1544 +@SYMTestActions Use CDiscoverer::ProcessSSAEventL to start discovery all at once. Check that the
1.1545 +CDiscoverer state is transitioning correctly at every step.
1.1546 +@SYMTestExpectedResults The test must not fail.
1.1547 +@SYMREQ REQ3655
1.1548 +*/
1.1549 +void CDiscovererTest::AllAtOnceDiscoveryStateTransitionTestL()
1.1550 + {
1.1551 + test.Next(_L(" @SYMTestCaseID:SYSLIB-ECOM-CT-0186 "));
1.1552 + //After construction check that:
1.1553 + //- current state is EDisc_NoPluginsDisc
1.1554 + //- registry is empty. i.e. no plugins discovered
1.1555 + test(iStateAccessor->State(*iDiscoverer) == CDiscoverer::EDisc_NoPluginsDisc);
1.1556 +
1.1557 + //Call ProcessSSAEvent with state set to various states that will
1.1558 + //not cause a transition. Check that:
1.1559 + //- current state has not changed
1.1560 + iDiscoverer->ProcessSSAEventL(EStartupStateUndefined);
1.1561 + test(iStateAccessor->State(*iDiscoverer) == CDiscoverer::EDisc_NoPluginsDisc);
1.1562 +
1.1563 + //Call ProcessSSAEventL with EStartupStateNonCritical state. Check that
1.1564 + //- current state is EDisc_AllPluginsDisc
1.1565 + //- discoverer observer has processed non-RO plugins
1.1566 + iDiscoverer->ProcessSSAEventL(EStartupStateNonCritical);
1.1567 + test(iStateAccessor->GetDiscovererObserverState(*iDiscoverer) == CObserverStub::OSS_AllPlugins);
1.1568 + test(iStateAccessor->State(*iDiscoverer) == CDiscoverer::EDisc_AllPluginsDisc);
1.1569 +
1.1570 + //Call ProcessSSAEvent with state set to various states that will
1.1571 + //not cause a transition. Check that:
1.1572 + //- current state has not changed
1.1573 + iDiscoverer->ProcessSSAEventL(EStartupStateUndefined);
1.1574 + test(iStateAccessor->State(*iDiscoverer) == CDiscoverer::EDisc_AllPluginsDisc);
1.1575 + iDiscoverer->ProcessSSAEventL(EStartupStateCriticalStatic);
1.1576 + test(iStateAccessor->State(*iDiscoverer) == CDiscoverer::EDisc_AllPluginsDisc);
1.1577 + iDiscoverer->ProcessSSAEventL(EStartupStateCriticalDynamic);
1.1578 + test(iStateAccessor->State(*iDiscoverer) == CDiscoverer::EDisc_AllPluginsDisc);
1.1579 + iDiscoverer->ProcessSSAEventL(EStartupStateNonCritical);
1.1580 + test(iStateAccessor->State(*iDiscoverer) == CDiscoverer::EDisc_AllPluginsDisc);
1.1581 +
1.1582 + //Call ProcessDNEventL to indicate that current set of plugins is dirty.
1.1583 + //Check that:
1.1584 + //- current state is EDisc_PluginsDirty
1.1585 + iDiscoverer->ProcessDNEventL(CDiscoverer::EPluginsModified, EDriveC);
1.1586 + test(iStateAccessor->State(*iDiscoverer) == CDiscoverer::EDisc_PluginsDirty);
1.1587 +
1.1588 + //Call ProcessDNEventL to indicate that a rediscovery should take place.
1.1589 + //Check that:
1.1590 + //- current state is EDisc_AllPluginsDisc
1.1591 + iDiscoverer->ProcessDNEventL(CDiscoverer::EPluginsRediscover, EDriveC);
1.1592 + iStateAccessor->CompleteNotificationProcessing(*iDiscoverer);
1.1593 + test(iStateAccessor->State(*iDiscoverer) == CDiscoverer::EDisc_AllPluginsDisc);
1.1594 + }
1.1595 +
1.1596 +/**
1.1597 +@SYMTestCaseID SYSLIB-ECOM-UT-1796
1.1598 +@SYMTestCaseDesc Tests multiple notification processing for
1.1599 + "INC087110: ECOM rescanning code could miss a drive?" and
1.1600 + "DEF088454: [PCB] ECOM CDiscoverer::CIdleScanningTimer::RunL() Performs Unnecessary Tasks"
1.1601 +@SYMTestPriority High
1.1602 +@SYMTestActions Create multiple notification request on both single drive and multiple drives.
1.1603 + Check if the notifications are ONLY processed on corresponding drive(s) by timer.
1.1604 + Check the notifications are processed properly by timer.
1.1605 + Check the state of discoverer was set correctly on completion.
1.1606 +@SYMTestExpectedResults The test must not fail.
1.1607 +@SYMDEF INC087110, DEF088454
1.1608 +*/
1.1609 +void CDiscovererTest::MultipleNotificationProcessingTestL()
1.1610 + {
1.1611 + test.Next(_L(" @SYMTestCaseID:SYSLIB-ECOM-UT-1796 "));
1.1612 + TBool pending = EFalse;
1.1613 +
1.1614 + // Multiple notification on single drive:
1.1615 + iDiscoverer->ProcessSSAEventL(EStartupStateNonCritical);
1.1616 + // Raise multiple notification on C: drive
1.1617 + for(TInt num = 0; num < 10; ++num)
1.1618 + {
1.1619 + iDiscoverer->ProcessDNEventL(CDiscoverer::EPluginsModified, EDriveC);
1.1620 + iDiscoverer->ProcessDNEventL(CDiscoverer::EPluginsRediscover, EDriveC);
1.1621 + }
1.1622 +
1.1623 + // Check only one pending drive in the list.
1.1624 + test(iStateAccessor->PendingDriveListCount(*iDiscoverer) == 1);
1.1625 + // Check the pending drive is C: drive
1.1626 + pending = iStateAccessor->IsScanDirectoryPending(*iDiscoverer, EDriveC);
1.1627 + test(pending);
1.1628 +
1.1629 + // Start Active Scheduler and shut it down in 3 secs, it will launch RunL of timer to process
1.1630 + // all pending notification.
1.1631 + iShutdown.StartAfter(KOneSecond * 3);
1.1632 + CActiveScheduler::Start();
1.1633 +
1.1634 + // Check if notifications have been processed on all drives.
1.1635 + test(iStateAccessor->IsScanDirectoryComplete(*iDiscoverer));
1.1636 +
1.1637 + // Multiple notification on multiple drives:
1.1638 + iDiscoverer->ProcessSSAEventL(EStartupStateNonCritical);
1.1639 + // Raise multiple notification on C: drive
1.1640 + for(TInt num = 0; num < 10; ++num)
1.1641 + {
1.1642 + iDiscoverer->ProcessDNEventL(CDiscoverer::EPluginsModified, EDriveC);
1.1643 + iDiscoverer->ProcessDNEventL(CDiscoverer::EPluginsRediscover, EDriveC);
1.1644 + }
1.1645 +#if defined(__WINSCW__) // X: drive on emulator
1.1646 + // Raise multiple notification on X: drive
1.1647 + for(TInt num = 0; num < 10; ++num)
1.1648 + {
1.1649 + iDiscoverer->ProcessDNEventL(CDiscoverer::EPluginsModified, EDriveX);
1.1650 + iDiscoverer->ProcessDNEventL(CDiscoverer::EPluginsRediscover, EDriveX);
1.1651 + }
1.1652 +
1.1653 +#else // E: drive on HW
1.1654 + // Raise multiple notification on E: drive
1.1655 + for(TInt num = 0; num < 10; ++num)
1.1656 + {
1.1657 + iDiscoverer->ProcessDNEventL(CDiscoverer::EPluginsModified, EDriveE);
1.1658 + iDiscoverer->ProcessDNEventL(CDiscoverer::EPluginsRediscover, EDriveE);
1.1659 + }
1.1660 +#endif // __WINSCW__
1.1661 +
1.1662 + // Check only one pending drive in the list.
1.1663 + test(iStateAccessor->PendingDriveListCount(*iDiscoverer) == 2);
1.1664 +
1.1665 + // Check the pending drive are C: and X: on emulator, or C: and E: on hardware.
1.1666 + pending = iStateAccessor->IsScanDirectoryPending(*iDiscoverer, EDriveC);
1.1667 + test(pending);
1.1668 +#if defined(__WINSCW__) // X: drive on emulator
1.1669 + pending = iStateAccessor->IsScanDirectoryPending(*iDiscoverer, EDriveX);
1.1670 + test(pending);
1.1671 +#else // E: drive on HW
1.1672 + pending = iStateAccessor->IsScanDirectoryPending(*iDiscoverer, EDriveE);
1.1673 + test(pending);
1.1674 +#endif // __WINSCW__
1.1675 +
1.1676 + // Start Active Scheduler and shut it down in 3 secs, it will launch RunL of timer to process
1.1677 + // all pending notification.
1.1678 + iShutdown.StartAfter(KOneSecond * 3);
1.1679 + CActiveScheduler::Start();
1.1680 +
1.1681 + // Check if notifications have been processed on all drives.
1.1682 + test(iStateAccessor->IsScanDirectoryComplete(*iDiscoverer));
1.1683 + }
1.1684 +
1.1685 +/**
1.1686 +@SYMTestCaseID SYSLIB-ECOM-UT-3519
1.1687 +@SYMTestCaseDesc Tests notification processing during SWI for
1.1688 + PDEF110201: Undesireable interaction between ECOM and SWI
1.1689 +@SYMTestActions Create notification request on drives.
1.1690 + Check the notifications are not processed by timer if SWI in progress.
1.1691 + Check that timer processes pending notifications after SWI completes
1.1692 +@SYMTestExpectedResults The test must not fail.
1.1693 +@SYMDEF PDEF110201
1.1694 +*/
1.1695 +void CDiscovererTest::SWINotificationProcessingTestL()
1.1696 + {
1.1697 + test.Next(_L(" @SYMTestCaseID:SYSLIB-ECOM-UT-3519 "));
1.1698 +
1.1699 + //Begin SWI
1.1700 + iStateAccessor->SwiChangeNotificationL(*iDiscoverer,ESASwisInstall);
1.1701 +
1.1702 + iDiscoverer->ProcessSSAEventL(EStartupStateNonCritical);
1.1703 +
1.1704 + // Raise a notification on C: drive
1.1705 + iDiscoverer->ProcessDNEventL(CDiscoverer::EPluginsModified, EDriveC);
1.1706 + iDiscoverer->ProcessDNEventL(CDiscoverer::EPluginsRediscover, EDriveC);
1.1707 +
1.1708 + // Start Active Scheduler and shut it down in 3 secs, it will launch RunL of timer to process
1.1709 + // all pending notification.
1.1710 + iShutdown.StartAfter(KOneSecond * 3);
1.1711 + CActiveScheduler::Start();
1.1712 +
1.1713 + // Check that notifications have NOT been processed as SWI is in progress
1.1714 + test(!iStateAccessor->IsScanDirectoryComplete(*iDiscoverer));
1.1715 +
1.1716 + //complete SWI
1.1717 + iStateAccessor->SwiChangeNotificationL(*iDiscoverer,ESASwisUninstall);
1.1718 +
1.1719 +
1.1720 +#if defined(__WINSCW__) // X: drive on emulator
1.1721 + // Raise notification on X: drive
1.1722 + iDiscoverer->ProcessDNEventL(CDiscoverer::EPluginsModified, EDriveX);
1.1723 + iDiscoverer->ProcessDNEventL(CDiscoverer::EPluginsRediscover, EDriveX);
1.1724 +#else // E: drive on HW
1.1725 + // Raise notification on E: drive
1.1726 + iDiscoverer->ProcessDNEventL(CDiscoverer::EPluginsModified, EDriveE);
1.1727 + iDiscoverer->ProcessDNEventL(CDiscoverer::EPluginsRediscover, EDriveE);
1.1728 +#endif // __WINSCW__
1.1729 +
1.1730 + // Start Active Scheduler and shut it down in 3 secs, it will launch RunL of timer to process
1.1731 + // all pending notification.
1.1732 + iShutdown.StartAfter(KOneSecond * 3);
1.1733 + CActiveScheduler::Start();
1.1734 +
1.1735 + // Check that notifications have NOT been processed as SWI is not finished
1.1736 + test(!iStateAccessor->IsScanDirectoryComplete(*iDiscoverer));
1.1737 +
1.1738 + //finalise SWI
1.1739 + iStateAccessor->SwiChangeNotificationL(*iDiscoverer,ESASwisNone);
1.1740 +
1.1741 + // Start Active Scheduler and shut it down in 3 secs, it will launch RunL of timer to process
1.1742 + // all pending notification.
1.1743 + iShutdown.StartAfter(KOneSecond * 3);
1.1744 + CActiveScheduler::Start();
1.1745 +
1.1746 + // Check that notifications have been processed on all drives
1.1747 + test(iStateAccessor->IsScanDirectoryComplete(*iDiscoverer));
1.1748 +
1.1749 + //Begin SWI
1.1750 + iStateAccessor->SwiChangeNotificationL(*iDiscoverer,ESASwisInstall);
1.1751 +
1.1752 + iDiscoverer->ProcessSSAEventL(EStartupStateNonCritical);
1.1753 +
1.1754 + // Raise a notification
1.1755 + iDiscoverer->ProcessDNEventL(CDiscoverer::EPluginsModified,EDriveC);
1.1756 + iDiscoverer->ProcessDNEventL(CDiscoverer::EPluginsRediscover,EDriveC);
1.1757 +
1.1758 + // Start Active Scheduler and shut it down in 3 secs, it will launch RunL of timer to process
1.1759 + // all pending notification.
1.1760 + iShutdown.StartAfter(KOneSecond * 3);
1.1761 + CActiveScheduler::Start();
1.1762 +
1.1763 + // Check that notifications have NOT been processed as SWI is in progress
1.1764 + test(!iStateAccessor->IsScanDirectoryComplete(*iDiscoverer));
1.1765 +
1.1766 + //Simulate an error in reading the P&S Variable - This should reset the
1.1767 + //SWI state to ESASwisNone in the same way as completing SWI
1.1768 + iStateAccessor->SwiChangeNotifierRunError(*iDiscoverer,KErrNotFound);
1.1769 +
1.1770 + // Start Active Scheduler and shut it down in 3 secs, it will launch RunL of timer to process
1.1771 + // all pending notification.
1.1772 + iShutdown.StartAfter(KOneSecond * 3);
1.1773 + CActiveScheduler::Start();
1.1774 +
1.1775 + // Check that notifications have been processed on all drives
1.1776 + test(iStateAccessor->IsScanDirectoryComplete(*iDiscoverer));
1.1777 + }
1.1778 +
1.1779 +/**
1.1780 +Call the TDiscoverer_StateAccessor::IdleScanningTimerRunErrorL funtion
1.1781 +passing in a reference to the CDiscoverer object and the error code
1.1782 +to be passed to the CIdleScanningTimer::RunError function
1.1783 +*/
1.1784 +void CDiscovererTest::IdleScanningTimerRunErrorL()
1.1785 + {
1.1786 + iStateAccessor->IdleScanningTimerRunErrorL(*iDiscoverer, EEComPanic_CDiscoverer_CIdleScanningTimer_RunError);
1.1787 + }
1.1788 +
1.1789 +/**
1.1790 +Call the TDiscoverer_StateAccessor::IdleScanningTimerRunErrorL funtion
1.1791 +passing in a reference to the CDiscoverer object and the error code
1.1792 +to be passed to the CDirChangeNotifier::RunError function
1.1793 +*/
1.1794 +void CDiscovererTest::DirChangeNotifierRunErrorL()
1.1795 + {
1.1796 + iStateAccessor->DirChangeNotifierRunErrorL(*iDiscoverer, EEComPanic_CDiscoverer_CDirChangeNotifier_RunError);
1.1797 + }
1.1798 +
1.1799 +/**
1.1800 +Call the TDiscoverer_StateAccessor::IdleScanningTimerRunErrorL funtion
1.1801 +passing in a reference to the CDiscoverer object and the error code
1.1802 +to be passed to the CSwiChangeNotifier::RunError function
1.1803 +*/
1.1804 +void CDiscovererTest::SwiChangeNotifierRunError()
1.1805 + {
1.1806 + iStateAccessor->SwiChangeNotifierRunError(*iDiscoverer, KErrNoMemory);
1.1807 + }
1.1808 +/**
1.1809 +@SYMTestCaseID SYSLIB-ECOM-UT-3172
1.1810 +@SYMTestCaseDesc Tests language switch notification processing for
1.1811 + "CR0902: Enable Dynamic Language Switching in APPARC, ECOM and EIKSTD"
1.1812 +@SYMTestPriority High
1.1813 +@SYMTestActions Call ProcessSSAEventL with EStartupStateNonCritical state.
1.1814 + Call DriveMountedL to build up drives in system.
1.1815 + Call LanguageChangedL to raise multiple notification on all drives in system.
1.1816 + Check if the notifications are processed on all drive(s) by timer.
1.1817 + Check the notifications are processed properly by timer.
1.1818 + Check the state of discoverer was set correctly on completion.
1.1819 +@SYMTestExpectedResults The test must not fail.
1.1820 +@SYMDEF CR0902
1.1821 +*/
1.1822 +void CDiscovererTest::LanguageChangedNotificationTestL()
1.1823 + {
1.1824 + test.Next(_L(" @SYMTestCaseID:SYSLIB-ECOM-UT-3172 "));
1.1825 + TBool pending = EFalse;
1.1826 +
1.1827 + //Call ProcessSSAEventL with EStartupStateNonCritical state
1.1828 + iDiscoverer->ProcessSSAEventL(EStartupStateNonCritical);
1.1829 +
1.1830 + if(iStateAccessor->IsDriveMounted(*iDiscoverer, EDriveK))
1.1831 + {
1.1832 + TRAPD(err, iStateAccessor->DriveUnmountedL(*iDiscoverer, EDriveK));
1.1833 + TEST_OOM_ERR;
1.1834 + test(err == KErrNone);
1.1835 + }
1.1836 +
1.1837 + // Mount drives on system
1.1838 + TRAPD(err, iStateAccessor->DriveMountedL(*iDiscoverer, EDriveZ));
1.1839 + TEST_OOM_ERR;
1.1840 + test(err == KErrNone);
1.1841 +
1.1842 + TRAP(err, iStateAccessor->DriveMountedL(*iDiscoverer, EDriveC));
1.1843 + TEST_OOM_ERR;
1.1844 + test(err == KErrNone);
1.1845 +
1.1846 +#if defined(__WINSCW__) // X: drive on emulator
1.1847 + TRAP(err, iStateAccessor->DriveMountedL(*iDiscoverer, EDriveX));
1.1848 + TEST_OOM_ERR;
1.1849 + test(err == KErrNone);
1.1850 +#else // E: drive on HW
1.1851 + TRAP(err, iStateAccessor->DriveMountedL(*iDiscoverer, EDriveE));
1.1852 + TEST_OOM_ERR;
1.1853 + test(err == KErrNone);
1.1854 +#endif
1.1855 +
1.1856 + // Multiple notification on all drives:
1.1857 + iStateAccessor->LanguageChangedL(*iDiscoverer);
1.1858 +
1.1859 + // Check three pending drive in the list.
1.1860 + test(iStateAccessor->PendingDriveListCount(*iDiscoverer) == 3);
1.1861 + // Check the pending drive is Z: drive
1.1862 + pending = iStateAccessor->IsScanDirectoryPending(*iDiscoverer, EDriveZ);
1.1863 + test(pending);
1.1864 +
1.1865 + // Check the pending drive is C: drive
1.1866 + pending = iStateAccessor->IsScanDirectoryPending(*iDiscoverer, EDriveC);
1.1867 + test(pending);
1.1868 +
1.1869 +#if defined(__WINSCW__) // X: drive on emulator
1.1870 + pending = iStateAccessor->IsScanDirectoryPending(*iDiscoverer, EDriveX);
1.1871 + test(pending);
1.1872 +#else // E: drive on HW
1.1873 + pending = iStateAccessor->IsScanDirectoryPending(*iDiscoverer, EDriveE);
1.1874 + test(pending);
1.1875 +#endif // __WINSCW__
1.1876 +
1.1877 + // Start Active Scheduler and shut it down in 3 secs, it will launch RunL of timer to process
1.1878 + // all pending notification.
1.1879 + iShutdown.StartAfter(KOneSecond * 3);
1.1880 + CActiveScheduler::Start();
1.1881 +
1.1882 + // Check if notifications have been processed on all drives.
1.1883 + test(iStateAccessor->IsScanDirectoryComplete(*iDiscoverer));
1.1884 +
1.1885 + }
1.1886 +
1.1887 +/**
1.1888 +@SYMTestCaseID SYSLIB-ECOM-CT-0723
1.1889 +@SYMTestCaseDesc Tests the creation and deletion of CDiscoverer
1.1890 +@SYMTestPriority High
1.1891 +@SYMTestActions Create and delete CDiscoverer object,checks for open handles
1.1892 +@SYMTestExpectedResults The test must not fail.
1.1893 +@SYMREQ REQ0000
1.1894 +*/
1.1895 +LOCAL_C void CreateDeleteTestL()
1.1896 + {
1.1897 + test.Next(_L(" @SYMTestCaseID:SYSLIB-ECOM-CT-0723 CreateDeleteTestL "));
1.1898 + //
1.1899 + // Tests the Creating and deletion of CDiscoverer
1.1900 + // ------------------------------------------------------------------
1.1901 + //
1.1902 + // Set up for heap leak checking
1.1903 + __UHEAP_MARK;
1.1904 +
1.1905 + //Check Thread handles leak
1.1906 + TInt startProcessHandleCount = 0;
1.1907 + TInt startThreadHandleCount = 0;
1.1908 + TInt endProcessHandleCount = 0;
1.1909 + TInt endThreadHandleCount = 0;
1.1910 +
1.1911 + RThread rThread;
1.1912 + rThread.HandleCount(startProcessHandleCount, startThreadHandleCount);
1.1913 +
1.1914 + //START CREATE DELETE TEST//
1.1915 +
1.1916 + CDiscovererTest* discTest = CDiscovererTest::NewL();
1.1917 +
1.1918 + test(discTest != NULL);
1.1919 +
1.1920 + delete discTest;
1.1921 +
1.1922 + //END CREATE DELETE TEST//
1.1923 +
1.1924 + // Check for open handles
1.1925 + rThread.HandleCount(endProcessHandleCount, endThreadHandleCount);
1.1926 + test(startThreadHandleCount == endThreadHandleCount);
1.1927 +
1.1928 + //Test ends
1.1929 + __UHEAP_MARKEND;
1.1930 + }
1.1931 +
1.1932 +/**
1.1933 +@SYMTestCaseID SYSLIB-ECOM-CT-0724
1.1934 +@SYMTestCaseDesc OOM test for create and delete of CDiscoverer.
1.1935 +@SYMTestPriority High
1.1936 +@SYMTestActions Create and delete CDiscoverer object,checks for any memory leak.
1.1937 +@SYMTestExpectedResults The test must not fail.
1.1938 +@SYMREQ REQ0000
1.1939 +*/
1.1940 +LOCAL_C void OOMCreateDeleteTest()
1.1941 + {
1.1942 + test.Next(_L(" @SYMTestCaseID:SYSLIB-ECOM-CT-0724 OOM CreateDeleteTest "));
1.1943 + TInt err;
1.1944 + TInt failAt = 1;
1.1945 + __UNUSED_VAR(failAt);
1.1946 +
1.1947 + CDiscovererTest* discTest = NULL;
1.1948 +
1.1949 + do
1.1950 + {
1.1951 + __UHEAP_MARK;
1.1952 + // find out the number of open handles
1.1953 + TInt startProcessHandleCount;
1.1954 + TInt startThreadHandleCount;
1.1955 + RThread().HandleCount(startProcessHandleCount, startThreadHandleCount);
1.1956 +
1.1957 + __UHEAP_SETFAIL(RHeap::EDeterministic, failAt++);
1.1958 +
1.1959 + TRAP(err, discTest = CDiscovererTest::NewL());
1.1960 +
1.1961 + __UHEAP_SETFAIL(RHeap::ENone, 0);
1.1962 +
1.1963 + delete discTest;
1.1964 + discTest = NULL;
1.1965 +
1.1966 + // check that no handles have leaked
1.1967 + TInt endProcessHandleCount;
1.1968 + TInt endThreadHandleCount;
1.1969 + RThread().HandleCount(endProcessHandleCount, endThreadHandleCount);
1.1970 +
1.1971 + test(startProcessHandleCount == endProcessHandleCount);
1.1972 + test(startThreadHandleCount == endThreadHandleCount);
1.1973 +
1.1974 + __UHEAP_MARKEND;
1.1975 + }
1.1976 + while(err == KErrNoMemory);
1.1977 +
1.1978 + test.Printf(_L("- Succeeded at heap failure rate of %i\n"), failAt);
1.1979 + test(err == KErrNone);
1.1980 + }
1.1981 +
1.1982 +// Type definition for pointer to member function.
1.1983 +// Used in calling the CDiscovererTest member function for testing.
1.1984 +typedef void (CDiscovererTest::*ClassFuncPtrL) (void);
1.1985 +
1.1986 +/**
1.1987 +@SYMTestCaseID SYSLIB-ECOM-CT-0725
1.1988 +@SYMTestCaseDesc Function to call all test functions
1.1989 +@SYMTestPriority High
1.1990 +@SYMTestActions Calls up test function of CDiscovererTest.
1.1991 +@SYMTestExpectedResults The test must not fail.
1.1992 +@SYMREQ REQ0000
1.1993 +*/
1.1994 +/**
1.1995 +Wrapper function to call all test functions
1.1996 +
1.1997 +@param testFunc pointer to test function
1.1998 +@param aTestDesc test function name
1.1999 +*/
1.2000 +LOCAL_C void DoBasicTestL(ClassFuncPtrL testFuncL, const TDesC& aTestDesc)
1.2001 + {
1.2002 + test.Next(_L(" @SYMTestCaseID:SYSLIB-ECOM-CT-0725 "));
1.2003 + test.Next(aTestDesc);
1.2004 +
1.2005 + __UHEAP_MARK;
1.2006 + // find out the number of open handles
1.2007 + TInt startProcessHandleCount;
1.2008 + TInt startThreadHandleCount;
1.2009 + RThread().HandleCount(startProcessHandleCount, startThreadHandleCount);
1.2010 +
1.2011 + CDiscovererTest* discTest = CDiscovererTest::NewL();
1.2012 + CleanupStack::PushL(discTest);
1.2013 +
1.2014 + (discTest->*testFuncL)();
1.2015 +
1.2016 + CleanupStack::PopAndDestroy(discTest);
1.2017 +
1.2018 + // check that no handles have leaked
1.2019 + TInt endProcessHandleCount;
1.2020 + TInt endThreadHandleCount;
1.2021 + RThread().HandleCount(endProcessHandleCount, endThreadHandleCount);
1.2022 +
1.2023 + test(startProcessHandleCount == endProcessHandleCount);
1.2024 + test(startThreadHandleCount == endThreadHandleCount);
1.2025 +
1.2026 + __UHEAP_MARKEND;
1.2027 + }
1.2028 +
1.2029 +/**
1.2030 +Utility function to continually invoke a test function and cause memory allocation failures
1.2031 +
1.2032 +@param testFuncL pointer to OOM test function
1.2033 +@param tryCount specifies what value to start memory allocation failures at
1.2034 +@param increment how much to increase the point at which memory allocation will fail on each test attempt
1.2035 +@param stopCount the value of memory allocation failure to stop testing at
1.2036 +*/
1.2037 +TInt RunTestUnderOOMCondition(ClassFuncPtrL testFuncL, TInt tryCount, TInt increment, TInt stopCount)
1.2038 +{
1.2039 + TInt err = KErrNone;
1.2040 +
1.2041 + do
1.2042 + {
1.2043 +
1.2044 + __UHEAP_MARK;
1.2045 + // find out the number of open handles
1.2046 + TInt startProcessHandleCount;
1.2047 + TInt startThreadHandleCount;
1.2048 + RThread().HandleCount(startProcessHandleCount, startThreadHandleCount);
1.2049 +
1.2050 + CDiscovererTest* discTest = CDiscovererTest::NewL();
1.2051 + CleanupStack::PushL(discTest);
1.2052 +
1.2053 +
1.2054 + __UHEAP_SETFAIL(RHeap::EDeterministic, tryCount);
1.2055 + TRAP(err, (discTest->*testFuncL)());
1.2056 + __UHEAP_SETFAIL(RHeap::ENone, 0);
1.2057 +
1.2058 +
1.2059 + CleanupStack::PopAndDestroy(discTest);
1.2060 + discTest = NULL;
1.2061 +
1.2062 + // check that no handles have leaked
1.2063 + TInt endProcessHandleCount;
1.2064 + TInt endThreadHandleCount;
1.2065 + RThread().HandleCount(endProcessHandleCount, endThreadHandleCount);
1.2066 +
1.2067 + test(startProcessHandleCount == endProcessHandleCount);
1.2068 + test(startThreadHandleCount == endThreadHandleCount);
1.2069 +
1.2070 + __UHEAP_MARKEND;
1.2071 +
1.2072 + tryCount = tryCount + increment;
1.2073 + } while((err == KErrNoMemory) && (tryCount != stopCount));
1.2074 +
1.2075 + tryCount = tryCount - increment;
1.2076 +
1.2077 +
1.2078 + if (err == KErrNoMemory)
1.2079 + {
1.2080 + // test has not yet been able to pass due to memory allocation failures.
1.2081 + return -1;
1.2082 + }
1.2083 +
1.2084 + test(err == KErrNone);
1.2085 +
1.2086 + // If enough memory has finally been allocated for the test to pass then return
1.2087 + // the memory allocation counter value.
1.2088 + test.Printf(_L("- server succeeded at heap failure rate of %i\n"), tryCount);
1.2089 + return tryCount;
1.2090 +}
1.2091 +
1.2092 +/**
1.2093 +Wrapper function to call all OOM test functions
1.2094 +
1.2095 +@param testFuncL pointer to OOM test function
1.2096 +@param aTestDesc test function name
1.2097 +*/
1.2098 +LOCAL_C void DoOOMTestL(ClassFuncPtrL testFuncL, const TDesC& aTestDesc)
1.2099 + {
1.2100 + test.Next(aTestDesc);
1.2101 +
1.2102 + TInt startCount = 1;
1.2103 + TInt increment = 1;
1.2104 + TInt successRate = -1;
1.2105 + TInt stopCount = 256;
1.2106 +
1.2107 + successRate = RunTestUnderOOMCondition(testFuncL, startCount, increment, stopCount);
1.2108 +
1.2109 + // (INC115057)
1.2110 + // When method CDiscoverer::CDirScanner::DoScanDriveL is encountered in a test hundreds
1.2111 + // of plug-in files will be scanned. It takes in the order of 3-4000 memory allocation failure
1.2112 + // loops (in techview context) before the scan is finished and the test can complete successfully.
1.2113 + // This will take over an hour. Instead determine the approximate failure point by
1.2114 + // testing with large increments between failures. Once a failure rate interval is found test
1.2115 + // for OOM conditions running up to it.
1.2116 + // This in effect means that we are checking OOM at the start and end of tests but skipping
1.2117 + // the scanning of each and every plugin in the middle of the test.
1.2118 + // (Note that CDiscoverer::CDirScanner::DoScanDriveL may return without leaving when it
1.2119 + // can't allocate TFileName. In this case it seems to this function that the test is
1.2120 + // successful. Therefore even if the successRate above indicates a pass the test is still
1.2121 + // re-run below with larger memory allocation failure valued to make sure that the test does
1.2122 + // in fact run to completion.
1.2123 +
1.2124 + startCount = 256;
1.2125 + increment = 256;
1.2126 + stopCount = -1;
1.2127 + successRate = RunTestUnderOOMCondition(testFuncL, startCount, increment, stopCount);
1.2128 + test(successRate > 0);
1.2129 +
1.2130 + if (successRate > 256)
1.2131 + {
1.2132 + startCount = successRate - 256;
1.2133 + increment = 1;
1.2134 + stopCount = -1;
1.2135 + successRate = RunTestUnderOOMCondition(testFuncL, startCount, increment, stopCount);
1.2136 + }
1.2137 +
1.2138 + test(successRate > 0);
1.2139 + }
1.2140 +
1.2141 +/**
1.2142 +Creates and installs active scheduler for this thread and calls
1.2143 +CDiscovererTest::IdleScanningTimerRunErrorL
1.2144 +
1.2145 +@param aDiscTest The CDiscovererTest object used to carry out the test
1.2146 +*/
1.2147 +LOCAL_C void DoIdleScanningTimerRunErrorTestL(CDiscovererTest* aDiscTest)
1.2148 + {
1.2149 +
1.2150 + // create and install the active scheduler we need
1.2151 + CActiveScheduler* scheduler=new(ELeave) CActiveScheduler;
1.2152 + CleanupStack::PushL(scheduler);
1.2153 +
1.2154 + CActiveScheduler::Install(scheduler);
1.2155 +
1.2156 + aDiscTest->IdleScanningTimerRunErrorL();
1.2157 +
1.2158 + // Cleanup CDiscovererTest, TheFs and scheduler
1.2159 + CleanupStack::PopAndDestroy(scheduler);
1.2160 +
1.2161 + }
1.2162 +/**
1.2163 +Thread entry point for the test thread. Creates a CTrapCleanup and
1.2164 +calls DoIdleScanningTimerRunErrorTestL to carry out the test
1.2165 +
1.2166 +@param aDiscTest The CDiscovererTest object used to carry out the test
1.2167 +*/
1.2168 +LOCAL_C TInt IdleScanningTimerRunErrorThreadEntry(TAny* aDiscTest)
1.2169 + {
1.2170 +
1.2171 + CTrapCleanup* tc = CTrapCleanup::New();
1.2172 +
1.2173 + CDiscovererTest *discTest = static_cast<CDiscovererTest*>(aDiscTest);
1.2174 +
1.2175 + TRAPD(err,DoIdleScanningTimerRunErrorTestL(discTest));
1.2176 +
1.2177 + delete tc;
1.2178 +
1.2179 + return err;
1.2180 +
1.2181 + }
1.2182 +
1.2183 +
1.2184 +/**
1.2185 +@SYMTestCaseID SYSLIB-ECOM-CT-3165
1.2186 +@SYMTestCaseDesc Check that the CIdleScanningTimer::RunError() works correctly.
1.2187 +@SYMTestPriority High
1.2188 +@SYMTestActions Create a new thread which will call RunError. Wait for the
1.2189 + thread to exit and check the thread exit type and reason
1.2190 + to verify behaviour
1.2191 +@SYMTestExpectedResults The test must not fail.
1.2192 +@SYMDEF DEF094675
1.2193 +*/
1.2194 +LOCAL_C void IdleScanningTimer_RunErrorTest()
1.2195 + {
1.2196 + __UHEAP_MARK;
1.2197 +
1.2198 + test.Next(_L(" @SYMTestCaseID:SYSLIB-ECOM-CT-3165 CIdleScanningTimer RunError test "));
1.2199 +
1.2200 + _LIT(KStartThreadName,"CIdleScanningTimer RunError Thread");
1.2201 +
1.2202 + //Disable JIT so that the Panic doesn't bring up a dialog
1.2203 + //and stop the test
1.2204 + TBool jitEnabled = User::JustInTime();
1.2205 + User::SetJustInTime(EFalse);
1.2206 +
1.2207 + //Create a CDiscovererTest object to pass into the test thread
1.2208 + CDiscovererTest* discTest = CDiscovererTest::NewL();
1.2209 + CleanupStack::PushL(discTest);
1.2210 +
1.2211 + //Create a new thread to run the test
1.2212 + RThread testThread;
1.2213 + testThread.Create(KStartThreadName, IdleScanningTimerRunErrorThreadEntry,
1.2214 + KDefaultStackSize,KMinHeapSize,KMinHeapSize,discTest);
1.2215 + TRequestStatus status;
1.2216 + testThread.Logon(status);
1.2217 +
1.2218 +
1.2219 + testThread.Resume();
1.2220 +
1.2221 + //Wait for the thread to exit
1.2222 + User::WaitForRequest(status);
1.2223 +
1.2224 + //Obtain exit type and reason for test thread
1.2225 + TExitType exitType = testThread.ExitType();
1.2226 + TInt exitReason = testThread.ExitReason();
1.2227 +
1.2228 + //close the thread handle
1.2229 + testThread.Close();
1.2230 +
1.2231 + CleanupStack::PopAndDestroy(discTest);
1.2232 +
1.2233 + //Set JIT back to original state
1.2234 + User::SetJustInTime(jitEnabled);
1.2235 +
1.2236 + //Verify the exit reason and exit code
1.2237 + test(exitType == EExitPanic);
1.2238 + test(exitReason == EEComPanic_CDiscoverer_CIdleScanningTimer_RunError);
1.2239 +
1.2240 + __UHEAP_MARKEND;
1.2241 + }
1.2242 +
1.2243 +/**
1.2244 +Creates and installs active scheduler for this thread and calls
1.2245 +CDiscovererTest::DirChangeNotifierRunErrorL
1.2246 +
1.2247 +@param aDiscTest The CDiscovererTest object used to carry out the test
1.2248 +*/
1.2249 +LOCAL_C void DoDirChangeNotifierRunErrorTestL(CDiscovererTest* aDiscTest)
1.2250 + {
1.2251 +
1.2252 + // create and install the active scheduler we need
1.2253 + CActiveScheduler* scheduler=new(ELeave) CActiveScheduler;
1.2254 + CleanupStack::PushL(scheduler);
1.2255 +
1.2256 + CActiveScheduler::Install(scheduler);
1.2257 +
1.2258 + //call the RunErrorL method which should panic
1.2259 + aDiscTest->DirChangeNotifierRunErrorL();
1.2260 +
1.2261 + // Cleanup CDiscovererTest, TheFs and scheduler
1.2262 + CleanupStack::PopAndDestroy(scheduler);
1.2263 +
1.2264 + }
1.2265 +
1.2266 +/**
1.2267 +Thread entry point for the test thread. Creates a CTrapCleanup and
1.2268 +calls DoDirChangeNotifierRunErrorTestL to carry out the test
1.2269 +
1.2270 +@param aDiscTest The CDiscovererTest object used to carry out the test
1.2271 +*/
1.2272 +LOCAL_C TInt DirChangeNotifierRunErrorThreadEntry(TAny* aDiscTest)
1.2273 + {
1.2274 +
1.2275 + CTrapCleanup* tc = CTrapCleanup::New();
1.2276 +
1.2277 + CDiscovererTest *discTest = static_cast<CDiscovererTest*>(aDiscTest);
1.2278 +
1.2279 + TRAPD(err,DoDirChangeNotifierRunErrorTestL(discTest));
1.2280 +
1.2281 + delete tc;
1.2282 +
1.2283 + return err;
1.2284 +
1.2285 + }
1.2286 +
1.2287 +/**
1.2288 +@SYMTestCaseID SYSLIB-ECOM-CT-3166
1.2289 +@SYMTestCaseDesc Check that the CDirChangeNotifier::RunError() works correctly.
1.2290 +@SYMTestPriority High
1.2291 +@SYMTestActions Create a new thread which will call RunError. Wait for the
1.2292 + thread to exit and check the thread exit type and reason
1.2293 + to verify behaviour
1.2294 +@SYMTestExpectedResults The test must not fail.
1.2295 +@SYMDEF DEF094675
1.2296 +*/
1.2297 +LOCAL_C void DirChangeNotifier_RunErrorTest()
1.2298 + {
1.2299 + __UHEAP_MARK;
1.2300 +
1.2301 + test.Next(_L(" @SYMTestCaseID:SYSLIB-ECOM-CT-3166 CDirChangeNotifier RunError test "));
1.2302 +
1.2303 + _LIT(KStartThreadName,"CDirChangeNotifier RunError Thread");
1.2304 +
1.2305 + //Disable JIT so that the Panic doesn't bring up a dialog
1.2306 + //and stop the test
1.2307 + TBool jitEnabled = User::JustInTime();
1.2308 + User::SetJustInTime(EFalse);
1.2309 +
1.2310 + //Create a CDiscovererTest object to pass into the test thread
1.2311 + CDiscovererTest* discTest = CDiscovererTest::NewL();
1.2312 + CleanupStack::PushL(discTest);
1.2313 +
1.2314 + //Create a new thread to run the test
1.2315 + RThread testThread;
1.2316 + testThread.Create(KStartThreadName, DirChangeNotifierRunErrorThreadEntry,
1.2317 + KDefaultStackSize,KMinHeapSize,KMinHeapSize,discTest);
1.2318 + TRequestStatus status;
1.2319 + testThread.Logon(status);
1.2320 + testThread.Resume();
1.2321 +
1.2322 + //Wait for the thread to exit
1.2323 + User::WaitForRequest(status);
1.2324 +
1.2325 + //Obtain exit type and reason for test thread
1.2326 + TExitType exitType = testThread.ExitType();
1.2327 + TInt exitReason = testThread.ExitReason();
1.2328 +
1.2329 + //close the thread handle
1.2330 + testThread.Close();
1.2331 +
1.2332 + CleanupStack::PopAndDestroy(discTest);
1.2333 +
1.2334 + //Set JIT back to original state
1.2335 + User::SetJustInTime(jitEnabled);
1.2336 +
1.2337 + //Verify the exit reason and exit code
1.2338 + test(exitType == EExitPanic);
1.2339 + test(exitReason == EEComPanic_CDiscoverer_CDirChangeNotifier_RunError);
1.2340 +
1.2341 + __UHEAP_MARKEND;
1.2342 + }
1.2343 +
1.2344 +TInt DoTestsL()
1.2345 + {
1.2346 + __UHEAP_MARK;
1.2347 +
1.2348 + // Basic tests
1.2349 + CreateDeleteTestL();
1.2350 + DoBasicTestL(&CDiscovererTest::ResumeSuspendTestL, _L("ResumeSuspendTestL"));
1.2351 + DoBasicTestL(&CDiscovererTest::DriveMountUnmountTestL, _L("DriveMountUnmountTestL"));
1.2352 + DoBasicTestL(&CDiscovererTest::ProcessEntryTestL, _L("ProcessEntryTestL"));
1.2353 + DoBasicTestL(&CDiscovererTest::ValidateEntryTestL, _L("ValidateEntryTestL"));
1.2354 + DoBasicTestL(&CDiscovererTest::ProcessSpiEntryTestL, _L("ProcessSpiEntryTestL"));
1.2355 + DoBasicTestL(&CDiscovererTest::ValidateSpiEntryTestL, _L("ValidateSpiEntryTestL"));
1.2356 + DoBasicTestL(&CDiscovererTest::ProcessEntryPlugIn3TestL, _L("ProcessEntryPlugIn3TestL"));
1.2357 + DoBasicTestL(&CDiscovererTest::ValidateEntryPlugIn3TestL, _L("ValidateEntryPlugIn3TestL"));
1.2358 + DoBasicTestL(&CDiscovererTest::ProcessSpiEntryPlugIn3TestL, _L("ProcessSpiEntryPlugIn3TestL"));
1.2359 + DoBasicTestL(&CDiscovererTest::ValidateSpiEntryPlugIn3TestL, _L("ValidateSpiEntryPlugIn3TestL"));
1.2360 + DoBasicTestL(&CDiscovererTest::ValidateSpiPluginsTestL, _L("ValidateSpiPluginsTestL"));
1.2361 + DoBasicTestL(&CDiscovererTest::ScanDirectoryIncrementTestL, _L("ScanDirectoryIncrementTestL"));
1.2362 + DoBasicTestL(&CDiscovererTest::StagedDiscoveryStateTransitionTestL, _L("StagedDiscoveryStateTransitionTestL"));
1.2363 + DoBasicTestL(&CDiscovererTest::AllAtOnceDiscoveryStateTransitionTestL, _L("AllAtOnceDiscoveryStateTransitionTestL"));
1.2364 + DoBasicTestL(&CDiscovererTest::ScanDirectoryTestL, _L("ScanDirectoryTestL"));
1.2365 + DoBasicTestL(&CDiscovererTest::MultipleNotificationProcessingTestL, _L("MultipleNotificationProcessingTestL"));
1.2366 + DoBasicTestL(&CDiscovererTest::LanguageChangedNotificationTestL, _L("MLanguageChangedNotificationTestL"));
1.2367 + DoBasicTestL(&CDiscovererTest::SWINotificationProcessingTestL, _L("SWINotificationProcessingTestL"));
1.2368 +
1.2369 + //RunError tests
1.2370 + IdleScanningTimer_RunErrorTest();
1.2371 + DirChangeNotifier_RunErrorTest();
1.2372 +
1.2373 + // OOM tests
1.2374 + OOMCreateDeleteTest();
1.2375 + // This test is not performed because the error from the final memory allocation failures are not
1.2376 + // propagated back to the calling function and cannot be dealt with. Therefore
1.2377 + // this test does not complete. However the normal test is performed above.
1.2378 + //DoOOMTestL(&CDiscovererTest::ResumeSuspendTestL, _L("OOM ResumeSuspendTestL"));
1.2379 + DoOOMTestL(&CDiscovererTest::DriveMountUnmountTestL, _L("OOM DriveMountUnmountTestL"));
1.2380 + DoOOMTestL(&CDiscovererTest::ProcessEntryTestL, _L("OOM ProcessEntryTestL"));
1.2381 + DoOOMTestL(&CDiscovererTest::ProcessSpiEntryTestL, _L("OOM ProcessSpiEntryTestL"));
1.2382 + DoOOMTestL(&CDiscovererTest::ValidateSpiEntryTestL, _L("OOM ValidateSpiEntryTestL"));
1.2383 + DoOOMTestL(&CDiscovererTest::ValidateEntryTestL, _L("OOM ValidateEntryTestL"));
1.2384 + DoOOMTestL(&CDiscovererTest::ProcessEntryPlugIn3TestL, _L("OOM ProcessEntryPlugIn3TestL"));
1.2385 + DoOOMTestL(&CDiscovererTest::ProcessSpiEntryPlugIn3TestL, _L("OOM ProcessSpiEntryPlugIn3TestL"));
1.2386 + DoOOMTestL(&CDiscovererTest::ValidateSpiEntryPlugIn3TestL, _L("OOM ValidateSpiEntryPlugIn3TestL"));
1.2387 + DoOOMTestL(&CDiscovererTest::ValidateEntryPlugIn3TestL, _L("OOM ValidateEntryPlugIn3TestL"));
1.2388 + DoOOMTestL(&CDiscovererTest::ScanDirectoryIncrementTestL, _L("OOM ScanDirectoryIncrementTestL"));
1.2389 + DoOOMTestL(&CDiscovererTest::StagedDiscoveryStateTransitionTestL, _L("StagedDiscoveryStateTransitionTestL"));
1.2390 + DoOOMTestL(&CDiscovererTest::AllAtOnceDiscoveryStateTransitionTestL, _L("AllAtOnceDiscoveryStateTransitionTestL"));
1.2391 + DoOOMTestL(&CDiscovererTest::ScanDirectoryTestL, _L("OOM ScanDirectoryTestL"));
1.2392 + // This test is not performed because the error from the final memory allocation failures are not
1.2393 + // propagated back to the calling function and cannot be dealt with. Therefore
1.2394 + // this test does not complete. However the normal test is performed above.
1.2395 + //DoOOMTestL(&CDiscovererTest::MultipleNotificationProcessingTestL, _L("MultipleNotificationProcessingTestL"));
1.2396 + // This test is not performed because the error from the final memory allocation failures are not
1.2397 + // propagated back to the calling function and cannot be dealt with. Therefore
1.2398 + // this test does not complete. However the normal test is performed above.
1.2399 + //DoOOMTestL(&CDiscovererTest::SWINotificationProcessingTestL, _L("OOM SWINotificationProcessingTestL"));
1.2400 +
1.2401 + __UHEAP_MARKEND;
1.2402 + return KErrNone;
1.2403 + }
1.2404 +
1.2405 +// Copy the Plugins to specific folder for testing purpose
1.2406 +LOCAL_C void CopyPlugins()
1.2407 + {
1.2408 + TInt err=KErrNone;
1.2409 + TRAP(err, EComTestUtils::FileManCopyFileL(KNewResourceFileNameOnZ, KNewResourceFileName));
1.2410 + test(err==KErrNone);
1.2411 + TRAP(err, EComTestUtils::FileManCopyFileL(KNewExampleDllFileNameOnZ, KNewExampleDllFileName));
1.2412 + test(err==KErrNone);
1.2413 + TRAP(err, EComTestUtils::FileManCopyFileL(KPlugIn3ResourceFileNameOnZ, KPlugIn3ResourceFileName));
1.2414 + test(err==KErrNone);
1.2415 + TRAP(err, EComTestUtils::FileManCopyFileL(KPlugIn3ExampleDllFileNameOnZ, KPlugIn3ExampleDllFileName));
1.2416 + test(err==KErrNone);
1.2417 + }
1.2418 +
1.2419 +// Deleting plugin from the RAM for cleanup purpose
1.2420 +inline LOCAL_C void DeleteTestPlugin()
1.2421 + {
1.2422 + TInt err=KErrNone;
1.2423 + TRAP(err, EComTestUtils::FileManDeleteFileL(KNewResourceFileName));
1.2424 + TRAP(err, EComTestUtils::FileManDeleteFileL(KNewExampleDllFileName));
1.2425 + TRAP(err, EComTestUtils::FileManDeleteFileL(KPlugIn3ResourceFileName));
1.2426 + TRAP(err, EComTestUtils::FileManDeleteFileL(KPlugIn3ExampleDllFileName));
1.2427 + }
1.2428 +
1.2429 +//
1.2430 +//Initialise the Active Scheduler
1.2431 +//
1.2432 +LOCAL_C void SetupL()
1.2433 + {
1.2434 + // Construct and install the Active Scheduler. The Active Schedular is needed
1.2435 + // by components used by this test as they are ActiveObjects.
1.2436 + TheActiveScheduler = new(ELeave)CActiveScheduler;
1.2437 + CActiveScheduler::Install(TheActiveScheduler);
1.2438 + }
1.2439 +
1.2440 +GLDEF_C TInt E32Main()
1.2441 + {
1.2442 + __UHEAP_MARK;
1.2443 +
1.2444 + test.Printf(_L("\n"));
1.2445 + test.Title();
1.2446 + test.Start(_L("Discoverer Tests."));
1.2447 +
1.2448 + TheTrapCleanup = CTrapCleanup::New();
1.2449 +
1.2450 + TRAPD(err, SetupL());
1.2451 + test(err == KErrNone);
1.2452 +
1.2453 + // Connect the file server instance
1.2454 + User::LeaveIfError(TheFs.Connect());
1.2455 +
1.2456 + CopyPlugins();
1.2457 +
1.2458 + // The reason for the folowing delay is:
1.2459 + // ECOM server could be already started. It means that when we copy some
1.2460 + // ECOM plugins from Z: to C: drive - ECOM server should look for and
1.2461 + // find the new ECOM plugins. The ECOM server uses for that an active object,
1.2462 + // which scans plugin directories. So the discovering service is asynchronous.
1.2463 + // We have to wait some time until it finishes.
1.2464 + // Otherwise ListImplementationsL could fail to find requested implementations.
1.2465 + User::After(KOneSecond * 3);
1.2466 +
1.2467 +
1.2468 + // Call the main tests
1.2469 + TRAP(err, DoTestsL());
1.2470 + test(err == KErrNone);
1.2471 +
1.2472 + // Cleanup files. If the cleanup fails that is no problem,
1.2473 + // as any subsequent tests will replace them. The only downside
1.2474 + // would be the disk not being tidied
1.2475 + DeleteTestPlugin();
1.2476 +
1.2477 + TheFs.Close();
1.2478 +
1.2479 + delete TheActiveScheduler;
1.2480 + delete TheTrapCleanup;
1.2481 +
1.2482 + test.End();
1.2483 + test.Close();
1.2484 +
1.2485 + __UHEAP_MARKEND;
1.2486 + return (KErrNone);
1.2487 + }
1.2488 +