[Libreoffice-commits] core.git: sw/qa
Libreoffice Gerrit user
logerrit at kemper.freedesktop.org
Mon Dec 31 14:23:53 UTC 2018
sw/qa/extras/uiwriter/data2/tdf64242_optimizeTable.odt |binary
sw/qa/extras/uiwriter/uiwriter2.cxx | 44 +++++++++++++++++
2 files changed, 44 insertions(+)
New commits:
commit 0e9d621c471bdf486fb535b068fe841b56e2e8c6
Author: Justin Luth <justin.luth at collabora.com>
AuthorDate: Mon Dec 31 14:20:15 2018 +0300
Commit: Justin Luth <justin_luth at sil.org>
CommitDate: Mon Dec 31 15:23:31 2018 +0100
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 at 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 000000000000..83d9be2cdf16
Binary files /dev/null and b/sw/qa/extras/uiwriter/data2/tdf64242_optimizeTable.odt differ
diff --git a/sw/qa/extras/uiwriter/uiwriter2.cxx b/sw/qa/extras/uiwriter/uiwriter2.cxx
index 67aa3b7d7145..233b50ebe3dc 100644
--- a/sw/qa/extras/uiwriter/uiwriter2.cxx
+++ b/sw/qa/extras/uiwriter/uiwriter2.cxx
@@ -37,6 +37,7 @@ public:
void testTdf47471_paraStyleBackground();
void testTdf101534();
void testTdf54819();
+ void testTdf64242_optimizeTable();
void testTdf108687_tabstop();
void testTdf119571();
void testTdf119019();
@@ -49,6 +50,7 @@ public:
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 @@ void SwUiWriterTest2::testTdf54819()
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");
More information about the Libreoffice-commits
mailing list