瀏覽代碼

Add unit tests to CTK Core

ctkHistogram, ctkLogger, ctkModelTester, ctkTransferFunctionRepresentation,
 ctkTransferFunction, ctkVTKHistogram and ctkVTKColorTransferFunction are
now being tested with a coverage >80.
It fails due to a couple of bugs.
Benjamin Long 13 年之前
父節點
當前提交
c3f5a34100

+ 12 - 0
Libs/Core/Testing/Cpp/CMakeLists.txt

@@ -31,16 +31,22 @@ SET(KITTests_SRCS
   ctkErrorLogModelTest1.cpp
   ctkErrorLogModelTest2.cpp
   ctkErrorLogModelTest3.cpp
+  ctkHistogramTest1.cpp
+  ctkLoggerTest1.cpp
   ctkModelTesterTest1.cpp
+  ctkModelTesterTest2.cpp
   ctkUtilsClosestPowerOfTenTest1.cpp
   ctkUtilsOrderOfMagnitudeTest1.cpp
   ctkUtilsSignificantDecimalsTest1.cpp
   ctkUtilsTest1.cpp
   ctkUtilsTest2.cpp
+  ctkUtilsTest3.cpp
   ctkDependencyGraphTest1.cpp
   ctkDependencyGraphTest2.cpp
   ctkPimplTest1.cpp
   ctkSingletonTest1.cpp
+  ctkTransferFunctionTest1.cpp
+  ctkTransferFunctionRepresentationTest1.cpp
   ctkWorkflowTest1.cpp
   ctkWorkflowTest2.cpp
   ctkWorkflowTest3.cpp
@@ -122,16 +128,22 @@ SIMPLE_TEST( ctkDependencyGraphTest2 )
 SIMPLE_TEST( ctkErrorLogModelTest1 )
 SIMPLE_TEST( ctkErrorLogModelTest2 )
 SIMPLE_TEST( ctkErrorLogModelTest3 )
+SIMPLE_TEST( ctkHistogramTest1 )
+SIMPLE_TEST( ctkLoggerTest1 )
 SET_TESTS_PROPERTIES(ctkErrorLogModelTest3 PROPERTIES PASS_REGULAR_EXPRESSION
 "This is a qDebug message\nThis is a std::cerr message\nThis is a qWarning message\nThis is a std::cout message\nThis is a qCritical message\n")
 SIMPLE_TEST( ctkModelTesterTest1 )
+SIMPLE_TEST( ctkModelTesterTest2 )
 SIMPLE_TEST( ctkPimplTest1 )
 SIMPLE_TEST( ctkSingletonTest1 )
+SIMPLE_TEST( ctkTransferFunctionTest1 )
+SIMPLE_TEST( ctkTransferFunctionRepresentationTest1 )
 SIMPLE_TEST( ctkUtilsClosestPowerOfTenTest1 )
 SIMPLE_TEST( ctkUtilsOrderOfMagnitudeTest1 )
 SIMPLE_TEST( ctkUtilsSignificantDecimalsTest1 )
 SIMPLE_TEST( ctkUtilsTest1 )
 SIMPLE_TEST( ctkUtilsTest2 )
+SIMPLE_TEST( ctkUtilsTest3 )
 SIMPLE_TEST( ctkWorkflowTest1 )
 SIMPLE_TEST( ctkWorkflowTest2 )
 SIMPLE_TEST( ctkWorkflowTest3 )

+ 212 - 0
Libs/Core/Testing/Cpp/ctkHistogramTest1.cpp

@@ -0,0 +1,212 @@
+/*=========================================================================
+
+  Library:   CTK
+
+  Copyright (c) Kitware Inc.
+
+  Licensed under the Apache License, Version 2.0 (the "License");
+  you may not use this file except in compliance with the License.
+  You may obtain a copy of the License at
+
+      http://www.commontk.org/LICENSE
+
+  Unless required by applicable law or agreed to in writing, software
+  distributed under the License is distributed on an "AS IS" BASIS,
+  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  See the License for the specific language governing permissions and
+  limitations under the License.
+
+=========================================================================*/
+
+// Qt includes
+#include <QCoreApplication>
+#include <QVariant>
+
+// CTK includes
+#include <ctkHistogram.h>
+#include <ctkTransferFunction.h>
+
+// STD includes
+#include <cstdlib>
+#include <iostream>
+
+//-----------------------------------------------------------------------------
+class ctkDummyHistogram: public ctkHistogram
+{
+public:
+  ctkDummyHistogram(QObject* parent = 0):ctkHistogram(parent){}
+  virtual ~ctkDummyHistogram(){}
+
+  virtual ctkControlPoint* controlPoint(int index)const
+  {
+    Q_UNUSED(index);
+    return 0;
+  }
+
+  virtual QVariant value(qreal pos)const
+  {
+    Q_UNUSED(pos);
+    return 0.;
+  }
+
+  virtual int count()const
+  {
+    return 0;
+  }
+
+  virtual bool isDiscrete()const
+  {
+    return true;
+  }
+
+  virtual bool isEditable()const
+  {
+    return false;
+  }
+
+  virtual void range(qreal& minRange, qreal& maxRange)const
+  {
+    Q_UNUSED(minRange);
+    Q_UNUSED(maxRange);
+    minRange = 0.;
+    maxRange = 0.;
+  }
+
+  virtual QVariant minValue()const
+  {
+    return 0;
+  }
+
+  virtual QVariant maxValue()const
+  {
+    return 0;
+  }
+
+  ///
+  virtual int insertControlPoint(const ctkControlPoint& cp)
+  {
+    Q_UNUSED(cp);
+    return -1;
+  }
+
+  virtual int insertControlPoint(qreal pos)
+  {
+    Q_UNUSED(pos);
+    return -1;
+  }
+
+  virtual void removeControlPoint( qreal pos )
+  {
+    Q_UNUSED(pos);
+  }
+  ///
+  /// be careful with it, as changing the value might require
+  /// more changes to ctkControlPoint.
+  virtual void setControlPointPos(int index, qreal pos)
+  {
+    Q_UNUSED(pos);
+    Q_UNUSED(index);
+  }
+
+  ///
+  /// be careful with it, as changing the value might require
+  /// more changes to ctkControlPoint.
+  virtual void setControlPointValue(int index, const QVariant& value)
+  {
+    Q_UNUSED(index);
+    Q_UNUSED(value);
+  }
+
+  virtual void build()
+  {
+  }
+
+protected:
+
+};
+
+int ctkHistogramTest1(int argc, char * argv [] )
+{
+  Q_UNUSED(argc);
+  Q_UNUSED(argv);
+  ctkDummyHistogram dummyHistogram;
+
+  if (!dummyHistogram.isDiscrete())
+    {
+    std::cerr << "Line : " << __LINE__
+              << " - Problem with ctkHistogram::isDiscrete"
+              <<std::endl;
+    return EXIT_FAILURE;
+    }
+
+  if (dummyHistogram.isEditable())
+    {
+    std::cerr << "Line : " << __LINE__
+              << " - Problem with ctkHistogram::isEditable"
+              <<std::endl;
+    return EXIT_FAILURE;
+    }
+
+  qreal defaultIndex = 0.;
+  if (dummyHistogram.controlPoint(defaultIndex) != 0)
+    {
+    std::cerr << "Line : " << __LINE__
+              << " - Problem with ctkHistogram::controlPoint"
+              <<std::endl;
+    return EXIT_FAILURE;
+    }
+  if (dummyHistogram.count() != 0)
+    {
+    std::cerr << "Line : " << __LINE__
+              << " - Problem with ctkHistogram::count"
+              <<std::endl;
+    return EXIT_FAILURE;
+    }
+  qreal defaultPos = 0.;
+  if (dummyHistogram.value(defaultPos) != 0)
+    {
+    std::cerr << "Line : " << __LINE__
+              << " - Problem with ctkHistogram::value"
+              <<std::endl;
+    return EXIT_FAILURE;
+    }
+  if (dummyHistogram.minValue() != 0)
+    {
+    std::cerr << "Line : " << __LINE__
+              << " - Problem with ctkHistogram::minValue"
+              <<std::endl;
+    return EXIT_FAILURE;
+    }
+  if (dummyHistogram.maxValue() != 0)
+    {
+    std::cerr << "Line : " << __LINE__
+              << " - Problem with ctkHistogram::maxValue"
+              <<std::endl;
+    return EXIT_FAILURE;
+    }
+  if (dummyHistogram.insertControlPoint(defaultPos) != -1)
+  {
+    std::cerr << "Line : " << __LINE__
+              << " - Problem with ctkHistogram::insertControlPoint"
+              <<std::endl;
+    return EXIT_FAILURE;
+  }
+  ctkControlPoint defaultCP;
+  if (dummyHistogram.insertControlPoint(defaultCP) != -1)
+  {
+    std::cerr << "Line : " << __LINE__
+              << " - Problem with ctkHistogram::insertControlPoint"
+              <<std::endl;
+    return EXIT_FAILURE;
+  }
+
+  //----------
+  QVariant defaultValue;
+  dummyHistogram.removeControlPoint(defaultPos);
+  dummyHistogram.setControlPointPos(defaultIndex,defaultPos);
+  dummyHistogram.setControlPointValue(defaultIndex,defaultValue);
+  dummyHistogram.build();
+
+  return EXIT_SUCCESS;
+}
+

+ 118 - 0
Libs/Core/Testing/Cpp/ctkLoggerTest1.cpp

@@ -0,0 +1,118 @@
+/*=========================================================================
+
+  Library:   CTK
+
+  Copyright (c) Kitware Inc.
+
+  Licensed under the Apache License, Version 2.0 (the "License");
+  you may not use this file except in compliance with the License.
+  You may obtain a copy of the License at
+
+      http://www.commontk.org/LICENSE
+
+  Unless required by applicable law or agreed to in writing, software
+  distributed under the License is distributed on an "AS IS" BASIS,
+  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  See the License for the specific language governing permissions and
+  limitations under the License.
+
+=========================================================================*/
+
+// Qt includes
+#include <QCoreApplication>
+
+// CTK includes
+#include <ctkLogger.h>
+
+// STL includes
+#include <cstdlib>
+#include <iostream>
+
+int ctkLoggerTest1(int argc, char * argv [] )
+{
+  Q_UNUSED(argc);
+  Q_UNUSED(argv);
+
+  //--------------------------------------------------------------------
+  ctkLogger logger("LoggerTest");
+  std::cout<< "Logger default : " << logger.isOffEnabled() << std::endl;
+  logger.setOff();
+  if (!logger.isOffEnabled())
+    {
+    std::cerr << "Line " << __LINE__
+              << " - Problem vith Logger::setOff()" << std::endl;
+    return EXIT_FAILURE;
+    }
+  std::cout<< "Logger after setOff() : " << logger.isOffEnabled() << std::endl;
+
+  //------------------------------------------------------------------
+  std::cout<< "Logger Debug default : " << logger.isDebugEnabled() << std::endl;
+  logger.setDebug();
+  if (!logger.isDebugEnabled())
+    {
+    std::cerr << "Line " << __LINE__
+              << " - Problem vith Logger::setDebug()" << std::endl;
+    return EXIT_FAILURE;
+    }
+  std::cout << "Logger Debug after setDebug() : "
+            << logger.isDebugEnabled() << std::endl;
+
+  //------------------------------------------------------------------
+  logger.setInfo();
+  if (!logger.isInfoEnabled())
+    {
+    std::cerr << "Line " << __LINE__
+              << " - Problem vith Logger::setDebug()" << std::endl;
+    return EXIT_FAILURE;
+    }
+
+  //------------------------------------------------------------------
+  logger.setTrace();
+  if (!logger.isTraceEnabled())
+    {
+    std::cerr << "Line " << __LINE__
+              << " - Problem vith Logger::setTrace()" << std::endl;
+    return EXIT_FAILURE;
+    }
+
+  //------------------------------------------------------------------
+  logger.setError();
+  if (!logger.isErrorEnabled())
+    {
+    std::cerr << "Line " << __LINE__
+              << " - Problem vith Logger::setError()" << std::endl;
+    return EXIT_FAILURE;
+    }
+
+  //------------------------------------------------------------------
+  logger.setWarn();
+  if (!logger.isWarnEnabled())
+    {
+    std::cerr << "Line " << __LINE__
+              << " - Problem vith Logger::setWarn()" << std::endl;
+    return EXIT_FAILURE;
+    }
+
+  //------------------------------------------------------------------
+  logger.setFatal();
+  if (!logger.isFatalEnabled())
+    {
+    std::cerr << "Line " << __LINE__
+              << " - Problem vith Logger::setFatal()" << std::endl;
+    return EXIT_FAILURE;
+    }
+
+  //------------------------------------------------------------------
+  logger.configure();
+  QString defaultString;  
+  logger.debug(defaultString);
+  logger.info(defaultString);
+  logger.trace(defaultString);
+  logger.warn(defaultString);
+  logger.warn(defaultString);
+  logger.error(defaultString);
+  logger.fatal(defaultString);
+
+  return EXIT_SUCCESS;
+}
+

+ 47 - 3
Libs/Core/Testing/Cpp/ctkModelTesterTest1.cpp

@@ -64,29 +64,73 @@ int ctkModelTesterTest1(int argc, char * argv [] )
     // with mem leaks.
     QStandardItemModel model;
     ctkModelTester treeModelTester(&model);
+
+    //------ Test on row--------
     QList<QStandardItem*> items;
     items << new QStandardItem("col1") << new QStandardItem("col2");
     model.appendRow(items);
     QList<QStandardItem*> items2  = model.takeRow(0);
     if (items2 != items)
       {
-      std::cerr << "Error" << std::endl;
+      std::cerr << "Line : " << __LINE__ << "Error" << std::endl;
       return EXIT_FAILURE;
       }
-    items2.clear();
     model.appendRow(items);
     for (int i = 0; i < 10; ++i)
       {
       model.appendRow(QList<QStandardItem*>() << new QStandardItem("col1") << new QStandardItem("col2"));
       }
     model.takeRow(0);
+    model.setHeaderData(0, Qt::Vertical, QString("ID"));
     model.takeRow(model.rowCount() / 2 );
     model.takeRow(model.rowCount() - 1);
+    items2.clear();
     items2 << new QStandardItem("col1") << new QStandardItem("col2");
     items2[0]->appendRow(QList<QStandardItem*>() << new QStandardItem("subcol1") << new QStandardItem("subcol2"));
     items2[0]->appendRow(QList<QStandardItem*>() << new QStandardItem("subcol1") << new QStandardItem("subcol2"));
-    model.setData(model.index(0,0), QString("foo"));
+
+    model.appendRow(items2);
+    items2[0]->child(0,0)->setText("foo");
     model.sort(0);
+
+    //------ Test on Column-----
+    QStandardItemModel model2;
+    ctkModelTester treeModelTester2(&model2);
+
+    QList<QStandardItem*> itemsCol;
+    itemsCol << new QStandardItem("row1") << new QStandardItem("row2");
+    model2.appendColumn(itemsCol);
+    QList<QStandardItem*> itemsCol2  = model2.takeColumn(0);
+    if (itemsCol2 != itemsCol)
+      {
+      std::cerr << "Line : " << __LINE__ << "Error" << std::endl;
+      return EXIT_FAILURE;
+      }
+    model2.appendColumn(itemsCol);
+    for (int i = 0; i < 10; ++i)
+      {
+      model2.appendColumn(QList<QStandardItem*>() << new QStandardItem("row1") << new QStandardItem("row2"));
+      }
+    model2.takeColumn(0);
+    model2.takeColumn(model2.columnCount() / 2 );
+    model2.takeColumn(model2.columnCount() - 1);
+    itemsCol2 << new QStandardItem("row1") << new QStandardItem("row2");
+    itemsCol2[0]->appendColumn(QList<QStandardItem*>() << new QStandardItem("subrow1") << new QStandardItem("subrow2"));
+    itemsCol2[0]->appendColumn(QList<QStandardItem*>() << new QStandardItem("subrow1") << new QStandardItem("subrow2"));
+
+    model2.setData(model2.index(0,0), QString("foo"));
+    model2.sort(0);
+    model2.clear();
+
+    //------ Test setDataHeader ----------
+    for (int i = 0; i < 10; ++i)
+      {
+      QList<QStandardItem*> columns;
+      columns << new QStandardItem("row1") << new QStandardItem("row2");
+      model2.appendColumn(columns);
+      model2.setHorizontalHeaderItem(i,new QStandardItem(QString("Column %1").arg(i)));
+      }
+    model2.setHeaderData(0, Qt::Horizontal, QString("ID"));
     }
   catch (const char* error)
     {

+ 120 - 0
Libs/Core/Testing/Cpp/ctkModelTesterTest2.cpp

@@ -0,0 +1,120 @@
+/*=========================================================================
+
+  Library:   CTK
+
+  Copyright (c) Kitware Inc.
+
+  Licensed under the Apache License, Version 2.0 (the "License");
+  you may not use this file except in compliance with the License.
+  You may obtain a copy of the License at
+
+      http://www.commontk.org/LICENSE
+
+  Unless required by applicable law or agreed to in writing, software
+  distributed under the License is distributed on an "AS IS" BASIS,
+  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  See the License for the specific language governing permissions and
+  limitations under the License.
+
+=========================================================================*/
+
+// Qt includes
+#include <QAbstractItemModel>
+#include <QCoreApplication>
+#include <QStandardItemModel>
+#include <QModelIndex>
+
+// CTK includes
+#include "ctkModelTester.h"
+
+// STL includes
+#include <cstdlib>
+#include <iostream>
+
+//-----------------------------------------------------------------------------
+class QAbstractItemModelHelper : public QAbstractItemModel
+{
+public:
+  virtual QModelIndex index(int, int, const QModelIndex&) const { return QModelIndex(); }
+  virtual QModelIndex parent(const QModelIndex&) const { return QModelIndex(); }
+  virtual int rowCount(const QModelIndex&) const { return 0; }
+  virtual int columnCount(const QModelIndex&) const { return 0; }
+  virtual QVariant data(const QModelIndex&, int) const { return QVariant(); }
+  void emitInvalidHeaderDataChanged()
+  { emit this->headerDataChanged(Qt::Vertical, 10, 10);}
+};
+
+//-----------------------------------------------------------------------------
+int ctkModelTesterTest2(int argc, char * argv [] )
+{
+  QCoreApplication app(argc, argv);
+
+  QObject * object = new QObject; 
+
+  ctkModelTester ctkTester( object );
+
+  //---------------------------------------------------
+  if (    ctkTester.model() != 0
+      ||  ctkTester.throwOnError() != true
+      ||  ctkTester.nestedInserts() != false
+      ||  ctkTester.testDataEnabled() != true
+      ||  ctkTester.verbose() != true)
+    {
+    std::cerr << "Line : " << __LINE__
+              << " - Error in ctkModelTester::ctkModelTester" << std::endl;
+    return EXIT_FAILURE;
+    }
+
+  ctkTester.setThrowOnError(false);
+  ctkTester.setNestedInserts(true);
+  ctkTester.setTestDataEnabled(false);
+  ctkTester.setVerbose(false);
+
+  if (    ctkTester.throwOnError() != false
+      ||  ctkTester.nestedInserts() != true
+      ||  ctkTester.testDataEnabled() != false
+      ||  ctkTester.verbose() != false)
+    {
+    std::cerr << "Line : " << __LINE__
+              << " - Error " << std::endl;
+    return EXIT_FAILURE;
+    }
+
+  QModelIndex defaultModelIndex;
+  ctkTester.testModelIndex(defaultModelIndex);
+
+  ctkTester.setThrowOnError(true);
+  ctkTester.setNestedInserts(false);
+  ctkTester.setTestDataEnabled(true);
+  ctkTester.setVerbose(true);
+
+  ctkTester.testModel();
+
+  QAbstractItemModelHelper helper;
+  ctkTester.setModel(&helper);
+  bool errorThrown = false;
+  try
+    {
+    helper.emitInvalidHeaderDataChanged();
+    }
+  catch (...)
+    {
+    errorThrown = true;
+    }
+  if (!errorThrown)
+    {
+    std::cerr << "ThrowOnError failed" << std::endl;
+    return EXIT_FAILURE;
+    }
+
+  QStandardItemModel model;
+  ctkTester.setModel(&model);
+  ctkTester.setModel(0);
+  ctkTester.setModel(&model);
+
+  ctkTester.testModelIndex(defaultModelIndex);
+
+
+  return EXIT_SUCCESS;
+}
+

+ 277 - 0
Libs/Core/Testing/Cpp/ctkTransferFunctionRepresentationTest1.cpp

@@ -0,0 +1,277 @@
+/*=========================================================================
+
+  Library:   CTK
+
+  Copyright (c) Kitware Inc.
+
+  Licensed under the Apache License, Version 2.0 (the "License");
+  you may not use this file except in compliance with the License.
+  You may obtain a copy of the License at
+
+      http://www.commontk.org/LICENSE
+
+  Unless required by applicable law or agreed to in writing, software
+  distributed under the License is distributed on an "AS IS" BASIS,
+  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  See the License for the specific language governing permissions and
+  limitations under the License.
+
+=========================================================================*/
+
+// Qt includes
+#include <QCoreApplication>
+#include <QColor>
+#include <QVariant>
+#include <QLocale>
+#include <QRectF>
+#include <QPainterPath>
+#include <QGradient>
+#include <QList>
+
+// CTK includes
+#include "ctkTransferFunctionRepresentation.h"
+#include "ctkTransferFunction.h"
+
+// STL includes
+#include <cstdlib>
+#include <iostream>
+#include <limits>
+
+int ctkTransferFunctionRepresentationTest1(int argc, char * argv [])
+{
+  Q_UNUSED(argc);
+  Q_UNUSED(argv);
+
+//--------------------------------------------------------------
+// Test 1 : test without transfert function
+//--------------------------------------------------------------
+
+  //---------Test Constructor----------  
+  ctkTransferFunctionRepresentation representation;
+  if(representation.transferFunction() != 0)
+    {
+    std::cerr << "Line " << __LINE__
+              << " - Problem with ctkTransfertFunctionRepresentation::"
+              << " ctkTransfertFunctionRepresentation - transfertFunction not null." 
+              << std::endl;
+    return EXIT_FAILURE;
+    }
+
+  QColor expectedVerticalGradientColor = QColor::fromRgbF(1., 0., 0., 1.);
+  if(representation.verticalGradientColor() != expectedVerticalGradientColor)
+    {
+    std::cerr << "Line " << __LINE__
+              << " - Problem with ctkTransfertFunctionRepresentation:: "
+              << "ctkTransfertFunctionRepresentation"
+              << std::endl;
+    return EXIT_FAILURE;
+    }
+
+  //---------Test setVerticalGradientColor------
+  expectedVerticalGradientColor = QColor::fromRgbF(0., 1., 1., 0.);
+  representation.setVerticalGradientColor(expectedVerticalGradientColor);
+  if(representation.verticalGradientColor() != expectedVerticalGradientColor)
+    {
+    std::cerr << "Line " << __LINE__
+              << " - Problem with "
+              << "ctkTransfertFunctionRepresentation::setVerticalGradientColor"
+              << std::endl;
+    return EXIT_FAILURE;
+    }
+
+  //---------Test PosX--------------------------
+  qreal expectedPosX = 2.;
+  if (representation.posX(expectedPosX) != expectedPosX)
+  {
+  std::cerr << "Line " << __LINE__ 
+            << " - Problem with ctkTransfertFunctionRepresentation::posX" 
+            << std::endl;
+  return EXIT_FAILURE;
+  }
+
+  //---------Test PosY--------------------------
+  QVariant variant = 2.;
+  if (representation.posY(variant) != 2.)  
+    {
+    std::cerr << "Line " << __LINE__ 
+              << " - Problem with ctkTransfertFunctionRepresentation::posY"
+              << " - for the qreal" << std::endl;
+    return EXIT_FAILURE;
+    }
+
+  QColor defaultColor = QColor::fromRgbF(0., 0., 0., 0.);
+  variant = defaultColor;
+  if (representation.posY(variant) != defaultColor.alphaF())
+    {
+    std::cerr << "Line " << __LINE__
+              << " - Problem with ctkTransfertFunctionRepresentation::posY"
+              << " - for the color: " << representation.posY(variant) 
+              << " - " << defaultColor.alphaF() << std::endl;
+    return EXIT_FAILURE;
+    } 
+ 
+  //--------Test Color--------------------------
+  QColor expectedColor = QColor::fromRgbF(1., 1., 1.);
+  variant = expectedColor;
+  if (representation.color(variant) != expectedColor)
+    {
+    std::cerr << "Line " << __LINE__
+              << " - Problem with ctkTransfertFunctionRepresentation::color"
+              << " when QVariant is a color"
+              << std::endl;
+    return EXIT_FAILURE;
+    }
+  variant = expectedPosX;
+  if (representation.color(variant) != QColor::fromRgbF(0., 0., 0.))
+    {
+    std::cerr << "Line " << __LINE__
+              << " - Problem with ctkTransfertFunctionRepresentation::color"
+              << " when QVariant is a not a color"
+              << std::endl;
+    return EXIT_FAILURE;
+    }
+
+  //---------Test MapXToScene------------------
+  qreal xPos = 2.;
+  if (representation.mapXToScene(xPos) != 0) 
+    {
+    std::cerr << "Line " << __LINE__
+              << " - Problem with "
+              << "ctkTransfertFunctionRepresentation::mapXToScene   "
+              << representation.mapXToScene(xPos)
+              << std::endl;
+    return EXIT_FAILURE;
+    }
+
+  //--------Test MapYToScene------------------
+  qreal yPos = 2.;
+  if (representation.mapYToScene(yPos) != 1) //Because la fonction height return 1.
+    {
+    std::cerr << "Line " << __LINE__
+              << " - Problem with "
+              << "ctkTransfertFunctionRepresentation::mapYToScene   "
+              << representation.mapYToScene(yPos)
+              << std::endl;
+    return EXIT_FAILURE;
+    } 
+
+  //--------Test MapXFromScene----------------
+  qreal defaultScenePosX = 2.;
+  qreal mapX = representation.mapXFromScene(defaultScenePosX);
+  if (mapX != std::numeric_limits<qreal>::infinity())
+    {
+    std::cerr << "Line " << __LINE__
+              << " - Problem with "
+              << "ctkTransfertFunctionRepresentation::mapXFromScene  "
+              << representation.mapXFromScene(defaultScenePosX)
+              << std::endl;
+    return EXIT_FAILURE;
+    } 
+
+  //--------Test MapyFromScene----------------  
+  qreal defaultScenePosY = 2.;
+  qreal mapY = representation.mapYFromScene(defaultScenePosY);
+  if (mapY != - std::numeric_limits<qreal>::infinity())
+    {
+    std::cerr << "Line " << __LINE__
+              << " - Problem with "
+              << "ctkTransfertFunctionRepresentation::mapyFromScene  "
+              << representation.mapYFromScene(defaultScenePosY)
+              << std::endl;
+    return EXIT_FAILURE;
+    } 
+
+  //--------Test Curve-----------------------
+  QPainterPath defaultPath = representation.curve();
+  if(!defaultPath.isEmpty())
+    {
+    std::cerr << "Line " << __LINE__
+              << " - Problem with "
+              << "ctkTransfertFunctionRepresentation::curve  "
+              << std::endl;
+    return EXIT_FAILURE;
+    }
+
+  //--------Test gradient--------------------
+  if(representation.gradient().type() != QGradient::LinearGradient)
+    {
+    std::cerr << "Line " << __LINE__
+              << " - Problem with "
+              << "ctkTransfertFunctionRepresentation::gradient  "
+              << std::endl;
+    return EXIT_FAILURE;   
+    }
+  
+  //--------Test points---------------------- 
+  QList<QPointF> expectedPoints;
+  if(representation.points().size() != 0)
+    {
+    std::cerr << "Line " << __LINE__
+              << " - Problem with "
+              << "ctkTransfertFunctionRepresentation::points  "
+              << std::endl;
+    return EXIT_FAILURE; 
+    }
+  
+  //--------Test bezierParams----------------
+  ctkControlPoint startPoint;
+  ctkControlPoint endPoint;
+  if(representation.bezierParams(&startPoint,&endPoint).size() != 4)
+    {
+    std::cerr << "Line " << __LINE__
+              << " - Problem with "
+              << "ctkTransfertFunctionRepresentation::bezierParams "
+              << std::endl;
+    return EXIT_FAILURE; 
+    }
+
+  //--------Test nonLinearPoints------------- // ? case subpoint ?
+  if(representation.nonLinearPoints(&startPoint,&endPoint).size() != 2)
+    {
+    std::cerr << "Line " << __LINE__
+              << " - Problem with "
+              << "ctkTransfertFunctionRepresentation::nonLinearPoints "
+              << std::endl;
+    return EXIT_FAILURE; 
+    }
+  
+  //-------Test mapPointToScene-With q ctkPoint*----------
+  qreal defaultX = 2.;
+  QVariant defaultVariant = 1.;  
+  ctkPoint defaultPoint(defaultX,defaultVariant);  
+  QPointF defaultPointF(0,1);
+  if(representation.mapPointToScene(defaultPoint) != defaultPointF)
+    {
+    std::cerr << "Line " << __LINE__
+              << " - Problem with "
+              << "ctkTransfertFunctionRepresentation::mapPointFromScene  "
+              << defaultPointF.x()
+              << "   "
+              << defaultPointF.y()
+              << std::endl;
+    return EXIT_FAILURE; 
+    }
+  
+  //-------Test mapPointToScene-With a ctkControlPoint&------------  
+  ctkControlPoint defaultControlPoint;     
+  if(representation.mapPointToScene(&defaultControlPoint) != defaultPointF)
+    {
+    std::cerr << "Line " << __LINE__
+              << " - Problem with "
+              << "ctkTransfertFunctionRepresentation::mapPointFromScene  "
+              << defaultPointF.x()
+              << "   "
+              << defaultPointF.y()
+              << std::endl;
+    return EXIT_FAILURE; 
+    }
+  
+  //-------Test computeCurve----------------
+  representation.computeCurve();
+
+  //-------Test computegradient-------------
+  representation.computeGradient();
+
+  return EXIT_SUCCESS;
+}
+

+ 190 - 0
Libs/Core/Testing/Cpp/ctkTransferFunctionTest1.cpp

@@ -0,0 +1,190 @@
+/*=========================================================================
+
+  Library:   CTK
+
+  Copyright (c) Kitware Inc.
+
+  Licensed under the Apache License, Version 2.0 (the "License");
+  you may not use this file except in compliance with the License.
+  You may obtain a copy of the License at
+
+      http://www.commontk.org/LICENSE
+
+  Unless required by applicable law or agreed to in writing, software
+  distributed under the License is distributed on an "AS IS" BASIS,
+  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  See the License for the specific language governing permissions and
+  limitations under the License.
+
+=========================================================================*/
+
+// Qt includes
+#include <QCoreApplication>
+
+// CTK includes
+#include "ctkTransferFunction.h"
+
+// STL includes
+#include <cstdlib>
+#include <iostream>
+
+class ctkDummyTransferFunction: public ctkTransferFunction
+{
+public:
+  ctkDummyTransferFunction(QObject* parent = 0):ctkTransferFunction(parent){}
+  virtual ~ctkDummyTransferFunction(){}
+
+  virtual ctkControlPoint* controlPoint(int index)const
+  {
+    Q_UNUSED(index);
+    return 0;
+  }
+  virtual QVariant value(qreal pos)const
+  {
+    Q_UNUSED(pos);
+    return 0.;
+  }
+
+  virtual int count()const
+  {
+    return 0;
+  }
+  virtual bool isDiscrete()const
+  {
+    return true;
+  }
+  virtual bool isEditable()const
+  {
+    return false;
+  }
+
+  virtual void range(qreal& minRange, qreal& maxRange)const
+  {
+    minRange = 0.;
+    maxRange = 0.;
+  }
+  virtual QVariant minValue()const
+  {
+    return 0.;
+  }
+  virtual QVariant maxValue()const
+  {
+    return 0.;
+  }
+  virtual int insertControlPoint(const ctkControlPoint& cp)
+  {
+    Q_UNUSED(cp);
+    return -1;
+  }
+  
+  virtual int insertControlPoint(qreal pos)
+  {
+    Q_UNUSED(pos);
+    return -1;
+  }
+
+  virtual void removeControlPoint( qreal pos )
+  {
+    Q_UNUSED(pos);
+  }
+
+  virtual void setControlPointPos(int index, qreal pos)
+  {
+    Q_UNUSED(pos);
+    Q_UNUSED(index);
+  }
+  virtual void setControlPointValue(int index, const QVariant& value)
+  {
+    Q_UNUSED(index);
+    Q_UNUSED(value);
+  }
+
+private:
+  Q_DISABLE_COPY(ctkDummyTransferFunction);
+};
+
+
+int ctkTransferFunctionTest1(int argc, char * argv [])
+{
+  Q_UNUSED(argc);
+  Q_UNUSED(argv);
+  ctkDummyTransferFunction dummy;
+
+  if (!dummy.isDiscrete())
+    {
+    std::cerr << "Line : " << __LINE__
+              << " - Problem with ctkHistogram::isDiscrete"
+              <<std::endl;
+    return EXIT_FAILURE;
+    }
+
+  if (dummy.isEditable())
+    {
+    std::cerr << "Line : " << __LINE__
+              << " - Problem with ctkHistogram::isEditable"
+              <<std::endl;
+    return EXIT_FAILURE;
+    }
+
+  qreal defaultIndex = 0.;
+  if (dummy.controlPoint(defaultIndex) != 0)
+    {
+    std::cerr << "Line : " << __LINE__
+              << " - Problem with ctkHistogram::controlPoint"
+              <<std::endl;
+    return EXIT_FAILURE;
+    }
+  if (dummy.count() != 0)
+    {
+    std::cerr << "Line : " << __LINE__
+              << " - Problem with ctkHistogram::count"
+              <<std::endl;
+    return EXIT_FAILURE;
+    }
+  qreal defaultPos = 0.;
+  if (dummy.value(defaultPos) != 0)
+    {
+    std::cerr << "Line : " << __LINE__
+              << " - Problem with ctkHistogram::value"
+              <<std::endl;
+    return EXIT_FAILURE;
+    }
+  if (dummy.minValue() != 0)
+    {
+    std::cerr << "Line : " << __LINE__
+              << " - Problem with ctkHistogram::minValue"
+              <<std::endl;
+    return EXIT_FAILURE;
+    }
+  if (dummy.maxValue() != 0)
+    {
+    std::cerr << "Line : " << __LINE__
+              << " - Problem with ctkHistogram::maxValue"
+              <<std::endl;
+    return EXIT_FAILURE;
+    }
+  if (dummy.insertControlPoint(defaultPos) != -1)
+  {
+    std::cerr << "Line : " << __LINE__
+              << " - Problem with ctkHistogram::insertControlPoint"
+              <<std::endl;
+    return EXIT_FAILURE;
+  }
+  ctkControlPoint defaultCP;
+  if (dummy.insertControlPoint(defaultCP) != -1)
+  {
+    std::cerr << "Line : " << __LINE__
+              << " - Problem with ctkHistogram::insertControlPoint"
+              <<std::endl;
+    return EXIT_FAILURE;
+  }
+
+  //----------
+  QVariant defaultValue;
+  dummy.removeControlPoint(defaultPos);
+  dummy.setControlPointPos(defaultIndex,defaultPos);
+  dummy.setControlPointValue(defaultIndex,defaultValue);
+
+  return EXIT_SUCCESS;
+}
+

+ 142 - 0
Libs/Core/Testing/Cpp/ctkUtilsTest3.cpp

@@ -0,0 +1,142 @@
+/*=========================================================================
+
+  Library:   CTK
+
+  Copyright (c) Kitware Inc.
+
+  Licensed under the Apache License, Version 2.0 (the "License");
+  you may not use this file except in compliance with the License.
+  You may obtain a copy of the License at
+
+      http://www.commontk.org/LICENSE
+
+  Unless required by applicable law or agreed to in writing, software
+  distributed under the License is distributed on an "AS IS" BASIS,
+  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  See the License for the specific language governing permissions and
+  limitations under the License.
+
+=========================================================================*/
+
+// Qt includes
+#include <QDebug>
+#include <QStringList>
+
+// CTK includes
+#include "ctkUtils.h"
+
+// STD includes
+#include <cstdlib>
+#include <iostream>
+#include <string>
+
+
+//-----------------------------------------------------------------------------
+int ctkUtilsTest3(int argc, char * argv [] )
+{
+  Q_UNUSED(argc);
+  Q_UNUSED(argv);
+
+  QString dummy;
+  QStringList dummyList;
+  QRegExp defaultDummyRegExp(".+");
+
+  if (!ctk::extensionToRegExp(dummy).isEmpty())
+    {
+    qWarning() << "Line" << __LINE__ << "ctk::extensionToRegExp() failed: ";
+    return EXIT_FAILURE;
+    }
+  QRegExp dummyRegExp = ctk::nameFiltersToRegExp(dummyList);
+  if(dummyRegExp != defaultDummyRegExp )
+    {
+    qWarning() << "Line" << __LINE__ << "ctk::nameFiltersToRegExp() failed: ";
+    return EXIT_FAILURE;
+    }
+  //add test if it take all the extension, test with exemples
+  if (!dummyRegExp.exactMatch("c:/foo.jpg"))
+    {
+    qWarning() << "Line" << __LINE__ << "ctk::nameFiltersToRegExp() failed: ";
+    return EXIT_FAILURE;
+    }
+  if (!dummyRegExp.exactMatch("c:/foo.jpga"))
+    {
+    qWarning() << "Line" << __LINE__ << "ctk::nameFiltersToRegExp() failed: ";
+    return EXIT_FAILURE;
+    }
+  if (!dummyRegExp.exactMatch("c:/foo.png"))
+    {
+    qWarning() << "Line" << __LINE__ << "ctk::nameFiltersToRegExp() failed: ";
+    return EXIT_FAILURE;
+    }
+
+  //-------Test Function extensionToRegExp(const QString& extension)
+  QString simpleExtension("*.jpg");
+  QString standardSimpleExtension(".*\\.jpg?$");
+
+  if (ctk::extensionToRegExp(simpleExtension).isEmpty())
+    {
+    qWarning() << "Line" << __LINE__ << "ctk::extensionToRegExp() failed: input "
+               << simpleExtension << "output:"
+               << ctk::extensionToRegExp(simpleExtension);
+    return EXIT_FAILURE;
+    }
+  if (ctk::extensionToRegExp(simpleExtension) != standardSimpleExtension)
+    {
+    qWarning() << "Line" << __LINE__<< "ctk::extensionToRegExp() failed: input "
+               << standardSimpleExtension << "output:"
+               << ctk::extensionToRegExp(simpleExtension);
+    return EXIT_FAILURE;
+    }
+
+  QString standardNameFilter("Images (*.jpg)");
+  QString simpleStandardNameFilter("Text (*.txt)");
+  QStringList standardNameFilters;
+  standardNameFilters << standardNameFilter << simpleStandardNameFilter;
+
+  QString nameFiltersExtensions("(.*\\.jpg?$|.*\\.txt?$)");
+  QRegExp defaultRegExp(nameFiltersExtensions);
+
+  if(ctk::nameFiltersToRegExp(standardNameFilters).isEmpty())
+    {
+    qWarning() << "Line" << __LINE__ << "ctk::nameFiltersToRegExp() failed: input "
+               << nameFiltersExtensions << "output:"
+               << ctk::nameFiltersToRegExp(standardNameFilters).pattern();
+    return EXIT_FAILURE;
+    }
+
+  QRegExp regExp = ctk::nameFiltersToRegExp(standardNameFilters);
+  if (regExp != defaultRegExp)
+    {
+    qWarning() << "Line" << __LINE__ << "ctk::nameFiltersToRegExp() failed: input "
+               << nameFiltersExtensions << "output:"
+               << regExp.pattern();
+    return EXIT_FAILURE;
+    }
+  if (!regExp.exactMatch("c:/foo.jpg"))
+    {
+    qWarning() << "Line" << __LINE__ << "ctk::nameFiltersToRegExp() failed:";
+    return EXIT_FAILURE;
+    }
+  if (!regExp.exactMatch("c:/foo.txt"))
+    {
+    qWarning() << "Line" << __LINE__ << "ctk::nameFiltersToRegExp() failed:";
+    return EXIT_FAILURE;
+    }
+  if (regExp.exactMatch("c:/foo.txta"))
+    {
+    qWarning() << "Line" << __LINE__ << "ctk::nameFiltersToRegExp() failed:";
+    return EXIT_FAILURE;
+    }
+  if (regExp.exactMatch("c:/foo.jpga"))
+    {
+    qWarning() << "Line" << __LINE__ << "ctk::nameFiltersToRegExp() failed:";
+    return EXIT_FAILURE;
+    }
+  if (regExp.exactMatch("c:/foo.png"))
+    {
+    qWarning() << "Line" << __LINE__ << "ctk::nameFiltersToRegExp() failed:";
+    return EXIT_FAILURE;
+    }
+
+  return EXIT_SUCCESS;
+}

+ 10 - 0
Libs/Visualization/VTK/Core/Testing/Cpp/CMakeLists.txt

@@ -4,8 +4,13 @@ SET(KIT ${PROJECT_NAME})
 # Tests
 #
 SET(TEST_SOURCES
+  ctkVTKColorTransferFunctionTest1.cpp
   ctkVTKConnectionTest1.cpp
   ctkVTKErrorLogModelTest1.cpp
+  ctkVTKHistogramTest1.cpp
+  ctkVTKHistogramTest2.cpp
+  ctkVTKHistogramTest3.cpp
+  ctkVTKHistogramTest4.cpp
   ctkVTKObjectTest1.cpp
   )
 
@@ -69,8 +74,13 @@ ENDMACRO( SIMPLE_TEST  )
 # Add Tests
 #
 
+SIMPLE_TEST( ctkVTKColorTransferFunctionTest1 )
 SIMPLE_TEST( ctkVTKConnectionTest1 )
 SIMPLE_TEST( ctkVTKErrorLogModelTest1 )
+SIMPLE_TEST( ctkVTKHistogramTest1 )
+SIMPLE_TEST( ctkVTKHistogramTest2 )
+SIMPLE_TEST( ctkVTKHistogramTest3 )
+SIMPLE_TEST( ctkVTKHistogramTest4 )
 SIMPLE_TEST( ctkVTKObjectTest1 )
 
 #

+ 211 - 0
Libs/Visualization/VTK/Core/Testing/Cpp/ctkVTKColorTransferFunctionTest1.cpp

@@ -0,0 +1,211 @@
+
+// Qt includes
+#include <QCoreApplication>
+#include <QVariant>
+#include <QColor>
+
+// CTKVTK includes
+#include "ctkVTKColorTransferFunction.h"
+
+// VTK includes
+#include <vtkColorTransferFunction.h>
+#include <vtkSmartPointer.h>
+
+// STD includes
+#include <cstdlib>
+#include <iostream>
+
+int ctkVTKColorTransferFunctionTest1( int argc, char * argv [])
+{
+  Q_UNUSED(argc);
+  Q_UNUSED(argv);
+
+//--------------------------------------------
+//Test 1 : with default TransfertFunction
+//----------------------------------------------------------------------
+
+  ctkVTKColorTransferFunction defaultTF;
+
+  //------Test Function Count-wihtout colorTransferFunction-------------
+  if (defaultTF.count() != -1
+        || defaultTF.minValue() != -1
+        || defaultTF.maxValue() != -1)
+    {
+    std::cerr << "Line : " << __LINE__
+              << " - Problem with ctkVTKColorTransferFunction::count"
+              <<std::endl;
+    return EXIT_FAILURE;
+    }
+
+  //------Test Function range-------------------
+  qreal defaultMinRange = 0.;
+  qreal defaultMaxRange = 1.;
+  defaultTF.range(defaultMinRange, defaultMaxRange);
+
+  //------Test Function colorTransferFunction---
+  vtkColorTransferFunction* defaultVTKColorTransferFunction = defaultTF.colorTransferFunction();
+  if (defaultVTKColorTransferFunction != 0)
+    {
+    std::cerr << "Line : " << __LINE__
+              << " - Problem with ctkVTKColorTransferFunction::colorTransfertFunction  "
+              //<< defaultVTKColorTransferFunction->GetSize()
+              <<std::endl;
+    return EXIT_FAILURE;
+    }
+
+  //-----Test Function vtkColorTransferFunction::New()---------
+  vtkColorTransferFunction*  colorTransferFunction = vtkColorTransferFunction::New();
+  if (colorTransferFunction->GetSize() > 0)
+    {
+    std::cerr << "Line : " << __LINE__
+              << " - Problem with ctkVTKColorTransferFunction::vtkColorTransferFunction::New() "
+              //<< defaultVTKColorTransferFunction->GetSize()
+              <<std::endl;
+    return EXIT_FAILURE;
+    }
+
+  //------Test Function setColorTransfertFunction------
+  defaultTF.setColorTransferFunction(colorTransferFunction);
+
+  //------Test Function Value-------------------
+  qreal defaultPos = 1.;
+  QVariant defaultVariant = defaultTF.value(defaultPos);
+  if (defaultTF.value(defaultPos).type() != QVariant::Color)
+  {
+    std::cerr << "Line : " << __LINE__
+              << " - Problem with ctkVTKColorTransferFunction::value> "
+              <<std::endl;
+    //return EXIT_FAILURE;
+  }
+
+  //------Test Function Count wiht colorTransferFunction-------------
+  if (defaultTF.count() < 0)
+    {
+    std::cerr << "Line : " << __LINE__
+              << " - Problem with ctkVTKColorTransferFunction::count"
+              <<std::endl;
+    return EXIT_FAILURE;
+    }
+
+  //------Test Function isDiscrete--------------
+  if(defaultTF.isDiscrete())
+  {
+    std::cerr << "Line : " << __LINE__
+              << " - Problem with ctkVTKColorTransferFunction::isDiscrete"
+              <<std::endl;
+    return EXIT_FAILURE;
+  }
+
+  //------Test Function isEnable----------------
+  if(!defaultTF.isEditable())
+  {
+    std::cerr << "Line : " << __LINE__
+              << " - Problem with ctkVTKColorTransferFunction::isEditable"
+              <<std::endl;
+    return EXIT_FAILURE;
+  }
+
+  //------Test Function range-------------------
+  defaultMinRange = 0.;
+  defaultMaxRange = 1.;
+
+  defaultTF.range(defaultMinRange,defaultMaxRange);
+
+  //------Test Function minValue----------------
+  QVariant defaultMinValue;
+  defaultMinValue = defaultTF.minValue();
+  if (defaultMinValue == -1)
+    {
+    std::cerr << "Line : " << __LINE__
+              << " - Problem with ctkVTKColorTransferFunction::minValue"
+              <<std::endl;
+    return EXIT_FAILURE;
+    }
+
+  //-----Test Function maxValue----------------
+  QVariant defaultMaxValue;
+  defaultMaxValue = defaultTF.maxValue();
+  if (defaultMaxValue == -1)
+    {
+    std::cerr << "Line : " << __LINE__
+              << " - Problem with ctkVTKColorTransferFunction::minValue"
+              <<std::endl;
+    return EXIT_FAILURE;
+    }
+  //-----Test Function insertControlPoint with qreal------
+  defaultPos = 1.;
+  defaultTF.insertControlPoint(defaultPos);
+  if (defaultTF.count() != 1)
+    {
+    std::cerr << "Line : " << __LINE__
+              << " - Problem with ctkVTKColorTransferFunction"
+              << "::insertControlPoint(qreal) "
+              << defaultTF.count()
+              <<std::endl;
+    return EXIT_FAILURE;
+    }
+
+  //------Test Function removeControlpoint--------
+  qreal fakeDefaultPos = 2.;
+  defaultTF.removeControlPoint(fakeDefaultPos);
+  if (defaultTF.count() != 1)
+    {
+    std::cerr << "Line : " << __LINE__
+              << " - Problem with ctkVTKColorTransferFunction"
+              << "::insertControlPoint(qreal) "
+              << defaultTF.count()
+              <<std::endl;
+    return EXIT_FAILURE;
+    }
+  defaultTF.removeControlPoint(defaultPos);
+  if (defaultTF.count() != 0)
+    {
+    std::cerr << "Line : " << __LINE__
+              << " - Problem with ctkVTKColorTransferFunction"
+              << "::insertControlPoint(qreal) "
+              << defaultTF.count()
+              <<std::endl;
+    return EXIT_FAILURE;
+    }
+
+  //------Test Function insertControlPoint with ctkControlPoint-------
+  ctkControlPoint cp;
+  int index1 = defaultTF.insertControlPoint(cp);
+  if (defaultTF.count() != 1)
+    {
+    std::cerr << "Line : " << __LINE__
+              << " - Problem with ctkVTKColorTransferFunction"
+              << "::insertControlPoint(qreal) "
+              << defaultTF.count()
+              <<std::endl;
+    return EXIT_FAILURE;
+    }
+
+  //------Test Function setControlPointPos---------
+  qreal newPos = 5.;
+  defaultTF.setControlPointPos(index1,newPos);
+
+  //------Test Function setControlPointValue-------
+  QVariant newValue = QColor::fromRgbF(0., 1., 1.);
+  defaultTF.setControlPointValue(index1,newValue);
+
+  //------Test Function minValue----------------
+  defaultMinValue = defaultTF.minValue();
+
+  //-----Test Function maxValue----------------
+  defaultMaxValue = defaultTF.maxValue();
+
+  //-----Test ControlPoint---------------------
+  qreal firstPos = 10.;
+  qreal secondPos = 20.;
+  ctkControlPoint* defaultControlPoint;
+  int firstIndex = defaultTF.insertControlPoint(firstPos);
+  int secondIndex = defaultTF.insertControlPoint(secondPos);
+  std::cout << "Index :" << firstIndex << "  " << secondIndex << std::endl;
+  defaultControlPoint = defaultTF.controlPoint(0);
+  defaultControlPoint = defaultTF.controlPoint(firstIndex);
+  defaultControlPoint = defaultTF.controlPoint(secondIndex);
+
+  colorTransferFunction->Delete();
+  return EXIT_SUCCESS;
+}

+ 133 - 0
Libs/Visualization/VTK/Core/Testing/Cpp/ctkVTKHistogramTest1.cpp

@@ -0,0 +1,133 @@
+
+// Qt includes
+#include <QCoreApplication>
+
+// CTKVTK includes
+#include "ctkVTKHistogram.h"
+
+// VTK includes
+#include <vtkSmartPointer.h>
+#include <vtkDataArray.h>
+
+// STD includes
+#include <cstdlib>
+#include <iostream>
+
+int ctkVTKHistogramTest1( int argc, char * argv [])
+{
+  Q_UNUSED(argc);
+  Q_UNUSED(argv);
+
+//---------------------------------------------------
+// test 1 : With default Histogram
+//---------------------------------------------------
+
+  ctkVTKHistogram defaultHistogram;
+
+  //------Test constructor---------------------------
+
+  if (defaultHistogram.count() != 0
+      || defaultHistogram.minValue() != 0
+      || defaultHistogram.maxValue() != 0
+      || defaultHistogram.component() != 0)
+    {
+    std::cerr << "Line : " << __LINE__
+              << " - Problem with ctkVTKHistogram::ctkVTKHistogram "
+              << defaultHistogram.count()
+              << std::endl;
+    return EXIT_FAILURE;
+    }
+
+  //-----Test setComponent---------------------------
+  int newComponent = 1;
+  defaultHistogram.setComponent(newComponent);
+  if (defaultHistogram.component() != newComponent)
+    {
+    std::cerr << "Line : " << __LINE__
+              << " - Problem with ctkVTKHistogram::setComponent "
+              << defaultHistogram.component()
+              << std::endl;
+    return EXIT_FAILURE;
+    }
+  // All the following data array have only 1 component.
+  defaultHistogram.setComponent(0);
+  //------Test build--------------------------------
+  defaultHistogram.build();
+
+  //-----Test Range----------------------------------
+  qreal minRange = 1;
+  qreal maxRange = 2;
+  defaultHistogram.range(minRange,maxRange);
+
+  //------Test dataArray-----------------------------
+  vtkSmartPointer<vtkDataArray> defaultDataArray;
+  defaultDataArray = defaultHistogram.dataArray();
+
+  //------Test setDataArray--------------------------
+  int dataType = VTK_CHAR;
+  vtkSmartPointer<vtkDataArray> newDataArray = vtkDataArray::CreateDataArray(dataType);
+  defaultHistogram.setDataArray(newDataArray);
+  if (defaultHistogram.dataArray() != newDataArray)
+    {
+    std::cerr << "Line : " << __LINE__
+              << " - Problem with ctkVTKHistogram::setDataArray "
+              << std::endl;
+    return EXIT_FAILURE;
+    }
+
+  //------Test build---------------------------------
+  defaultHistogram.build();
+
+  dataType = VTK_INT;
+  newDataArray = vtkDataArray::CreateDataArray(dataType);
+  newDataArray->SetNumberOfComponents(1);
+  newDataArray->InsertNextTuple1(50);
+  newDataArray->InsertNextTuple1(143);
+  newDataArray->InsertNextTuple1(210);
+  newDataArray->InsertNextTuple1(210);
+  defaultHistogram.setDataArray(newDataArray);
+  if (defaultHistogram.dataArray() != newDataArray)
+    {
+    std::cerr << "Line : " << __LINE__
+              << " - Problem with ctkVTKHistogram::setDataArray "
+              << std::endl;
+    return EXIT_FAILURE;
+    }
+
+  //------Test build---------------------------------
+  defaultHistogram.build();
+
+  dataType = VTK_FLOAT;
+  newDataArray = vtkDataArray::CreateDataArray(dataType);
+  defaultHistogram.setDataArray(newDataArray);
+  if (defaultHistogram.dataArray() != newDataArray)
+    {
+    std::cerr << "Line : " << __LINE__
+              << " - Problem with ctkVTKHistogram::setDataArray "
+              << std::endl;
+    return EXIT_FAILURE;
+    }
+
+  //------Test setNumberOfBins-----------------------
+  defaultHistogram.setNumberOfBins(5);
+
+  //-----Test Range----------------------------------
+  defaultHistogram.range(minRange,maxRange);
+
+  //------Test build---------------------------------
+  defaultHistogram.build();
+
+  //------Test value---------------------------------
+  qreal defaultPos = 0.;
+  defaultHistogram.value(defaultPos);
+
+  //------Test ControlPoint--------------------------
+  defaultHistogram.controlPoint(0);
+
+  //------Test removeControlPoint--------------------
+  /// Function NOT implemented
+  defaultHistogram.removeControlPoint(0);
+
+  return EXIT_SUCCESS;
+}
+

+ 64 - 0
Libs/Visualization/VTK/Core/Testing/Cpp/ctkVTKHistogramTest2.cpp

@@ -0,0 +1,64 @@
+
+// Qt includes
+#include <QCoreApplication>
+
+// CTKVTK includes
+#include "ctkVTKHistogram.h"
+
+// VTK includes
+#include <vtkSmartPointer.h>
+#include <vtkDataArray.h>
+
+// STD includes
+#include <cstdlib>
+#include <iostream>
+
+int ctkVTKHistogramTest2( int argc, char * argv [])
+{
+  Q_UNUSED(argc);
+  Q_UNUSED(argv);
+
+//---------------------------------------------------
+// test 2 :
+//---------------------------------------------------
+
+  //------Test build--------------------------------
+  ctkVTKHistogram rgbHistogram;
+
+  vtkSmartPointer<vtkDataArray> rgbDataArray = vtkDataArray::CreateDataArray(VTK_INT);
+  rgbDataArray->SetNumberOfComponents(3);
+  rgbDataArray->InsertNextTuple3(   0,  50,     0);
+  rgbDataArray->InsertNextTuple3(1000, 143, -1412);
+  rgbDataArray->InsertNextTuple3(-543, 210,   151);
+  rgbDataArray->InsertNextTuple3(  -1, 210,    10);
+  rgbHistogram.setDataArray(rgbDataArray);
+  if (rgbHistogram.dataArray() != rgbDataArray)
+    {
+    std::cerr << "Line : " << __LINE__
+              << " - Problem with ctkVTKHistogram::setDataArray "
+              << std::endl;
+    return EXIT_FAILURE;
+    }
+
+  // Generate histogram on the Green values
+  rgbHistogram.setComponent(1);
+
+  //------Test build---------------------------------
+  rgbHistogram.build();
+
+  if (rgbHistogram.count() != (210 - 50 + 1))
+    {
+    std::cerr << "Failed to build histogram" << rgbHistogram.count()
+              << std::endl;
+    return EXIT_FAILURE;
+    }
+
+  if (rgbHistogram.value(210).toInt() != 2)
+    {
+    std::cerr << "Failed to build histogram" << rgbHistogram.value(210).toInt()
+              << std::endl;
+    return EXIT_FAILURE;
+    }
+  return EXIT_SUCCESS;
+}
+

+ 82 - 0
Libs/Visualization/VTK/Core/Testing/Cpp/ctkVTKHistogramTest3.cpp

@@ -0,0 +1,82 @@
+
+// Qt includes
+#include <QCoreApplication>
+
+// CTKVTK includes
+#include "ctkVTKHistogram.h"
+
+// VTK includes
+#include <vtkSmartPointer.h>
+#include <vtkDataArray.h>
+
+// STD includes
+#include <cstdlib>
+#include <iostream>
+
+int ctkVTKHistogramTest3( int argc, char * argv [])
+{
+  Q_UNUSED(argc);
+  Q_UNUSED(argv);
+
+//---------------------------------------------------
+// test 3 :
+//---------------------------------------------------
+
+  //------Test build--------------------------------
+  ctkVTKHistogram histogram;
+
+  vtkSmartPointer<vtkDataArray> dataArray = vtkDataArray::CreateDataArray(VTK_CHAR);
+  dataArray->InsertNextTuple1(0);
+  dataArray->InsertNextTuple1(0);
+  dataArray->InsertNextTuple1(0);
+  dataArray->InsertNextTuple1(0);
+  histogram.setDataArray(dataArray);
+  if (histogram.dataArray() != dataArray)
+    {
+    std::cerr << "Line : " << __LINE__
+              << " - Problem with ctkVTKHistogram::setDataArray "
+              << std::endl;
+    return EXIT_FAILURE;
+    }
+
+  //------Test build---------------------------------
+  histogram.build();
+
+  if (histogram.count() != 256)
+    {
+    std::cerr << "Failed to build histogram" << histogram.count()
+              << std::endl;
+    return EXIT_FAILURE;
+    }
+
+  if (histogram.value(0).toInt() != 4)
+    {
+    std::cerr << "Failed to build histogram" << histogram.value(0).toInt()
+              << std::endl;
+    return EXIT_FAILURE;
+    }
+
+  if (histogram.value(1).toInt() != 0)
+    {
+    std::cerr << "Failed to build histogram" << histogram.value(1).toInt()
+              << std::endl;
+    return EXIT_FAILURE;
+    }
+
+  if (histogram.value(255).toInt() != 0)
+    {
+    std::cerr << "Failed to build histogram" << histogram.value(255).toInt()
+              << std::endl;
+    return EXIT_FAILURE;
+    }
+
+  if (histogram.value(1024).toInt() != 0)
+    {
+    std::cerr << "Failed to build histogram" << histogram.value(1024).toInt()
+              << std::endl;
+    return EXIT_FAILURE;
+    }
+
+  return EXIT_SUCCESS;
+}
+

+ 84 - 0
Libs/Visualization/VTK/Core/Testing/Cpp/ctkVTKHistogramTest4.cpp

@@ -0,0 +1,84 @@
+
+// Qt includes
+#include <QCoreApplication>
+
+// CTKVTK includes
+#include "ctkVTKHistogram.h"
+
+// VTK includes
+#include <vtkSmartPointer.h>
+#include <vtkDataArray.h>
+
+// STD includes
+#include <cstdlib>
+#include <iostream>
+
+int ctkVTKHistogramTest4( int argc, char * argv [])
+{
+  Q_UNUSED(argc);
+  Q_UNUSED(argv);
+
+//---------------------------------------------------
+// test 4 :
+//---------------------------------------------------
+
+  //------Test build--------------------------------
+  ctkVTKHistogram histogram;
+
+  vtkSmartPointer<vtkDataArray> dataArray = vtkDataArray::CreateDataArray(VTK_FLOAT);
+  dataArray->InsertNextTuple1( 10.001);
+  dataArray->InsertNextTuple1( -0.231);
+  dataArray->InsertNextTuple1( 220.0001);
+  dataArray->InsertNextTuple1(1234.0);
+  dataArray->InsertNextTuple1(220.0);
+  histogram.setDataArray(dataArray);
+  if (histogram.dataArray() != dataArray)
+    {
+    std::cerr << "Line : " << __LINE__
+              << " - Problem with ctkVTKHistogram::setDataArray "
+              << std::endl;
+    return EXIT_FAILURE;
+    }
+
+  histogram.setNumberOfBins(256);
+  //------Test build---------------------------------
+  histogram.build();
+
+  if (histogram.count() != 256)
+    {
+    std::cerr << "Failed to build histogram" << histogram.count()
+              << std::endl;
+    return EXIT_FAILURE;
+    }
+
+  if (histogram.value(-0.231).toInt() != 1)
+    {
+    std::cerr << "Failed to build histogram" << histogram.value(-0.231).toInt()
+              << std::endl;
+    return EXIT_FAILURE;
+    }
+
+  if (histogram.value(10.001).toInt() != 1)
+    {
+    std::cerr << "Failed to build histogram" << histogram.value(10.001).toInt()
+              << std::endl;
+    return EXIT_FAILURE;
+    }
+
+  if (histogram.value(220).toInt() != 2)
+    {
+    std::cerr << "Failed to build histogram" << histogram.value(220).toInt()
+              << std::endl;
+    return EXIT_FAILURE;
+    }
+
+  if (histogram.value(500).toInt() != 0)
+    {
+    std::cerr << "Failed to build histogram" << histogram.value(500).toInt()
+              << std::endl;
+    return EXIT_FAILURE;
+    }
+
+  return EXIT_SUCCESS;
+}
+