add test
authorJakub Jaszczynski <j.j.jaszczynski@gmail.com>
Fri, 3 Sep 2010 12:57:20 +0000 (14:57 +0200)
committerJakub Jaszczynski <j.j.jaszczynski@gmail.com>
Fri, 3 Sep 2010 12:57:20 +0000 (14:57 +0200)
mdictionary.pro
src/mdictionary/backbone/Bookmarks.cpp
src/mdictionary/backbone/backbone.cpp
src/mdictionary/gui/TranslationWidget.cpp
tests/GooglePluginTests/test.cpp
tests/XdxfPluginTests/test.cpp
tests/XdxfPluginTests/test.h

index e0fbf59..6dcf823 100644 (file)
@@ -1,11 +1,11 @@
 TEMPLATE = subdirs
-SUBDIRS = src
+SUBDIRS = src tests
 CONFIG += ordered
 include (mdictionary.pri)
 
 
 check.CONFIG += recursive
-check.recurse = src 
+check.recurse = src tests
 QMAKE_EXTRA_TARGETS += check
 
 
index 2df2de7..32a3ab3 100644 (file)
@@ -43,10 +43,9 @@ bool Bookmarks::checkAndCreateDb() {
 
 void Bookmarks::clear() {
     checkAndCreateDb();
-    qDebug()<<"dename1"<<dbName;
     QSqlDatabase db = getDbCnx(dbName);
     if(!db.isOpen() && !db.open()) {
-        qDebug() << "Database error1: " << db.lastError().text() << endl;
+        qDebug() << "Database error: " << db.lastError().text() << endl;
         return ;
     }
     QSqlQuery cur(db);
@@ -59,10 +58,9 @@ void Bookmarks::clear() {
 
 void Bookmarks::add(Translation* translation) {
     checkAndCreateDb();
-    qDebug()<<"dename2"<<dbName;
     QSqlDatabase db = getDbCnx(dbName);
     if(!db.isOpen() && !db.open()) {
-        qDebug() << "Database error2: " << db.lastError().text() << endl;
+        qDebug() << "Database error: " << db.lastError().text() << endl;
         return ;
     }
     translation->setBookmark(true);
@@ -77,11 +75,10 @@ void Bookmarks::add(Translation* translation) {
 
 
 void Bookmarks::remove(Translation* translation) {
-    qDebug()<<"dename3"<<dbName;
     checkAndCreateDb();
     QSqlDatabase db = getDbCnx(dbName);
     if(!db.isOpen() && !db.open()) {
-        qDebug() << "Database error3: " << db.lastError().text() << endl;
+        qDebug() << "Database error: " << db.lastError().text() << endl;
         return ;
     }
     QSqlQuery cur(db);
@@ -94,12 +91,11 @@ void Bookmarks::remove(Translation* translation) {
 
 
 QList<Translation*> Bookmarks::list() {
-    qDebug()<<"dename4"<<dbName;
     checkAndCreateDb();
     QList<Translation*> res;
     QSqlDatabase db = getDbCnx(dbName);
     if(!db.isOpen() && !db.open()) {
-        qDebug() << "Database error4: " << db.lastError().text() << endl;
+        qDebug() << "Database error: " << db.lastError().text() << endl;
         return res;
     }
     QSqlQuery cur(db);
@@ -114,7 +110,6 @@ QList<Translation*> Bookmarks::list() {
 
 
 QList<Translation*> Bookmarks::searchWordList(QString word) {
-    qDebug()<<"dename5"<<dbName;
     checkAndCreateDb();
     if(word.indexOf("*")==-1 && word.indexOf("?")== -1)
         word+="%";
@@ -124,7 +119,7 @@ QList<Translation*> Bookmarks::searchWordList(QString word) {
     QList<Translation*> tr;
     QSqlDatabase db = getDbCnx(dbName);
     if(!db.isOpen() && !db.open()) {
-        qDebug() << "Database error5: " << db.lastError().text() << endl;
+        qDebug() << "Database error: " << db.lastError().text() << endl;
         return tr;
     }
     QSqlQuery cur(db);
@@ -145,11 +140,10 @@ QList<Translation*> Bookmarks::searchWordList(QString word) {
 
 QStringList Bookmarks::search(QString word, QString dbName) {
     checkAndCreateDb();
-    qDebug()<<"dename6"<<dbName;
     QStringList result;
     QSqlDatabase db = getDbCnx(dbName);
     if(!db.isOpen() && !db.open()) {
-        qDebug() << "Database error6: " << db.lastError().text() << endl;
+        qDebug() << "Database error: " << db.lastError().text() << endl;
         return result;
     }
     QSqlQuery cur(db);
@@ -167,9 +161,8 @@ QStringList Bookmarks::search(QString word, QString dbName) {
 
 
 bool Bookmarks::inBookmarks(QString word) {
-    qDebug()<<"dename7"<<dbName;
     if(!mdb.isOpen() && !mdb.open()) {
-        qDebug() << "Database error7: " << mdb.lastError().text() << endl;
+        qDebug() << "Database error: " << mdb.lastError().text() << endl;
         return false;
     }
     QSqlQuery cur(mdb);
index 2bff627..0f22272 100644 (file)
@@ -263,13 +263,11 @@ void Backbone::addInternalDictionary(CommonDictInterface* dict, bool active) {
 
  void Backbone::removeDictionary(CommonDictInterface *dict) {
      _dicts.remove(dict);
-     if(dict)
+     if(dict) {
         dict->clean();
-     else
-        qDebug()<<"delete empty dict";
-     delete dict;
+        delete dict;
+     }
      dictUpdated();
-
  }
 
 
index 15b830c..935323e 100644 (file)
@@ -92,8 +92,6 @@ void TranslationWidget::show(QStringList translations) {
     trans+= "</body></html>";
     trans.replace("$STAR$", "/usr/share/mdictionary/staron.png");
 
-//    qDebug()<<trans;
-
     webkit->setHtml(trans, QUrl().fromLocalFile("/"));
 
 
index 36492bd..c803afd 100644 (file)
@@ -31,8 +31,8 @@ void GoogleTest::jsonParse() {
     QString test4("");
     QString test5("");
 
-    QCOMPARE(plugin.jsonParse(test1),QString("kot<br/><pos>rzeczownik</pos>:kot, kotka, kociątko, złośliwa kobieta<br/><pos>czasownik</pos>:podnieść"));
-    QCOMPARE(plugin.jsonParse(test2),QString("Go! wyjechać<br/><pos>czasownik</pos>:wyjechać, odchodzić, zgrzeszyć<br/><pos>wykrzyknik</pos>:Odejdź"));
+    QCOMPARE(plugin.jsonParse(test1),QString("kot<br/><pos>rzeczownik</pos>: kot, kotka, kociątko, złośliwa kobieta<br/><pos>czasownik</pos>: podnieść"));
+    QCOMPARE(plugin.jsonParse(test2),QString("Go! wyjechać<br/><pos>czasownik</pos>: wyjechać, odchodzić, zgrzeszyć<br/><pos>wykrzyknik</pos>: Odejdź"));
 }
 
 
@@ -42,7 +42,7 @@ void GoogleTest::getDictionaryInfo() {
     plugin.setLangTo("en");
     plugin.getDictionaryInfo();
 
-    QCOMPARE(plugin.infoNote(),QString(" [Polish-English] (Google)" ));
+    QCOMPARE(plugin.infoNote(),QString(" [Polish-English] " ));
 }
 
 QTEST_MAIN(GoogleTest)
index 7397adc..8cb0a2e 100644 (file)
@@ -26,7 +26,7 @@ void XdxfTest::getNew() {
     qDebug()<<"\n";
     XdxfPlugin xdxfPluginB(this);
     Settings *settings=new Settings;
-    settings->setValue("path","../tests/dict.xdxf");
+    settings->setValue("path","../XdxfPluginTests/dict.xdxf");
     CommonDictInterface *xdxfPlugin = xdxfPluginB.getNew(settings);
     delete settings;
 
@@ -42,7 +42,7 @@ void XdxfTest::searchFile() {
     qDebug()<<"\n";
     XdxfPlugin xdxfPluginB(this);
     Settings *settings=new Settings;
-    settings->setValue("path","../tests/dict.xdxf");
+    settings->setValue("path","../XdxfPluginTests/dict.xdxf");
     CommonDictInterface *xdxfPlugin = xdxfPluginB.getNew(settings);
     delete settings;
 
@@ -60,14 +60,14 @@ void XdxfTest::makeCache()
     qDebug()<<"\n";
     XdxfPlugin xdxfPluginB(this);
     Settings *settings=new Settings;
-    settings->setValue("path","../tests/dict.xdxf");
+    settings->setValue("path","../XdxfPluginTests/dict.xdxf");
     settings->setValue("generateCache", "true");
     CommonDictInterface *xdxfPlugin = xdxfPluginB.getNew(settings);
-    delete settings;
 
     QCOMPARE(xdxfPlugin->settings()->value("cached"),tr("true"));
 
     xdxfPlugin->clean();
+    delete settings;
     delete xdxfPlugin;
 
 }
@@ -76,7 +76,7 @@ void XdxfTest::searchCache() {
     qDebug()<<"\n";
     XdxfPlugin xdxfPluginB(this);
     Settings *settings=new Settings;
-    settings->setValue("path","../tests/dict.xdxf");
+    settings->setValue("path","../XdxfPluginTests/dict.xdxf");
     settings->setValue("generateCache", "true");
     CommonDictInterface *xdxfPlugin = xdxfPluginB.getNew(settings);
     delete settings;
@@ -95,7 +95,7 @@ void XdxfTest::searchWordListCache(){
     qDebug()<<"\n";
     XdxfPlugin xdxfPluginB(this);
     Settings *settings=new Settings;
-    settings->setValue("path","../tests/dict.xdxf");
+    settings->setValue("path","../XdxfPluginTests/dict.xdxf");
     settings->setValue("generateCache", "true");
     CommonDictInterface *xdxfPlugin = xdxfPluginB.getNew(settings);
     delete settings;
@@ -142,7 +142,7 @@ void XdxfTest::searchWordListFile() {
     qDebug()<<"\n";
     XdxfPlugin xdxfPluginB(this);
     Settings *settings=new Settings;
-    settings->setValue("path","../tests/dict.xdxf");
+    settings->setValue("path","../XdxfPluginTests/dict.xdxf");
     CommonDictInterface *xdxfPlugin = xdxfPluginB.getNew(settings);
     delete settings;
 
@@ -187,7 +187,7 @@ void XdxfTest::stop() {
     qDebug()<<"\n";
     XdxfPlugin xdxfPluginB(this);
     Settings *settings=new Settings;
-    settings->setValue("path","../tests/dict.xdxf");
+    settings->setValue("path","../XdxfPluginTests/dict.xdxf");
     CommonDictInterface *xdxfPlugin = xdxfPluginB.getNew(settings);
     delete settings;
 
@@ -206,7 +206,7 @@ void XdxfTest::langFrom() {
     qDebug()<<"\n";
     XdxfPlugin xdxfPluginB(this);
     Settings *settings=new Settings;
-    settings->setValue("path","../tests/dict.xdxf");
+    settings->setValue("path","../XdxfPluginTests/dict.xdxf");
     CommonDictInterface *xdxfPlugin = xdxfPluginB.getNew(settings);
     delete settings;
 
@@ -220,7 +220,7 @@ void XdxfTest::timeCache() {
     qDebug()<<"\n";
     QTime timer;
     QDate date;
-    QFile File("../tests/time.xml");
+    QFile File("../XdxfPluginTests/time.xml");
     if(!File.open(QFile::ReadWrite | QFile::Text)) {
         qDebug()<<"Error: could not open file";
         return;
@@ -275,7 +275,7 @@ void XdxfTest::timeFile() {
     qDebug()<<"\n";
     QTime timer;
     QDate date;
-    QFile File("../tests/time.xml");
+    QFile File("../XdxfPluginTests/time.xml");
     if(!File.open(QFile::ReadWrite | QFile::Text)) {
         qDebug()<<"Error: could not open file";
         return;
@@ -325,7 +325,7 @@ void  XdxfTest::timeCacheNormalize() {
     qDebug()<<"\n";
     QTime timer;
     QDate date;
-    QFile File("../tests/time.xml");
+    QFile File("../XdxfPluginTests/time.xml");
     if(!File.open(QFile::ReadWrite | QFile::Text)) {
         qDebug()<<"Error: could not open file";
         return;
@@ -398,7 +398,7 @@ void XdxfTest::timeFileNormalize(){
     qDebug()<<"\n";
     QTime timer;
     QDate date;
-    QFile File("../tests/time.xml");
+    QFile File("../XdxfPluginTests/time.xml");
     if(!File.open(QFile::ReadWrite | QFile::Text)) {
         qDebug()<<"Error: could not open file";
         return;
index b713dca..e75db70 100644 (file)
@@ -37,7 +37,6 @@
  {
      Q_OBJECT
 
-
  private slots:
      void langFrom();
      void getNew();