commsconfig/commsdatabaseshim/ts_commdb/Teststepcommdb.h
changeset 0 dfb7c4ff071f
equal deleted inserted replaced
-1:000000000000 0:dfb7c4ff071f
       
     1 // Copyright (c) 2001-2009 Nokia Corporation and/or its subsidiary(-ies).
       
     2 // All rights reserved.
       
     3 // This component and the accompanying materials are made available
       
     4 // under the terms of "Eclipse Public License v1.0"
       
     5 // which accompanies this distribution, and is available
       
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     7 //
       
     8 // Initial Contributors:
       
     9 // Nokia Corporation - initial contribution.
       
    10 //
       
    11 // Contributors:
       
    12 //
       
    13 // Description:
       
    14 // This contains CTestCaseCommDb which is the base class for all 
       
    15 // the CommDb suite test cases
       
    16 // 
       
    17 //
       
    18 
       
    19 #if (!defined __COMMDBTESTSTEP_H__)
       
    20 #define __COMMDBTESTSTEP_H__
       
    21 
       
    22 _LIT(KCommDbName, "C:\\private\\100012a5\\DBS_10004e1d_CDBV3.DAT");
       
    23 
       
    24 
       
    25 class CTestSuite;
       
    26 class CTestSuiteCommDb;
       
    27 class CCommsDatabase;
       
    28 class CCommsDbTableView;
       
    29 class CCommsDbProtectTableView;
       
    30 class CCommsDbProtectConnectPrefTableView;
       
    31 
       
    32 NONSHARABLE_CLASS(CTestStepCommDb) : public CTestStep
       
    33 {
       
    34 public:
       
    35 	CTestStepCommDb();
       
    36 	~CTestStepCommDb();
       
    37 
       
    38 	// pointer to suite which owns this test 
       
    39 	CTestSuiteCommDb * iCommDbSuite;
       
    40 
       
    41 	//Functions to set and clear the database objects that will
       
    42 	//be used by test steps derived from this class.
       
    43 	//This prevents the test steps from creating their own database objects
       
    44 	void setRemoteDatabaseObjects( CCommsDatabase* aDb, CCommsDbTableView* aDbView );
       
    45 	void clearRemoteDatabaseObjects();
       
    46 
       
    47 	TInt executeStep( CTestStepCommDb& aTestStep );
       
    48 	TInt executeStep( );
       
    49 	virtual TInt executeStepL();
       
    50 	TVerdict doTestStepPostambleL();
       
    51 	TInt doTestStepWithHeapFailureL( CTestStepCommDb& aTestStep, TInt aReturnValue );
       
    52 	TInt doTestStepWithHeapFailureDb( CTestStepCommDb& aTestStep, TInt aReturnValue );
       
    53 
       
    54 	enum TDatabaseNumber
       
    55 		{
       
    56 		EDatabase_1,		//Records in ISP tables only
       
    57 		EDatabase_7			//No records
       
    58 		};
       
    59 	TInt copyTestDatabase( TDatabaseNumber aDbNumber );
       
    60 	TInt copyDatabaseToDefault( TDatabaseNumber aDbNumber );
       
    61 	void copyFileL (const TDesC& anOld,const TDesC& aNew);
       
    62 	void deleteFileL (const TDesC& aFileName);
       
    63 
       
    64 	void DeleteCurrentDatabaseL();
       
    65 	void CopyDatabaseL(const TDesC& aSource);
       
    66 
       
    67 
       
    68 	//Pointers to the current database objects
       
    69 	CCommsDatabase*		iTheDb;
       
    70 	CCommsDbTableView*	iTheView;
       
    71 
       
    72 
       
    73 protected:
       
    74 	//Set by derived steps when local database objects have been allocated
       
    75 	TBool	iLocalObjects;
       
    76 
       
    77 	//Opens a database object and assigns it to iTheDb
       
    78 	TBool openDbL();
       
    79 	//Opens a database and a table view, assigns them to iTheDb and iTheView
       
    80 	TBool openDbAndViewL( const TDesC16& aTable );
       
    81 	//Releases any objects assigned to iTheDb and iTheView
       
    82 	void popAndDestroyDatabaseObjects();
       
    83 
       
    84 	TInt ChangeCPRankingL(CCommsDbProtectConnectPrefTableView* aTable, TUint32& Ranking);
       
    85 	//Functions needed for Protection tests
       
    86 	void    CheckTableIsProtectedL(CCommsDbProtectTableView* aTable);
       
    87 	void    CheckTableIsNotProtectedL(CCommsDbProtectTableView* aTable);
       
    88 	void    GoToPositionL(CCommsDbProtectTableView* aTable,TInt aPos);
       
    89 
       
    90 	void    UpdateRecordL   (CCommsDbProtectTableView* aTable,TInt aResult);
       
    91 	void    DeleteRecordL   (CCommsDbProtectTableView* aTable,TInt aResult);
       
    92 	void    InsertRecordL   (CCommsDbProtectTableView* aTable,TInt aResult);
       
    93 	void    ModifyRecordL   (CCommsDbProtectTableView* aTable);
       
    94 	void    PopulateInsertedRecordL(CCommsDbProtectTableView* aTable);
       
    95 
       
    96 	void    CheckTableIsProtectedL(CCommsDbProtectConnectPrefTableView* aTable);
       
    97 	void    CheckTableIsNotProtectedL(CCommsDbProtectConnectPrefTableView* aTable);
       
    98 	void    GoToPositionL(CCommsDbProtectConnectPrefTableView* aTable,TInt aPos);
       
    99 
       
   100 	void    UpdateRecordL   (CCommsDbProtectConnectPrefTableView* aTable,TInt aResult);
       
   101 	void    DeleteRecordL   (CCommsDbProtectConnectPrefTableView* aTable,TInt aResult);
       
   102 	void    InsertRecordL   (CCommsDbProtectConnectPrefTableView* aTable,TInt aResult);
       
   103 	void    ModifyRecordL   (CCommsDbProtectConnectPrefTableView* aTable);
       
   104 	void    PopulateInsertedRecordL(CCommsDbProtectConnectPrefTableView* aTable);
       
   105 
       
   106 	void    CheckRecordAccessL(CCommsDbProtectConnectPrefTableView* aTable, TInt aExpectedAccess);
       
   107 
       
   108 	void    ProtectRecordL  (CCommsDbProtectTableView* aTable,TInt aResult);
       
   109 	void    UnprotectRecordL(CCommsDbProtectTableView* aTable,TInt aResult);
       
   110 
       
   111     void    ProtectRecordL(CCommsDbProtectConnectPrefTableView* aTable, TInt aResult);
       
   112 	void    UnprotectRecordL(CCommsDbProtectConnectPrefTableView* aTable,TInt aResult);
       
   113 
       
   114 
       
   115 private:
       
   116 	//Set when remote database object are in use
       
   117 	TBool	iRemoteObjects;
       
   118 
       
   119 };
       
   120 
       
   121 #define CDBLEAVE( exp1, exp2 )			{	\
       
   122 											TInt _r;	\
       
   123 											_r = (exp1);  \
       
   124 											if ( _r!=exp2 ) User::Leave(_r);\
       
   125 										}
       
   126 
       
   127 _LIT(KInvalidColumnName, "InvalidColumn");
       
   128 
       
   129 #endif /* __COMMDBTESTSTEP_H__ */