|
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 // Test23RMBufQ.cpp |
|
15 // Contains MBufMgr Test Step 22 for Append() methods |
|
16 // |
|
17 // |
|
18 |
|
19 // EPOC includes |
|
20 #include <e32base.h> |
|
21 |
|
22 // Test system includes |
|
23 #ifdef SYMBIAN_OLD_EXPORT_LOCATION |
|
24 #include "networking/log.h" |
|
25 #include "networking/teststep.h" |
|
26 #else |
|
27 #include <networking/log.h> |
|
28 #include <networking/teststep.h> |
|
29 #endif |
|
30 |
|
31 #include "TestStepCTMbufmgr.h" |
|
32 #include "TestSuiteCTMbufmgr.h" |
|
33 |
|
34 #include "Test23RMBufQ.h" |
|
35 |
|
36 // constructor |
|
37 CTest23RMBufQ::CTest23RMBufQ() |
|
38 { |
|
39 iTestStepName = _L("MBufMgrTest23");// Store the name of this test case |
|
40 } |
|
41 |
|
42 // destructor |
|
43 CTest23RMBufQ::~CTest23RMBufQ() |
|
44 { |
|
45 } |
|
46 |
|
47 // |
|
48 enum TVerdict CTest23RMBufQ::doTestStepL(void) |
|
49 { |
|
50 __UHEAP_MARK; |
|
51 |
|
52 #ifdef __CFLOG_ACTIVE |
|
53 __CFLOG_CREATEL; |
|
54 __CFLOG_OPEN; |
|
55 #endif |
|
56 |
|
57 //-------------- substep 1 -------------------- |
|
58 Log(_L(" 01 Create CMBufManager and install active scheduler:")); |
|
59 CleanupStack::PushL( iActSch = new(ELeave) CActiveScheduler ); |
|
60 CActiveScheduler::Install(iActSch); |
|
61 |
|
62 RArray<TCommsBufPoolCreateInfo> poolInfoArray; |
|
63 TCommsBufPoolCreateInfo createInfo; |
|
64 createInfo.iBufSize = 128; |
|
65 createInfo.iInitialBufs = 128; |
|
66 createInfo.iGrowByBufs = 64; |
|
67 createInfo.iMinFreeBufs = 40; |
|
68 createInfo.iCeiling = (KMBufDefaultHeapSize / 2)/createInfo.iBufSize; |
|
69 poolInfoArray.AppendL(createInfo); |
|
70 CreateInstanceMBufMgrL(poolInfoArray); |
|
71 CleanupClosePushL(iBufPond); |
|
72 poolInfoArray.Close (); |
|
73 |
|
74 TBool firstFail = EFalse; |
|
75 TBool secondFail = EFalse; |
|
76 TInt ret; |
|
77 RMBufChain chain,chain2; |
|
78 |
|
79 //-------------- substep 2 -------------------- |
|
80 Log(_L(" 2 Append a chain onto an RMBuqQ")); |
|
81 ret = chain.Alloc(20); |
|
82 if (ret != KErrNone) |
|
83 { |
|
84 Log(_L("Error: Couldn't allocate initial chain:")); |
|
85 firstFail = ETrue; |
|
86 } |
|
87 else |
|
88 { |
|
89 ret = chain2.Alloc(20); |
|
90 if (ret != KErrNone) |
|
91 { |
|
92 Log(_L("Error: Couldn't allocate second chain:")); |
|
93 firstFail = ETrue; |
|
94 } |
|
95 else |
|
96 { |
|
97 RMBuf* first2 = chain2.First(); |
|
98 RMBuf* first = chain.First(); |
|
99 |
|
100 RMBufQ aBufList; |
|
101 aBufList.Assign(chain); |
|
102 |
|
103 aBufList.Append(chain2); |
|
104 |
|
105 // Check that the buffers come back out of the queue in the right order |
|
106 if(aBufList.Remove() != first) |
|
107 { |
|
108 Log(_L("Error: chain not appended to RMBufQ correctly:")); |
|
109 secondFail = ETrue; |
|
110 } |
|
111 if(aBufList.Remove() != first2) |
|
112 { |
|
113 Log(_L("Error: chain not appended to RMBufQ correctly:")); |
|
114 secondFail = ETrue; |
|
115 } |
|
116 //-------------- substep 3 -------------------- |
|
117 Log(_L(" 3 Deallocating RMBufChains")); |
|
118 chain2.Free(); |
|
119 } |
|
120 chain.Free(); |
|
121 } |
|
122 //-------------- substep 4 -------------------- |
|
123 Log(_L(" 4 Prepend a chain onto an RMBuqQ")); |
|
124 ret = chain.Alloc(20); |
|
125 if (ret != KErrNone) |
|
126 { |
|
127 Log(_L("Error: Couldn't allocate initial chain:")); |
|
128 firstFail = ETrue; |
|
129 } |
|
130 else |
|
131 { |
|
132 ret = chain2.Alloc(20); |
|
133 if (ret != KErrNone) |
|
134 { |
|
135 Log(_L("Error: Couldn't allocate second chain:")); |
|
136 firstFail = ETrue; |
|
137 } |
|
138 else |
|
139 { |
|
140 RMBuf* first2 = chain2.First(); |
|
141 RMBuf* first = chain.First(); |
|
142 |
|
143 RMBufQ aBufList; |
|
144 aBufList.Assign(chain); |
|
145 |
|
146 aBufList.Prepend(chain2); |
|
147 |
|
148 // Check that the buffers come back out of the queue in the right order |
|
149 if(aBufList.Remove() != first2) |
|
150 { |
|
151 Log(_L("Error: chain not prepended to RMBufQ correctly:")); |
|
152 secondFail = ETrue; |
|
153 } |
|
154 if(aBufList.Remove() != first) |
|
155 { |
|
156 Log(_L("Error: chain not prepended to RMBufQ correctly:")); |
|
157 secondFail = ETrue; |
|
158 } |
|
159 //-------------- substep 5 -------------------- |
|
160 Log(_L(" 5 Deallocating RMBufChains")); |
|
161 chain2.Free(); |
|
162 } |
|
163 chain.Free(); |
|
164 } |
|
165 //-------------- substep 6 --------------------- |
|
166 Log(_L(" 6 Clean up stack:")); |
|
167 CleanupStack::PopAndDestroy(); // pond |
|
168 CActiveScheduler::Install(NULL); |
|
169 CleanupStack::PopAndDestroy(iActSch); |
|
170 |
|
171 #ifdef __CFLOG_ACTIVE |
|
172 __CFLOG_CLOSE; |
|
173 __CFLOG_DELETE; |
|
174 #endif |
|
175 __UHEAP_MARKEND; |
|
176 |
|
177 if (firstFail || secondFail) |
|
178 { |
|
179 return EFail; |
|
180 } |
|
181 |
|
182 return EPass; |
|
183 } |