Tests
This commit is contained in:
1 parent
ef8e21db2e
commit
a6016248f8
11 files changed
+529
-252
No files matched your search
@@ -2,9 +2,10 @@
|
||||
#include "dbc_tree_builder.h"
|
||||
#include "dbc_tree_model.h"
|
||||
#include <QAbstractItemModelTester>
|
||||
#include <QGuiApplication>
|
||||
#include <QSignalSpy>
|
||||
#include <QTemporaryFile>
|
||||
#include <QStringList>
|
||||
#include <QTemporaryFile>
|
||||
#include <QtTest>
|
||||
#include <limits>
|
||||
|
||||
@@ -50,8 +51,8 @@ private Q_SLOTS:
|
||||
const QStringList headers = {"Name", "CAN ID", "Payload (bytes)", "Start bit",
|
||||
"Length (bits)", "Byte order", "Signedness", "Unit", "Comment"};
|
||||
for (int column = 0; column < model.columnCount(); ++column) {
|
||||
const auto frameIndex = model.index(0, column);
|
||||
const auto signalIndex = model.index(0, column, parent);
|
||||
const QModelIndex frameIndex = model.index(0, column);
|
||||
const QModelIndex signalIndex = model.index(0, column, parent);
|
||||
QCOMPARE(model.headerData(column, Qt::Horizontal).toString(), headers.at(column));
|
||||
QVERIFY(!model.headerData(column, Qt::Horizontal, Qt::ToolTipRole).isValid());
|
||||
QCOMPARE(model.data(frameIndex, Qt::ToolTipRole).toString(), QString("Frame tooltip"));
|
||||
@@ -66,7 +67,7 @@ private Q_SLOTS:
|
||||
QCOMPARE(model.data(signalIndex, DbcTreeModel::LittleEndianRole).toBool(), false);
|
||||
QCOMPARE(model.data(signalIndex, DbcTreeModel::SignedRole).toBool(), true);
|
||||
QCOMPARE(model.data(signalIndex, DbcTreeModel::UnitRole).toString(), QString("rpm"));
|
||||
const auto descriptions = model.data(signalIndex, DbcTreeModel::ValueDescriptionsRole);
|
||||
const QVariant descriptions = model.data(signalIndex, DbcTreeModel::ValueDescriptionsRole);
|
||||
QVERIFY(descriptions.isValid());
|
||||
QVERIFY(descriptions.toList().isEmpty());
|
||||
QVERIFY(!model.data(frameIndex, Qt::UserRole + 1000).isValid());
|
||||
@@ -203,5 +204,12 @@ private Q_SLOTS:
|
||||
QCOMPARE(resets.count(), 4);
|
||||
}
|
||||
};
|
||||
QTEST_GUILESS_MAIN(ModelTest)
|
||||
int main(int argc, char **argv) {
|
||||
// Model tests need QtGui's metatypes, but do not need a display server.
|
||||
if (qEnvironmentVariableIsEmpty("QT_QPA_PLATFORM"))
|
||||
qputenv("QT_QPA_PLATFORM", "offscreen");
|
||||
QGuiApplication application(argc, argv);
|
||||
ModelTest tests;
|
||||
return QTest::qExec(&tests, argc, argv);
|
||||
}
|
||||
#include "dbc_tree_model_test.moc"
|
||||
Reference in new issue
Block a user