13 * |
13 * |
14 * Description: Main plugin class |
14 * Description: Main plugin class |
15 * |
15 * |
16 */ |
16 */ |
17 |
17 |
18 #include <sipstrings.h> |
18 |
19 #include "musunittesting.h" |
19 #include "musunittesting.h" |
20 #include "musmanagerstub.h" |
20 #include "musmanagerstub.h" |
21 #include "mussipcrplugin.h" |
21 #include "mussipcrplugin.h" |
22 #include "mussipcrplugintest.h" |
22 #include "mussipcrplugintest.h" |
23 #include "muslogger.h" |
23 #include "muslogger.h" |
24 #include "musmanager.h" |
24 #include "musmanager.h" |
|
25 #include "mussettings.h" |
25 |
26 |
26 #include <alwaysonlinemanagercommon.h> |
27 #include <alwaysonlinemanagercommon.h> |
27 #include <alwaysonlinemanagerclient.h> |
28 #include <alwaysonlinemanagerclient.h> |
28 #include <digia/eunit/eunitmacros.h> |
29 #include <digia/eunit/eunitmacros.h> |
29 #include <SipResolvedClient.h> |
30 #include <SipResolvedClient.h> |
|
31 #include <sipstrings.h> |
30 #include <sipstrconsts.h> |
32 #include <sipstrconsts.h> |
31 #include "FeatMgr.h" |
33 #include <SdpCodecStringPool.h> |
32 |
34 #include <sdpdocument.h> |
33 |
35 |
34 // Next row is to disable warning emerging from EUnit code. |
36 // Next row is to disable warning emerging from EUnit code. |
35 #pragma warn_illtokenpasting off |
37 #pragma warn_illtokenpasting off |
|
38 |
|
39 _LIT8( KSdpSendOnly, "v=0\r\n\ |
|
40 o=Inviter2008 63241204263093750 132223800 IN IP4 10.0.0.6\r\n\ |
|
41 s=-\r\n\ |
|
42 c=IN IP4 10.0.0.6\r\n\ |
|
43 t=0 0\r\n\ |
|
44 m=video 49152 RTP/AVP 98\r\n\ |
|
45 a=sendonly\r\n\ |
|
46 a=rtpmap:98 H264/90000\r\n" ); |
|
47 |
|
48 _LIT8( KSdpSendRecv, "v=0\r\n\ |
|
49 o=Inviter2008 63241204263093750 132223800 IN IP4 10.0.0.6\r\n\ |
|
50 s=-\r\n\ |
|
51 c=IN IP4 10.0.0.6\r\n\ |
|
52 t=0 0\r\n\ |
|
53 m=video 49152 RTP/AVP 98\r\n\ |
|
54 a=sendrecv\r\n\ |
|
55 a=rtpmap:98 H264/90000\r\n" ); |
|
56 |
|
57 _LIT8( KSdpNoMedia, "v=0\r\n\ |
|
58 o=Inviter2008 63241204263093750 132223800 IN IP4 10.0.0.6\r\n\ |
|
59 s=-\r\n\ |
|
60 c=IN IP4 10.0.0.6\r\n\ |
|
61 t=0 0\r\n" ); |
|
62 |
|
63 _LIT8( KSdpNoVideo, "v=0\r\n\ |
|
64 o=Inviter2008 63241204263093750 132223800 IN IP4 10.0.0.6\r\n\ |
|
65 s=-\r\n\ |
|
66 c=IN IP4 10.0.0.6\r\n\ |
|
67 t=0 0\r\n\ |
|
68 m=audio 5000 RTP/AVP 106 8 0\r\n\ |
|
69 a=sendrecv\r\n\ |
|
70 a=rtpmap:106 AMR/8000\r\n" ); |
|
71 |
|
72 _LIT8( KSdpVideoNoAttributes, "v=0\r\n\ |
|
73 o=Inviter2008 63241204263093750 132223800 IN IP4 10.0.0.6\r\n\ |
|
74 s=-\r\n\ |
|
75 c=IN IP4 10.0.0.6\r\n\ |
|
76 t=0 0\r\n\ |
|
77 m=video 49152 RTP/AVP 98\r\n" ); |
|
78 |
|
79 _LIT8( KSdpRecvOnly, "v=0\r\n\ |
|
80 o=Inviter2008 63241204263093750 132223800 IN IP4 10.0.0.6\r\n\ |
|
81 s=-\r\n\ |
|
82 c=IN IP4 10.0.0.6\r\n\ |
|
83 t=0 0\r\n\ |
|
84 m=video 49152 RTP/AVP 98\r\n\ |
|
85 a=recvonly\r\n\ |
|
86 a=rtpmap:98 H264/90000\r\n" ); |
36 |
87 |
37 |
88 |
38 // -------------------------------------------------------------------------- |
89 // -------------------------------------------------------------------------- |
39 // C++ constructor. |
90 // C++ constructor. |
40 // -------------------------------------------------------------------------- |
91 // -------------------------------------------------------------------------- |
87 // -------------------------------------------------------------------------- |
138 // -------------------------------------------------------------------------- |
88 // |
139 // |
89 void CMusSipCrPluginTest::SetupL( ) |
140 void CMusSipCrPluginTest::SetupL( ) |
90 { |
141 { |
91 iPlugin = CMusSipCrPlugin::NewL(); |
142 iPlugin = CMusSipCrPlugin::NewL(); |
|
143 SIPStrings::OpenL(); |
92 } |
144 } |
93 |
145 |
94 |
146 |
95 // -------------------------------------------------------------------------- |
147 // -------------------------------------------------------------------------- |
96 // |
148 // |
97 // -------------------------------------------------------------------------- |
149 // -------------------------------------------------------------------------- |
98 // |
150 // |
99 void CMusSipCrPluginTest::Teardown( ) |
151 void CMusSipCrPluginTest::Teardown( ) |
100 { |
152 { |
|
153 SIPStrings::Close(); |
101 delete iPlugin; |
154 delete iPlugin; |
102 } |
155 } |
103 |
156 |
104 |
157 |
105 |
158 |
106 // ------------------------- Test functions begin --------------------------- |
159 // ------------------------- Test functions begin --------------------------- |
107 |
160 |
|
161 // -------------------------------------------------------------------------- |
|
162 // |
|
163 // -------------------------------------------------------------------------- |
|
164 // |
|
165 void CMusSipCrPluginTest::UT_ConstructL() |
|
166 { |
|
167 // 1. String pool was opend by us |
|
168 EUNIT_ASSERT( iPlugin->iCloseStringPool ); |
|
169 |
|
170 // 2. String pool was already opened by someone else, KErrAlreadyExists |
|
171 delete iPlugin; |
|
172 iPlugin = NULL; |
|
173 SdpCodecStringPool::OpenL(); |
|
174 TRAPD( err, iPlugin = CMusSipCrPlugin::NewL() ); |
|
175 if ( err != KErrNone ) |
|
176 { |
|
177 SdpCodecStringPool::Close(); |
|
178 User::Leave(err); |
|
179 } |
|
180 EUNIT_ASSERT( !iPlugin->iCloseStringPool ); |
|
181 SdpCodecStringPool::Close(); |
|
182 } |
|
183 |
108 |
184 |
109 // -------------------------------------------------------------------------- |
185 // -------------------------------------------------------------------------- |
110 // |
186 // |
111 // -------------------------------------------------------------------------- |
187 // -------------------------------------------------------------------------- |
112 // |
188 // |
113 void CMusSipCrPluginTest::UT_ChannelL() |
189 void CMusSipCrPluginTest::UT_ChannelL() |
114 { |
190 { |
115 SIPStrings::OpenL(); |
|
116 |
|
117 RPointerArray<CSIPHeaderBase> array; |
191 RPointerArray<CSIPHeaderBase> array; |
118 |
192 |
119 TUid response; |
193 TUid response; |
120 |
194 |
121 // Options |
195 // Options |
160 array, |
234 array, |
161 KNullDesC8(), |
235 KNullDesC8(), |
162 NULL ); |
236 NULL ); |
163 |
237 |
164 EUNIT_ASSERT( response.iUid == CMusManager::ESipInviteNotDesired ) |
238 EUNIT_ASSERT( response.iUid == CMusManager::ESipInviteNotDesired ) |
165 //Feature Manager testing |
239 |
166 FeatureManager::MultimediaSharingNotSupported(); |
240 // 2-way video is supported and sendrecv not present in SDP |
167 response = iPlugin->ChannelL( |
241 MultimediaSharingSettings::iVideoDirection = MusSettingsKeys::ETwoWayVideo; |
168 SIPStrings::StringF( SipStrConsts::EOptions ), |
|
169 KNullDesC8(), |
|
170 array, |
|
171 KNullDesC8(), |
|
172 NULL ); |
|
173 |
|
174 EUNIT_ASSERT( response.iUid == CMusManager::ESipInviteNotDesired ) |
|
175 // Everything is OK |
|
176 CMusManager::SetAvailability( |
242 CMusManager::SetAvailability( |
177 ( MultimediaSharing::TMusAvailabilityStatus ) KErrNone ); |
243 ( MultimediaSharing::TMusAvailabilityStatus ) KErrNone ); |
178 |
244 |
179 response = iPlugin->ChannelL( SIPStrings::StringF( SipStrConsts::EMessage ), |
245 response = iPlugin->ChannelL( SIPStrings::StringF( SipStrConsts::EMessage ), |
180 KNullDesC8(), |
246 KNullDesC8(), |
181 array, |
247 array, |
182 KNullDesC8(), |
248 KSdpSendOnly(), |
183 NULL ); |
249 NULL ); |
184 |
250 |
185 EUNIT_ASSERT( response.iUid == CMusManager::ESipInviteNotDesired ) |
251 EUNIT_ASSERT( response.iUid == CMusManager::ESipInviteDesired ) |
186 |
252 |
187 // Server is shut down |
253 // 2-way video is supported and sendrecv is present in SDP |
188 CMusManager::SetAvailability( MultimediaSharing::EErrServerShutDown ); |
|
189 |
|
190 response = iPlugin->ChannelL( SIPStrings::StringF( SipStrConsts::EMessage ), |
254 response = iPlugin->ChannelL( SIPStrings::StringF( SipStrConsts::EMessage ), |
191 KNullDesC8(), |
255 KNullDesC8(), |
192 array, |
256 array, |
193 KNullDesC8(), |
257 KSdpSendRecv(), |
194 NULL ); |
258 NULL ); |
195 |
259 |
196 EUNIT_ASSERT( response.iUid == CMusManager::ESipInviteNotDesired ) |
260 EUNIT_ASSERT( response.iUid == CMusManager::ESipInviteDesired2WayVideo ) |
197 |
|
198 // Mus is not supported |
|
199 CMusManager::SetAvailability( |
|
200 ( MultimediaSharing::TMusAvailabilityStatus ) KErrNotSupported ); |
|
201 |
|
202 response = iPlugin->ChannelL( SIPStrings::StringF( SipStrConsts::EMessage ), |
|
203 KNullDesC8(), |
|
204 array, |
|
205 KNullDesC8(), |
|
206 NULL ); |
|
207 |
|
208 EUNIT_ASSERT( response.iUid == CMusManager::ESipInviteNotDesired ) |
|
209 FeatureManager::MultimediaSharingSupported(); |
|
210 SIPStrings::Close(); |
|
211 |
|
212 } |
261 } |
213 |
262 |
214 |
263 |
215 // -------------------------------------------------------------------------- |
264 // -------------------------------------------------------------------------- |
216 // |
265 // |
267 |
316 |
268 ImplementationGroupProxy( tableCount ); |
317 ImplementationGroupProxy( tableCount ); |
269 } |
318 } |
270 |
319 |
271 |
320 |
|
321 // -------------------------------------------------------------------------- |
|
322 // |
|
323 // -------------------------------------------------------------------------- |
|
324 // |
|
325 void CMusSipCrPluginTest::UT_CheckForSendRecvAttributeL() |
|
326 { |
|
327 CSdpDocument* sdpDocument; |
|
328 TBool sendRecv; |
|
329 |
|
330 // 1. SDP doesn't have a single media field |
|
331 sdpDocument = CSdpDocument::DecodeLC( KSdpNoMedia() ); |
|
332 sendRecv = iPlugin->CheckForSendRecvAttributeL( sdpDocument->MediaFields() ); |
|
333 CleanupStack::PopAndDestroy( sdpDocument ); |
|
334 EUNIT_ASSERT( !sendRecv ); |
|
335 |
|
336 // 2. SDP has audio field, but no video |
|
337 sdpDocument = CSdpDocument::DecodeLC( KSdpNoVideo() ); |
|
338 sendRecv = iPlugin->CheckForSendRecvAttributeL( sdpDocument->MediaFields() ); |
|
339 CleanupStack::PopAndDestroy( sdpDocument ); |
|
340 EUNIT_ASSERT( !sendRecv ); |
|
341 |
|
342 // 3. SDP has video field without any attributes |
|
343 sdpDocument = CSdpDocument::DecodeLC( KSdpVideoNoAttributes() ); |
|
344 sendRecv = iPlugin->CheckForSendRecvAttributeL( sdpDocument->MediaFields() ); |
|
345 CleanupStack::PopAndDestroy( sdpDocument ); |
|
346 EUNIT_ASSERT( sendRecv ); |
|
347 |
|
348 // 4. SDP has video with "sendrecv" attribute |
|
349 sdpDocument = CSdpDocument::DecodeLC( KSdpSendRecv() ); |
|
350 sendRecv = iPlugin->CheckForSendRecvAttributeL( sdpDocument->MediaFields() ); |
|
351 CleanupStack::PopAndDestroy( sdpDocument ); |
|
352 EUNIT_ASSERT( sendRecv ); |
|
353 |
|
354 // 5. SDP has video with "recvonly" attribute |
|
355 sdpDocument = CSdpDocument::DecodeLC( KSdpRecvOnly() ); |
|
356 sendRecv = iPlugin->CheckForSendRecvAttributeL( sdpDocument->MediaFields() ); |
|
357 CleanupStack::PopAndDestroy( sdpDocument ); |
|
358 EUNIT_ASSERT( !sendRecv ); |
|
359 } |
272 |
360 |
273 |
361 |
274 // TEST TABLE |
362 // TEST TABLE |
275 |
363 |
276 EUNIT_BEGIN_TEST_TABLE( |
364 EUNIT_BEGIN_TEST_TABLE( |
277 CMusSipCrPluginTest, |
365 CMusSipCrPluginTest, |
278 "CMusSipCrPluginTest", |
366 "CMusSipCrPluginTest", |
279 "CMusSipCrPluginTest" ) |
367 "CMusSipCrPluginTest" ) |
|
368 |
|
369 EUNIT_TEST( |
|
370 "ConstructL - test", |
|
371 "CMusSipCrPluginTest", |
|
372 "UT_ConstructL", |
|
373 "FUNCTIONALITY", |
|
374 SetupL, UT_ConstructL, Teardown) |
280 |
375 |
281 EUNIT_TEST( |
376 EUNIT_TEST( |
282 "CMusSipCrPluginTest", |
377 "CMusSipCrPluginTest", |
283 "CMusSipCrPluginTest", |
378 "CMusSipCrPluginTest", |
284 "ConnectL", |
379 "ConnectL", |
304 "CMusSipCrPluginTest", |
399 "CMusSipCrPluginTest", |
305 "ImplementationGroupProxyTest", |
400 "ImplementationGroupProxyTest", |
306 "FUNCTIONALITY", |
401 "FUNCTIONALITY", |
307 SetupL, UT_ImplementationGroupProxy, Teardown) |
402 SetupL, UT_ImplementationGroupProxy, Teardown) |
308 |
403 |
|
404 EUNIT_TEST( |
|
405 "CheckForSendRecvAttribute - stest", |
|
406 "CMusSipCrPluginTest", |
|
407 "UT_CheckForSendRecvAttribute", |
|
408 "FUNCTIONALITY", |
|
409 SetupL, UT_CheckForSendRecvAttributeL, Teardown) |
|
410 |
309 EUNIT_END_TEST_TABLE |
411 EUNIT_END_TEST_TABLE |
310 |
412 |