rust-qt-binding-generator/tests/test_objects.cpp

71 lines
1.5 KiB
C++
Raw Normal View History

2017-08-26 10:10:18 -07:00
#include "test_objects_rust.h"
#include <QTest>
#include <QSignalSpy>
class TestRustObjects : public QObject
{
Q_OBJECT
private slots:
void testOneLevelConstructor();
void testOneLevelStringGetter();
void testOneLevelStringSetter();
void testTwoLevelsConstructor();
void testTwoLevelsStringGetter();
void testTwoLevelsStringSetter();
2017-08-26 10:10:18 -07:00
};
void TestRustObjects::testOneLevelConstructor()
2017-08-26 10:10:18 -07:00
{
Person person;
}
void TestRustObjects::testOneLevelStringGetter()
2017-08-26 10:10:18 -07:00
{
Person person;
person.object()->setDescription("Konqi");
}
void TestRustObjects::testOneLevelStringSetter()
2017-08-26 10:10:18 -07:00
{
// GIVEN
Person person;
QSignalSpy spy(person.object(), &InnerObject::descriptionChanged);
// WHEN
person.object()->setDescription("Konqi");
// THEN
QVERIFY(spy.isValid());
QCOMPARE(spy.count(), 1);
QCOMPARE(person.object()->description(), QString("Konqi"));
}
void TestRustObjects::testTwoLevelsConstructor()
{
Group group;
}
void TestRustObjects::testTwoLevelsStringGetter()
{
Group group;
group.person()->object()->setDescription("Konqi");
}
void TestRustObjects::testTwoLevelsStringSetter()
{
// GIVEN
Group group;
QSignalSpy spy(group.person()->object(), &InnerObject::descriptionChanged);
// WHEN
group.person()->object()->setDescription("Konqi");
// THEN
QVERIFY(spy.isValid());
QCOMPARE(spy.count(), 1);
QCOMPARE(group.person()->object()->description(), QString("Konqi"));
}
2017-08-26 10:10:18 -07:00
QTEST_MAIN(TestRustObjects)
#include "test_objects.moc"