tdf#64242 unit test added
TableColumns must be much different from rows, because I couldn't
get the properties/width of those, and even MRI just threw a
VOID message when trying to getByIndex. So I couldn't do any
specific column-width tests, just table-width.
Similarly, I couldn't do simple table-height tests.
Change-Id: I4c1deaf6a4f6beb7325467ac9940f4328cfc1d44
Reviewed-on: https://gerrit.libreoffice.org/65768
Tested-by: Jenkins
Reviewed-by: Justin Luth <justin_luth@sil.org>
diff --git a/sw/qa/extras/uiwriter/data2/tdf64242_optimizeTable.odt b/sw/qa/extras/uiwriter/data2/tdf64242_optimizeTable.odt
new file mode 100644
index 0000000..83d9be2
--- /dev/null
+++ b/sw/qa/extras/uiwriter/data2/tdf64242_optimizeTable.odt
Binary files differ
diff --git a/sw/qa/extras/uiwriter/uiwriter2.cxx b/sw/qa/extras/uiwriter/uiwriter2.cxx
index 67aa3b7..233b50e 100644
--- a/sw/qa/extras/uiwriter/uiwriter2.cxx
+++ b/sw/qa/extras/uiwriter/uiwriter2.cxx
@@ -37,6 +37,7 @@
void testTdf47471_paraStyleBackground();
void testTdf101534();
void testTdf54819();
void testTdf64242_optimizeTable();
void testTdf108687_tabstop();
void testTdf119571();
void testTdf119019();
@@ -49,6 +50,7 @@
CPPUNIT_TEST(testTdf47471_paraStyleBackground);
CPPUNIT_TEST(testTdf101534);
CPPUNIT_TEST(testTdf54819);
CPPUNIT_TEST(testTdf64242_optimizeTable);
CPPUNIT_TEST(testTdf108687_tabstop);
CPPUNIT_TEST(testTdf119571);
CPPUNIT_TEST(testTdf119019);
@@ -277,6 +279,48 @@
getProperty<OUString>(getParagraph(1), "ParaStyleName"));
}
void SwUiWriterTest2::testTdf64242_optimizeTable()
{
SwDoc* pDoc = createDoc("tdf64242_optimizeTable.odt");
SwWrtShell* pWrtShell = pDoc->GetDocShell()->GetWrtShell();
uno::Reference<text::XTextTablesSupplier> xTablesSupplier(mxComponent, uno::UNO_QUERY);
uno::Reference<frame::XModel> xModel(mxComponent, uno::UNO_QUERY);
uno::Reference<container::XIndexAccess> xTables(xTablesSupplier->getTextTables(),
uno::UNO_QUERY);
uno::Reference<text::XTextTable> xTextTable(xTables->getByIndex(0), uno::UNO_QUERY);
uno::Reference<table::XTableRows> xTableRows(xTextTable->getRows(), uno::UNO_QUERY);
double origWidth = getProperty<double>(xTextTable, "Width");
sal_Int32 nToleranceW = origWidth * .01;
CPPUNIT_ASSERT_DOUBLES_EQUAL_MESSAGE("Table Width", double(17013), origWidth, nToleranceW);
pWrtShell->SelTable(); //select the whole table
lcl_dispatchCommand(mxComponent, ".uno:SetOptimalColumnWidth", {});
CPPUNIT_ASSERT_DOUBLES_EQUAL_MESSAGE("Table Width: optimize", origWidth,
getProperty<double>(xTextTable, "Width"), nToleranceW);
lcl_dispatchCommand(mxComponent, ".uno:SetMinimalColumnWidth", {});
CPPUNIT_ASSERT_MESSAGE("Table Width: minimized",
(origWidth - nToleranceW) > getProperty<double>(xTextTable, "Width"));
double origRowHeight = getProperty<double>(xTableRows->getByIndex(2), "Height");
sal_Int32 nToleranceH = origRowHeight * .01;
CPPUNIT_ASSERT_DOUBLES_EQUAL_MESSAGE("Row Height", double(3441), origRowHeight, nToleranceH);
lcl_dispatchCommand(mxComponent, ".uno:SetOptimalRowHeight", {});
double optimalRowHeight = getProperty<double>(xTableRows->getByIndex(2), "Height");
CPPUNIT_ASSERT_MESSAGE("Row Height: optimized",
(origRowHeight - nToleranceH) > optimalRowHeight);
lcl_dispatchCommand(mxComponent, ".uno:SetMinimalRowHeight", {});
double minimalRowHeight = getProperty<double>(xTableRows->getByIndex(2), "Height");
CPPUNIT_ASSERT_MESSAGE("Row Height: minimized",
(optimalRowHeight - nToleranceH) > minimalRowHeight);
CPPUNIT_ASSERT_EQUAL_MESSAGE("Row set to auto-height", double(0), minimalRowHeight);
}
void SwUiWriterTest2::testTdf108687_tabstop()
{
SwDoc* pDoc = createDoc("tdf108687_tabstop.odt");