On Tue, Nov 20, 2012 at 5:52 PM, Etienne Tourigny
<[email protected]>wrote:

> Hi,
>
> I am trying to add some tests for the addRasterLayer() and
> addVectorLayer() members in QgisApp, and it seems I cannot have access
> to them from the test environment.


>
[...]



How to get the "real" QgsAppInterface like when using a plugin?
>

Hi Etienne

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.

IIRC addVectorLayer() and addRasterLayer() are just relatively simple
wrappers around this code:
layer = new Qgs[Vector / Raster]Layer( ... );
if (layer->isValid())
  QgsMapLayerRegistry::instance()->addMapLayer(layer);

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?

Regards
Martin
_______________________________________________
Qgis-developer mailing list
[email protected]
http://lists.osgeo.org/mailman/listinfo/qgis-developer

Reply via email to