<div dir="ltr"><div><div><div><div><div><div><div><div><div><div><div><div><div><div>Hi,<br><br></div>While trying to get some labeling bugs fixed, I noticed some serious issues with the local unit test server, for qgis_mapsev.fcgi, I had previously made, and some issues relating to the loading of test fonts. The latter drove me crazy for over a week trying to track it down, but I finally have a workaround. I can now essentially 'trust' the output from server tests.<br>
<br></div>What changes did I make?<br><br></div>* Tossed all the old QgsLocalServer[Config] classes and support files<br><br>* QgsLocalServer is now a server controller class [0] with these features:<br></div>-   Web and FCGI processes are separated and can be independently controlled<br>
</div>-   Abstracted controller can work with any backend Web and FCGI-spawning executables<br></div>-   Initial Lighttpd and spawn-fcgi support, but can work with Nginx, Apache, uWSGI, fcgiwrap, etc.<br>-   Just need local init scripts, or commands, and configs to add new backends, which only need to be on PATH<br>
</div>-   Uses sockets on *nix-based machines<br><br></div>* Removed FreeSansQGIS font and added Bitstream Vera Sans (Roman, Bold, Oblique, Bold Oblique) test font family [1]<br></div>* Test fonts reworked to have specific 'QGIS Vera Sans' name to avoid font conflicts<br>
</div>* Test fonts are now built into desktop and server executables via testdata.qrc<br>* In Release builds, all test fonts are available, but not loaded by default<br>* In Debug builds, all test fonts are available, but only Roman and Bold styles are loaded by default</div>
* Loading of test fonts moved to QgsFontUtils, with sip bindings<br></div><br></div><div><br>What does this affect?<br><br></div><div>Very little, except my sanity. :-) Other than the adding of testdata.qrc to the desktop and server executables, regardless of build type, only the fledgling Python unit tests for labeling were affected. This is because no one else used the old QgsLocalServer classes.<br>
</div><div><br></div><br>So, what's this mean?<br><br></div><div>* Adding a local server to a Python test class is very simple [1]<br></div><div>* Once Web and FCGI-spawning executables are available on PATH, no other config required<br>
</div><div>* Classes are initial foundation for a Python plugin that allows live previewing of current project in a local, no-config QGIS Server, with chose-able web client loaded into QWebPage<br></div><div><br></div><div>
* Test fonts are more robust, but still fairly small in size (load quickly) [2, see char tables]<br></div><div>* Test fonts can easily be loaded via C++ or Python in desktop or unit tests<br></div><div>* Example: loaded from PyQGIS Console (running RelWithDebInfo build)<br>
<br></div><div>from PyQt4.QtGui import *<br>fontdb = QFontDatabase()<br><br>fontdb.styles(QgsFontUtils.standardTestFontFamily()) --> [u'Bold', u'Roman']<br>QgsFontUtils.loadStandardTestFonts(['Bold Oblique']) --> True<br>
fontdb.styles(QgsFontUtils.standardTestFontFamily()) --> [u'Bold Oblique', u'Bold', u'Roman']<br><br>tf = QgsFontUtils.getStandardTestFont('Bold Oblique', 12) --> QFont<br>tf.family() --> u'QGIS Vera Sans'<br>
tf.bold() --> True<br>tf.italic() --> True<br>tf.pointSize() --> 12<br><br></div><div>* Such manual loading of test font(s) in a Release build allows helping users debug labeling, etc. with a known, valid font<br>
</div><div>* Using similar interface, other fonts of differing typeface, writing direction, etc. can easily be unit tested<br><br></div><div><br></div>Caveats?<br><div><br></div><div>* Only config'd to work with lighttpd/spawn-fcgi and only on Mac, right now<br>
<br>This is because I didn't have time to also config on other platforms and work on labeling bugs. It's fairly quick to do however. See [3, 4], if interested in adding a platform/server setup. The labeling tests generally failed on most platforms anyways, due to other issues that this setup has fixed.<br>
<br></div><div>* Practically no docstrings or other documentation, yet (classes are pretty semantic, though)<br></div><div><br></div><div>* Control images need rebuilt.. so, all labeling tests will fail until then<br></div>
<div><br><br></div><div>Lastly, please do not hesitate to make my submitted code better. :-)<br><br></div><div><br>[0] <a href="https://github.com/qgis/QGIS/blob/master/tests/src/python/qgis_local_server.py#L208-L467">https://github.com/qgis/QGIS/blob/master/tests/src/python/qgis_local_server.py#L208-L467</a><br>
[1] <a href="https://github.com/qgis/QGIS/blob/master/tests/src/python/qgis_local_server.py#L542-L587">https://github.com/qgis/QGIS/blob/master/tests/src/python/qgis_local_server.py#L542-L587</a><br>[2] <a href="https://github.com/qgis/QGIS/tree/master/tests/testdata/font/QGIS-Vera">https://github.com/qgis/QGIS/tree/master/tests/testdata/font/QGIS-Vera</a><br>
[3] <a href="https://github.com/qgis/QGIS/blob/master/tests/src/python/test_qgis_local_server.py#L51">https://github.com/qgis/QGIS/blob/master/tests/src/python/test_qgis_local_server.py#L51</a><br>[4] <a href="https://github.com/qgis/QGIS/tree/master/tests/testdata/qgis_local_server">https://github.com/qgis/QGIS/tree/master/tests/testdata/qgis_local_server</a><br>
<div><div><div><div><div><div><div><div><div><div><div><div><div><div><div><div><br></div><div>Regards,<br></div><div><br>Larry Shaffer<br>Dakota Cartography<br>Black Hills, South Dakota</div>
</div></div></div></div></div></div></div></div></div></div></div></div></div></div></div></div></div>