165 |
177 |
166 // These should work eventually, but do not yet |
178 // These should work eventually, but do not yet |
167 // QTest::keyPress(&w, Qt::Key_Context1); |
179 // QTest::keyPress(&w, Qt::Key_Context1); |
168 // QTest::keyPress(&w, Qt::Key_Context2); |
180 // QTest::keyPress(&w, Qt::Key_Context2); |
169 |
181 |
170 qApp->symbianHandleCommand(6000); |
182 simulateSymbianCommand(6000); |
171 qApp->symbianHandleCommand(6001); |
183 simulateSymbianCommand(6001); |
172 |
184 |
173 QApplication::processEvents(); |
185 QApplication::processEvents(); |
174 |
186 |
175 QCOMPARE(spy0.count(), 1); |
187 QCOMPARE(spy0.count(), 1); |
176 QCOMPARE(spy1.count(), 1); |
188 QCOMPARE(spy1.count(), 1); |
198 |
210 |
199 //Verify that enabled button gets all the action trigger signals and |
211 //Verify that enabled button gets all the action trigger signals and |
200 //disabled button gets none. |
212 //disabled button gets none. |
201 for (int i = 0; i < 10; i++) { |
213 for (int i = 0; i < 10; i++) { |
202 //simulate "Restore Defaults" softkey press |
214 //simulate "Restore Defaults" softkey press |
203 qApp->symbianHandleCommand(s60CommandStart); |
215 simulateSymbianCommand(s60CommandStart); |
204 //simulate "help" softkey press |
216 //simulate "help" softkey press |
205 qApp->symbianHandleCommand(s60CommandStart + 1); |
217 simulateSymbianCommand(s60CommandStart + 1); |
206 } |
218 } |
207 QApplication::processEvents(); |
219 QApplication::processEvents(); |
208 QCOMPARE(spy0.count(), 10); |
220 QCOMPARE(spy0.count(), 10); |
209 QCOMPARE(spy1.count(), 0); |
221 QCOMPARE(spy1.count(), 0); |
210 spy0.clear(); |
222 spy0.clear(); |
211 spy1.clear(); |
223 spy1.clear(); |
212 |
224 |
213 for (int i = 0; i < 10; i++) { |
225 for (int i = 0; i < 10; i++) { |
214 //simulate "Restore Defaults" softkey press |
226 //simulate "Restore Defaults" softkey press |
215 qApp->symbianHandleCommand(s60CommandStart); |
227 simulateSymbianCommand(s60CommandStart); |
216 //simulate "help" softkey press |
228 //simulate "help" softkey press |
217 qApp->symbianHandleCommand(s60CommandStart + 1); |
229 simulateSymbianCommand(s60CommandStart + 1); |
218 //switch enabled button to disabled and vice versa |
230 //switch enabled button to disabled and vice versa |
219 pBHelp->setEnabled(!pBHelp->isEnabled()); |
231 pBHelp->setEnabled(!pBHelp->isEnabled()); |
220 pBDefaults->setEnabled(!pBDefaults->isEnabled()); |
232 pBDefaults->setEnabled(!pBDefaults->isEnabled()); |
221 } |
233 } |
222 QApplication::processEvents(); |
234 QApplication::processEvents(); |
223 QCOMPARE(spy0.count(), 5); |
235 QCOMPARE(spy0.count(), 5); |
224 QCOMPARE(spy1.count(), 5); |
236 QCOMPARE(spy1.count(), 5); |
|
237 } |
|
238 |
|
239 /* |
|
240 This tests that the softkeys are not merged over window boundaries. I.e. dialogs |
|
241 don't get softkeys of base widget by default - QTBUG-6163. |
|
242 */ |
|
243 void tst_QSoftKeyManager::noMergingOverWindowBoundary() |
|
244 { |
|
245 // Create base window against which the dialog softkeys will ve verified |
|
246 QWidget base; |
|
247 |
|
248 QAction* baseLeft = new QAction(tr("BaseLeft"), &base); |
|
249 baseLeft->setSoftKeyRole(QAction::PositiveSoftKey); |
|
250 base.addAction(baseLeft); |
|
251 |
|
252 QAction* baseRight = new QAction(tr("BaseRight"), &base); |
|
253 baseRight->setSoftKeyRole(QAction::NegativeSoftKey); |
|
254 base.addAction(baseRight); |
|
255 |
|
256 base.showMaximized(); |
|
257 QApplication::processEvents(); |
|
258 |
|
259 QSignalSpy baseLeftSpy(baseLeft, SIGNAL(triggered())); |
|
260 QSignalSpy baseRightSpy(baseRight, SIGNAL(triggered())); |
|
261 |
|
262 //Verify that both base softkeys emit triggered signals |
|
263 simulateSymbianCommand(s60CommandStart); |
|
264 simulateSymbianCommand(s60CommandStart + 1); |
|
265 |
|
266 QCOMPARE(baseLeftSpy.count(), 1); |
|
267 QCOMPARE(baseRightSpy.count(), 1); |
|
268 baseLeftSpy.clear(); |
|
269 baseRightSpy.clear(); |
|
270 |
|
271 // Verify that no softkey merging when using dialog without parent |
|
272 QDialog dlg; |
|
273 dlg.show(); |
|
274 |
|
275 QApplication::processEvents(); |
|
276 |
|
277 simulateSymbianCommand(s60CommandStart); |
|
278 simulateSymbianCommand(s60CommandStart + 1); |
|
279 |
|
280 QCOMPARE(baseLeftSpy.count(), 0); |
|
281 QCOMPARE(baseRightSpy.count(), 0); |
|
282 |
|
283 // Ensure base view has focus again |
|
284 dlg.hide(); |
|
285 base.showMaximized(); |
|
286 |
|
287 // Verify that no softkey merging when using dialog with parent |
|
288 QDialog dlg2(&base); |
|
289 dlg2.show(); |
|
290 |
|
291 QApplication::processEvents(); |
|
292 |
|
293 simulateSymbianCommand(s60CommandStart); |
|
294 simulateSymbianCommand(s60CommandStart + 1); |
|
295 |
|
296 QCOMPARE(baseLeftSpy.count(), 0); |
|
297 QCOMPARE(baseRightSpy.count(), 0); |
225 } |
298 } |
226 |
299 |
227 QTEST_MAIN(tst_QSoftKeyManager) |
300 QTEST_MAIN(tst_QSoftKeyManager) |
228 #include "tst_qsoftkeymanager.moc" |
301 #include "tst_qsoftkeymanager.moc" |