mirror of
https://github.com/qgis/QGIS.git
synced 2025-11-28 00:06:23 -05:00
Unit tests for raster contrast enhancements
git-svn-id: http://svn.osgeo.org/qgis/trunk@9230 c8812cc2-4d05-0410-92ff-de0c093fc19c
This commit is contained in:
parent
443f73576d
commit
66ed0b9071
@ -191,6 +191,27 @@ ELSE (APPLE)
|
|||||||
INSTALL(TARGETS qgis_rasterlayertest RUNTIME DESTINATION ${CMAKE_INSTALL_PREFIX}/bin)
|
INSTALL(TARGETS qgis_rasterlayertest RUNTIME DESTINATION ${CMAKE_INSTALL_PREFIX}/bin)
|
||||||
ENDIF (APPLE)
|
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
|
# QgsMapLayer test
|
||||||
#
|
#
|
||||||
SET(qgis_maplayertest_SRCS testqgsmaplayer.cpp ${util_SRCS})
|
SET(qgis_maplayertest_SRCS testqgsmaplayer.cpp ${util_SRCS})
|
||||||
|
|||||||
83
tests/src/core/testcontrastenhancements.cpp
Normal file
83
tests/src/core/testcontrastenhancements.cpp
Normal file
@ -0,0 +1,83 @@
|
|||||||
|
/***************************************************************************
|
||||||
|
testcontrastenhancements.cpp
|
||||||
|
--------------------------------------
|
||||||
|
Date : Frida Nov 23 2007
|
||||||
|
Copyright : (C) 2007 by Tim Sutton
|
||||||
|
Email : tim@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"
|
||||||
|
|
||||||
BIN
tests/testdata/expected_rgbwcmyk01_YeGeo.jp2.png
vendored
BIN
tests/testdata/expected_rgbwcmyk01_YeGeo.jp2.png
vendored
Binary file not shown.
|
Before Width: | Height: | Size: 639 B After Width: | Height: | Size: 641 B |
Loading…
x
Reference in New Issue
Block a user