Add QCheckBox test in tst_baseline_widgets
Task-number: QTBUG-99748 Pick-to: 6.3 Change-Id: I45fe3b102fba4dd6a6f8cd08bab5543f12265aa7 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
This commit is contained in:
parent
6442fbafcd
commit
d99714e316
@ -52,6 +52,9 @@ private slots:
|
||||
|
||||
void tst_QDial_data();
|
||||
void tst_QDial();
|
||||
|
||||
void tst_QCheckbox_data();
|
||||
void tst_QCheckbox();
|
||||
};
|
||||
|
||||
void tst_Widgets::tst_QSlider_data()
|
||||
@ -254,6 +257,60 @@ void tst_Widgets::tst_QDial()
|
||||
takeStandardSnapshots();
|
||||
}
|
||||
|
||||
void tst_Widgets::tst_QCheckbox_data()
|
||||
{
|
||||
QTest::addColumn<QString>("text");
|
||||
QTest::addColumn<bool>("hasIcon");
|
||||
QTest::addColumn<bool>("isTriState");
|
||||
|
||||
QTest::newRow("SimpleCheckbox") << "" << false << false;
|
||||
QTest::newRow("SimpleCheckboxWithIcon") << "" << true << false;
|
||||
QTest::newRow("SimpleCheckboxWithText") << "checkBox" << false << false;
|
||||
QTest::newRow("SimpleCheckboxWithTextAndIcon") << "checkBox with icon" << true << false;
|
||||
QTest::newRow("SimpleTristate") << "" << false << true;
|
||||
QTest::newRow("SimpleTristateWithText") << "tristateBox" << false << true;
|
||||
}
|
||||
|
||||
void tst_Widgets::tst_QCheckbox()
|
||||
{
|
||||
QFETCH(QString, text);
|
||||
QFETCH(bool, hasIcon);
|
||||
QFETCH(bool, isTriState);
|
||||
|
||||
QBoxLayout layout(QBoxLayout::TopToBottom);
|
||||
QCheckBox box;
|
||||
box.setTristate(isTriState);
|
||||
|
||||
if (!text.isEmpty())
|
||||
box.setText(text);
|
||||
|
||||
if (hasIcon)
|
||||
box.setIcon(QApplication::style()->standardIcon(QStyle::SP_ComputerIcon));
|
||||
|
||||
layout.addWidget(&box);
|
||||
testWindow()->setLayout(&layout);
|
||||
takeStandardSnapshots();
|
||||
|
||||
do
|
||||
{
|
||||
const Qt::CheckState checkState = box.checkState();
|
||||
const QPoint clickTarget = box.rect().center();
|
||||
|
||||
const std::array titles = {"unChecked", "partiallyChecked", "checked"};
|
||||
const QString snapShotTitle = titles[checkState];
|
||||
|
||||
QTest::mousePress(&box,Qt::MouseButton::LeftButton, Qt::KeyboardModifiers(), clickTarget,0);
|
||||
QVERIFY(box.isDown());
|
||||
QBASELINE_CHECK_DEFERRED(takeSnapshot(), (snapShotTitle + "_pressed").toLocal8Bit().constData());
|
||||
|
||||
QTest::mouseRelease(&box,Qt::MouseButton::LeftButton, Qt::KeyboardModifiers(), clickTarget,0);
|
||||
QVERIFY(!box.isDown());
|
||||
QVERIFY(checkState != box.checkState());
|
||||
QBASELINE_CHECK_DEFERRED(takeSnapshot(), (snapShotTitle + "_released").toLocal8Bit().constData());
|
||||
|
||||
} while (box.checkState() != Qt::Unchecked);
|
||||
}
|
||||
|
||||
#define main _realmain
|
||||
QTEST_MAIN(tst_Widgets)
|
||||
#undef main
|
||||
|
Loading…
x
Reference in New Issue
Block a user