|
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_CMccJitterCalculator.h" |
|
23 |
|
24 // EXTERNAL INCLUDES |
|
25 #include <digia/eunit/eunitmacros.h> |
|
26 |
|
27 |
|
28 // INTERNAL INCLUDES |
|
29 #include "MccRtpInterface.h" |
|
30 |
|
31 // CONSTRUCTION |
|
32 UT_CMccJitterCalculator* UT_CMccJitterCalculator::NewL() |
|
33 { |
|
34 UT_CMccJitterCalculator* self = UT_CMccJitterCalculator::NewLC(); |
|
35 CleanupStack::Pop(); |
|
36 |
|
37 return self; |
|
38 } |
|
39 |
|
40 UT_CMccJitterCalculator* UT_CMccJitterCalculator::NewLC() |
|
41 { |
|
42 UT_CMccJitterCalculator* self = new( ELeave ) UT_CMccJitterCalculator(); |
|
43 CleanupStack::PushL( self ); |
|
44 |
|
45 self->ConstructL(); |
|
46 |
|
47 return self; |
|
48 } |
|
49 |
|
50 // Destructor (virtual by CBase) |
|
51 UT_CMccJitterCalculator::~UT_CMccJitterCalculator() |
|
52 { |
|
53 } |
|
54 |
|
55 // Default constructor |
|
56 UT_CMccJitterCalculator::UT_CMccJitterCalculator() |
|
57 { |
|
58 } |
|
59 |
|
60 // Second phase construct |
|
61 void UT_CMccJitterCalculator::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 // Observer impl |
|
69 void UT_CMccJitterCalculator::SendJitterEvent( TMccRtpEventData aEvent, TInt aError ) |
|
70 { |
|
71 iLastEvent = aEvent; |
|
72 iLastError = aError; |
|
73 } |
|
74 |
|
75 // METHODS |
|
76 |
|
77 |
|
78 |
|
79 void UT_CMccJitterCalculator::SetupL( ) |
|
80 { |
|
81 iCalculator = CMccJitterCalculator::NewL( *this ); |
|
82 } |
|
83 |
|
84 void UT_CMccJitterCalculator::Teardown( ) |
|
85 { |
|
86 delete iCalculator; |
|
87 } |
|
88 |
|
89 void UT_CMccJitterCalculator::UT_CMccJitterCalculator_StartObservingL() |
|
90 { |
|
91 // Test delete of inactive calculator |
|
92 delete iCalculator; |
|
93 iCalculator = NULL; |
|
94 |
|
95 iCalculator = CMccJitterCalculator::NewL( *this ); |
|
96 |
|
97 // Jitter reports |
|
98 iCalculator->iReportType = EMccJitterReport; |
|
99 EUNIT_ASSERT_EQUALS( iCalculator->StartObserving(), KErrNone ); |
|
100 EUNIT_ASSERT_EQUALS( iCalculator->iJitterObsOn, ETrue ); |
|
101 |
|
102 // Packet loss reports |
|
103 iCalculator->iReportType = EMccPacketLossReport; |
|
104 EUNIT_ASSERT_EQUALS( iCalculator->StartObserving(), KErrNone ); |
|
105 EUNIT_ASSERT_EQUALS( iCalculator->iFrameLossObsOn, ETrue ); |
|
106 |
|
107 // All reports |
|
108 iCalculator->iFrameLossObsOn = EFalse; |
|
109 iCalculator->iJitterObsOn = EFalse; |
|
110 iCalculator->iMediaQualityObservingStarted = EFalse; |
|
111 iCalculator->iReportType = EMccQualityReportAll; |
|
112 EUNIT_ASSERT_EQUALS( iCalculator->StartObserving(), KErrNone ); |
|
113 EUNIT_ASSERT_EQUALS( iCalculator->iJitterObsOn, ETrue ); |
|
114 EUNIT_ASSERT_EQUALS( iCalculator->iFrameLossObsOn, ETrue ); |
|
115 EUNIT_ASSERT_EQUALS( iCalculator->iMediaQualityObservingStarted, ETrue ); |
|
116 |
|
117 // Not supported reports |
|
118 iCalculator->iReportType = 998; |
|
119 EUNIT_ASSERT_EQUALS( iCalculator->StartObserving(), KErrArgument ); |
|
120 } |
|
121 |
|
122 void UT_CMccJitterCalculator::UT_CMccJitterCalculator_JitterObservingL() |
|
123 { |
|
124 iCalculator->iHomeTime.HomeTime(); |
|
125 |
|
126 // Not active |
|
127 iCalculator->JitterObserving(); |
|
128 |
|
129 iCalculator->iPacketsReceived = 5; |
|
130 iCalculator->iJitterLevelFromClient = 10000; |
|
131 iCalculator->iCurJitter = 10000; |
|
132 iCalculator->iJitterObsOn = ETrue; |
|
133 |
|
134 // Time based reporting |
|
135 // |
|
136 iCalculator->iReportIntervalType = EMccQualityTimeBased; |
|
137 iCalculator->iCurTime.HomeTime(); |
|
138 |
|
139 // Not reported as not enough time elapsed |
|
140 iCalculator->iReportInterval = 100000; |
|
141 iCalculator->JitterObserving(); |
|
142 EUNIT_ASSERT_EQUALS( iLastEvent.iPacketsReceived, 0 ); |
|
143 |
|
144 // Enough time elapsed but not over jitter level defined by client |
|
145 iCalculator->iReportInterval = 0; |
|
146 iCalculator->JitterObserving(); |
|
147 EUNIT_ASSERT_EQUALS( iLastEvent.iPacketsReceived, 0 ); |
|
148 |
|
149 // Jitter level defined by client exceeded |
|
150 iCalculator->iJitterLevelFromClient = 10; |
|
151 iCalculator->JitterObserving(); |
|
152 EUNIT_ASSERT_EQUALS( iLastEvent.iPacketsReceived, 5 ); // just making sure that callback was called |
|
153 |
|
154 // Quality based reporting |
|
155 // |
|
156 iCalculator->iReportIntervalType = EMccQualityPacketBased; |
|
157 iLastEvent.iPacketsReceived = 0; |
|
158 iCalculator->iReportInterval = 2; |
|
159 iCalculator->iJitterObsOn = ETrue; |
|
160 |
|
161 // Not the packet when calculation is done |
|
162 iCalculator->iReceivedPacketCounter = 0; |
|
163 iCalculator->JitterObserving(); |
|
164 EUNIT_ASSERT_EQUALS( iCalculator->iReceivedPacketCounter, 1 ); |
|
165 |
|
166 // Now the interval is reached |
|
167 iCalculator->JitterObserving(); |
|
168 EUNIT_ASSERT_EQUALS( iLastEvent.iPacketsReceived, 5 ); // just making sure that callback was called |
|
169 EUNIT_ASSERT_EQUALS( iCalculator->iReceivedPacketCounter, 0 ); // counter is zeroed |
|
170 |
|
171 // Other reporting |
|
172 iCalculator->iReportIntervalType = 998; |
|
173 iLastEvent.iPacketsReceived = 0; |
|
174 iCalculator->iJitterObsOn = ETrue; |
|
175 iCalculator->JitterObserving(); |
|
176 EUNIT_ASSERT_EQUALS( iLastEvent.iPacketsReceived, 5 ); // just making sure that callback was called |
|
177 } |
|
178 |
|
179 void UT_CMccJitterCalculator::UT_CMccJitterCalculator_RtpPacketReceivedL() |
|
180 { |
|
181 // TBD: real assert for values |
|
182 |
|
183 const TInt KTestConversion = 8000; |
|
184 |
|
185 // First packet |
|
186 const TInt firstPacketTimestamp = 1000; |
|
187 iCalculator->RtpPacketReceived( firstPacketTimestamp, EFalse ); |
|
188 EUNIT_ASSERT( iCalculator->iPrevPacketTransit != 0 ); |
|
189 |
|
190 // Second packet (fake that it is the one when reporting) |
|
191 iCalculator->iPacketsReceived = 15; // ( KJitterReportInterval - 1 ) |
|
192 const TInt secondPacketTimestamp = 3000; |
|
193 iCalculator->RtpPacketReceived( secondPacketTimestamp, EFalse ); |
|
194 EUNIT_ASSERT( iCalculator->iCurJitter != 0 ); |
|
195 EUNIT_ASSERT_EQUALS( (TInt)iLastEvent.iPacketsReceived, 16 ); // just making sure that callback was called |
|
196 } |
|
197 |
|
198 // TEST TABLE |
|
199 |
|
200 EUNIT_BEGIN_TEST_TABLE( |
|
201 UT_CMccJitterCalculator, |
|
202 "Add test suite description here.", |
|
203 "UNIT" ) |
|
204 |
|
205 EUNIT_TEST( |
|
206 "StartObserving - test ", |
|
207 "CMccJitterCalculator", |
|
208 "StartObserving", |
|
209 "FUNCTIONALITY", |
|
210 SetupL, UT_CMccJitterCalculator_StartObservingL, Teardown) |
|
211 |
|
212 EUNIT_TEST( |
|
213 "JitterObserving - test ", |
|
214 "CMccJitterCalculator", |
|
215 "JitterObserving", |
|
216 "FUNCTIONALITY", |
|
217 SetupL, UT_CMccJitterCalculator_JitterObservingL, Teardown) |
|
218 |
|
219 EUNIT_TEST( |
|
220 "RtpPacketReceived - test ", |
|
221 "CMccJitterCalculator", |
|
222 "RtpPacketReceived", |
|
223 "FUNCTIONALITY", |
|
224 SetupL, UT_CMccJitterCalculator_RtpPacketReceivedL, Teardown) |
|
225 |
|
226 EUNIT_END_TEST_TABLE |
|
227 |
|
228 // END OF FILE |