27 #include <hbinstance.h> |
27 #include <hbinstance.h> |
28 #include <btxqserviceapi.h> |
28 #include <btxqserviceapi.h> |
29 |
29 |
30 #ifdef Q_OS_SYMBIAN |
30 #ifdef Q_OS_SYMBIAN |
31 #include "xqappmgr.h" |
31 #include "xqappmgr.h" |
|
32 #include "xqaiwrequest.h" |
32 #endif |
33 #endif |
33 |
34 |
34 #include "dialpadtest.h" |
35 #include "dialpadtest.h" |
35 #include "dialpadtestutil.h" |
36 #include "dialpadtestutil.h" |
36 #include "dialpadbluetootheventfilter.h" |
37 #include "dialpadbluetootheventfilter.h" |
40 QString mService; |
41 QString mService; |
41 QString mInterface; |
42 QString mInterface; |
42 QString mOperation; |
43 QString mOperation; |
43 bool mEmbedded; |
44 bool mEmbedded; |
44 bool mSendCalled; |
45 bool mSendCalled; |
|
46 bool mSynchronous; |
|
47 bool mSetSynchronousCalled; |
|
48 bool mXQAiwRequestDestructorCalled; |
|
49 bool mEmitOK; |
45 |
50 |
46 #ifdef Q_OS_SYMBIAN |
51 #ifdef Q_OS_SYMBIAN |
47 XQAiwRequest* XQApplicationManager::create(const QString& service, const QString& interface, const QString& operation, bool embedded) |
52 XQAiwRequest* XQApplicationManager::create(const QString& service, const QString& interface, const QString& operation, bool embedded) |
48 { |
53 { |
49 mService = service; |
54 mService = service; |
50 mInterface = interface; |
55 mInterface = interface; |
51 mOperation = operation; |
56 mOperation = operation; |
52 mEmbedded = embedded; |
57 mEmbedded = embedded; |
53 return new XQAiwRequest(); |
58 return new XQAiwRequest(); |
54 } |
59 } |
55 void XQAiwRequest::send() { mSendCalled = true; } |
60 void XQAiwRequest::send() { mSendCalled = true; if(mEmitOK){ QVariant var; emit requestOk(var); }else{ emit requestError(-1, QString("error message")); } } |
|
61 void XQAiwRequest::setSynchronous(bool synchronous) { mSynchronous = synchronous; mSetSynchronousCalled = true; } |
|
62 XQAiwRequest::~XQAiwRequest() { mXQAiwRequestDestructorCalled = true; }; |
56 #endif |
63 #endif |
57 |
64 |
58 // helper class |
65 // helper class |
59 class KeyEventCatcher : public QObject |
66 class KeyEventCatcher : public QObject |
60 { |
67 { |
131 mService = QString(""); |
139 mService = QString(""); |
132 mInterface = QString(""); |
140 mInterface = QString(""); |
133 mOperation = QString(""); |
141 mOperation = QString(""); |
134 mEmbedded = false; |
142 mEmbedded = false; |
135 mSendCalled = false; |
143 mSendCalled = false; |
|
144 mSynchronous = true; |
|
145 mSetSynchronousCalled = false; |
|
146 mXQAiwRequestDestructorCalled = false; |
|
147 mEmitOK = true; |
136 } |
148 } |
137 |
149 |
138 void ut_DialpadBluetoothEventFilter::cleanupTestCase() |
150 void ut_DialpadBluetoothEventFilter::cleanupTestCase() |
139 { |
151 { |
140 delete mDialpad; |
152 delete mDialpad; |
151 QTest::qWait(WAIT_TIME); // delay between tests |
163 QTest::qWait(WAIT_TIME); // delay between tests |
152 } |
164 } |
153 |
165 |
154 void ut_DialpadBluetoothEventFilter::testLongPressAsteriskKey() |
166 void ut_DialpadBluetoothEventFilter::testLongPressAsteriskKey() |
155 { |
167 { |
|
168 // Emit fail from event |
|
169 mEmitOK = false; |
|
170 |
156 mDialpad->openDialpad(); |
171 mDialpad->openDialpad(); |
157 QTest::qWait(2*WAIT_TIME); |
172 QTest::qWait(2*WAIT_TIME); |
158 |
173 |
159 // Basic long press |
174 // Basic long press |
160 mUtil->mouseClickDialpad(Qt::Key_Asterisk, DialpadTestUtil::Press); |
175 mUtil->mouseClickDialpad(Qt::Key_Asterisk, DialpadTestUtil::Press); |
166 |
181 |
167 QCOMPARE(mService, BluetoothServiceName); |
182 QCOMPARE(mService, BluetoothServiceName); |
168 QCOMPARE(mInterface, BluetoothInterfaceTogglePower); |
183 QCOMPARE(mInterface, BluetoothInterfaceTogglePower); |
169 QCOMPARE(mOperation, BluetoothTogglePower); |
184 QCOMPARE(mOperation, BluetoothTogglePower); |
170 QVERIFY(mEmbedded == false); |
185 QVERIFY(mEmbedded == false); |
|
186 QVERIFY(mSetSynchronousCalled == true); |
|
187 QVERIFY(mSynchronous == false); |
171 QVERIFY(mSendCalled == true); |
188 QVERIFY(mSendCalled == true); |
|
189 |
|
190 QTest::qWait(100); |
|
191 QVERIFY(mXQAiwRequestDestructorCalled == true); |
|
192 } |
|
193 |
|
194 void ut_DialpadBluetoothEventFilter::testFailingLongPressAsteriskKey() |
|
195 { |
|
196 mDialpad->openDialpad(); |
|
197 QTest::qWait(2*WAIT_TIME); |
|
198 |
|
199 // Basic long press |
|
200 mUtil->mouseClickDialpad(Qt::Key_Asterisk, DialpadTestUtil::Press); |
|
201 QTest::qWait(2000); |
|
202 mUtil->mouseClickDialpad(Qt::Key_Asterisk, DialpadTestUtil::Release); |
|
203 QTest::qWait(1000); |
|
204 QCOMPARE(mDialpad->editor().text(), QString("")); |
|
205 mDialpad->closeDialpad(); |
|
206 |
|
207 QCOMPARE(mService, BluetoothServiceName); |
|
208 QCOMPARE(mInterface, BluetoothInterfaceTogglePower); |
|
209 QCOMPARE(mOperation, BluetoothTogglePower); |
|
210 QVERIFY(mEmbedded == false); |
|
211 QVERIFY(mSetSynchronousCalled == true); |
|
212 QVERIFY(mSynchronous == false); |
|
213 QVERIFY(mSendCalled == true); |
|
214 |
|
215 QTest::qWait(100); |
|
216 QVERIFY(mXQAiwRequestDestructorCalled == true); |
|
217 |
172 } |
218 } |
173 |
219 |
174 void ut_DialpadBluetoothEventFilter::testShortAndLongPressAsteriskKey() |
220 void ut_DialpadBluetoothEventFilter::testShortAndLongPressAsteriskKey() |
175 { |
221 { |
176 mDialpad->openDialpad(); |
222 mDialpad->openDialpad(); |