Commit c85415cf authored by Volker Krause's avatar Volker Krause
Browse files

Add unit test rig for sample parsing

parent a13f3034
set(analyzer_lib_srcs
core/product.cpp
core/ratioset.cpp
core/sample.cpp
core/schemaentry.cpp
core/schemaentryelement.cpp
core/schemaentrytemplates.cpp
......@@ -29,9 +31,7 @@ set(analyzer_srcs
main.cpp
mainwindow.cpp
numericaggregationmodel.cpp
ratioset.cpp
ratiosetaggregationmodel.cpp
sample.cpp
timeaggregationmodel.cpp
analytics/analyticsview.cpp
......
......@@ -16,7 +16,7 @@
*/
#include "categoryaggregationmodel.h"
#include "sample.h"
#include <core/sample.h>
#include "timeaggregationmodel.h"
#include <QDebug>
......
......@@ -17,10 +17,10 @@
#include "datamodel.h"
#include "ratioset.h"
#include <rest/restapi.h>
#include <rest/restclient.h>
#include "sample.h"
#include <core/ratioset.h>
#include <core/sample.h>
#include <QDebug>
#include <QJsonDocument>
......
......@@ -16,7 +16,7 @@
*/
#include "numericaggregationmodel.h"
#include "sample.h"
#include <core/sample.h>
#include "timeaggregationmodel.h"
using namespace UserFeedback::Analyzer;
......
......@@ -16,8 +16,8 @@
*/
#include "ratiosetaggregationmodel.h"
#include "ratioset.h"
#include "sample.h"
#include <core/ratioset.h>
#include <core/sample.h>
#include "timeaggregationmodel.h"
#include <QSet>
......
......@@ -17,7 +17,7 @@
#include "timeaggregationmodel.h"
#include "datamodel.h"
#include "sample.h"
#include <core/sample.h>
#include <QDebug>
......
......@@ -29,6 +29,10 @@ add_executable(providertest providertest.cpp)
target_link_libraries(providertest UserFeedbackTestUtils UserFeedbackCore Qt5::Gui)
add_test(NAME providertest COMMAND providertest)
add_executable(sampletest sampletest.cpp)
target_link_libraries(sampletest UserFeedbackAnalyzer Qt5::Test)
add_test(NAME sampletest COMMAND sampletest)
set(php_test_srcs
utilstest.php
schemaentrytest.php
......
/*
Copyright (C) 2016 Volker Krause <vkrause@kde.org>
This program is free software; you can redistribute it and/or modify it
under the terms of the GNU Library General Public License as published by
the Free Software Foundation; either version 2 of the License, or (at your
option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public
License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include <core/product.h>
#include <core/sample.h>
#include <core/schemaentrytemplates.h>
#include <QDebug>
#include <QtTest/qtest.h>
#include <QObject>
#include <QStandardPaths>
using namespace UserFeedback::Analyzer;
class SampleTest : public QObject
{
Q_OBJECT
private slots:
void initTestCase()
{
Q_INIT_RESOURCE(schemaentrytemplates);
QStandardPaths::setTestModeEnabled(true);
}
void testFromJson()
{
Product p;
p.setName(QStringLiteral("org.kde.UserFeedback.UnitTestProduct"));
p.setSchema(SchemaEntryTemplates::availableTemplates());
QVERIFY(p.isValid());
auto samples = Sample::fromJson("[]", p);
QVERIFY(samples.isEmpty());
samples = Sample::fromJson(R"([{
"id": 42,
"timestampe": "2016-11-27 16:09:06",
"platform": { "os": "linux", "version": "suse" },
"applicationVersion": { "value": "1.9.84" },
"screens": [ { "width": 1920, "height": 1200 }, { "width": 1920, "height": 1200 } ]
}])", p);
QCOMPARE(samples.size(), 1);
auto s = samples.at(0);
}
};
QTEST_MAIN(SampleTest)
#include "sampletest.moc"
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment