[QGIS Commit] r9230 - in trunk/qgis/tests: src/core testdata
svn_qgis at osgeo.org
svn_qgis at osgeo.org
Sun Aug 31 11:50:23 EDT 2008
Author: timlinux
Date: 2008-08-31 11:50:23 -0400 (Sun, 31 Aug 2008)
New Revision: 9230
Added:
trunk/qgis/tests/src/core/testcontrastenhancements.cpp
Modified:
trunk/qgis/tests/src/core/CMakeLists.txt
trunk/qgis/tests/testdata/expected_rgbwcmyk01_YeGeo.jp2.png
Log:
Unit tests for raster contrast enhancements
Modified: trunk/qgis/tests/src/core/CMakeLists.txt
===================================================================
--- trunk/qgis/tests/src/core/CMakeLists.txt 2008-08-31 13:20:51 UTC (rev 9229)
+++ trunk/qgis/tests/src/core/CMakeLists.txt 2008-08-31 15:50:23 UTC (rev 9230)
@@ -191,6 +191,27 @@
INSTALL(TARGETS qgis_rasterlayertest RUNTIME DESTINATION ${CMAKE_INSTALL_PREFIX}/bin)
ENDIF (APPLE)
#
+# Contrast Enhancements Test
+#
+SET(qgis_contrastenhancementtest_SRCS testcontrastenhancements.cpp)
+SET(qgis_contrastenhancementtest_MOC_CPPS testcontrastenhancements.cpp)
+QT4_WRAP_CPP(qgis_contrastenhancementtest_MOC_SRCS ${qgis_contrastenhancementtest_MOC_CPPS})
+ADD_CUSTOM_TARGET(qgis_contrastenhancementtestmoc ALL DEPENDS ${qgis_contrastenhancementtest_MOC_SRCS})
+ADD_EXECUTABLE(qgis_contrastenhancementtest ${qgis_contrastenhancementtest_SRCS})
+ADD_DEPENDENCIES(qgis_contrastenhancementtest qgis_contrastenhancementtestmoc)
+TARGET_LINK_LIBRARIES(qgis_contrastenhancementtest ${QT_LIBRARIES} qgis_core)
+SET_TARGET_PROPERTIES(qgis_contrastenhancementtest
+ PROPERTIES INSTALL_RPATH ${QGIS_LIB_DIR}
+ INSTALL_RPATH_USE_LINK_PATH true)
+IF (APPLE)
+ # For Mac OS X, the executable must be at the root of the bundle's executable folder
+ ADD_TEST(qgis_contrastenhancementtest ${CMAKE_INSTALL_PREFIX}/qgis_contrastenhancementtest)
+ INSTALL(TARGETS qgis_contrastenhancementtest RUNTIME DESTINATION ${CMAKE_INSTALL_PREFIX})
+ELSE (APPLE)
+ ADD_TEST(qgis_contrastenhancementtest ${CMAKE_INSTALL_PREFIX}/bin/qgis_contrastenhancementtest)
+ INSTALL(TARGETS qgis_contrastenhancementtest RUNTIME DESTINATION ${CMAKE_INSTALL_PREFIX}/bin)
+ENDIF (APPLE)
+#
# QgsMapLayer test
#
SET(qgis_maplayertest_SRCS testqgsmaplayer.cpp ${util_SRCS})
Added: trunk/qgis/tests/src/core/testcontrastenhancements.cpp
===================================================================
--- trunk/qgis/tests/src/core/testcontrastenhancements.cpp (rev 0)
+++ trunk/qgis/tests/src/core/testcontrastenhancements.cpp 2008-08-31 15:50:23 UTC (rev 9230)
@@ -0,0 +1,83 @@
+/***************************************************************************
+ testcontrastenhancements.cpp
+ --------------------------------------
+ Date : Frida Nov 23 2007
+ Copyright : (C) 2007 by Tim Sutton
+ Email : tim at linfiniti.com
+ ***************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ ***************************************************************************/
+#include <QtTest>
+#include <QObject>
+#include <QApplication>
+#include <QDesktopServices>
+
+
+//qgis includes...
+#include <qgsrasterlayer.h>
+#include <qgscliptominmaxenhancement.h>
+#include <qgscontrastenhancement.h>
+#include <qgslinearminmaxenhancement.h>
+
+/** \ingroup UnitTests
+ * This is a unit test for the ContrastEnhancements contrast enhancement classes.
+ */
+class TestContrastEnhancements: public QObject
+{
+ Q_OBJECT;
+ private slots:
+ void initTestCase();// will be called before the first testfunction is executed.
+ void cleanupTestCase();// will be called after the last testfunction was executed.
+ void init() {};// will be called before each testfunction is executed.
+ void cleanup() {};// will be called after every testfunction.
+
+ void minMaxEnhancementTest();
+ void linearMinMaxEnhancementTest();
+ private:
+ QString mReport;
+};
+
+//runs before all tests
+void TestContrastEnhancements::initTestCase()
+{
+ mReport += "<h1>Raster Contrast Enhancement Tests</h1>\n";
+}
+//runs after all tests
+void TestContrastEnhancements::cleanupTestCase()
+{
+ QString myReportFile = QDir::tempPath() + QDir::separator() + "contrastenhancementest.html";
+ QFile myFile( myReportFile );
+ if ( myFile.open( QIODevice::WriteOnly ) )
+ {
+ QTextStream myQTextStream( &myFile );
+ myQTextStream << mReport;
+ myFile.close();
+ QDesktopServices::openUrl( "file://" + myReportFile );
+ }
+
+}
+
+
+void TestContrastEnhancements::minMaxEnhancementTest()
+{
+ QgsClipToMinMaxEnhancement myEnhancement(QgsContrastEnhancement::QGS_Byte, 10.0, 240.0);
+ QVERIFY(!myEnhancement.isValueInDisplayableRange(0.0));
+ QVERIFY(10.0 == myEnhancement.enhanceValue(0.0)) ;
+ QVERIFY(250.0 == myEnhancement.enhanceValue(240.0)) ;
+}
+void TestContrastEnhancements::linearMinMaxEnhancementTest()
+{
+ QgsLinearMinMaxEnhancement myEnhancement(QgsContrastEnhancement::QGS_Byte, 10.0, 240.0);
+ //0 should be scaled to 10 and not clipped
+ QVERIFY(myEnhancement.isValueInDisplayableRange(0.0));
+ QVERIFY(10.0 == myEnhancement.enhanceValue(0.0)) ;
+ QVERIFY(250.0 == myEnhancement.enhanceValue(240.0)) ;
+}
+QTEST_MAIN( TestContrastEnhancements )
+#include "moc_testcontrastenhancements.cxx"
+
Modified: trunk/qgis/tests/testdata/expected_rgbwcmyk01_YeGeo.jp2.png
===================================================================
(Binary files differ)
More information about the QGIS-commit
mailing list