phonebookengines/contactsmodel/tsrc/asynaccess/inc/CntModelTesterAsynch.h
changeset 0 e686773b3f54
child 24 0ba2181d7c28
equal deleted inserted replaced
-1:000000000000 0:e686773b3f54
       
     1 /*
       
     2 * Copyright (c) 2009 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 "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:
       
    15 *
       
    16 */
       
    17 
       
    18 #ifndef __CCntModelTesterAsynch_H__
       
    19 #define __CCntModelTesterAsynch_H__
       
    20 
       
    21 #include <e32base.h>
       
    22 #include <cntdef.h>
       
    23 #include "t_utils2.h"
       
    24 
       
    25 class CContactDatabase;
       
    26 class CContactItemField;
       
    27 class CCntModelTesterSetToneToContacts;
       
    28 class CCntModelTesterAsynch;
       
    29 	
       
    30 // CLASS DECLARATION
       
    31 
       
    32 //
       
    33 // CTestConductor.
       
    34 //
       
    35 
       
    36 class CTestConductor : public CBase
       
    37 	{
       
    38 public:
       
    39 	static CTestConductor* NewL();
       
    40 	~CTestConductor();
       
    41 	void SetTestError(TInt aTestError);
       
    42 
       
    43 private:
       
    44 	CTestConductor();
       
    45 	void ConstructL();
       
    46 	void RunTestsL();
       
    47 private:
       
    48 	RFs iFs;
       
    49 	CLog* iLog;
       
    50 	CContactDatabase* iDb;
       
    51 	CRandomContactGenerator* iRandomGenerator;
       
    52 	CCntModelTesterAsynch* iAsync;
       
    53 	TInt iTestError;
       
    54 	};
       
    55 
       
    56 class CCntModelTesterAsynch : public CActive
       
    57     {
       
    58     friend class CTester;
       
    59     
       
    60     public:  // Interface		
       
    61         
       
    62         static CCntModelTesterAsynch* NewL(CLog& iLog);
       
    63 
       
    64 		/**
       
    65          * Destructor.
       
    66          */
       
    67         ~CCntModelTesterAsynch();
       
    68         
       
    69         void IssueRequest();
       
    70         void SetSpeedDialL();
       
    71         void RemoveAndCreateFieldL();
       
    72         
       
    73     private: 
       
    74         CCntModelTesterAsynch(CLog& iLog);
       
    75         void ConstructL();
       
    76         void CreateContactsL();
       
    77         TContactItemId CreateContactL( CContactDatabase* aDb,
       
    78                                    const TDesC& aName, 
       
    79                                    const TDesC& aNumber);
       
    80         CContactItemField* CreateFieldLC(const TUid aMappingUId,
       
    81                                          TFieldType aFieldType, 
       
    82                                          const TDesC &aText);
       
    83     
       
    84     private:  // from CActive
       
    85 	    void DoCancel();
       
    86         void RunL();
       
    87 	    void Error(TInt aError);
       
    88 
       
    89     private:  // Data
       
    90 		/// Ref. compression strategy
       
    91         CContactDatabase* iDb;
       
    92         CLog& iLog;
       
    93         CContactIdArray* iArray;
       
    94         CCntModelTesterSetToneToContacts* iOperation;
       
    95         CContactItem* iGroup;
       
    96     };
       
    97     
       
    98 // Active object to Test Async open from two threads at once
       
    99 class CTester : public CActive
       
   100 	{
       
   101 public:
       
   102 	static CTester* NewL();
       
   103 	~CTester();
       
   104 	
       
   105 private:
       
   106 	enum TTest
       
   107 		{
       
   108 		EAsyncOpenNamed,
       
   109 		EAsyncOpenedNamed=EAsyncOpenNamed+10,
       
   110 		ESyncOpenNamed,
       
   111 		ESyncOpenedNamed=ESyncOpenNamed+10,
       
   112 		ENumTests
       
   113 		};	
       
   114 
       
   115 
       
   116 	CTester();
       
   117 	void ConstructL();
       
   118 	void NextTest();
       
   119 	void RunL();      // From CActive.
       
   120 	void DoCancel();  // From CActive.
       
   121 	void Error(TInt aError);
       
   122 private:
       
   123     CContactOpenOperation* iContactOpenOperation;
       
   124     TInt iCurrentTestNumber;
       
   125 	CContactDatabase* iDb;
       
   126 	};
       
   127 
       
   128 
       
   129 // This class (CDbOpenLauncher) creates a thread to do async and sync opens 
       
   130 class CDbOpenLauncher : public CBase	
       
   131 	{
       
   132 public:
       
   133 	static void Create(const TDesC& aName, const TDesC& aViewName);
       
   134 
       
   135 private:
       
   136 	static void DoMainL(const TDesC& aName);
       
   137 	static TInt LaunchThread(TAny* aAny);	
       
   138 		
       
   139 	class CViewer : public CBase
       
   140 		{
       
   141 	public: 
       
   142 		static CViewer* NewL(const TDesC& aViewName);
       
   143 		~CViewer();
       
   144 	private: 
       
   145 		void ConstructL(const TDesC& aViewName);
       
   146 		
       
   147 	private:
       
   148 		CContactDatabase* iDatabase;
       
   149 		CTester* tester;
       
   150 		
       
   151 	};
       
   152 			
       
   153 };   
       
   154 
       
   155 #endif // __CCntModelTesterAsynch_H__
       
   156 
       
   157 // End of File