--- a/uiacceltk/hitchcock/CommonInc/alfmoduletest.h Mon Mar 15 12:43:37 2010 +0200
+++ b/uiacceltk/hitchcock/CommonInc/alfmoduletest.h Wed Mar 31 23:03:58 2010 +0300
@@ -1,427 +1,30 @@
-#include "e32base.h"
-#include "e32debug.h"
-
#ifndef ALFMODULETEST_H
#define ALFMODULETEST_H
-// Define this to build module testing enchanced version of ALF
-//#define USE_MODULE_TEST_HOOKS_FOR_ALF
-#if !defined(USE_MODULE_TEST_HOOKS_FOR_ALF) || !defined(AMT_CONTROL)
-
-#define AMT_DATA()
-#define AMT_FUNC(func)
-#define AMT_FUNC_EXC(func)
-#define AMT_FUNC_EXC_RET(ret, func)
-#define AMT_FUNC_EXC_IF(cond, func)
-#define AMT_FUNC_EXC_IF_RET(cond, ret, func)
-#define AMT_INC_COUNTER(member)
-#define AMT_DEC_COUNTER(member)
-#define AMT_SET_VALUE(member, val)
-#define AMT_GET_VALUE(x, member)
-#define AMT_INC_COUNTER_IF(cond, member)
-#define AMT_DEC_COUNTER_IF(cond, member)
-#define AMT_SET_VALUE_IF(cond, member, val)
-#define AMT_GET_VALUE_IF(cond, x, member)
+#include <e32base.h>
+#include <e32debug.h>
-#define AMT_MAP_APPEND(memberMap, key, type, defaultValue)
-#define AMT_MAP_SET_VALUE_IF(cond, memberMap, key, value, type)
-#define AMT_MAP_INC_VALUE_IF(cond, memberMap, key, type)
-#define AMT_MAP_DEC_VALUE_IF(cond, memberMap, key, type)
-#define AMT_MAP_SET_VALUE(memberMap, key, value, type)
-#define AMT_MAP_INC_VALUE(memberMap, key, type)
-#define AMT_MAP_DEC_VALUE(memberMap, key, type)
-#define AMT_MAP_RESET(memberMap)
-
-#define AMT_PRINT_STATE()
+// Informs if module test hooks have been set on.
+#include "alfmoduletestconf.h"
-#ifndef AMT_CONTROL
-#error "Error: you need to define AMT_CONTROL macro in your code to be able to use ALF module test system!"
-// The user have to define AMT_CONTROL, e.g. like this:
-// #define AMT_CONTROL() static_cast<CAlfModuleTestDataControl*>(Dll::Tls())
-// or
-// #define AMT_CONTROL() iMyModuleTestDataControl
-// etc.
-#endif
-
-#else
+// Provides module test hooks defines.
+#include "alfmoduletestdefines.h"
-// *** Use these macros to access global memory chunk
-
-
-// Note: If you read/write a large block of data members, it is advisable not use the AMT_FUNC_EXC() based macros below.
-// Use Lock() and Unlock() around the block explicitely, and use AMT_FUNC() macro.
-// That is to avoid unnecessary nested lock-unlock sequences (even if nested locks are working ok).
-
-// Note: Be careful not to lock the the mutex for a long time as it will halt other processes if they are using the lock during that time!
-
-// Generic macros
-#define AMT_DATA() AMT_CONTROL()->iModuleTestData
-#define AMT_FUNC(func) if (AMT_DATA()->iIsEnabled) {func;}
-#define AMT_FUNC_EXC(func) {AMT_CONTROL()->Lock(); if (AMT_DATA()->iIsEnabled) {func;} AMT_CONTROL()->Unlock();}
-#define AMT_FUNC_EXC_RET(ret, func) {AMT_CONTROL()->Lock(); if (AMT_DATA()->iIsEnabled) {ret = func;} AMT_CONTROL()->Unlock();}
-#define AMT_FUNC_EXC_IF(cond, func) {AMT_CONTROL()->Lock(); if (AMT_DATA()->iIsEnabled && (cond)) {func;} AMT_CONTROL()->Unlock();}
-#define AMT_FUNC_EXC_IF_RET(cond, ret, func) {AMT_CONTROL()->Lock(); if (AMT_DATA()->iIsEnabled && (cond)) {ret = func;} AMT_CONTROL()->Unlock();}
+#ifdef USE_MODULE_TEST_HOOKS_FOR_ALF
-// Single operation macros, that will do lock/unlock.
-#define AMT_INC_COUNTER(member) AMT_FUNC_EXC(AMT_DATA()->member++)
-#define AMT_DEC_COUNTER(member) AMT_FUNC_EXC(AMT_DATA()->member--)
-#define AMT_SET_VALUE(member, val) AMT_FUNC_EXC(AMT_DATA()->member=(val))
-#define AMT_GET_VALUE(x, member) AMT_FUNC_EXC((x) = AMT_DATA()->member)
-#define AMT_PRINT_STATE() AMT_FUNC_EXC(AMT_DATA()->PrintState())
+// *** Test map classes
+#include "alfmoduletesttype.h"
+#include "alfmoduletestitem.h"
+#include "alfmoduletestmap.h"
-// Conditional single operation macros, that will do lock/unlock.
-#define AMT_INC_COUNTER_IF(cond, member) AMT_FUNC_EXC_IF((cond), AMT_DATA()->member++)
-#define AMT_DEC_COUNTER_IF(cond, member) AMT_FUNC_EXC_IF((cond), AMT_DATA()->member--)
-#define AMT_SET_VALUE_IF(cond, member, val) AMT_FUNC_EXC_IF((cond), AMT_DATA()->member=(val))
-#define AMT_GET_VALUE_IF(cond, x, member) AMT_FUNC_EXC_IF((cond), (x) = AMT_DATA()->member)
-
-// Map operation macros, that will do lock/unlock
-#define AMT_MAP_APPEND(memberMap, key, type, defaultValue) AMT_FUNC_EXC(AMT_DATA()->memberMap.Append(key, type, defaultValue))
-#define AMT_MAP_SET_VALUE_IF(cond, memberMap, key, value, type) AMT_FUNC_EXC_IF((cond), AMT_DATA()->memberMap.SetValue(key, value, type))
-#define AMT_MAP_INC_VALUE_IF(cond, memberMap, key, type) AMT_FUNC_EXC_IF((cond && AMT_DATA()->memberMap.Find(key, type)), AMT_DATA()->memberMap.SetValue(key, AMT_DATA()->memberMap.Find(key, type)->Value() + 1, type))
-#define AMT_MAP_DEC_VALUE_IF(cond, memberMap, key, type) AMT_FUNC_EXC_IF((cond && AMT_DATA()->memberMap.Find(key, type)), AMT_DATA()->memberMap.SetValue(key, AMT_DATA()->memberMap.Find(key, type)->Value() - 1, type))
-#define AMT_MAP_SET_VALUE(memberMap, key, value, type) AMT_FUNC_EXC_IF(ETrue, AMT_DATA()->memberMap.SetValue(key, value, type))
-#define AMT_MAP_INC_VALUE(memberMap, key, type) AMT_MAP_INC_VALUE_IF(ETrue, memberMap, key, type)
-#define AMT_MAP_DEC_VALUE(memberMap, key, type) AMT_MAP_DEC_VALUE_IF(ETrue, memberMap, key, type)
-#define AMT_MAP_RESET(memberMap) AMT_FUNC_EXC(AMT_DATA()->memberMap.Reset())
// *** Global object names
_LIT(KAlfModuleTestChunkName, "ALF_MODULE_TEST_CHUNK");
_LIT(KAlfModuleTestMutexName, "ALF_MODULE_TEST_MUTEX");
-/**
- * TAlfModuleTestType specifies recognized test types.
- */
-enum TAlfModuleTestType
- {
- // Do not use this value when creating item.
- EAlfModuleTestTypeNone,
-
- // Render stage component specific tests
- EAlfModuleTestTypeRenderStageChangeSize,
- EAlfModuleTestTypeRenderStageChangePosition,
- EAlfModuleTestTypeRenderStageChangeFlag,
-
- // Streamer hierarchy model component specific tests
- EAlfModuleTestTypeHierarchyModelChangeSize,
- EAlfModuleTestTypeHierarchyModelChangePosition,
- EAlfModuleTestTypeHierarchyModelChangeFlag,
-
- // Server bridge component specific tests
- EAlfModuleTestTypeBridgeChangeSize,
- EAlfModuleTestTypeBridgeChangePosition,
- EAlfModuleTestTypeBridgeChangeFlag,
-
- // Do not use this value when creating item.
- // This is just meant for Find operations when all tests are accepted.
- EAlfModuleTestTypeAll
- };
-
-
-/**
- * CAlfModuleTestItem
- *
- * Provides key-value pair that is used in TAlfModuleTestMap.
- */
-template< class T >
-NONSHARABLE_CLASS( TAlfModuleTestItem )
- {
-
-public:
-
- /**
- * Constructor to initialize variables.
- *
- * @param aKey Key that identifies the item.
- * In test cases this could be for example handle.
- * @param aTestType Defines for what this test item is meant for.
- */
- TAlfModuleTestItem( TInt aKey, const TAlfModuleTestType& aTestType, const T& aDefaultValue ):
- iKey( aKey ),
- iTestType( aTestType ),
- iValue( aDefaultValue ),
- iValueSetCount( 0 )
- {
- }
-
-
- /**
- * @param aObject Value to be compared.
- * @return ETrue if given object equals the value of this item.
- * Else EFalse.
- */
- TBool Equals( const T& aValue, const TAlfModuleTestType& aTestType ) const
- {
- // Also, check that value has been set. If it has not been set,
- // then think objects as unequals.
- return ( iValueSetCount > 0
- && iValue == aValue
- && TestTypeMatch( aTestType ) );
- }
-
-
- /**
- * @return TInt Key that should be set during creation of this object.
- */
- TInt Key() const
- {
- return iKey;
- }
-
- /**
- * @see ValueSet to check if the value has already been set.
- *
- * @return const T& Value that corresonds the key.
- */
- const T& Value() const
- {
- return iValue;
- }
-
-
- /**
- * @param aValue Value to be set for the key
- */
- void SetValue( const T& aValue )
- {
- iValue = aValue;
- ++iValueSetCount;
- }
-
-
- /**
- * @return TInt Informs how many times the value has been set.
- */
- TInt ValueSetCount() const
- {
- return iValueSetCount;
- }
-
- /**
- * @return const TAlfModuleTestType& Defines what the test is for
- */
- const TAlfModuleTestType& TestType() const
- {
- return iTestType;
- }
-
-
- /**
- * @param aTestType
- * @return TBool ETrue if flag matches this item. Else EFalse.
- */
- TBool TestTypeMatch( const TAlfModuleTestType& aTestType ) const
- {
- return ( EAlfModuleTestTypeAll == aTestType
- || iTestType == aTestType );
- }
-
-
- /**
- * Resets the item info
- */
- void Reset()
- {
- iValueSetCount = 0;
- }
-
-
-private: // data
-
- TInt iKey;
- TAlfModuleTestType iTestType;
- T iValue;
- TInt iValueSetCount;
-
- };
-
-
-/**
- * Class CAlfModuleTestMap
- *
- * Provides map functionality for the key-value-pairs.
- * In test cases, this should most likely be used so, that
- * first test case classes create items with certain keys, for example with handle values.
- * Then, define hooks are used in the code to update values that corresond the correct handles.
- * In the end, test case classes can check that items have correct values set and if the test
- * is passed.
- */
-template< class T >
-NONSHARABLE_CLASS( TAlfModuleTestMap )
- {
-public:
-
- // Maximum item count in the map
- static const TInt KMaxArrayCount = 50;
-
-
- /**
- * Constructor to initialize variables.
- */
- TAlfModuleTestMap():
- iCount( 0 ),
- iSetValueCallCount( 0 )
- {
- }
-
-
- /**
- * @param aKey
- * @param aTestType Informs what type of test is accepted. Others are skipped.
- * @return T* Ownership is not transferred.
- * NULL if item is not found.
- */
- TAlfModuleTestItem< T >* Find( TInt aKey, const TAlfModuleTestType& aTestType )
- {
- // Try to find the item corresponding the given key.
- for ( TInt i = 0; i < iCount; ++i )
- {
- TAlfModuleTestItem< T >& testItem( iArray[ i ] );
- if ( testItem.Key() == aKey
- && testItem.TestTypeMatch( aTestType ) )
- {
- return &( testItem );
- }
- }
- // Item corresponding the given key was not found.
- return NULL;
- }
-
-
- /**
- * Function to append new item into the map.
- *
- * @param aKey
- * @param aTestType Describes for what case the appended test item is created for.
- * @return TInt System wide error code.
- */
- TInt Append( TInt aKey, const TAlfModuleTestType& aTestType, const T& aDefaultValue )
- {
- if ( iCount == KMaxArrayCount )
- {
- // Array already full.
- return KErrOverflow;
- }
- else if ( Find( aKey, aTestType ) )
- {
- // Key has already been inserted.
- return KErrAlreadyExists;
- }
-
- // Append new key value set into the array.
- iArray[ iCount ] = TAlfModuleTestItem< T >( aKey, aTestType, aDefaultValue );
- ++iCount;
- return KErrNone;
- }
-
-
- /**
- * Sets the value for the item.
- * Item itself should already exist in the array before
- * setting its value here. See, Append function.
- *
- * @param aKey
- * @param aValue
- * @return TInt System wide error code.
- */
- TInt SetValue( TInt aKey, const T& aValue, const TAlfModuleTestType& aTestType )
- {
- // Increase counter, because this function is called.
- ++iSetValueCallCount;
- TAlfModuleTestItem< T >* item( Find( aKey, aTestType ) );
- if ( !item )
- {
- // Item was not found from the array.
- return KErrNotFound;
- }
- // Item exists. So, set its values.
- item->SetValue( aValue );
- return KErrNone;
- }
-
-
- /**
- * Resets the map
- */
- void Reset()
- {
- // Just reset the counter.
- // We do not bother to reset map items, because when counter is reseted
- // already set items and their info is left out of the scope.
- iCount = 0;
- iSetValueCallCount = 0;
- }
-
-
- /**
- * Checks if all the values of items in the array match the given value.
- *
- * @param aValue Reference to the value that items are compared to.
- * @param aTestType Informs the test type whose items should be compared.
- */
- TInt CountEquals( const T& aValue, const TAlfModuleTestType& aTestType ) const
- {
- TInt count( 0 );
- for ( TInt i = 0; i < iCount; ++i )
- {
- if ( iArray[ i ].Equals( aValue, aTestType ) )
- {
- // Item matches
- ++count;
- }
- }
- return count;
- }
-
-
- /**
- * @return TInt Number of map items
- */
- TInt ItemCount() const
- {
- return iCount;
- }
-
-
- /**
- * @return const TAlfModuleTestItem< T >& Reference to the map item
- */
- const TAlfModuleTestItem< T >& Item( TInt aIndex ) const
- {
- return iArray[ aIndex ];
- }
-
-
- /**
- * @return TInt Number of times SetValue function has been called
- * since last reset. This information can be used
- * to check if hooks have been used correct times during
- * a test case. Notice, that this informs the number of
- * function calls, not the number of times a value has actually
- * set for some item.
- */
- TInt SetValueCallCount() const
- {
- return iSetValueCallCount;
- }
-
-
-private: // data
-
- TAlfModuleTestItem< T > iArray[ KMaxArrayCount ];
- // Informs number of array items
- TInt iCount;
- // Informs how many times SetItem has been called since last reset.
- // Notice, that this informs the number of function calls, not the number
- // of times a value has actually set for some item.
- TInt iSetValueCallCount;
-
- };
-
-
/*
* Class CAlfModuleTestData
*/
@@ -471,24 +74,55 @@
iLatestVisualExtentRect.Width(), iLatestVisualExtentRect.Height());
RDebug::Print(_L("iTotalVisualFlagChangedCount=%d"), iTotalVisualFlagChangedCount);
RDebug::Print(_L("iTotalVisualAttributeChangedCount=%d"), iTotalVisualAttributeChangedCount);
+ RDebug::Print(_L("iBoolMap =>"));
+ PrintBoolMapState( iBoolMap );
+ RDebug::Print(_L("iIntMap =>"));
+ PrintIntMapState( iIntMap );
RDebug::Print(_L("iSizeMap =>"));
PrintSizeMapState( iSizeMap );
RDebug::Print(_L("iPositionMap =>"));
- PrintPositionMapState( iPositionMap );
+ PrintPositionMapState( iPositionMap );
RDebug::Print(_L("*** ALF INTERNAL STATE ***"));
}
+
+ void PrintBoolMapState( TAlfModuleTestMap< TBool > aMap )
+ {
+ RDebug::Print(_L("*** ALF INTERNAL BOOL MAP STATE -->"));
+ RDebug::Print(_L("Map item count=%d"), aMap.ItemCount());
+ for ( TInt i = 0; i < aMap.ItemCount(); ++i )
+ {
+ const TAlfModuleTestItem< TBool >& item( aMap.Item( i ) );
+ RDebug::Print(_L("Map item %d, iTestType=%d, iKey=%d, iValue=%d, iValueSetCount=%d, iLinkTargetKey=%d"),
+ i, item.TestType(), item.Key(), item.Value(), item.ValueSetCount(), item.LinkTargetKey());
+ }
+ RDebug::Print(_L("<-- ALF INTERNAL BOOL MAP STATE ***"));
+ }
+
+
+ void PrintIntMapState( TAlfModuleTestMap< TInt > aMap )
+ {
+ RDebug::Print(_L("*** ALF INTERNAL INT MAP STATE -->"));
+ RDebug::Print(_L("Map item count=%d"), aMap.ItemCount());
+ for ( TInt i = 0; i < aMap.ItemCount(); ++i )
+ {
+ const TAlfModuleTestItem< TInt >& item( aMap.Item( i ) );
+ RDebug::Print(_L("Map item %d, iTestType=%d, iKey=%d, iValue=%d, iValueSetCount=%d, iLinkTargetKey=%d"),
+ i, item.TestType(), item.Key(), item.Value(), item.ValueSetCount(), item.LinkTargetKey());
+ }
+ RDebug::Print(_L("<-- ALF INTERNAL INT MAP STATE ***"));
+ }
+
void PrintSizeMapState( TAlfModuleTestMap< TSize > aMap )
{
RDebug::Print(_L("*** ALF INTERNAL SIZE MAP STATE -->"));
- RDebug::Print(_L("Map item count=%d, SetValue call count=%d"),
- aMap.ItemCount(), aMap.SetValueCallCount());
+ RDebug::Print(_L("Map item count=%d"), aMap.ItemCount());
for ( TInt i = 0; i < aMap.ItemCount(); ++i )
{
const TAlfModuleTestItem< TSize >& item( aMap.Item( i ) );
- RDebug::Print(_L("Map item %d, iKey=%d, iTestType=%d, iValueSetCount=%d"),
- i, item.Key(), item.TestType(), item.ValueSetCount());
+ RDebug::Print(_L("Map item %d, iTestType=%d, iKey=%d, iValueSetCount=%d, iLinkTargetKey=%d"),
+ i, item.TestType(), item.Key(), item.ValueSetCount(), item.LinkTargetKey());
RDebug::Print(_L("Map item index=%d, width=%d, height=%d"),
i, item.Value().iWidth, item.Value().iHeight);
}
@@ -499,13 +133,12 @@
void PrintPositionMapState( TAlfModuleTestMap< TPoint > aMap )
{
RDebug::Print(_L("*** ALF INTERNAL POSITION MAP STATE -->"));
- RDebug::Print(_L("Map item count=%d, SetValue call count=%d"),
- aMap.ItemCount(), aMap.SetValueCallCount());
+ RDebug::Print(_L("Map item count=%d"), aMap.ItemCount() );
for ( TInt i = 0; i < aMap.ItemCount(); ++i )
{
const TAlfModuleTestItem< TPoint >& item( aMap.Item( i ) );
- RDebug::Print(_L("Map item %d, iKey=%d, iTestType=%d, iValueSetCount=%d"),
- i, item.Key(), item.TestType(), item.ValueSetCount());
+ RDebug::Print(_L("Map item %d, iKey=%d, iTestType=%d, iValueSetCount=%d, iLinkTargetKey=%d"),
+ i, item.Key(), item.TestType(), item.ValueSetCount(), item.LinkTargetKey());
RDebug::Print(_L("Map item index=%d, x=%d, y=%d"),
i, item.Value().iX, item.Value().iY);
}
@@ -571,6 +204,8 @@
TInt iASE_Temp3;
TInt iASE_Temp4;
+ // Map that contains boolean items that can be specified for certain test cases.
+ TAlfModuleTestMap< TBool > iBoolMap;
// Map that contains integer items that can be specified for certain test cases.
TAlfModuleTestMap< TInt > iIntMap;
// Map that contains size items that can be specified for certain test cases.
@@ -634,7 +269,8 @@
CAlfModuleTestData* iModuleTestData; // Not owned
};
-#endif
+#endif // USE_MODULE_TEST_HOOKS_FOR_ALF
+
#endif // ALFMODULETEST_H