summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Kaganski <mike.kaganski@collabora.com>2020-04-27 17:20:42 +0300
committerMike Kaganski <mike.kaganski@collabora.com>2020-04-27 18:11:20 +0200
commitbbae20800758802d828805925c1ba526715cca78 (patch)
tree870751b820dfbdcb9c5271bae9ef54eb45810aa4
parent22a2698466bb7ca14744e6aa39e8940de1c05f1f (diff)
Fix testFdo58949
For some reason, on my Windows box (but apparently not on CI) I saw testFdo58949 consistently failing during `make CppunitTest_sw_odfexport`, but not in `make CppunitTest_sw_odfexport CPPUNIT_TEST_NAME=testFdo58949`. Turns out that depends on test order (if the static counter for objects was inreased by other tests or not). This makes the test not rely on a specific object name, but rather on total matching names count. Additionally allow testResolvedComment to run on Windows, since it seems this reason why it used to break testFdo58949. Change-Id: Ibf0b7f1848622f800a05035a96028a8ed0986f48 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/92980 Tested-by: Mike Kaganski <mike.kaganski@collabora.com> Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
-rw-r--r--sw/qa/extras/odfexport/odfexport.cxx24
1 files changed, 20 insertions, 4 deletions
diff --git a/sw/qa/extras/odfexport/odfexport.cxx b/sw/qa/extras/odfexport/odfexport.cxx
index 91e0b846d602..89cf753241d9 100644
--- a/sw/qa/extras/odfexport/odfexport.cxx
+++ b/sw/qa/extras/odfexport/odfexport.cxx
@@ -7,6 +7,7 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
+#include <algorithm>
#include <memory>
#include <swmodeltestbase.hxx>
#include <config_features.h>
@@ -501,10 +502,8 @@ DECLARE_ODFEXPORT_TEST(testSenderInitials, "sender-initials.fodt")
}
}
-#ifndef _WIN32
DECLARE_ODFEXPORT_TEST(testResolvedComment, "resolved-comment.odt")
{
- // TODO find out why does this break testFdo58949 on Windows.
uno::Reference<text::XTextFieldsSupplier> xTextFieldsSupplier(mxComponent, uno::UNO_QUERY);
uno::Reference<container::XEnumerationAccess> xFieldsAccess(xTextFieldsSupplier->getTextFields());
uno::Reference<container::XEnumeration> xFields(xFieldsAccess->createEnumeration());
@@ -513,7 +512,6 @@ DECLARE_ODFEXPORT_TEST(testResolvedComment, "resolved-comment.odt")
xPropertySet.set(xFields->nextElement(), uno::UNO_QUERY);
CPPUNIT_ASSERT_EQUAL(false, getProperty<bool>(xPropertySet, "Resolved"));
}
-#endif
DECLARE_ODFEXPORT_TEST(testTdf92379, "tdf92379.fodt")
{
@@ -721,7 +719,25 @@ DECLARE_ODFEXPORT_TEST(testFdo58949, "fdo58949.docx")
uno::Sequence<uno::Any> aArgs(1);
aArgs[0] <<= aTempFile.GetURL();
uno::Reference<container::XNameAccess> xNameAccess(m_xSFactory->createInstanceWithArguments("com.sun.star.packages.zip.ZipFileAccess", aArgs), uno::UNO_QUERY);
- CPPUNIT_ASSERT_EQUAL(true, bool(xNameAccess->hasByName("Obj102")));
+ const css::uno::Sequence<OUString> aNames(xNameAccess->getElementNames());
+ // The exported document must have three objects named ObjNNN. The names are assigned in
+ // OLEHandler::copyOLEOStream using a static counter, and actual numbers depend on previous
+ // tests; so just count the matching names here.
+ int nMatches = 0;
+ for (const OUString& sName : aNames)
+ {
+ OUString sRest;
+ if (sName.startsWith("Obj", &sRest))
+ {
+ // all following characters must be decimal digits; minimal value is 100
+ bool bMatch = sRest.getLength() >= 3
+ && std::all_of(sRest.getStr(), sRest.getStr() + sRest.getLength(),
+ [](sal_Unicode ch) { return ch >= '0' && ch <= '9'; });
+ if (bMatch)
+ ++nMatches;
+ }
+ }
+ CPPUNIT_ASSERT_EQUAL(3, nMatches);
}
DECLARE_ODFEXPORT_TEST(testStylePageNumber, "ooo321_stylepagenumber.odt")