Showing with 2,748 additions and 6,517 deletions.
  1. +28 −0 python/core/qgsfontutils.sip
  2. +3 −6 src/app/CMakeLists.txt
  3. +4 −8 src/app/main.cpp
  4. +1 −0 src/core/qgsapplication.cpp
  5. +94 −1 src/core/qgsfontutils.cpp
  6. +28 −0 src/core/qgsfontutils.h
  7. +9 −4 src/core/qgsrenderchecker.cpp
  8. +3 −6 src/mapserver/CMakeLists.txt
  9. +2 −11 src/mapserver/qgis_map_serv.cpp
  10. +2 −0 tests/src/python/CMakeLists.txt
  11. +628 −334 tests/src/python/qgis_local_server.py
  12. 0 tests/src/python/qgis_local_server_spawn/__init__.py
  13. +0 −325 tests/src/python/qgis_local_server_spawn/flup/ChangeLog
  14. +0 −18 tests/src/python/qgis_local_server_spawn/flup/PKG-INFO
  15. +0 −6 tests/src/python/qgis_local_server_spawn/flup/README_QGIS.txt
  16. +0 −1 tests/src/python/qgis_local_server_spawn/flup/__init__.py
  17. +0 −5 tests/src/python/qgis_local_server_spawn/flup/server/__init__.py
  18. +0 −207 tests/src/python/qgis_local_server_spawn/flup/server/ajp.py
  19. +0 −978 tests/src/python/qgis_local_server_spawn/flup/server/ajp_base.py
  20. +0 −180 tests/src/python/qgis_local_server_spawn/flup/server/threadedserver.py
  21. +0 −150 tests/src/python/qgis_local_server_spawn/flup/server/threadpool.py
  22. +0 −473 tests/src/python/qgis_local_server_spawn/flup_fcgi_client.py
  23. +0 −54 tests/src/python/qgis_local_server_spawn/qgis_server_local_spawn.py
  24. +0 −2 tests/src/python/qgis_local_server_spawn/spawn-fcgi/AUTHORS
  25. +0 −20 tests/src/python/qgis_local_server_spawn/spawn-fcgi/CMakeLists.txt
  26. +0 −31 tests/src/python/qgis_local_server_spawn/spawn-fcgi/COPYING
  27. +0 −4 tests/src/python/qgis_local_server_spawn/spawn-fcgi/Makefile.am
  28. +0 −44 tests/src/python/qgis_local_server_spawn/spawn-fcgi/NEWS
  29. +0 −41 tests/src/python/qgis_local_server_spawn/spawn-fcgi/README
  30. +0 −24 tests/src/python/qgis_local_server_spawn/spawn-fcgi/autogen.sh
  31. +0 −88 tests/src/python/qgis_local_server_spawn/spawn-fcgi/configure.ac
  32. +0 −1 tests/src/python/qgis_local_server_spawn/spawn-fcgi/doc/Makefile.am
  33. +0 −49 tests/src/python/qgis_local_server_spawn/spawn-fcgi/doc/run-generic
  34. +0 −8 tests/src/python/qgis_local_server_spawn/spawn-fcgi/doc/run-php
  35. +0 −8 tests/src/python/qgis_local_server_spawn/spawn-fcgi/doc/run-rails
  36. +0 −122 tests/src/python/qgis_local_server_spawn/spawn-fcgi/spawn-fcgi.1
  37. +0 −72 tests/src/python/qgis_local_server_spawn/spawn-fcgi/src/CMakeLists.txt
  38. +0 −5 tests/src/python/qgis_local_server_spawn/spawn-fcgi/src/Makefile.am
  39. +0 −37 tests/src/python/qgis_local_server_spawn/spawn-fcgi/src/config.h.cmake
  40. +0 −732 tests/src/python/qgis_local_server_spawn/spawn-fcgi/src/spawn-fcgi.c
  41. +0 −11 tests/src/python/qgis_local_server_spawn/spawn-qgis-server-local.sh
  42. +195 −0 tests/src/python/test_qgis_local_server.py
  43. +78 −0 tests/src/python/test_qgsfontutils.py
  44. +6 −8 tests/src/python/test_qgspallabeling_base.py
  45. +22 −59 tests/src/python/test_qgspallabeling_server.py
  46. +1 −1 tests/src/python/test_qgspallabeling_tests.py
  47. +30 −14 tests/src/python/utilities.py
  48. BIN tests/testdata/control_images/expected_qgis_local_server/expected_qgis_local_server.png
  49. +0 −159 tests/testdata/font/AUTHORS
  50. +0 −341 tests/testdata/font/COPYING
  51. +0 −430 tests/testdata/font/CREDITS
  52. +0 −1,257 tests/testdata/font/ChangeLog
  53. +0 −8 tests/testdata/font/FreeSansQGIS-README.txt
  54. BIN tests/testdata/font/FreeSansQGIS-chars.png
  55. BIN tests/testdata/font/FreeSansQGIS.ttf
  56. +124 −0 tests/testdata/font/QGIS-Vera/COPYRIGHT.TXT
  57. +9 −0 tests/testdata/font/QGIS-Vera/QGIS-Vera-README.txt
  58. BIN tests/testdata/font/QGIS-Vera/QGIS-Vera.ttf
  59. BIN tests/testdata/font/QGIS-Vera/QGIS-Vera.vfb
  60. BIN tests/testdata/font/QGIS-Vera/QGIS-VeraBI.ttf
  61. BIN tests/testdata/font/QGIS-Vera/QGIS-VeraBI.vfb
  62. BIN tests/testdata/font/QGIS-Vera/QGIS-VeraBI_font-table.pdf
  63. BIN tests/testdata/font/QGIS-Vera/QGIS-VeraBd.ttf
  64. BIN tests/testdata/font/QGIS-Vera/QGIS-VeraBd.vfb
  65. BIN tests/testdata/font/QGIS-Vera/QGIS-VeraBd_font-table.pdf
  66. BIN tests/testdata/font/QGIS-Vera/QGIS-VeraIt.ttf
  67. BIN tests/testdata/font/QGIS-Vera/QGIS-VeraIt.vfb
  68. BIN tests/testdata/font/QGIS-Vera/QGIS-VeraIt_font-table.pdf
  69. BIN tests/testdata/font/QGIS-Vera/QGIS-Vera_font-table.pdf
  70. +11 −0 tests/testdata/font/QGIS-Vera/README.TXT
  71. +162 −0 tests/testdata/font/QGIS-Vera/RELEASENOTES.TXT
  72. +0 −142 tests/testdata/font/README
  73. +38 −31 tests/testdata/labeling/{test-connection.qgs → test-labeling.qgs}
  74. +92 −0 tests/testdata/qgis_local_server/fcgi/scripts/spawn_fcgi_mac.sh
  75. +10 −0 tests/testdata/qgis_local_server/index.html
  76. +27 −0 tests/testdata/qgis_local_server/lighttpd/config/conf/access_log.conf
  77. +47 −0 tests/testdata/qgis_local_server/lighttpd/config/conf/debug.conf
  78. +55 −0 tests/testdata/qgis_local_server/lighttpd/config/conf/dirlisting.conf
  79. +16 −0 tests/testdata/qgis_local_server/lighttpd/config/conf/fastcgi.conf
  80. +78 −0 tests/testdata/qgis_local_server/lighttpd/config/conf/mime.conf
  81. +51 −0 tests/testdata/qgis_local_server/lighttpd/config/conf/scgi.conf
  82. +28 −0 tests/testdata/qgis_local_server/lighttpd/config/conf/simple_vhost.conf
  83. +24 −0 tests/testdata/qgis_local_server/lighttpd/config/conf/status.conf
  84. +64 −0 tests/testdata/qgis_local_server/lighttpd/config/lighttpd_unix.conf
  85. +172 −0 tests/testdata/qgis_local_server/lighttpd/config/modules.conf
  86. +85 −0 tests/testdata/qgis_local_server/lighttpd/scripts/lighttpd_mac.sh
  87. +21 −0 tests/testdata/qgis_local_server/test-project/background.qml
  88. BIN tests/testdata/qgis_local_server/test-project/features_v3.sqlite
  89. +27 −0 tests/testdata/qgis_local_server/test-project/point.qml
  90. +469 −0 tests/testdata/qgis_local_server/test-project/test-server.qgs
  91. +4 −1 tests/testdata/testdata.qrc
28 changes: 28 additions & 0 deletions python/core/qgsfontutils.sip
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,14 @@ class QgsFontUtils
*/
static bool fontFamilyOnSystem( const QString& family );

/** Check whether font family on system has specific style
* @param family The family to test
* @param style The style to test for
* @returns Whether family has style
* @note Added in QGIS 2.1
*/
static bool fontFamilyHasStyle( const QString& family, const QString& style );

/** Check whether font family is on system
* @param family The family to test
* @param chosen The actual family (possibly from different foundry) returned by system
Expand All @@ -33,4 +41,24 @@ class QgsFontUtils
*/
static bool updateFontViaStyle( QFont& f, const QString& fontstyle, bool fallback = false );

/** Get standard test font family
* @note Added in QGIS 2.1
*/
static QString standardTestFontFamily();

/** Loads standard test fonts from filesystem or qrc resource
* @param loadstyles List of styles to load, e.g. All, Roman, Oblique, Bold, Bold Oblique
* @returns Whether any font was loaded
* @note Done by default on debug app/server startup to ensure fonts available for unit tests (Roman and Bold)
* @note Added in QGIS 2.1
*/
static bool loadStandardTestFonts( QStringList loadstyles );

/** Get standard test font with specific style
* @param style Style to load, e.g. Roman, Oblique, Bold, Bold Oblique
* @param pointsize Font point size to set
* @returns QFont
* @note Added in QGIS 2.1
*/
static QFont getStandardTestFont( const QString& style = "Roman", int pointsize = 12 );
};
9 changes: 3 additions & 6 deletions src/app/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -373,12 +373,9 @@ SET(IMAGE_RCCS ../../images/images.qrc)

QT4_ADD_RESOURCES(IMAGE_RCC_SRCS ${IMAGE_RCCS})

SET(TEST_RCC_SRCS)
IF (ENABLE_TESTS)
# add test resources, e.g. standard test font
SET(TEST_RCCS ../../tests/testdata/testdata.qrc)
QT4_ADD_RESOURCES(TEST_RCC_SRCS ${TEST_RCCS})
ENDIF (ENABLE_TESTS)
# add test resources, e.g. standard test font
SET(TEST_RCCS ../../tests/testdata/testdata.qrc)
QT4_ADD_RESOURCES(TEST_RCC_SRCS ${TEST_RCCS})

QT4_WRAP_CPP(QGIS_APP_MOC_SRCS ${QGIS_APP_MOC_HDRS})

Expand Down
12 changes: 4 additions & 8 deletions src/app/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
#include <QMessageBox>

#include "qgscustomization.h"
#include "qgsfontutils.h"
#include "qgspluginregistry.h"
#include "qgsmessagelog.h"
#include "qgspythonrunner.h"
Expand Down Expand Up @@ -736,14 +737,9 @@ int main( int argc, char *argv[] )
}
}

// load standard test font from testdata.qrc (for unit tests)
QFile testFont( ":/testdata/font/FreeSansQGIS.ttf" );
if ( testFont.open( QIODevice::ReadOnly ) )
{
int fontID = QFontDatabase::addApplicationFontFromData( testFont.readAll() );
Q_UNUSED( fontID );
QgsDebugMsg( QString( "Test font %1loaded from testdata.qrc" ).arg( fontID != -1 ? "" : "NOT " ) );
} // else app wasn't built with ENABLE_TESTS
#ifdef QGISDEBUG
QgsFontUtils::loadStandardTestFonts( QStringList() << "Roman" << "Bold" );
#endif

// Set the application style. If it's not set QT will use the platform style except on Windows
// as it looks really ugly so we use QPlastiqueStyle.
Expand Down
1 change: 1 addition & 0 deletions src/core/qgsapplication.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ void QgsApplication::init( QString customConfigPath )
qRegisterMetaType<QgsGeometry::Error>( "QgsGeometry::Error" );

QString prefixPath( getenv( "QGIS_PREFIX_PATH" ) ? getenv( "QGIS_PREFIX_PATH" ) : applicationDirPath() );
// QgsDebugMsg( QString( "prefixPath(): %1" ).arg( prefixPath ) );

// check if QGIS is run from build directory (not the install directory)
QFile f;
Expand Down
95 changes: 94 additions & 1 deletion src/core/qgsfontutils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,11 @@

#include "qgsfontutils.h"

#include "qgsapplication.h"
#include "qgslogger.h"

#include <QApplication>
#include <QFile>
#include <QFont>
#include <QFontDatabase>
#include <QFontInfo>
Expand All @@ -32,7 +36,13 @@ bool QgsFontUtils::fontFamilyOnSystem( const QString& family )
{
QFont tmpFont = QFont( family );
// compare just beginning of family string in case 'family [foundry]' differs
return family.startsWith( tmpFont.family(), Qt::CaseInsensitive );
return tmpFont.family().startsWith( family, Qt::CaseInsensitive );
}

bool QgsFontUtils::fontFamilyHasStyle( const QString& family, const QString& style )
{
QFontDatabase fontDB;
return ( fontFamilyOnSystem( family ) && fontDB.styles( family ).contains( style ) );
}

bool QgsFontUtils::fontFamilyMatchOnSystem( const QString& family, QString* chosen, bool* match )
Expand Down Expand Up @@ -191,3 +201,86 @@ bool QgsFontUtils::updateFontViaStyle( QFont& f, const QString& fontstyle, bool

return false;
}

QString QgsFontUtils::standardTestFontFamily()
{
return "QGIS Vera Sans";
}

bool QgsFontUtils::loadStandardTestFonts( QStringList loadstyles )
{
// load standard test font from filesystem or testdata.qrc (for unit tests and general testing)
bool fontsLoaded = false;

QString fontFamily = standardTestFontFamily();
QMap<QString, QString> fontStyles;
fontStyles.insert( "Roman", "QGIS-Vera/QGIS-Vera.ttf" );
fontStyles.insert( "Oblique", "QGIS-Vera/QGIS-VeraIt.ttf" );
fontStyles.insert( "Bold", "QGIS-Vera/QGIS-VeraBd.ttf" );
fontStyles.insert( "Bold Oblique", "QGIS-Vera/QGIS-VeraBI.ttf" );

QMap<QString, QString>::const_iterator f = fontStyles.constBegin();
for ( ; f != fontStyles.constEnd(); ++f )
{
QString fontstyle( f.key() );
QString fontpath( f.value() );
if ( !( loadstyles.contains( fontstyle ) || loadstyles.contains( "All" ) ) )
{
continue;
}
QString familyStyle = QString( "%1 %2" ).arg( fontFamily ).arg( fontstyle );

if ( fontFamilyHasStyle( fontFamily, fontstyle ) )
{
fontsLoaded = ( fontsLoaded || false );
QgsDebugMsg( QString( "Test font '%1' already available" ).arg( familyStyle ) );
}
else
{
bool loaded = false;
if ( QgsApplication::isRunningFromBuildDir() )
{
// workaround for bugs with Qt 4.8.5 (other versions?) on Mac 10.9, where fonts
// from qrc resources load but fail to work and default font is substituted [LS]:
// https://bugreports.qt-project.org/browse/QTBUG-30917
// https://bugreports.qt-project.org/browse/QTBUG-32789
QString fontPath( QgsApplication::buildSourcePath() + "/tests/testdata/font/" + fontpath );
int fontID = QFontDatabase::addApplicationFont( fontPath );
loaded = ( fontID != -1 );
fontsLoaded = ( fontsLoaded || loaded );
QgsDebugMsg( QString( "Test font '%1' %2 from filesystem" )
.arg( familyStyle ).arg( loaded ? "loaded" : "FAILED to load" ) );
}
else
{
QFile fontResource( ":/testdata/font/" + fontpath );
if ( fontResource.open( QIODevice::ReadOnly ) )
{
int fontID = QFontDatabase::addApplicationFontFromData( fontResource.readAll() );
loaded = ( fontID != -1 );
fontsLoaded = ( fontsLoaded || loaded );
}
QgsDebugMsg( QString( "Test font '%1' %2 from testdata.qrc" )
.arg( familyStyle ).arg( loaded ? "loaded" : "FAILED to load" ) );
}
}
}

return fontsLoaded;
}

QFont QgsFontUtils::getStandardTestFont( const QString& style, int pointsize )
{
QFontDatabase fontDB;
if ( ! fontFamilyHasStyle( standardTestFontFamily(), style ) )
{
loadStandardTestFonts( QStringList() << style );
}

QFont f = fontDB.font( standardTestFontFamily(), style, pointsize );
// in case above statement fails to set style
f.setBold( style.contains( "Bold" ) );
f.setItalic( style.contains( "Oblique" ) );

return f;
}
28 changes: 28 additions & 0 deletions src/core/qgsfontutils.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,14 @@ class CORE_EXPORT QgsFontUtils
*/
static bool fontFamilyOnSystem( const QString& family );

/** Check whether font family on system has specific style
* @param family The family to test
* @param style The style to test for
* @returns Whether family has style
* @note Added in QGIS 2.1
*/
static bool fontFamilyHasStyle( const QString& family, const QString& style );

/** Check whether font family is on system
* @param family The family to test
* @param chosen The actual family (possibly from different foundry) returned by system
Expand All @@ -51,6 +59,26 @@ class CORE_EXPORT QgsFontUtils
*/
static bool updateFontViaStyle( QFont& f, const QString& fontstyle, bool fallback = false );

/** Get standard test font family
* @note Added in QGIS 2.1
*/
static QString standardTestFontFamily();

/** Loads standard test fonts from filesystem or qrc resource
* @param loadstyles List of styles to load, e.g. All, Roman, Oblique, Bold, Bold Oblique
* @returns Whether any font was loaded
* @note Done by default on debug app/server startup to ensure fonts available for unit tests (Roman and Bold)
* @note Added in QGIS 2.1
*/
static bool loadStandardTestFonts( QStringList loadstyles );

/** Get standard test font with specific style
* @param style Style to load, e.g. Roman, Oblique, Bold, Bold Oblique
* @param pointsize Font point size to set
* @returns QFont
* @note Added in QGIS 2.1
*/
static QFont getStandardTestFont( const QString& style = "Roman", int pointsize = 12 );
};

#endif // QGSFONTUTILS_H
13 changes: 9 additions & 4 deletions src/core/qgsrenderchecker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -93,10 +93,10 @@ bool QgsRenderChecker::isKnownAnomaly( QString theDiffImageFile )
QString myAnomalyHash = imageToHash( controlImagePath() + mControlName
+ QDir::separator() + myFile );
QString myHashMessage = QString(
"Checking if anomaly %1 (hash %2)" )
"Checking if anomaly %1 (hash %2)<br>" )
.arg( myFile )
.arg( myAnomalyHash );
myHashMessage += QString( " matches %1 (hash %2)" )
myHashMessage += QString( "&nbsp; matches %1 (hash %2)" )
.arg( theDiffImageFile )
.arg( myImageHash );
//foo CDash
Expand Down Expand Up @@ -246,8 +246,13 @@ bool QgsRenderChecker::compareImages( QString theTestName,
mReport += "Actual Duration : " + QString::number( mElapsedTime ) + "ms<br>";

// limit image size in page to something reasonable
int imgWidth = qMin( myExpectedImage.width(), 400 );
int imgHeight = myExpectedImage.height() * imgWidth / myExpectedImage.width();
int imgWidth = 420;
int imgHeight = 280;
if ( ! myExpectedImage.isNull() )
{
imgWidth = qMin( myExpectedImage.width(), imgWidth );
imgHeight = myExpectedImage.height() * imgWidth / myExpectedImage.width();
}
QString myImagesString = "</td></tr>"
"<tr><td>Test Result:</td><td>Expected Result:</td><td>Difference (all blue is good, any red is bad)</td></tr>\n"
"<tr><td><img width=" + QString::number( imgWidth ) +
Expand Down
9 changes: 3 additions & 6 deletions src/mapserver/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -67,12 +67,9 @@ QT4_WRAP_CPP (qgis_mapserv_MOC_SRCS ${qgis_mapserv_MOC_HDRS})

QT4_ADD_RESOURCES(qgis_mapserv_RCC_SRCS ${qgis_mapserv_RCCS})

SET(qgis_mapserv_TESTRCC_SRCS)
IF (ENABLE_TESTS)
# add test resources, e.g. standard test font
SET(qgis_mapserv_TESTRCCS ../../tests/testdata/testdata.qrc)
QT4_ADD_RESOURCES(qgis_mapserv_TESTRCC_SRCS ${qgis_mapserv_TESTRCCS})
ENDIF(ENABLE_TESTS)
# add test resources, e.g. standard test font
SET(qgis_mapserv_TESTRCCS ../../tests/testdata/testdata.qrc)
QT4_ADD_RESOURCES(qgis_mapserv_TESTRCC_SRCS ${qgis_mapserv_TESTRCCS})

ADD_EXECUTABLE(qgis_mapserv.fcgi
${qgis_mapserv_SRCS}
Expand Down
13 changes: 2 additions & 11 deletions src/mapserver/qgis_map_serv.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ map service syntax for SOAP/HTTP POST
#include "qgsapplication.h"
#include "qgscapabilitiescache.h"
#include "qgsconfigcache.h"
#include "qgsfontutils.h"
#include "qgsgetrequesthandler.h"
#include "qgspostrequesthandler.h"
#include "qgssoaprequesthandler.h"
Expand Down Expand Up @@ -248,22 +249,12 @@ int main( int argc, char * argv[] )
theMapRenderer->setLabelingEngine( new QgsPalLabeling() );

#ifdef QGSMSDEBUG
// load standard test font from testdata.qrc (for unit tests)
bool testFontLoaded = false;
QFile testFont( ":/testdata/font/FreeSansQGIS.ttf" );
if ( testFont.open( QIODevice::ReadOnly ) )
{
int fontID = QFontDatabase::addApplicationFontFromData( testFont.readAll() );
testFontLoaded = ( fontID != -1 );
} // else app wasn't built with ENABLE_TESTS or not GUI app
QgsFontUtils::loadStandardTestFonts( QStringList() << "Roman" << "Bold" );
#endif

while ( fcgi_accept() >= 0 )
{
printRequestInfos(); //print request infos if in debug mode
#ifdef QGSMSDEBUG
QgsDebugMsg( QString( "Test font %1 loaded from testdata.qrc" ).arg( testFontLoaded ? "" : "NOT " ) );
#endif

//use QgsGetRequestHandler in case of HTTP GET and QgsSOAPRequestHandler in case of HTTP POST
QgsRequestHandler* theRequestHandler = 0;
Expand Down
2 changes: 2 additions & 0 deletions tests/src/python/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
INCLUDE(UsePythonTest)
ADD_PYTHON_TEST(PyQgsApplication test_qgsapplication.py)
ADD_PYTHON_TEST(PyQgsLocalServer test_qgis_local_server.py)
ADD_PYTHON_TEST(PyQgsFontUtils test_qgsfontutils.py)
ADD_PYTHON_TEST(PyQgsFeature test_qgsfeature.py)
ADD_PYTHON_TEST(PyQgsFeatureIterator test_qgsfeatureiterator.py)
ADD_PYTHON_TEST(PyQgsGeometry test_qgsgeometry.py)
Expand Down
Loading