|
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_musaocalleventmonitor.h" |
|
20 #include "musaocalleventmonitor.h" |
|
21 #include "mussesseioninformationapi.h" |
|
22 |
|
23 /* |
|
24 #include "muscallmonitor.h" |
|
25 #include "muscalleventmonitor.h" |
|
26 #include "musaoplugin.h" |
|
27 #include "ut_muscalleventmonitor.h" |
|
28 #include "mussesseioninformationapi.h" |
|
29 */ |
|
30 |
|
31 #include <etelmm.h> |
|
32 #include <etel.h> |
|
33 #include <digia/eunit/eunitmacros.h> |
|
34 #include <e32property.h> |
|
35 |
|
36 |
|
37 #pragma warn_illtokenpasting off |
|
38 |
|
39 _LIT( KEmptyTelNumber, ""); |
|
40 |
|
41 |
|
42 // ----------------------------------------------------------------------------- |
|
43 // Symbian two-phase constructor. |
|
44 // ----------------------------------------------------------------------------- |
|
45 // |
|
46 UT_CMusAoCallEventMonitor* UT_CMusAoCallEventMonitor::NewLC() |
|
47 { |
|
48 UT_CMusAoCallEventMonitor* self = new (ELeave) UT_CMusAoCallEventMonitor(); |
|
49 CleanupStack::PushL( self ); |
|
50 self->ConstructL(); |
|
51 return self; |
|
52 } |
|
53 |
|
54 |
|
55 // ----------------------------------------------------------------------------- |
|
56 // Symbian second-phase constructor. |
|
57 // ----------------------------------------------------------------------------- |
|
58 // |
|
59 void UT_CMusAoCallEventMonitor::ConstructL() |
|
60 { |
|
61 CEUnitTestSuiteClass::ConstructL(); |
|
62 } |
|
63 |
|
64 |
|
65 // ----------------------------------------------------------------------------- |
|
66 // |
|
67 // ----------------------------------------------------------------------------- |
|
68 // |
|
69 void UT_CMusAoCallEventMonitor::CallConnectedL( const TDesC& /*aTelNumber*/ ) |
|
70 { |
|
71 iCallConnected = ETrue; |
|
72 } |
|
73 |
|
74 |
|
75 // ----------------------------------------------------------------------------- |
|
76 // |
|
77 // ----------------------------------------------------------------------------- |
|
78 // |
|
79 void UT_CMusAoCallEventMonitor::CallHoldL( const TDesC& /*aTelNumber*/ ) |
|
80 { |
|
81 iCallHold = ETrue; |
|
82 } |
|
83 |
|
84 |
|
85 // ----------------------------------------------------------------------------- |
|
86 // |
|
87 // ----------------------------------------------------------------------------- |
|
88 // |
|
89 void UT_CMusAoCallEventMonitor::ConferenceCallL() |
|
90 { |
|
91 iConferenceCall = ETrue; |
|
92 } |
|
93 |
|
94 |
|
95 // ----------------------------------------------------------------------------- |
|
96 // |
|
97 // ----------------------------------------------------------------------------- |
|
98 // |
|
99 void UT_CMusAoCallEventMonitor::NoActiveCallL() |
|
100 { |
|
101 iNoActiveCall = ETrue; |
|
102 } |
|
103 |
|
104 |
|
105 // ----------------------------------------------------------------------------- |
|
106 // C++ constructor. |
|
107 // ----------------------------------------------------------------------------- |
|
108 // |
|
109 UT_CMusAoCallEventMonitor::UT_CMusAoCallEventMonitor() |
|
110 : CEUnitTestSuiteClass() |
|
111 { |
|
112 // nothing |
|
113 } |
|
114 |
|
115 |
|
116 // ----------------------------------------------------------------------------- |
|
117 // C++ destructor. |
|
118 // ----------------------------------------------------------------------------- |
|
119 // |
|
120 UT_CMusAoCallEventMonitor::~UT_CMusAoCallEventMonitor() |
|
121 { |
|
122 } |
|
123 |
|
124 |
|
125 // ----------------------------------------------------------------------------- |
|
126 // |
|
127 // ----------------------------------------------------------------------------- |
|
128 // |
|
129 void UT_CMusAoCallEventMonitor::UT_ConnectedCallCountLL() |
|
130 { |
|
131 iMonitor->iCallCount = 2; |
|
132 iMonitor->ConnectedCallCountL(); |
|
133 EUNIT_ASSERT_EQUALS( iMonitor->ConnectedCallCountL(), 2); |
|
134 } |
|
135 |
|
136 |
|
137 // ----------------------------------------------------------------------------- |
|
138 // |
|
139 // ----------------------------------------------------------------------------- |
|
140 // |
|
141 void UT_CMusAoCallEventMonitor::UT_RunLL() |
|
142 { |
|
143 ResetObserverFlags(); |
|
144 iMonitor->RunL(); |
|
145 iMonitor->Cancel(); |
|
146 EUNIT_ASSERT( iNoActiveCall ); |
|
147 } |
|
148 |
|
149 |
|
150 // ----------------------------------------------------------------------------- |
|
151 // |
|
152 // ----------------------------------------------------------------------------- |
|
153 // |
|
154 void UT_CMusAoCallEventMonitor::UT_ExamineEventLL() |
|
155 { |
|
156 |
|
157 ResetObserverFlags(); |
|
158 iMonitor->ExamineEventL( NMusSessionInformationApi::ENoCall ); |
|
159 EUNIT_ASSERT( iNoActiveCall ) |
|
160 |
|
161 ResetObserverFlags(); |
|
162 iMonitor->ExamineEventL( NMusSessionInformationApi::EConferenceCall ); |
|
163 EUNIT_ASSERT( iConferenceCall ) |
|
164 |
|
165 // Without telephony number |
|
166 ResetObserverFlags(); |
|
167 iMonitor->ExamineEventL( NMusSessionInformationApi::ECallConnected ); |
|
168 EUNIT_ASSERT( iNoActiveCall ) |
|
169 |
|
170 ResetObserverFlags(); |
|
171 iMonitor->ExamineEventL( NMusSessionInformationApi::ECallHold ); |
|
172 EUNIT_ASSERT( iNoActiveCall ) |
|
173 |
|
174 |
|
175 // 6. telephone number |
|
176 RProperty::Define( NMusSessionInformationApi::KCategoryUid, |
|
177 NMusSessionInformationApi::KMusTelNumber, |
|
178 RProperty::EText, |
|
179 0 ); |
|
180 User::LeaveIfError( RProperty::Set( |
|
181 NMusSessionInformationApi::KCategoryUid, |
|
182 NMusSessionInformationApi::KMusTelNumber, |
|
183 KEmptyTelNumber ) ); |
|
184 |
|
185 |
|
186 // With telephony number |
|
187 ResetObserverFlags(); |
|
188 iMonitor->ExamineEventL( NMusSessionInformationApi::ECallConnected ); |
|
189 EUNIT_ASSERT( iCallConnected ) |
|
190 |
|
191 ResetObserverFlags(); |
|
192 iMonitor->ExamineEventL( NMusSessionInformationApi::ECallHold ); |
|
193 EUNIT_ASSERT( iCallHold ) |
|
194 |
|
195 // 6. telephone number |
|
196 RProperty::Delete( NMusSessionInformationApi::KCategoryUid, |
|
197 NMusSessionInformationApi::KMusTelNumber ); |
|
198 |
|
199 RProperty::Delete( NMusSessionInformationApi::KCategoryUid, |
|
200 NMusSessionInformationApi::KMusCallCount ); |
|
201 |
|
202 |
|
203 // 7. call count |
|
204 RProperty::Define( NMusSessionInformationApi::KCategoryUid, |
|
205 NMusSessionInformationApi::KMusCallCount, |
|
206 RProperty::EInt, |
|
207 0 ); |
|
208 ResetObserverFlags(); |
|
209 iMonitor->ExamineEventL( KErrNotFound ); |
|
210 EUNIT_ASSERT( iNoActiveCall ); |
|
211 |
|
212 // 7. call count |
|
213 RProperty::Delete( NMusSessionInformationApi::KCategoryUid, |
|
214 NMusSessionInformationApi::KMusCallCount ); |
|
215 |
|
216 } |
|
217 |
|
218 |
|
219 // ----------------------------------------------------------------------------- |
|
220 // |
|
221 // ----------------------------------------------------------------------------- |
|
222 // |
|
223 void UT_CMusAoCallEventMonitor::SetupL() |
|
224 { |
|
225 RMobilePhone phone; |
|
226 iMonitor = CMusAoCallEventMonitor::NewL( *this ); |
|
227 iMonitor->Cancel(); |
|
228 |
|
229 |
|
230 } |
|
231 |
|
232 |
|
233 // ----------------------------------------------------------------------------- |
|
234 // |
|
235 // ----------------------------------------------------------------------------- |
|
236 // |
|
237 void UT_CMusAoCallEventMonitor::Teardown() |
|
238 { |
|
239 delete iMonitor; |
|
240 } |
|
241 |
|
242 |
|
243 // ----------------------------------------------------------------------------- |
|
244 // |
|
245 // ----------------------------------------------------------------------------- |
|
246 // |
|
247 void UT_CMusAoCallEventMonitor::ResetObserverFlags() |
|
248 { |
|
249 iCallConnected = EFalse; |
|
250 iCallHold = EFalse; |
|
251 iConferenceCall = EFalse; |
|
252 iNoActiveCall = EFalse; |
|
253 } |
|
254 |
|
255 |
|
256 // test table |
|
257 |
|
258 EUNIT_BEGIN_TEST_TABLE( |
|
259 UT_CMusAoCallEventMonitor, |
|
260 "UT_CMusAoCallEventMonitor", |
|
261 "UNIT" ) |
|
262 |
|
263 EUNIT_TEST( |
|
264 "UT_ConnectedCallCountL", |
|
265 "CMusCallEventMonitor", |
|
266 "ConnectedCallCountL", |
|
267 "FUNCTIONALITY", |
|
268 SetupL, UT_ConnectedCallCountLL, Teardown) |
|
269 |
|
270 EUNIT_TEST( |
|
271 "UT_RunL", |
|
272 "CMusCallEventMonitor", |
|
273 "RunL", |
|
274 "FUNCTIONALITY", |
|
275 SetupL, UT_RunLL, Teardown) |
|
276 |
|
277 EUNIT_TEST( |
|
278 "UT_ExamineEventL", |
|
279 "CMusCallEventMonitor", |
|
280 "ExamineEventL", |
|
281 "FUNCTIONALITY", |
|
282 SetupL, UT_ExamineEventLL, Teardown) |
|
283 |
|
284 |
|
285 EUNIT_END_TEST_TABLE |