Bug 94272 - Reduce copy'n'pasta code in Impress unit tests (sd/qa)
Summary: Reduce copy'n'pasta code in Impress unit tests (sd/qa)
Status: RESOLVED FIXED
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: Impress (show other bugs)
Version:
(earliest affected)
5.1.0.0.alpha0+ Master
Hardware: Other All
: medium normal
Assignee: Not Assigned
URL:
Whiteboard: target:5.1.0
Keywords: difficultyInteresting, easyHack, skillCpp, skillUno, topicCleanup
Depends on:
Blocks:
 
Reported: 2015-09-16 12:02 UTC by Katarina Behrens (Inactive)
Modified: 2016-10-25 19:17 UTC (History)
2 users (show)

See Also:
Crash report or crash signature:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Katarina Behrens (Inactive) 2015-09-16 12:02:48 UTC
There's lot of duplicated code in sd (unit) tests, such as:

    uno::Reference<text::XText> xText = uno::Reference<text::XTextRange>(xShape, uno::UNO_QUERY)->getText();
    CPPUNIT_ASSERT_MESSAGE( "not a text shape", xText.is() );
    uno::Reference<container::XEnumerationAccess> paraEnumAccess;
    paraEnumAccess.set(xText, uno::UNO_QUERY);
    uno::Reference<container::XEnumeration> paraEnum = paraEnumAccess->createEnumeration();
    uno::Reference<text::XTextRange> const xParagraph(paraEnum->nextElement(),
                uno::UNO_QUERY_THROW);
    uno::Reference< beans::XPropertySet > xPropSet( xParagraph, uno::UNO_QUERY_THROW );

Such code is copy'n'pasted all over the place, whenever it is used.

It'd be useful to reduce that copy'n'pasta and make some convenience functions out of this frequently used code, such as:

getSlide(document, N ) 
getShape( slide, N)
getParagraph(shape, N)
getRun(paragraph, N) 

and so on
Comment 1 Commit Notification 2015-11-17 10:31:54 UTC
Katarina Behrens committed a patch related to this issue.
It has been pushed to "master":

http://cgit.freedesktop.org/libreoffice/core/commit/?id=927019f5d253a12d285f68a5f0240548d2048def

tdf#94272: Reduce copy'n'pasta code in sd unit tests

It will be available in 5.1.0.

The patch should be included in the daily builds available at
http://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More
information about daily builds can be found at:
http://wiki.documentfoundation.org/Testing_Daily_Builds

Affected users are encouraged to test the fix and report feedback.
Comment 2 Robinson Tryon (qubit) 2015-12-15 23:33:27 UTC Comment hidden (obsolete)
Comment 3 Robinson Tryon (qubit) 2016-02-18 16:37:22 UTC Comment hidden (obsolete)