videofeeds/server/tsrc/IptvTestUtility/inc/CIptvTestUtilities.h
changeset 0 96612d01cf9f
equal deleted inserted replaced
-1:000000000000 0:96612d01cf9f
       
     1 /*
       
     2 * Copyright (c) 2002-2004 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of the License "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:   Object to offer some common utility functions to Iptv engine testing*
       
    15 */
       
    16 
       
    17 
       
    18 #ifndef CIPTVTESTUTILITIES_H
       
    19 #define CIPTVTESTUTILITIES_H
       
    20 
       
    21 //  INCLUDES
       
    22 #include "CIptvIapList.h"
       
    23 #include "MTestUtilConnectionObserver.h"
       
    24 #include "VCXTestConstants.h"
       
    25 #include "VCXTestCommon.h"
       
    26 
       
    27 #include "CIptvService.h"
       
    28 #include "CIptvTestVerifyData.h"
       
    29 #include "CIptvTestVideoCreator.h"
       
    30 #include "CIptvServiceManagementClient.h"
       
    31 
       
    32 // MACROS
       
    33 // FORWARD DECLARATIONS
       
    34 //class CIptvService;
       
    35 class CIptvTestSMApiUtil;
       
    36 class CIptvTestMVApiUtil;
       
    37 class CIptvTestVCApiUtil;
       
    38 class CIptvMyVideosGlobalFileId;
       
    39 class CIptvIapList;
       
    40 class CIptvTestVodContentAllDetails;
       
    41 class CIptvVodContentContentFullDetails;
       
    42 class CIptvVodContentContentBriefDetails;
       
    43 class CIptvVodContentCategoryBriefDetails;
       
    44 class CIptvMyVideosVideoFullDetails;
       
    45 class CIptvMediaContent;
       
    46 
       
    47 // DATA TYPES
       
    48 
       
    49 class CIptvServiceInfo : public CBase
       
    50 	{
       
    51 	public:
       
    52 
       
    53         /**
       
    54         * Two-phased constructor.
       
    55         */
       
    56 		IMPORT_C static CIptvServiceInfo* NewL();
       
    57 		IMPORT_C static CIptvServiceInfo* NewL(CIptvServiceInfo& aServiceInfo);
       
    58 
       
    59         /**
       
    60         * Destructor
       
    61         */
       
    62 		virtual ~CIptvServiceInfo();
       
    63 
       
    64 
       
    65 	private:
       
    66 
       
    67         /**
       
    68         * C++ default constructor.
       
    69         */
       
    70         CIptvServiceInfo();
       
    71 
       
    72         /**
       
    73         * By default Symbian 2nd phase constructor is private.
       
    74         */
       
    75         void ConstructL(CIptvServiceInfo* aServiceInfo);
       
    76 
       
    77 	public:
       
    78 
       
    79 		TUint iId;
       
    80 		TBuf16<255> iName;
       
    81 		TBuf16<255> iAddress;
       
    82 		TBuf16<255> iIconPath;
       
    83 		TUid iEpgPluginUid;
       
    84 		TUid iVodPluginUid;
       
    85 		TUid iIptvPluginUid;
       
    86 		CIptvService::TServiceType iServiceType;
       
    87 		CIptvIapList* iIapList;
       
    88 		TBuf16<255> iUserName;
       
    89 		TBuf16<255> iPassWord;
       
    90 		TBuf16<255> iDesc;
       
    91 		TBool iSelectedFlag;
       
    92 	    TBool iReadOnlyFlag;
       
    93 	    TBool iMainServiceFlag;
       
    94 	    TBool iConnectionApprovedFlag;
       
    95 	    TInt32 iApplicationUid;
       
    96 	    TInt32 iDisplayOrder;
       
    97 	    TBuf16<255> iProviderId;
       
    98 	    TBuf16<255> iAccountManagementUrl;
       
    99 	};
       
   100 
       
   101 // FUNCTION PROTOTYPES
       
   102 
       
   103 // CLASS DECLARATION
       
   104 
       
   105 /**
       
   106 *  Class for helper functions that have depencies to Video Center.
       
   107 *  Add functions without depencies to VCXTestCommon.
       
   108 *
       
   109 *  @since
       
   110 */
       
   111 class CIptvTestUtilities : public CBase, public MTestUtilConnectionObserver
       
   112     {
       
   113     public:  // Constructors and destructor
       
   114 
       
   115         /**
       
   116         * Two-phased constructor.
       
   117         */
       
   118         IMPORT_C static CIptvTestUtilities* NewL();
       
   119 
       
   120         /**
       
   121         * Destructor.
       
   122         */
       
   123         IMPORT_C virtual ~CIptvTestUtilities();
       
   124 
       
   125     public: // New functions
       
   126 
       
   127         /**
       
   128         * Prints service information to debug output
       
   129         * @since
       
   130         * @param
       
   131         */
       
   132         IMPORT_C void PrintIptvService(CIptvService *aIptvService);
       
   133 
       
   134         /**
       
   135         * Writes service information into verify stream.
       
   136         * @since
       
   137         * @param
       
   138         */
       
   139         IMPORT_C void WriteVerifyIptvService(TDes& aCaseId, CIptvService *aIptvService);
       
   140 
       
   141         /**
       
   142         * Creates instance of service class.
       
   143         * @since
       
   144         * @param
       
   145         */
       
   146         IMPORT_C CIptvService* CreateIptvServiceInstanceL( CIptvServiceInfo& aService );
       
   147 
       
   148         /**
       
   149         * Compares two services.
       
   150         * @since
       
   151         * @param
       
   152         */
       
   153         IMPORT_C TBool VerifyServices(CIptvService& aS1, CIptvService& aS2);
       
   154 
       
   155         /**
       
   156         * Gets VOD content IDs for a service.
       
   157         * @since
       
   158         * @param
       
   159         */
       
   160         IMPORT_C TBool GetContentIdsL(TIptvServiceId aServiceId, TUint32 aIapId, RArray<TIptvContentId>& aContentIdArray, TUint32 aMaxSize, TUint32 aMaxPlaytime);
       
   161 
       
   162         /**
       
   163         * Gets size of a file.
       
   164         * @since
       
   165         * @param
       
   166         */
       
   167         IMPORT_C TBool GetFileSize(TDesC& aFullPath, TUint32& aFileSize);
       
   168 
       
   169         /**
       
   170         * Gets service from service DB.
       
   171         * @since
       
   172         * @param
       
   173         */
       
   174         IMPORT_C CIptvService* GetServiceFromDb(TInt aId);
       
   175 
       
   176         /**
       
   177         * Searches AP by name.
       
   178         * First searches if there's IAP matchin for the name. After that following rules are used:
       
   179         * If name is Internet tries to find first GPRS AP, Internet2 second GPRS AP
       
   180         * If name is Wlan tries to find first WLAN AP, Wlan2 second WLAN AP
       
   181         * If AP is not found returns on of the known APs, if one is found.
       
   182         */
       
   183         IMPORT_C TBool GetIapIdL(const TDesC& aIapName, TUint32& aIapId);
       
   184 
       
   185         /**
       
   186         * Searches AP by name.
       
   187         */
       
   188 		IMPORT_C TBool GetIapIdByNameL(const TDesC& aIapName, TUint32& aIapId);
       
   189 
       
   190         /**
       
   191         * Searches for AP as defined in TIptvTestIapType. In emulator always returns "Ethernet with Daemon Dynamic IP"
       
   192         * @since
       
   193         * @param aType AP type which is wanted
       
   194         * @param aIapId id of found AP is written here
       
   195         * @param aOrderNumber return nTh AP of the specified type
       
   196         * @return KErrNotFound if no AP with the type is found, KErrNone if no errors,
       
   197         */
       
   198 		IMPORT_C TInt GetIapIdByTypeL(CVCXTestCommon::TIptvTestIapType aType, TUint32& aIapId, TInt aOrderNumber);
       
   199 
       
   200         /**
       
   201         * Returns a name of AP
       
   202         */
       
   203         IMPORT_C TBool GetIapNameById(TDes& aIapName, TUint32 aIapId);
       
   204 
       
   205         /**
       
   206         * Prints APs in COMMDB into debug output.
       
   207         */
       
   208         IMPORT_C void PrintIaps();
       
   209 
       
   210         /**
       
   211         * Returns used AP for a service.
       
   212         */
       
   213         IMPORT_C TBool GetUsedIap(TUint32 aServiceId, TUint32& aIapId,TDes& aIapName);
       
   214 
       
   215         /**
       
   216         * Sets used AP for a service.
       
   217         * @return KErrNone if succeed, otherwise an error code
       
   218         */
       
   219 	    IMPORT_C TInt SetUsedIap(TUint32 aServiceId, TUint32 aIapId);
       
   220 
       
   221     	/**
       
   222         * Gets the services from the services DB
       
   223         * @param aServicesArray array where services will be added
       
   224         * @param aFlagsFilter only services with these flags will be added, use 0 to skip flags test
       
   225         * @param aOrder CIptvServiceManagementClient::TOrder enumeration to sort the services array or -1 to use no sort
       
   226         */
       
   227 		IMPORT_C TBool GetServicesFromDbL(RPointerArray<CIptvService>& aServicesArray, TUint32 aFlags, CIptvServiceManagementClient::TOrder aOrder);
       
   228 
       
   229         /**
       
   230         * Gets the services from the services DB
       
   231         * @param aServicesArray array where services will be added
       
   232         */
       
   233         IMPORT_C TBool GetServicesFromDbL(RPointerArray<CIptvService>& aServicesArray);
       
   234 
       
   235         /**
       
   236         * Gets ID of service by name.
       
   237         * @since
       
   238         * @param
       
   239         */
       
   240 		IMPORT_C TInt GetServiceIdByNameL(TDesC& aServiceName, TInt& aId);
       
   241 
       
   242         /**
       
   243         * Gets video info.
       
   244         * @since
       
   245         * @param
       
   246         */
       
   247         TBool GetVideoInfo(CIptvMyVideosGlobalFileId& aFileId,
       
   248                             TUint32& aServiceId,
       
   249                             TDes& aName,
       
   250                             TDes& aFileName);
       
   251 
       
   252   		/**
       
   253         * Initializes the verify file, deletes if the file exists
       
   254         * @since
       
   255         * @param aVerifyId An id to identify the file where verify data is written
       
   256         * @return Error code, KErrNone if no errors,
       
   257         */
       
   258 		IMPORT_C TInt CreateVerifyData(TDesC& aVerifyId, TBool aAppend);
       
   259 
       
   260 		/**
       
   261         * Writes verify data to a file
       
   262         * @since
       
   263         * @param aVerifyId An id to identify the file where verify data is written
       
   264         * @param aVerifyData Data to write into the file
       
   265         * @return Error code, KErrNone if no errors,
       
   266         */
       
   267 		IMPORT_C TInt WriteVerifyData(TDesC& aVerifyId, TDesC& aVerifyData);
       
   268 
       
   269 		/**
       
   270         * Writes verify data to a file
       
   271         * @since
       
   272         * @param aVerifyId An id to identify the file where verify data is written
       
   273         * @param aVerifyData Data to write into the file
       
   274         * @return Error code, KErrNone if no errors,
       
   275         */
       
   276 		IMPORT_C TInt WriteVerifyData(TDesC& aVerifyId, TRefByValue<const TDesC> aFmt, ... );
       
   277 
       
   278 		/**
       
   279         *
       
   280         * @since
       
   281         * @param aVerifyId An id to identify the files which are compared
       
   282         * @param aVerifyResult Result is written here
       
   283         * @return Error code, KErrNone if no errors,
       
   284         */
       
   285 		IMPORT_C TInt VerifyData(TDesC& aVerifyId, CIptvTestVerifyData::TVerifyResult& aVerifyResult);
       
   286 
       
   287         /**
       
   288         * Enables timestamp writing into the verify file.
       
   289         * @since
       
   290         * @param aUseTimestamps
       
   291         */
       
   292         IMPORT_C void EnableVerifyTimestamps( TBool aUseTimestamps );
       
   293 
       
   294         /**
       
   295         * Gets content access list
       
   296         * @since
       
   297         * @param
       
   298         */
       
   299 		IMPORT_C TInt GetContentAccessListL(TUint32 aServiceId, TUint32 aContentId, RPointerArray<CIptvMediaContent>& aCAList);
       
   300 
       
   301         /**
       
   302         * Gets content details
       
   303         * @since
       
   304         * @param
       
   305         */
       
   306 		IMPORT_C TInt GetVodContentContentDetailsL(TUint32 aServiceId, TUint32 aContentId, CIptvVodContentContentFullDetails& aContentDetails);
       
   307 
       
   308         /**
       
   309         * Gets ECG category list for a service.
       
   310         */
       
   311         IMPORT_C void GetVodEcgCategoryListL(TUint32 aServiceID, TUint32 aParentCategoryId, RPointerArray<CIptvVodContentCategoryBriefDetails>& aCategoryList);
       
   312 
       
   313         /**
       
   314         * Gets ecg list for a service.
       
   315         */
       
   316         IMPORT_C void GetVodEcgListL(TUint32 aServiceId, TUint32 aCategoryId, RPointerArray<CIptvVodContentContentBriefDetails>& aEcgList);
       
   317 
       
   318         /**
       
   319         * Gets all content details
       
   320         * @since
       
   321         * @param
       
   322         */
       
   323 		IMPORT_C void GetVodContentAllDetailsListL( TUint32 aServiceId, RPointerArray<CIptvTestVodContentAllDetails>& aDetailsList );
       
   324 
       
   325         /**
       
   326         * Gets details for a video
       
   327         * @since
       
   328         * @param
       
   329         */
       
   330 		IMPORT_C TInt GetMyVideosVideoDetailsL(CIptvMyVideosGlobalFileId& aFileId, CIptvMyVideosVideoFullDetails& aVideoDetails);
       
   331 
       
   332         /**
       
   333         * Converts string to integer.
       
   334 		* @param aInt parsed int is stored here
       
   335         * @param aString string containing the number
       
   336         * @return KErrNone if succeed, otherwise an error code
       
   337         */
       
   338 		IMPORT_C static TInt ParseIntFromString(TInt& aInt, TDesC& aString);
       
   339 
       
   340         /**
       
   341         * Creates bad iap for testing purposes
       
   342         * @param aName name of the iap to be created
       
   343         */
       
   344 		IMPORT_C TUint32 CreateBadIapL(TDesC& aName);
       
   345 
       
   346         /**
       
   347         * TInt ReallycleanL();
       
   348         * @param  -
       
   349         * @return error
       
   350         */
       
   351 		IMPORT_C TInt ReallycleanL();
       
   352 
       
   353        /**
       
   354         * TInt DeleteVideoL();
       
   355         * @param  -
       
   356         * @return error
       
   357         */
       
   358 		IMPORT_C TInt DeleteVideoL(CIptvMyVideosGlobalFileId& aFileId);
       
   359 
       
   360 		/**
       
   361         * static TInt AdvanceSystemTime1Second();
       
   362         * @return KErrNone if succeed, otherwise an error code
       
   363         */
       
   364 		IMPORT_C static TInt AdvanceSystemTime1Second();
       
   365 
       
   366         /**
       
   367         * static TInt SetSystemTime();
       
   368         * @return KErrNone if succeed, otherwise an error code
       
   369         */
       
   370 		IMPORT_C static TInt SetSystemTime(TTime aTime);
       
   371 
       
   372         /**
       
   373         * static TInt SetTimeZone();
       
   374         * @return KErrNone if succeed, otherwise an error code
       
   375         */
       
   376 		IMPORT_C static TInt SetTimeZone(TDesC& aTimeZone);
       
   377 
       
   378         /**
       
   379         * static TInt RefreshService(TUint32 aServiceId);
       
   380         * @return KErrNone if succeed, otherwise an error code
       
   381         */
       
   382 	    IMPORT_C TInt RefreshService(TUint32 aServiceId, TTime aLastDownloadTime);
       
   383 
       
   384 	    /*
       
   385 	     * Creates a video file to the system.
       
   386 	     */
       
   387 	    IMPORT_C void CreateVideoFileL( CIptvTestVideoCreator::TIptvTestVideoType aVideoType, TDesC& aFileName, TInt aSize );
       
   388 
       
   389         /*
       
   390          * Creates video files to the system.
       
   391          */
       
   392         IMPORT_C void CreateVideoFilesL( CIptvTestVideoCreator::TIptvTestVideoType aVideoType, TDesC& aFileName, TInt aCount, RPointerArray<HBufC>& aFileArray );
       
   393 
       
   394 	    /*
       
   395 	     * Sets free space for a drive.
       
   396 	     */
       
   397 	    IMPORT_C void SetDriveFreeSpaceL( TInt aDriveNumber, TUint aDesiredFreeSpace );
       
   398 
       
   399         /**
       
   400          * Deletes files created by SetDriveFreeSpaceL. Should be called by any test module which
       
   401          * has reserved disk space.
       
   402          */
       
   403         IMPORT_C void DeleteDummyFilesL( TInt aDriveNumber );
       
   404 
       
   405         /*
       
   406          * Returns KErrNone if file is not in use.
       
   407          */
       
   408         IMPORT_C TInt EnsureFileIsNotInUse( const TPtrC& aFileName );
       
   409 
       
   410 	    /*
       
   411 	     * CalculateSpaceToReserveL
       
   412 	     */
       
   413 	    void CalculateSpaceToReserveL( RFs &aFs, TInt aDriveNumber, TInt aDesiredSpace, TInt64& aSpaceToReserve, TInt64& aDriveFreeSpace, TInt64& aUsableSpace );
       
   414 
       
   415     public: // From base classes
       
   416 
       
   417         void ConnectionCreated() {};
       
   418         void ConnectionClosed() {};
       
   419         void ConnectionFailed() {};
       
   420         void ConnectionAlreadyExists() {};
       
   421         void ConnectionTimeout() {};
       
   422 
       
   423     private:
       
   424 
       
   425         /**
       
   426         * C++ default constructor.
       
   427         */
       
   428         CIptvTestUtilities();
       
   429 
       
   430         /**
       
   431         * By default Symbian 2nd phase constructor is private.
       
   432         */
       
   433         void ConstructL();
       
   434 
       
   435     private:    // Data
       
   436 	    CIptvTestSMApiUtil*    iIptvTestSMApiUtil;
       
   437 	    CIptvTestMVApiUtil*    iIptvTestMVApiUtil;
       
   438 	    CIptvTestVCApiUtil*    iIptvTestVCApiUtil;
       
   439 	    CIptvTestVerifyData*   iIptvVerifyData;
       
   440         CIptvTestVideoCreator* iVideoCreator;
       
   441         RFs iFs;
       
   442         CVCXTestCommon* iVcxCommon;
       
   443     };
       
   444 
       
   445 
       
   446 #endif      // CIPTVTESTUTILITIES_H
       
   447 
       
   448 // End of File