From ff9e685cc4e6daa83e48cc94816de1be65751567 Mon Sep 17 00:00:00 2001 From: Clemens Manert Date: Tue, 26 Apr 2022 21:54:02 +0200 Subject: [PATCH] Add TristateCheckBox tests --- tests/tests.pro | 2 + tests/tristatecheckbox/TristateCheckBox.cpp | 55 +++++++++++++++++++++ tests/tristatecheckbox/TristateCheckBox.h | 22 +++++++++ tests/tristatecheckbox/tristatecheckbox.pro | 12 +++++ 4 files changed, 91 insertions(+) create mode 100644 tests/tristatecheckbox/TristateCheckBox.cpp create mode 100644 tests/tristatecheckbox/TristateCheckBox.h create mode 100644 tests/tristatecheckbox/tristatecheckbox.pro diff --git a/tests/tests.pro b/tests/tests.pro index 566e1725..5d3a0adf 100644 --- a/tests/tests.pro +++ b/tests/tests.pro @@ -1,2 +1,4 @@ TEMPLATE = subdirs +SUBDIRS += \ + tristatecheckbox diff --git a/tests/tristatecheckbox/TristateCheckBox.cpp b/tests/tristatecheckbox/TristateCheckBox.cpp new file mode 100644 index 00000000..dddfd290 --- /dev/null +++ b/tests/tristatecheckbox/TristateCheckBox.cpp @@ -0,0 +1,55 @@ +#include "TristateCheckBox.h" + +#include + +void TristateCheckBox::init() +{ + root = new QskControl(); +} + +void TristateCheckBox::cleanup() +{ + delete root; +} + +void TristateCheckBox::checkbox() +{ + auto t = new QskTristateCheckBox( root ); + + QVERIFY( t->isCheckable() ); +} + +void TristateCheckBox::click() +{ + auto t = new QskTristateCheckBox( root ); + + QVERIFY( t->isChecked() == false ); + t->click(); + QVERIFY( t->isChecked() ); +} + +void TristateCheckBox::toggle() +{ + auto t = new QskTristateCheckBox( root ); + + QVERIFY( t->isChecked() == false ); + t->toggle(); + QVERIFY( t->isChecked() ); + + t->toggle(); + QVERIFY( t->isChecked() == false ); +} + +void TristateCheckBox::tristate() +{ + auto t = new QskTristateCheckBox( root ); + + QVERIFY( t->isChecked() == false ); + + t->setCheckState( Qt::CheckState::PartiallyChecked ); + + QVERIFY( t->isChecked() == true ); +} + +#include "moc_TristateCheckBox.cpp" + diff --git a/tests/tristatecheckbox/TristateCheckBox.h b/tests/tristatecheckbox/TristateCheckBox.h new file mode 100644 index 00000000..73d982e0 --- /dev/null +++ b/tests/tristatecheckbox/TristateCheckBox.h @@ -0,0 +1,22 @@ +#pragma once + +#include +#include + +class QskControl; +class TristateCheckBox : public QObject +{ + Q_OBJECT + + QskControl * root; + private Q_SLOTS: + void init(); + void cleanup(); + + void checkbox(); + void click(); + void toggle(); + void tristate(); +}; + +QTEST_MAIN(TristateCheckBox) diff --git a/tests/tristatecheckbox/tristatecheckbox.pro b/tests/tristatecheckbox/tristatecheckbox.pro new file mode 100644 index 00000000..70d3104f --- /dev/null +++ b/tests/tristatecheckbox/tristatecheckbox.pro @@ -0,0 +1,12 @@ +CONFIG += qskexample +CONFIG += console +CONFIG += testcase + +QT += testlib + +HEADERS += \ + TristateCheckBox.h + +SOURCES += \ + TristateCheckBox.cpp +