Commit c335097d authored by Lukas Appelhans's avatar Lukas Appelhans

Add test for hooks

parent 8145e098
if(CMAKE_BUILD_TYPE MATCHES debugfull)
ENABLE_TESTING()
#add_definitions(-DDO_AKABEI_TEST)
#General test
set(akabei_test_SRCS
akabeitest.cpp
)
......@@ -13,4 +13,17 @@ if(CMAKE_BUILD_TYPE MATCHES debugfull)
target_link_libraries(akabei_test ${QT_QTTEST_LIBRARY} akabeicore)
add_test(akabei akabei_test)
#Hook test
set(akabei_hook_test_SRCS
akabeihooktest.cpp
)
qt4_wrap_cpp(akabei_hook_test_MOC_SRCS akabeihooktest.h)
add_executable(akabei_hook_test ${akabei_hook_test_SRCS} ${akabei_hook_test_MOC_SRCS})
target_link_libraries(akabei_hook_test ${QT_QTTEST_LIBRARY} akabeicore)
add_test(akabei akabei_hook_test)
endif(CMAKE_BUILD_TYPE MATCHES debugfull)
/* This file is part of the Chakra project
Copyright (C) 2011 Lukas Appelhans
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.
*/
#include "akabeihooktest.h"
#include <QtTest/QtTest>
#include <akabeihook.h>
#include <akabeipackage.h>
#include <akabeibackend.h>
AkabeiHookTest::AkabeiHookTest()
{
}
AkabeiHookTest::~AkabeiHookTest()
{
}
void AkabeiHookTest::simpleTest()
{
QString name = "bla";
QString content = "print 'foo'";
QFile *hFile = new QFile("/tmp/" + name);
hFile->open(QFile::WriteOnly);
hFile->write(content.toAscii());
hFile->close();
Akabei::Hook * hook = Akabei::Backend::instance()->loadHookFromFile(hFile->fileName(), QList<Akabei::Package*>());
QVERIFY(hook->content().simplified() == content);
QVERIFY(hook->name() == name);
QString path = hook->path();
QVERIFY(QFile::exists(path));
QFile * file = new QFile(path);
file->open(QFile::ReadOnly);
QString readContent = QString(file->readAll().data());
QVERIFY(readContent.simplified() == content);
file->close();
}
QTEST_MAIN(AkabeiHookTest)
/* This file is part of the Chakra project
Copyright (C) 2011 Lukas Appelhans
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.
*/
#ifndef AKABEIHOOKTEST_H
#define AKABEIHOOKTEST_H
#include <QtCore/QObject>
class AkabeiHookTest : public QObject
{
Q_OBJECT
public:
AkabeiHookTest();
virtual ~AkabeiHookTest();
private slots:
void simpleTest();
};
#endif // AKABEIHOOKTEST_H
Markdown is supported
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