commsfwutils/commsbufs/mbufgobblerlayer/inc/mbufgobblertestflags.h
branchRCL_3
changeset 84 486e9e9c45a7
parent 76 576874e13a2c
child 85 7c25be0307fe
equal deleted inserted replaced
76:576874e13a2c 84:486e9e9c45a7
     1 // Copyright (c) 2010 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 // Test flags. Lightweight functions to provide basic coverage test
       
    15 //
       
    16 //
       
    17 //  This is a 3-plane comms layer implementation example, which has been customised to be a test layer which gobbles and releases ESOCK MBUFs.
       
    18 //  The MBuf gobbling functionality can be disabled by undefining the macro SYMBIAN_COMMSFW_MBUF_GOBBLER which is specified in mbufgobblerproviders.mmp.
       
    19 //  When SYMBIAN_COMMSFW_MBUF_GOBBLER is undefined, the source code specified by mbufgobblerproviders.mmp becomes a pass through layer i.e. it passes the data
       
    20 //  through to the layer above or below without altering it. This makes it useful as a starting point for implementing your own layers / providers;
       
    21 //  useful documentation on how to customise your own passthrough layer can be found in ..\docs\MbufGobblerLayer.doc
       
    22 //
       
    23 
       
    24 /**
       
    25  @file
       
    26  @internalComponent
       
    27 */
       
    28 
       
    29 #ifndef MBUFGOBBLERTESTFLAGS_H_
       
    30 #define MBUFGOBBLERTESTFLAGS_H_
       
    31 
       
    32 
       
    33 #include <e32property.h>
       
    34 
       
    35 #ifdef _DEBUG
       
    36 #define MBUFGOBBLER_TEST_POINT(flag,result) if(iTestFlags) {MbufGobblerTestFlags::SetResult(MbufGobblerTestFlags::flag,result);}
       
    37 #define MBUFGOBBLER_TEST_DATA TBool iTestFlags;
       
    38 #define MBUFGOBBLER_TEST_DATA_INIT iTestFlags = MbufGobblerTestFlags::TestFlagsActive();
       
    39 
       
    40 
       
    41 namespace MbufGobblerTestFlags
       
    42 {
       
    43 const TUid KPubSubUid = {0x00285DAC};
       
    44 
       
    45 enum
       
    46 	{
       
    47 	// set by test library, read by binder
       
    48 	KFlagsActive = 100,
       
    49 	
       
    50 	// set by binder, read by test library
       
    51 	KTierUp = 101,
       
    52 	
       
    53 	KMCPrUp = 111,
       
    54 	
       
    55 	KCPrUp = 121,
       
    56 	
       
    57 	KSCPrUp = 131,
       
    58 	
       
    59 	KBind = 141,
       
    60 	KBinderSend = 142,
       
    61 	KBinderReceive = 143,
       
    62 	};
       
    63 
       
    64 
       
    65 // used by client test library
       
    66 static TInt ActivateTestFlags()
       
    67 	{
       
    68 	return RProperty::Define(KPubSubUid, KFlagsActive, RProperty::EInt);
       
    69 	}
       
    70 
       
    71 // used by client test library
       
    72 static TInt GetResult(TInt aFlag)
       
    73 	{
       
    74 	TInt value=0;
       
    75 	TInt retcode=RProperty::Get(KPubSubUid, aFlag, value);
       
    76 	return (retcode==KErrNone) ? value : retcode;
       
    77 	}
       
    78 	
       
    79 // used by binder
       
    80 static TBool TestFlagsActive()
       
    81 	{
       
    82 	return GetResult(KFlagsActive) == KErrNone;
       
    83 	}
       
    84 
       
    85 // used by binder
       
    86 static void SetResult(TInt aFlag, TInt aValue)
       
    87 	{
       
    88 	// Yes it is very inefficient making these calls
       
    89 	//  on e.g. each packet send but we only do this when
       
    90 	//  the test is running i.e. if it was explicitly
       
    91 	//  switched on, so it won't affect "normal" operation.
       
    92 	RProperty::Define(KPubSubUid, aFlag, RProperty::EInt);
       
    93 	RProperty::Set(KPubSubUid, aFlag, aValue);
       
    94 	}
       
    95 } // namespace MbufGobblerTestFlags
       
    96 
       
    97 #else // _DEBUG
       
    98 #define MBUFGOBBLER_TEST_POINT(flag,result)
       
    99 // It's better to make the urel and udeb objects the same size,
       
   100 //  at the expense of 4 bytes:
       
   101 #define MBUFGOBBLER_TEST_DATA TBool iTestFlags_unused;
       
   102 #define MBUFGOBBLER_TEST_DATA_INIT
       
   103 #endif // _DEBUG
       
   104 
       
   105 #endif /* MBUFGOBBLERTESTFLAGS_H_ */