Skip to content

Commit

Permalink
Use a checkerboard background in svg cache tests
Browse files Browse the repository at this point in the history
  • Loading branch information
nyalldawson committed Mar 29, 2018
1 parent c71347c commit 3f733e7
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions tests/src/python/test_qgssvgcache.py
Expand Up @@ -19,9 +19,9 @@
import threading
import http.server
from qgis.PyQt.QtCore import QDir
from qgis.PyQt.QtGui import QColor
from qgis.PyQt.QtGui import QColor, QImage, QPainter

from qgis.core import (QgsSvgCache, QgsRenderChecker, QgsApplication)
from qgis.core import (QgsSvgCache, QgsRenderChecker, QgsApplication, QgsMultiRenderChecker)
from qgis.testing import start_app, unittest
from utilities import unitTestDataPath

Expand Down Expand Up @@ -84,7 +84,14 @@ def imageCheck(self, name, reference_image, image):
self.report += "<h2>Render {}</h2>\n".format(name)
temp_dir = QDir.tempPath() + '/'
file_name = temp_dir + 'svg_' + name + ".png"
image.save(file_name, "PNG")

output_image = QImage(image.size(), QImage.Format_RGB32)
QgsMultiRenderChecker.drawBackground(output_image)
painter = QPainter(output_image)
painter.drawImage(0, 0, image)
painter.end()

output_image.save(file_name, "PNG")
checker = QgsRenderChecker()
checker.setControlPathPrefix("svg_cache")
checker.setControlName("expected_" + reference_image)
Expand Down
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 3f733e7

Please sign in to comment.