Hello,
On 08/08/2018 07:03 AM, Rahul Gurung wrote:
Hi,
I have almost converted ifc/text/_XFootnote.java into cpp but I am
confused with the sc/qa/extra part which file should be changed or
created and why? I checked old commits and think it depends on the test
but what should it be, in the case of _XFootnote.java?
Here is my step-by-step approach to convert Java UnitTest to C++. From
what I read you are currently at step 3.
As mentioned in this comment
https://bugs.documentfoundation.org/show_bug.cgi?id=45904#c4 the code is
divided in two parts:
One parts set ups the test and you will find them under
qadevOOo/tests/java/mod/ (e.g for calc/sheet they're here
qadevOOo/tests/java/mod/_sc/). They mostly called *Obj.java. (I will
referrer to them as obj in the rest of the email).
The second part are the actual tests and they're under
qadevOOo/tests/java/ifc/ (e.g. for calc/sheet/ you will find them here
qadevOOo/tests/java/ifc/sheet).
You also will find two types of tests in the interface directory
(.../ifc). One tests services and their properties and the other one
tests interfaces and the function they provide. The later ones start
with an X and the first one don't start with a X in their file name (you
can ignore the underscore "_").
The obj and the tests are tied together by CSV files, you will find them
under qadevOOo/objdsc/ (e.g qadevOOo/objdsc/sc/).
The service/property tests are special kind of tests. All the logic is
moved to this file
https://opengrok.libreoffice.org/xref/core/qadevOOo/runner/lib/MultiPropertyTest.java.
This class extracts the information from the corresponding CSV file and
the information of the interface.
Then decides what kind of type the property has and runs the test
against it by getting the property value and the changing the property
value (that's done in
https://opengrok.libreoffice.org/xref/core/qadevOOo/runner/util/ValueChanger.java).
To every test file you can find an IDL file. That file contains
information about the functions or the properties. You can look at them
under https://opengrok.libreoffice.org/xref/core/offapi/com/sun/star/ or
https://api.libreoffice.org/docs/idl/ref/index.html.
Next I will describe how I transformed the tests from Java to C++ with
an example of SheetFilterDescriptor:
https://cgit.freedesktop.org/libreoffice/core/commit/?id=5a0acced8988a54d8aaf0328d2696dae21727c6a
I do all my coding under Linux, so some of the steps include CLI commands.
1. I looked at the Java code of
qadevOOo/tests/java/ifc/sheet/_SheetFilterDescriptor.java
Because the class was empty I knew the tests of the properties is done
with
https://opengrok.libreoffice.org/xref/core/qadevOOo/runner/lib/MultiPropertyTest.java
and I don't have to create special cases.
2. Next I looked at the IDL file
(https://opengrok.libreoffice.org/xref/core/offapi/com/sun/star/sheet/SheetFilterDescriptor.idl)
to understand, what properties the services has, what type they are, and
if some of them are read-only.
3. Now I searched for the obj which is used to test the interface.
I normally use grep like # grep "sheet::SheetFilterDescriptor"
core/qadevOOo/objdsc/sc/*. This will list the file or files which uses
the tests. From the file name I can extract the obj. It's the last part
of the filename before the file extension. The filename was
"com.sun.star.comp.office.ScFilterDescriptorBase.csv" so the obj is
"ScFilterDescriptorBase".
4. Now I looked at the Java code for the obj
(https://opengrok.libreoffice.org/xref/core/qadevOOo/tests/java/mod/_sc/ScFilterDescriptorBase.java)
just to get feel what is created to run the test.
5. Now I look at the C++ code for the obj, if it exists. It did
https://opengrok.libreoffice.org/xref/core/sc/qa/extras/scfilterdescriptorbaseobj.cxx.
If not you have to create the object from the Java code.
6. Now I started coding.
This included creating a new header file, adding the test to the C++
obj file, creating the source file and enabling it in the Makefile.
You can run only the specific tests of the obj by make
CppunitTest_sc_filterdescriptorbaseobj
7. Clean up the old Java stuff.
8. Check that everything is still working with "make check"
9. Push changes to gerrit and wait for the tests to finish.
I hope that will help you to get started. Should you have more question
try to get a hold off me in IRC (it's not always possible to answer
right away, because I'm working) or send an email.
Cheers,
Jens
P.S. All the remaining tests under qadevOOo/tests/java/ifc/sheet/ are
the hardest to transfer, because some of them have bugs. You can find a
list in
https://opengrok.libreoffice.org/xref/core/sc/qa/unoapi/knownissues.xcl.
Context
Privacy Policy |
Impressum (Legal Info) |
Copyright information: Unless otherwise specified, all text and images
on this website are licensed under the
Creative Commons Attribution-Share Alike 3.0 License.
This does not include the source code of LibreOffice, which is
licensed under the Mozilla Public License (
MPLv2).
"LibreOffice" and "The Document Foundation" are
registered trademarks of their corresponding registered owners or are
in actual use as trademarks in one or more countries. Their respective
logos and icons are also subject to international copyright laws. Use
thereof is explained in our
trademark policy.