--- a/tests/auto/qsoftkeymanager/tst_qsoftkeymanager.cpp Tue Jan 26 12:42:25 2010 +0200
+++ b/tests/auto/qsoftkeymanager/tst_qsoftkeymanager.cpp Tue Feb 02 00:43:10 2010 +0200
@@ -47,6 +47,10 @@
#include "qdialogbuttonbox.h"
#include "private/qsoftkeymanager_p.h"
+#ifdef Q_OS_SYMBIAN
+#include "qsymbianevent.h"
+#endif
+
#ifdef Q_WS_S60
static const int s60CommandStart = 6000;
#endif
@@ -69,6 +73,14 @@
void updateSoftKeysCompressed();
void handleCommand();
void checkSoftkeyEnableStates();
+ void noMergingOverWindowBoundary();
+
+private: // utils
+ inline void simulateSymbianCommand(int command)
+ {
+ QSymbianEvent event1(QSymbianEvent::CommandEvent, command);
+ qApp->symbianProcessEvent(&event1);
+ };
};
class EventListener : public QObject
@@ -167,8 +179,8 @@
// QTest::keyPress(&w, Qt::Key_Context1);
// QTest::keyPress(&w, Qt::Key_Context2);
- qApp->symbianHandleCommand(6000);
- qApp->symbianHandleCommand(6001);
+ simulateSymbianCommand(6000);
+ simulateSymbianCommand(6001);
QApplication::processEvents();
@@ -200,9 +212,9 @@
//disabled button gets none.
for (int i = 0; i < 10; i++) {
//simulate "Restore Defaults" softkey press
- qApp->symbianHandleCommand(s60CommandStart);
+ simulateSymbianCommand(s60CommandStart);
//simulate "help" softkey press
- qApp->symbianHandleCommand(s60CommandStart + 1);
+ simulateSymbianCommand(s60CommandStart + 1);
}
QApplication::processEvents();
QCOMPARE(spy0.count(), 10);
@@ -212,16 +224,77 @@
for (int i = 0; i < 10; i++) {
//simulate "Restore Defaults" softkey press
- qApp->symbianHandleCommand(s60CommandStart);
+ simulateSymbianCommand(s60CommandStart);
//simulate "help" softkey press
- qApp->symbianHandleCommand(s60CommandStart + 1);
+ simulateSymbianCommand(s60CommandStart + 1);
//switch enabled button to disabled and vice versa
pBHelp->setEnabled(!pBHelp->isEnabled());
pBDefaults->setEnabled(!pBDefaults->isEnabled());
}
QApplication::processEvents();
QCOMPARE(spy0.count(), 5);
- QCOMPARE(spy1.count(), 5);
+ QCOMPARE(spy1.count(), 5);
+}
+
+/*
+ This tests that the softkeys are not merged over window boundaries. I.e. dialogs
+ don't get softkeys of base widget by default - QTBUG-6163.
+*/
+void tst_QSoftKeyManager::noMergingOverWindowBoundary()
+{
+ // Create base window against which the dialog softkeys will ve verified
+ QWidget base;
+
+ QAction* baseLeft = new QAction(tr("BaseLeft"), &base);
+ baseLeft->setSoftKeyRole(QAction::PositiveSoftKey);
+ base.addAction(baseLeft);
+
+ QAction* baseRight = new QAction(tr("BaseRight"), &base);
+ baseRight->setSoftKeyRole(QAction::NegativeSoftKey);
+ base.addAction(baseRight);
+
+ base.showMaximized();
+ QApplication::processEvents();
+
+ QSignalSpy baseLeftSpy(baseLeft, SIGNAL(triggered()));
+ QSignalSpy baseRightSpy(baseRight, SIGNAL(triggered()));
+
+ //Verify that both base softkeys emit triggered signals
+ simulateSymbianCommand(s60CommandStart);
+ simulateSymbianCommand(s60CommandStart + 1);
+
+ QCOMPARE(baseLeftSpy.count(), 1);
+ QCOMPARE(baseRightSpy.count(), 1);
+ baseLeftSpy.clear();
+ baseRightSpy.clear();
+
+ // Verify that no softkey merging when using dialog without parent
+ QDialog dlg;
+ dlg.show();
+
+ QApplication::processEvents();
+
+ simulateSymbianCommand(s60CommandStart);
+ simulateSymbianCommand(s60CommandStart + 1);
+
+ QCOMPARE(baseLeftSpy.count(), 0);
+ QCOMPARE(baseRightSpy.count(), 0);
+
+ // Ensure base view has focus again
+ dlg.hide();
+ base.showMaximized();
+
+ // Verify that no softkey merging when using dialog with parent
+ QDialog dlg2(&base);
+ dlg2.show();
+
+ QApplication::processEvents();
+
+ simulateSymbianCommand(s60CommandStart);
+ simulateSymbianCommand(s60CommandStart + 1);
+
+ QCOMPARE(baseLeftSpy.count(), 0);
+ QCOMPARE(baseRightSpy.count(), 0);
}
QTEST_MAIN(tst_QSoftKeyManager)