Skip to content
Permalink
Browse files

[composer] Add tests for expression based picture source (sponsored b…

…y City of Uster, Switzerland)
  • Loading branch information
nyalldawson committed Apr 28, 2014
1 parent ddfb697 commit 3afee3c62924815aac1ffa6ff9dc88b61cff1646
@@ -48,6 +48,9 @@ class TestQgsComposerPicture: public QObject
void pictureSvgZoomAndResize();
void pictureSvgFrameToImage();

void pictureExpression();
void pictureInvalidExpression();

private:
QgsComposition* mComposition;
QgsComposerPicture* mComposerPicture;
@@ -275,5 +278,38 @@ void TestQgsComposerPicture::pictureSvgFrameToImage()
mComposerPicture->setPictureFile( mPngImage );
}

void TestQgsComposerPicture::pictureExpression()
{
//test picture source via expression
mComposition->addComposerPicture( mComposerPicture );

QString expr = QString( "'" ) + QString( TEST_DATA_DIR ) + QDir::separator()
+ QString( "' || 'sample_svg.svg'" );
mComposerPicture->setPictureExpression( expr );
mComposerPicture->setUsePictureExpression( true );

QgsCompositionChecker checker( "composerpicture_expression", mComposition );
QVERIFY( checker.testComposition( mReport, 0, 100 ) );

mComposition->removeItem( mComposerPicture );
mComposerPicture->setUsePictureExpression( false );
}

void TestQgsComposerPicture::pictureInvalidExpression()
{
//test picture source via bad expression
mComposition->addComposerPicture( mComposerPicture );

QString expr = QString( "bad expression" );
mComposerPicture->setPictureExpression( expr );
mComposerPicture->setUsePictureExpression( true );

QgsCompositionChecker checker( "composerpicture_badexpression", mComposition );
QVERIFY( checker.testComposition( mReport, 0, 100 ) );

mComposition->removeItem( mComposerPicture );
mComposerPicture->setUsePictureExpression( false );
}

QTEST_MAIN( TestQgsComposerPicture )
#include "moc_testqgscomposerpicture.cxx"
Binary file not shown.
Binary file not shown.
@@ -0,0 +1,286 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!-- Created with Inkscape (http://www.inkscape.org/) -->

<svg
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:cc="http://creativecommons.org/ns#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns="http://www.w3.org/2000/svg"
xmlns:xlink="http://www.w3.org/1999/xlink"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
width="59.266239"
height="65.359184"
id="svg4907"
version="1.1"
inkscape:version="0.48+devel r11668"
sodipodi:docname="logo-proposal.svg">
<defs
id="defs4909">
<clipPath
clipPathUnits="userSpaceOnUse"
id="clipPath4144">
<rect
style="fill:#000000;stroke:none"
id="rect4146"
width="42.875"
height="39.625"
x="565.16125"
y="646.18127"
transform="matrix(0.99990096,-0.01407388,0.01407388,0.99990096,0,0)" />
</clipPath>
<linearGradient
inkscape:collect="always"
xlink:href="#linearGradient5342-4-9-7"
id="linearGradient3970-6"
gradientUnits="userSpaceOnUse"
gradientTransform="translate(156.08765,208.94407)"
x1="413.40717"
y1="477.57877"
x2="423.64282"
y2="463.79016" />
<linearGradient
id="linearGradient5342-4-9-7">
<stop
style="stop-color:#0d4100;stop-opacity:1;"
offset="0"
id="stop5344-0-0-6" />
<stop
style="stop-color:#129300;stop-opacity:1;"
offset="1"
id="stop5346-85-9-0" />
</linearGradient>
<linearGradient
y2="463.79016"
x2="423.64282"
y1="477.57877"
x1="413.40717"
gradientTransform="matrix(-0.28268074,-0.95921406,-0.95921406,0.28268074,1144.7424,948.30227)"
gradientUnits="userSpaceOnUse"
id="linearGradient4111"
xlink:href="#linearGradient5342-4-0-4"
inkscape:collect="always" />
<linearGradient
id="linearGradient5342-4-0-4">
<stop
style="stop-color:#0d1d00;stop-opacity:1;"
offset="0"
id="stop5344-0-9-7" />
<stop
style="stop-color:#0d7200;stop-opacity:1;"
offset="1"
id="stop5346-85-5-3" />
</linearGradient>
<clipPath
clipPathUnits="userSpaceOnUse"
id="clipPath4825-8">
<path
style="fill:#e4f363;fill-opacity:1;stroke:none"
d="m 485.06341,446.7935 c -9.77401,0.51743 -17.5625,8.97625 -17.5625,19.3125 0,10.66968 8.28361,19.3125 18.5,19.3125 1.1046,0 2.16736,-0.11879 3.21875,-0.3125 l 0,3.09375 c 0.085,1.31607 1.67268,4.12266 6.65625,4.15625 5.76986,0.0389 8.44866,-3.49777 8.9375,-4.5625 0.90942,-2.43008 0.73396,-3.98858 0.6875,-4.96875 -0.019,0.58818 -1.99576,4.1014 -5.09375,4.21875 -4.98011,0.18864 -4.4375,-0.71244 -4.4375,-2.03125 l 0,-2.625 c 5.12836,-3.43242 8.53125,-9.44688 8.53125,-16.28125 0,-10.66968 -8.28361,-19.3125 -18.5,-19.3125 C 485.68165,446.7935 485.3787,446.7768 485.06341,446.7935 z m 0.625,1.375 c 3.87037,0 7,7.86055 7,17.59375 0,2.16342 -0.15449,4.24122 -0.4375,6.15625 -1.61816,-0.66461 -3.68163,-1.19682 -6.1875,-1.1875 -3.70225,0.0138 -5.98672,0.85933 -6.875,1.46875 -0.3101,-1.99278 -0.5,-4.16771 -0.5,-6.4375 C 478.68841,456.02905 481.81804,448.1685 485.68841,448.1685 z m -1.28125,23.46875 c 3.73877,0.0637 4.8125,1.51573 4.8125,2.28125 l 0,7.0625 c -1.03594,1.52517 -2.24316,2.40625 -3.53125,2.40625 -2.82374,0 -5.23629,-4.19827 -6.34375,-10.25 C 480.23849,472.49987 482.04501,471.59702 484.40716,471.63725 Z"
id="path4827-5"
inkscape:connector-curvature="0"
inkscape:export-filename="/home/webmaster/Desktop/path3895-6-6-7-4-4-0_2.png"
inkscape:export-xdpi="300"
inkscape:export-ydpi="300" />
</clipPath>
<filter
inkscape:collect="always"
id="filter4776-5"
x="-0.33183911"
width="1.6636782"
y="-0.39338365"
height="1.7867672"
style="color-interpolation-filters:sRGB">
<feGaussianBlur
inkscape:collect="always"
stdDeviation="0.65194979"
id="feGaussianBlur4778-0" />
</filter>
<filter
inkscape:collect="always"
id="filter4947-8-4"
style="color-interpolation-filters:sRGB">
<feGaussianBlur
inkscape:collect="always"
stdDeviation="1.0155639"
id="feGaussianBlur4949-0-5" />
</filter>
<linearGradient
inkscape:collect="always"
xlink:href="#linearGradient5342-4-9"
id="linearGradient3970"
gradientUnits="userSpaceOnUse"
gradientTransform="translate(156.08765,208.94407)"
x1="413.40717"
y1="477.57877"
x2="423.64282"
y2="463.79016" />
<linearGradient
id="linearGradient5342-4-9">
<stop
style="stop-color:#0d4100;stop-opacity:1;"
offset="0"
id="stop5344-0-0" />
<stop
style="stop-color:#129300;stop-opacity:1;"
offset="1"
id="stop5346-85-9" />
</linearGradient>
<linearGradient
inkscape:collect="always"
xlink:href="#linearGradient5342-4-0-4"
id="linearGradient3972"
gradientUnits="userSpaceOnUse"
gradientTransform="matrix(-0.28268074,-0.95921406,-0.95921406,0.28268074,1144.7424,948.30227)"
x1="413.40717"
y1="477.57877"
x2="423.64282"
y2="463.79016" />
<linearGradient
id="linearGradient4887">
<stop
style="stop-color:#0d1d00;stop-opacity:1;"
offset="0"
id="stop4889" />
<stop
style="stop-color:#0d7200;stop-opacity:1;"
offset="1"
id="stop4891" />
</linearGradient>
<filter
inkscape:collect="always"
id="filter5427-2-5"
style="color-interpolation-filters:sRGB">
<feGaussianBlur
inkscape:collect="always"
stdDeviation="0.48785405"
id="feGaussianBlur5429-2-8" />
</filter>
</defs>
<sodipodi:namedview
id="base"
pagecolor="#ffffff"
bordercolor="#666666"
borderopacity="1.0"
inkscape:pageopacity="0.0"
inkscape:pageshadow="2"
inkscape:zoom="2.8"
inkscape:cx="31.572364"
inkscape:cy="28.045706"
inkscape:document-units="px"
inkscape:current-layer="layer1"
showgrid="false"
width="0px"
height="0px"
fit-margin-top="0"
fit-margin-left="0"
fit-margin-right="0"
fit-margin-bottom="0"
inkscape:window-width="1920"
inkscape:window-height="1018"
inkscape:window-x="-8"
inkscape:window-y="-8"
inkscape:window-maximized="1" />
<metadata
id="metadata4912">
<rdf:RDF>
<cc:Work
rdf:about="">
<dc:format>image/svg+xml</dc:format>
<dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
<cc:license
rdf:resource="" />
<dc:title></dc:title>
</cc:Work>
</rdf:RDF>
</metadata>
<g
inkscape:label="Layer 1"
inkscape:groupmode="layer"
id="layer1"
transform="translate(-293.22402,-451.11116)">
<path
style="opacity:0.30041151;fill:#000000;fill-opacity:1;stroke:#060000;stroke-width:0.60000002;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;filter:url(#filter5427-2-5)"
d="m 445.49832,443.64178 -13.43694,5.46836 3.53559,2.34117 c 0,0 -21.73596,25.20136 -26.72117,31.08815 l -9.37732,3.36622 7.94737,1.95465 2.1582,7.35242 2.83885,-9.42158 26.7609,-31.21072 2.97047,3.27344 L 445.49832,443.64178 Z"
id="path3895-6-6-7-4-6-2-7-5"
inkscape:connector-curvature="0"
inkscape:export-xdpi="300"
inkscape:export-ydpi="300"
inkscape:export-filename="/home/webmaster/Desktop/path3895-6-6-7-4-4-0_2.png"
transform="matrix(0.99958439,-0.02882794,0.02882794,0.99958439,-112.94886,26.451722)" />
<g
id="g3966"
transform="matrix(0.99990096,0.01407388,-0.01407388,0.99990096,-245.10157,-201.70028)">
<path
inkscape:connector-curvature="0"
id="path3895-6-6-7-4-6-8-4"
d="m 597.71136,649.10637 -12.9375,6.3125 3.6875,2.09375 c 0,0 -19.96054,26.62963 -24.53125,32.84375 l -9.125,4 8.03125,1.40625 L 597.71136,649.10637 Z"
style="fill:url(#linearGradient3970);fill-opacity:1;stroke:none" />
<path
inkscape:connector-curvature="0"
id="path3895-6-6-7-4-6-8-4-5"
d="m 597.69396,649.11595 -2.39786,14.19425 -3.05074,-2.94525 c 0,0 -19.90106,26.67412 -24.56967,32.81503 l -1.25739,9.88354 -3.61917,-7.30616 L 597.69396,649.11595 Z"
style="fill:url(#linearGradient3972);fill-opacity:1;stroke:none" />
</g>
<path
inkscape:connector-curvature="0"
style="fill:#000000;fill-opacity:1;stroke:none;filter:url(#filter4947-8-4)"
d="m 322.14652,464.00363 c -9.77401,0.51743 -17.5625,8.97625 -17.5625,19.3125 0,10.66968 8.28361,19.3125 18.5,19.3125 1.1046,0 2.16736,-0.11879 3.21875,-0.3125 l 0,3.09375 c 0.085,1.31607 1.67268,4.12266 6.65625,4.15625 5.76986,0.0389 8.44866,-3.49777 8.9375,-4.5625 0.90942,-2.43008 0.73396,-3.98858 0.6875,-4.96875 -0.019,0.58818 -1.99576,4.1014 -5.09375,4.21875 -4.98011,0.18864 -4.4375,-0.71244 -4.4375,-2.03125 l 0,-2.625 c 5.12836,-3.43242 8.53125,-9.44688 8.53125,-16.28125 0,-10.66968 -8.28361,-19.3125 -18.5,-19.3125 C 322.76476,464.00363 322.46181,463.98693 322.14652,464.00363 z m 0.625,1.375 c 3.87037,0 7,7.86055 7,17.59375 0,2.16342 -0.15449,4.24122 -0.4375,6.15625 -1.61816,-0.66461 -3.68163,-1.19682 -6.1875,-1.1875 -3.70225,0.0138 -5.98672,0.85933 -6.875,1.46875 -0.3101,-1.99278 -0.5,-4.16771 -0.5,-6.4375 C 315.77152,473.23918 318.90115,465.37863 322.77152,465.37863 z m -1.28125,23.46875 c 3.73877,0.0637 4.8125,1.51573 4.8125,2.28125 l 0,7.0625 c -1.03594,1.52517 -2.24316,2.40625 -3.53125,2.40625 -2.82374,0 -5.23629,-4.19827 -6.34375,-10.25 C 317.3216,489.71 319.12812,488.80715 321.49027,488.84738 Z"
id="path3050-3-9-3-4-2-4"
inkscape:export-filename="/home/webmaster/Desktop/path3895-6-6-7-4-4-0_2.png"
inkscape:export-xdpi="300"
inkscape:export-ydpi="300" />
<path
style="fill:#e4f363;fill-opacity:1;stroke:none"
d="m 321.61618,463.47329 c -9.77401,0.51743 -17.5625,8.97625 -17.5625,19.3125 0,10.66968 8.28361,19.3125 18.5,19.3125 1.1046,0 2.16736,-0.11879 3.21875,-0.3125 l 0,3.09375 c 0.085,1.31607 1.67268,4.12266 6.65625,4.15625 5.76986,0.0389 8.44866,-3.49777 8.9375,-4.5625 0.90942,-2.43008 0.73396,-3.98858 0.6875,-4.96875 -0.019,0.58818 -1.99576,4.1014 -5.09375,4.21875 -4.98011,0.18864 -4.4375,-0.71244 -4.4375,-2.03125 l 0,-2.625 c 5.12836,-3.43242 8.53125,-9.44688 8.53125,-16.28125 0,-10.66968 -8.28361,-19.3125 -18.5,-19.3125 C 322.23442,463.47329 321.93147,463.45659 321.61618,463.47329 z m 0.625,1.375 c 3.87037,0 7,7.86055 7,17.59375 0,2.16342 -0.15449,4.24122 -0.4375,6.15625 -1.61816,-0.66461 -3.68163,-1.19682 -6.1875,-1.1875 -3.70225,0.0138 -5.98672,0.85933 -6.875,1.46875 -0.3101,-1.99278 -0.5,-4.16771 -0.5,-6.4375 C 315.24118,472.70884 318.37081,464.84829 322.24118,464.84829 z m -1.28125,23.46875 c 3.73877,0.0637 4.8125,1.51573 4.8125,2.28125 l 0,7.0625 c -1.03594,1.52517 -2.24316,2.40625 -3.53125,2.40625 -2.82374,0 -5.23629,-4.19827 -6.34375,-10.25 C 316.79126,489.17966 318.59778,488.27681 320.95993,488.31704 Z"
id="path3050-3-9-3-2-3"
inkscape:connector-curvature="0"
inkscape:export-filename="/home/webmaster/Desktop/path3895-6-6-7-4-4-0_2.png"
inkscape:export-xdpi="300"
inkscape:export-ydpi="300" />
<path
id="path4738-5"
style="opacity:0.38271604;fill:#ffffff;stroke:none;filter:url(#filter4776-5)"
d="m 488.43401,448.93493 c 0,0 3.0052,0.53033 4.15425,1.23744 1.14905,0.70711 0.17678,2.65165 0.17678,2.65165 L 490.64372,452.91242 Z M 479.5,472.11218 c 0,0 2.375,-1.25 4,-1.4375 1.625,-0.1875 4.4375,-0.25 5.5625,0.0625 1.125,0.3125 3.3125,0.9375 3.5,1.25 0.1875,0.3125 1,3.25 1,3.25 l -2.5625,0.25 -1.8125,-2.0625 c 0,0 -2.6875,-1.625 -3.0625,-1.625 -0.375,0 -2.5625,-0.25 -3.375,-0.125 C 481.9375,471.79968 479.1875,471.98718 479.1875,471.98718 z m -10.50551,-11.04186 c -0.0152,-0.28825 0.41404,-1.95744 0.76266,-2.40979 0.34862,-0.45234 -1.01549,1.31997 1.48894,-2.21065 0.3964,-0.55884 2.30192,-2.23113 1.87609,-1.6724 -0.57503,0.75451 -1.69674,3.24294 -1.84878,3.44985 -0.15205,0.2069 -0.43962,1.94011 -0.58236,2.71994 -0.29797,1.62698 0.78628,3.18584 0.71846,3.88506 -0.0679,0.69921 -2.18969,0.99323 -2.79525,-0.55484 C 468.00873,462.72922 468.99448,461.07053 468.99448,461.07053 z m 2.84019,-0.47809 c -0.072,-0.27952 0.018,-2.00067 0.27008,-2.51312 0.25208,-0.51245 -0.73383,1.495 1.02141,-2.46184 0.27782,-0.6263 1.43552,-2.70976 1.50754,-2.01096 0.072,0.6988 -0.51233,4.19984 -0.62036,4.43277 -0.10804,0.23293 -0.50416,1.30443 -0.54017,2.0964 -0.036,0.79197 0.0319,2.63542 0.10396,3.33422 0.072,0.6988 -0.57946,1.73885 -1.47974,0.34125 C 471.19712,462.41335 471.83468,460.59223 471.83468,460.59223 z m -1.98207,2.65501 c -0.125,-0.48512 0.0313,-3.47232 0.46875,-4.36172 0.4375,-0.8894 1.46875,-2.49709 2.15625,-3.46735 0.6875,-0.97025 2.03125,-2.74708 2.15625,-1.53426 0.125,1.21282 -0.8125,4.52786 -1,4.93214 -0.1875,0.40427 -0.875,2.26393 -0.9375,3.63846 -0.0625,1.37452 3.0625,10.39787 3.1875,11.61069 0.125,1.21282 -0.68502,2.96943 -2.875,1.09083 C 464.13386,467.54289 469.85261,463.24724 469.85261,463.24724 z m 19.70936,-12.96734 c 0,0 3.9375,0.75963 5.375,4.62679 1.4375,3.86716 2.6875,6.9747 1.0625,11.80866 -1.625,4.83395 -3.25,7.87244 -3.25,7.87244 0,0 0.375,-11.94678 0.25,-13.8113 C 492.87447,458.91196 489.56197,450.2799 489.56197,450.2799 Z"
clip-path="url(#clipPath4825-8)"
mask="none"
inkscape:connector-curvature="0"
sodipodi:nodetypes="csccccssscccsscccscscccccccssccccscccssssssccsscsc"
transform="translate(-163.44724,16.679802)" />
<path
style="fill:none;stroke:none"
d="m 327.55368,480.31704 10.25,-13.75 3.1875,3.0625 2.34375,-14.40625 -13.03125,6.375 3.6875,2.09375 c 0,0 -4.79404,6.41727 -10,13.375"
id="path3895-6-6-7-4-4-0-2-0"
inkscape:connector-curvature="0"
inkscape:export-xdpi="300"
inkscape:export-ydpi="300"
sodipodi:nodetypes="ccccccc" />
<rect
style="opacity:0.39506172;fill:none;stroke:none"
id="rect5465-5-8"
width="57.375"
height="57.375"
x="295.11526"
y="454.49084"
inkscape:export-xdpi="94.117645"
inkscape:export-ydpi="94.117645"
inkscape:export-filename="/home/webmaster/Desktop/new_doc_128.png" />
<g
id="g3966-2"
transform="matrix(0.99990096,0.01407388,-0.01407388,0.99990096,-245.10157,-201.70028)"
clip-path="url(#clipPath4144)">
<path
inkscape:connector-curvature="0"
id="path3895-6-6-7-4-6-8-4-4"
d="m 597.71136,649.10637 -12.9375,6.3125 3.6875,2.09375 c 0,0 -19.96054,26.62963 -24.53125,32.84375 l -9.125,4 8.03125,1.40625 L 597.71136,649.10637 Z"
style="fill:url(#linearGradient3970-6);fill-opacity:1;stroke:none" />
<path
inkscape:connector-curvature="0"
id="path3895-6-6-7-4-6-8-4-5-8"
d="m 597.69396,649.11595 -2.39786,14.19425 -3.05074,-2.94525 c 0,0 -19.90106,26.67412 -24.56967,32.81503 l -1.25739,9.88354 -3.61917,-7.30616 L 597.69396,649.11595 Z"
style="fill:url(#linearGradient4111);fill-opacity:1;stroke:none" />
</g>
</g>
</svg>

0 comments on commit 3afee3c

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