|
1 // Copyright (c) 2008-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 // Test19Align.cpp |
|
15 // Contains MBufMgr Test Step 19 for Prepend() methods |
|
16 // |
|
17 // |
|
18 |
|
19 // EPOC includes |
|
20 #include <e32base.h> |
|
21 |
|
22 // Test system includes |
|
23 #include <networking/log.h> |
|
24 #include <networking/teststep.h> |
|
25 #include "TestStepCTMbufmgr.h" |
|
26 #include "TestSuiteCTMbufmgr.h" |
|
27 |
|
28 #include "Test19Prepend.h" |
|
29 |
|
30 // constructor |
|
31 CTest19Prepend::CTest19Prepend() |
|
32 { |
|
33 iTestStepName = _L("MBufMgrTest19");// Store the name of this test case |
|
34 } |
|
35 |
|
36 // destructor |
|
37 CTest19Prepend::~CTest19Prepend() |
|
38 { |
|
39 } |
|
40 |
|
41 // |
|
42 enum TVerdict CTest19Prepend::doTestStepL(void) |
|
43 { |
|
44 __UHEAP_MARK; |
|
45 |
|
46 #ifdef __CFLOG_ACTIVE |
|
47 __CFLOG_CREATEL; |
|
48 __CFLOG_OPEN; |
|
49 #endif |
|
50 |
|
51 //-------------- substep 1 -------------------- |
|
52 Log(_L(" 01 Create CMBufManager and install active scheduler:")); |
|
53 CleanupStack::PushL( iActSch = new(ELeave) CActiveScheduler ); |
|
54 CActiveScheduler::Install(iActSch); |
|
55 |
|
56 MMBufSizeAllocator* MBufSizeAllocator; |
|
57 CleanupStack::PushL(CreateInstanceMBufMgrL(KMBufDefaultHeapSize / 2, MBufSizeAllocator)); |
|
58 |
|
59 // Create some initial pools |
|
60 MBufSizeAllocator->AddL(128,128,64,40); |
|
61 |
|
62 TBool firstFail = EFalse; |
|
63 TBool secondFail = EFalse; |
|
64 TInt ret; |
|
65 RMBufChain chain; |
|
66 |
|
67 //-------------- substep 2 -------------------- |
|
68 Log(_L(" 02 Prepend 20 bytes to an empty chain")); |
|
69 ret = chain.Prepend(20); |
|
70 if (ret != KErrNone) |
|
71 { |
|
72 Log(_L("Error: Couldn't prepend:")); |
|
73 firstFail = ETrue; |
|
74 } |
|
75 else |
|
76 { |
|
77 if(chain.NumBufs() != 1) |
|
78 { |
|
79 Log(_L("Error: Wrong number of MBufs allocated:")); |
|
80 secondFail = ETrue; |
|
81 } |
|
82 if(chain.Length() != 20) |
|
83 { |
|
84 Log(_L("Error: Wrong number of bytes prepended:")); |
|
85 secondFail = ETrue; |
|
86 } |
|
87 //-------------- substep 3 -------------------- |
|
88 Log(_L(" 03 Deallocating RMBufChain")); |
|
89 chain.Free(); |
|
90 } |
|
91 |
|
92 //-------------- substep 4 -------------------- |
|
93 Log(_L(" 04 Prepend 200 bytes to an empty chain")); |
|
94 ret = chain.Prepend(200); |
|
95 if (ret != KErrNone) |
|
96 { |
|
97 Log(_L("Error: Couldn't prepend:")); |
|
98 firstFail = ETrue; |
|
99 } |
|
100 else |
|
101 { |
|
102 if(chain.NumBufs() != 2) |
|
103 { |
|
104 Log(_L("Error: Wrong number of MBufs allocated:")); |
|
105 secondFail = ETrue; |
|
106 } |
|
107 if(chain.Length() != 200) |
|
108 { |
|
109 Log(_L("Error: Wrong number of bytes prepended:")); |
|
110 secondFail = ETrue; |
|
111 } |
|
112 //-------------- substep 6 -------------------- |
|
113 Log(_L(" 05 Deallocating RMBufChain")); |
|
114 chain.Free(); |
|
115 } |
|
116 //-------------- substep 6 -------------------- |
|
117 Log(_L(" 06 Prepend 20 bytes to an existing chain")); |
|
118 ret = chain.Alloc(20); |
|
119 if (ret != KErrNone) |
|
120 { |
|
121 Log(_L("Error: Couldn't allocate initial chain:")); |
|
122 firstFail = ETrue; |
|
123 } |
|
124 else |
|
125 { |
|
126 ret = chain.Prepend(20); |
|
127 if (ret != KErrNone) |
|
128 { |
|
129 Log(_L("Error: Couldn't prepend:")); |
|
130 firstFail = ETrue; |
|
131 } |
|
132 else |
|
133 { |
|
134 if(chain.NumBufs() != 2) |
|
135 { |
|
136 Log(_L("Error: Wrong number of MBufs allocated:")); |
|
137 secondFail = ETrue; |
|
138 } |
|
139 if(chain.Length() != 40) |
|
140 { |
|
141 Log(_L("Error: Wrong number of bytes:")); |
|
142 secondFail = ETrue; |
|
143 } |
|
144 //-------------- substep 7 -------------------- |
|
145 Log(_L(" 07 Deallocating RMBufChain")); |
|
146 chain.Free(); |
|
147 } |
|
148 } |
|
149 //-------------- substep 6 -------------------- |
|
150 Log(_L(" 08 Prepend 200 bytes to an existing chain")); |
|
151 ret = chain.Alloc(20); |
|
152 if (ret != KErrNone) |
|
153 { |
|
154 Log(_L("Error: Couldn't allocate initial chain:")); |
|
155 firstFail = ETrue; |
|
156 } |
|
157 else |
|
158 { |
|
159 ret = chain.Prepend(200); |
|
160 if (ret != KErrNone) |
|
161 { |
|
162 Log(_L("Error: Couldn't prepend:")); |
|
163 firstFail = ETrue; |
|
164 } |
|
165 else |
|
166 { |
|
167 if(chain.NumBufs() != 3) |
|
168 { |
|
169 Log(_L("Error: Wrong number of MBufs allocated:")); |
|
170 secondFail = ETrue; |
|
171 } |
|
172 if(chain.Length() != 220) |
|
173 { |
|
174 Log(_L("Error: Wrong number of bytes:")); |
|
175 secondFail = ETrue; |
|
176 } |
|
177 //-------------- substep 7 -------------------- |
|
178 Log(_L(" 09 Deallocating RMBufChain")); |
|
179 chain.Free(); |
|
180 } |
|
181 } |
|
182 //-------------- substep 7 -------------------- |
|
183 Log(_L(" 10 Clean up stack:")); |
|
184 CleanupStack::PopAndDestroy(iMBMngr); |
|
185 CActiveScheduler::Install(NULL); |
|
186 CleanupStack::PopAndDestroy(iActSch); |
|
187 |
|
188 #ifdef __CFLOG_ACTIVE |
|
189 __CFLOG_CLOSE; |
|
190 __CFLOG_DELETE; |
|
191 #endif |
|
192 __UHEAP_MARKEND; |
|
193 |
|
194 if (firstFail || secondFail) |
|
195 { |
|
196 return EFail; |
|
197 } |
|
198 |
|
199 return EPass; |
|
200 } |
|
201 |