The unit tests architecture

Nathan Sala sala.nathan at gmail.com
Sat Jan 30 14:50:11 CET 2010


Thank you Leo,

This code is really helpful for us!

Anyway, are some people willing to comment a global unit tests
system refactoring in Amarok?


2010/1/29 Leo Franchi <lfranchi at kde.org>

> On Wed, Jan 27, 2010 at 8:00 PM, Nathan Sala <sala.nathan at gmail.com>
> wrote:
> > Hello,
> >
> > Anyway, while working on Data Engines, we are stuck because we simply
> can't
> > link to
> > our engines in our test files. It is the consequence of the fact that the
> > Data Engines are not
> > linkable from our test directory. The tests are part of
> amaroklib_LIB_SRCS
> > and the engines
> > link to amaroklib_LIB_SRCS but are not part of it. The result is we can't
> > instanciate any of
> > our data engines in the test folder. Adding the DataEngines classes into
> > amaroklib_LIB_SRCS
> > will result in linking error due to recursive inclusion  (if I understand
> > correctly).
> >
> >
> > We have thought about two solutions:
> >
> > Perform "black box tests" instead of "white box" ==> use the DataEngine
> > methods
> > instead of MyAppletDataEngine methods. But the problem is the way to
> request
> > a
> > DataEngine from the KDE plugin service seems complex regarding to the
> > Applet::dataEngine(QString)
> > method. If you someone knows a more simple way to request the DataEngine,
> > please let us know.
>
> I don';t know much about unit testing so i'm going to respond only to
> this KDE/plasma-specific part of the email. You can't use the applet
> ::dataEngine() methods to load the dataengine automatically, right? so
> you can load the dataengines yourself through the KTrader system.
>
> it would look something like this: (from
> DataEngineManager.cpp::loadEngine()
>
> Plasma::DataEngine *engine = 0;
>  // load the engine, add it to the engines
>    QString constraint = QString("[X-KDE-PluginInfo-Name] == 'PLUGIN
> NAME OF THE DATA ENGINE YOU WANT'").arg(name);
>    KService::List offers =
> KServiceTypeTrader::self()->query("Plasma/DataEngine", constraint);
>    QString error;
>
> if (offers.isEmpty()) {
>        kDebug() << "offers are empty for " << name << " with
> constraint " << constraint;
>    } else {
>        QVariantList allArgs;
>        allArgs << offers.first()->storageId();
>        QString api = offers.first()->property("X-Plasma-API").toString();
>        if (api.isEmpty()) {
>            if (offers.first()) {
>                KPluginLoader plugin(*offers.first());
>                if
> (Plasma::isPluginVersionCompatible(plugin.pluginVersion())) {
>                    engine =
> offers.first()->createInstance<Plasma::DataEngine>(0, allArgs,
> &error);
>                }
>            }
>        } else {
>            engine = new DataEngine(0, offers.first());
>        }
>    }
>
> And there you go, you have your DataEngine pointer from the plugin
> name, without having to use anything plasma-specific.
>
> hth,
> leo
>
> --
> ______________________________________________________
> lfranchi at kde.org                       Tufts  University 2010
> leonardo.franchi at tufts.edu         The KDE Project
> _______________________________________________
> Amarok-devel mailing list
> Amarok-devel at kde.org
> https://mail.kde.org/mailman/listinfo/amarok-devel
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.kde.org/pipermail/amarok-devel/attachments/20100130/c75f37ec/attachment.htm 


More information about the Amarok-devel mailing list