summaryrefslogtreecommitdiffstats
path: root/tests/auto/qaction/tst_qaction.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'tests/auto/qaction/tst_qaction.cpp')
-rw-r--r--tests/auto/qaction/tst_qaction.cpp59
1 files changed, 53 insertions, 6 deletions
diff --git a/tests/auto/qaction/tst_qaction.cpp b/tests/auto/qaction/tst_qaction.cpp
index bb7c687..abc5d8d 100644
--- a/tests/auto/qaction/tst_qaction.cpp
+++ b/tests/auto/qaction/tst_qaction.cpp
@@ -75,6 +75,8 @@ private slots:
void alternateShortcuts();
void enabledVisibleInteraction();
void task200823_tooltip();
+ void task229128TriggeredSignalWithoutActiongroup();
+ void task229128TriggeredSignalWhenInActiongroup();
private:
int m_lastEventType;
@@ -103,13 +105,17 @@ void tst_QAction::getSetCheck()
obj1.setMenu((QMenu *)0);
QCOMPARE((QMenu *)0, obj1.menu());
delete var2;
+
+ QCOMPARE(obj1.priority(), QAction::NormalPriority);
+ obj1.setPriority(QAction::LowPriority);
+ QCOMPARE(obj1.priority(), QAction::LowPriority);
}
class MyWidget : public QWidget
{
Q_OBJECT
public:
- MyWidget(tst_QAction *tst, QWidget *parent=0) : QWidget(parent) { this->tst = tst; }
+ MyWidget(tst_QAction *tst, QWidget *parent = 0) : QWidget(parent) { this->tst = tst; }
protected:
virtual void actionEvent(QActionEvent *e) { tst->updateState(e); }
@@ -141,7 +147,7 @@ void tst_QAction::initTestCase()
void tst_QAction::cleanupTestCase()
{
QWidget *testWidget = m_tstWidget;
- if ( testWidget ) {
+ if (testWidget) {
testWidget->hide();
delete testWidget;
}
@@ -189,7 +195,7 @@ void tst_QAction::updateState(QActionEvent *e)
{
if (!e) {
m_lastEventType = 0;
- m_lastAction = 0;
+ m_lastAction = 0;
} else {
m_lastEventType = (int)e->type();
m_lastAction = e->action();
@@ -234,7 +240,7 @@ void tst_QAction::setStandardKeys()
QVERIFY(act.shortcut() == act.shortcuts().first());
QList<QKeySequence> expected;
-#ifdef Q_WS_MAC
+#if defined(Q_WS_MAC) || defined(Q_OS_SYMBIAN)
expected << QKeySequence("CTRL+C");
#elif defined(Q_WS_WIN) || defined(Q_WS_QWS)
expected << QKeySequence("CTRL+C") << QKeySequence("CTRL+INSERT");
@@ -249,12 +255,12 @@ void tst_QAction::alternateShortcuts()
{
//test the alternate shortcuts (by adding more than 1 shortcut)
- QWidget *wid=m_tstWidget;
+ QWidget *wid = m_tstWidget;
{
QAction act(wid);
wid->addAction(&act);
- QList<QKeySequence> shlist= QList<QKeySequence>() << QKeySequence("CTRL+P") <<QKeySequence("CTRL+A");
+ QList<QKeySequence> shlist = QList<QKeySequence>() << QKeySequence("CTRL+P") << QKeySequence("CTRL+A");
act.setShortcuts(shlist);
QSignalSpy spy(&act, SIGNAL(triggered()));
@@ -322,5 +328,46 @@ void tst_QAction::task200823_tooltip()
QCOMPARE(action->toolTip(), ref);
}
+void tst_QAction::task229128TriggeredSignalWithoutActiongroup()
+{
+ // test without a group
+ QAction *actionWithoutGroup = new QAction("Test", qApp);
+ QSignalSpy spyWithoutGroup(actionWithoutGroup, SIGNAL(triggered(bool)));
+ QCOMPARE(spyWithoutGroup.count(), 0);
+ actionWithoutGroup->trigger();
+ // signal should be emitted
+ QCOMPARE(spyWithoutGroup.count(), 1);
+
+ // it is now a checkable checked action
+ actionWithoutGroup->setCheckable(true);
+ actionWithoutGroup->setChecked(true);
+ spyWithoutGroup.clear();
+ QCOMPARE(spyWithoutGroup.count(), 0);
+ actionWithoutGroup->trigger();
+ // signal should be emitted
+ QCOMPARE(spyWithoutGroup.count(), 1);
+}
+
+void tst_QAction::task229128TriggeredSignalWhenInActiongroup()
+{
+ QActionGroup ag(0);
+ QAction *action = new QAction("Test", &ag);
+ QAction *checkedAction = new QAction("Test 2", &ag);
+ ag.addAction(action);
+ action->setCheckable(true);
+ ag.addAction(checkedAction);
+ checkedAction->setCheckable(true);
+ checkedAction->setChecked(true);
+
+ QSignalSpy actionSpy(checkedAction, SIGNAL(triggered(bool)));
+ QSignalSpy actionGroupSpy(&ag, SIGNAL(triggered(QAction *)));
+ QCOMPARE(actionGroupSpy.count(), 0);
+ QCOMPARE(actionSpy.count(), 0);
+ checkedAction->trigger();
+ // check that both the group and the action have emitted the signal
+ QCOMPARE(actionGroupSpy.count(), 1);
+ QCOMPARE(actionSpy.count(), 1);
+}
+
QTEST_MAIN(tst_QAction)
#include "tst_qaction.moc"