21 #include "mussipprofilehandler.h" |
21 #include "mussipprofilehandler.h" |
22 #include "musengstubs.h" |
22 #include "musengstubs.h" |
23 #include "musengtestdefs.h" |
23 #include "musengtestdefs.h" |
24 #include "sipprofilealrcontroller.h" |
24 #include "sipprofilealrcontroller.h" |
25 |
25 |
|
26 |
26 // SYSTEM INCLUDES |
27 // SYSTEM INCLUDES |
27 #include <sipprofile.h> |
28 #include <sipprofile.h> |
28 #include <digia/eunit/eunitmacros.h> |
29 #include <digia/eunit/eunitmacros.h> |
29 #include <uri8.h> |
30 #include <uri8.h> |
30 |
31 |
31 const TUint KSipProfileId( 1 ); |
32 const TUint KSipProfileId( 1 ); |
32 |
33 |
|
34 |
33 // ----------------------------------------------------------------------------- |
35 // ----------------------------------------------------------------------------- |
34 // |
36 // |
35 // ----------------------------------------------------------------------------- |
37 // ----------------------------------------------------------------------------- |
36 // |
38 // |
37 UT_CMusEngSipProfileHandler* UT_CMusEngSipProfileHandler::NewL() |
39 UT_CMusEngSipProfileHandler* UT_CMusEngSipProfileHandler::NewL() |
83 { |
85 { |
84 // The ConstructL from the base class CEUnitTestSuiteClass must be called. |
86 // The ConstructL from the base class CEUnitTestSuiteClass must be called. |
85 // It generates the test case table. |
87 // It generates the test case table. |
86 CEUnitTestSuiteClass::ConstructL(); |
88 CEUnitTestSuiteClass::ConstructL(); |
87 } |
89 } |
88 |
90 |
89 |
91 |
|
92 // ----------------------------------------------------------------------------- |
|
93 // From MMusSipProfileUser |
|
94 // ----------------------------------------------------------------------------- |
|
95 // |
|
96 TBool UT_CMusEngSipProfileHandler::IsRoamingBetweenAPsAllowed() |
|
97 { |
|
98 return iRoamingBetweenAPsAllowed; |
|
99 } |
|
100 |
|
101 |
90 // ----------------------------------------------------------------------------- |
102 // ----------------------------------------------------------------------------- |
91 // |
103 // |
92 // ----------------------------------------------------------------------------- |
104 // ----------------------------------------------------------------------------- |
93 // |
105 // |
94 void UT_CMusEngSipProfileHandler::SetupL() |
106 void UT_CMusEngSipProfileHandler::SetupL() |
95 { |
107 { |
96 iObserver = new( ELeave ) CMusEngObserverStub; |
108 iProfileHandler = CMusSipProfileHandler::NewL( *this ); |
97 iProfileHandler = CMusSipProfileHandler::NewL( *iObserver ); |
|
98 } |
109 } |
99 |
110 |
100 |
111 |
101 // ----------------------------------------------------------------------------- |
112 // ----------------------------------------------------------------------------- |
102 // |
113 // |
103 // ----------------------------------------------------------------------------- |
114 // ----------------------------------------------------------------------------- |
104 // |
115 // |
105 void UT_CMusEngSipProfileHandler::Teardown() |
116 void UT_CMusEngSipProfileHandler::Teardown() |
106 { |
117 { |
107 delete iProfileHandler; |
118 delete iProfileHandler; |
108 delete iObserver; |
119 iRoamingBetweenAPsAllowed = EFalse; |
109 } |
120 } |
110 |
121 |
111 |
122 |
112 |
123 |
113 // TEST CASES |
124 // TEST CASES |
114 |
125 |
115 // ----------------------------------------------------------------------------- |
126 // ----------------------------------------------------------------------------- |
116 // |
127 // |
117 // ----------------------------------------------------------------------------- |
128 // ----------------------------------------------------------------------------- |
118 // |
129 // |
119 void UT_CMusEngSipProfileHandler::UT_CreateSipProfileLL() |
130 void UT_CMusEngSipProfileHandler::UT_CMusEngSipProfileHandler_CreateSipProfileLL() |
120 { |
131 { |
121 // SIP profile ID zero |
132 // SIP profile ID zero |
122 iProfileHandler->CreateProfileL( 0 ); |
133 iProfileHandler->CreateProfileL( 0 ); |
123 EUNIT_ASSERT( iProfileHandler->iSipProfile != NULL ) |
134 EUNIT_ASSERT( iProfileHandler->iSipProfile != NULL ) |
124 EUNIT_ASSERT( iProfileHandler->iSipProfile == iProfileHandler->Profile() ) |
135 EUNIT_ASSERT( iProfileHandler->iSipProfile == iProfileHandler->Profile() ) |
135 |
146 |
136 // ----------------------------------------------------------------------------- |
147 // ----------------------------------------------------------------------------- |
137 // |
148 // |
138 // ----------------------------------------------------------------------------- |
149 // ----------------------------------------------------------------------------- |
139 // |
150 // |
140 void UT_CMusEngSipProfileHandler::UT_ProfileIdL() |
151 void UT_CMusEngSipProfileHandler::UT_CMusEngSipProfileHandler_ProfileIdL() |
141 { |
152 { |
142 // SIP profile does not yet exist |
153 // SIP profile does not yet exist |
143 EUNIT_ASSERT_EQUALS( 0, iProfileHandler->ProfileId() ) |
154 EUNIT_ASSERT_EQUALS( 0, iProfileHandler->ProfileId() ) |
144 |
155 |
145 // SIP profile exists |
156 // SIP profile exists |
149 |
160 |
150 // ----------------------------------------------------------------------------- |
161 // ----------------------------------------------------------------------------- |
151 // |
162 // |
152 // ----------------------------------------------------------------------------- |
163 // ----------------------------------------------------------------------------- |
153 // |
164 // |
154 void UT_CMusEngSipProfileHandler::UT_AlrEventL() |
165 void UT_CMusEngSipProfileHandler::UT_CMusEngSipProfileHandler_AlrEventL() |
155 { |
166 { |
156 const TUint32 KSnapId( 1 ); |
167 const TUint32 KSnapId( 1 ); |
157 const TUint32 KIapId( 1 ); |
168 const TUint32 KIapId( 1 ); |
158 |
169 |
159 // Event is other that EIapAvailable |
170 // Event is other that EIapAvailable |
216 EUNIT_ASSERT_EQUALS( |
227 EUNIT_ASSERT_EQUALS( |
217 KIapId, iProfileHandler->iProfileAlrController->iLastUsedIap ) |
228 KIapId, iProfileHandler->iProfileAlrController->iLastUsedIap ) |
218 iProfileHandler->iProfileAlrController->iLastUsedIap = 0; |
229 iProfileHandler->iProfileAlrController->iLastUsedIap = 0; |
219 |
230 |
220 // Event is EIapAvailable, SIP profile ID matches, roaming not allowed |
231 // Event is EIapAvailable, SIP profile ID matches, roaming not allowed |
221 iObserver->iRoamingBetweenAPsAllowed = ETrue; |
232 iRoamingBetweenAPsAllowed = ETrue; |
222 iProfileHandler->AlrEvent( |
233 iProfileHandler->AlrEvent( |
223 MSipProfileAlrObserver::EIapAvailable, |
234 MSipProfileAlrObserver::EIapAvailable, |
224 KSipProfileId, KSnapId, KIapId ); |
235 KSipProfileId, KSnapId, KIapId ); |
225 if ( !iProfileHandler->iProfileAlrController->iAllowMigrationCalled ) |
236 if ( !iProfileHandler->iProfileAlrController->iAllowMigrationCalled ) |
226 { |
237 { |
238 |
249 |
239 // ----------------------------------------------------------------------------- |
250 // ----------------------------------------------------------------------------- |
240 // |
251 // |
241 // ----------------------------------------------------------------------------- |
252 // ----------------------------------------------------------------------------- |
242 // |
253 // |
243 void UT_CMusEngSipProfileHandler::UT_NullTestsL() |
254 void UT_CMusEngSipProfileHandler::UT_CMusEngSipProfileHandler_NullTestsL() |
244 { |
255 { |
245 // Dummies |
256 // Dummies |
246 |
|
247 CSIPTransactionBase transactionBase; |
257 CSIPTransactionBase transactionBase; |
248 CSIPServerTransaction serverTransaction; |
258 CSIPServerTransaction serverTransaction; |
249 CSIPDialog dialog; |
259 CSIPDialog dialog; |
250 CSIPClientTransaction clientTransaction; |
260 CSIPClientTransaction clientTransaction; |
251 CSIPDialogAssocBase dialogAssocBase; |
261 CSIPDialogAssocBase dialogAssocBase; |
252 CSIPRegistrationBinding registrationBinding; |
262 CSIPRegistrationBinding registrationBinding; |
253 CSIPRefresh refresh; |
263 CSIPRefresh refresh; |
254 |
264 |
255 // Tests |
265 // Tests |
256 |
266 iProfileHandler->ProfileRegistryEventOccurred( 0, |
|
267 MSIPProfileRegistryObserver::EProfileCreated ); |
257 iProfileHandler->ProfileRegistryErrorOccurred( 0, 0 ); |
268 iProfileHandler->ProfileRegistryErrorOccurred( 0, 0 ); |
258 iProfileHandler->IncomingRequest( 0, NULL ); |
269 iProfileHandler->IncomingRequest( 0, NULL ); |
259 iProfileHandler->TimedOut( serverTransaction ); |
270 iProfileHandler->TimedOut( serverTransaction ); |
260 iProfileHandler->IncomingRequest( NULL ); |
271 iProfileHandler->IncomingRequest( NULL ); |
261 iProfileHandler->IncomingRequest( NULL, dialog ); |
272 iProfileHandler->IncomingRequest( NULL, dialog ); |
277 |
288 |
278 // ----------------------------------------------------------------------------- |
289 // ----------------------------------------------------------------------------- |
279 // |
290 // |
280 // ----------------------------------------------------------------------------- |
291 // ----------------------------------------------------------------------------- |
281 // |
292 // |
282 void UT_CMusEngSipProfileHandler::UT_UserFromProfileLCL() |
293 void UT_CMusEngSipProfileHandler::UT_CMusEngSipProfileHandler_UserFromProfileLCL() |
283 { |
294 { |
284 iProfileHandler->CreateProfileL( KSipProfileId ); |
295 iProfileHandler->CreateProfileL( KSipProfileId ); |
285 CSIPProfile* profile = iProfileHandler->Profile(); |
296 CSIPProfile* profile = iProfileHandler->Profile(); |
286 delete profile->iArray; |
297 delete profile->iArray; |
287 profile->iArray = NULL; |
298 profile->iArray = NULL; |
300 EUNIT_ASSERT_EQUALS( KUserUri(), user->Uri().UriDes() ) |
311 EUNIT_ASSERT_EQUALS( KUserUri(), user->Uri().UriDes() ) |
301 |
312 |
302 CleanupStack::PopAndDestroy( user ); |
313 CleanupStack::PopAndDestroy( user ); |
303 } |
314 } |
304 |
315 |
305 |
|
306 // ----------------------------------------------------------------------------- |
|
307 // |
|
308 // ----------------------------------------------------------------------------- |
|
309 // |
|
310 void UT_CMusEngSipProfileHandler::UT_IsRegisteredL() |
|
311 { |
|
312 EUNIT_ASSERT( !iProfileHandler->IsRegistered( ) ) |
|
313 iProfileHandler->CreateProfileL( KSipProfileId ); |
|
314 EUNIT_ASSERT( iProfileHandler->IsRegistered( ) ) |
|
315 } |
|
316 |
|
317 |
|
318 // ----------------------------------------------------------------------------- |
|
319 // |
|
320 // ----------------------------------------------------------------------------- |
|
321 // |
|
322 void UT_CMusEngSipProfileHandler::UT_ProfileRegistryEventOccurredL() |
|
323 { |
|
324 // No profile yet |
|
325 iProfileHandler->ProfileRegistryEventOccurred( 0, |
|
326 MSIPProfileRegistryObserver::EProfileRegistered ); |
|
327 EUNIT_ASSERT( iObserver->IsReseted() ) |
|
328 |
|
329 // Create profile, but notify about registration of some other profile |
|
330 iProfileHandler->CreateProfileL( 1 ); |
|
331 iProfileHandler->ProfileRegistryEventOccurred( 2, |
|
332 MSIPProfileRegistryObserver::EProfileRegistered ); |
|
333 EUNIT_ASSERT( iObserver->IsReseted() ) |
|
334 |
|
335 // Normal case |
|
336 iProfileHandler->ProfileRegistryEventOccurred( 1, |
|
337 MSIPProfileRegistryObserver::EProfileRegistered ); |
|
338 EUNIT_ASSERT( iObserver->iProfileRegisteredCalled ) |
|
339 iObserver->Reset(); |
|
340 |
|
341 // React exclusively to EProfileRegistered |
|
342 iProfileHandler->ProfileRegistryEventOccurred( 1, |
|
343 MSIPProfileRegistryObserver::EProfileCreated ); |
|
344 EUNIT_ASSERT( iObserver->IsReseted() ) |
|
345 iProfileHandler->ProfileRegistryEventOccurred( 1, |
|
346 MSIPProfileRegistryObserver::EProfileUpdated ); |
|
347 EUNIT_ASSERT( iObserver->IsReseted() ) |
|
348 iProfileHandler->ProfileRegistryEventOccurred( 1, |
|
349 MSIPProfileRegistryObserver::EProfileDeregistered ); |
|
350 EUNIT_ASSERT( iObserver->IsReseted() ) |
|
351 iProfileHandler->ProfileRegistryEventOccurred( 1, |
|
352 MSIPProfileRegistryObserver::EProfileDestroyed ); |
|
353 EUNIT_ASSERT( iObserver->IsReseted() ) |
|
354 } |
|
355 |
|
356 |
|
357 // TEST TABLE |
316 // TEST TABLE |
358 |
317 |
359 EUNIT_BEGIN_TEST_TABLE( |
318 EUNIT_BEGIN_TEST_TABLE( |
360 UT_CMusEngSipProfileHandler, |
319 UT_CMusEngSipProfileHandler, |
361 "UT_CMusEngSipProfileHandler", |
320 "UT_CMusEngSipProfileHandler", |
364 EUNIT_TEST( |
323 EUNIT_TEST( |
365 "CreateSipProfileL - test ", |
324 "CreateSipProfileL - test ", |
366 "CMusSipProfileHandler", |
325 "CMusSipProfileHandler", |
367 "CreateSipProfileL", |
326 "CreateSipProfileL", |
368 "FUNCTIONALITY", |
327 "FUNCTIONALITY", |
369 SetupL, UT_CreateSipProfileLL, Teardown) |
328 SetupL, UT_CMusEngSipProfileHandler_CreateSipProfileLL, Teardown) |
370 |
329 |
371 EUNIT_TEST( |
330 EUNIT_TEST( |
372 "ProfileId - test ", |
331 "ProfileId - test ", |
373 "CMusSipProfileHandler", |
332 "CMusSipProfileHandler", |
374 "ProfileId", |
333 "ProfileId", |
375 "FUNCTIONALITY", |
334 "FUNCTIONALITY", |
376 SetupL, UT_ProfileIdL, Teardown) |
335 SetupL, UT_CMusEngSipProfileHandler_ProfileIdL, Teardown) |
377 |
336 |
378 EUNIT_TEST( |
337 EUNIT_TEST( |
379 "AlrEventL - test ", |
338 "AlrEventL - test ", |
380 "CMusEngSipProfileHandler", |
339 "CMusEngSipProfileHandler", |
381 "AlrEventL", |
340 "AlrEventL", |
382 "FUNCTIONALITY", |
341 "FUNCTIONALITY", |
383 SetupL, UT_AlrEventL, Teardown) |
342 SetupL, UT_CMusEngSipProfileHandler_AlrEventL, Teardown) |
384 |
343 |
385 EUNIT_TEST( |
344 EUNIT_TEST( |
386 "Null tests for NOP functions", |
345 "Null tests for NOP functions", |
387 "CMusEngSipProfileHandler", |
346 "CMusEngSipProfileHandler", |
388 "Several NOP functions", |
347 "Several NOP functions", |
389 "FUNCTIONALITY", |
348 "FUNCTIONALITY", |
390 SetupL, UT_NullTestsL, Teardown) |
349 SetupL, UT_CMusEngSipProfileHandler_NullTestsL, Teardown) |
391 |
350 |
392 EUNIT_TEST( |
351 EUNIT_TEST( |
393 "UserFromProfileLC - test ", |
352 "UserFromProfileLC - test ", |
394 "CMusEngSipProfileHandler", |
353 "CMusEngOutSession", |
395 "UserFromProfileLC", |
354 "UserFromProfileLC", |
396 "FUNCTIONALITY", |
355 "FUNCTIONALITY", |
397 SetupL, UT_UserFromProfileLCL, Teardown) |
356 SetupL, UT_CMusEngSipProfileHandler_UserFromProfileLCL, Teardown) |
398 |
357 |
399 EUNIT_TEST( |
|
400 "IsRegistered - test ", |
|
401 "CMusEngSipProfileHandler", |
|
402 "IsRegistered", |
|
403 "FUNCTIONALITY", |
|
404 SetupL, UT_IsRegisteredL, Teardown) |
|
405 |
|
406 EUNIT_TEST( |
|
407 "ProfileRegistryEventOccurred - test ", |
|
408 "CMusEngSipProfileHandler", |
|
409 "ProfileRegistryEventOccurred", |
|
410 "FUNCTIONALITY", |
|
411 SetupL, UT_ProfileRegistryEventOccurredL, Teardown) |
|
412 |
|
413 EUNIT_END_TEST_TABLE |
358 EUNIT_END_TEST_TABLE |
414 |
359 |
415 // END OF FILE |
360 // END OF FILE |
416 |
361 |
417 |
362 |