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 // CLASS HEADER |
|
20 #include "sipprofile.h" |
|
21 #include "UT_CMusAvaConnectionMonitor.h" |
|
22 #include "musavaavailability.h" |
|
23 #include "muslogger.h" |
|
24 #include "musavaobserver.h" |
|
25 #include "musavaobserverimp.h" |
|
26 #include "musavadefaultimp.h" |
|
27 #include "musavaobserverimp.h" |
|
28 #include "musavasettingsimp.h" |
|
29 #include "musavasharedobject.h" |
|
30 #include "musavasip.h" |
|
31 #include "musavaconnectionMonitorobserverimp.h" |
|
32 #include "mussettingskeys.h" |
|
33 #include "mussettings.h" |
|
34 #include "musavacapabilitytesthelper.h" //remove compilation warning |
|
35 #include "CSipSseTestTls.h" |
|
36 |
|
37 |
|
38 // EXTERNAL INCLUDES |
|
39 #include "sipprofile.h" |
|
40 #include <digia/eunit/eunitmacros.h> |
|
41 #include <e32base.h> |
|
42 #include <sipstrings.h> |
|
43 //#include <telephonyinternalpskeys.h> |
|
44 |
|
45 |
|
46 // INTERNAL INCLUDES |
|
47 #include "musavaconnectionmonitor.h" |
|
48 |
|
49 |
|
50 |
|
51 // CONSTRUCTION |
|
52 UT_CMusAvaConnectionMonitor* UT_CMusAvaConnectionMonitor::NewL() |
|
53 { |
|
54 UT_CMusAvaConnectionMonitor* self = UT_CMusAvaConnectionMonitor::NewLC(); |
|
55 CleanupStack::Pop(); |
|
56 |
|
57 return self; |
|
58 } |
|
59 |
|
60 UT_CMusAvaConnectionMonitor* UT_CMusAvaConnectionMonitor::NewLC() |
|
61 { |
|
62 UT_CMusAvaConnectionMonitor* self = new( ELeave ) UT_CMusAvaConnectionMonitor(); |
|
63 CleanupStack::PushL( self ); |
|
64 |
|
65 self->ConstructL(); |
|
66 |
|
67 return self; |
|
68 } |
|
69 |
|
70 // Destructor (virtual by CBase) |
|
71 UT_CMusAvaConnectionMonitor::~UT_CMusAvaConnectionMonitor() |
|
72 { |
|
73 } |
|
74 |
|
75 // Default constructor |
|
76 UT_CMusAvaConnectionMonitor::UT_CMusAvaConnectionMonitor() |
|
77 { |
|
78 } |
|
79 |
|
80 // Second phase construct |
|
81 void UT_CMusAvaConnectionMonitor::ConstructL() |
|
82 { |
|
83 // The ConstructL from the base class CEUnitTestSuiteClass must be called. |
|
84 // It generates the test case table. |
|
85 CEUnitTestSuiteClass::ConstructL(); |
|
86 } |
|
87 |
|
88 // METHODS |
|
89 |
|
90 |
|
91 |
|
92 void UT_CMusAvaConnectionMonitor::SetupL( ) |
|
93 { |
|
94 SIPStrings::OpenL(); |
|
95 CSipSseTestTls::OpenL(); |
|
96 iSharedObject = CMusAvaSharedObject::GetSingletonL(); |
|
97 iAvaConnectionMonitor = &iSharedObject->ConnectionMonitor(); |
|
98 } |
|
99 |
|
100 void UT_CMusAvaConnectionMonitor::Teardown( ) |
|
101 { |
|
102 CMusAvaSharedObject::DeleteSingleton(); |
|
103 CSipSseTestTls::Close(); |
|
104 SIPStrings::Close(); |
|
105 } |
|
106 |
|
107 void UT_CMusAvaConnectionMonitor::UT_CMusAvaConnectionMonitor_NewLL( ) |
|
108 { |
|
109 EUNIT_ASSERT( ETrue ); |
|
110 } |
|
111 |
|
112 void UT_CMusAvaConnectionMonitor::UT_CMusAvaConnectionMonitor_EventLL() |
|
113 { |
|
114 CConnMonNetworkStatusChange* netStatus = |
|
115 new( ELeave ) CConnMonNetworkStatusChange( 1, EBearerWCDMA ); |
|
116 CleanupStack::PushL( netStatus ); |
|
117 CMMusAvaConnectionMonitorObserverImp* imp1 = CMMusAvaConnectionMonitorObserverImp::NewL(); |
|
118 CleanupStack::PushL( imp1 ); |
|
119 iAvaConnectionMonitor->EventL( *netStatus ); |
|
120 EUNIT_ASSERT( imp1->iConnMonEventBase == NULL ); |
|
121 iAvaConnectionMonitor->AddAdapterL( *imp1 ); |
|
122 iAvaConnectionMonitor->EventL(* netStatus ); |
|
123 EUNIT_ASSERT( &imp1->iConnMonEventBase != NULL ); |
|
124 CMMusAvaConnectionMonitorObserverImp* imp2 = CMMusAvaConnectionMonitorObserverImp::NewL(); |
|
125 CleanupStack::PushL( imp2 ); |
|
126 iAvaConnectionMonitor->AddAdapterL( *imp2 ); |
|
127 iAvaConnectionMonitor->EventL( *netStatus ); |
|
128 EUNIT_ASSERT( &imp1->iConnMonEventBase != NULL ); |
|
129 CleanupStack::PopAndDestroy( imp2 ); |
|
130 CleanupStack::PopAndDestroy( imp1 ); |
|
131 CleanupStack::PopAndDestroy( netStatus ); |
|
132 } |
|
133 |
|
134 void UT_CMusAvaConnectionMonitor::UT_CMusAvaConnectionMonitor_AddAdapterLL() |
|
135 { |
|
136 CMMusAvaConnectionMonitorObserverImp* imp1 = CMMusAvaConnectionMonitorObserverImp::NewL(); |
|
137 CleanupStack::PushL( imp1 ); |
|
138 CMMusAvaConnectionMonitorObserverImp* imp2 = CMMusAvaConnectionMonitorObserverImp::NewL(); |
|
139 CleanupStack::PushL( imp2 ); |
|
140 iAvaConnectionMonitor->AddAdapterL( *imp1 ); |
|
141 iAvaConnectionMonitor->AddAdapterL( *imp2 ); |
|
142 CleanupStack::PopAndDestroy( imp2 ); |
|
143 CleanupStack::PopAndDestroy( imp1 ); |
|
144 } |
|
145 |
|
146 void UT_CMusAvaConnectionMonitor::UT_CMusAvaConnectionMonitor_RemoveAdapterL() |
|
147 { |
|
148 CMMusAvaConnectionMonitorObserverImp* imp1 = CMMusAvaConnectionMonitorObserverImp::NewL(); |
|
149 CleanupStack::PushL( imp1 ); |
|
150 CMMusAvaConnectionMonitorObserverImp* imp2 = CMMusAvaConnectionMonitorObserverImp::NewL(); |
|
151 CleanupStack::PushL( imp2 ); |
|
152 iAvaConnectionMonitor->AddAdapterL( *imp1 ); |
|
153 iAvaConnectionMonitor->AddAdapterL( *imp2 ); |
|
154 iAvaConnectionMonitor->RemoveAdapter( *imp1 ); |
|
155 iAvaConnectionMonitor->RemoveAdapter( *imp2 ); |
|
156 CleanupStack::PopAndDestroy( imp2 ); |
|
157 CleanupStack::PopAndDestroy( imp1 ); |
|
158 } |
|
159 void UT_CMusAvaConnectionMonitor::UT_CMusAvaConnectionMonitor_ConnectionCountL() |
|
160 { |
|
161 iAvaConnectionMonitor->iConnectionMonitor.iConnectionCounter = 10; |
|
162 TUint ret = iAvaConnectionMonitor->ConnectionCount(); |
|
163 EUNIT_ASSERT( ret == 10 ); |
|
164 iAvaConnectionMonitor->iConnectionMonitor.iConnectionCounter = 0; |
|
165 ret = iAvaConnectionMonitor->ConnectionCount(); |
|
166 EUNIT_ASSERT( ret == 0 ); |
|
167 } |
|
168 |
|
169 void UT_CMusAvaConnectionMonitor::UT_CMusAvaConnectionMonitor_ConnectionIDLL() |
|
170 { |
|
171 //No connection |
|
172 iAvaConnectionMonitor->iConnectionMonitor.iConnectionCounter = 0; |
|
173 EUNIT_ASSERT( iAvaConnectionMonitor->ConnectionIDL() == 0 ); |
|
174 //Connection created |
|
175 iAvaConnectionMonitor->iConnectionMonitor.iConnectionCounter = 1; |
|
176 EUNIT_ASSERT( !iAvaConnectionMonitor->ConnectionIDL() ); |
|
177 //Access point found |
|
178 MultimediaSharingSettings::SetSipProfileSettingL( 1 ); |
|
179 EUNIT_ASSERT( iAvaConnectionMonitor->ConnectionIDL() == 0 ); |
|
180 //ConnectionId leavs |
|
181 iAvaConnectionMonitor->iConnectionMonitor.iConnectionInfoError = KErrNotFound; |
|
182 TRAPD( error, iAvaConnectionMonitor->ConnectionIDL() ); |
|
183 if ( error == KErrNoMemory ) User::Leave( error ); |
|
184 EUNIT_ASSERT( error == KErrNotFound ); |
|
185 //Connection ID found |
|
186 iAvaConnectionMonitor->iConnectionMonitor.iConnectionId = 1; |
|
187 iAvaConnectionMonitor->iConnectionMonitor.iConnectionInfoError = KErrNone; |
|
188 EUNIT_ASSERT( iAvaConnectionMonitor->ConnectionIDL() == 0); |
|
189 //IAP doesn't match |
|
190 iAvaConnectionMonitor->iConnectionMonitor.iUintAttributeValue = 3; |
|
191 EUNIT_ASSERT( iAvaConnectionMonitor->ConnectionIDL() == 0 ); |
|
192 //IAP found |
|
193 iAvaConnectionMonitor->iConnectionMonitor.iUintAttributeValue = 1; |
|
194 EUNIT_ASSERT( iAvaConnectionMonitor->ConnectionIDL() ); |
|
195 } |
|
196 |
|
197 void UT_CMusAvaConnectionMonitor::UT_CMusAvaConnectionMonitor_MultimediaSharingAccessPointIDL() |
|
198 { |
|
199 //No profile |
|
200 MultimediaSharingSettings::SetSipProfileSettingL( KErrNotFound ); |
|
201 TInt ret = iAvaConnectionMonitor->MultimediaSharingAccessPointID(); |
|
202 if ( ret != KErrNotFound ) |
|
203 { |
|
204 if ( iSharedObject->MusAvaSip().Profile() ) |
|
205 { |
|
206 TBool val; |
|
207 iSharedObject->MusAvaSip().Profile()->GetParameter( KSIPDefaultProfile, val ); |
|
208 if ( val ) |
|
209 { |
|
210 User::Leave( KErrNoMemory ); |
|
211 } |
|
212 } |
|
213 } |
|
214 else |
|
215 { |
|
216 EUNIT_ASSERT( ret == KErrNotFound ); |
|
217 } |
|
218 MultimediaSharingSettings::SetSipProfileSettingL( 1 ); |
|
219 TRAPD( err, ret = iSharedObject->MusAvaSip().CreateProfileL() ); |
|
220 if ( err == KErrNoMemory || !ret ) |
|
221 { |
|
222 User::Leave( KErrNoMemory ); |
|
223 } |
|
224 //No profile id found |
|
225 iSharedObject->MusAvaSip().Profile()->iTUint32Value = 0; |
|
226 EUNIT_ASSERT( iAvaConnectionMonitor->MultimediaSharingAccessPointID() == 0 ); |
|
227 //Profile id found |
|
228 iSharedObject->MusAvaSip().Profile()->iTUint32Value = 1; |
|
229 EUNIT_ASSERT( iAvaConnectionMonitor->MultimediaSharingAccessPointID() == 1 ); |
|
230 } |
|
231 |
|
232 |
|
233 // TEST TABLE |
|
234 |
|
235 EUNIT_BEGIN_TEST_TABLE( |
|
236 UT_CMusAvaConnectionMonitor, |
|
237 "CMusAvaConnectionMonitor", |
|
238 "UNIT" ) |
|
239 |
|
240 EUNIT_TEST( |
|
241 "NewL - test ", |
|
242 "CMusAvaConnectionMonitor", |
|
243 "NewL", |
|
244 "FUNCTIONALITY", |
|
245 SetupL, UT_CMusAvaConnectionMonitor_NewLL, Teardown) |
|
246 |
|
247 EUNIT_TEST( |
|
248 "EventL - test ", |
|
249 "CMusAvaConnectionMonitor", |
|
250 "EventL", |
|
251 "FUNCTIONALITY", |
|
252 SetupL, UT_CMusAvaConnectionMonitor_EventLL, Teardown) |
|
253 |
|
254 EUNIT_TEST( |
|
255 "AddAdapterL - test ", |
|
256 "CMusAvaConnectionMonitor", |
|
257 "AddAdapterL", |
|
258 "FUNCTIONALITY", |
|
259 SetupL, UT_CMusAvaConnectionMonitor_AddAdapterLL, Teardown) |
|
260 |
|
261 |
|
262 EUNIT_TEST( |
|
263 "RemoveAdapter - test ", |
|
264 "CMusAvaConnectionMonitor", |
|
265 "RemoveAdapter", |
|
266 "FUNCTIONALITY", |
|
267 SetupL, UT_CMusAvaConnectionMonitor_RemoveAdapterL, Teardown) |
|
268 |
|
269 |
|
270 EUNIT_TEST( |
|
271 "ConnectionCount - test ", |
|
272 "CMusAvaConnectionMonitor", |
|
273 "ConnectionCount", |
|
274 "FUNCTIONALITY", |
|
275 SetupL, UT_CMusAvaConnectionMonitor_ConnectionCountL, Teardown) |
|
276 |
|
277 EUNIT_TEST( |
|
278 "ConnectionIDL - test ", |
|
279 "CMusAvaConnectionMonitor", |
|
280 "ConnectionIDL", |
|
281 "FUNCTIONALITY", |
|
282 SetupL, UT_CMusAvaConnectionMonitor_ConnectionIDLL, Teardown) |
|
283 |
|
284 EUNIT_TEST( |
|
285 "MultimediaSharingAccessPointID - test ", |
|
286 "CMusAvaConnectionMonitor", |
|
287 "MultimediaSharingAccessPointID", |
|
288 "FUNCTIONALITY", |
|
289 SetupL, UT_CMusAvaConnectionMonitor_MultimediaSharingAccessPointIDL, Teardown) |
|
290 |
|
291 |
|
292 |
|
293 EUNIT_END_TEST_TABLE |
|
294 |
|
295 // END OF FILE |
|