diff options
author | Miklos Vajna <vmiklos@collabora.com> | 2020-03-06 09:42:04 +0100 |
---|---|---|
committer | Miklos Vajna <vmiklos@collabora.com> | 2020-03-06 10:19:20 +0100 |
commit | 191b43536a2bee034ef9902b49ca5fbcdbddec53 (patch) | |
tree | 6cd291cb9a82877b06a00cdfffe4b2fbd37e68d9 /sw/qa/extras/rtfexport | |
parent | 30a6e9e991fd1b62ead2d393331a0364372c52fb (diff) |
SwModelTestBase: speed up export tests
Export tests used to do the following steps:
1) Import
2) Verify
3) Discard state
4) Import
5) Export
6) Import
7) Verify
Assuming that the cost of 2), 3) and 7) is almost zero, that leaves us
with 4 filter() invocations for every such "export" test. But it seems
to me, we can save one filter() call if we do it this way:
1) Import
2) Verify
3) Export
4) Import
5) Verify
The only trick is that verify should perform its verification by only
reading the document model. So adapt tests which mutated the doc model:
paste tests should be import tests, the rest only did mutation by
accident.
A 'make check' is 88 seconds faster for me with this, using -j8. (~12
minutes of CPU time saved.)
Change-Id: I40db8a9b9adaa99020acd718ba4ec3fd9bee3fb8
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/90077
Reviewed-by: Miklos Vajna <vmiklos@collabora.com>
Tested-by: Jenkins
Diffstat (limited to 'sw/qa/extras/rtfexport')
-rw-r--r-- | sw/qa/extras/rtfexport/rtfexport2.cxx | 18 | ||||
-rw-r--r-- | sw/qa/extras/rtfexport/rtfexport5.cxx | 9 |
2 files changed, 18 insertions, 9 deletions
diff --git a/sw/qa/extras/rtfexport/rtfexport2.cxx b/sw/qa/extras/rtfexport/rtfexport2.cxx index ff63ac7db40f..243bf2511585 100644 --- a/sw/qa/extras/rtfexport/rtfexport2.cxx +++ b/sw/qa/extras/rtfexport/rtfexport2.cxx @@ -599,8 +599,9 @@ DECLARE_RTFEXPORT_TEST(testFdo55493, "fdo55493.rtf") CPPUNIT_ASSERT_EQUAL(sal_Int32(3969), xShape->getSize().Width); } -DECLARE_RTFEXPORT_TEST(testCopyPastePageStyle, "copypaste-pagestyle.rtf") +CPPUNIT_TEST_FIXTURE(Test, testCopyPastePageStyle) { + load(mpTestDocumentPath, "copypaste-pagestyle.rtf"); // The problem was that RTF import during copy&paste did not ignore page styles. // Once we have more copy&paste tests, makes sense to refactor this to some helper method. uno::Reference<text::XTextDocument> xTextDocument(mxComponent, uno::UNO_QUERY); @@ -614,8 +615,9 @@ DECLARE_RTFEXPORT_TEST(testCopyPastePageStyle, "copypaste-pagestyle.rtf") getProperty<sal_Int32>(xPropertySet, "Width")); // Was letter, i.e. 21590 } -DECLARE_RTFEXPORT_TEST(testCopyPasteFootnote, "copypaste-footnote.rtf") +CPPUNIT_TEST_FIXTURE(Test, testCopyPasteFootnote) { + load(mpTestDocumentPath, "copypaste-footnote.rtf"); // The RTF import did not handle the case when the position wasn't the main document XText, but something different, e.g. a footnote. uno::Reference<text::XFootnotesSupplier> xFootnotesSupplier(mxComponent, uno::UNO_QUERY); uno::Reference<container::XIndexAccess> xFootnotes = xFootnotesSupplier->getFootnotes(); @@ -625,8 +627,9 @@ DECLARE_RTFEXPORT_TEST(testCopyPasteFootnote, "copypaste-footnote.rtf") CPPUNIT_ASSERT_EQUAL(OUString("bbb"), xTextRange->getString()); } -DECLARE_RTFEXPORT_TEST(testFdo63428, "hello.rtf") +CPPUNIT_TEST_FIXTURE(Test, testFdo63428) { + load(mpTestDocumentPath, "hello.rtf"); // Pasting content that contained an annotation caused a crash. uno::Reference<text::XTextDocument> xTextDocument(mxComponent, uno::UNO_QUERY); uno::Reference<text::XTextRange> xText = xTextDocument->getText(); @@ -650,8 +653,9 @@ DECLARE_RTFEXPORT_TEST(testFdo69384, "fdo69384-paste.rtf") CPPUNIT_ASSERT_EQUAL(68.f, getProperty<float>(xPropertySet, "CharHeight")); } -DECLARE_RTFEXPORT_TEST(testFdo69384Inserted, "hello.rtf") +CPPUNIT_TEST_FIXTURE(Test, testFdo69384Inserted) { + load(mpTestDocumentPath, "hello.rtf"); uno::Reference<text::XTextDocument> xTextDocument(mxComponent, uno::UNO_QUERY); uno::Reference<text::XTextRange> xText = xTextDocument->getText(); uno::Reference<text::XTextRange> xEnd = xText->getEnd(); @@ -664,8 +668,9 @@ DECLARE_RTFEXPORT_TEST(testFdo69384Inserted, "hello.rtf") CPPUNIT_ASSERT_EQUAL(12.f, getProperty<float>(xPropertySet, "CharHeight")); } -DECLARE_RTFEXPORT_TEST(testFdo61193, "hello.rtf") +CPPUNIT_TEST_FIXTURE(Test, testFdo61193) { + load(mpTestDocumentPath, "hello.rtf"); // Pasting content that contained a footnote caused a crash. uno::Reference<text::XTextDocument> xTextDocument(mxComponent, uno::UNO_QUERY); uno::Reference<text::XTextRange> xText = xTextDocument->getText(); @@ -673,8 +678,9 @@ DECLARE_RTFEXPORT_TEST(testFdo61193, "hello.rtf") paste("rtfexport/data/fdo61193.rtf", xEnd); } -DECLARE_RTFEXPORT_TEST(testTdf108123, "hello.rtf") +CPPUNIT_TEST_FIXTURE(Test, testTdf108123) { + load(mpTestDocumentPath, "hello.rtf"); // This crashed, the shape push/pop and table manager stack went out of // sync -> we tried to de-reference an empty stack. uno::Reference<text::XTextDocument> xTextDocument(mxComponent, uno::UNO_QUERY); diff --git a/sw/qa/extras/rtfexport/rtfexport5.cxx b/sw/qa/extras/rtfexport/rtfexport5.cxx index 24553a0c2538..bae656e26a70 100644 --- a/sw/qa/extras/rtfexport/rtfexport5.cxx +++ b/sw/qa/extras/rtfexport/rtfexport5.cxx @@ -112,8 +112,9 @@ DECLARE_RTFEXPORT_TEST(testFdo64671, "fdo64671.rtf") getRun(getParagraph(1), 1, OUString(u"\u017D")); } -DECLARE_RTFEXPORT_TEST(testFdo62044, "fdo62044.rtf") +CPPUNIT_TEST_FIXTURE(Test, testFdo62044) { + load(mpTestDocumentPath, "fdo62044.rtf"); // The problem was that RTF import during copy&paste did not ignore existing paragraph styles. uno::Reference<text::XTextDocument> xTextDocument(mxComponent, uno::UNO_QUERY); uno::Reference<text::XTextRange> xText = xTextDocument->getText(); @@ -815,8 +816,9 @@ DECLARE_RTFEXPORT_TEST(testTdf91074, "tdf91074.rtf") getProperty<table::BorderLine2>(xShape, "TopBorder").Color); } -DECLARE_RTFEXPORT_TEST(testTdf90260Nopar, "hello.rtf") +CPPUNIT_TEST_FIXTURE(Test, testTdf90260Nopar) { + load(mpTestDocumentPath, "hello.rtf"); uno::Reference<text::XTextDocument> xTextDocument(mxComponent, uno::UNO_QUERY); uno::Reference<text::XTextRange> xText = xTextDocument->getText(); uno::Reference<text::XTextRange> xEnd = xText->getEnd(); @@ -956,8 +958,9 @@ DECLARE_RTFEXPORT_TEST(testTdf87034, "tdf87034.rtf") CPPUNIT_ASSERT_EQUAL(OUString("A1B3C4D"), getParagraph(1)->getString()); } -DECLARE_RTFEXPORT_TEST(testClassificatonPasteLevels, "classification-confidential.rtf") +CPPUNIT_TEST_FIXTURE(Test, testClassificatonPasteLevels) { + load(mpTestDocumentPath, "classification-confidential.rtf"); uno::Reference<text::XTextDocument> xTextDocument(mxComponent, uno::UNO_QUERY); uno::Reference<text::XTextRange> xText = xTextDocument->getText(); uno::Reference<text::XTextRange> xEnd = xText->getEnd(); |