|
1 /* |
|
2 * Copyright (c) 2004 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 |
|
21 // CLASS HEADER |
|
22 #include "UT_CAmrPayloadEncoder.h" |
|
23 |
|
24 // EXTERNAL INCLUDES |
|
25 #include <digia/eunit/eunitmacros.h> |
|
26 |
|
27 |
|
28 // INTERNAL INCLUDES |
|
29 #include "AmrPayloadEncoder.h" |
|
30 |
|
31 // CONSTRUCTION |
|
32 UT_CAmrPayloadEncoder* UT_CAmrPayloadEncoder::NewL() |
|
33 { |
|
34 UT_CAmrPayloadEncoder* self = UT_CAmrPayloadEncoder::NewLC(); |
|
35 CleanupStack::Pop(); |
|
36 |
|
37 return self; |
|
38 } |
|
39 |
|
40 UT_CAmrPayloadEncoder* UT_CAmrPayloadEncoder::NewLC() |
|
41 { |
|
42 UT_CAmrPayloadEncoder* self = new( ELeave ) UT_CAmrPayloadEncoder(); |
|
43 CleanupStack::PushL( self ); |
|
44 |
|
45 self->ConstructL(); |
|
46 |
|
47 return self; |
|
48 } |
|
49 |
|
50 // Destructor (virtual by CBase) |
|
51 UT_CAmrPayloadEncoder::~UT_CAmrPayloadEncoder() |
|
52 { |
|
53 } |
|
54 |
|
55 // Default constructor |
|
56 UT_CAmrPayloadEncoder::UT_CAmrPayloadEncoder() |
|
57 { |
|
58 } |
|
59 |
|
60 // Second phase construct |
|
61 void UT_CAmrPayloadEncoder::ConstructL() |
|
62 { |
|
63 // The ConstructL from the base class CEUnitTestSuiteClass must be called. |
|
64 // It generates the test case table. |
|
65 CEUnitTestSuiteClass::ConstructL(); |
|
66 } |
|
67 |
|
68 // METHODS |
|
69 |
|
70 |
|
71 |
|
72 void UT_CAmrPayloadEncoder::SetupL( ) |
|
73 { |
|
74 iEnc = CAmrPayloadEncoder::NewL( ETrue ); |
|
75 } |
|
76 |
|
77 void UT_CAmrPayloadEncoder::SetupWbL( ) |
|
78 { |
|
79 iEnc = CAmrPayloadEncoder::NewL( EFalse ); |
|
80 } |
|
81 |
|
82 void UT_CAmrPayloadEncoder::Teardown( ) |
|
83 { |
|
84 delete iEnc; |
|
85 } |
|
86 |
|
87 void UT_CAmrPayloadEncoder::UT_CAmrPayloadEncoder_SetModeRequestL( ) |
|
88 { |
|
89 iEnc->SetModeRequest( EAmrModeReq0 ); |
|
90 EUNIT_ASSERT_EQUALS( iEnc->iModeRequest, EAmrModeReq0 ); |
|
91 iEnc->SetModeRequest( EAmrModeReq1 ); |
|
92 EUNIT_ASSERT_EQUALS( iEnc->iModeRequest, EAmrModeReq1 ); |
|
93 } |
|
94 |
|
95 void UT_CAmrPayloadEncoder::UT_CAmrPayloadEncoder_EncodeFrameL( ) |
|
96 { |
|
97 //EUNIT_ASSERT_NO_LEAVE( iEnc->EncodeFrame( ); |
|
98 } |
|
99 |
|
100 void UT_CAmrPayloadEncoder::UT_CAmrPayloadEncoder_ResetPayloadBufferL( ) |
|
101 { |
|
102 iEnc->ResetPayloadBuffer(); |
|
103 iEnc->iRedCount = 4; |
|
104 HBufC8* buf = HBufC8::NewLC(10); |
|
105 buf->Des().Copy(_L8("heeaaaaa")); |
|
106 iEnc->SaveRedundantFrame(buf->Des()); |
|
107 iEnc->SaveRedundantFrame(buf->Des()); |
|
108 CleanupStack::PopAndDestroy(buf); |
|
109 iEnc->iFrames[iEnc->iRedCount].iFrameData = (TUint8 *)(-1); |
|
110 iEnc->ResetPayloadBuffer(); |
|
111 EUNIT_ASSERT_EQUALS( iEnc->iFrames[iEnc->iRedCount].iFrameData, (TUint8 *)NULL ); |
|
112 } |
|
113 |
|
114 void UT_CAmrPayloadEncoder::UT_CAmrPayloadEncoder_ReEncodeFrameLL( ) |
|
115 { |
|
116 //EUNIT_ASSERT( EFalse ); |
|
117 } |
|
118 |
|
119 void UT_CAmrPayloadEncoder::UT_CAmrPayloadEncoder_ReEncodeFrameL_1L( ) |
|
120 { |
|
121 //EUNIT_ASSERT( EFalse ); |
|
122 } |
|
123 |
|
124 void UT_CAmrPayloadEncoder::UT_CAmrPayloadEncoder_SetChannelCountL( ) |
|
125 { |
|
126 EUNIT_ASSERT_EQUALS( iEnc->SetChannelCount( 1 ), KErrNone ); |
|
127 EUNIT_ASSERT_EQUALS( iEnc->SetChannelCount( 0 ), KErrArgument ); |
|
128 EUNIT_ASSERT_EQUALS( iEnc->SetChannelCount( 99 ), KErrArgument ); |
|
129 } |
|
130 |
|
131 void UT_CAmrPayloadEncoder::UT_CAmrPayloadEncoder_SetFrameBlockCountL( ) |
|
132 { |
|
133 EUNIT_ASSERT_EQUALS( iEnc->SetFrameBlockCount( 1 ), KErrNone ); |
|
134 EUNIT_ASSERT_EQUALS( iEnc->SetFrameBlockCount( 0 ), KErrArgument ); |
|
135 EUNIT_ASSERT_EQUALS( iEnc->SetFrameBlockCount( 99 ), KErrArgument ); |
|
136 } |
|
137 |
|
138 void UT_CAmrPayloadEncoder::UT_CAmrPayloadEncoder_SetRedFrameBlockCountL( ) |
|
139 { |
|
140 TInt count( KMaxAmrRedCount + 1 ); |
|
141 EUNIT_ASSERT_EQUALS( iEnc->SetRedFrameBlockCount( count ), KErrArgument ); |
|
142 |
|
143 count = 1; |
|
144 EUNIT_ASSERT_EQUALS( iEnc->SetRedFrameBlockCount( count ), KErrNone ); |
|
145 EUNIT_ASSERT_EQUALS( iEnc->iRedCount, count ); |
|
146 count = 0; |
|
147 EUNIT_ASSERT_EQUALS( iEnc->SetRedFrameBlockCount( count ), KErrNone ); |
|
148 EUNIT_ASSERT_EQUALS( iEnc->iRedCount, count ); |
|
149 count = -1; |
|
150 EUNIT_ASSERT_EQUALS( iEnc->SetRedFrameBlockCount( count ), KErrArgument ); |
|
151 EUNIT_ASSERT_EQUALS( iEnc->iRedCount, 0 ); |
|
152 } |
|
153 |
|
154 void UT_CAmrPayloadEncoder::UT_TStreamEncoder_SaveRedundantFrameL( ) |
|
155 { |
|
156 HBufC8* buf = HBufC8::NewLC(10); |
|
157 iEnc->SetRedFrameBlockCount( 0 ); |
|
158 iEnc->SaveRedundantFrame(buf->Des()); |
|
159 iEnc->SaveRedundantFrame(buf->Des()); |
|
160 EUNIT_ASSERT_EQUALS( iEnc->iFrameDatas.Count(), 0 ); |
|
161 iEnc->SetRedFrameBlockCount( 1 ); |
|
162 iEnc->SaveRedundantFrame(buf->Des()); |
|
163 iEnc->SaveRedundantFrame(buf->Des()); |
|
164 CleanupStack::PopAndDestroy(buf); |
|
165 } |
|
166 // TEST TABLE |
|
167 |
|
168 EUNIT_BEGIN_TEST_TABLE( |
|
169 UT_CAmrPayloadEncoder, |
|
170 "Add test suite description here.", |
|
171 "UNIT" ) |
|
172 |
|
173 EUNIT_TEST( |
|
174 "SetModeRequest - test ", |
|
175 "CAmrPayloadEncoder", |
|
176 "SetModeRequest", |
|
177 "FUNCTIONALITY", |
|
178 SetupL, UT_CAmrPayloadEncoder_SetModeRequestL, Teardown) |
|
179 |
|
180 EUNIT_TEST( |
|
181 "EncodeFrame - test ", |
|
182 "CAmrPayloadEncoder", |
|
183 "EncodeFrame", |
|
184 "FUNCTIONALITY", |
|
185 SetupL, UT_CAmrPayloadEncoder_EncodeFrameL, Teardown) |
|
186 |
|
187 EUNIT_TEST( |
|
188 "ResetPayloadBuffer - test ", |
|
189 "CAmrPayloadEncoder", |
|
190 "ResetPayloadBuffer", |
|
191 "FUNCTIONALITY", |
|
192 SetupL, UT_CAmrPayloadEncoder_ResetPayloadBufferL, Teardown) |
|
193 |
|
194 EUNIT_TEST( |
|
195 "ReEncodeFrameL - test ", |
|
196 "CAmrPayloadEncoder", |
|
197 "ReEncodeFrameL", |
|
198 "FUNCTIONALITY", |
|
199 SetupL, UT_CAmrPayloadEncoder_ReEncodeFrameLL, Teardown) |
|
200 |
|
201 EUNIT_TEST( |
|
202 "ReEncodeFrameL - test ", |
|
203 "CAmrPayloadEncoder", |
|
204 "ReEncodeFrameL", |
|
205 "FUNCTIONALITY", |
|
206 SetupL, UT_CAmrPayloadEncoder_ReEncodeFrameL_1L, Teardown) |
|
207 |
|
208 EUNIT_TEST( |
|
209 "SetChannelCount - test ", |
|
210 "CAmrPayloadEncoder", |
|
211 "SetChannelCount", |
|
212 "FUNCTIONALITY", |
|
213 SetupL, UT_CAmrPayloadEncoder_SetChannelCountL, Teardown) |
|
214 |
|
215 EUNIT_TEST( |
|
216 "SetFrameBlockCount - test ", |
|
217 "CAmrPayloadEncoder", |
|
218 "SetFrameBlockCount", |
|
219 "FUNCTIONALITY", |
|
220 SetupL, UT_CAmrPayloadEncoder_SetFrameBlockCountL, Teardown) |
|
221 |
|
222 EUNIT_TEST( |
|
223 "SetRedFrameBlockCount - test ", |
|
224 "CAmrPayloadEncoder", |
|
225 "SetRedFrameBlockCount", |
|
226 "FUNCTIONALITY", |
|
227 SetupL, UT_CAmrPayloadEncoder_SetRedFrameBlockCountL, Teardown) |
|
228 |
|
229 EUNIT_TEST( |
|
230 "SaveRedundantFrameL - test ", |
|
231 "CAmrPayloadEncoder", |
|
232 "SaveRedundantFrameL", |
|
233 "FUNCTIONALITY", |
|
234 SetupL, UT_TStreamEncoder_SaveRedundantFrameL, Teardown) |
|
235 |
|
236 EUNIT_TEST( |
|
237 "EncodeFrame WideBand - test ", |
|
238 "CAmrPayloadEncoder", |
|
239 "EncodeFrame", |
|
240 "FUNCTIONALITY", |
|
241 SetupWbL, UT_CAmrPayloadEncoder_EncodeFrameL, Teardown) |
|
242 |
|
243 EUNIT_TEST( |
|
244 "ReEncodeFrameL WideBand - test ", |
|
245 "CAmrPayloadEncoder", |
|
246 "ReEncodeFrameL", |
|
247 "FUNCTIONALITY", |
|
248 SetupWbL, UT_CAmrPayloadEncoder_ReEncodeFrameLL, Teardown) |
|
249 |
|
250 EUNIT_TEST( |
|
251 "ReEncodeFrameL WideBand - test ", |
|
252 "CAmrPayloadEncoder", |
|
253 "ReEncodeFrameL", |
|
254 "FUNCTIONALITY", |
|
255 SetupWbL, UT_CAmrPayloadEncoder_ReEncodeFrameL_1L, Teardown) |
|
256 |
|
257 EUNIT_END_TEST_TABLE |
|
258 |
|
259 // END OF FILE |