D17455: Write unit tests for DownloadManager

Johnny Jazeix noreply at phabricator.kde.org
Mon Dec 10 21:07:37 GMT 2018


jjazeix added a comment.


  Thank you for the unit test.
  It may be easier to read if you have the data() then the corresponding test() function instead of having all the data() and at the end the test() functions (when you read one test, you'll just have to scroll above to know which data is tested)

INLINE COMMENTS

> alexkovrigin wrote in DownloadManagerTest.cpp:172
> I've been debugging and trying to solve this issue for some time, but I couldn't find the solution.
> 
>   subject->isDataRegistered(resource)
> 
> Always returns false.

This function is a bit tricky and not really easy to test.
Basically, when we register an activity, we use the following path: "qrc:/gcompris/src/activities/{activity_name}".
The function isDataRegistered looks for data in "qrc:/gcompris/data" which is filled in only if we have registered a specific data file "words.rcc".
But, this file is not compiled and needs to be downloaded (~80Mo). We don't want this (because it will be downloaded at every commit).
If we want to test this function, I think we can try to mock the registerResource to "save" a fake data in the ":/gcompris/data" resource.
Not sure if it would work, but having a local qrc file containing one file in ":/gcompris/data/" and doing INIT_REGISTER_RESOURCE on the qrc. More info can be found in https://doc.qt.io/qt-5/resources.html (first and last paragraphs).

> DownloadManagerTest.cpp:191
> +    DownloadManager * subject;
> +    QString getVoicesRecource_1(QString locale)
> +    {

typo (Resource) + use const reference for passing arguments that won't be updated to avoid copies.

REPOSITORY
  R2 GCompris

REVISION DETAIL
  https://phabricator.kde.org/D17455

To: alexkovrigin, jjazeix
Cc: alexkovrigin, kde-edu, narvaez, apol
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.kde.org/pipermail/kde-edu/attachments/20181210/c5afadd6/attachment-0001.html>


More information about the kde-edu mailing list