[Kst] branches/work/kst/portto4/kst

Peter Kümmel syntheticpp at gmx.net
Wed Feb 2 18:49:43 CET 2011


SVN commit 1218514 by kuemmel:

^fix unit tests

 M  +2 -1      cmake/tests/CMakeLists.txt  
 M  +9 -1      tests/testdatasource.cpp  
 M  +1 -1      tests/testgeneratedvector.cpp  
 M  +5 -5      tests/testpsd.cpp  
 M  +14 -3     tests/testscalar.cpp  
 M  +7 -2      tests/testscalar.h  


--- branches/work/kst/portto4/kst/cmake/tests/CMakeLists.txt #1218513:1218514
@@ -6,8 +6,9 @@
 
 kst_include_directories(kstcore kstmath)
 
-add_definitions(-DKST_USE_QTEST_MAIN)
+add_definitions(-DKST_USE_QTEST_MAIN -DKST_SRC_DIR=${kst_dir})
 
+
 foreach(header ${test_headers})
 	get_filename_component(filename ${header} NAME_WE)
 	string(REPLACE test test_ testname ${filename})
--- branches/work/kst/portto4/kst/tests/testdatasource.cpp #1218513:1218514
@@ -28,12 +28,20 @@
 #include "datamatrix.h"
 #include "datasourcepluginmanager.h"
 
+#include "colorsequence.h"
 
+#define STRINGIFY(x) #x
+#define TOSTRING(x) STRINGIFY(x)
+
+
+
 static Kst::ObjectStore _store;
 
 void TestDataSource::initTestCase() {
   Kst::DataSourcePluginManager::init();
   _plugins = Kst::DataSourcePluginManager::pluginList();
+
+  Kst::ColorSequence::self();
 }
 
 
@@ -516,7 +524,7 @@
     QSKIP("...couldn't find plugin.", SkipAll);
 
   //These tests assume that the image kst.png exists in src/images
-  QString imageFile = QDir::currentPath() + QDir::separator() + QString("src") +
+  QString imageFile = QString(TOSTRING(KST_SRC_DIR)) + QDir::separator() + QString("src") +
                       QDir::separator() + QString("images") + QDir::separator() + QString("kst.png");
 
   if (!QFile::exists(imageFile)) {
--- branches/work/kst/portto4/kst/tests/testgeneratedvector.cpp #1218513:1218514
@@ -41,7 +41,7 @@
   QCOMPARE(m1->mean(), &Kst::NOPOINT);
 
   m1->changeRange(0, 100, 100);
-  QCOMPARE(m1->length(), 0);
+  QCOMPARE(m1->length(), 100);
 
   m1->writeLock();
   m1->internalUpdate();
--- branches/work/kst/portto4/kst/tests/testpsd.cpp #1218513:1218514
@@ -19,12 +19,12 @@
 #include <QXmlStreamWriter>
 
 
-#include <psd.h>
+#include "psd.h"
+#include "ksttest.h"
 
+#include "datacollection.h"
+#include "objectstore.h"
 
-#include <datacollection.h>
-#include <objectstore.h>
-
 static Kst::ObjectStore _store;
 
 void TestPSD::cleanupTestCase() {
@@ -139,7 +139,7 @@
   QVERIFY(vpVY->value()[0] != vpVY->value()[0]);
 
   for(int j = 0; j < vpVX->length(); j++){
-      QCOMPARE(vpVX->value()[j], 0.0);
+      QCOMPARE(vpVX->value()[j], &Kst::NOPOINT);
   }
 
   psd->setOutput(PSDAmplitudeSpectralDensity);
--- branches/work/kst/portto4/kst/tests/testscalar.cpp #1218513:1218514
@@ -22,6 +22,7 @@
 
 #include <datacollection.h>
 #include <objectstore.h>
+#include "updatemanager.h"
 
 static Kst::ObjectStore _store;
 
@@ -29,7 +30,9 @@
 
 SListener::SListener() : QObject(), _trigger(0) {}
 SListener::~SListener() {}
-void SListener::trigger() { _trigger++; }
+void SListener::trigger(qint64) { 
+    _trigger++; 
+}
 
 
 QDomDocument TestScalar::makeDOMDocument(const QString& tag, const QString& val, bool orphan) {
@@ -81,14 +84,22 @@
 
   QCOMPARE((*sp = 2.0).value(), 2.0);
   SListener *listener = new SListener;
-  sp->connect(sp, SIGNAL(updated(ObjectPtr)), listener, SLOT(trigger()));
+  Kst::UpdateManager::self()->setStore(&_store);
+  QObject::connect(Kst::UpdateManager::self(), SIGNAL(objectsUpdated(qint64)), listener, SLOT(trigger(qint64)));
+
   *sp = 3.1415;
+  Kst::UpdateManager::self()->doUpdates(true);
   QCOMPARE(listener->_trigger, 1);
+
   sp->setValue(3.1415);
   QCOMPARE(listener->_trigger, 1);
-  *sp = 1.1415;
+  Kst::UpdateManager::self()->doUpdates(true);
   QCOMPARE(listener->_trigger, 2);
 
+  *sp = 1.1415;
+  Kst::UpdateManager::self()->doUpdates(true);
+  QCOMPARE(listener->_trigger, 3);
+
   Kst::ScalarPtr sp2 = Kst::kst_cast<Kst::Scalar>(_store.createObject<Kst::Scalar>());
 
   QVERIFY(sp->displayable());
--- branches/work/kst/portto4/kst/tests/testscalar.h #1218513:1218514
@@ -15,16 +15,21 @@
 #include <QObject>
 #include <QDomDocument>
 
-class SListener : public QObject {
+class SListener : public QObject
+{
   Q_OBJECT
+
   public:
     SListener();
     virtual ~SListener();
+
     int _trigger;
+
   public Q_SLOTS:
-    void trigger();
+    void trigger(qint64);
 };
 
+
 class TestScalar : public QObject
 {
   Q_OBJECT


More information about the Kst mailing list