Skip to content
Permalink
Browse files

Use a non-transparent background for composition checker

Fix composerhtml tests on precise
  • Loading branch information
nyalldawson authored and m-kuhn committed Nov 14, 2014
1 parent eaf0d34 commit 2cfcca10d2e5eecd7c597d8684d2cc7a94d86cb7
Showing with 31 additions and 5 deletions.
  1. +23 −2 tests/src/core/qgscompositionchecker.cpp
  2. +6 −1 tests/src/core/qgscompositionchecker.h
  3. +2 −2 tests/src/core/testqgscomposerhtml.cpp
  4. BIN tests/testdata/control_images/expected_atlas_autoscale1/expected_atlas_autoscale1.png
  5. BIN tests/testdata/control_images/expected_atlas_autoscale2/expected_atlas_autoscale2.png
  6. BIN ...s/testdata/control_images/expected_atlas_autoscale_old_api1/expected_atlas_autoscale_old_api1.png
  7. BIN ...s/testdata/control_images/expected_atlas_autoscale_old_api2/expected_atlas_autoscale_old_api2.png
  8. BIN tests/testdata/control_images/expected_atlas_filtering1/expected_atlas_filtering1.png
  9. BIN tests/testdata/control_images/expected_atlas_fixedscale1/expected_atlas_fixedscale1.png
  10. BIN tests/testdata/control_images/expected_atlas_fixedscale2/expected_atlas_fixedscale2.png
  11. BIN ...testdata/control_images/expected_atlas_fixedscale_old_api1/expected_atlas_fixedscale_old_api1.png
  12. BIN ...testdata/control_images/expected_atlas_fixedscale_old_api2/expected_atlas_fixedscale_old_api2.png
  13. BIN tests/testdata/control_images/expected_atlas_hiding1/expected_atlas_hiding1.png
  14. BIN tests/testdata/control_images/expected_atlas_hiding2/expected_atlas_hiding2.png
  15. BIN tests/testdata/control_images/expected_atlas_predefinedscales1/expected_atlas_predefinedscales1.png
  16. BIN tests/testdata/control_images/expected_atlas_predefinedscales2/expected_atlas_predefinedscales2.png
  17. BIN tests/testdata/control_images/expected_atlas_sorting1/expected_atlas_sorting1.png
  18. BIN tests/testdata/control_images/expected_atlas_sorting2/expected_atlas_sorting2.png
  19. BIN tests/testdata/control_images/expected_atlas_two_maps1/expected_atlas_two_maps1.png
  20. BIN tests/testdata/control_images/expected_atlas_two_maps2/expected_atlas_two_maps2.png
  21. BIN ...mages/expected_composerattributetable_columnwidth/expected_composerattributetable_columnwidth.png
  22. BIN ...ol_images/expected_composerattributetable_drawempty/expected_composerattributetable_drawempty.png
  23. BIN ...mages/expected_composerattributetable_headersonly/expected_composerattributetable_headersonly.png
  24. BIN ...ol_images/expected_composerattributetable_hidetable/expected_composerattributetable_hidetable.png
  25. BIN .../control_images/expected_composerattributetable_render/expected_composerattributetable_render.png
  26. BIN ...mages/expected_composerattributetable_showmessage/expected_composerattributetable_showmessage.png
  27. BIN tests/testdata/control_images/expected_composereffects_blend/expected_composereffects_blend.png
  28. BIN ...ta/control_images/expected_composereffects_transparency/expected_composereffects_transparency.png
  29. BIN ..._images/expected_composerhtml_expressions_disabled/expected_composerhtml_expressions_disabled.png
  30. BIN ...ol_images/expected_composerhtml_expressions_enabled/expected_composerhtml_expressions_enabled.png
  31. BIN tests/testdata/control_images/expected_composerhtml_manual/expected_composerhtml_manual.png
  32. BIN ...ntrol_images/expected_composerhtml_multiframe1/{ → default}/expected_composerhtml_multiframe1.png
  33. BIN ...ta/control_images/expected_composerhtml_multiframe1/precise/expected_composerhtml_multiframe1.png
  34. BIN ...ntrol_images/expected_composerhtml_multiframe2/{ → default}/expected_composerhtml_multiframe2.png
  35. BIN ...ta/control_images/expected_composerhtml_multiframe2/precise/expected_composerhtml_multiframe2.png
  36. BIN ...rol_images/expected_composerhtml_smartbreaks1/{ → default}/expected_composerhtml_smartbreaks1.png
  37. BIN .../control_images/expected_composerhtml_smartbreaks1/precise/expected_composerhtml_smartbreaks1.png
  38. BIN ...rol_images/expected_composerhtml_smartbreaks2/{ → default}/expected_composerhtml_smartbreaks2.png
  39. BIN .../control_images/expected_composerhtml_smartbreaks2/precise/expected_composerhtml_smartbreaks2.png
  40. BIN .../testdata/control_images/expected_composerhtml_table/{ → default}/expected_composerhtml_table.png
  41. BIN tests/testdata/control_images/expected_composerhtml_table/precise/expected_composerhtml_table.png
  42. BIN ...data/control_images/expected_composerhtml_userstylesheet/expected_composerhtml_userstylesheet.png
  43. BIN tests/testdata/control_images/expected_composermap_crossgrid/expected_composermap_crossgrid.png
  44. BIN ...testdata/control_images/expected_composermap_exteriorticks/expected_composermap_exteriorticks.png
  45. BIN ...ges/expected_composermap_exteriorticks_annotated/expected_composermap_exteriorticks_annotated.png
  46. BIN ...s/expected_composermap_exteriorticks_annotated2/expected_composermap_exteriorticks_annotated2.png
  47. BIN ...trol_images/expected_composermap_filteredannotations/expected_composermap_filteredannotations.png
  48. BIN ...stdata/control_images/expected_composermap_framedivisions/expected_composermap_framedivisions.png
  49. BIN tests/testdata/control_images/expected_composermap_grid/expected_composermap_grid.png
  50. BIN ...testdata/control_images/expected_composermap_gridframeonly/expected_composermap_gridframeonly.png
  51. BIN ...data/control_images/expected_composermap_gridreprojected/expected_composermap_gridreprojected.png
  52. BIN ..._images/expected_composermap_interiorexteriorticks/expected_composermap_interiorexteriorticks.png
  53. BIN ...posermap_interiorexteriorticks_annotated/expected_composermap_interiorexteriorticks_annotated.png
  54. BIN ...sermap_interiorexteriorticks_annotated2/expected_composermap_interiorexteriorticks_annotated2.png
  55. BIN ...testdata/control_images/expected_composermap_interiorticks/expected_composermap_interiorticks.png
  56. BIN ...ges/expected_composermap_interiorticks_annotated/expected_composermap_interiorticks_annotated.png
  57. BIN ...s/expected_composermap_interiorticks_annotated2/expected_composermap_interiorticks_annotated2.png
  58. BIN tests/testdata/control_images/expected_composermap_lineborder/expected_composermap_lineborder.png
  59. BIN ...ol_images/expected_composermap_lineborder_annotated/expected_composermap_lineborder_annotated.png
  60. BIN ..._images/expected_composermap_lineborder_annotated2/expected_composermap_lineborder_annotated2.png
  61. BIN tests/testdata/control_images/expected_composermap_markergrid/expected_composermap_markergrid.png
  62. BIN tests/testdata/control_images/expected_composermap_overview/expected_composermap_overview.png
  63. BIN .../control_images/expected_composermap_overview_blending/expected_composermap_overview_blending.png
  64. BIN ...data/control_images/expected_composermap_overview_center/expected_composermap_overview_center.png
  65. BIN ...data/control_images/expected_composermap_overview_invert/expected_composermap_overview_invert.png
  66. BIN ...ta/control_images/expected_composermap_overview_rotated/expected_composermap_overview_rotated.png
  67. BIN .../control_images/expected_composermap_overview_rotated2/expected_composermap_overview_rotated2.png
  68. BIN tests/testdata/control_images/expected_composermap_render/expected_composermap_render.png
  69. BIN ...ontrol_images/expected_composermap_rotatedannotations/expected_composermap_rotatedannotations.png
  70. BIN ...s/testdata/control_images/expected_composermap_rotatedframe/expected_composermap_rotatedframe.png
  71. BIN ...expected_composermap_verticaldescending_inside/expected_composermap_verticaldescending_inside.png
  72. BIN ...pected_composermap_verticaldescending_outside/expected_composermap_verticaldescending_outside.png
  73. BIN tests/testdata/control_images/expected_composermap_zebrastyle/expected_composermap_zebrastyle.png
  74. BIN ...data/control_images/expected_composermap_zebrastyle_left/expected_composermap_zebrastyle_left.png
  75. BIN ...ontrol_images/expected_composermap_zebrastyle_lefttop/expected_composermap_zebrastyle_lefttop.png
  76. BIN ...ges/expected_composermap_zebrastyle_lefttopright/expected_composermap_zebrastyle_lefttopright.png
  77. BIN tests/testdata/control_images/expected_composerpaper_bordered/expected_composerpaper_bordered.png
  78. BIN tests/testdata/control_images/expected_composerpaper_default/expected_composerpaper_default.png
  79. BIN ...stdata/control_images/expected_composerpaper_markerborder/expected_composerpaper_markerborder.png
  80. BIN ...testdata/control_images/expected_composerpaper_transparent/expected_composerpaper_transparent.png
  81. BIN .../control_images/expected_composerpicture_badexpression/expected_composerpicture_badexpression.png
  82. BIN ...data/control_images/expected_composerpicture_clip_anchor/expected_composerpicture_clip_anchor.png
  83. BIN ...ges/expected_composerpicture_clip_anchoroversize/expected_composerpicture_clip_anchoroversize.png
  84. BIN ...stdata/control_images/expected_composerpicture_expression/expected_composerpicture_expression.png
  85. BIN ...ta/control_images/expected_composerpicture_itemrotation/expected_composerpicture_itemrotation.png
  86. BIN tests/testdata/control_images/expected_composerpicture_remote/expected_composerpicture_remote.png
  87. BIN ...data/control_images/expected_composerpicture_resize_clip/expected_composerpicture_resize_clip.png
  88. BIN ...ges/expected_composerpicture_resize_frametoimage/expected_composerpicture_resize_frametoimage.png
  89. BIN ...ontrol_images/expected_composerpicture_resize_stretch/expected_composerpicture_resize_stretch.png
  90. BIN ...data/control_images/expected_composerpicture_resize_zoom/expected_composerpicture_resize_zoom.png
  91. BIN ..._images/expected_composerpicture_resize_zoomresize/expected_composerpicture_resize_zoomresize.png
  92. BIN ...s/testdata/control_images/expected_composerpicture_rotation/expected_composerpicture_rotation.png
  93. BIN ...ol_images/expected_composerpicture_svg_frametoimage/expected_composerpicture_svg_frametoimage.png
  94. BIN ...data/control_images/expected_composerpicture_svg_stretch/expected_composerpicture_svg_stretch.png
  95. BIN ...s/testdata/control_images/expected_composerpicture_svg_zoom/expected_composerpicture_svg_zoom.png
  96. BIN ...ontrol_images/expected_composerpicture_svg_zoomresize/expected_composerpicture_svg_zoomresize.png
  97. BIN ...data/control_images/expected_composerpicture_zoom_anchor/expected_composerpicture_zoom_anchor.png
  98. BIN tests/testdata/control_images/expected_composerrotation_label/expected_composerrotation_label.png
  99. BIN ...ol_images/expected_composerrotation_mapitemrotation/expected_composerrotation_mapitemrotation.png
  100. BIN ...ta/control_images/expected_composerrotation_maprotation/expected_composerrotation_maprotation.png
  101. BIN tests/testdata/control_images/expected_composerrotation_shape/expected_composerrotation_shape.png
  102. BIN ...stdata/control_images/expected_composerscalebar_doublebox/expected_composerscalebar_doublebox.png
  103. BIN ...s/testdata/control_images/expected_composerscalebar_numeric/expected_composerscalebar_numeric.png
  104. BIN ...stdata/control_images/expected_composerscalebar_singlebox/expected_composerscalebar_singlebox.png
  105. BIN ...ol_images/expected_composerscalebar_singlebox_alpha/expected_composerscalebar_singlebox_alpha.png
  106. BIN tests/testdata/control_images/expected_composerscalebar_tick/expected_composerscalebar_tick.png
  107. BIN tests/testdata/control_images/expected_composershapes_ellipse/expected_composershapes_ellipse.png
  108. BIN ...s/testdata/control_images/expected_composershapes_rectangle/expected_composershapes_rectangle.png
  109. BIN ...stdata/control_images/expected_composershapes_roundedrect/expected_composershapes_roundedrect.png
  110. BIN tests/testdata/control_images/expected_composershapes_symbolv2/expected_composershapes_symbolv2.png
  111. BIN tests/testdata/control_images/expected_composershapes_triangle/expected_composershapes_triangle.png
  112. BIN tests/testdata/control_images/expected_piediagram/expected_piediagram.png
  113. BIN tests/testdata/control_images/expected_piediagram_expression/expected_piediagram_expression.png
@@ -40,6 +40,27 @@ QgsCompositionChecker::~QgsCompositionChecker()
{
}

void QgsCompositionChecker::drawBackround( QImage* image )
{
// create a 2x2 checker-board image
uchar pixDataRGB[] = { 255, 255, 255, 255,
127, 127, 127, 255,
127, 127, 127, 255,
255, 255, 255, 255
};

QImage img( pixDataRGB, 2, 2, 8, QImage::Format_ARGB32 );
QPixmap pix = QPixmap::fromImage( img.scaled( 20, 20 ) );

// fill image with texture
QBrush brush;
brush.setTexture( pix );
QPainter p( image );
p.setRenderHint( QPainter::Antialiasing, false );
p.fillRect( QRect( 0, 0, image->width(), image->height() ), brush );
p.end();
}

bool QgsCompositionChecker::testComposition( QString &theReport, int page, int pixelDiff )
{
if ( !mComposition )
@@ -56,7 +77,7 @@ bool QgsCompositionChecker::testComposition( QString &theReport, int page, int p
mComposition->setPlotStyle( QgsComposition::Print );
newImage.setDotsPerMeterX( 96 / 25.4 * 1000 );
newImage.setDotsPerMeterY( 96 / 25.4 * 1000 );
newImage.fill( 0 );
drawBackround( &newImage );
QPainter expectedPainter( &newImage );
//QRectF sourceArea( 0, 0, mComposition->paperWidth(), mComposition->paperHeight() );
//QRectF targetArea( 0, 0, 3507, 2480 );
@@ -71,7 +92,7 @@ bool QgsCompositionChecker::testComposition( QString &theReport, int page, int p
mComposition->setPlotStyle( QgsComposition::Print );
outputImage.setDotsPerMeterX( mDotsPerMeter );
outputImage.setDotsPerMeterY( mDotsPerMeter );
outputImage.fill( 0 );
drawBackround( &outputImage );
QPainter p( &outputImage );
mComposition->renderPage( &p, page );
p.end();
@@ -29,11 +29,16 @@ class QgsCompositionChecker : public QgsMultiRenderChecker
QgsCompositionChecker( const QString& testName, QgsComposition* composition );
~QgsCompositionChecker();

bool testComposition( QString &report, int page = 0, int pixelDiff = 0 );
bool testComposition( QString &theReport, int page = 0, int pixelDiff = 0 );

private:
QgsCompositionChecker(); //forbidden

/**Draws a checkboard pattern for image backgrounds, so that transparency is visible
* without requiring a transparent background for the image
*/
void drawBackround( QImage* image );

QString mTestName;
QgsComposition* mComposition;
QSize mSize;
@@ -95,7 +95,7 @@ void TestQgsComposerHtml::sourceMode()
htmlItem->loadHtml();

QgsCompositionChecker checker( "composerhtml_manual", mComposition );
bool result = checker.testComposition( mReport );
bool result = checker.testComposition( mReport, 0, 100 );
mComposition->removeMultiFrame( htmlItem );
delete htmlItem;
QVERIFY( result );
@@ -116,7 +116,7 @@ void TestQgsComposerHtml::userStylesheets()
htmlItem->setUserStylesheetEnabled( true );

QgsCompositionChecker checker( "composerhtml_userstylesheet", mComposition );
bool result = checker.testComposition( mReport );
bool result = checker.testComposition( mReport, 0, 100 );
mComposition->removeMultiFrame( htmlItem );
delete htmlItem;
QVERIFY( result );
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.
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.
Binary file not shown.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.