<br><div class="gmail_extra"><div class="gmail_quote">On Tue, Nov 20, 2012 at 5:52 PM, Etienne Tourigny <span dir="ltr"><<a href="mailto:etourigny.dev@gmail.com" target="_blank">etourigny.dev@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi,<br>
<br>
I am trying to add some tests for the addRasterLayer() and<br>
addVectorLayer() members in QgisApp, and it seems I cannot have access<br>
to them from the test environment. </blockquote><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"> <br></blockquote><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
[...] </blockquote><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"> </blockquote><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">

How to get the "real" QgsAppInterface like when using a plugin?<br></blockquote><div> </div><div>Hi Etienne</div><div><br></div><div>that's right, it's not possible to access QgisAppInterface outside of running QGIS instance. This has a reason: the interface provides various methods that make sense only when QGIS is running (e.g. access to map canvas, main window, toolbars). For testing purposes you could create a fake implmentation of QgisInterface, but that's most likely not what you want.</div>
<div><br></div><div>IIRC addVectorLayer() and addRasterLayer() are just relatively simple wrappers around this code:</div><div>layer = new Qgs[Vector / Raster]Layer( ... );</div><div>if (layer->isValid())</div><div>  QgsMapLayerRegistry::instance()->addMapLayer(layer);</div>
<div><br></div><div>I'm wondering what exactly are you trying to test... is it the "core" layer (and provider) loading or the connection with other QGIS components?</div><div><br></div><div>Regards</div><div>
Martin</div></div></div>