|
1 /* |
|
2 * Copyright (c) 2005-2006 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: Monitor that observes the status of the current CS call |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #include "ut_muslineeventmonitor.h" |
|
20 #include "muslineeventmonitor.h" |
|
21 #include "muscalleventmonitor.h" |
|
22 #include "muspttcallmonitor.h" |
|
23 |
|
24 //#include "musmanagerstub.h" |
|
25 //#include "muscallmonitorobserver.h" |
|
26 |
|
27 #include <etelmm.h> |
|
28 #include <e32svr.h> |
|
29 #include <mmtsy_names.h> |
|
30 #include <digia/eunit/eunitmacros.h> |
|
31 |
|
32 #ifdef RD_KODIAK_POC |
|
33 #include <CTSYDomainPSKeys.h> |
|
34 #else |
|
35 //just for compilation . we never use this. |
|
36 const TUid KPSUidCtsyCallInformation = {0x102029AC}; |
|
37 const TUint32 KCTsyKodiakPtt = 0x00000003; |
|
38 enum TPSCTsyKodiakPtt |
|
39 { |
|
40 EPSCTsyKodiakPttNotActive, |
|
41 EPSCTsyKodiakPttActive |
|
42 }; |
|
43 #endif |
|
44 |
|
45 #pragma warn_illtokenpasting off |
|
46 |
|
47 // ----------------------------------------------------------------------------- |
|
48 // Symbian two-phase constructor. |
|
49 // ----------------------------------------------------------------------------- |
|
50 // |
|
51 UT_CMusLineEventMonitor* UT_CMusLineEventMonitor::NewLC() |
|
52 { |
|
53 UT_CMusLineEventMonitor* self = new (ELeave) UT_CMusLineEventMonitor(); |
|
54 CleanupStack::PushL( self ); |
|
55 self->ConstructL(); |
|
56 return self; |
|
57 } |
|
58 |
|
59 |
|
60 // ----------------------------------------------------------------------------- |
|
61 // Symbian second-phase constructor. |
|
62 // ----------------------------------------------------------------------------- |
|
63 // |
|
64 void UT_CMusLineEventMonitor::ConstructL() |
|
65 { |
|
66 CEUnitTestSuiteClass::ConstructL(); |
|
67 } |
|
68 |
|
69 |
|
70 // ----------------------------------------------------------------------------- |
|
71 // |
|
72 // ----------------------------------------------------------------------------- |
|
73 // |
|
74 void UT_CMusLineEventMonitor::StatusChanged() |
|
75 { |
|
76 } |
|
77 |
|
78 |
|
79 // ----------------------------------------------------------------------------- |
|
80 // C++ constructor. |
|
81 // ----------------------------------------------------------------------------- |
|
82 // |
|
83 UT_CMusLineEventMonitor::UT_CMusLineEventMonitor() |
|
84 : CEUnitTestSuiteClass() |
|
85 { |
|
86 // nothing |
|
87 } |
|
88 |
|
89 |
|
90 // ----------------------------------------------------------------------------- |
|
91 // C++ destructor. |
|
92 // ----------------------------------------------------------------------------- |
|
93 // |
|
94 UT_CMusLineEventMonitor::~UT_CMusLineEventMonitor() |
|
95 { |
|
96 } |
|
97 |
|
98 // ----------------------------------------------------------------------------- |
|
99 // |
|
100 // ----------------------------------------------------------------------------- |
|
101 // |
|
102 void UT_CMusLineEventMonitor::UT_GetLineL() |
|
103 { |
|
104 RMobileLine& line = iMonitor->GetLine(); |
|
105 |
|
106 // Just check something is returned.. |
|
107 RLine::TCallInfo callInfo; |
|
108 User::LeaveIfError( line.GetCallInfo( 0, callInfo ) ); |
|
109 EUNIT_ASSERT( callInfo.iStatus ); |
|
110 } |
|
111 |
|
112 |
|
113 // ----------------------------------------------------------------------------- |
|
114 // |
|
115 // ----------------------------------------------------------------------------- |
|
116 // |
|
117 void UT_CMusLineEventMonitor::UT_RemoteHoldCountL() |
|
118 { |
|
119 |
|
120 // without any calls |
|
121 EUNIT_ASSERT( iMonitor->RemoteHoldCount() == 0 ) |
|
122 |
|
123 // Local hold |
|
124 _LIT( callname, "MyCall" ); |
|
125 CMusCallEventMonitor* callEventMonitor = |
|
126 CMusCallEventMonitor::NewL( iMonitor->GetLine(), |
|
127 callname, |
|
128 *this ); |
|
129 CleanupStack::PushL( callEventMonitor ); |
|
130 |
|
131 callEventMonitor->iCallEvent = RMobileCall::ELocalHold; |
|
132 iMonitor->iCallEventArray.AppendL( callEventMonitor ); |
|
133 CleanupStack::Pop( callEventMonitor ); |
|
134 EUNIT_ASSERT( iMonitor->RemoteHoldCount() == 0 ) |
|
135 |
|
136 // Remote hold |
|
137 callEventMonitor = CMusCallEventMonitor::NewL( iMonitor->GetLine(), |
|
138 callname, |
|
139 *this ); |
|
140 |
|
141 CleanupStack::PushL( callEventMonitor ); |
|
142 callEventMonitor->iCallEvent = RMobileCall::ERemoteHold; |
|
143 iMonitor->iCallEventArray.AppendL( callEventMonitor ); |
|
144 CleanupStack::Pop( callEventMonitor ); |
|
145 EUNIT_ASSERT( iMonitor->RemoteHoldCount() == 1 ) |
|
146 |
|
147 // Cleanup |
|
148 iMonitor->iCallEventArray.ResetAndDestroy(); |
|
149 |
|
150 } |
|
151 |
|
152 |
|
153 // ----------------------------------------------------------------------------- |
|
154 // |
|
155 // ----------------------------------------------------------------------------- |
|
156 // |
|
157 void UT_CMusLineEventMonitor::UT_RunLL() |
|
158 { |
|
159 |
|
160 //RCall::whatever |
|
161 RTelHelper::SetCallStatus( RMobileCall::EStatusHold ); |
|
162 iMonitor->RunL(); |
|
163 EUNIT_ASSERT_EQUALS( iMonitor->iCallEventArray.Count(), 0 ); |
|
164 iMonitor->Cancel(); |
|
165 |
|
166 //RCall::EStatusConnected |
|
167 RTelHelper::SetCallStatus( RMobileCall::EStatusConnected ); |
|
168 iMonitor->RunL(); |
|
169 EUNIT_ASSERT_EQUALS( iMonitor->iCallEventArray.Count(), 1 ); |
|
170 iMonitor->Cancel(); |
|
171 |
|
172 //RCall::EStatusIdle |
|
173 RTelHelper::SetCallStatus( RMobileCall::EStatusIdle ); |
|
174 iMonitor->RunL(); |
|
175 EUNIT_ASSERT_EQUALS( iMonitor->iCallEventArray.Count(), 0 ); |
|
176 iMonitor->Cancel(); |
|
177 |
|
178 //RCall::EStatusConnected |
|
179 RTelHelper::SetCallStatus( RMobileCall::EStatusConnected ); |
|
180 iMonitor->RunL(); |
|
181 iMonitor->Cancel(); |
|
182 |
|
183 //RCall::EStatusHangingUp |
|
184 RTelHelper::SetCallStatus( RMobileCall::EStatusDisconnecting ); |
|
185 iMonitor->RunL(); |
|
186 EUNIT_ASSERT_EQUALS( iMonitor->iCallEventArray.Count(), 0 ); |
|
187 iMonitor->Cancel(); |
|
188 |
|
189 |
|
190 } |
|
191 |
|
192 |
|
193 // ----------------------------------------------------------------------------- |
|
194 // |
|
195 // ----------------------------------------------------------------------------- |
|
196 // |
|
197 void UT_CMusLineEventMonitor::UT_DoCancelL() |
|
198 { |
|
199 iMonitor->DoCancel(); |
|
200 EUNIT_ASSERT( RTelHelper::GetCalledFunction()== |
|
201 RTelSubSessionBase::ECancelAsyncRequest ) |
|
202 } |
|
203 |
|
204 |
|
205 // ----------------------------------------------------------------------------- |
|
206 // |
|
207 // ----------------------------------------------------------------------------- |
|
208 // |
|
209 void UT_CMusLineEventMonitor::UT_RunErrorL() |
|
210 { |
|
211 EUNIT_ASSERT_EQUALS( iMonitor->RunError( KErrNone ), KErrNone ); |
|
212 // Make sure RunError handles the error compleatly and returns |
|
213 // KErrNone |
|
214 EUNIT_ASSERT( iMonitor->RunError( KErrGeneral ) == KErrNone ); |
|
215 } |
|
216 |
|
217 |
|
218 // ----------------------------------------------------------------------------- |
|
219 // |
|
220 // ----------------------------------------------------------------------------- |
|
221 // |
|
222 void UT_CMusLineEventMonitor::UT_AddCallEventMonitorLL() |
|
223 { |
|
224 RProperty::Set(KPSUidCtsyCallInformation, KCTsyKodiakPtt, |
|
225 EPSCTsyKodiakPttActive ); |
|
226 iMonitor->iPTTCallMonitor->Cancel(); |
|
227 iMonitor->iPTTCallMonitor->RunL(); |
|
228 iMonitor->iPTTCallMonitor->Cancel(); |
|
229 // Add first call |
|
230 _LIT( KCallName, "FirstCall" ); |
|
231 iMonitor->AddCallEventMonitorL( KCallName() ); |
|
232 EUNIT_ASSERT_EQUALS( iMonitor->iCallEventArray.Count(), 1 ); |
|
233 |
|
234 // Trying add same call again |
|
235 iMonitor->AddCallEventMonitorL( KCallName() ); |
|
236 EUNIT_ASSERT_EQUALS( iMonitor->iCallEventArray.Count(), 1 ); |
|
237 |
|
238 // Add second call |
|
239 _LIT( KCallName2, "SecondCall" ); |
|
240 iMonitor->AddCallEventMonitorL( KCallName2() ); |
|
241 EUNIT_ASSERT_EQUALS( iMonitor->iCallEventArray.Count(), 2 ); |
|
242 |
|
243 RProperty::Set(KPSUidCtsyCallInformation, KCTsyKodiakPtt, |
|
244 EPSCTsyKodiakPttNotActive ); |
|
245 iMonitor->iPTTCallMonitor->RunL(); |
|
246 iMonitor->iPTTCallMonitor->Cancel(); |
|
247 // Add first call |
|
248 iMonitor->AddCallEventMonitorL( KCallName() ); |
|
249 EUNIT_ASSERT_EQUALS( iMonitor->iCallEventArray.Count(), 0 ); |
|
250 } |
|
251 |
|
252 // ----------------------------------------------------------------------------- |
|
253 // |
|
254 // ----------------------------------------------------------------------------- |
|
255 // |
|
256 void UT_CMusLineEventMonitor::UT_RemoveCallEventMonitorLL() |
|
257 { |
|
258 |
|
259 // Precondition add call |
|
260 _LIT( KCallName, "FirstCall" ); |
|
261 iMonitor->AddCallEventMonitorL( KCallName() ); |
|
262 EUNIT_ASSERT_EQUALS( iMonitor->iCallEventArray.Count(), 1 ); |
|
263 |
|
264 _LIT( KCallName2, "SecondCall" ); |
|
265 iMonitor->AddCallEventMonitorL( KCallName2() ); |
|
266 EUNIT_ASSERT_EQUALS( iMonitor->iCallEventArray.Count(), 2 ); |
|
267 |
|
268 // Remove call with wrong name |
|
269 _LIT( KCallName3, "ThirdCall" ); |
|
270 iMonitor->RemoveCallEventMonitorL( KCallName3() ); |
|
271 EUNIT_ASSERT_EQUALS( iMonitor->iCallEventArray.Count(), 2 ); |
|
272 |
|
273 // Remove second call remove |
|
274 iMonitor->RemoveCallEventMonitorL( KCallName2() ); |
|
275 EUNIT_ASSERT_EQUALS( iMonitor->iCallEventArray.Count(), 1 ); |
|
276 |
|
277 // Remove added call |
|
278 iMonitor->RemoveCallEventMonitorL( KCallName() ); |
|
279 EUNIT_ASSERT_EQUALS( iMonitor->iCallEventArray.Count(), 0 ); |
|
280 |
|
281 // Trying overload remove |
|
282 iMonitor->RemoveCallEventMonitorL( KCallName() ); |
|
283 EUNIT_ASSERT_EQUALS( iMonitor->iCallEventArray.Count(), 0 ); |
|
284 |
|
285 } |
|
286 |
|
287 |
|
288 // ----------------------------------------------------------------------------- |
|
289 // |
|
290 // ----------------------------------------------------------------------------- |
|
291 // |
|
292 void UT_CMusLineEventMonitor::SetupL() |
|
293 { |
|
294 RMobilePhone phone; |
|
295 iMonitor = CMusLineEventMonitor::NewL( phone, *this ); |
|
296 iMonitor->Cancel(); |
|
297 } |
|
298 |
|
299 |
|
300 // ----------------------------------------------------------------------------- |
|
301 // |
|
302 // ----------------------------------------------------------------------------- |
|
303 // |
|
304 void UT_CMusLineEventMonitor::Teardown() |
|
305 { |
|
306 delete iMonitor; |
|
307 } |
|
308 |
|
309 // test table |
|
310 |
|
311 EUNIT_BEGIN_TEST_TABLE( |
|
312 UT_CMusLineEventMonitor, |
|
313 "UT_CMusLineEventMonitor", |
|
314 "UNIT" ) |
|
315 |
|
316 EUNIT_TEST( |
|
317 "GetLine - test", |
|
318 "CMusAoCallMonitor", |
|
319 "GetLine", |
|
320 "FUNCTIONALITY", |
|
321 SetupL, UT_GetLineL, Teardown) |
|
322 |
|
323 EUNIT_TEST( |
|
324 "RemoteHoldCount - test", |
|
325 "CMusAoCallMonitor", |
|
326 "RemoteHoldCount", |
|
327 "FUNCTIONALITY", |
|
328 SetupL, UT_RemoteHoldCountL, Teardown) |
|
329 |
|
330 EUNIT_TEST( |
|
331 "RunL - test", |
|
332 "CMusAoCallMonitor", |
|
333 "RunL", |
|
334 "FUNCTIONALITY", |
|
335 SetupL, UT_RunLL, Teardown) |
|
336 |
|
337 EUNIT_TEST( |
|
338 "DoCancel - test", |
|
339 "CMusAoCallMonitor", |
|
340 "DoCancel", |
|
341 "FUNCTIONALITY", |
|
342 SetupL, UT_DoCancelL, Teardown) |
|
343 |
|
344 EUNIT_TEST( |
|
345 "RunError - test", |
|
346 "CMusAoCallMonitor", |
|
347 "RunError", |
|
348 "FUNCTIONALITY", |
|
349 SetupL, UT_RunErrorL, Teardown) |
|
350 |
|
351 EUNIT_TEST( |
|
352 "AddCallEventMonitorL - test", |
|
353 "CMusAoCallMonitor", |
|
354 "AddCallEventMonitorL", |
|
355 "FUNCTIONALITY", |
|
356 SetupL, UT_AddCallEventMonitorLL, Teardown) |
|
357 |
|
358 EUNIT_TEST( |
|
359 "RemoveCallEventMonitorL - test", |
|
360 "CMusAoCallMonitor", |
|
361 "RemoveCallEventMonitorL", |
|
362 "FUNCTIONALITY", |
|
363 SetupL, UT_RemoveCallEventMonitorLL, Teardown) |
|
364 |
|
365 |
|
366 |
|
367 |
|
368 |
|
369 EUNIT_END_TEST_TABLE |