Skip to content
Snippets Groups Projects
Commit 5ecc6bb2 authored by Volker Krause's avatar Volker Krause
Browse files

Use the schema model templates for unit testing the schema model

parent c42efd7a
No related branches found
No related tags found
No related merge requests found
...@@ -2,6 +2,7 @@ set(analyzer_lib_srcs ...@@ -2,6 +2,7 @@ set(analyzer_lib_srcs
core/product.cpp core/product.cpp
core/schemaentry.cpp core/schemaentry.cpp
core/schemaentryelement.cpp core/schemaentryelement.cpp
core/schemaentrytemplates.cpp
core/survey.cpp core/survey.cpp
rest/restapi.cpp rest/restapi.cpp
...@@ -11,6 +12,8 @@ set(analyzer_lib_srcs ...@@ -11,6 +12,8 @@ set(analyzer_lib_srcs
model/productmodel.cpp model/productmodel.cpp
model/schemamodel.cpp model/schemamodel.cpp
model/surveymodel.cpp model/surveymodel.cpp
schemaentrytemplates/schemaentrytemplates.qrc
) )
add_library(UserFeedbackAnalyzer STATIC ${analyzer_lib_srcs}) add_library(UserFeedbackAnalyzer STATIC ${analyzer_lib_srcs})
...@@ -35,11 +38,8 @@ set(analyzer_srcs ...@@ -35,11 +38,8 @@ set(analyzer_srcs
schemaeditor/schemaeditwidget.cpp schemaeditor/schemaeditwidget.cpp
schemaeditor/schemaentryitemeditorfactory.cpp schemaeditor/schemaentryitemeditorfactory.cpp
schemaeditor/schemaentrytemplates.cpp
schemaeditor/schemaentrytypecombobox.cpp schemaeditor/schemaentrytypecombobox.cpp
schemaentrytemplates/schemaentrytemplates.qrc
surveyeditor/surveydialog.cpp surveyeditor/surveydialog.cpp
surveyeditor/surveyeditor.cpp surveyeditor/surveyeditor.cpp
) )
......
...@@ -40,8 +40,6 @@ QVector<SchemaEntry> SchemaEntryTemplates::availableTemplates() ...@@ -40,8 +40,6 @@ QVector<SchemaEntry> SchemaEntryTemplates::availableTemplates()
QDirIterator it(dir, {QStringLiteral("*.json")}, QDir::Files | QDir::Readable); QDirIterator it(dir, {QStringLiteral("*.json")}, QDir::Files | QDir::Readable);
while (it.hasNext()) { while (it.hasNext()) {
const auto fileName = it.next(); const auto fileName = it.next();
qDebug() << fileName;
QFile f(fileName); QFile f(fileName);
if (!f.open(QFile::ReadOnly)) if (!f.open(QFile::ReadOnly))
continue; continue;
......
...@@ -27,6 +27,8 @@ int main(int argc, char** argv) ...@@ -27,6 +27,8 @@ int main(int argc, char** argv)
QCoreApplication::setOrganizationName(QStringLiteral("KDE")); QCoreApplication::setOrganizationName(QStringLiteral("KDE"));
QCoreApplication::setOrganizationDomain(QStringLiteral("kde.org")); QCoreApplication::setOrganizationDomain(QStringLiteral("kde.org"));
Q_INIT_RESOURCE(schemaentrytemplates);
QApplication app(argc, argv); QApplication app(argc, argv);
UserFeedback::Analyzer::MainWindow mainWindow; UserFeedback::Analyzer::MainWindow mainWindow;
......
...@@ -18,11 +18,11 @@ ...@@ -18,11 +18,11 @@
#include "schemaeditwidget.h" #include "schemaeditwidget.h"
#include "ui_schemaeditwidget.h" #include "ui_schemaeditwidget.h"
#include "schemaentryitemeditorfactory.h" #include "schemaentryitemeditorfactory.h"
#include "schemaentrytemplates.h"
#include <model/schemamodel.h> #include <model/schemamodel.h>
#include <rest/restapi.h> #include <rest/restapi.h>
#include <core/product.h> #include <core/product.h>
#include <core/schemaentrytemplates.h>
#include <QDebug> #include <QDebug>
#include <QMenu> #include <QMenu>
......
...@@ -16,6 +16,7 @@ ...@@ -16,6 +16,7 @@
*/ */
#include <model/schemamodel.h> #include <model/schemamodel.h>
#include <core/schemaentrytemplates.h>
#include <3rdparty/qt/modeltest.h> #include <3rdparty/qt/modeltest.h>
...@@ -33,6 +34,7 @@ class SchemaModelTest : public QObject ...@@ -33,6 +34,7 @@ class SchemaModelTest : public QObject
private slots: private slots:
void initTestCase() void initTestCase()
{ {
Q_INIT_RESOURCE(schemaentrytemplates);
QStandardPaths::setTestModeEnabled(true); QStandardPaths::setTestModeEnabled(true);
} }
...@@ -56,6 +58,10 @@ private slots: ...@@ -56,6 +58,10 @@ private slots:
p.setSchema(schema); p.setSchema(schema);
model.setProduct(p); model.setProduct(p);
QCOMPARE(model.rowCount(), schema.size()); QCOMPARE(model.rowCount(), schema.size());
p.setSchema(SchemaEntryTemplates::availableTemplates());
model.setProduct(p);
QVERIFY(model.rowCount() > 0);
} }
}; };
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment