Permalink
Browse files

Add starter mythsystem unit test.

  • Loading branch information...
daniel-kristjansson committed May 25, 2013
1 parent a385886 commit 368f4155c67618007586bf61b2964e7f7d2ea16a
@@ -73,7 +73,7 @@ typedef enum MythSignal {
// FIXME: _t is not how we name types in MythTV...
typedef QMap<QString, bool> Setting_t;
void ShutdownMythSystem(void);
void MBASE_PUBLIC ShutdownMythSystem(void);
// FIXME: Does MythSystem really need to inherit from QObject?
// we can probably create a private class that inherits
@@ -0,0 +1,3 @@
#include "test_mythsystem.h"
QTEST_APPLESS_MAIN(TestMythSystem)
@@ -0,0 +1,66 @@
/*
* Class TestMythSystem
*
* Copyright (C) Daniel Kristjansson 2013
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include <QtTest/QtTest>
#include <QDir>
#include <iostream>
using namespace std;
#include "mythcorecontext.h"
#include "mythsystem.h"
class TestMythSystem: public QObject
{
Q_OBJECT
private slots:
// called at the beginning of these sets of tests
void initTestCase(void)
{
gCoreContext = new MythCoreContext("bin_version", NULL);
}
// called at the end of these sets of tests
void cleanupTestCase(void)
{
ShutdownMythSystem();
}
// called before each test case
void init(void)
{
}
// called after each test case
void cleanup(void)
{
}
void constructed_command_is_run(void)
{
MythSystem cmd("pwd", kMSStdOut);
cmd.Run();
int ret = cmd.Wait();
QVERIFY(ret == 0);
QVERIFY(QString(cmd.ReadAll()).contains(QDir::currentPath()));
}
};
@@ -0,0 +1,31 @@
include ( ../../../../settings.pro )
QT += xml sql network
contains(QT_VERSION, ^4\\.[0-9]\\..*) {
CONFIG += qtestlib
}
contains(QT_VERSION, ^5\\.[0-9]\\..*) {
QT += testlib
}
TEMPLATE = app
TARGET = test_mythsystem
DEPENDPATH += . ../..
INCLUDEPATH += . ../..
LIBS += -L../.. -lmythbase-$$LIBVERSION
LIBS += -Wl,-rpath,$${PWD}/../..
contains(QMAKE_CXX, "g++") {
QMAKE_CXXFLAGS += -O0 -fprofile-arcs -ftest-coverage
QMAKE_LFLAGS += -fprofile-arcs
}
# Input
HEADERS += test_mythsystem.h
SOURCES += test_mythsystem.cpp
QMAKE_CLEAN += $(TARGET) $(TARGETA) $(TARGETD) $(TARGET0) $(TARGET1) $(TARGET2)
QMAKE_CLEAN += ; rm -f *.gcov *.gcda *.gcno
LIBS += $$EXTRA_LIBS $$LATE_LIBS

0 comments on commit 368f415

Please sign in to comment.