commsfwutils/commsbufs/TS_mbufmgr/Test04CopyInOut.cpp
changeset 72 ae47d0499bee
parent 68 5da8188e392b
child 77 c9776eadbffd
equal deleted inserted replaced
68:5da8188e392b 72:ae47d0499bee
     1 // Copyright (c) 2002-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 // Contains MBufMgr Test Step 04 for CopyIn() & CopyOut() methods
       
    15 // 
       
    16 //
       
    17 
       
    18 // EPOC includes
       
    19 #include <e32base.h>
       
    20 
       
    21 // Test system includes
       
    22 #ifdef SYMBIAN_OLD_EXPORT_LOCATION
       
    23 #include "networking/log.h"
       
    24 #include "networking/teststep.h"
       
    25 #else
       
    26 #include <networking/log.h>
       
    27 #include <networking/teststep.h>
       
    28 #endif
       
    29 #include "TestStepCTMbufmgr.h"
       
    30 #include "TestSuiteCTMbufmgr.h"
       
    31 
       
    32 #include "Test04CopyInOut.h"
       
    33 #include <comms-infras/commsbufpond.h>
       
    34 // constructor
       
    35 CTest04CopyInOut::CTest04CopyInOut()
       
    36 	{
       
    37 	iTestStepName = _L("MBufMgrTest04");// Store the name of this test case
       
    38 	}
       
    39 
       
    40 // destructor
       
    41 CTest04CopyInOut::~CTest04CopyInOut()
       
    42 	{
       
    43 	}
       
    44 
       
    45 //
       
    46 enum TVerdict CTest04CopyInOut::doTestStepL(void)
       
    47 	{
       
    48 	__UHEAP_MARK;
       
    49 	
       
    50 #ifdef __CFLOG_ACTIVE
       
    51 	__CFLOG_CREATEL;
       
    52 	__CFLOG_OPEN;
       
    53 #endif
       
    54 	
       
    55 	//-------------- substep 1 --------------------
       
    56 	Log(_L("  01 Create CMBufManager and install active scheduler:"));
       
    57     CleanupStack::PushL( iActSch = new(ELeave) CActiveScheduler );
       
    58 	CActiveScheduler::Install(iActSch);
       
    59 	CreateInstanceMBufMgrL(KMBufDefaultHeapSize);
       
    60 	CleanupClosePushL(iBufPond);
       
    61 
       
    62 	//-------------- substep 2 --------------------
       
    63 	Log(_L("  02 Allocate two 5000-bytes long descriptors (Des1 & Des2):"));
       
    64 	TBuf8<5000> *aDes1, *aDes2;
       
    65     CleanupStack::PushL( aDes1 = new(ELeave) TBuf8<5000> );
       
    66     CleanupStack::PushL( aDes2 = new(ELeave) TBuf8<5000> );
       
    67 	aDes1->SetLength(5000);
       
    68 	aDes2->SetLength(5000);
       
    69 
       
    70 	//-------------- substep 3 --------------------
       
    71 	Log(_L("  03 Fill in the Des1 with a pattern:"));
       
    72 	StripeDes(*aDes1, 0, 5000, '@', 'Z');
       
    73 
       
    74 	//-------------- substep 4 --------------------
       
    75 	Log(_L("  04 Allocate 5000-bytes long RMBufChain:"));
       
    76 	RMBufChain aChain;
       
    77 	TRAPD(ret,aChain.AllocL(5000));
       
    78 	if (ret != KErrNone)
       
    79 		{
       
    80 		Log(_L("Error: Couldn't allocate RMBuf:"));
       
    81 
       
    82 #ifdef __CFLOG_ACTIVE
       
    83 		__CFLOG_CLOSE;
       
    84 		__CFLOG_DELETE;
       
    85 #endif
       
    86 		User::Leave(EFail);
       
    87 		}
       
    88 
       
    89 	//-------------- substep 5 --------------------
       
    90 	Log(_L("  05 Copy in Des1 into Chain:"));
       
    91     aChain.CopyIn(*aDes1);
       
    92 
       
    93 	//-------------- substep 6 --------------------
       
    94 	Log(_L("  06 Fill in Des2 with zeros:"));
       
    95 	StripeDes(*aDes2, 0, 5000, 0, 0);
       
    96 
       
    97 	//-------------- substep 7 --------------------
       
    98 	Log(_L("  07 Copy out Chain into Des2:"));
       
    99     aChain.CopyOut(*aDes2);
       
   100 
       
   101 	//-------------- substep 8 --------------------
       
   102 	Log(_L("  08 Compare the contents of Des1 & Des2:"));
       
   103 	if(aDes1->Compare(*aDes2))
       
   104 		{
       
   105 		Log(_L("Error: The content is not the same"));
       
   106 		aChain.Free();
       
   107 
       
   108 #ifdef __CFLOG_ACTIVE
       
   109 		__CFLOG_CLOSE;
       
   110 		__CFLOG_DELETE;
       
   111 #endif
       
   112 		User::Leave(EFail);
       
   113 		}
       
   114 
       
   115 	//-------------- substep 9 --------------------
       
   116 	Log(_L("  09 Free chain. Clean up stack:"));
       
   117 	aChain.Free();
       
   118     CleanupStack::PopAndDestroy(aDes2);
       
   119     CleanupStack::PopAndDestroy(aDes1);
       
   120     CleanupStack::PopAndDestroy();
       
   121 	CActiveScheduler::Install(NULL);
       
   122 	CleanupStack::PopAndDestroy(iActSch);
       
   123 
       
   124 #ifdef __CFLOG_ACTIVE
       
   125 	__CFLOG_CLOSE;
       
   126 	__CFLOG_DELETE;
       
   127 #endif
       
   128  	__UHEAP_MARKEND;
       
   129 	return EPass;
       
   130 	}