713 QTest::newRow("second accept explicit after add") << 0 << 1 << 1; |
716 QTest::newRow("second accept explicit after add") << 0 << 1 << 1; |
714 QTest::newRow("third accept explicit befare add") << 1 << 2 << 2; |
717 QTest::newRow("third accept explicit befare add") << 1 << 2 << 2; |
715 QTest::newRow("third accept explicit after add") << 0 << 2 << 2; |
718 QTest::newRow("third accept explicit after add") << 0 << 2 << 2; |
716 } |
719 } |
717 |
720 |
|
721 static int softKeyCount(QWidget *widget) |
|
722 { |
|
723 int softkeyCount = 0; |
|
724 QList<QAction *> actions = widget->actions(); |
|
725 foreach (QAction *action, actions) { |
|
726 if (action->softKeyRole() != QAction::NoSoftKey) |
|
727 softkeyCount++; |
|
728 } |
|
729 return softkeyCount; |
|
730 } |
|
731 |
718 void tst_QDialogButtonBox::testS60SoftKeys() |
732 void tst_QDialogButtonBox::testS60SoftKeys() |
719 { |
733 { |
720 #ifdef Q_WS_S60 |
734 #ifdef Q_WS_S60 |
721 QDialog dialog(0); |
735 QDialog dialog(0); |
722 QDialogButtonBox buttonBox(&dialog); |
736 QDialogButtonBox buttonBox(&dialog); |
723 buttonBox.setStandardButtons(QDialogButtonBox::Ok | QDialogButtonBox::Cancel); |
737 buttonBox.setStandardButtons(QDialogButtonBox::Ok | QDialogButtonBox::Cancel); |
724 dialog.show(); |
738 dialog.show(); |
725 |
739 |
726 int softkeyCount = 0; |
740 QCOMPARE( softKeyCount(&dialog), 2); |
727 QList<QAction *> actions = dialog.actions(); |
|
728 foreach (QAction *action, actions) { |
|
729 if (action->softKeyRole() != QAction::NoSoftKey) |
|
730 softkeyCount++; |
|
731 } |
|
732 QCOMPARE( softkeyCount, 2); |
|
733 |
741 |
734 QDialog dialog2(0); |
742 QDialog dialog2(0); |
735 QDialogButtonBox buttonBox2(&dialog2); |
743 QDialogButtonBox buttonBox2(&dialog2); |
736 buttonBox2.setStandardButtons(QDialogButtonBox::Cancel); |
744 buttonBox2.setStandardButtons(QDialogButtonBox::Cancel); |
737 dialog2.show(); |
745 dialog2.show(); |
738 |
746 |
739 int softkeyCount2 = 0; |
747 QCOMPARE( softKeyCount(&dialog2), 1); |
740 QList<QAction *> actions2 = dialog2.actions(); |
748 |
741 foreach (QAction *action, actions2) { |
|
742 if (action->softKeyRole() != QAction::NoSoftKey) |
|
743 softkeyCount2++; |
|
744 } |
|
745 QCOMPARE( softkeyCount2, 1); |
|
746 |
|
747 #else |
749 #else |
748 QSKIP("S60-specific test", SkipAll ); |
750 QSKIP("S60-specific test", SkipAll ); |
749 #endif |
751 #endif |
750 } |
752 } |
|
753 |
|
754 #ifdef QT_SOFTKEYS_ENABLED |
|
755 void tst_QDialogButtonBox::testSoftKeyReparenting() |
|
756 { |
|
757 QDialog dialog; |
|
758 QDialogButtonBox *buttonBox = new QDialogButtonBox; |
|
759 buttonBox->addButton(QDialogButtonBox::Ok); |
|
760 buttonBox->addButton(QDialogButtonBox::Cancel); |
|
761 |
|
762 QCOMPARE(softKeyCount(&dialog), 0); |
|
763 QCOMPARE(softKeyCount(buttonBox), 2); |
|
764 |
|
765 // Were the softkeys re-parented correctly? |
|
766 dialog.setLayout(new QVBoxLayout); |
|
767 dialog.layout()->addWidget(buttonBox); |
|
768 QCOMPARE(softKeyCount(&dialog), 2); |
|
769 QCOMPARE(softKeyCount(buttonBox), 0); |
|
770 |
|
771 // Softkeys are only added to QDialog, not QWidget |
|
772 QWidget *nested = new QWidget; |
|
773 nested->setLayout(new QVBoxLayout); |
|
774 nested->layout()->addWidget(buttonBox); |
|
775 QCOMPARE(softKeyCount(nested), 0); |
|
776 QCOMPARE(softKeyCount(buttonBox), 2); |
|
777 } |
|
778 #endif |
751 |
779 |
752 void tst_QDialogButtonBox::testDefaultButton() |
780 void tst_QDialogButtonBox::testDefaultButton() |
753 { |
781 { |
754 QFETCH(int, whenToSetDefault); |
782 QFETCH(int, whenToSetDefault); |
755 QFETCH(int, buttonToBeDefault); |
783 QFETCH(int, buttonToBeDefault); |