Skip to content

Commit

Permalink
various windows test fixes:
Browse files Browse the repository at this point in the history
* .gitignore sort and remove duplicates
* show more warnings in tests
* add/update masks for rendering checks on windows
* fix delimited text provider tests
* disable QgsLogger and QgsPalLabelingServer on windows
  • Loading branch information
jef-n committed Jul 5, 2015
1 parent fbad680 commit 5b54e26
Show file tree
Hide file tree
Showing 125 changed files with 316 additions and 203 deletions.
85 changes: 42 additions & 43 deletions .gitignore
@@ -1,67 +1,66 @@
*.pyc
.DS_Store
Thumb.db
desktop.ini
*.*~
*~
*.aux
*.diff
*.orig
*.log*
*.orig
*.out
*.prepare
debian/*.debhelper
debian/*.substvars
Makefile
*.pyc
*.sortinc
*.tex
*.toc
*~
*-stamp
.*.swp
.DS_Store
.idea
.kdev4/
.project
.pydevproject
/CMakeLists.txt.user
/CMakeLists.txt.user.*
/python/plugins/sextante/about/ui_aboutdialogbase.py
/python/plugins/sextante/resources_rc.py
api_doc
build*
debian/*.debhelper
debian/*.substvars
desktop.ini
doc/CODING.tex
doc/INSTALL.tex
i18n/*.qm
Makefile
ms-windows/*.exe*
ms-windows/Installer-Files/postinstall.bat
ms-windows/Installer-Files/preremove.bat
ms-windows/osgeo4w/packages/
ms-windows/osgeo4w/unpacked/
ms-windows/*Setup.exe
ms-windows/osgeo4w/nsis/
ms-windows/osgeo4w/untgz/
scripts/astyle
qtcreator-build/
ms-windows/nsis/
ms-windows/osgeo4w/addons/
ms-windows/packages/
ms-windows/osgeo4w/binary-*
ms-windows/osgeo4w/nsis/
ms-windows/osgeo4w/packages-x86/
ms-windows/osgeo4w/packages-x86_64/
ms-windows/osgeo4w/unpacked/
ms-windows/osgeo4w/untgz/
ms-windows/packages/
ms-windows/progs/
ms-windows/untgz/
qgis.kdev4
qgis.supp
qgis-test.ctest
qtcreator-build/
scripts/astyle.exe
# vim temporary files
.*.swp
*.aux
*.out
*.tex
*.toc
*.sortinc
doc/CODING.tex
doc/INSTALL.tex
scripts/Debug
scripts/qgisstyle*
scripts/RelWithDebInfo
/CMakeLists.txt.user
/CMakeLists.txt.user.*
qgis-test.ctest
i18n/*.qm
.project
.pydevproject
.idea
/python/plugins/sextante/resources_rc.py
/python/plugins/sextante/about/ui_aboutdialogbase.py
scripts/qgisstyle
.kdev4/
qgis.kdev4
qgis.supp
src/core/qgscontexthelp_texts.cpp
src/core/qgsexpression_texts.cpp
tests/testdata/checker360by180.asc.aux.xml
tests/testdata/grass/wgs84/test/.gislock
tests/testdata/grass/wgs84/test6/.gislock
tests/testdata/grass/wgs84/test7/.gislock
tests/testdata/raster/band1_byte_noct_epsg4326.tif.aux.xml
tests/testdata/raster/band1_float32_noct_epsg4326.tif.aux.xml
tests/testdata/raster/band1_int16_noct_epsg4326.tif.aux.xml
tests/testdata/raster/band3_float32_noct_epsg4326.tif.aux.xml
tests/testdata/raster/band3_int16_noct_epsg4326.tif.aux.xml
tests/testdata/checker360by180.asc.aux.xml
tests/testdata/grass/wgs84/test/.gislock
tests/testdata/grass/wgs84/test6/.gislock
tests/testdata/grass/wgs84/test7/.gislock
Thumb.db
6 changes: 4 additions & 2 deletions scripts/generate_test_mask_image.py
Expand Up @@ -80,7 +80,7 @@ def updateMask(control_image_path, rendered_image_path, mask_image_path):
#read current mask, if it exist
mask_image = imageFromPath( mask_image_path )
if mask_image.isNull():
print 'Mask image does not exist, creating'
print 'Mask image does not exist, creating {}'.format( mask_image_path )
mask_image = QImage( control_image.width(), control_image.height(), QImage.Format_ARGB32 )
mask_image.fill( QColor(0,0,0) )

Expand Down Expand Up @@ -113,7 +113,9 @@ def updateMask(control_image_path, rendered_image_path, mask_image_path):
if mismatch_count:
#update mask
mask_image.save( mask_image_path, "png" )
print 'Updated {} pixels'.format( mismatch_count )
print 'Updated {} pixels in {}'.format( mismatch_count, mask_image_path )
else:
print 'No mismatches in {}'.format( mask_image_path )

parser = argparse.ArgumentParser() # OptionParser("usage: %prog control_image rendered_image mask_image")
parser.add_argument('control_image')
Expand Down
20 changes: 19 additions & 1 deletion src/core/qgsfontutils.cpp
Expand Up @@ -42,7 +42,25 @@ bool QgsFontUtils::fontFamilyOnSystem( const QString& family )
bool QgsFontUtils::fontFamilyHasStyle( const QString& family, const QString& style )
{
QFontDatabase fontDB;
return ( fontFamilyOnSystem( family ) && fontDB.styles( family ).contains( style ) );
if ( !fontFamilyOnSystem( family ) )
return false;

if ( fontDB.styles( family ).contains( style ) )
return true;

#ifdef Q_OS_WIN
QString modified( style );
if ( style == "Roman" )
modified = "Normal";
if ( style == "Oblique" )
modified = "Italic";
if ( style == "Bold Oblique" )
modified = "Bold Italic";
if ( fontDB.styles( family ).contains( modified ) )
return true;
#endif

return false;
}

bool QgsFontUtils::fontFamilyMatchOnSystem( const QString& family, QString* chosen, bool* match )
Expand Down
79 changes: 37 additions & 42 deletions src/core/qgsrenderchecker.cpp
Expand Up @@ -255,9 +255,14 @@ bool QgsRenderChecker::compareImages( QString theTestName,
}
if ( ! theRenderedImageFile.isEmpty() )
{
#ifndef Q_OS_WIN
mRenderedImageFile = theRenderedImageFile;
#else
mRenderedImageFile = theRenderedImageFile.replace( "\\", "/" );
#endif
}
else if ( mRenderedImageFile.isEmpty() )

if ( mRenderedImageFile.isEmpty() )
{
qDebug( "QgsRenderChecker::runTest failed - Rendered Image File not set." );
mReport = "<table>"
Expand All @@ -266,6 +271,7 @@ bool QgsRenderChecker::compareImages( QString theTestName,
"Image File not set.</td></tr></table>\n";
return false;
}

//
// Load /create the images
//
Expand Down Expand Up @@ -308,16 +314,16 @@ bool QgsRenderChecker::compareImages( QString theTestName,
mReport = QString( "<script src=\"file://%1/../renderchecker.js\"></script>\n" ).arg( TEST_DATA_DIR );
mReport += "<table>";
mReport += "<tr><td colspan=2>";
mReport += QString( "Test image and result image for %1<br>"
mReport += QString( "<tr><td colspan=2>"
"Test image and result image for %1<br>"
"Expected size: %2 w x %3 h (%4 pixels)<br>"
"Actual size: %5 w x %6 h (%7 pixels)" )
"Actual size: %5 w x %6 h (%7 pixels)"
"</td></tr>" )
.arg( theTestName )
.arg( myExpectedImage.width() ).arg( myExpectedImage.height() ).arg( mMatchTarget )
.arg( myResultImage.width() ).arg( myResultImage.height() ).arg( myPixelCount );

mReport += "</td></tr>";
mReport += "<tr><td colspan=2>\n";
mReport += QString( "Expected Duration : <= %1 (0 indicates not specified)<br>"
mReport += QString( "<tr><td colspan=2>\n"
"Expected Duration : <= %1 (0 indicates not specified)<br>"
"Actual Duration : %2 ms<br></td></tr>" )
.arg( mElapsedTimeTarget )
.arg( mElapsedTime );
Expand Down Expand Up @@ -368,7 +374,7 @@ bool QgsRenderChecker::compareImages( QString theTestName,

if ( mMatchTarget != myPixelCount )
{
qDebug( "Test image and result image for %s are different - FAILING!", theTestName.toLocal8Bit().constData() );
qDebug( "Test image and result image for %s are different dimensions - FAILING!", theTestName.toLocal8Bit().constData() );
mReport += "<tr><td colspan=3>";
mReport += "<font color=red>Expected image and result image for " + theTestName + " are different dimensions - FAILING!</font>";
mReport += "</td></tr>";
Expand Down Expand Up @@ -439,40 +445,14 @@ bool QgsRenderChecker::compareImages( QString theTestName,
//
// Send match result to report
//
mReport += "<tr><td colspan=3>" +
QString::number( mMismatchCount ) + "/" +
QString::number( mMatchTarget ) +
" pixels mismatched (allowed threshold: " +
QString::number( theMismatchCount ) +
", allowed color component tolerance: " +
QString::number( mColorTolerance ) + ")";
mReport += "</td></tr>";
mReport += QString( "<tr><td colspan=3>%1/%2 pixels mismatched (allowed threshold: %3, allowed color component tolerance: %4)</td></tr>" )
.arg( mMismatchCount ).arg( mMatchTarget ).arg( theMismatchCount ).arg( mColorTolerance );

//
// And send it to CDash
//
emitDashMessage( "Mismatch Count", QgsDartMeasurement::Integer, QString( "%1/%2" ).arg( mMismatchCount ).arg( mMatchTarget ) );

bool myAnomalyMatchFlag = isKnownAnomaly( myDiffImageFile );

if ( myAnomalyMatchFlag )
{
mReport += "<tr><td colspan=3>"
"Difference image matched a known anomaly - passing test! "
"</td></tr>";
return true;
}
else
{
mReport += "<tr><td colspan=3>"
"</td></tr>";
emitDashMessage( "No Anomalies Match", QgsDartMeasurement::Text, "Difference image did not match any known anomaly."
" If you feel the difference image should be considered an anomaly "
"you can do something like this\n"
"cp " + myDiffImageFile + " ../tests/testdata/control_images/" + theTestName +
"/<imagename>.{wld,png}" );
}

if ( mMismatchCount <= theMismatchCount )
{
mReport += "<tr><td colspan = 3>\n";
Expand All @@ -494,12 +474,27 @@ bool QgsRenderChecker::compareImages( QString theTestName,
return true;
}
}
else

bool myAnomalyMatchFlag = isKnownAnomaly( myDiffImageFile );
if ( myAnomalyMatchFlag )
{
mReport += "<tr><td colspan = 3>\n";
mReport += "<font color=red>Test image and result image for " + theTestName + " are mismatched</font><br>";
mReport += "</td></tr>";
mReport += myImagesString;
return false;
mReport += "<tr><td colspan=3>"
"Difference image matched a known anomaly - passing test! "
"</td></tr>";
return true;
}

mReport += "<tr><td colspan=3></td></tr>";
emitDashMessage( "Image mismatch", QgsDartMeasurement::Text, "Difference image did not match any known anomaly or mask."
" If you feel the difference image should be considered an anomaly "
"you can do something like this\n"
"cp '" + myDiffImageFile + "' " + controlImagePath() + mControlName +
"/\nIf it should be included in the mask run\n"
"scripts/generate_test_mask_image.py '" + mExpectedImageFile + "' '" + mRenderedImageFile + "'\n" );

mReport += "<tr><td colspan = 3>\n";
mReport += "<font color=red>Test image and result image for " + theTestName + " are mismatched</font><br>";
mReport += "</td></tr>";
mReport += myImagesString;
return false;
}
6 changes: 3 additions & 3 deletions src/core/qgsrenderchecker.h
Expand Up @@ -66,9 +66,9 @@ class CORE_EXPORT QgsRenderChecker
/** Prefix where the control images are kept.
* This will be appended to controlImagePath
*/
void setControlPathPrefix( const QString &theName ) { mControlPathPrefix = theName + QDir::separator(); }
void setControlPathPrefix( const QString &theName ) { mControlPathPrefix = theName + "/"; }

void setControlPathSuffix( const QString& theName ) { mControlPathSuffix = theName + QDir::separator(); }
void setControlPathSuffix( const QString& theName ) { mControlPathSuffix = theName + "/"; }

/** Get an md5 hash that uniquely identifies an image */
QString imageToHash( QString theImageFile );
Expand Down Expand Up @@ -129,7 +129,7 @@ class CORE_EXPORT QgsRenderChecker
*/
bool isKnownAnomaly( QString theDiffImageFile );

/**Draws a checkboard pattern for image backgrounds, so that transparency is visible
/** Draws a checkboard pattern for image backgrounds, so that transparency is visible
* without requiring a transparent background for the image
*/
static void drawBackground( QImage* image );
Expand Down
4 changes: 2 additions & 2 deletions src/providers/delimitedtext/qgsdelimitedtextfile.cpp
Expand Up @@ -20,6 +20,7 @@

#include <QtGlobal>
#include <QFile>
#include <QFileInfo>
#include <QDataStream>
#include <QTextStream>
#include <QFileSystemWatcher>
Expand Down Expand Up @@ -840,7 +841,6 @@ QgsDelimitedTextFile::Status QgsDelimitedTextFile::parseQuoted( QString &buffer,

bool QgsDelimitedTextFile::isValid()
{

return mDefinitionValid && QFile::exists( mFileName );
return mDefinitionValid && QFile::exists( mFileName ) && QFileInfo( mFileName ).size() > 0;
}

1 change: 1 addition & 0 deletions src/providers/spatialite/qgsspatialiteprovider.cpp
Expand Up @@ -4060,6 +4060,7 @@ void QgsSpatiaLiteProvider::closeDb()
if ( handle )
{
QgsSqliteHandle::closeDb( handle );
handle = 0;
}
}

Expand Down
2 changes: 1 addition & 1 deletion tests/src/analysis/CMakeLists.txt
Expand Up @@ -63,7 +63,7 @@ MACRO (ADD_QGIS_TEST testname testsrc)
${QT_QTCORE_LIBRARY}
${QT_QTTEST_LIBRARY}
qgis_analysis)
ADD_TEST(qgis_${testname} ${CMAKE_CURRENT_BINARY_DIR}/../../../output/bin/qgis_${testname})
ADD_TEST(qgis_${testname} ${CMAKE_CURRENT_BINARY_DIR}/../../../output/bin/qgis_${testname} -maxwarnings 10000)
#SET_TARGET_PROPERTIES(qgis_${testname} PROPERTIES
# INSTALL_RPATH ${CMAKE_INSTALL_PREFIX}/${QGIS_LIB_DIR}
# INSTALL_RPATH_USE_LINK_PATH true )
Expand Down
2 changes: 1 addition & 1 deletion tests/src/app/CMakeLists.txt
Expand Up @@ -82,7 +82,7 @@ MACRO (ADD_QGIS_TEST testname testsrc)
IF (APPLE)
TARGET_LINK_LIBRARIES(qgis_${testname} ${APP_SERVICES_LIBRARY} )
ENDIF(APPLE)
ADD_TEST(qgis_${testname} ${CMAKE_CURRENT_BINARY_DIR}/../../../output/bin/qgis_${testname})
ADD_TEST(qgis_${testname} ${CMAKE_CURRENT_BINARY_DIR}/../../../output/bin/qgis_${testname} -maxwarnings 10000)
#SET_TARGET_PROPERTIES(qgis_${testname} PROPERTIES
# INSTALL_RPATH ${CMAKE_INSTALL_PREFIX}/${QGIS_LIB_DIR}
# INSTALL_RPATH_USE_LINK_PATH true )
Expand Down
2 changes: 1 addition & 1 deletion tests/src/core/CMakeLists.txt
Expand Up @@ -68,7 +68,7 @@ MACRO (ADD_QGIS_TEST testname testsrc)
${GEOS_LIBRARY}
${GDAL_LIBRARY}
qgis_core)
ADD_TEST(qgis_${testname} ${CMAKE_CURRENT_BINARY_DIR}/../../../output/bin/qgis_${testname})
ADD_TEST(qgis_${testname} ${CMAKE_CURRENT_BINARY_DIR}/../../../output/bin/qgis_${testname} -maxwarnings 10000)
#SET_TARGET_PROPERTIES(qgis_${testname} PROPERTIES
# INSTALL_RPATH ${CMAKE_INSTALL_PREFIX}/${QGIS_LIB_DIR}
# INSTALL_RPATH_USE_LINK_PATH true )
Expand Down

0 comments on commit 5b54e26

Please sign in to comment.