telephonyserverplugins/common_tsy/test/component/inc/cctsyactiveretriever.h
changeset 0 3553901f7fa8
child 24 6638e7f4bd8f
equal deleted inserted replaced
-1:000000000000 0:3553901f7fa8
       
     1 // Copyright (c) 2007-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 /**
       
    17  @file
       
    18 */
       
    19 
       
    20 #ifndef CCTSYACTIVERETRIEVER_H
       
    21 #define CCTSYACTIVERETRIEVER_H
       
    22 
       
    23 #include <etelutils.h>
       
    24 
       
    25 //-------------------------------------------------------------------------------
       
    26 // CActiveRetriever is an Active Object(AO) class created for 
       
    27 // testing Start function of CAsyncRetrieveVariableLengthBufferV2 derivied classes.
       
    28 //
       
    29 // CAsyncRetrieveVariableLengthBufferV2 is also an AO. To use it we
       
    30 // need to install our active scheduler(AS) into the thread. We start our AS within
       
    31 // the test step after start of request using an AO function, but we need to stop AS 
       
    32 // at some moment to finish test step execution.
       
    33 //
       
    34 // Base CActiveRetriever class creation purpose is TO STOP active 
       
    35 // scheduler, after completion of all AO requests.
       
    36 //--------------------------------------------------------------------------------
       
    37 class CActiveRetriever : public CActive
       
    38     {
       
    39     public:
       
    40        	enum TTestCase
       
    41        	{
       
    42        		ECaseNotSpecified,
       
    43        		
       
    44        		// cancel on completion cases
       
    45        		ECasePhase1Cancel,// we have to do 2 cancel test cases because 
       
    46        		                  // CAsyncRetrieveVariableLengthBufferV2 AO does 2 requests to CTSY
       
    47        		       		      // while processing our request
       
    48        		ECasePhase2Cancel,
       
    49        		
       
    50        		// general cancel test
       
    51        		ECaseGeneralCancelCase
       
    52        	};
       
    53 
       
    54     public:
       
    55     	static CActiveRetriever* NewLC(CAsyncRetrieveVariableLengthBufferV2& aAsynchRetrieveBuffer);
       
    56     	static CActiveRetriever* NewL(CAsyncRetrieveVariableLengthBufferV2& aAsynchRetrieveBuffer);
       
    57 
       
    58         CActiveRetriever(CAsyncRetrieveVariableLengthBufferV2& aAsynchRetrieveBuffer);
       
    59         virtual ~CActiveRetriever();
       
    60 
       
    61     public: // new functions
       
    62     	TBool IsRequestComplete();
       
    63     	void PerformCancelIfNeeded();
       
    64     	static TInt ResetRequestsNumber(); // resets pending requests number, STATIC 
       
    65 
       
    66 		TRequestStatus& Status();
       
    67     	// AO's request function with test case parameter
       
    68         void Activate(TTestCase aTestCase = ECaseNotSpecified);
       
    69 
       
    70     protected: // from CActive
       
    71         void RunL();
       
    72         void DoCancel();
       
    73 
       
    74     protected: // new functions	
       
    75 		CActive& AsynchRetrieveBuffer();
       
    76 		void SetTestCase(TTestCase aCase);
       
    77 		TTestCase TestCase();
       
    78 		void SetPhase1Passed(TBool aPassed = ETrue);
       
    79 		TBool Phase1Passed();
       
    80 
       
    81     	void DoComplete();
       
    82 
       
    83     protected: // data
       
    84 		CAsyncRetrieveVariableLengthBufferV2& iAsynchRetrieveBuffer; //testing API AO from etelmm derieved from this class
       
    85 		TTestCase iTestCase; // test case parameter
       
    86 		TBool iPhase1Passed; // phase1 passing flag for ECasePhase2Cancel test case
       
    87 		
       
    88 		static TInt iSimultaneousRetrieveRequestsNumber;// STATIC 
       
    89 
       
    90 	}; // class CActiveRetriever
       
    91 
       
    92 //--------------------------------------------------------------------------------------------
       
    93 // If we install standard Active scheduler into this thread, it will catch completion of all requests
       
    94 // in the thread, causing E32USER-CBase 46 panic during test step execution.
       
    95 // Base CFilteringActiveScheduler class creation purpose is to avoid E32USER-CBase 46 panic.
       
    96 // It is achieved by filtering of request completion in CFilteringActiveScheduler::WaitForAnyRequest().
       
    97 //
       
    98 // Secondary purpose is to Cancel() RetrieveInfo request on
       
    99 // receipt of completion of a request phase before invoking 
       
   100 // AsynchRetrieveBuffer's RunL() function
       
   101 //---------------------------------------------------------------------------------------------
       
   102 class CFilteringActiveScheduler : public CActiveScheduler
       
   103 	{
       
   104 	public:
       
   105 		virtual ~CFilteringActiveScheduler();
       
   106 		
       
   107 			// add retriever to use later for filtering of request completion in 
       
   108 			// CFilteringActiveScheduler::WaitForAnyRequest()
       
   109 		void AddRetrieverL(CActiveRetriever& aRetriever);
       
   110 		void StartScheduler();
       
   111 	protected:
       
   112 		void WaitForAnyRequest();
       
   113 		TBool IsOneOfMyRequestsComplete();
       
   114 	private:
       
   115 		RPointerArray<CActiveRetriever> iRetrievers;
       
   116 	}; // class CFilteringActiveScheduler
       
   117 
       
   118 #endif // CCTSYACTIVERETRIEVER_H