diff options
author | Ashod Nakashian <ashod.nakashian@collabora.co.uk> | 2018-11-11 16:54:59 -0500 |
---|---|---|
committer | Michael Meeks <michael.meeks@collabora.com> | 2019-10-02 16:50:13 +0200 |
commit | 13fb343e3c48439c6cd7365f9a69ba2261885beb (patch) | |
tree | ccf7033fa476b51aa1214585f1ff92045424a345 /sd | |
parent | 79b27379c1cf109faeb80bc51fdd1c44df4fbfee (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 'sd')
-rw-r--r-- | sd/qa/unit/tiledrendering/tiledrendering.cxx | 59 |
1 files changed, 2 insertions, 57 deletions
diff --git a/sd/qa/unit/tiledrendering/tiledrendering.cxx b/sd/qa/unit/tiledrendering/tiledrendering.cxx index 9422355835b2..cfcf3241e2b9 100644 --- a/sd/qa/unit/tiledrendering/tiledrendering.cxx +++ b/sd/qa/unit/tiledrendering/tiledrendering.cxx @@ -212,6 +212,7 @@ void SdTiledRenderingTest::setUp() // prevent showing warning message box setenv("OOX_NO_SMARTART_WARNING", "1", 1); + comphelper::LibreOfficeKit::setActive(true); mxDesktop.set(css::frame::Desktop::create(comphelper::getComponentContext(getMultiServiceFactory()))); } @@ -225,6 +226,7 @@ void SdTiledRenderingTest::tearDown() xmlBufferFree(m_pXmlBuffer); comphelper::LibreOfficeKit::setActive(false); + test::BootstrapFixture::tearDown(); } @@ -368,7 +370,6 @@ void SdTiledRenderingTest::testCreateView() void SdTiledRenderingTest::testRegisterCallback() { - comphelper::LibreOfficeKit::setActive(); SdXImpressDocument* pXImpressDocument = createDoc("dummy.odp"); sd::ViewShell* pViewShell = pXImpressDocument->GetDocShell()->GetViewShell(); pViewShell->GetViewShellBase().registerLibreOfficeKitViewCallback(&SdTiledRenderingTest::callback, this); @@ -388,7 +389,6 @@ void SdTiledRenderingTest::testRegisterCallback() void SdTiledRenderingTest::testPostKeyEvent() { - comphelper::LibreOfficeKit::setActive(); SdXImpressDocument* pXImpressDocument = createDoc("dummy.odp"); sd::ViewShell* pViewShell = pXImpressDocument->GetDocShell()->GetViewShell(); SdPage* pActualPage = pViewShell->GetActualPage(); @@ -417,7 +417,6 @@ void SdTiledRenderingTest::testPostKeyEvent() void SdTiledRenderingTest::testPostMouseEvent() { - comphelper::LibreOfficeKit::setActive(); SdXImpressDocument* pXImpressDocument = createDoc("dummy.odp"); sd::ViewShell* pViewShell = pXImpressDocument->GetDocShell()->GetViewShell(); SdPage* pActualPage = pViewShell->GetActualPage(); @@ -451,7 +450,6 @@ void SdTiledRenderingTest::testPostMouseEvent() void SdTiledRenderingTest::testSetTextSelection() { - comphelper::LibreOfficeKit::setActive(); SdXImpressDocument* pXImpressDocument = createDoc("dummy.odp"); uno::Reference<container::XIndexAccess> xDrawPage(pXImpressDocument->getDrawPages()->getByIndex(0), uno::UNO_QUERY); uno::Reference<text::XTextRange> xShape(xDrawPage->getByIndex(0), uno::UNO_QUERY); @@ -480,7 +478,6 @@ void SdTiledRenderingTest::testSetTextSelection() void SdTiledRenderingTest::testGetTextSelection() { - comphelper::LibreOfficeKit::setActive(); SdXImpressDocument* pXImpressDocument = createDoc("dummy.odp"); uno::Reference<container::XIndexAccess> xDrawPage(pXImpressDocument->getDrawPages()->getByIndex(0), uno::UNO_QUERY); uno::Reference<text::XTextRange> xShape(xDrawPage->getByIndex(0), uno::UNO_QUERY); @@ -504,7 +501,6 @@ void SdTiledRenderingTest::testGetTextSelection() void SdTiledRenderingTest::testSetGraphicSelection() { - comphelper::LibreOfficeKit::setActive(); SdXImpressDocument* pXImpressDocument = createDoc("shape.odp"); sd::ViewShell* pViewShell = pXImpressDocument->GetDocShell()->GetViewShell(); SdPage* pPage = pViewShell->GetActualPage(); @@ -540,7 +536,6 @@ void SdTiledRenderingTest::testSetGraphicSelection() void SdTiledRenderingTest::testUndoShells() { - comphelper::LibreOfficeKit::setActive(); // Load a document and set the page size. SdXImpressDocument* pXImpressDocument = createDoc("shape.odp"); uno::Sequence<beans::PropertyValue> aPropertyValues(comphelper::InitPropertySequence( @@ -562,7 +557,6 @@ void SdTiledRenderingTest::testUndoShells() void SdTiledRenderingTest::testResetSelection() { - comphelper::LibreOfficeKit::setActive(); SdXImpressDocument* pXImpressDocument = createDoc("dummy.odp"); uno::Reference<container::XIndexAccess> xDrawPage(pXImpressDocument->getDrawPages()->getByIndex(0), uno::UNO_QUERY); uno::Reference<text::XTextRange> xShape(xDrawPage->getByIndex(0), uno::UNO_QUERY); @@ -598,7 +592,6 @@ static void lcl_search(const OUString& rKey, bool bFindAll = false) void SdTiledRenderingTest::testSearch() { - comphelper::LibreOfficeKit::setActive(); SdXImpressDocument* pXImpressDocument = createDoc("dummy.odp"); sd::ViewShell* pViewShell = pXImpressDocument->GetDocShell()->GetViewShell(); pViewShell->GetViewShellBase().registerLibreOfficeKitViewCallback(&SdTiledRenderingTest::callback, this); @@ -632,7 +625,6 @@ void SdTiledRenderingTest::testSearch() void SdTiledRenderingTest::testSearchAll() { - comphelper::LibreOfficeKit::setActive(); SdXImpressDocument* pXImpressDocument = createDoc("search-all.odp"); sd::ViewShell* pViewShell = pXImpressDocument->GetDocShell()->GetViewShell(); pViewShell->GetViewShellBase().registerLibreOfficeKitViewCallback(&SdTiledRenderingTest::callback, this); @@ -651,7 +643,6 @@ void SdTiledRenderingTest::testSearchAll() void SdTiledRenderingTest::testSearchAllSelections() { - comphelper::LibreOfficeKit::setActive(); SdXImpressDocument* pXImpressDocument = createDoc("search-all.odp"); sd::ViewShell* pViewShell = pXImpressDocument->GetDocShell()->GetViewShell(); pViewShell->GetViewShellBase().registerLibreOfficeKitViewCallback(&SdTiledRenderingTest::callback, this); @@ -665,7 +656,6 @@ void SdTiledRenderingTest::testSearchAllSelections() void SdTiledRenderingTest::testSearchAllNotifications() { - comphelper::LibreOfficeKit::setActive(); SdXImpressDocument* pXImpressDocument = createDoc("search-all.odp"); sd::ViewShell* pViewShell = pXImpressDocument->GetDocShell()->GetViewShell(); pViewShell->GetViewShellBase().registerLibreOfficeKitViewCallback(&SdTiledRenderingTest::callback, this); @@ -679,7 +669,6 @@ void SdTiledRenderingTest::testSearchAllNotifications() void SdTiledRenderingTest::testSearchAllFollowedBySearch() { - comphelper::LibreOfficeKit::setActive(); SdXImpressDocument* pXImpressDocument = createDoc("search-all.odp"); sd::ViewShell* pViewShell = pXImpressDocument->GetDocShell()->GetViewShell(); pViewShell->GetViewShellBase().registerLibreOfficeKitViewCallback(&SdTiledRenderingTest::callback, this); @@ -694,7 +683,6 @@ void SdTiledRenderingTest::testSearchAllFollowedBySearch() void SdTiledRenderingTest::testDontSearchInMasterPages() { - comphelper::LibreOfficeKit::setActive(); SdXImpressDocument* pXImpressDocument = createDoc("dummy.odp"); sd::ViewShell* pViewShell = pXImpressDocument->GetDocShell()->GetViewShell(); pViewShell->GetViewShellBase().registerLibreOfficeKitViewCallback(&SdTiledRenderingTest::callback, this); @@ -726,7 +714,6 @@ std::vector<OUString> getCurrentParts(SdXImpressDocument* pDocument) void SdTiledRenderingTest::testInsertDeletePage() { - comphelper::LibreOfficeKit::setActive(); SdXImpressDocument* pXImpressDocument = createDoc("insert-delete.odp"); sd::ViewShell* pViewShell = pXImpressDocument->GetDocShell()->GetViewShell(); pViewShell->GetViewShellBase().registerLibreOfficeKitViewCallback(&SdTiledRenderingTest::callback, this); @@ -821,7 +808,6 @@ void SdTiledRenderingTest::testInsertDeletePage() void SdTiledRenderingTest::testInsertTable() { - comphelper::LibreOfficeKit::setActive(); SdXImpressDocument* pXImpressDocument = createDoc("dummy.odp"); uno::Sequence<beans::PropertyValue> aArgs(comphelper::InitPropertySequence( @@ -848,7 +834,6 @@ void SdTiledRenderingTest::testInsertTable() void SdTiledRenderingTest::testPartHash() { - comphelper::LibreOfficeKit::setActive(); SdXImpressDocument* pDoc = createDoc("dummy.odp"); int nParts = pDoc->getParts(); @@ -864,7 +849,6 @@ void SdTiledRenderingTest::testPartHash() void SdTiledRenderingTest::testResizeTable() { // Load the document. - comphelper::LibreOfficeKit::setActive(); SdXImpressDocument* pXImpressDocument = createDoc("table.odp"); sd::ViewShell* pViewShell = pXImpressDocument->GetDocShell()->GetViewShell(); SdPage* pActualPage = pViewShell->GetActualPage(); @@ -911,7 +895,6 @@ void SdTiledRenderingTest::testResizeTable() void SdTiledRenderingTest::testResizeTableColumn() { // Load the document. - comphelper::LibreOfficeKit::setActive(); SdXImpressDocument* pXImpressDocument = createDoc("table-column.odp"); sd::ViewShell* pViewShell = pXImpressDocument->GetDocShell()->GetViewShell(); SdPage* pActualPage = pViewShell->GetActualPage(); @@ -1091,8 +1074,6 @@ public: void SdTiledRenderingTest::testViewCursors() { - comphelper::LibreOfficeKit::setActive(); - // Create two views. SdXImpressDocument* pXImpressDocument = createDoc("shape.odp"); ViewCallback aView1; @@ -1115,8 +1096,6 @@ void SdTiledRenderingTest::testViewCursors() void SdTiledRenderingTest::testViewCursorParts() { - comphelper::LibreOfficeKit::setActive(); - // Create two views. SdXImpressDocument* pXImpressDocument = createDoc("shape.odp"); ViewCallback aView1; @@ -1150,8 +1129,6 @@ void SdTiledRenderingTest::testViewCursorParts() void SdTiledRenderingTest::testCursorViews() { - comphelper::LibreOfficeKit::setActive(); - // Create the first view. SdXImpressDocument* pXImpressDocument = createDoc("title-shape.odp"); int nView1 = SfxLokHelper::getView(); @@ -1193,8 +1170,6 @@ void SdTiledRenderingTest::testCursorViews() void SdTiledRenderingTest::testViewLock() { - comphelper::LibreOfficeKit::setActive(); - // Load a document that has a shape and create two views. SdXImpressDocument* pXImpressDocument = createDoc("shape.odp"); ViewCallback aView1; @@ -1219,8 +1194,6 @@ void SdTiledRenderingTest::testViewLock() void SdTiledRenderingTest::testUndoLimiting() { - comphelper::LibreOfficeKit::setActive(); - // Create the first view. SdXImpressDocument* pXImpressDocument = createDoc("title-shape.odp"); sd::ViewShell* pViewShell1 = pXImpressDocument->GetDocShell()->GetViewShell(); @@ -1262,8 +1235,6 @@ void SdTiledRenderingTest::testUndoLimiting() void SdTiledRenderingTest::testCreateViewGraphicSelection() { - comphelper::LibreOfficeKit::setActive(); - // Load a document and register a callback. SdXImpressDocument* pXImpressDocument = createDoc("shape.odp"); ViewCallback aView1; @@ -1295,8 +1266,6 @@ void SdTiledRenderingTest::testCreateViewGraphicSelection() void SdTiledRenderingTest::testCreateViewTextCursor() { - comphelper::LibreOfficeKit::setActive(); - // Load a document and register a callback. SdXImpressDocument* pXImpressDocument = createDoc("title-shape.odp"); ViewCallback aView1; @@ -1346,7 +1315,6 @@ void SdTiledRenderingTest::testCreateViewTextCursor() void SdTiledRenderingTest::testTdf102223() { // Load the document. - comphelper::LibreOfficeKit::setActive(); SdXImpressDocument* pXImpressDocument = createDoc("tdf102223.odp"); sd::ViewShell* pViewShell = pXImpressDocument->GetDocShell()->GetViewShell(); SdPage* pActualPage = pViewShell->GetActualPage(); @@ -1387,7 +1355,6 @@ void SdTiledRenderingTest::testTdf102223() void SdTiledRenderingTest::testPostKeyEventInvalidation() { // Load a document and begin text edit on the first slide. - comphelper::LibreOfficeKit::setActive(); SdXImpressDocument* pXImpressDocument = createDoc("2slides.odp"); CPPUNIT_ASSERT_EQUAL(0, pXImpressDocument->getPart()); ViewCallback aView1; @@ -1430,7 +1397,6 @@ void SdTiledRenderingTest::testPostKeyEventInvalidation() void SdTiledRenderingTest::testTdf103083() { // Load the document. - comphelper::LibreOfficeKit::setActive(); SdXImpressDocument* pXImpressDocument = createDoc("tdf103083.fodp"); sd::ViewShell* pViewShell = pXImpressDocument->GetDocShell()->GetViewShell(); SdPage* pActualPage = pViewShell->GetActualPage(); @@ -1496,7 +1462,6 @@ void SdTiledRenderingTest::testTdf103083() void SdTiledRenderingTest::testTdf104405() { // Load the document. - comphelper::LibreOfficeKit::setActive(); SdXImpressDocument* pXImpressDocument = createDoc("tdf104405.fodp"); sd::ViewShell* pViewShell = pXImpressDocument->GetDocShell()->GetViewShell(); SdPage* pActualPage = pViewShell->GetActualPage(); @@ -1548,7 +1513,6 @@ void SdTiledRenderingTest::testTdf104405() void SdTiledRenderingTest::testTdf81754() { - comphelper::LibreOfficeKit::setActive(); SdXImpressDocument* pXImpressDocument = createDoc("tdf81754.pptx"); sd::ViewShell* pViewShell = pXImpressDocument->GetDocShell()->GetViewShell(); SdPage* pActualPage = pViewShell->GetActualPage(); @@ -1583,7 +1547,6 @@ void SdTiledRenderingTest::testTdf81754() void SdTiledRenderingTest::testTdf105502() { // Load the document. - comphelper::LibreOfficeKit::setActive(); SdXImpressDocument* pXImpressDocument = createDoc("tdf105502.odp"); sd::ViewShell* pViewShell = pXImpressDocument->GetDocShell()->GetViewShell(); sd::Window* pWindow = pViewShell->GetActiveWindow(); @@ -1639,7 +1602,6 @@ void SdTiledRenderingTest::testTdf105502() void SdTiledRenderingTest::testCommentCallbacks() { // Load the document. - comphelper::LibreOfficeKit::setActive(); // Set the tiled annotations off comphelper::LibreOfficeKit::setTiledAnnotations(false); @@ -1749,7 +1711,6 @@ void SdTiledRenderingTest::testCommentCallbacks() void SdTiledRenderingTest::testMultiViewInsertDeletePage() { // Load the document. - comphelper::LibreOfficeKit::setActive(); SdXImpressDocument* pXImpressDocument = createDoc("dummy.odp"); ViewCallback aView1; int nView1 = SfxLokHelper::getView(); @@ -1790,7 +1751,6 @@ void SdTiledRenderingTest::testMultiViewInsertDeletePage() void SdTiledRenderingTest::testDisableUndoRepair() { // Load the document. - comphelper::LibreOfficeKit::setActive(); SdXImpressDocument* pXImpressDocument = createDoc("dummy.odp"); SfxViewShell* pView1 = SfxViewShell::Current(); int nView1 = SfxLokHelper::getView(); @@ -1844,8 +1804,6 @@ void SdTiledRenderingTest::testDisableUndoRepair() void SdTiledRenderingTest::testDocumentRepair() { - comphelper::LibreOfficeKit::setActive(); - // Create two views. SdXImpressDocument* pXImpressDocument = createDoc("dummy.odp"); CPPUNIT_ASSERT(pXImpressDocument); @@ -1896,7 +1854,6 @@ void SdTiledRenderingTest::testDocumentRepair() void SdTiledRenderingTest::testLanguageStatus() { // Load the document. - comphelper::LibreOfficeKit::setActive(); createDoc("dummy.odp"); SfxViewShell* pView1 = SfxViewShell::Current(); SfxLokHelper::createView(); @@ -1918,7 +1875,6 @@ void SdTiledRenderingTest::testLanguageStatus() void SdTiledRenderingTest::testLanguageAllText() { // Load the document, which has a single shape, with Hungarian text. - comphelper::LibreOfficeKit::setActive(); createDoc("language-all-text.odp"); // Set the language to English for all text. @@ -1945,8 +1901,6 @@ void SdTiledRenderingTest::testLanguageAllText() void SdTiledRenderingTest::testDefaultView() { // Load the document with notes view. - comphelper::LibreOfficeKit::setActive(); - SdXImpressDocument* pXImpressDocument = createDoc("notes-view.odp"); sd::ViewShell* pView = pXImpressDocument->GetDocShell()->GetViewShell(); { @@ -1966,8 +1920,6 @@ void SdTiledRenderingTest::testDefaultView() void SdTiledRenderingTest::testIMESupport() { // Load the document with notes view. - comphelper::LibreOfficeKit::setActive(); - SdXImpressDocument* pXImpressDocument = createDoc("dummy.odp"); VclPtr<vcl::Window> pDocWindow = pXImpressDocument->getDocWindow(); sd::ViewShell* pViewShell = pXImpressDocument->GetDocShell()->GetViewShell(); @@ -2005,7 +1957,6 @@ void SdTiledRenderingTest::testIMESupport() void SdTiledRenderingTest::testTdf115783() { // Load the document. - comphelper::LibreOfficeKit::setActive(); SdXImpressDocument* pXImpressDocument = createDoc("tdf115783.fodp"); sd::ViewShell* pViewShell = pXImpressDocument->GetDocShell()->GetViewShell(); SdPage* pActualPage = pViewShell->GetActualPage(); @@ -2072,7 +2023,6 @@ void SdTiledRenderingTest::testTdf115783() void SdTiledRenderingTest::testPasteTextOnSlide() { // Load the document. - comphelper::LibreOfficeKit::setActive(); SdXImpressDocument* pXImpressDocument = createDoc("paste_text_onslide.odp"); CPPUNIT_ASSERT(pXImpressDocument); @@ -2146,7 +2096,6 @@ void SdTiledRenderingTest::testPasteTextOnSlide() void SdTiledRenderingTest::testTdf115873() { - comphelper::LibreOfficeKit::setActive(); // Initialize the navigator. SdXImpressDocument* pXImpressDocument = createDoc("tdf115873.fodp"); SfxViewShell* pViewShell = SfxViewShell::Current(); @@ -2182,7 +2131,6 @@ void SdTiledRenderingTest::testTdf115873() void SdTiledRenderingTest::testTdf115873Group() { - comphelper::LibreOfficeKit::setActive(); // Initialize the navigator. SdXImpressDocument* pXImpressDocument = createDoc("tdf115873-group.fodp"); SfxViewShell* pViewShell = SfxViewShell::Current(); @@ -2199,7 +2147,6 @@ void SdTiledRenderingTest::testTdf115873Group() void SdTiledRenderingTest::testCutSelectionChange() { // Load the document. - comphelper::LibreOfficeKit::setActive(); SdXImpressDocument* pXImpressDocument = createDoc("cut_selection_change.odp"); CPPUNIT_ASSERT(pXImpressDocument); @@ -2238,7 +2185,6 @@ void SdTiledRenderingTest::testCutSelectionChange() void SdTiledRenderingTest::testRegenerateDiagram() { // Load the document. - comphelper::LibreOfficeKit::setActive(); SdXImpressDocument* pXImpressDocument = createDoc("regenerate-diagram.pptx"); CPPUNIT_ASSERT(pXImpressDocument); @@ -2289,7 +2235,6 @@ void SdTiledRenderingTest::testRegenerateDiagram() void SdTiledRenderingTest::testInsertDeletePageInvalidation() { // Load the document. - comphelper::LibreOfficeKit::setActive(); SdXImpressDocument* pXImpressDocument = createDoc("dummy.odp"); ViewCallback aView1; CPPUNIT_ASSERT_EQUAL(8, pXImpressDocument->getParts()); |