14 * Description: Unit tests for Phone Services. |
14 * Description: Unit tests for Phone Services. |
15 * |
15 * |
16 */ |
16 */ |
17 |
17 |
18 #include <QtTest/QtTest> |
18 #include <QtTest/QtTest> |
19 |
|
20 //#include <hbglobal_p.h> |
|
21 #include "phoneservices.h" |
19 #include "phoneservices.h" |
22 #include "dialservice.h" |
20 #include "dialservice.h" |
23 #include "dtmfservice.h" |
21 #include "dtmfservice.h" |
24 #include "keysequencerecognitionservice.h" |
22 #include "urischemehandlerservice.h" |
25 #include "mpekeysequencerecognitionif.h" |
23 |
26 |
24 bool g_dialServiceConstructed; |
27 bool m_dialServiceConstructed; |
25 MPECallControlIF* g_dialServiceCallPointer; |
28 bool m_dtmfServiceConstructed; |
26 MPECallSettersIF* g_dialServiceParameterPointer; |
29 bool g_keySequenceServiceConstructed; |
27 |
30 MPECallControlIF* m_dialServiceCallPointer; |
28 bool g_dtmfServiceConstructed; |
31 MPECallSettersIF* m_dialServiceParameterPointer; |
29 MPECallControlIF* g_dtmfServiceCallPointer; |
32 MPEKeySequenceRecognitionIF* g_keySequenceRecognizerParameterPointer; |
30 MPECallSettersIF* g_dtmfServiceParameterPointer; |
33 MPECallControlIF* m_dtmfServiceCallPointer; |
31 |
34 MPECallSettersIF* m_dtmfServiceParameterPointer; |
32 bool g_uriSchemeHandlerServiceConstructed; |
|
33 MPECallControlIF* g_uriSchemeServiceCallPointer; |
|
34 MPECallSettersIF* g_uriSchemeServiceParameterPointer; |
35 |
35 |
36 class TestPhoneServices |
36 class TestPhoneServices |
37 : |
37 : |
38 public QObject, |
38 public QObject, |
39 public MPECallControlIF, |
39 public MPECallControlIF, |
40 public MPECallSettersIF, |
40 public MPECallSettersIF |
41 public MPEKeySequenceRecognitionIF |
|
42 { |
41 { |
43 Q_OBJECT |
42 Q_OBJECT |
44 public: |
43 public: |
45 TestPhoneServices(); |
44 TestPhoneServices(); |
46 virtual ~TestPhoneServices(); |
45 virtual ~TestPhoneServices(); |
47 |
46 |
48 public: |
|
49 TBool ExecuteKeySequenceL(const TDesC16& aSequence); |
|
50 |
|
51 public slots: |
47 public slots: |
52 void initTestCase (); |
48 void initTestCase (); |
53 void cleanupTestCase (); |
49 void cleanupTestCase (); |
54 void init (); |
50 void init (); |
55 void cleanup (); |
51 void cleanup (); |
84 }; |
80 }; |
85 |
81 |
86 DialService::DialService(MPECallControlIF &call, MPECallSettersIF ¶meters, QObject* parent) : |
82 DialService::DialService(MPECallControlIF &call, MPECallSettersIF ¶meters, QObject* parent) : |
87 XQServiceProvider(QLatin1String("com.nokia.symbian.ICallDial"), parent), m_call (call), m_parameters (parameters) |
83 XQServiceProvider(QLatin1String("com.nokia.symbian.ICallDial"), parent), m_call (call), m_parameters (parameters) |
88 { |
84 { |
89 m_dialServiceConstructed = true; |
85 g_dialServiceConstructed = true; |
90 m_dialServiceCallPointer = &call; |
86 g_dialServiceCallPointer = &call; |
91 m_dialServiceParameterPointer = ¶meters; |
87 g_dialServiceParameterPointer = ¶meters; |
92 } |
88 } |
93 |
89 |
94 DialService::~DialService() |
90 DialService::~DialService() |
95 { |
91 { |
96 } |
92 } |
97 |
93 |
98 int DialService::dial(const QString& number) |
94 int DialService::dial(const QString& number) |
99 { |
95 { |
100 Q_UNUSED(number); |
96 Q_UNUSED(number) |
101 return 0; |
97 return 0; |
102 } |
98 } |
103 |
99 |
104 int DialService::dial(const QString& number, int contactId) |
100 int DialService::dial(const QString& number, int contactId) |
105 { |
101 { |
106 Q_UNUSED(number); |
102 Q_UNUSED(number) |
107 Q_UNUSED (contactId); |
103 Q_UNUSED (contactId) |
108 return 0; |
104 return 0; |
109 } |
105 } |
110 |
106 |
111 void DialService::dialVideo(const QString& number) |
107 void DialService::dialVideo(const QString& number) |
112 { |
108 { |
113 Q_UNUSED(number); |
109 Q_UNUSED(number) |
114 } |
110 } |
115 |
111 |
116 void DialService::dialVideo(const QString& number, int contactId) |
112 void DialService::dialVideo(const QString& number, int contactId) |
117 { |
113 { |
118 Q_UNUSED(number); |
114 Q_UNUSED(number) |
119 Q_UNUSED(contactId); |
115 Q_UNUSED(contactId) |
120 } |
116 } |
121 |
117 |
122 void DialService::dialVoip(const QString& address) |
118 void DialService::dialVoip(const QString& address) |
123 { |
119 { |
124 Q_UNUSED(address); |
120 Q_UNUSED(address) |
125 } |
121 } |
126 |
122 |
127 void DialService::dialVoip(const QString& address, int contactId) |
123 void DialService::dialVoip(const QString& address, int contactId) |
128 { |
124 { |
129 Q_UNUSED(address); |
125 Q_UNUSED(address) |
130 Q_UNUSED(contactId); |
126 Q_UNUSED(contactId) |
131 } |
127 } |
132 |
128 |
133 void DialService::dialVoipService(const QString& address, int serviceId) |
129 void DialService::dialVoipService(const QString& address, int serviceId) |
134 { |
130 { |
135 Q_UNUSED(address); |
131 Q_UNUSED(address) |
136 Q_UNUSED(serviceId); |
132 Q_UNUSED(serviceId) |
137 } |
133 } |
138 |
134 |
139 void DialService::dialVoipService( |
135 void DialService::dialVoipService( |
140 const QString& address, int serviceId, int contactId) |
136 const QString& address, int serviceId, int contactId) |
141 { |
137 { |
142 Q_UNUSED(address); |
138 Q_UNUSED(address) |
143 Q_UNUSED(serviceId); |
139 Q_UNUSED(serviceId) |
144 Q_UNUSED(contactId); |
140 Q_UNUSED(contactId) |
145 } |
141 } |
146 |
142 |
147 DTMFService::DTMFService(MPECallControlIF &call, MPECallSettersIF ¶meters, QObject* parent) : |
143 DTMFService::DTMFService(MPECallControlIF &call, MPECallSettersIF ¶meters, QObject* parent) : |
148 XQServiceProvider(QLatin1String("com.nokia.symbian.IDtmfPlay"), parent), m_call (call), m_parameters (parameters) |
144 XQServiceProvider(QLatin1String("com.nokia.symbian.IDtmfPlay"), parent), m_call (call), m_parameters (parameters) |
149 { |
145 { |
150 m_dtmfServiceConstructed = true; |
146 g_dtmfServiceConstructed = true; |
151 m_dtmfServiceCallPointer = &call; |
147 g_dtmfServiceCallPointer = &call; |
152 m_dtmfServiceParameterPointer = ¶meters; |
148 g_dtmfServiceParameterPointer = ¶meters; |
153 } |
149 } |
154 |
150 |
155 DTMFService::~DTMFService() |
151 DTMFService::~DTMFService() |
156 { |
152 { |
157 } |
153 } |
158 |
154 |
159 void DTMFService::playDTMFTone(const QChar& keyToPlay) |
155 void DTMFService::playDTMFTone(const QChar& keyToPlay) |
160 { |
156 { |
161 Q_UNUSED(keyToPlay); |
157 Q_UNUSED(keyToPlay) |
162 } |
158 } |
163 |
159 |
164 void DTMFService::stopDTMFPlay() |
160 void DTMFService::stopDTMFPlay() |
165 { |
161 { |
166 } |
162 } |
167 |
163 |
168 KeySequenceRecognitionService::KeySequenceRecognitionService( |
164 UriSchemeHandlerService::UriSchemeHandlerService( |
169 MPEKeySequenceRecognitionIF &keySequenceRecognizer, |
165 MPECallControlIF &call, MPECallSettersIF ¶meters, QObject* parent) |
170 QObject* parent) |
|
171 : |
166 : |
172 XQServiceProvider( |
167 XQServiceProvider( |
173 QLatin1String("com.nokia.symbian.IDtmfPlay"), parent), |
168 QLatin1String("phoneui.com.nokia.symbian.IUriView"), parent), |
174 m_keySequenceRecognizer(keySequenceRecognizer) |
169 m_callControlIf(call), |
175 { |
170 m_callParameters(parameters) |
176 g_keySequenceServiceConstructed = true; |
171 { |
177 g_keySequenceRecognizerParameterPointer = &keySequenceRecognizer; |
172 g_uriSchemeHandlerServiceConstructed = true; |
178 } |
173 g_uriSchemeServiceCallPointer = &call; |
179 |
174 g_uriSchemeServiceParameterPointer = ¶meters; |
180 bool KeySequenceRecognitionService::executeKeySequence( |
175 } |
181 const QString &keySequence) |
176 |
182 { |
177 UriSchemeHandlerService::~UriSchemeHandlerService() |
183 Q_UNUSED(keySequence); |
178 { |
|
179 |
|
180 } |
|
181 |
|
182 bool UriSchemeHandlerService::view(const QString &uri) |
|
183 { |
|
184 Q_UNUSED(uri) |
184 return true; |
185 return true; |
185 } |
|
186 |
|
187 KeySequenceRecognitionService::~KeySequenceRecognitionService() |
|
188 { |
|
189 } |
186 } |
190 |
187 |
191 TestPhoneServices::TestPhoneServices () |
188 TestPhoneServices::TestPhoneServices () |
192 { |
189 { |
193 } |
190 } |
214 m_contactId = -1; |
211 m_contactId = -1; |
215 m_handleEndDTMFCalled = false; |
212 m_handleEndDTMFCalled = false; |
216 m_handlePlayDTMFLCalled = false; |
213 m_handlePlayDTMFLCalled = false; |
217 m_setKeyCodeCalled = false; |
214 m_setKeyCodeCalled = false; |
218 keyValue = -1; |
215 keyValue = -1; |
219 m_dialServiceConstructed = false; |
216 g_dialServiceConstructed = false; |
220 m_dtmfServiceConstructed = false; |
217 g_dtmfServiceConstructed = false; |
221 g_keySequenceServiceConstructed = false; |
218 |
222 |
219 g_uriSchemeHandlerServiceConstructed = false; |
223 m_phoneServices = new PhoneServices (*this, *this, *this, this); |
220 g_uriSchemeServiceCallPointer = NULL; |
224 |
221 g_uriSchemeServiceParameterPointer = NULL; |
225 QVERIFY(m_dialServiceConstructed == true); |
222 |
226 QVERIFY(m_dialServiceCallPointer == this); |
223 m_phoneServices = new PhoneServices(*this, *this, this); |
227 QVERIFY(m_dialServiceParameterPointer == this); |
224 |
228 |
225 QVERIFY(g_dialServiceConstructed == true); |
229 QVERIFY(m_dtmfServiceConstructed == true); |
226 QVERIFY(g_dialServiceCallPointer == this); |
230 QVERIFY(m_dtmfServiceCallPointer == this); |
227 QVERIFY(g_dialServiceParameterPointer == this); |
231 QVERIFY(m_dtmfServiceParameterPointer == this); |
228 |
232 |
229 QVERIFY(g_dtmfServiceConstructed == true); |
233 QVERIFY(g_keySequenceServiceConstructed == true); |
230 QVERIFY(g_dtmfServiceCallPointer == this); |
234 QVERIFY(g_keySequenceRecognizerParameterPointer == this); |
231 QVERIFY(g_dtmfServiceParameterPointer == this); |
|
232 |
|
233 QVERIFY(g_uriSchemeHandlerServiceConstructed == true); |
|
234 QVERIFY(g_uriSchemeServiceCallPointer == this); |
|
235 QVERIFY(g_uriSchemeServiceParameterPointer == this); |
235 } |
236 } |
236 |
237 |
237 void TestPhoneServices::cleanup () |
238 void TestPhoneServices::cleanup () |
238 { |
239 { |
239 delete m_phoneServices; |
240 delete m_phoneServices; |
240 } |
|
241 |
|
242 TBool TestPhoneServices::ExecuteKeySequenceL(const TDesC16& aSequence) |
|
243 { |
|
244 Q_UNUSED(aSequence) |
|
245 return ETrue; |
|
246 } |
241 } |
247 |
242 |
248 void TestPhoneServices::SetKeyCode( const TChar& aKeyCode ) |
243 void TestPhoneServices::SetKeyCode( const TChar& aKeyCode ) |
249 { |
244 { |
250 m_setKeyCodeCalled = true; |
245 m_setKeyCodeCalled = true; |