Added tests and some maintenance
authorBartosz Szatkowski <bulislaw@linux.com>
Fri, 6 Aug 2010 08:35:20 +0000 (10:35 +0200)
committerBartosz Szatkowski <bulislaw@linux.com>
Fri, 6 Aug 2010 08:35:20 +0000 (10:35 +0200)
trunk/src/base/backbone/backbone.cpp
trunk/src/base/backbone/backbone.h
trunk/tests/mDictionaryTests/tst_Backbone.cpp

index 023c82f..680feca 100644 (file)
@@ -119,7 +119,6 @@ void Backbone::stopSearching() {
 
 
 void Backbone::search(QString word) {
-    //TODO add running searches in new threads
     _timer.stop();
     _result.clear();
     _innerResult.clear();
index a2750cf..fdcce17 100644 (file)
@@ -87,7 +87,9 @@ public Q_SLOTS:
     //! Fired when dictionary call finalTranslation(..) with translation ready
     void translation();
 
+    //! Removes given dictionary
     void removeDictionary(CommonDictInterface* dict);
+
     // TODO addToBookmark(Translation*);
     // TODO removeFromBookmark(Translation*);
 
index 9bfdae8..c39f9f7 100644 (file)
@@ -51,6 +51,7 @@ private Q_SLOTS:
     void stopSearchingTest();
     void searchTest();
     void translationTest();
+    void quitTest();
 };
 
 BackboneTest::BackboneTest()
@@ -190,7 +191,29 @@ void BackboneTest::translationTest() {
     back->translation();
 
     QVERIFY2(translatS.count() == 1, "Lost finall 'ready()' signal");
-    QVERIFY2(back->result().size() == total*2, "Lost some of translations");
+    QVERIFY2(back->result().size() == total*2, "Lost some of the translations");
+}
+
+void BackboneTest::quitTest() {
+    QSignalSpy translatS(back, SIGNAL(closeOk()));
+    for(int i = 0; i < total; i++) {
+        CommonDictInterfaceMock *m = (CommonDictInterfaceMock*) dict[i];
+        m->stopped = 0;
+        back->addDictionary(dict[i]);
+    }
+
+    for(int i = 0; i < total; i++) {
+        CommonDictInterfaceMock *m = (CommonDictInterfaceMock*)dict[i];
+        QCOMPARE(m->stopped, 0);
+    }
+
+    back->quit();
+
+    for(int i = 0; i < total; i++) {
+        CommonDictInterfaceMock *m = (CommonDictInterfaceMock*)dict[i];
+        QCOMPARE(m->stopped, 1);
+    }
+    QVERIFY2(translatS.count() == 1, "Lost finall 'closeOk()' signal");
 }