Kaydet (Commit) 08dc5de9 authored tarafından Michael Stahl's avatar Michael Stahl

fdo#60842: add a unit test

Change-Id: Ie91fe22f2baf0a280e5cf21c2416228ab414f285
üst 40dc6c3a
......@@ -30,6 +30,8 @@
#include <com/sun/star/style/XStyleFamiliesSupplier.hpp>
#include <com/sun/star/text/XTextDocument.hpp>
#include <com/sun/star/text/XTextRange.hpp>
#include <com/sun/star/text/XTextTable.hpp>
#include <com/sun/star/table/XCell.hpp>
#include <test/bootstrapfixture.hxx>
#include <unotest/macros_test.hxx>
......@@ -196,7 +198,7 @@ protected:
}
// Get paragraph (counted from 1), optionally check it contains the given text.
uno::Reference< text::XTextRange > getParagraph( int number, OUString content = OUString() ) const
uno::Reference<text::XTextContent> getParagraphOrTable(int number) const
{
uno::Reference<text::XTextDocument> textDocument(mxComponent, uno::UNO_QUERY);
uno::Reference<container::XEnumerationAccess> paraEnumAccess(textDocument->getText(), uno::UNO_QUERY);
......@@ -205,10 +207,18 @@ protected:
i < number;
++i )
paraEnum->nextElement();
uno::Reference< text::XTextRange > paragraph( paraEnum->nextElement(), uno::UNO_QUERY );
uno::Reference< text::XTextContent> const xElem(paraEnum->nextElement(),
uno::UNO_QUERY_THROW);
return xElem;
}
uno::Reference< text::XTextRange > getParagraph( int number, OUString content = OUString() ) const
{
uno::Reference<text::XTextRange> const xParagraph(
getParagraphOrTable(number), uno::UNO_QUERY_THROW);
if( !content.isEmpty())
CPPUNIT_ASSERT_EQUAL( content, paragraph->getString());
return paragraph;
CPPUNIT_ASSERT_EQUAL( content, xParagraph->getString());
return xParagraph;
}
/// Get run (counted from 1) of a paragraph, optionally check it contains the given text.
......@@ -233,6 +243,24 @@ protected:
return getProperty<OUString>(getProperty< uno::Reference<beans::XPropertySet> >(xFormula, "Model"), "Formula");
}
/// get cell of a table; table can be retrieved with getParagraphOrTable
uno::Reference<table::XCell> getCell(
uno::Reference<uno::XInterface> const& xTableIfc,
OUString const& rCell, OUString const& rContent = OUString())
{
uno::Reference<text::XTextTable> const xTable(xTableIfc,
uno::UNO_QUERY_THROW);
uno::Reference<table::XCell> const xCell(
xTable->getCellByName(rCell), uno::UNO_SET_THROW);
if (!rContent.isEmpty())
{
uno::Reference<text::XText> const xCellText(xCell,
uno::UNO_QUERY_THROW);
CPPUNIT_ASSERT_EQUAL(rContent, xCellText->getString());
}
return xCell;
}
void header()
{
fprintf(stderr, "File tested,Execution Time (ms)\n");
......@@ -246,7 +274,7 @@ protected:
mxComponent = loadFromDesktop(getURLFromSrc(pDir) + OUString::createFromAscii(pName), "com.sun.star.text.TextDocument");
calcLayout();
}
void reload(OUString aFilter)
{
uno::Reference<frame::XStorable> xStorable(mxComponent, uno::UNO_QUERY);
......
......@@ -42,6 +42,7 @@ public:
void testOdtBorders();
void testPageStyleLayoutDefault();
void testPageStyleLayoutRight();
void testFdo60842();
CPPUNIT_TEST_SUITE(Test);
#if !defined(MACOSX) && !defined(WNT)
......@@ -61,6 +62,7 @@ void Test::run()
{"borders_ooo33.odt", &Test::testOdtBorders},
{"hello.odt", &Test::testPageStyleLayoutDefault},
{"hello.odt", &Test::testPageStyleLayoutRight},
{"fdo60842.odt", &Test::testFdo60842},
};
header();
for (unsigned int i = 0; i < SAL_N_ELEMENTS(aMethods); ++i)
......@@ -291,6 +293,16 @@ void Test::testPageStyleLayoutRight()
xPropertySet->setPropertyValue("PageStyleLayout", uno::makeAny(style::PageStyleLayout_RIGHT));
}
void Test::testFdo60842()
{
uno::Reference<text::XTextContent> const xTable(getParagraphOrTable(0));
getCell(xTable, "A1", "");
getCell(xTable, "B1", "18/02/2012");
getCell(xTable, "C1", "USD"); // this is the cell with office:string-value
getCell(xTable, "D1", "");
getCell(xTable, "E1", "01/04/2012");
}
CPPUNIT_TEST_SUITE_REGISTRATION(Test);
CPPUNIT_PLUGIN_IMPLEMENT();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment