72
|
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 8 for TrimEnd() method
|
|
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 |
|
|
31 |
#include "Test08TrimEnd.h"
|
|
32 |
#include <comms-infras/commsbufpond.h>
|
|
33 |
// constructor
|
|
34 |
CTest08TrimEnd::CTest08TrimEnd()
|
|
35 |
{
|
|
36 |
SetTestStepName(_L("MBufMgrTest08"));// Store the name of this test case
|
|
37 |
}
|
|
38 |
|
|
39 |
// destructor
|
|
40 |
CTest08TrimEnd::~CTest08TrimEnd()
|
|
41 |
{
|
|
42 |
}
|
|
43 |
|
|
44 |
//
|
|
45 |
enum TVerdict CTest08TrimEnd::doTestStepL(void)
|
|
46 |
{
|
|
47 |
SetTestStepResult(EFail);
|
|
48 |
//-------------- substep 0 --------------------
|
|
49 |
INFO_PRINTF1(_L(" 00 Read parameters from the script:"));
|
|
50 |
TInt aOffset;// Will contain the position in chain where split action will be done
|
|
51 |
TInt aLength;// Will contain the length of desc & chains in the test
|
|
52 |
TInt bRet = GetIntFromConfig(_L("MBufMgrTest08"), _L("Length"), aLength);
|
|
53 |
if (!bRet)
|
|
54 |
{
|
|
55 |
SetTestStepResult(EFail);
|
|
56 |
|
|
57 |
return TestStepResult();
|
|
58 |
}
|
|
59 |
bRet = GetIntFromConfig(_L("MBufMgrTest08"), _L("Offset"), aOffset);
|
|
60 |
if (!bRet)
|
|
61 |
{
|
|
62 |
SetTestStepResult(EFail);
|
|
63 |
|
|
64 |
return TestStepResult();
|
|
65 |
}
|
|
66 |
INFO_PRINTF2(_L(" ------- Chain LENGTH = %d --"), aLength);
|
|
67 |
INFO_PRINTF2(_L(" ------- OFFSET where to TrimStart = %d --"), aOffset);
|
|
68 |
if ( (aLength > 1000) ||(aLength <0) ||
|
|
69 |
(aOffset > aLength) || (aOffset <0) )
|
|
70 |
{
|
|
71 |
INFO_PRINTF1(_L("ERROR: Wrong input parameter(s)"));
|
|
72 |
SetTestStepResult(EFail);
|
|
73 |
|
|
74 |
return TestStepResult();
|
|
75 |
}
|
|
76 |
|
|
77 |
//-------------- substep 1 --------------------
|
|
78 |
INFO_PRINTF1(_L(" 01 Creating CMBufManager and installing active scheduler:"));
|
|
79 |
CleanupStack::PushL( iActSch = new(ELeave) CActiveScheduler );
|
|
80 |
CActiveScheduler::Install(iActSch);
|
|
81 |
CreateInstanceMBufMgrL(KMBufDefaultHeapSize);
|
|
82 |
CleanupClosePushL(iBufPond);
|
|
83 |
|
|
84 |
//-------------- substep 2 --------------------
|
|
85 |
INFO_PRINTF1(_L(" 02 Allocate two desc. of Length:LENGTH(Des1) & OFFSET(Des2):"));
|
|
86 |
TBuf8<1000> *aDes1, *aDes2;
|
|
87 |
CleanupStack::PushL( aDes1 = new(ELeave) TBuf8<1000> );
|
|
88 |
CleanupStack::PushL( aDes2 = new(ELeave) TBuf8<1000> );
|
|
89 |
aDes1->SetLength(aLength);
|
|
90 |
aDes2->SetLength(aOffset);
|
|
91 |
|
|
92 |
//-------------- substep 3 --------------------
|
|
93 |
INFO_PRINTF1(_L(" 03 Fill in Des1 with a pattern:"));
|
|
94 |
StripeDes(*aDes1, 0, aLength, '@', 'Z');
|
|
95 |
|
|
96 |
//-------------- substep 4 --------------------
|
|
97 |
INFO_PRINTF1(_L(" 04 Fill in Des2 with zeros:"));
|
|
98 |
StripeDes(*aDes2, 0, aOffset, 0, 0);
|
|
99 |
|
|
100 |
//-------------- substep 5 --------------------
|
|
101 |
INFO_PRINTF1(_L(" 05 Allocate Chain:"));
|
|
102 |
RMBufChain aChain;
|
|
103 |
TRAPD(ret,aChain.AllocL(aLength));
|
|
104 |
if (ret != KErrNone)
|
|
105 |
{
|
|
106 |
INFO_PRINTF1(_L("Error: Couldn't allocate RMBuf:"));
|
|
107 |
User::Leave(EFail);
|
|
108 |
}
|
|
109 |
|
|
110 |
//-------------- substep 6 --------------------
|
|
111 |
INFO_PRINTF1(_L(" 06 Copy in Des1 into Chain1:"));
|
|
112 |
aChain.CopyIn(*aDes1);
|
|
113 |
|
|
114 |
//-------------- substep 7 --------------------
|
|
115 |
INFO_PRINTF1(_L(" 07 TrimEnd Chain1 at OFFSET position (i.e. remove the bytes after OFFSET position:"));
|
|
116 |
aChain.TrimEnd(aOffset);
|
|
117 |
|
|
118 |
//-------------- substep 8 --------------------
|
|
119 |
INFO_PRINTF1(_L(" 08 Check the length of the chain. It should be OFFSET:"));
|
|
120 |
TInt temp;
|
|
121 |
if ( (temp = aChain.Length()) != aOffset)
|
|
122 |
{
|
|
123 |
INFO_PRINTF3(_L("Error: Chain length is %d instead of %d"), temp, aOffset);
|
|
124 |
aChain.Free();
|
|
125 |
User::Leave(EFail);
|
|
126 |
}
|
|
127 |
|
|
128 |
//-------------- substep 9 --------------------
|
|
129 |
INFO_PRINTF1(_L(" 09 Set the length of Des1 to value OFFSET"));
|
|
130 |
aDes1->SetLength(aOffset);
|
|
131 |
|
|
132 |
//-------------- substep 10 --------------------
|
|
133 |
INFO_PRINTF1(_L(" 10 Copy out Chain into Des2:"));
|
|
134 |
aChain.CopyOut(*aDes2);
|
|
135 |
|
|
136 |
//-------------- substep 11 --------------------
|
|
137 |
INFO_PRINTF1(_L(" 11 Compare the content of Des1 & Des2:"));
|
|
138 |
if(aDes1->Compare(*aDes2))
|
|
139 |
{
|
|
140 |
aChain.Free();
|
|
141 |
INFO_PRINTF1(_L("Error: The content is not the same"));
|
|
142 |
User::Leave(EFail);
|
|
143 |
}
|
|
144 |
|
|
145 |
//-------------- substep 12 --------------------
|
|
146 |
INFO_PRINTF1(_L(" 12 Free the chains. Clean up stack:"));
|
|
147 |
aChain.Free();
|
|
148 |
CleanupStack::PopAndDestroy(aDes2);
|
|
149 |
CleanupStack::PopAndDestroy(aDes1);
|
|
150 |
CleanupStack::PopAndDestroy();
|
|
151 |
CActiveScheduler::Install(NULL);
|
|
152 |
CleanupStack::PopAndDestroy(iActSch);
|
|
153 |
SetTestStepResult(EPass);
|
|
154 |
|
|
155 |
return TestStepResult();
|
|
156 |
}
|