diff options
author | Miklos Vajna <vmiklos@collabora.com> | 2019-05-10 16:41:11 +0200 |
---|---|---|
committer | Miklos Vajna <vmiklos@collabora.com> | 2019-05-10 18:04:42 +0200 |
commit | c1486533818de626378ec67afa49845da164d00c (patch) | |
tree | e8964f6c2531a5096240e6855fc19a103fe654d3 /sw | |
parent | 758c44f69f0a0ed4a501695de4f065824325e750 (diff) |
CppunitTest_sw_tiledrendering: close the document while LOK is still active
This is the same type of problem that was fixed for
CppunitTest_desktop_lib in commit
da17ccaec39f50de68c3fdd431bc66a2bec04127 (CppunitTest_desktop_lib: close
the document while LOK is still active, 2019-05-09).
Change-Id: I2fe050bf40d68dafa0334f4149e54958c492122d
Reviewed-on: https://gerrit.libreoffice.org/72126
Reviewed-by: Miklos Vajna <vmiklos@collabora.com>
Tested-by: Jenkins
Diffstat (limited to 'sw')
-rw-r--r-- | sw/qa/extras/tiledrendering/tiledrendering.cxx | 273 |
1 files changed, 146 insertions, 127 deletions
diff --git a/sw/qa/extras/tiledrendering/tiledrendering.cxx b/sw/qa/extras/tiledrendering/tiledrendering.cxx index 973d751e83d3..27e84046050c 100644 --- a/sw/qa/extras/tiledrendering/tiledrendering.cxx +++ b/sw/qa/extras/tiledrendering/tiledrendering.cxx @@ -57,6 +57,7 @@ class SwTiledRenderingTest : public SwModelTestBase { public: SwTiledRenderingTest(); + virtual void tearDown() override; void testRegisterCallback(); void testPostKeyEvent(); void testPostMouseEvent(); @@ -200,6 +201,27 @@ SwTiledRenderingTest::SwTiledRenderingTest() { } +void SwTiledRenderingTest::tearDown() +{ + if (mxComponent.is()) + { + SwXTextDocument* pTextDocument = dynamic_cast<SwXTextDocument*>(mxComponent.get()); + if (pTextDocument) + { + SwWrtShell* pWrtShell = pTextDocument->GetDocShell()->GetWrtShell(); + if (pWrtShell) + { + pWrtShell->GetSfxViewShell()->registerLibreOfficeKitViewCallback(nullptr, nullptr); + } + } + mxComponent->dispose(); + mxComponent.clear(); + } + comphelper::LibreOfficeKit::setActive(false); + + test::BootstrapFixture::tearDown(); +} + SwXTextDocument* SwTiledRenderingTest::createDoc(const char* pName) { if (!pName) @@ -313,7 +335,6 @@ void SwTiledRenderingTest::testRegisterCallback() CPPUNIT_ASSERT(!m_aInvalidation.IsEmpty()); tools::Rectangle aTopLeft(0, 0, 256*15, 256*15); // 1 px = 15 twips, assuming 96 DPI. CPPUNIT_ASSERT(m_aInvalidation.IsOver(aTopLeft)); - comphelper::LibreOfficeKit::setActive(false); } void SwTiledRenderingTest::testPostKeyEvent() @@ -349,7 +370,6 @@ void SwTiledRenderingTest::testPostMouseEvent() Scheduler::ProcessEventsToIdle(); // The new cursor position must be before the first word. CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(0), pShellCursor->GetPoint()->nContent.GetIndex()); - comphelper::LibreOfficeKit::setActive(false); } void SwTiledRenderingTest::testSetTextSelection() @@ -408,8 +428,6 @@ void SwTiledRenderingTest::testGetTextSelection() ESelection aWordSelection(0, 0, 0, 5); rEditView.SetSelection(aWordSelection); CPPUNIT_ASSERT_EQUAL(OString("Shape"), pXTextDocument->getTextSelection("text/plain;charset=utf-8", aUsedFormat)); - - comphelper::LibreOfficeKit::setActive(false); } void SwTiledRenderingTest::testSetGraphicSelection() @@ -481,8 +499,6 @@ void SwTiledRenderingTest::testInsertShape() // check that it is in the foreground layer CPPUNIT_ASSERT_EQUAL(rDrawModelAccess.GetHeavenId().get(), pObject->GetLayer().get()); - - comphelper::LibreOfficeKit::setActive(false); } static void lcl_search(bool bBackward) @@ -535,8 +551,6 @@ void SwTiledRenderingTest::testSearch() CPPUNIT_ASSERT(!pWrtShell->GetDrawView()->GetTextEditObject()); nActual = pWrtShell->getShellCursor(false)->Start()->nNode.GetNode().GetIndex(); CPPUNIT_ASSERT_EQUAL(nNode + 1, nActual); - - comphelper::LibreOfficeKit::setActive(false); } void SwTiledRenderingTest::testSearchViewArea() @@ -579,8 +593,6 @@ void SwTiledRenderingTest::testSearchTextFrame() comphelper::dispatchCommand(".uno:ExecuteSearch", aPropertyValues); // This was empty: nothing was highlighted after searching for 'TextFrame'. CPPUNIT_ASSERT(!m_aTextSelection.isEmpty()); - - comphelper::LibreOfficeKit::setActive(false); } void SwTiledRenderingTest::testSearchTextFrameWrapAround() @@ -616,7 +628,6 @@ void SwTiledRenderingTest::testDocumentSizeChanged() CPPUNIT_ASSERT_EQUAL(aSize.getWidth(), m_aDocumentSize.getWidth()); // Document height should be smaller now. CPPUNIT_ASSERT(aSize.getHeight() > m_aDocumentSize.getHeight()); - comphelper::LibreOfficeKit::setActive(false); } void SwTiledRenderingTest::testSearchAll() @@ -637,8 +648,6 @@ void SwTiledRenderingTest::testSearchAll() CPPUNIT_ASSERT_EQUAL(static_cast<std::size_t>(2), m_aSearchResultSelection.size()); // Writer documents are always a single part. CPPUNIT_ASSERT_EQUAL(0, m_aSearchResultPart[0]); - - comphelper::LibreOfficeKit::setActive(false); } void SwTiledRenderingTest::testSearchAllNotifications() @@ -662,8 +671,6 @@ void SwTiledRenderingTest::testSearchAllNotifications() CPPUNIT_ASSERT_EQUAL(0, m_nSelectionBeforeSearchResult); // But we do get the selection afterwards. CPPUNIT_ASSERT(m_nSelectionAfterSearchResult > 0); - - comphelper::LibreOfficeKit::setActive(false); } void SwTiledRenderingTest::testPageDownInvalidation() @@ -682,8 +689,6 @@ void SwTiledRenderingTest::testPageDownInvalidation() // This was 2. CPPUNIT_ASSERT_EQUAL(0, m_nInvalidations); - - comphelper::LibreOfficeKit::setActive(false); } void SwTiledRenderingTest::testPartHash() @@ -696,8 +701,6 @@ void SwTiledRenderingTest::testPartHash() { CPPUNIT_ASSERT(!pXTextDocument->getPartHash(it).isEmpty()); } - - comphelper::LibreOfficeKit::setActive(false); } /// A view callback tracks callbacks invoked on one specific view. @@ -918,10 +921,11 @@ void SwTiledRenderingTest::testMissingInvalidation() Scheduler::ProcessEventsToIdle(); CPPUNIT_ASSERT(aView1.m_bTilesInvalidated); CPPUNIT_ASSERT(aView2.m_bTilesInvalidated); - mxComponent->dispose(); - mxComponent.clear(); - comphelper::LibreOfficeKit::setActive(false); + SfxLokHelper::setView(nView1); + SfxViewShell::Current()->registerLibreOfficeKitViewCallback(nullptr, nullptr); + SfxLokHelper::setView(nView2); + SfxViewShell::Current()->registerLibreOfficeKitViewCallback(nullptr, nullptr); } void SwTiledRenderingTest::testViewCursors() @@ -961,10 +965,6 @@ void SwTiledRenderingTest::testViewCursors() CPPUNIT_ASSERT(aView1.m_bViewSelectionSet); CPPUNIT_ASSERT(aView2.m_bOwnSelectionSet); CPPUNIT_ASSERT(!aView2.m_bViewSelectionSet); - mxComponent->dispose(); - mxComponent.clear(); - - comphelper::LibreOfficeKit::setActive(false); } void SwTiledRenderingTest::testShapeViewCursors() @@ -975,7 +975,9 @@ void SwTiledRenderingTest::testShapeViewCursors() SwXTextDocument* pXTextDocument = createDoc("shape.fodt"); ViewCallback aView1; SfxViewShell::Current()->registerLibreOfficeKitViewCallback(&ViewCallback::callback, &aView1); + int nView1 = SfxLokHelper::getView(); SfxLokHelper::createView(); + int nView2 = SfxLokHelper::getView(); ViewCallback aView2; pXTextDocument->initializeForTiledRendering(uno::Sequence<beans::PropertyValue>()); SfxViewShell::Current()->registerLibreOfficeKitViewCallback(&ViewCallback::callback, &aView2); @@ -1006,10 +1008,11 @@ void SwTiledRenderingTest::testShapeViewCursors() CPPUNIT_ASSERT(aView1.m_bViewCursorInvalidated && aLastViewCursor1 != aView1.m_aViewCursor); CPPUNIT_ASSERT(aView2.m_bOwnCursorInvalidated && aLastOwnCursor2 != aView2.m_aOwnCursor); CPPUNIT_ASSERT_EQUAL(aLastViewCursor2, aView2.m_aViewCursor); - mxComponent->dispose(); - mxComponent.clear(); - comphelper::LibreOfficeKit::setActive(false); + SfxLokHelper::setView(nView1); + SfxViewShell::Current()->registerLibreOfficeKitViewCallback(nullptr, nullptr); + SfxLokHelper::setView(nView2); + SfxViewShell::Current()->registerLibreOfficeKitViewCallback(nullptr, nullptr); } void SwTiledRenderingTest::testViewCursorVisibility() @@ -1020,7 +1023,9 @@ void SwTiledRenderingTest::testViewCursorVisibility() SwXTextDocument* pXTextDocument = createDoc("shape.fodt"); ViewCallback aView1; SfxViewShell::Current()->registerLibreOfficeKitViewCallback(&ViewCallback::callback, &aView1); + int nView1 = SfxLokHelper::getView(); SfxLokHelper::createView(); + int nView2 = SfxLokHelper::getView(); pXTextDocument->initializeForTiledRendering(uno::Sequence<beans::PropertyValue>()); ViewCallback aView2; SfxViewShell::Current()->registerLibreOfficeKitViewCallback(&ViewCallback::callback, &aView2); @@ -1038,10 +1043,11 @@ void SwTiledRenderingTest::testViewCursorVisibility() Scheduler::ProcessEventsToIdle(); // Make sure the "view/text" cursor of the first view gets a notification. CPPUNIT_ASSERT(!aView1.m_bViewCursorVisible); - mxComponent->dispose(); - mxComponent.clear(); - comphelper::LibreOfficeKit::setActive(false); + SfxLokHelper::setView(nView1); + SfxViewShell::Current()->registerLibreOfficeKitViewCallback(nullptr, nullptr); + SfxLokHelper::setView(nView2); + SfxViewShell::Current()->registerLibreOfficeKitViewCallback(nullptr, nullptr); } void SwTiledRenderingTest::testViewCursorCleanup() @@ -1052,6 +1058,7 @@ void SwTiledRenderingTest::testViewCursorCleanup() SwXTextDocument* pXTextDocument = createDoc("shape.fodt"); ViewCallback aView1; SfxViewShell::Current()->registerLibreOfficeKitViewCallback(&ViewCallback::callback, &aView1); + int nView1 = SfxLokHelper::getView(); int nView2 = SfxLokHelper::createView(); pXTextDocument->initializeForTiledRendering(uno::Sequence<beans::PropertyValue>()); ViewCallback aView2; @@ -1075,10 +1082,11 @@ void SwTiledRenderingTest::testViewCursorCleanup() CPPUNIT_ASSERT_EQUAL(static_cast<std::size_t>(1), SfxLokHelper::getViewsCount()); // Make sure that the graphic view selection on the first view is cleaned up. CPPUNIT_ASSERT(!aView1.m_bGraphicViewSelection); - mxComponent->dispose(); - mxComponent.clear(); - comphelper::LibreOfficeKit::setActive(false); + SfxLokHelper::setView(nView1); + SfxViewShell::Current()->registerLibreOfficeKitViewCallback(nullptr, nullptr); + SfxLokHelper::setView(nView2); + SfxViewShell::Current()->registerLibreOfficeKitViewCallback(nullptr, nullptr); } void SwTiledRenderingTest::testViewLock() @@ -1089,7 +1097,8 @@ void SwTiledRenderingTest::testViewLock() SwXTextDocument* pXTextDocument = createDoc("shape.fodt"); ViewCallback aView1; SfxViewShell::Current()->registerLibreOfficeKitViewCallback(&ViewCallback::callback, &aView1); - SfxLokHelper::createView(); + int nView1 = SfxLokHelper::getView(); + int nView2 = SfxLokHelper::createView(); pXTextDocument->initializeForTiledRendering(uno::Sequence<beans::PropertyValue>()); ViewCallback aView2; SfxViewShell::Current()->registerLibreOfficeKitViewCallback(&ViewCallback::callback, &aView2); @@ -1109,10 +1118,10 @@ void SwTiledRenderingTest::testViewLock() pWrtShell->EndTextEdit(); CPPUNIT_ASSERT(!aView1.m_bViewLock); - mxComponent->dispose(); - mxComponent.clear(); - - comphelper::LibreOfficeKit::setActive(false); + SfxLokHelper::setView(nView1); + SfxViewShell::Current()->registerLibreOfficeKitViewCallback(nullptr, nullptr); + SfxLokHelper::setView(nView2); + SfxViewShell::Current()->registerLibreOfficeKitViewCallback(nullptr, nullptr); } void SwTiledRenderingTest::testTextEditViewInvalidations() @@ -1122,7 +1131,8 @@ void SwTiledRenderingTest::testTextEditViewInvalidations() SwXTextDocument* pXTextDocument = createDoc("shape.fodt"); ViewCallback aView1; SfxViewShell::Current()->registerLibreOfficeKitViewCallback(&ViewCallback::callback, &aView1); - SfxLokHelper::createView(); + int nView1 = SfxLokHelper::getView(); + int nView2 = SfxLokHelper::createView(); pXTextDocument->initializeForTiledRendering(uno::Sequence<beans::PropertyValue>()); ViewCallback aView2; SfxViewShell::Current()->registerLibreOfficeKitViewCallback(&ViewCallback::callback, &aView2); @@ -1146,9 +1156,11 @@ void SwTiledRenderingTest::testTextEditViewInvalidations() CPPUNIT_ASSERT(aView1.m_bTilesInvalidated); pWrtShell->EndTextEdit(); - mxComponent->dispose(); - mxComponent.clear(); - comphelper::LibreOfficeKit::setActive(false); + + SfxLokHelper::setView(nView1); + SfxViewShell::Current()->registerLibreOfficeKitViewCallback(nullptr, nullptr); + SfxLokHelper::setView(nView2); + SfxViewShell::Current()->registerLibreOfficeKitViewCallback(nullptr, nullptr); } void SwTiledRenderingTest::testUndoInvalidations() @@ -1163,6 +1175,7 @@ void SwTiledRenderingTest::testUndoInvalidations() pXTextDocument->initializeForTiledRendering(uno::Sequence<beans::PropertyValue>()); ViewCallback aView2; SfxViewShell::Current()->registerLibreOfficeKitViewCallback(&ViewCallback::callback, &aView2); + int nView2 = SfxLokHelper::getView(); SfxLokHelper::setView(nView1); // Insert a character the end of the document. @@ -1185,9 +1198,10 @@ void SwTiledRenderingTest::testUndoInvalidations() // Undo was dispatched on the first view, this second view was not invalidated. CPPUNIT_ASSERT(aView2.m_bTilesInvalidated); - mxComponent->dispose(); - mxComponent.clear(); - comphelper::LibreOfficeKit::setActive(false); + SfxLokHelper::setView(nView1); + SfxViewShell::Current()->registerLibreOfficeKitViewCallback(nullptr, nullptr); + SfxLokHelper::setView(nView2); + SfxViewShell::Current()->registerLibreOfficeKitViewCallback(nullptr, nullptr); } void SwTiledRenderingTest::testUndoLimiting() @@ -1196,7 +1210,8 @@ void SwTiledRenderingTest::testUndoLimiting() comphelper::LibreOfficeKit::setActive(); SwXTextDocument* pXTextDocument = createDoc("dummy.fodt"); SwWrtShell* pWrtShell1 = pXTextDocument->GetDocShell()->GetWrtShell(); - SfxLokHelper::createView(); + int nView1 = SfxLokHelper::getView(); + int nView2 = SfxLokHelper::createView(); pXTextDocument->initializeForTiledRendering(uno::Sequence<beans::PropertyValue>()); // Insert a character the end of the document in the second view. @@ -1212,7 +1227,10 @@ void SwTiledRenderingTest::testUndoLimiting() CPPUNIT_ASSERT(!pWrtShell1->GetLastUndoInfo(nullptr, nullptr, &pWrtShell1->GetView())); CPPUNIT_ASSERT(pWrtShell2->GetLastUndoInfo(nullptr, nullptr, &pWrtShell2->GetView())); - comphelper::LibreOfficeKit::setActive(false); + SfxLokHelper::setView(nView1); + SfxViewShell::Current()->registerLibreOfficeKitViewCallback(nullptr, nullptr); + SfxLokHelper::setView(nView2); + SfxViewShell::Current()->registerLibreOfficeKitViewCallback(nullptr, nullptr); } void SwTiledRenderingTest::testUndoShapeLimiting() @@ -1221,7 +1239,8 @@ void SwTiledRenderingTest::testUndoShapeLimiting() comphelper::LibreOfficeKit::setActive(); SwXTextDocument* pXTextDocument = createDoc("shape.fodt"); SwWrtShell* pWrtShell1 = pXTextDocument->GetDocShell()->GetWrtShell(); - SfxLokHelper::createView(); + int nView1 = SfxLokHelper::getView(); + int nView2 = SfxLokHelper::createView(); pXTextDocument->initializeForTiledRendering(uno::Sequence<beans::PropertyValue>()); SwWrtShell* pWrtShell2 = pXTextDocument->GetDocShell()->GetWrtShell(); @@ -1245,7 +1264,11 @@ void SwTiledRenderingTest::testUndoShapeLimiting() pWrtShell2->EndTextEdit(); rUndoManager.SetView(nullptr); - comphelper::LibreOfficeKit::setActive(false); + + SfxLokHelper::setView(nView1); + SfxViewShell::Current()->registerLibreOfficeKitViewCallback(nullptr, nullptr); + SfxLokHelper::setView(nView2); + SfxViewShell::Current()->registerLibreOfficeKitViewCallback(nullptr, nullptr); } void SwTiledRenderingTest::testUndoDispatch() @@ -1282,7 +1305,10 @@ void SwTiledRenderingTest::testUndoDispatch() // This failed: setView() did not update the active frame. CPPUNIT_ASSERT(xFrame1 != xFrame2); - comphelper::LibreOfficeKit::setActive(false); + SfxLokHelper::setView(nView1); + SfxViewShell::Current()->registerLibreOfficeKitViewCallback(nullptr, nullptr); + SfxLokHelper::setView(nView2); + SfxViewShell::Current()->registerLibreOfficeKitViewCallback(nullptr, nullptr); } void SwTiledRenderingTest::testUndoRepairDispatch() @@ -1322,7 +1348,10 @@ void SwTiledRenderingTest::testUndoRepairDispatch() // This was 1: repair mode couldn't undo the action, either. CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(0), rUndoManager.GetUndoActionCount()); - comphelper::LibreOfficeKit::setActive(false); + SfxLokHelper::setView(nView1); + SfxViewShell::Current()->registerLibreOfficeKitViewCallback(nullptr, nullptr); + SfxLokHelper::setView(nView2); + SfxViewShell::Current()->registerLibreOfficeKitViewCallback(nullptr, nullptr); } void SwTiledRenderingTest::testShapeTextUndoShells() @@ -1348,10 +1377,6 @@ void SwTiledRenderingTest::testShapeTextUndoShells() CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(1), rUndoManager.GetUndoActionCount()); // This was -1: the view shell id for the undo action wasn't known. CPPUNIT_ASSERT_EQUAL(ViewShellId(nView1), rUndoManager.GetUndoAction()->GetViewShellId()); - - mxComponent->dispose(); - mxComponent.clear(); - comphelper::LibreOfficeKit::setActive(false); } void SwTiledRenderingTest::testShapeTextUndoGroupShells() @@ -1393,7 +1418,7 @@ void SwTiledRenderingTest::testShapeTextUndoGroupShells() // Create a second view, and make sure that the new view sees the same // cursor position as the old one. - SfxLokHelper::createView(); + int nView2 = SfxLokHelper::createView(); pXTextDocument->initializeForTiledRendering({}); ViewCallback aView2; aView2.m_aViewCursor = tools::Rectangle(); @@ -1410,9 +1435,10 @@ void SwTiledRenderingTest::testShapeTextUndoGroupShells() // by the old view. CPPUNIT_ASSERT(aView2.m_bViewLock); - mxComponent->dispose(); - mxComponent.clear(); - comphelper::LibreOfficeKit::setActive(false); + SfxLokHelper::setView(nView1); + SfxViewShell::Current()->registerLibreOfficeKitViewCallback(nullptr, nullptr); + SfxLokHelper::setView(nView2); + SfxViewShell::Current()->registerLibreOfficeKitViewCallback(nullptr, nullptr); } void SwTiledRenderingTest::testTrackChanges() @@ -1448,8 +1474,6 @@ void SwTiledRenderingTest::testTrackChanges() SwShellCursor* pShellCursor = pWrtShell->getShellCursor(false); // This was 'Aaa bbb.zzz', the change wasn't rejected. CPPUNIT_ASSERT_EQUAL(OUString("Aaa bbb."), pShellCursor->GetPoint()->nNode.GetNode().GetTextNode()->GetText()); - - comphelper::LibreOfficeKit::setActive(false); } void SwTiledRenderingTest::testTrackChangesCallback() @@ -1478,8 +1502,6 @@ void SwTiledRenderingTest::testTrackChangesCallback() pWrtShell->GetView().GetState(aSet); // This failed, LOK_CALLBACK_STATE_CHANGED wasn't sent. CPPUNIT_ASSERT_EQUAL(0, m_nTrackedChangeIndex); - - comphelper::LibreOfficeKit::setActive(false); } void SwTiledRenderingTest::testRedlineUpdateCallback() @@ -1520,8 +1542,6 @@ void SwTiledRenderingTest::testRedlineUpdateCallback() // No Modify callbacks CPPUNIT_ASSERT_EQUAL(3, m_nRedlineTableEntryModified); - - comphelper::LibreOfficeKit::setActive(false); } void SwTiledRenderingTest::testSetViewGraphicSelection() @@ -1533,7 +1553,7 @@ void SwTiledRenderingTest::testSetViewGraphicSelection() ViewCallback aView1; SfxViewShell::Current()->registerLibreOfficeKitViewCallback(&ViewCallback::callback, &aView1); // Create a second view, and switch back to the first view. - SfxLokHelper::createView(); + int nView2 = SfxLokHelper::createView(); pXTextDocument->initializeForTiledRendering({}); SfxLokHelper::setView(nView1); @@ -1550,9 +1570,10 @@ void SwTiledRenderingTest::testSetViewGraphicSelection() // This failed, mark handles were hidden in the first view. CPPUNIT_ASSERT(!pView->areMarkHandlesHidden()); - mxComponent->dispose(); - mxComponent.clear(); - comphelper::LibreOfficeKit::setActive(false); + SfxLokHelper::setView(nView1); + SfxViewShell::Current()->registerLibreOfficeKitViewCallback(nullptr, nullptr); + SfxLokHelper::setView(nView2); + SfxViewShell::Current()->registerLibreOfficeKitViewCallback(nullptr, nullptr); } void SwTiledRenderingTest::testCreateViewGraphicSelection() @@ -1574,7 +1595,8 @@ void SwTiledRenderingTest::testCreateViewGraphicSelection() CPPUNIT_ASSERT(aView1.m_bGraphicSelection); // Create a second view. - SfxLokHelper::createView(); + int nView1 = SfxLokHelper::getView(); + int nView2 = SfxLokHelper::createView(); // This was false, creating a second view cleared the selection of the // first one. CPPUNIT_ASSERT(aView1.m_bGraphicSelection); @@ -1591,9 +1613,10 @@ void SwTiledRenderingTest::testCreateViewGraphicSelection() // first view. CPPUNIT_ASSERT(aView2.m_bGraphicViewSelection); - mxComponent->dispose(); - mxComponent.clear(); - comphelper::LibreOfficeKit::setActive(false); + SfxLokHelper::setView(nView1); + SfxViewShell::Current()->registerLibreOfficeKitViewCallback(nullptr, nullptr); + SfxLokHelper::setView(nView2); + SfxViewShell::Current()->registerLibreOfficeKitViewCallback(nullptr, nullptr); } void SwTiledRenderingTest::testCreateViewTextSelection() @@ -1615,7 +1638,8 @@ void SwTiledRenderingTest::testCreateViewTextSelection() CPPUNIT_ASSERT_EQUAL(OUString("bbb"), pShellCursor->GetText()); // Create a second view. - SfxLokHelper::createView(); + int nView1 = SfxLokHelper::getView(); + int nView2 = SfxLokHelper::createView(); // Make sure that the text selection is visible in the second view. ViewCallback aView2; @@ -1624,9 +1648,10 @@ void SwTiledRenderingTest::testCreateViewTextSelection() // This failed, the second view didn't get the text selection of the first view. CPPUNIT_ASSERT(!aView2.m_aViewSelection.isEmpty()); - mxComponent->dispose(); - mxComponent.clear(); - comphelper::LibreOfficeKit::setActive(false); + SfxLokHelper::setView(nView1); + SfxViewShell::Current()->registerLibreOfficeKitViewCallback(nullptr, nullptr); + SfxLokHelper::setView(nView2); + SfxViewShell::Current()->registerLibreOfficeKitViewCallback(nullptr, nullptr); } void SwTiledRenderingTest::testRedlineColors() @@ -1648,8 +1673,6 @@ void SwTiledRenderingTest::testRedlineColors() boost::property_tree::ptree aTree; boost::property_tree::read_json(aStream, aTree); CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(1), aTree.get_child("authors").size()); - - comphelper::LibreOfficeKit::setActive(false); } void SwTiledRenderingTest::testCommentEndTextEdit() @@ -1689,10 +1712,6 @@ void SwTiledRenderingTest::testCommentEndTextEdit() pXTextDocument->postKeyEvent(LOK_KEYEVENT_KEYUP, 0, KEY_RETURN); Scheduler::ProcessEventsToIdle(); CPPUNIT_ASSERT(aView1.m_bTilesInvalidated); - - mxComponent->dispose(); - mxComponent.clear(); - comphelper::LibreOfficeKit::setActive(false); } void SwTiledRenderingTest::testCursorPosition() @@ -1704,7 +1723,8 @@ void SwTiledRenderingTest::testCursorPosition() SfxViewShell::Current()->registerLibreOfficeKitViewCallback(&ViewCallback::callback, &aView1); // Crete a second view, so the first view gets a collaborative cursor. - SfxLokHelper::createView(); + int nView1 = SfxLokHelper::getView(); + int nView2 = SfxLokHelper::createView(); pXTextDocument->initializeForTiledRendering({}); ViewCallback aView2; SfxViewShell::Current()->registerLibreOfficeKitViewCallback(&ViewCallback::callback, &aView2); @@ -1714,9 +1734,10 @@ void SwTiledRenderingTest::testCursorPosition() // '1425, 1425', due to pixel alignment. CPPUNIT_ASSERT_EQUAL(aView1.m_aOwnCursor.toString(), aView1.m_aViewCursor.toString()); - mxComponent->dispose(); - mxComponent.clear(); - comphelper::LibreOfficeKit::setActive(false); + SfxLokHelper::setView(nView1); + SfxViewShell::Current()->registerLibreOfficeKitViewCallback(nullptr, nullptr); + SfxLokHelper::setView(nView2); + SfxViewShell::Current()->registerLibreOfficeKitViewCallback(nullptr, nullptr); } void SwTiledRenderingTest::testPaintCallbacks() @@ -1729,9 +1750,10 @@ void SwTiledRenderingTest::testPaintCallbacks() SwXTextDocument* pXTextDocument = createDoc(); ViewCallback aView1; SfxViewShell::Current()->registerLibreOfficeKitViewCallback(&ViewCallback::callback, &aView1); + int nView1 = SfxLokHelper::getView(); // Create a second view and paint a tile on that second view. - SfxLokHelper::createView(); + int nView2 = SfxLokHelper::createView(); int nCanvasWidth = 256; int nCanvasHeight = 256; std::vector<unsigned char> aBuffer(nCanvasWidth * nCanvasHeight * 4); @@ -1742,10 +1764,14 @@ void SwTiledRenderingTest::testPaintCallbacks() aView1.m_bCalled = false; pXTextDocument->paintTile(*pDevice, nCanvasWidth, nCanvasHeight, /*nTilePosX=*/0, /*nTilePosY=*/0, /*nTileWidth=*/3840, /*nTileHeight=*/3840); CPPUNIT_ASSERT(!aView1.m_bCalled); + SfxViewShell::Current()->registerLibreOfficeKitViewCallback(nullptr, nullptr); + SfxLokHelper::setView(nView1); + SfxViewShell::Current()->registerLibreOfficeKitViewCallback(nullptr, nullptr); - mxComponent->dispose(); - mxComponent.clear(); - comphelper::LibreOfficeKit::setActive(false); + SfxLokHelper::setView(nView1); + SfxViewShell::Current()->registerLibreOfficeKitViewCallback(nullptr, nullptr); + SfxLokHelper::setView(nView2); + SfxViewShell::Current()->registerLibreOfficeKitViewCallback(nullptr, nullptr); } void SwTiledRenderingTest::testUndoRepairResult() @@ -1778,9 +1804,10 @@ void SwTiledRenderingTest::testUndoRepairResult() Scheduler::ProcessEventsToIdle(); CPPUNIT_ASSERT_EQUAL(static_cast<sal_uInt32>(SID_REPAIRPACKAGE), pResult2->m_nDocRepair); - mxComponent->dispose(); - mxComponent.clear(); - comphelper::LibreOfficeKit::setActive(false); + SfxLokHelper::setView(nView1); + SfxViewShell::Current()->registerLibreOfficeKitViewCallback(nullptr, nullptr); + SfxLokHelper::setView(nView2); + SfxViewShell::Current()->registerLibreOfficeKitViewCallback(nullptr, nullptr); } void SwTiledRenderingTest::testRedoRepairResult() @@ -1816,9 +1843,10 @@ void SwTiledRenderingTest::testRedoRepairResult() Scheduler::ProcessEventsToIdle(); CPPUNIT_ASSERT_EQUAL(static_cast<sal_uInt32>(SID_REPAIRPACKAGE), pResult2->m_nDocRepair); - mxComponent->dispose(); - mxComponent.clear(); - comphelper::LibreOfficeKit::setActive(false); + SfxLokHelper::setView(nView1); + SfxViewShell::Current()->registerLibreOfficeKitViewCallback(nullptr, nullptr); + SfxLokHelper::setView(nView2); + SfxViewShell::Current()->registerLibreOfficeKitViewCallback(nullptr, nullptr); } namespace { @@ -1902,9 +1930,10 @@ void SwTiledRenderingTest::testDisableUndoRepair() Scheduler::ProcessEventsToIdle(); checkUndoRepairStates(pXTextDocument, pView1, pView2); - mxComponent->dispose(); - mxComponent.clear(); - comphelper::LibreOfficeKit::setActive(false); + SfxLokHelper::setView(nView1); + SfxViewShell::Current()->registerLibreOfficeKitViewCallback(nullptr, nullptr); + SfxLokHelper::setView(nView2); + SfxViewShell::Current()->registerLibreOfficeKitViewCallback(nullptr, nullptr); } void SwTiledRenderingTest::testAllTrackedChanges() @@ -1922,7 +1951,8 @@ void SwTiledRenderingTest::testAllTrackedChanges() SwWrtShell* pWrtShell1 = pView1->GetWrtShellPtr(); // view #2 - SfxLokHelper::createView(); + int nView1 = SfxLokHelper::getView(); + int nView2 = SfxLokHelper::createView(); SwView* pView2 = dynamic_cast<SwView*>(SfxViewShell::Current()); CPPUNIT_ASSERT(pView2 && pView1 != pView2); SwWrtShell* pWrtShell2 = pView2->GetWrtShellPtr(); @@ -1974,7 +2004,10 @@ void SwTiledRenderingTest::testAllTrackedChanges() CPPUNIT_ASSERT_EQUAL(OUString("hyyAaa bbb.cyy"), pShellCursor->GetPoint()->nNode.GetNode().GetTextNode()->GetText()); } - comphelper::LibreOfficeKit::setActive(false); + SfxLokHelper::setView(nView1); + SfxViewShell::Current()->registerLibreOfficeKitViewCallback(nullptr, nullptr); + SfxLokHelper::setView(nView2); + SfxViewShell::Current()->registerLibreOfficeKitViewCallback(nullptr, nullptr); } void SwTiledRenderingTest::testDocumentRepair() @@ -1987,6 +2020,7 @@ void SwTiledRenderingTest::testDocumentRepair() SfxViewShell* pView1 = SfxViewShell::Current(); // view #2 + int nView1 = SfxLokHelper::getView(); SfxLokHelper::createView(); SfxViewShell* pView2 = SfxViewShell::Current(); int nView2 = SfxLokHelper::getView(); @@ -2022,7 +2056,10 @@ void SwTiledRenderingTest::testDocumentRepair() CPPUNIT_ASSERT_EQUAL(true, pItem2->GetValue()); } - comphelper::LibreOfficeKit::setActive(false); + SfxLokHelper::setView(nView1); + SfxViewShell::Current()->registerLibreOfficeKitViewCallback(nullptr, nullptr); + SfxLokHelper::setView(nView2); + SfxViewShell::Current()->registerLibreOfficeKitViewCallback(nullptr, nullptr); } namespace { @@ -2071,10 +2108,6 @@ void SwTiledRenderingTest::testPageHeader() } // Check Page Header State checkPageHeaderOrFooter(pViewShell, FN_INSERT_PAGEHEADER, false); - - mxComponent->dispose(); - mxComponent.clear(); - comphelper::LibreOfficeKit::setActive(false); } void SwTiledRenderingTest::testPageFooter() @@ -2102,10 +2135,6 @@ void SwTiledRenderingTest::testPageFooter() } // Check Footer State checkPageHeaderOrFooter(pViewShell, FN_INSERT_PAGEFOOTER, false); - - mxComponent->dispose(); - mxComponent.clear(); - comphelper::LibreOfficeKit::setActive(false); } void SwTiledRenderingTest::testTdf115088() @@ -2163,8 +2192,6 @@ void SwTiledRenderingTest::testRedlineField() CPPUNIT_ASSERT_EQUAL(static_cast<SwRedlineTable::size_type>(1), rTable.size()); SwRangeRedline* pRedline = rTable[0]; CPPUNIT_ASSERT(pRedline->GetDescr().indexOf(aDate.GetFieldName())!= -1); - - comphelper::LibreOfficeKit::setActive(false); } void SwTiledRenderingTest::testIMESupport() @@ -2196,8 +2223,6 @@ void SwTiledRenderingTest::testIMESupport() // content contains only the last IME composition, not all CPPUNIT_ASSERT_EQUAL(aInputs[aInputs.size() - 1].concat("Aaa bbb."), pShellCursor->GetPoint()->nNode.GetNode().GetTextNode()->GetText()); - - comphelper::LibreOfficeKit::setActive(false); } void SwTiledRenderingTest::testSplitNodeRedlineCallback() @@ -2257,8 +2282,6 @@ void SwTiledRenderingTest::testSplitNodeRedlineCallback() pXTextDocument->postKeyEvent(LOK_KEYEVENT_KEYUP, 0, KEY_RETURN); Scheduler::ProcessEventsToIdle(); CPPUNIT_ASSERT_EQUAL(0, m_nRedlineTableEntryModified); - - comphelper::LibreOfficeKit::setActive(false); } void SwTiledRenderingTest::testDeleteNodeRedlineCallback() @@ -2318,8 +2341,6 @@ void SwTiledRenderingTest::testDeleteNodeRedlineCallback() pXTextDocument->postKeyEvent(LOK_KEYEVENT_KEYUP, 0, KEY_BACKSPACE); Scheduler::ProcessEventsToIdle(); CPPUNIT_ASSERT_EQUAL(0, m_nRedlineTableEntryModified); - - comphelper::LibreOfficeKit::setActive(false); } @@ -2396,10 +2417,10 @@ void SwTiledRenderingTest::testVisCursorInvalidation() CPPUNIT_ASSERT_EQUAL(nView2, aView2.m_nOwnCursorInvalidatedBy); comphelper::LibreOfficeKit::setViewIdForVisCursorInvalidation(false); - - mxComponent->dispose(); - mxComponent.clear(); - comphelper::LibreOfficeKit::setActive(false); + SfxLokHelper::setView(nView1); + SfxViewShell::Current()->registerLibreOfficeKitViewCallback(nullptr, nullptr); + SfxLokHelper::setView(nView2); + SfxViewShell::Current()->registerLibreOfficeKitViewCallback(nullptr, nullptr); } void SwTiledRenderingTest::testDeselectCustomShape() @@ -2421,8 +2442,6 @@ void SwTiledRenderingTest::testDeselectCustomShape() pXTextDocument->postMouseEvent(LOK_MOUSEEVENT_MOUSEBUTTONUP, aStart.getX(), aStart.getY(), 1, MOUSE_LEFT, 0); Scheduler::ProcessEventsToIdle(); CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(0), pWrtShell->GetDrawView()->GetMarkedObjectList().GetMarkCount()); - - comphelper::LibreOfficeKit::setActive(false); } CPPUNIT_TEST_SUITE_REGISTRATION(SwTiledRenderingTest); |