appfw/apparchitecture/tef/testableapalssession.h
changeset 0 2e3d3ce01487
equal deleted inserted replaced
-1:000000000000 0:2e3d3ce01487
       
     1 // Copyright (c) 2006-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  @internalComponent - Internal Symbian test code 
       
    19 */
       
    20 
       
    21 #ifndef __TESTABLEAPALSSESSION_H__
       
    22 #define __TESTABLEAPALSSESSION_H__
       
    23 
       
    24 #include <apgcli.h>
       
    25 	
       
    26 class RTestableApaLsSession : public RApaLsSession
       
    27 	{
       
    28 public: //from RApaLsSession
       
    29 	TInt Connect();	
       
    30 public:
       
    31 	TInt ConnectWithoutWaitingForListPopulation();
       
    32 	TInt HeapMark() const;
       
    33 	TInt HeapMarkEnd() const;
       
    34 	TInt HeapMarkEnd(TInt aCount) const;
       
    35 	TInt HeapFailNext(TInt aCount) const;
       
    36 	TInt ClearAppInfoArray() const;
       
    37 	TInt FlushRecognitionCache() const;
       
    38 	TInt SetLoadRecognizersOnDemand(TBool aLoadRecognizersOnDemand) const;
       
    39 	TInt PerformOutstandingRecognizerUnloading() const;
       
    40 	void DeleteExtension();
       
    41 	TInt WaitForTypeStoreUpdate();
       
    42 	TInt AddFailingNonNativeApplicationsUpdate();
       
    43 	TInt AddPanicingNonNativeApplicationsUpdate();
       
    44 	TInt AddRollbackPanicingNonNativeApplicationsUpdate();
       
    45 	};
       
    46 	
       
    47 /**
       
    48 Use as @c aCleanup argument to @c HEAP_TEST_LS_SESSION if the test doesn't need
       
    49 any cleanup in order to be heap checkable.
       
    50 */
       
    51 #define NO_CLEANUP
       
    52 /**
       
    53 Use as @c aClientCount or @c aServerCount arguments to @c HEAP_TEST_LS_SESSION
       
    54 if you don't want the heap to be checked
       
    55 */
       
    56 #define DONT_CHECK -1
       
    57 
       
    58 /**
       
    59 Heap tests a RTestableApaLsSession by calling __UHEAP_MARK before some test code
       
    60 and __UHEAP_MARKEND after.
       
    61 
       
    62 @param aApaLsSession A reference to a RTestableApaLsSession
       
    63 @param aClientCount The value sent to __UHEAP_MARKENDC() on the client side. 
       
    64        Usually 0. DONT_CHECK if no check shall be made.
       
    65 @param aServerCount The value sent to __UHEAP_MARKENDC() on the server side. 
       
    66        Usually 0. DONT_CHECK if no check shall be made.
       
    67 @param aTest The test code
       
    68 @param aCleanup Any cleanup that is needed before the heap check is made. 
       
    69        NO_CLEANUP if no cleanup is needed.
       
    70 */
       
    71 #define HEAP_TEST_LS_SESSION(aApaLsSession, aClientCount, aServerCount, aTest, aCleanup) \
       
    72 	if(aClientCount != DONT_CHECK)														\
       
    73 		{																				\
       
    74 		__UHEAP_MARK;																	\
       
    75 		}																				\
       
    76 	if(aServerCount != DONT_CHECK) 														\
       
    77 		{																				\
       
    78 		const TInt _error = aApaLsSession.HeapMark();									\
       
    79 		if(_error != KErrNone)															\
       
    80 			{																			\
       
    81 			INFO_PRINTF2(_L("__UHEAP_MARK failed on the server (error=%d)"), _error);	\
       
    82 			}																			\
       
    83 		TESTL(KErrNone == _error);														\
       
    84 		}																				\
       
    85 	{																					\
       
    86 	TRAPD(_error, aTest); /* execute the test code */									\
       
    87 	if(_error != KErrNone)																\
       
    88 		{																				\
       
    89 		INFO_PRINTF2(_L("Test code issued a leave (%d)"), _error);						\
       
    90 		}																				\
       
    91 	TESTL(KErrNone == _error);															\
       
    92 	}																					\
       
    93 	aCleanup; /* execute the cleanup */													\
       
    94 	aApaLsSession.DeleteExtension();													\
       
    95 	aApaLsSession.PerformOutstandingRecognizerUnloading();										\
       
    96 	if(aServerCount != DONT_CHECK)														\
       
    97 		{																				\
       
    98 		const TInt _error = aApaLsSession.HeapMarkEnd(aServerCount);					\
       
    99 		if(_error != KErrNone)															\
       
   100 			{																			\
       
   101 			INFO_PRINTF2(_L("__UHEAP_MARKEND failed on the server (error=%d)"), _error);\
       
   102 			}																			\
       
   103 		TESTL(KErrNone == _error);														\
       
   104 		}																				\
       
   105 	if(aClientCount != DONT_CHECK)														\
       
   106 		{																				\
       
   107 		__UHEAP_MARKENDC(aClientCount);													\
       
   108 		}																				\
       
   109 	
       
   110 		
       
   111 
       
   112 #endif //__TESTABLEAPALSSESSION_H__