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