From: Bartosz Szatkowski Date: Tue, 3 Aug 2010 12:31:20 +0000 (+0200) Subject: Added test suit X-Git-Tag: 0.4~114^2~11 X-Git-Url: http://vcs.maemo.org/git/?a=commitdiff_plain;h=f9df891f0705520787fe8b2023545fadec94fa65;p=mdictionary Added test suit --- diff --git a/trunk/tests/mDictionaryTests/CommonDictInterfaceMock.cpp b/trunk/tests/mDictionaryTests/CommonDictInterfaceMock.cpp new file mode 100644 index 0000000..9f414b9 --- /dev/null +++ b/trunk/tests/mDictionaryTests/CommonDictInterfaceMock.cpp @@ -0,0 +1,28 @@ +/******************************************************************************* + + This file is part of mDictionary. + + mDictionary 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 3 of the License, or + (at your option) any later version. + + mDictionary 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 mDictionary. If not, see . + + Copyright 2010 Comarch S.A. + +*******************************************************************************/ + +// Created by Bartosz Szatkowski + + + + +#include "CommonDictInterfaceMock.h" + diff --git a/trunk/tests/mDictionaryTests/CommonDictInterfaceMock.h b/trunk/tests/mDictionaryTests/CommonDictInterfaceMock.h new file mode 100644 index 0000000..232acc9 --- /dev/null +++ b/trunk/tests/mDictionaryTests/CommonDictInterfaceMock.h @@ -0,0 +1,53 @@ +/******************************************************************************* + + This file is part of mDictionary. + + mDictionary 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 3 of the License, or + (at your option) any later version. + + mDictionary 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 mDictionary. If not, see . + + Copyright 2010 Comarch S.A. + +*******************************************************************************/ + +// Created by Bartosz Szatkowski + + + + +#ifndef COMMONDICTINTERFACEMOCK_H +#define COMMONDICTINTERFACEMOCK_H + +#include "../../src/includes/CommonDictInterface.h" + +class CommonDictInterfaceMock : public CommonDictInterface +{ +public: + QString fromv, tov, namev, typev, infoNotev; + bool available; + + QString langFrom () const { return fromv; } + QString langTo() const {return tov;} + QString name() const { return namev;} + QString type() const {return typev;} + QString infoNote() const {return infoNotev;} + QDialog* loadDialog() {return 0;} + QDialog* settingsDialog() {return 0;} + CommonDictInterface* getNew(const Settings *) const { return 0;} + bool isAvailable() const {return available;} + uint hash() const { return namev.length() + 10*typev.length();} + void search(QString word, int limit) {} + void stop() {} + +}; + +#endif // COMMONDICTINTERFACEMOCK_H diff --git a/trunk/tests/mDictionaryTests/mDictionaryTests.pro b/trunk/tests/mDictionaryTests/mDictionaryTests.pro new file mode 100644 index 0000000..cfe9528 --- /dev/null +++ b/trunk/tests/mDictionaryTests/mDictionaryTests.pro @@ -0,0 +1,27 @@ +#------------------------------------------------- +# +# Project created by QtCreator 2010-08-03T13:34:36 +# +#------------------------------------------------- + +QT += testlib core + + +TARGET = tst_Backbone +CONFIG += console +CONFIG -= app_bundle + +TEMPLATE = app + + +SOURCES += tst_Backbone.cpp \ + CommonDictInterfaceMock.cpp \ + ../../src/base/backbone/backbone.cpp +DEFINES += SRCDIR=\\\"$$PWD/\\\" + +HEADERS += \ + CommonDictInterfaceMock.h \ + ../../src/base/backbone/backbone.h \ + ../../src/includes/translation.h \ + ../../src/includes/settings.h \ + ../../src/includes/CommonDictInterface.h diff --git a/trunk/tests/mDictionaryTests/mDictionaryTests.pro.user b/trunk/tests/mDictionaryTests/mDictionaryTests.pro.user new file mode 100644 index 0000000..ef5a8f0 --- /dev/null +++ b/trunk/tests/mDictionaryTests/mDictionaryTests.pro.user @@ -0,0 +1,181 @@ + + + + ProjectExplorer.Project.ActiveTarget + 0 + + + ProjectExplorer.Project.EditorSettings + + UTF-8 + + + + ProjectExplorer.Project.Target.0 + + Desktop + Qt4ProjectManager.Target.DesktopTarget + 0 + 0 + + + QMake + QtProjectManager.QMakeBuildStep + + + + Make + Qt4ProjectManager.MakeStep + false + + + + 2 + + Make + Qt4ProjectManager.MakeStep + true + + clean + + + + 1 + false + + Qt w PATH Debug + Qt4ProjectManager.Qt4BuildConfiguration + 2 + /home/bulislaw/devel/mdictionary/trunk/tests/mDictionaryTests-build-desktop + 3 + 0 + true + + + + QMake + QtProjectManager.QMakeBuildStep + + + + Make + Qt4ProjectManager.MakeStep + false + + + + 2 + + Make + Qt4ProjectManager.MakeStep + true + + clean + + + + 1 + false + + Qt w PATH Release + Qt4ProjectManager.Qt4BuildConfiguration + 0 + /home/bulislaw/devel/mdictionary/trunk/tests/mDictionaryTests-build-desktop + 3 + 0 + true + + + + QMake + QtProjectManager.QMakeBuildStep + + + + Make + Qt4ProjectManager.MakeStep + false + + + + 2 + + Make + Qt4ProjectManager.MakeStep + true + + clean + + + + 1 + false + + Qt 4.6.3 OpenSource Debug + Qt4ProjectManager.Qt4BuildConfiguration + 2 + /home/bulislaw/devel/mdictionary/trunk/tests/mDictionaryTests-build-desktop + 2 + 0 + true + + + + QMake + QtProjectManager.QMakeBuildStep + + + + Make + Qt4ProjectManager.MakeStep + false + + + + 2 + + Make + Qt4ProjectManager.MakeStep + true + + clean + + + + 1 + false + + Qt 4.6.3 OpenSource Release + Qt4ProjectManager.Qt4BuildConfiguration + 0 + /home/bulislaw/devel/mdictionary/trunk/tests/mDictionaryTests-build-desktop + 2 + 0 + true + + 4 + + mDictionaryTests + Qt4ProjectManager.Qt4RunConfiguration + 2 + + mDictionaryTests.pro + false + false + + false + false + + + 1 + + + + ProjectExplorer.Project.TargetCount + 1 + + + ProjectExplorer.Project.Updater.FileVersion + 4 + + diff --git a/trunk/tests/mDictionaryTests/tst_Backbone.cpp b/trunk/tests/mDictionaryTests/tst_Backbone.cpp new file mode 100644 index 0000000..41f90fb --- /dev/null +++ b/trunk/tests/mDictionaryTests/tst_Backbone.cpp @@ -0,0 +1,82 @@ +/******************************************************************************* + + This file is part of mDictionary. + + mDictionary 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 3 of the License, or + (at your option) any later version. + + mDictionary 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 mDictionary. If not, see . + + Copyright 2010 Comarch S.A. + +*******************************************************************************/ + +// Created by Bartosz Szatkowski + + + + +#include +#include +#include +#include "../../src/base/backbone/backbone.h" +#include "CommonDictInterfaceMock.h" + +class BackboneTest : public QObject +{ + Q_OBJECT + + QList dict; + int total; + Backbone* back; +public: + BackboneTest(); + +private Q_SLOTS: + void initTestCase(); + void cleanupTestCase(); + void addDictionaryTest(); +}; + +BackboneTest::BackboneTest() +{ + total = 5; + for(int i = 0; i < total; i++) + dict.push_back(new CommonDictInterfaceMock()); +} + +void BackboneTest::initTestCase() +{ + for(int i = 0; i < total; i++) + dict[i] = new CommonDictInterfaceMock(); + back = new Backbone(); +} + +void BackboneTest::cleanupTestCase() +{ + for(int i = 0; i < total; i++) + delete dict[i]; + delete back; +} + +void BackboneTest::addDictionaryTest() +{ + for(int i = 0; i < total; i++) + back->addDictionary(dict[i]); + QCOMPARE(back->getDictionaries().size(), total); + for(int i = 0; i < total; i++) + QCOMPARE(back->getDictionaries().keys().contains(dict[i]), QBool(true)); + +} + +QTEST_APPLESS_MAIN(BackboneTest); + +#include "tst_Backbone.moc"