Exemplo n.º 1
0
            self.line_symbol.startRender(context)
            self.line_symbol.renderFeature(f, context)
            self.line_symbol.stopRender(context)

        elif geom.type() == QGis.Point:
            self.marker_symbol.startRender(context)
            self.marker_symbol.renderFeature(f, context)
            self.marker_symbol.stopRender(context)

        painter.end()
        return image

    def imageCheck(self, name, reference_image, image):
        self.report += "<h2>Render {}</h2>\n".format(name)
        temp_dir = QDir.tempPath() + '/'
        file_name = temp_dir + 'symbol_' + name + ".png"
        image.save(file_name, "PNG")
        checker = QgsRenderChecker()
        checker.setControlPathPrefix("symbolv2")
        checker.setControlName("expected_" + reference_image)
        checker.setRenderedImage(file_name)
        checker.setColorTolerance(2)
        result = checker.compareImages(name, 20)
        self.report += checker.report()
        print self.report
        return result


if __name__ == '__main__':
    unittest.main()# -*- coding: utf-8 -*-
              break

        oldId = self.mComposerMap.id()
        newId = newMap.id()

        self.mComposition.removeComposerItem(newMap)
        myMessage = 'old: %s new: %s'  % (oldId, newId)
        assert oldId != newId, myMessage

    def testZebraStyle(self):
        self.mComposerMap.setGridFrameStyle(QgsComposerMap.Zebra)
        myRectangle = QgsRectangle(785462.375, 3341423.125,
                                   789262.375, 3343323.125)
        self.mComposerMap.setNewExtent( myRectangle )
        self.mComposerMap.setGridEnabled(True)
        self.mComposerMap.setGridIntervalX(2000)
        self.mComposerMap.setGridIntervalY(2000)
        checker = QgsCompositionChecker()
        myPngPath = os.path.join(TEST_DATA_DIR,
                                 'control_images',
                                 'expected_composermap',
                                 'composermap_zebra_style.png')
        testResult, myMessage = checker.testComposition('Composer map zebra',
                                             self.mComposition,
                                             myPngPath)
        assert testResult == True, myMessage

if __name__ == '__main__':
    unittest.main()

    def test_loading_base_test_fonts(self):
        loadTestFonts()

    def test_loading_every_test_font(self):
        QgsFontUtils.loadStandardTestFonts(['All'])
        # styles = ''
        # for style in QFontDatabase().styles(self._family):
        #     styles += ' ' + style
        # print self._family + ' styles:' + styles

        res = (self._has_style(self._family, 'Roman')
               and self._has_style(self._family, 'Oblique')
               and self._has_style(self._family, 'Bold')
               and self._has_style(self._family, 'Bold Oblique'))
        msg = self._family + ' test font styles could not be loaded'
        assert res, msg

    def test_get_specific_test_font(self):
        # default returned is Roman at 12 pt
        f = QgsFontUtils.getStandardTestFont('Bold Oblique', 14)
        """:type: QFont"""
        res = (f.family() == self._family and f.bold() and f.italic()
               and f.pointSize() == 14)
        msg = self._family + ' test font Bold Oblique at 14 pt not retrieved'
        assert res, msg


if __name__ == '__main__':
    unittest.main()