|
1 /*! |
|
2 * Copyright (c) 2009 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: Unit tests for Phone Services. |
|
15 * |
|
16 */ |
|
17 |
|
18 #include <QtTest/QtTest> |
|
19 |
|
20 //#include <hbglobal_p.h> |
|
21 #include "phoneservices.h" |
|
22 #include "dialservice.h" |
|
23 #include "dtmfservice.h" |
|
24 #include "keysequencerecognitionservice.h" |
|
25 #include "mpekeysequencerecognitionif.h" |
|
26 |
|
27 bool m_dialServiceConstructed; |
|
28 bool m_dtmfServiceConstructed; |
|
29 bool g_keySequenceServiceConstructed; |
|
30 MPECallControlIF* m_dialServiceCallPointer; |
|
31 MPECallSettersIF* m_dialServiceParameterPointer; |
|
32 MPEKeySequenceRecognitionIF* g_keySequenceRecognizerParameterPointer; |
|
33 MPECallControlIF* m_dtmfServiceCallPointer; |
|
34 MPECallSettersIF* m_dtmfServiceParameterPointer; |
|
35 |
|
36 class TestPhoneServices |
|
37 : |
|
38 public QObject, |
|
39 public MPECallControlIF, |
|
40 public MPECallSettersIF, |
|
41 public MPEKeySequenceRecognitionIF |
|
42 { |
|
43 Q_OBJECT |
|
44 public: |
|
45 TestPhoneServices(); |
|
46 virtual ~TestPhoneServices(); |
|
47 |
|
48 public: |
|
49 TBool ExecuteKeySequenceL(const TDesC16& aSequence); |
|
50 |
|
51 public slots: |
|
52 void initTestCase (); |
|
53 void cleanupTestCase (); |
|
54 void init (); |
|
55 void cleanup (); |
|
56 |
|
57 public: |
|
58 void SetKeyCode( const TChar& aKeyCode ); |
|
59 void SetPhoneNumber( const TPEPhoneNumber& aPhoneNumber ); |
|
60 void SetCallTypeCommand( const TPECallType& aCallType ); |
|
61 TInt HandleDialServiceCall( const TBool aClientCall = EFalse ); |
|
62 void HandlePlayDTMFL(); |
|
63 TInt HandleEndDTMF(); |
|
64 void SetContactId2( const TInt aContactId ); |
|
65 void SetServiceIdCommand( TUint32 aServiceId ); |
|
66 |
|
67 private slots: |
|
68 void testPhoneServiceStartup(); |
|
69 |
|
70 private: |
|
71 PhoneServices *m_phoneServices; // class under test |
|
72 bool m_setPhoneNumberCalled; |
|
73 bool m_setCallTypeCommandCalled; |
|
74 bool m_handleDialCallCalled; |
|
75 TPEPhoneNumber m_phoneNumber; |
|
76 TPECallType m_callType; |
|
77 bool m_clientCall; |
|
78 int m_contactId; |
|
79 bool m_setContactIdCalled; |
|
80 bool m_handleEndDTMFCalled; |
|
81 bool m_handlePlayDTMFLCalled; |
|
82 bool m_setKeyCodeCalled; |
|
83 ushort keyValue; |
|
84 }; |
|
85 |
|
86 DialService::DialService(MPECallControlIF &call, MPECallSettersIF ¶meters, QObject* parent) : |
|
87 XQServiceProvider(QLatin1String("com.nokia.symbian.ICallDial"), parent), m_call (call), m_parameters (parameters) |
|
88 { |
|
89 m_dialServiceConstructed = true; |
|
90 m_dialServiceCallPointer = &call; |
|
91 m_dialServiceParameterPointer = ¶meters; |
|
92 } |
|
93 |
|
94 DialService::~DialService() |
|
95 { |
|
96 } |
|
97 |
|
98 int DialService::dial(const QString& number) |
|
99 { |
|
100 Q_UNUSED(number); |
|
101 return 0; |
|
102 } |
|
103 |
|
104 int DialService::dial(const QString& number, int contactId) |
|
105 { |
|
106 Q_UNUSED(number); |
|
107 Q_UNUSED (contactId); |
|
108 return 0; |
|
109 } |
|
110 |
|
111 void DialService::dialVideo(const QString& number) |
|
112 { |
|
113 Q_UNUSED(number); |
|
114 } |
|
115 |
|
116 void DialService::dialVideo(const QString& number, int contactId) |
|
117 { |
|
118 Q_UNUSED(number); |
|
119 Q_UNUSED(contactId); |
|
120 } |
|
121 |
|
122 void DialService::dialVoip(const QString& address) |
|
123 { |
|
124 Q_UNUSED(address); |
|
125 } |
|
126 |
|
127 void DialService::dialVoip(const QString& address, int contactId) |
|
128 { |
|
129 Q_UNUSED(address); |
|
130 Q_UNUSED(contactId); |
|
131 } |
|
132 |
|
133 void DialService::dialVoipService(const QString& address, int serviceId) |
|
134 { |
|
135 Q_UNUSED(address); |
|
136 Q_UNUSED(serviceId); |
|
137 } |
|
138 |
|
139 void DialService::dialVoipService( |
|
140 const QString& address, int serviceId, int contactId) |
|
141 { |
|
142 Q_UNUSED(address); |
|
143 Q_UNUSED(serviceId); |
|
144 Q_UNUSED(contactId); |
|
145 } |
|
146 |
|
147 DTMFService::DTMFService(MPECallControlIF &call, MPECallSettersIF ¶meters, QObject* parent) : |
|
148 XQServiceProvider(QLatin1String("com.nokia.symbian.IDtmfPlay"), parent), m_call (call), m_parameters (parameters) |
|
149 { |
|
150 m_dtmfServiceConstructed = true; |
|
151 m_dtmfServiceCallPointer = &call; |
|
152 m_dtmfServiceParameterPointer = ¶meters; |
|
153 } |
|
154 |
|
155 DTMFService::~DTMFService() |
|
156 { |
|
157 } |
|
158 |
|
159 void DTMFService::playDTMFTone(const QChar& keyToPlay) |
|
160 { |
|
161 Q_UNUSED(keyToPlay); |
|
162 } |
|
163 |
|
164 void DTMFService::stopDTMFPlay() |
|
165 { |
|
166 } |
|
167 |
|
168 KeySequenceRecognitionService::KeySequenceRecognitionService( |
|
169 MPEKeySequenceRecognitionIF &keySequenceRecognizer, |
|
170 QObject* parent) |
|
171 : |
|
172 XQServiceProvider( |
|
173 QLatin1String("com.nokia.symbian.IDtmfPlay"), parent), |
|
174 m_keySequenceRecognizer(keySequenceRecognizer) |
|
175 { |
|
176 g_keySequenceServiceConstructed = true; |
|
177 g_keySequenceRecognizerParameterPointer = &keySequenceRecognizer; |
|
178 } |
|
179 |
|
180 bool KeySequenceRecognitionService::executeKeySequence( |
|
181 const QString &keySequence) |
|
182 { |
|
183 Q_UNUSED(keySequence); |
|
184 return true; |
|
185 } |
|
186 |
|
187 KeySequenceRecognitionService::~KeySequenceRecognitionService() |
|
188 { |
|
189 } |
|
190 |
|
191 TestPhoneServices::TestPhoneServices () |
|
192 { |
|
193 } |
|
194 |
|
195 TestPhoneServices::~TestPhoneServices () |
|
196 { |
|
197 } |
|
198 |
|
199 void TestPhoneServices::initTestCase () |
|
200 { |
|
201 } |
|
202 |
|
203 void TestPhoneServices::cleanupTestCase () |
|
204 { |
|
205 } |
|
206 |
|
207 void TestPhoneServices::init () |
|
208 { |
|
209 m_setPhoneNumberCalled = false; |
|
210 m_setCallTypeCommandCalled = false; |
|
211 m_handleDialCallCalled = false; |
|
212 m_clientCall = false; |
|
213 m_setContactIdCalled = false; |
|
214 m_contactId = -1; |
|
215 m_handleEndDTMFCalled = false; |
|
216 m_handlePlayDTMFLCalled = false; |
|
217 m_setKeyCodeCalled = false; |
|
218 keyValue = -1; |
|
219 m_dialServiceConstructed = false; |
|
220 m_dtmfServiceConstructed = false; |
|
221 g_keySequenceServiceConstructed = false; |
|
222 |
|
223 m_phoneServices = new PhoneServices (*this, *this, *this, this); |
|
224 |
|
225 QVERIFY(m_dialServiceConstructed == true); |
|
226 QVERIFY(m_dialServiceCallPointer == this); |
|
227 QVERIFY(m_dialServiceParameterPointer == this); |
|
228 |
|
229 QVERIFY(m_dtmfServiceConstructed == true); |
|
230 QVERIFY(m_dtmfServiceCallPointer == this); |
|
231 QVERIFY(m_dtmfServiceParameterPointer == this); |
|
232 |
|
233 QVERIFY(g_keySequenceServiceConstructed == true); |
|
234 QVERIFY(g_keySequenceRecognizerParameterPointer == this); |
|
235 } |
|
236 |
|
237 void TestPhoneServices::cleanup () |
|
238 { |
|
239 delete m_phoneServices; |
|
240 } |
|
241 |
|
242 TBool TestPhoneServices::ExecuteKeySequenceL(const TDesC16& aSequence) |
|
243 { |
|
244 Q_UNUSED(aSequence) |
|
245 return ETrue; |
|
246 } |
|
247 |
|
248 void TestPhoneServices::SetKeyCode( const TChar& aKeyCode ) |
|
249 { |
|
250 m_setKeyCodeCalled = true; |
|
251 keyValue = aKeyCode; |
|
252 } |
|
253 |
|
254 void TestPhoneServices::SetPhoneNumber( const TPEPhoneNumber& aPhoneNumber ) |
|
255 { |
|
256 m_setPhoneNumberCalled = true; |
|
257 m_phoneNumber = aPhoneNumber; |
|
258 } |
|
259 |
|
260 void TestPhoneServices::SetCallTypeCommand( const TPECallType& aCallType ) |
|
261 { |
|
262 m_setCallTypeCommandCalled = true; |
|
263 m_callType = aCallType; |
|
264 } |
|
265 |
|
266 void TestPhoneServices::HandlePlayDTMFL() |
|
267 { |
|
268 m_handlePlayDTMFLCalled = true; |
|
269 } |
|
270 |
|
271 TInt TestPhoneServices::HandleEndDTMF() |
|
272 { |
|
273 m_handleEndDTMFCalled = true; |
|
274 return 0; |
|
275 } |
|
276 |
|
277 void TestPhoneServices::SetContactId2( const TInt aContactId ) |
|
278 { |
|
279 m_setContactIdCalled = true; |
|
280 m_contactId = aContactId; |
|
281 } |
|
282 |
|
283 void TestPhoneServices::SetServiceIdCommand( TUint32 aServiceId ) |
|
284 { |
|
285 Q_UNUSED(aServiceId) |
|
286 } |
|
287 |
|
288 TInt TestPhoneServices::HandleDialServiceCall( const TBool aClientCall ) |
|
289 { |
|
290 m_handleDialCallCalled = true; |
|
291 m_clientCall = aClientCall; |
|
292 return KErrNone; |
|
293 } |
|
294 |
|
295 void TestPhoneServices::testPhoneServiceStartup() |
|
296 { |
|
297 |
|
298 } |
|
299 |
|
300 QTEST_MAIN(TestPhoneServices) |
|
301 #include "unit_tests.moc" |