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">&lt;<a href="mailto:lfranchi@kde.org">lfranchi@kde.org</a>&gt;</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 &lt;<a href="mailto:sala.nathan@gmail.com">sala.nathan@gmail.com</a>&gt; wrote:<br>

&gt; Hello,<br>
<div class="im">&gt;<br>
&gt; Anyway, while working on Data Engines, we are stuck because we simply can&#39;t<br>
&gt; link to<br>
&gt; our engines in our test files. It is the consequence of the fact that the<br>
&gt; Data Engines are not<br>
&gt; linkable from our test directory. The tests are part of amaroklib_LIB_SRCS<br>
&gt; and the engines<br>
&gt; link to amaroklib_LIB_SRCS but are not part of it. The result is we can&#39;t<br>
&gt; instanciate any of<br>
&gt; our data engines in the test folder. Adding the DataEngines classes into<br>
&gt; amaroklib_LIB_SRCS<br>
&gt; will result in linking error due to recursive inclusion  (if I understand<br>
&gt; correctly).<br>
&gt;<br>
&gt;<br>
&gt; We have thought about two solutions:<br>
&gt;<br>
&gt; Perform &quot;black box tests&quot; instead of &quot;white box&quot; ==&gt; use the DataEngine<br>
&gt; methods<br>
&gt; instead of MyAppletDataEngine methods. But the problem is the way to request<br>
&gt; a<br>
&gt; DataEngine from the KDE plugin service seems complex regarding to the<br>
&gt; Applet::dataEngine(QString)<br>
&gt; method. If you someone knows a more simple way to request the DataEngine,<br>
&gt; please let us know.<br>
<br>
</div>I don&#39;;t know much about unit testing so i&#39;m going to respond only to<br>
this KDE/plasma-specific part of the email. You can&#39;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(&quot;[X-KDE-PluginInfo-Name] == &#39;PLUGIN<br>
NAME OF THE DATA ENGINE YOU WANT&#39;&quot;).arg(name);<br>
    KService::List offers =<br>
KServiceTypeTrader::self()-&gt;query(&quot;Plasma/DataEngine&quot;, constraint);<br>
    QString error;<br>
<br>
if (offers.isEmpty()) {<br>
        kDebug() &lt;&lt; &quot;offers are empty for &quot; &lt;&lt; name &lt;&lt; &quot; with<br>
constraint &quot; &lt;&lt; constraint;<br>
    } else {<br>
        QVariantList allArgs;<br>
        allArgs &lt;&lt; offers.first()-&gt;storageId();<br>
        QString api = offers.first()-&gt;property(&quot;X-Plasma-API&quot;).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()-&gt;createInstance&lt;Plasma::DataEngine&gt;(0, allArgs,<br>
&amp;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>