Skip to content
Permalink
Browse files

[Server] Fonts used in GetLegendGraphics tests are bolded and increased

  • Loading branch information
pblottiere committed Jun 9, 2017
1 parent c1657ac commit 7b844837bb6bcfe8d6d4555bcfe3ad15d81ddd19
@@ -39,7 +39,7 @@

from io import StringIO
from qgis.server import QgsServer, QgsServerRequest, QgsBufferServerRequest, QgsBufferServerResponse
from qgis.core import QgsRenderChecker, QgsApplication
from qgis.core import QgsRenderChecker, QgsApplication, QgsFontUtils
from qgis.testing import unittest
from qgis.PyQt.QtCore import QSize
from utilities import unitTestDataPath
@@ -94,6 +94,9 @@ def tearDownClass(cls):

def setUp(self):
"""Create the server instance"""
self.fontFamily = QgsFontUtils.standardTestFontFamily()
QgsFontUtils.loadStandardTestFonts(['All'])

self.testdata_path = unitTestDataPath('qgis_server') + '/'

d = unitTestDataPath('qgis_server_accesscontrol') + '/'
@@ -1059,6 +1059,12 @@ def test_wms_GetLegendGraphic_LayerSpace(self):
# "HEIGHT": "500",
# "WIDTH": "500",
"LAYERSPACE": "50.0",
"LAYERFONTBOLD": "TRUE",
"LAYERFONTSIZE": "30",
"ITEMFONTBOLD": "TRUE",
"ITEMFONTSIZE": "20",
"LAYERFONTFAMILY": self.fontFamily,
"ITEMFONTFAMILY": self.fontFamily,
"LAYERTITLE": "TRUE",
"CRS": "EPSG:3857"
}.items())])
@@ -1077,15 +1083,24 @@ def test_wms_GetLegendGraphic_ShowFeatureCount(self):
# "HEIGHT": "500",
# "WIDTH": "500",
"LAYERTITLE": "TRUE",
"LAYERFONTBOLD": "TRUE",
"LAYERFONTSIZE": "30",
"LAYERFONTFAMILY": self.fontFamily,
"ITEMFONTFAMILY": self.fontFamily,
"ITEMFONTBOLD": "TRUE",
"ITEMFONTSIZE": "20",
"SHOWFEATURECOUNT": "TRUE",
"CRS": "EPSG:3857"
}.items())])

r, h = self._result(self._execute_request(qs))
self._img_diff_error(r, h, "WMS_GetLegendGraphic_ShowFeatureCount")
self._img_diff_error(r, h, "WMS_GetLegendGraphic_ShowFeatureCount", max_size_diff=QSize(1, 1))

def test_getLegendGraphics_layertitle(self):
"""Test that does not return an exception but an image"""

print("TEST FONT FAMILY: ", self.fontFamily)

parms = {
'MAP': self.testdata_path + "test_project.qgs",
'SERVICE': 'WMS',
@@ -1095,6 +1110,12 @@ def test_getLegendGraphics_layertitle(self):
# 'WIDTH': '20', # optional
# 'HEIGHT': '20', # optional
'LAYER': u'testlayer%20èé',
'LAYERFONTBOLD': 'TRUE',
'LAYERFONTSIZE': '30',
'ITEMFONTBOLD': 'TRUE',
'LAYERFONTFAMILY': self.fontFamily,
'ITEMFONTFAMILY': self.fontFamily,
'ITEMFONTSIZE': '20',
'LAYERTITLE': 'TRUE',
}
qs = '?' + '&'.join([u"%s=%s" % (k, v) for k, v in parms.items()])
@@ -1125,6 +1146,12 @@ def test_getLegendGraphics_rulelabel(self):
'REQUEST': 'GetLegendGraphic',
'FORMAT': 'image/png',
'LAYER': u'testlayer%20èé',
'LAYERFONTBOLD': 'TRUE',
'LAYERFONTSIZE': '30',
'LAYERFONTFAMILY': self.fontFamily,
'ITEMFONTFAMILY': self.fontFamily,
'ITEMFONTBOLD': 'TRUE',
'ITEMFONTSIZE': '20',
'RULELABEL': 'TRUE',
}
qs = '?' + '&'.join([u"%s=%s" % (k, v) for k, v in parms.items()])
@@ -1138,6 +1165,12 @@ def test_getLegendGraphics_rulelabel(self):
'REQUEST': 'GetLegendGraphic',
'FORMAT': 'image/png',
'LAYER': u'testlayer%20èé',
'LAYERFONTBOLD': 'TRUE',
'LAYERFONTSIZE': '30',
'ITEMFONTBOLD': 'TRUE',
'ITEMFONTSIZE': '20',
'LAYERFONTFAMILY': self.fontFamily,
'ITEMFONTFAMILY': self.fontFamily,
'RULELABEL': 'FALSE',
}
qs = '?' + '&'.join([u"%s=%s" % (k, v) for k, v in parms.items()])
@@ -1330,14 +1363,18 @@ def test_wms_GetLegendGraphic_LayerFont(self):
"LAYERFONTBOLD": "TRUE",
"LAYERFONTITALIC": "TRUE",
"LAYERFONTSIZE": "30",
"ITEMFONTBOLD": "TRUE",
"ITEMFONTSIZE": "20",
"LAYERFONTFAMILY": self.fontFamily,
"ITEMFONTFAMILY": self.fontFamily,
"FORMAT": "image/png",
"HEIGHT": "500",
"WIDTH": "500",
"CRS": "EPSG:3857"
}.items())])

r, h = self._result(self._execute_request(qs))
self._img_diff_error(r, h, "WMS_GetLegendGraphic_LayerFont")
self._img_diff_error(r, h, "WMS_GetLegendGraphic_LayerFont", max_size_diff=QSize(1, 1))

def test_wms_GetLegendGraphic_ItemFont(self):
qs = "?" + "&".join(["%s=%s" % i for i in list({
@@ -1347,17 +1384,21 @@ def test_wms_GetLegendGraphic_ItemFont(self):
"REQUEST": "GetLegendGraphic",
"LAYER": "Country,Hello",
"LAYERTITLE": "TRUE",
"LAYERFONTBOLD": "TRUE",
"LAYERFONTSIZE": "30",
"ITEMFONTBOLD": "TRUE",
"ITEMFONTITALIC": "TRUE",
"ITEMFONTSIZE": "30",
"ITEMFONTSIZE": "20",
"LAYERFONTFAMILY": self.fontFamily,
"ITEMFONTFAMILY": self.fontFamily,
"FORMAT": "image/png",
"HEIGHT": "500",
"WIDTH": "500",
"CRS": "EPSG:3857"
}.items())])

r, h = self._result(self._execute_request(qs))
self._img_diff_error(r, h, "WMS_GetLegendGraphic_ItemFont")
self._img_diff_error(r, h, "WMS_GetLegendGraphic_ItemFont", max_size_diff=QSize(1, 1))

def test_wms_GetLegendGraphic_BBox(self):
qs = "?" + "&".join(["%s=%s" % i for i in list({
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.

0 comments on commit 7b84483

Please sign in to comment.
You can’t perform that action at this time.