Added some tests for xdxf plugin
authorPiotrek <ppilar11@gmail.com>
Mon, 16 Aug 2010 12:34:27 +0000 (14:34 +0200)
committerPiotrek <ppilar11@gmail.com>
Mon, 16 Aug 2010 12:34:27 +0000 (14:34 +0200)
trunk/src/plugins/xdxf/src/XdxfCachingDialog.cpp
trunk/src/plugins/xdxf/tests/test.cpp
trunk/src/plugins/xdxf/tests/tests.pro

index 2a3b935..56b273c 100644 (file)
@@ -67,3 +67,7 @@ void XdxfCachingDialog::updateCachingProgress(int progress, int time) {
 void XdxfCachingDialog::reject() {
     return;
 }
+
+void XdxfCachingDialog::cancelButtonClicked(){
+    return;
+}
index affe5a5..b06adf7 100644 (file)
@@ -25,7 +25,8 @@
 void XdxfTest::getNew() {
     XdxfPlugin xdxfPlugin(this);
     Settings *settings=new Settings;
-    settings->setValue("path","dict.xdxf");
+    settings->setValue("path","../tests/dict.xdxf");
+
     CommonDictInterface *xdxfPlugin2 = xdxfPlugin.getNew(settings);
     QList<Translation*> te6=xdxfPlugin2->searchWordList("*",8);
         QCOMPARE(te6.size(),8);
@@ -34,11 +35,13 @@ void XdxfTest::getNew() {
 void XdxfTest::search() {
     /*test for English-Polish dictionary */
     XdxfPlugin xdxfPluginB(this);
-//    xdxfPlugin.setPatch("dict.xdxf");
+
+
 
     Settings *settings=new Settings;
-    settings->setValue("path","dict.xdxf");
+    settings->setValue("path","../tests/dict.xdxf");
     CommonDictInterface *xdxfPlugin = xdxfPluginB.getNew(settings);
+
     xdxfPlugin->search("wino");
     QCOMPARE(xdxfPlugin->search("."), QString("kropka\n"));
     QCOMPARE(xdxfPlugin->search("1"), QString("one\n"));
@@ -47,28 +50,43 @@ void XdxfTest::search() {
 void XdxfTest::searchWordList() {
      /*test for English-Polish dictionary */
     XdxfPlugin xdxfPluginB(this);
-//    xdxfPlugin.setPatch("dict.xdxf");
 
     Settings *settings=new Settings;
-    settings->setValue("path","dict.xdxf");
+    settings->setValue("path","../tests/dict.xdxf");
     CommonDictInterface *xdxfPlugin = xdxfPluginB.getNew(settings);
-    QList<Translation*> te=xdxfPlugin->searchWordList(".",10);
+    QList<Translation*> te = xdxfPlugin->searchWordList(".", 10);
     if(te.size()>0)
-        QCOMPARE(te.at(0)->key(), QString("."));
-    QList<Translation*> te2=xdxfPlugin->searchWordList("1",10);
-    QCOMPARE(te2.size(),5);
+        QCOMPARE(te.size(), 8);
+    QList<Translation*> te2 = xdxfPlugin->searchWordList("1",10);
+    QCOMPARE(te2.size(), 5);
 
-    QList<Translation*> te3=xdxfPlugin->searchWordList("1",2);
-    QCOMPARE(te3.size(),2);
+    QList<Translation*> te3 = xdxfPlugin->searchWordList("1", 2);
+        QCOMPARE(te3.size(), 2);
 
-    QList<Translation*> te4=xdxfPlugin->searchWordList("ho*SE",10);
+    QList<Translation*> te4 = xdxfPlugin->searchWordList("ho*SE", 10);
         QCOMPARE(te4.at(0)->key(), QString("house"));
 
-    QList<Translation*> te5=xdxfPlugin->searchWordList("*");
-        QCOMPARE(te5.size(),8);
+    QList<Translation*> te5 = xdxfPlugin->searchWordList("*");
+        QCOMPARE(te5.size(), 8);
+
+    QList<Translation*> te6 = xdxfPlugin->searchWordList("*", 8);
+        QCOMPARE(te6.size(), 8);
+
+    QList<Translation*> te7 = xdxfPlugin->searchWordList("*ou*");
+        QCOMPARE(te7.at(0)->key(), QString("house"));
+
+    QList<Translation*> te8 = xdxfPlugin->searchWordList("1?");
+        QCOMPARE(te8.at(0)->key(), QString("10"));
+
+    QList<Translation*> te9 = xdxfPlugin->searchWordList("1???");
+        QCOMPARE(te9.at(0)->key(), QString("1000"));
+
+    QList<Translation*> te10 = xdxfPlugin->searchWordList("1????*");
+        QCOMPARE(te10.at(0)->key(), QString("1 000 000"));
+
+    QList<Translation*> te11 = xdxfPlugin->searchWordList("h**?*?**e");
+        QCOMPARE(te11.at(0)->key(), QString("house"));
 
-    QList<Translation*> te6=xdxfPlugin->searchWordList("*",8);
-        QCOMPARE(te6.size(),8);
 
 }
 
@@ -78,14 +96,14 @@ void XdxfTest::stop() {
 //    xdxfPlugin.setPatch("dict.xdxf");
 
     Settings *settings=new Settings;
-    settings->setValue("path","dict.xdxf");
+    settings->setValue("path","../tests/dict.xdxf");
     CommonDictInterface *xdxfPlugin = xdxfPluginB.getNew(settings);
 
     QString string("*");
     QFuture<QList<Translation*> > future = QtConcurrent::run(xdxfPlugin, &CommonDictInterface::searchWordList, string, 10);
     QList<Translation*> te5 = future.result();
 
-    QCOMPARE(te5.size(),8);
+    QCOMPARE(te5.size(), 8);
 }
 
 
@@ -95,9 +113,9 @@ void XdxfTest::langFrom() {
 //    xdxfPlugin.setPatch("dict.xdxf");
 
     Settings *settings=new Settings;
-    settings->setValue("path","dict.xdxf");
+    settings->setValue("path","../tests/dict.xdxf");
     CommonDictInterface *xdxfPlugin = xdxfPluginB.getNew(settings);
-    xdxfPlugin->searchWordList("rope",10);
+    xdxfPlugin->searchWordList("rope", 10);
     QCOMPARE(xdxfPlugin->langFrom(), QString("ENG"));
 }
 
index 4d319d7..0abb298 100644 (file)
@@ -3,6 +3,7 @@
 ######################################################################
 
 CONFIG += qtestlib
+QT += sql
 TARGET = xdxfPluginTests
 TEMPLATE = app
 INCLUDEPATH += .
@@ -16,14 +17,18 @@ HEADERS += test.h \
     ../../../includes/DictDialog.h \
     ../../../includes/CommonDictInterface.h \
     ../src/XdxfDictDialog.h \
-    ../src/XdxfLoadDialog.h
+    ../src/XdxfLoadDialog.h \
+    ../src/XdxfSettingsDialog.h \
+    ../src/XdxfCachingDialog.h
 
 
 SOURCES += test.cpp \
     ../src/xdxfplugin.cpp \
     ../src/TranslationXdxf.cpp \
     ../src/XdxfLoadDialog.cpp \
-    ../src/XdxfDictDialog.cpp
+    ../src/XdxfDictDialog.cpp \
+    ../src/XdxfCachingDialog.cpp \
+    ../src/XdxfSettingsDialog.cpp
 
 check.target = check
 check.commands = ./xdxfPluginTests