From bcc5404b68b38746c8b00e08f8d5684582fbecc8 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Mikko=20Kein=C3=A4nen?= Date: Sun, 21 Nov 2010 23:41:12 +0200 Subject: [PATCH] First unit test implemented! --- src/dataobjects/emufrontobject.cpp | 2 +- src/db/dbfilepath.cpp | 3 ++- src/debian/changelog | 17 ++++++++++---- testing/EmuFrontTesting/EmuFrontTesting.pro | 34 +++++++++++++++++++++++++++ testing/EmuFrontTesting/main.cpp | 11 +++++++++ testing/EmuFrontTesting/platformtest.cpp | 15 ++++++++++++ testing/EmuFrontTesting/platformtest.h | 16 +++++++++++++ 7 files changed, 92 insertions(+), 6 deletions(-) create mode 100644 testing/EmuFrontTesting/EmuFrontTesting.pro create mode 100644 testing/EmuFrontTesting/main.cpp create mode 100644 testing/EmuFrontTesting/platformtest.cpp create mode 100644 testing/EmuFrontTesting/platformtest.h diff --git a/src/dataobjects/emufrontobject.cpp b/src/dataobjects/emufrontobject.cpp index f3f1774..1b94837 100644 --- a/src/dataobjects/emufrontobject.cpp +++ b/src/dataobjects/emufrontobject.cpp @@ -49,7 +49,7 @@ EmuFrontObject& EmuFrontObject::operator =(const EmuFrontObject &ob) bool EmuFrontObject::operator ==(const EmuFrontObject &sup) { - return (id >= 0 && id == sup.id); + return (id >= 0 && id == sup.id && sup.name == name); } bool EmuFrontObject::operator !=(const EmuFrontObject &sup) diff --git a/src/db/dbfilepath.cpp b/src/db/dbfilepath.cpp index b77d48b..b75ef52 100644 --- a/src/db/dbfilepath.cpp +++ b/src/db/dbfilepath.cpp @@ -112,7 +112,8 @@ bool DbFilePath::deleteDataObject(int id) const QString DbFilePath::constructSelect(QString where) const { - return QString("SELECT filepath.id AS FilePathId, " + return QString("SELECT " + "filepath.id AS FilePathId, " "filepath.name AS Name, " "datetime(filepath.lastscanned, 'unixepoch') AS LastScanned, " "setup.id AS SetupId, " diff --git a/src/debian/changelog b/src/debian/changelog index 52c6268..74ed129 100644 --- a/src/debian/changelog +++ b/src/debian/changelog @@ -1,3 +1,12 @@ +emufront (0.1.8) unstable; urgency=low + + * Fixed a bug in the edit dialog fields: the fields were not cleared + if an object was first edited or added and then add dialog was started. + * Fixed bug in main window: selected platform and media types remain selected + after update button is pressed. + + -- Mikko Keinänen Fri, 20 Nov 2010 23:16:00 +0200 + emufront (0.1.7) unstable; urgency=low * Database file renamed to 'emufront.db.sqlite' @@ -10,7 +19,7 @@ emufront (0.1.7) unstable; urgency=low * The 'last scanned' time stamp is updated for media image paths after scanning - -- Mikko Keinänen Fri, 19 Oct 2010 22:52:00 +0200 + -- Mikko Keinänen Fri, 19 Nov 2010 22:52:00 +0200 emufront (0.1.6) unstable; urgency=low @@ -19,16 +28,16 @@ emufront (0.1.6) unstable; urgency=low * UI update: Label and tooltip to set up configuration editor. * UI update: Added a confirmation dialog to file paths scanning. - -- Mikko Keinänen Tue, 16 Oct 2010 00:18:00 +0200 + -- Mikko Keinänen Tue, 16 Nov 2010 00:18:00 +0200 emufront (0.1.5) unstable; urgency=low * Bug fixed: files were not removed from temporary file directory. - -- Mikko Keinänen Sun, 14 Oct 2010 23:22:21 +0200 + -- Mikko Keinänen Sun, 14 Nov 2010 23:22:21 +0200 emufront (0.1.4) unstable; urgency=low * Initial Official Release. - -- Mikko Keinänen Thu, 13 Oct 2010 22:30:31 +0200 + -- Mikko Keinänen Thu, 13 Nov 2010 22:30:31 +0200 diff --git a/testing/EmuFrontTesting/EmuFrontTesting.pro b/testing/EmuFrontTesting/EmuFrontTesting.pro new file mode 100644 index 0000000..0a3340a --- /dev/null +++ b/testing/EmuFrontTesting/EmuFrontTesting.pro @@ -0,0 +1,34 @@ +#------------------------------------------------- +# +# Project created by QtCreator 2010-11-21T22:52:33 +# +#------------------------------------------------- + +QT += core +QT += testlib +QT -= gui + +#INCLUDEPATH += "../../src/dataobjects" +#include("../../src/emufront.pro") + +#INCLUDEPATH += . "../../src/" +TARGET = EmuFrontTesting +CONFIG += console +CONFIG -= app_bundle + +TEMPLATE = app + + +SOURCES += main.cpp \ + platformtest.cpp \ + ../../src/dataobjects/platform.cpp \ + ../../src/dataobjects/emufrontobject.cpp \ + ../../src/dataobjects/emufrontfileobject.cpp \ + ../../src/dataobjects/emufrontfile.cpp + +HEADERS += \ + platformtest.h \ + ../../src/dataobjects/platform.h \ + ../../src/dataobjects/emufrontobject.h \ + ../../src/dataobjects/emufrontfileobject.h \ + ../../src/dataobjects/emufrontfile.h diff --git a/testing/EmuFrontTesting/main.cpp b/testing/EmuFrontTesting/main.cpp new file mode 100644 index 0000000..5b9a1b1 --- /dev/null +++ b/testing/EmuFrontTesting/main.cpp @@ -0,0 +1,11 @@ +#include "platformtest.h" + +int main(int argc, char *argv[]) +{ + PlatformTest plfTest; + QTest::qExec(&plfTest, argc, argv); + + // More tests here... + + return 0; +} diff --git a/testing/EmuFrontTesting/platformtest.cpp b/testing/EmuFrontTesting/platformtest.cpp new file mode 100644 index 0000000..011d987 --- /dev/null +++ b/testing/EmuFrontTesting/platformtest.cpp @@ -0,0 +1,15 @@ +#include "platformtest.h" +#include "../../src/dataobjects/platform.h" + +/* Platforms are equal if the following fields match: + - id (int) + - name (QString) + - filename (QString) +*/ +void PlatformTest::equals() +{ + Platform p1(1, "testa"); + Platform p2(1, "test"); + // This should return true + QVERIFY(p1 != p2); +} diff --git a/testing/EmuFrontTesting/platformtest.h b/testing/EmuFrontTesting/platformtest.h new file mode 100644 index 0000000..623d598 --- /dev/null +++ b/testing/EmuFrontTesting/platformtest.h @@ -0,0 +1,16 @@ +#ifndef PLATFORMTEST_H +#define PLATFORMTEST_H + +#include +#include + +class PlatformTest : public QObject +{ + Q_OBJECT + +private slots: + void equals(); + +}; + +#endif // PLATFORMTEST_H -- 1.7.9.5