83 void UT_ManufacturerKeySequenceHandler::t_executeKeySequenceDeviceManagerCodes() |
83 void UT_ManufacturerKeySequenceHandler::t_executeKeySequenceDeviceManagerCodes() |
84 { |
84 { |
85 XQAiwInterfaceDescriptor dummyDescriptor; |
85 XQAiwInterfaceDescriptor dummyDescriptor; |
86 QPointer<XQAiwRequest> request = |
86 QPointer<XQAiwRequest> request = |
87 new XQAiwRequest(dummyDescriptor, QString(""), KIsEmbedded); |
87 new XQAiwRequest(dummyDescriptor, QString(""), KIsEmbedded); |
88 EXPECT(XQApplicationManager::create) |
88 EXPECT(XQApplicationManager, create) |
89 .with( |
89 .with( |
90 QString("com.nokia.services"), QString("devicemanager"), |
90 QString("com.nokia.services"), QString("devicemanager"), |
91 QString("showVersionNumber()"), KIsEmbedded) |
91 QString("showVersionNumber()"), KIsEmbedded) |
92 .returns(request.data()); |
92 .returns(request.data()); |
93 EXPECT(XQAiwRequest::send).returns(true); |
93 EXPECT(XQAiwRequest, send).returns(true); |
94 |
94 |
95 bool handled = m_handler->executeKeySequence(KCodeSwVersion); |
95 bool handled = m_handler->executeKeySequence(KCodeSwVersion); |
96 |
96 |
97 QVERIFY(verify()); |
97 QVERIFY(verify()); |
98 emit request->requestOk(QVariant(true)); |
98 emit request->requestOk(QVariant(true)); |
104 void UT_ManufacturerKeySequenceHandler::t_executeKeySequenceFactoryResetCodes() |
104 void UT_ManufacturerKeySequenceHandler::t_executeKeySequenceFactoryResetCodes() |
105 { |
105 { |
106 XQAiwInterfaceDescriptor dummyDescriptor; |
106 XQAiwInterfaceDescriptor dummyDescriptor; |
107 QPointer<XQAiwRequest> request = |
107 QPointer<XQAiwRequest> request = |
108 new XQAiwRequest(dummyDescriptor, QString(""), KIsEmbedded); |
108 new XQAiwRequest(dummyDescriptor, QString(""), KIsEmbedded); |
109 EXPECT(XQApplicationManager::create) |
109 EXPECT(XQApplicationManager, create) |
110 .with( |
110 .with( |
111 QString("com.nokia.symbian"), QString("IFactoryReset"), |
111 QString("com.nokia.symbian"), QString("IFactoryReset"), |
112 QString("showResetUi()"), KIsEmbedded) |
112 QString("showResetUi()"), KIsEmbedded) |
113 .returns(request.data()); |
113 .returns(request.data()); |
114 EXPECT(XQAiwRequest::send).returns(true); |
114 EXPECT(XQAiwRequest, send).returns(true); |
115 |
115 |
116 bool handled = m_handler->executeKeySequence(KCodeActivateRfsNormal); |
116 bool handled = m_handler->executeKeySequence(KCodeActivateRfsNormal); |
117 |
117 |
118 QVERIFY(verify()); |
118 QVERIFY(verify()); |
119 emit request->requestOk(QVariant(true)); |
119 emit request->requestOk(QVariant(true)); |
120 QVERIFY(request.isNull()); |
120 QVERIFY(request.isNull()); |
121 QCOMPARE(handled, true); |
121 QCOMPARE(handled, true); |
122 |
122 |
123 request = new XQAiwRequest(dummyDescriptor, QString(""), KIsEmbedded); |
123 request = new XQAiwRequest(dummyDescriptor, QString(""), KIsEmbedded); |
124 EXPECT(XQApplicationManager::create) |
124 EXPECT(XQApplicationManager, create) |
125 .with( |
125 .with( |
126 QString("com.nokia.symbian"), QString("IFactoryReset"), |
126 QString("com.nokia.symbian"), QString("IFactoryReset"), |
127 QString("showResetUi()"), KIsEmbedded) |
127 QString("showResetUi()"), KIsEmbedded) |
128 .returns(request.data()); |
128 .returns(request.data()); |
129 EXPECT(XQAiwRequest::send).returns(true); |
129 EXPECT(XQAiwRequest, send).returns(true); |
130 |
130 |
131 handled = m_handler->executeKeySequence(KCodeActivateRfsDeep); |
131 handled = m_handler->executeKeySequence(KCodeActivateRfsDeep); |
132 |
132 |
133 QVERIFY(verify()); |
133 QVERIFY(verify()); |
134 emit request->requestOk(QVariant(true)); |
134 emit request->requestOk(QVariant(true)); |
140 void UT_ManufacturerKeySequenceHandler::t_executeKeySequenceBluetoothCodes() |
140 void UT_ManufacturerKeySequenceHandler::t_executeKeySequenceBluetoothCodes() |
141 { |
141 { |
142 XQAiwInterfaceDescriptor dummyDescriptor; |
142 XQAiwInterfaceDescriptor dummyDescriptor; |
143 QPointer<XQAiwRequest> request = |
143 QPointer<XQAiwRequest> request = |
144 new XQAiwRequest(dummyDescriptor, QString(""), KIsEmbedded); |
144 new XQAiwRequest(dummyDescriptor, QString(""), KIsEmbedded); |
145 EXPECT(XQApplicationManager::create) |
145 EXPECT(XQApplicationManager, create) |
146 .with( |
146 .with( |
147 QString("com.nokia.services"), QString("bluetooth"), |
147 QString("com.nokia.services"), QString("bluetooth"), |
148 QString("showBluetoothDeviceAddress()"), KIsEmbedded) |
148 QString("showBluetoothDeviceAddress()"), KIsEmbedded) |
149 .returns(request.data()); |
149 .returns(request.data()); |
150 EXPECT(XQAiwRequest::send).returns(true); |
150 EXPECT(XQAiwRequest, send).returns(true); |
151 |
151 |
152 bool handled = m_handler->executeKeySequence(KCodeBtAddress); |
152 bool handled = m_handler->executeKeySequence(KCodeBtAddress); |
153 |
153 |
154 QVERIFY(verify()); |
154 QVERIFY(verify()); |
155 emit request->requestOk(QVariant(true)); |
155 emit request->requestOk(QVariant(true)); |
156 QVERIFY(request.isNull()); |
156 QVERIFY(request.isNull()); |
157 QCOMPARE(handled, true); |
157 QCOMPARE(handled, true); |
158 |
158 |
159 request = new XQAiwRequest(dummyDescriptor, QString(""), KIsEmbedded); |
159 request = new XQAiwRequest(dummyDescriptor, QString(""), KIsEmbedded); |
160 EXPECT(XQApplicationManager::create) |
160 EXPECT(XQApplicationManager, create) |
161 .with( |
161 .with( |
162 QString("com.nokia.services"), QString("bluetooth"), |
162 QString("com.nokia.services"), QString("bluetooth"), |
163 QString("showBluetoothLoopback()"), KIsEmbedded) |
163 QString("showBluetoothLoopback()"), KIsEmbedded) |
164 .returns(request.data()); |
164 .returns(request.data()); |
165 EXPECT(XQAiwRequest::send).returns(true); |
165 EXPECT(XQAiwRequest, send).returns(true); |
166 |
166 |
167 handled = m_handler->executeKeySequence(KCodeRFLoopback); |
167 handled = m_handler->executeKeySequence(KCodeRFLoopback); |
168 |
168 |
169 QVERIFY(verify()); |
169 QVERIFY(verify()); |
170 emit request->requestOk(QVariant(true)); |
170 emit request->requestOk(QVariant(true)); |
185 { |
185 { |
186 // controlled synchronous Qt Highway error during request processing |
186 // controlled synchronous Qt Highway error during request processing |
187 XQAiwInterfaceDescriptor dummyDescriptor; |
187 XQAiwInterfaceDescriptor dummyDescriptor; |
188 QPointer<XQAiwRequest> request = |
188 QPointer<XQAiwRequest> request = |
189 new XQAiwRequest(dummyDescriptor, QString(""), KIsEmbedded); |
189 new XQAiwRequest(dummyDescriptor, QString(""), KIsEmbedded); |
190 EXPECT(XQApplicationManager::create) |
190 EXPECT(XQApplicationManager, create) |
191 .with( |
191 .with( |
192 QString("com.nokia.services"), QString("devicemanager"), |
192 QString("com.nokia.services"), QString("devicemanager"), |
193 QString("showVersionNumber()"), KIsEmbedded) |
193 QString("showVersionNumber()"), KIsEmbedded) |
194 .returns(request.data()); |
194 .returns(request.data()); |
195 EXPECT(XQAiwRequest::send).returns(false); |
195 EXPECT(XQAiwRequest, send).returns(false); |
196 |
196 |
197 bool handled = m_handler->executeKeySequence(KCodeSwVersion); |
197 bool handled = m_handler->executeKeySequence(KCodeSwVersion); |
198 m_handler->requestError(0, QString("")); |
198 m_handler->requestError(0, QString("")); |
199 |
199 |
200 QVERIFY(verify()); |
200 QVERIFY(verify()); |
201 QVERIFY(request.isNull()); |
201 QVERIFY(request.isNull()); |
202 QCOMPARE(handled, false); |
202 QCOMPARE(handled, false); |
203 |
203 |
204 // controlled asynchronous Qt Highway error during request processing |
204 // controlled asynchronous Qt Highway error during request processing |
205 request = new XQAiwRequest(dummyDescriptor, QString(""), KIsEmbedded); |
205 request = new XQAiwRequest(dummyDescriptor, QString(""), KIsEmbedded); |
206 EXPECT(XQApplicationManager::create) |
206 EXPECT(XQApplicationManager, create) |
207 .with( |
207 .with( |
208 QString("com.nokia.services"), QString("devicemanager"), |
208 QString("com.nokia.services"), QString("devicemanager"), |
209 QString("showVersionNumber()"), KIsEmbedded) |
209 QString("showVersionNumber()"), KIsEmbedded) |
210 .returns(request.data()); |
210 .returns(request.data()); |
211 EXPECT(XQAiwRequest::send).returns(true); |
211 EXPECT(XQAiwRequest, send).returns(true); |
212 |
212 |
213 handled = m_handler->executeKeySequence(KCodeSwVersion); |
213 handled = m_handler->executeKeySequence(KCodeSwVersion); |
214 |
214 |
215 QVERIFY(verify()); |
215 QVERIFY(verify()); |
216 emit request->requestError(0, QString("")); |
216 emit request->requestError(0, QString("")); |
218 // asynchronous errors have to be silently discarded |
218 // asynchronous errors have to be silently discarded |
219 QCOMPARE(handled, true); |
219 QCOMPARE(handled, true); |
220 |
220 |
221 // exception during service request dispatching/send |
221 // exception during service request dispatching/send |
222 request = new XQAiwRequest(dummyDescriptor, QString(""), KIsEmbedded); |
222 request = new XQAiwRequest(dummyDescriptor, QString(""), KIsEmbedded); |
223 EXPECT(XQApplicationManager::create) |
223 EXPECT(XQApplicationManager, create) |
224 .with( |
224 .with( |
225 QString("com.nokia.services"), QString("devicemanager"), |
225 QString("com.nokia.services"), QString("devicemanager"), |
226 QString("showVersionNumber()"), KIsEmbedded) |
226 QString("showVersionNumber()"), KIsEmbedded) |
227 .returns(request.data()); |
227 .returns(request.data()); |
228 EXPECT(XQAiwRequest::send) |
228 EXPECT(XQAiwRequest, send) |
229 .willOnce(invokeWithoutArguments(generateException)); |
229 .willOnce(invokeWithoutArguments(generateException)); |
230 |
230 |
231 int result = 0; |
231 int result = 0; |
232 QT_TRYCATCH_ERROR( |
232 QT_TRYCATCH_ERROR( |
233 result, handled = m_handler->executeKeySequence(KCodeSwVersion)); |
233 result, handled = m_handler->executeKeySequence(KCodeSwVersion)); |
245 void UT_ManufacturerKeySequenceHandler::t_executeKeySequenceSimultaneousRequest() |
245 void UT_ManufacturerKeySequenceHandler::t_executeKeySequenceSimultaneousRequest() |
246 { |
246 { |
247 XQAiwInterfaceDescriptor dummyDescriptor; |
247 XQAiwInterfaceDescriptor dummyDescriptor; |
248 QPointer<XQAiwRequest> request = |
248 QPointer<XQAiwRequest> request = |
249 new XQAiwRequest(dummyDescriptor, QString(""), KIsEmbedded); |
249 new XQAiwRequest(dummyDescriptor, QString(""), KIsEmbedded); |
250 EXPECT(XQApplicationManager::create) |
250 EXPECT(XQApplicationManager, create) |
251 .with( |
251 .with( |
252 QString("com.nokia.services"), QString("devicemanager"), |
252 QString("com.nokia.services"), QString("devicemanager"), |
253 QString("showVersionNumber()"), KIsEmbedded) |
253 QString("showVersionNumber()"), KIsEmbedded) |
254 .returns(request.data()); |
254 .returns(request.data()); |
255 EXPECT(XQAiwRequest::send).returns(true); |
255 EXPECT(XQAiwRequest, send).returns(true); |
256 |
256 |
257 bool handled = m_handler->executeKeySequence(KCodeSwVersion); |
257 bool handled = m_handler->executeKeySequence(KCodeSwVersion); |
258 |
258 |
259 QVERIFY(verify()); |
259 QVERIFY(verify()); |
260 QVERIFY(!request.isNull()); |
260 QVERIFY(!request.isNull()); |
261 QCOMPARE(handled, true); |
261 QCOMPARE(handled, true); |
262 |
262 |
263 // simultaneous request attempt |
263 // simultaneous request attempt |
264 EXPECT(XQApplicationManager::create).times(0); |
264 EXPECT(XQApplicationManager, create).times(0); |
265 EXPECT(XQAiwRequest::send).times(0); |
265 EXPECT(XQAiwRequest, send).times(0); |
266 handled = m_handler->executeKeySequence(KCodeSwVersion); |
266 handled = m_handler->executeKeySequence(KCodeSwVersion); |
267 QCOMPARE(handled, false); |
267 QCOMPARE(handled, false); |
268 } |
268 } |
269 |
269 |
270 QTEST_MAIN_S60(UT_ManufacturerKeySequenceHandler) |
270 QTEST_MAIN_S60(UT_ManufacturerKeySequenceHandler) |