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