summaryrefslogtreecommitdiff
path: root/desktop
diff options
context:
space:
mode:
authorAshod Nakashian <ashod.nakashian@collabora.co.uk>2018-11-11 16:54:59 -0500
committerMichael Meeks <michael.meeks@collabora.com>2019-10-02 16:50:13 +0200
commit13fb343e3c48439c6cd7365f9a69ba2261885beb (patch)
treeccf7033fa476b51aa1214585f1ff92045424a345 /desktop
parent79b27379c1cf109faeb80bc51fdd1c44df4fbfee (diff)
LOK: disable LOKit in unit-tests only after destroying all
When we disable LOKit at the end of a unit-test, we do so before any of the smart-pointers go out of scope. These instances are then destroyed when LOKit is no longer active, in spite of the fact that they were created while it was. This leaves some dialog/window routing notifiers dangling, which cause assertion failures and access-after-free (when they are invoked on destruction inadvertently). The latter issue was found with 'make CppunitTest_sd_tiledrendering VALGRIND=memcheck'. The fix is to move these flags to the setup and teardown stages of cpp-unit. Change-Id: Ic4481305ca1a5cca14d70a4ebbc820a3fdeea9cc Reviewed-on: https://gerrit.libreoffice.org/80028 Tested-by: Jenkins Reviewed-by: Michael Meeks <michael.meeks@collabora.com>
Diffstat (limited to 'desktop')
-rw-r--r--desktop/qa/desktop_lib/test_desktop_lib.cxx90
1 files changed, 5 insertions, 85 deletions
diff --git a/desktop/qa/desktop_lib/test_desktop_lib.cxx b/desktop/qa/desktop_lib/test_desktop_lib.cxx
index eb3c713560ee..e16bc91aecb7 100644
--- a/desktop/qa/desktop_lib/test_desktop_lib.cxx
+++ b/desktop/qa/desktop_lib/test_desktop_lib.cxx
@@ -72,7 +72,10 @@ public:
virtual void setUp() override
{
+ comphelper::LibreOfficeKit::setActive(true);
+
UnoApiTest::setUp();
+
mxDesktop.set(frame::Desktop::create(comphelper::getComponentContext(getMultiServiceFactory())));
SfxApplication::GetOrCreate();
};
@@ -82,9 +85,9 @@ public:
if (m_pDocument)
m_pDocument->pClass->registerCallback(m_pDocument.get(), nullptr, nullptr);
closeDoc();
- comphelper::LibreOfficeKit::setActive(false);
-
UnoApiTest::tearDown();
+
+ comphelper::LibreOfficeKit::setActive(false);
};
LibLODocument_Impl* loadDoc(const char* pName, LibreOfficeKitDocumentType eType = LOK_DOCTYPE_TEXT);
@@ -349,7 +352,6 @@ void DesktopLOKTest::callbackImpl(int nType, const char* pPayload)
void DesktopLOKTest::testGetStyles()
{
- comphelper::LibreOfficeKit::setActive();
LibLODocument_Impl* pDocument = loadDoc("blank_text.odt");
boost::property_tree::ptree aTree;
char* pJSON = pDocument->m_pDocumentClass->getCommandValues(pDocument, ".uno:StyleApply");
@@ -384,7 +386,6 @@ void DesktopLOKTest::testGetStyles()
void DesktopLOKTest::testGetFonts()
{
- comphelper::LibreOfficeKit::setActive();
LibLODocument_Impl* pDocument = loadDoc("blank_presentation.odp");
boost::property_tree::ptree aTree;
char* pJSON = pDocument->m_pDocumentClass->getCommandValues(pDocument, ".uno:CharFontName");
@@ -405,7 +406,6 @@ void DesktopLOKTest::testGetFonts()
void DesktopLOKTest::testCreateView()
{
- comphelper::LibreOfficeKit::setActive();
LibLODocument_Impl* pDocument = loadDoc("blank_text.odt");
CPPUNIT_ASSERT_EQUAL(1, pDocument->m_pDocumentClass->getViewsCount(pDocument));
@@ -431,7 +431,6 @@ void DesktopLOKTest::testCreateView()
void DesktopLOKTest::testGetPartPageRectangles()
{
- comphelper::LibreOfficeKit::setActive();
// Test that we get as many page rectangles as expected: blank document is
// one page.
LibLODocument_Impl* pDocument = loadDoc("blank_text.odt");
@@ -454,7 +453,6 @@ void DesktopLOKTest::testGetPartPageRectangles()
void DesktopLOKTest::testGetFilterTypes()
{
- comphelper::LibreOfficeKit::setActive();
LibLibreOffice_Impl aOffice;
char* pJSON = aOffice.m_pOfficeClass->getFilterTypes(&aOffice);
@@ -469,8 +467,6 @@ void DesktopLOKTest::testGetFilterTypes()
void DesktopLOKTest::testSearchCalc()
{
- comphelper::LibreOfficeKit::setActive();
-
LibLibreOffice_Impl aOffice;
LibLODocument_Impl* pDocument = loadDoc("search.ods");
pDocument->pClass->initializeForRendering(pDocument, nullptr);
@@ -502,8 +498,6 @@ void DesktopLOKTest::testSearchCalc()
void DesktopLOKTest::testSearchAllNotificationsCalc()
{
- comphelper::LibreOfficeKit::setActive();
-
LibLibreOffice_Impl aOffice;
LibLODocument_Impl* pDocument = loadDoc("search.ods");
pDocument->pClass->initializeForRendering(pDocument, nullptr);
@@ -526,8 +520,6 @@ void DesktopLOKTest::testSearchAllNotificationsCalc()
void DesktopLOKTest::testPaintTile()
{
- comphelper::LibreOfficeKit::setActive();
-
LibLODocument_Impl* pDocument = loadDoc("blank_text.odt");
int nCanvasWidth = 100;
int nCanvasHeight = 300;
@@ -554,8 +546,6 @@ void DesktopLOKTest::testPaintTile()
void DesktopLOKTest::testSaveAs()
{
- comphelper::LibreOfficeKit::setActive();
-
LibLODocument_Impl* pDocument = loadDoc("blank_text.odt");
utl::TempFile aTempFile;
aTempFile.EnableKillingFile();
@@ -564,8 +554,6 @@ void DesktopLOKTest::testSaveAs()
void DesktopLOKTest::testSaveAsCalc()
{
- comphelper::LibreOfficeKit::setActive();
-
LibLODocument_Impl* pDocument = loadDoc("search.ods");
utl::TempFile aTempFile;
aTempFile.EnableKillingFile();
@@ -574,8 +562,6 @@ void DesktopLOKTest::testSaveAsCalc()
void DesktopLOKTest::testPasteWriter()
{
- comphelper::LibreOfficeKit::setActive();
-
LibLODocument_Impl* pDocument = loadDoc("blank_text.odt");
OString aText("hello");
@@ -613,8 +599,6 @@ void DesktopLOKTest::testPasteWriter()
void DesktopLOKTest::testPasteWriterJPEG()
{
- comphelper::LibreOfficeKit::setActive();
-
LibLODocument_Impl* pDocument = loadDoc("blank_text.odt");
OUString aFileURL;
@@ -648,8 +632,6 @@ void DesktopLOKTest::testPasteWriterJPEG()
void DesktopLOKTest::testUndoWriter()
{
// Load a Writer document and press a key.
- comphelper::LibreOfficeKit::setActive();
-
LibLODocument_Impl* pDocument = loadDoc("blank_text.odt");
pDocument->pClass->postKeyEvent(pDocument, LOK_KEYEVENT_KEYINPUT, 't', 0);
pDocument->pClass->postKeyEvent(pDocument, LOK_KEYEVENT_KEYUP, 't', 0);
@@ -696,8 +678,6 @@ void DesktopLOKTest::testRowColumnHeaders()
* "size" defines the bottom/right boundary of a row/column in twips (size between 0 and boundary)
* "text" has the header label in UTF-8
*/
- comphelper::LibreOfficeKit::setActive();
-
LibLODocument_Impl* pDocument = loadDoc("search.ods");
pDocument->pClass->initializeForRendering(pDocument, nullptr);
@@ -779,8 +759,6 @@ void DesktopLOKTest::testRowColumnHeaders()
void DesktopLOKTest::testHiddenRowHeaders()
{
- comphelper::LibreOfficeKit::setActive();
-
LibLODocument_Impl* pDocument = loadDoc("hidden-row.ods");
pDocument->pClass->initializeForRendering(pDocument, nullptr);
@@ -819,8 +797,6 @@ void DesktopLOKTest::testHiddenRowHeaders()
void DesktopLOKTest::testCellCursor()
{
- comphelper::LibreOfficeKit::setActive();
-
LibLODocument_Impl* pDocument = loadDoc("search.ods");
boost::property_tree::ptree aTree;
@@ -840,8 +816,6 @@ void DesktopLOKTest::testCellCursor()
void DesktopLOKTest::testCommandResult()
{
- comphelper::LibreOfficeKit::setActive();
-
LibLODocument_Impl* pDocument = loadDoc("blank_text.odt");
// the postUnoCommand() is supposed to be async, let's test it safely
@@ -876,8 +850,6 @@ void DesktopLOKTest::testCommandResult()
void DesktopLOKTest::testWriterComments()
{
- comphelper::LibreOfficeKit::setActive();
-
LibLODocument_Impl* pDocument = loadDoc("blank_text.odt");
pDocument->pClass->registerCallback(pDocument, &DesktopLOKTest::callback, this);
uno::Reference<awt::XReschedule> xToolkit = com::sun::star::awt::Toolkit::create(comphelper::getProcessComponentContext());
@@ -917,8 +889,6 @@ void DesktopLOKTest::testWriterComments()
void DesktopLOKTest::testTrackChanges()
{
- comphelper::LibreOfficeKit::setActive();
-
// Load a document and create two views.
LibLibreOffice_Impl aOffice;
LibLODocument_Impl* pDocument = loadDoc("blank_text.odt");
@@ -939,8 +909,6 @@ void DesktopLOKTest::testTrackChanges()
void DesktopLOKTest::testSheetOperations()
{
- comphelper::LibreOfficeKit::setActive();
-
LibLODocument_Impl* pDocument = loadDoc("sheets.ods");
// insert the last sheet
@@ -971,8 +939,6 @@ void DesktopLOKTest::testSheetOperations()
void DesktopLOKTest::testSheetSelections()
{
- comphelper::LibreOfficeKit::setActive();
-
LibLODocument_Impl* pDocument = loadDoc("sheets.ods", LOK_DOCTYPE_SPREADSHEET);
pDocument->pClass->initializeForRendering(pDocument, nullptr);
pDocument->pClass->registerCallback(pDocument, &DesktopLOKTest::callback, this);
@@ -1152,8 +1118,6 @@ namespace {
void DesktopLOKTest::testContextMenuCalc()
{
- comphelper::LibreOfficeKit::setActive();
-
LibLODocument_Impl* pDocument = loadDoc("sheet_with_image.ods", LOK_DOCTYPE_SPREADSHEET);
pDocument->pClass->initializeForRendering(pDocument, nullptr);
pDocument->pClass->registerCallback(pDocument, &DesktopLOKTest::callback, this);
@@ -1262,8 +1226,6 @@ void DesktopLOKTest::testContextMenuCalc()
void DesktopLOKTest::testContextMenuWriter()
{
- comphelper::LibreOfficeKit::setActive();
-
LibLODocument_Impl* pDocument = loadDoc("blank_text.odt");
pDocument->pClass->initializeForRendering(pDocument, nullptr);
pDocument->pClass->registerCallback(pDocument, &DesktopLOKTest::callback, this);
@@ -1317,8 +1279,6 @@ void DesktopLOKTest::testContextMenuWriter()
void DesktopLOKTest::testContextMenuImpress()
{
- comphelper::LibreOfficeKit::setActive();
-
LibLODocument_Impl* pDocument = loadDoc("blank_presentation.odp", LOK_DOCTYPE_PRESENTATION);
pDocument->pClass->initializeForRendering(pDocument, nullptr);
pDocument->pClass->registerCallback(pDocument, &DesktopLOKTest::callback, this);
@@ -1449,8 +1409,6 @@ static void callbackCompressionTest(const int type, const char* payload, void* d
void DesktopLOKTest::testNotificationCompression()
{
- comphelper::LibreOfficeKit::setActive();
-
LibLODocument_Impl* pDocument = loadDoc("blank_text.odt");
std::vector<std::tuple<int, std::string>> notifs;
std::unique_ptr<CallbackFlushHandler> handler(new CallbackFlushHandler(pDocument, callbackCompressionTest, &notifs));
@@ -1537,8 +1495,6 @@ void DesktopLOKTest::testNotificationCompression()
void DesktopLOKTest::testTileInvalidationCompression()
{
- comphelper::LibreOfficeKit::setActive();
-
LibLODocument_Impl* pDocument = loadDoc("blank_text.odt");
comphelper::LibreOfficeKit::setPartInInvalidation(true);
@@ -1674,8 +1630,6 @@ void DesktopLOKTest::testTileInvalidationCompression()
void DesktopLOKTest::testPartInInvalidation()
{
- comphelper::LibreOfficeKit::setActive();
-
LibLODocument_Impl* pDocument = loadDoc("blank_text.odt");
// No part in invalidation: merge.
{
@@ -1747,8 +1701,6 @@ void DesktopLOKTest::testPartInInvalidation()
void DesktopLOKTest::testRedlineWriter()
{
- comphelper::LibreOfficeKit::setActive();
-
// Load a Writer document, enable change recording and press a key.
LibLODocument_Impl* pDocument = loadDoc("blank_text.odt");
uno::Reference<beans::XPropertySet> xPropertySet(mxComponent, uno::UNO_QUERY);
@@ -1777,8 +1729,6 @@ void DesktopLOKTest::testRedlineWriter()
void DesktopLOKTest::testRedlineCalc()
{
// Load a Writer document, enable change recording and press a key.
- comphelper::LibreOfficeKit::setActive();
-
LibLODocument_Impl* pDocument = loadDoc("sheets.ods");
uno::Reference<beans::XPropertySet> xPropertySet(mxComponent, uno::UNO_QUERY);
xPropertySet->setPropertyValue("RecordChanges", uno::makeAny(true));
@@ -1876,7 +1826,6 @@ public:
void DesktopLOKTest::testPaintPartTile()
{
// Load an impress doc of 2 slides.
- comphelper::LibreOfficeKit::setActive();
// ViewCallback aView1;
// ViewCallback aView2;
@@ -1919,8 +1868,6 @@ void DesktopLOKTest::testPaintPartTile()
void DesktopLOKTest::testWriterCommentInsertCursor()
{
// Load a document and type a character into the body text of the second view.
- comphelper::LibreOfficeKit::setActive();
-
LibLODocument_Impl* pDocument = loadDoc("blank_text.odt");
pDocument->m_pDocumentClass->initializeForRendering(pDocument, "{}");
ViewCallback aView1(pDocument);
@@ -1955,8 +1902,6 @@ void DesktopLOKTest::testWriterCommentInsertCursor()
#if HAVE_MORE_FONTS
void DesktopLOKTest::testGetFontSubset()
{
- comphelper::LibreOfficeKit::setActive();
-
LibLODocument_Impl* pDocument = loadDoc("blank_text.odt");
OUString aFontName = rtl::Uri::encode(
OUString("Liberation Sans"),
@@ -1979,7 +1924,6 @@ void DesktopLOKTest::testGetFontSubset()
void DesktopLOKTest::testCommentsWriter()
{
- comphelper::LibreOfficeKit::setActive();
// Disable tiled rendering for comments
comphelper::LibreOfficeKit::setTiledAnnotations(false);
@@ -2032,7 +1976,6 @@ void DesktopLOKTest::testCommentsWriter()
void DesktopLOKTest::testCommentsCalc()
{
- comphelper::LibreOfficeKit::setActive();
// Disable tiled rendering for comments
comphelper::LibreOfficeKit::setTiledAnnotations(false);
@@ -2083,7 +2026,6 @@ void DesktopLOKTest::testCommentsCalc()
void DesktopLOKTest::testCommentsImpress()
{
- comphelper::LibreOfficeKit::setActive();
// Disable tiled rendering for comments
comphelper::LibreOfficeKit::setTiledAnnotations(false);
@@ -2139,7 +2081,6 @@ void DesktopLOKTest::testCommentsImpress()
void DesktopLOKTest::testCommentsCallbacksWriter()
{
- comphelper::LibreOfficeKit::setActive();
// Comments callback are emitted only if tiled annotations are off
comphelper::LibreOfficeKit::setTiledAnnotations(false);
LibLODocument_Impl* pDocument = loadDoc("comments.odt");
@@ -2223,8 +2164,6 @@ void DesktopLOKTest::testCommentsCallbacksWriter()
void DesktopLOKTest::testRunMacro()
{
- comphelper::LibreOfficeKit::setActive();
-
LibLibreOffice_Impl aOffice;
bool bGoodMacro, bNonExistentMacro;
@@ -2238,8 +2177,6 @@ void DesktopLOKTest::testRunMacro()
void DesktopLOKTest::testExtractParameter()
{
- comphelper::LibreOfficeKit::setActive();
-
OUString aOptions("Language=de-DE");
OUString aValue = extractParameter(aOptions, "Language");
CPPUNIT_ASSERT_EQUAL(OUString("de-DE"), aValue);
@@ -2278,7 +2215,6 @@ void DesktopLOKTest::readFileIntoByteVector(OUString const & sFilename, std::vec
void DesktopLOKTest::testGetSignatureState_Signed()
{
- comphelper::LibreOfficeKit::setActive();
LibLODocument_Impl* pDocument = loadDoc("signed.odt");
Scheduler::ProcessEventsToIdle();
pDocument->m_pDocumentClass->initializeForRendering(pDocument, "{}");
@@ -2306,7 +2242,6 @@ void DesktopLOKTest::testGetSignatureState_Signed()
void DesktopLOKTest::testGetSignatureState_NonSigned()
{
- comphelper::LibreOfficeKit::setActive();
LibLODocument_Impl* pDocument = loadDoc("blank_text.odt");
Scheduler::ProcessEventsToIdle();
pDocument->m_pDocumentClass->initializeForRendering(pDocument, "{}");
@@ -2316,8 +2251,6 @@ void DesktopLOKTest::testGetSignatureState_NonSigned()
void DesktopLOKTest::testInsertCertificate_DER_ODT()
{
- comphelper::LibreOfficeKit::setActive();
-
// Load the document, save it into a temp file and load that file again
LibLODocument_Impl* pDocument = loadDoc("blank_text.odt");
utl::TempFile aTempFile;
@@ -2369,8 +2302,6 @@ void DesktopLOKTest::testInsertCertificate_DER_ODT()
void DesktopLOKTest::testInsertCertificate_PEM_ODT()
{
- comphelper::LibreOfficeKit::setActive();
-
// Load the document, save it into a temp file and load that file again
LibLODocument_Impl* pDocument = loadDoc("blank_text.odt");
utl::TempFile aTempFile;
@@ -2429,8 +2360,6 @@ void DesktopLOKTest::testInsertCertificate_PEM_ODT()
void DesktopLOKTest::testInsertCertificate_PEM_DOCX()
{
- comphelper::LibreOfficeKit::setActive();
-
// Load the document, save it into a temp file and load that file again
LibLODocument_Impl* pDocument = loadDoc("blank_text.docx");
utl::TempFile aTempFile;
@@ -2489,8 +2418,6 @@ void DesktopLOKTest::testInsertCertificate_PEM_DOCX()
void DesktopLOKTest::testSignDocument_PEM_PDF()
{
- comphelper::LibreOfficeKit::setActive();
-
// Load the document, save it into a temp file and load that file again
LibLODocument_Impl* pDocument = loadDoc("blank_text.odt");
utl::TempFile aTempFile;
@@ -2547,8 +2474,6 @@ void DesktopLOKTest::testSignDocument_PEM_PDF()
void DesktopLOKTest::testTextSelectionHandles()
{
- comphelper::LibreOfficeKit::setActive();
-
LibLODocument_Impl* pDocument = loadDoc("blank_text.odt");
pDocument->pClass->registerCallback(pDocument, &DesktopLOKTest::callback, this);
@@ -2588,7 +2513,6 @@ void DesktopLOKTest::testTextSelectionHandles()
void DesktopLOKTest::testDialogPaste()
{
- comphelper::LibreOfficeKit::setActive();
LibLODocument_Impl* pDocument = loadDoc("blank_text.odt");
pDocument->pClass->postUnoCommand(pDocument, ".uno:HyperlinkDialog", nullptr, false);
Scheduler::ProcessEventsToIdle();
@@ -2616,7 +2540,6 @@ void DesktopLOKTest::testDialogPaste()
void DesktopLOKTest::testShowHideDialog()
{
- comphelper::LibreOfficeKit::setActive();
LibLODocument_Impl* pDocument = loadDoc("blank_text.odt");
pDocument->m_pDocumentClass->initializeForRendering(pDocument, "{}");
@@ -2641,9 +2564,6 @@ void DesktopLOKTest::testShowHideDialog()
void DesktopLOKTest::testComplexSelection()
{
- // needed for SwTransferable to cope with the selection.
- comphelper::LibreOfficeKit::setActive();
-
// Start with a blank text file and add contents.
LibLODocument_Impl* pDocument = loadDoc("blank_text.odt");
static const OString aText("hello world");