phonebookengines_old/contactsmodel/tsrc/T_Sec_AsyncOpen.h
changeset 40 b46a585f6909
equal deleted inserted replaced
37:fd64c38c277d 40:b46a585f6909
       
     1 // Copyright (c) 2004-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 //
       
    15 
       
    16 #include <cntdb.h>
       
    17 #include <e32svr.h>
       
    18 #include <cntviewbase.h>
       
    19 #include "T_UTILS.H"
       
    20 
       
    21 #ifndef __TSECASYNCOPEN__
       
    22 #define __TSECASYNCOPEN__
       
    23 
       
    24 // Main test conducting class for Secure Async Open Testing
       
    25 class CTestConductor : public CActive
       
    26 	{
       
    27 public:
       
    28 	static CTestConductor* NewL();
       
    29 	~CTestConductor();
       
    30 	
       
    31 private:
       
    32 	enum TTest
       
    33 		{
       
    34 		EAsyncOpenNamed  = 0,
       
    35 		EAsyncOpenedNamed,
       
    36 		EAsyncOpenDefault,
       
    37 		EAsyncOpenedDefault,
       
    38 		EAsyncOpenNonExistent,
       
    39 		EAsyncOpenedNonExistent,
       
    40 		EAsyncCancelOpenDefault,
       
    41 		EAsyncCanceledOpenedDefault,
       
    42 		EAsyncOpenDamaged,
       
    43 		EAsyncOpenedDamaged,
       
    44 #ifndef _TEST_ON_SQLITE_		
       
    45 		EAsyncOpenPreviousVersion,
       
    46 		EAsyncOpenedPreviousVersion,
       
    47 		EOpenAsyncAndAsync,
       
    48 		EOpenedAsyncAndAsync,
       
    49 		EWaitState,
       
    50 		EWaitedState,
       
    51 		EOpenAsyncAndSync,
       
    52 		EOpenedAsyncAndSync,
       
    53 #endif // _TEST_ON_SQLITE_		
       
    54 		ENumTests
       
    55 		};	
       
    56 		
       
    57 	CTestConductor();
       
    58 	void ConstructL();
       
    59 	TInt RunError(TInt aError);
       
    60 	void NextTest();
       
    61 	void CopyCdbFileL(const TDesC& aFileName, const TDesC& aToFileName);
       
    62 	void RunL();      // From CActive.
       
    63 	void DoCancel();  // From CActive.
       
    64 
       
    65 private:
       
    66     CContactOpenOperation* iContactOpenOperation;
       
    67 	TInt iCurrentTestNumber;
       
    68 	CContactDatabase* iDb;
       
    69 	TInt iWaitCounter;
       
    70 	TInt iTestError;
       
    71 	};
       
    72 
       
    73 
       
    74 
       
    75 // Active object to Test Async open from two threads at once
       
    76 class CTester : public CActive
       
    77 	{
       
    78 public:
       
    79 	static CTester* NewL();
       
    80 	~CTester();
       
    81 	
       
    82 private:
       
    83 	enum TTest
       
    84 		{
       
    85 		EAsyncOpenNamed,
       
    86 		EAsyncOpenedNamed,
       
    87 		ENumTests
       
    88 		};	
       
    89 
       
    90 
       
    91 	CTester();
       
    92 	void ConstructL();
       
    93 	void NextTest();
       
    94 	void RunL();      // From CActive.
       
    95 	void DoCancel();  // From CActive.
       
    96 
       
    97 private:
       
    98     CContactOpenOperation* iContactOpenOperation;
       
    99     TInt iCurrentTestNumber;
       
   100 	CContactDatabase* iDb;
       
   101 	};
       
   102 
       
   103 
       
   104 // This class (CDbOpenLauncher) creates a thread to do async and sync opens 
       
   105 class CDbOpenLauncher : public CBase	
       
   106 	{
       
   107 public:
       
   108 	static void Create(const TDesC& aName, const TDesC& aViewName);
       
   109 
       
   110 private:
       
   111 	static void DoMainL(const TDesC& aName);
       
   112 	static TInt LaunchThread(TAny* aAny);	
       
   113 		
       
   114 	class CViewer : public CBase
       
   115 		{
       
   116 	public: 
       
   117 		static CViewer* NewL(const TDesC& aViewName);
       
   118 		~CViewer();
       
   119 	private: 
       
   120 		void ConstructL(const TDesC& aViewName);
       
   121 		
       
   122 	private:
       
   123 		CContactDatabase* iDatabase;
       
   124 		CTester* tester;
       
   125 		
       
   126 	};
       
   127 			
       
   128 };
       
   129 
       
   130 #endif // __TSECASYNCOPEN__
       
   131