2017-08-11 14:47:56 -07:00
|
|
|
#include "test_object_types_rust.h"
|
2017-08-11 12:55:51 -07:00
|
|
|
#include <QTest>
|
|
|
|
#include <QSignalSpy>
|
2017-08-11 14:47:56 -07:00
|
|
|
#include <QDebug>
|
2017-08-11 12:55:51 -07:00
|
|
|
|
|
|
|
class TestRustObject : public QObject
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
private slots:
|
|
|
|
void testConstructor();
|
|
|
|
void testStringGetter();
|
|
|
|
void testStringSetter();
|
|
|
|
};
|
|
|
|
|
|
|
|
void TestRustObject::testConstructor()
|
|
|
|
{
|
|
|
|
Person person;
|
|
|
|
}
|
|
|
|
|
|
|
|
void TestRustObject::testStringGetter()
|
|
|
|
{
|
|
|
|
Person person;
|
|
|
|
person.setUserName("Konqi");
|
|
|
|
}
|
|
|
|
|
|
|
|
void TestRustObject::testStringSetter()
|
|
|
|
{
|
|
|
|
// GIVEN
|
|
|
|
Person person;
|
2017-08-11 14:47:56 -07:00
|
|
|
const QVariant userName(QString("Konqi"));
|
2017-08-11 12:55:51 -07:00
|
|
|
QSignalSpy spy(&person, &Person::userNameChanged);
|
|
|
|
|
|
|
|
// WHEN
|
2017-08-11 14:47:56 -07:00
|
|
|
person.setUserName(userName);
|
2017-08-11 12:55:51 -07:00
|
|
|
|
|
|
|
// THEN
|
|
|
|
QVERIFY(spy.isValid());
|
|
|
|
QCOMPARE(spy.count(), 1);
|
2017-08-11 14:47:56 -07:00
|
|
|
QCOMPARE(person.userName().type(), userName.type());
|
|
|
|
QCOMPARE(person.userName(), userName);
|
2017-08-11 12:55:51 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
QTEST_MAIN(TestRustObject)
|
|
|
|
#include "test_object_types.moc"
|