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