a = dictionaryReader.readElementText();
if(regWord.exactMatch(a) && i<limit) {
translations.append(new TranslationXdxf(a,_infoNote,this));
+ qDebug()<<a;
i++;
if(i>=limit)
break;
else if(dictionaryReader.tokenType() == QXmlStreamReader::Characters)
if(match) {
dictionaryFile.close();
+ qDebug()<<dictionaryReader.text().toString().replace("\n","");
return dictionaryReader.text().toString().replace("\n","");
-
}
}
return "";
//! returns destination language code iso 639-2
QString langTo() const;
- //! returns dictionary name (like "old english" or so
+ //! returns dictionary name (like "old english" or so)
QString name() const;
//! returns dictionary type (xdxf, google translate, etc)
//! returns information about dictionary in html (name, authors, etc)
QString infoNote() const;
- //! return dialog that creates new dictionary and fills necesary options
- //! QDialog should returns Setting* object after being showed
+ //! returns dialog that creates new dictionary and fills necessary options
+ //! QDialog should return Setting* object after being shown
QDialog* loadDialog();
- //! return dialog with dictionary settings
+ //! returns dialog with dictionary settings
QDialog* settingsDialog();
- //! return new, clean copy of plugin with setting set as in Settings*
+ //! returns new, clean copy of plugin with setting set as in Settings*
CommonDictInterface* getNew(const Settings*) const;
//! returns whether plugin can start searching
\param word word to search in dictionary
\param limit limit on number of results
- After finishing search it have to emit
+ After finishing search it has to emit
\see CommonDictInterface:finalTranslation finalTranslation
*/
QList<Translation*> searchWordList(QString word, int limit);
--- /dev/null
+#include "test.h"
+#include <QSignalSpy>
+
+void Testowanie::search()
+{
+ XdxfPlugin xdxfPlugin(this);
+ xdxfPlugin.loadDialog();
+ xdxfPlugin.searchWordList("Cain",10);
+ xdxfPlugin.search("Cain");
+ QCOMPARE(xdxfPlugin.search("cain"), QString("lina"));
+ QCOMPARE(xdxfPlugin.search("sin"), QString("grzech"));
+ //QCOMPARE(xdxfPlugin.search("boss"), QString(""));
+}
+
+void Testowanie::langFrom()
+{
+ XdxfPlugin xdxfPlugin(this);
+ xdxfPlugin.loadDialog();
+ // xdxfPlugin.searchWordList("rope",10);
+ //QCOMPARE(xdxfPlugin.langFrom(), QString("ENG"));
+}
+
+void Testowanie::sig()
+{
+ XdxfPlugin xdxfPlugin(this);
+ xdxfPlugin.loadDialog();
+
+ QSignalSpy spy(&xdxfPlugin, SIGNAL(finalTranslation(QList<Translation*>)));
+
+ xdxfPlugin.searchWordList("rope",10);
+
+ QCOMPARE(spy.count(), 1); // make sure the signal was emitted exactly one time
+}
+
+QTEST_MAIN(Testowanie)
+//#include "testqstring.moc"
--- /dev/null
+#ifndef TEST_H
+#define TEST_H
+
+#include <QtTest/QtTest>
+#include "../src/XdxfPlugin/xdxfplugin.h"
+#include "../src/XdxfPlugin/TranslationXdxf.h"
+#include "../../../includes/translation.h"
+
+#include <QList>
+
+ class Testowanie: public QObject
+ {
+ Q_OBJECT
+
+
+ private slots:
+ void search();
+ void langFrom();
+ void sig();
+ };
+
+
+#endif // TEST_H
--- /dev/null
+######################################################################
+# Automatically generated by qmake (1.07a) Wed Aug 4 11:35:12 2010
+######################################################################
+
+CONFIG += qtestlib
+TEMPLATE = app
+INCLUDEPATH += .
+
+# Input
+HEADERS += test.h \
+ ../src/XdxfPlugin/xdxfplugin.h \
+ ../src/XdxfPlugin/TranslationXdxf.h \
+ ../../../includes/translation.h \
+ ../../../includes/settings.h \
+ ../../../includes/CommonDictInterface.h
+
+SOURCES += test.cpp \
+ ../src/XdxfPlugin/xdxfplugin.cpp \
+ ../src/XdxfPlugin/TranslationXdxf.cpp