Add checkbox tests

This commit is contained in:
Clemens Manert 2022-04-04 00:43:53 +02:00
parent 08837285a4
commit 79fbe1be2e
No known key found for this signature in database
GPG Key ID: 9197EAE8F85E3A18
5 changed files with 90 additions and 0 deletions

View File

@ -7,6 +7,7 @@ SUBDIRS = \
qmlexport \ qmlexport \
tools \ tools \
support \ support \
tests \
examples \ examples \
playground playground

View File

@ -0,0 +1,11 @@
CONFIG += qskexample
CONFIG += console
CONFIG += testcase
QT += testlib
HEADERS += \
main.h
SOURCES += \
main.cpp

50
tests/checkboxes/main.cpp Normal file
View File

@ -0,0 +1,50 @@
#include "main.h"
#include <QskCheckBox.h>
void CheckBoxTests::init() {
root = new QskControl();
}
void CheckBoxTests::cleanup() {
delete root;
}
void CheckBoxTests::checkbox() {
auto t = new QskCheckBox( root );
QVERIFY( t->isCheckable() );
}
void CheckBoxTests::click() {
auto t = new QskCheckBox( root );
QVERIFY( t->isChecked() == false );
t->click();
QVERIFY( t->isChecked() );
}
void CheckBoxTests::toggle() {
auto t = new QskCheckBox( root );
QVERIFY( t->isChecked() == false );
t->toggle();
QVERIFY( t->isChecked() );
t->toggle();
QVERIFY( t->isChecked() == false );
}
void CheckBoxTests::triState() {
auto t = new QskCheckBox( root );
QVERIFY( t->isChecked() == false );
QVERIFY( t->isTriState() == false );
t->setCheckState( Qt::CheckState::PartiallyChecked );
QVERIFY( t->isChecked() == true );
QVERIFY( t->isTriState() == true );
}
#include "moc_main.cpp"

23
tests/checkboxes/main.h Normal file
View File

@ -0,0 +1,23 @@
#pragma once
#include <qobject.h>
#include <QtTest/QtTest>
class QskControl;
class CheckBoxTests : public QObject
{
Q_OBJECT
QskControl * root;
private Q_SLOTS:
void init();
void cleanup();
void checkbox();
void click();
void toggle();
void triState();
};
QTEST_MAIN(CheckBoxTests)

5
tests/tests.pro Normal file
View File

@ -0,0 +1,5 @@
TEMPLATE = subdirs
SUBDIRS += \
checkboxes