summaryrefslogtreecommitdiff
path: root/sw
diff options
context:
space:
mode:
authorAshod Nakashian <ashod.nakashian@collabora.co.uk>2020-08-01 16:09:00 -0400
committerAshod Nakashian <ash@collabora.com>2020-08-10 04:49:44 +0200
commitafaed0b1141d67c36ff0714be5d7eb2825a79bdd (patch)
tree80d1414e29a8c41b663a2410b42723b1ead4163c /sw
parentb7b81c68dc406cfa16d959f22417a3c3ed7888d5 (diff)
lok: minor cleanup of ViewCallback in tiledrendering tests
Change-Id: I39b964a7aa7d181083a153283f38c1a5bc64de58 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/99973 Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com> Reviewed-by: Ashod Nakashian <ash@collabora.com>
Diffstat (limited to 'sw')
-rw-r--r--sw/qa/extras/tiledrendering/tiledrendering.cxx69
1 files changed, 35 insertions, 34 deletions
diff --git a/sw/qa/extras/tiledrendering/tiledrendering.cxx b/sw/qa/extras/tiledrendering/tiledrendering.cxx
index 7cb4978be44c..4b4f00887a74 100644
--- a/sw/qa/extras/tiledrendering/tiledrendering.cxx
+++ b/sw/qa/extras/tiledrendering/tiledrendering.cxx
@@ -752,7 +752,7 @@ void SwTiledRenderingTest::testPartHash()
}
/// A view callback tracks callbacks invoked on one specific view.
-class ViewCallback
+class ViewCallback final
{
SfxViewShell* mpViewShell;
int mnView;
@@ -780,7 +780,7 @@ public:
/// Post-it / annotation payload.
boost::property_tree::ptree m_aComment;
- ViewCallback(SfxViewShell* pViewShell, std::function<void(ViewCallback&)> const & rBeforeInstallFunc = {})
+ ViewCallback(SfxViewShell* pViewShell = nullptr, std::function<void(ViewCallback&)> const & rBeforeInstallFunc = {})
: m_bOwnCursorInvalidated(false),
m_nOwnCursorInvalidatedBy(-1),
m_bOwnCursorAtOrigin(false),
@@ -798,7 +798,7 @@ public:
if (rBeforeInstallFunc)
rBeforeInstallFunc(*this);
- mpViewShell = pViewShell;
+ mpViewShell = pViewShell ? pViewShell : SfxViewShell::Current();
mpViewShell->registerLibreOfficeKitViewCallback(&ViewCallback::callback, this);
mnView = SfxLokHelper::getView();
}
@@ -966,10 +966,10 @@ void SwTiledRenderingTest::testMissingInvalidation()
// Create two views.
SwXTextDocument* pXTextDocument = createDoc("dummy.fodt");
- ViewCallback aView1(SfxViewShell::Current());
+ ViewCallback aView1;
int nView1 = SfxLokHelper::getView();
SfxLokHelper::createView();
- ViewCallback aView2(SfxViewShell::Current());
+ ViewCallback aView2;
int nView2 = SfxLokHelper::getView();
// First view: put the cursor into the first word.
@@ -999,9 +999,10 @@ void SwTiledRenderingTest::testViewCursors()
comphelper::LibreOfficeKit::setActive();
SwXTextDocument* pXTextDocument = createDoc("dummy.fodt");
- ViewCallback aView1(SfxViewShell::Current());
+ ViewCallback aView1;
SfxLokHelper::createView();
- ViewCallback aView2(SfxViewShell::Current());
+ ViewCallback aView2;
+
CPPUNIT_ASSERT(aView1.m_bOwnCursorInvalidated);
CPPUNIT_ASSERT(aView1.m_bViewCursorInvalidated);
CPPUNIT_ASSERT(aView2.m_bOwnCursorInvalidated);
@@ -1037,10 +1038,10 @@ void SwTiledRenderingTest::testShapeViewCursors()
// Load a document and create a view, so we have 2 ones.
SwXTextDocument* pXTextDocument = createDoc("shape.fodt");
- ViewCallback aView1(SfxViewShell::Current());
+ ViewCallback aView1;
SfxLokHelper::createView();
pXTextDocument->initializeForTiledRendering(uno::Sequence<beans::PropertyValue>());
- ViewCallback aView2(SfxViewShell::Current());
+ ViewCallback aView2;
SwWrtShell* pWrtShell2 = pXTextDocument->GetDocShell()->GetWrtShell();
// Start shape text in the second view.
@@ -1076,10 +1077,10 @@ void SwTiledRenderingTest::testViewCursorVisibility()
// Load a document that has a shape and create two views.
SwXTextDocument* pXTextDocument = createDoc("shape.fodt");
- ViewCallback aView1(SfxViewShell::Current());
+ ViewCallback aView1;
SfxLokHelper::createView();
pXTextDocument->initializeForTiledRendering(uno::Sequence<beans::PropertyValue>());
- ViewCallback aView2(SfxViewShell::Current());
+ ViewCallback aView2;
// This failed, initially the view cursor in the second view wasn't visible.
CPPUNIT_ASSERT(aView2.m_bViewCursorVisible);
@@ -1102,11 +1103,11 @@ void SwTiledRenderingTest::testViewCursorCleanup()
// Load a document that has a shape and create two views.
SwXTextDocument* pXTextDocument = createDoc("shape.fodt");
- ViewCallback aView1(SfxViewShell::Current());
+ ViewCallback aView1;
int nView2 = SfxLokHelper::createView();
pXTextDocument->initializeForTiledRendering(uno::Sequence<beans::PropertyValue>());
{
- ViewCallback aView2(SfxViewShell::Current());
+ ViewCallback aView2;
// Click on the shape in the second view.
SwWrtShell* pWrtShell = pXTextDocument->GetDocShell()->GetWrtShell();
@@ -1134,10 +1135,10 @@ void SwTiledRenderingTest::testViewLock()
// Load a document that has a shape and create two views.
SwXTextDocument* pXTextDocument = createDoc("shape.fodt");
- ViewCallback aView1(SfxViewShell::Current());
+ ViewCallback aView1;
SfxLokHelper::createView();
pXTextDocument->initializeForTiledRendering(uno::Sequence<beans::PropertyValue>());
- ViewCallback aView2(SfxViewShell::Current());
+ ViewCallback aView2;
// Begin text edit in the second view and assert that the first gets a lock
// notification.
@@ -1160,10 +1161,10 @@ void SwTiledRenderingTest::testTextEditViewInvalidations()
// Load a document that has a shape and create two views.
comphelper::LibreOfficeKit::setActive();
SwXTextDocument* pXTextDocument = createDoc("shape.fodt");
- ViewCallback aView1(SfxViewShell::Current());
+ ViewCallback aView1;
SfxLokHelper::createView();
pXTextDocument->initializeForTiledRendering(uno::Sequence<beans::PropertyValue>());
- ViewCallback aView2(SfxViewShell::Current());
+ ViewCallback aView2;
// Begin text edit in the second view.
SwWrtShell* pWrtShell = pXTextDocument->GetDocShell()->GetWrtShell();
@@ -1191,11 +1192,11 @@ void SwTiledRenderingTest::testUndoInvalidations()
// Load a document and create two views.
comphelper::LibreOfficeKit::setActive();
SwXTextDocument* pXTextDocument = createDoc("dummy.fodt");
- ViewCallback aView1(SfxViewShell::Current());
+ ViewCallback aView1;
int nView1 = SfxLokHelper::getView();
SfxLokHelper::createView();
pXTextDocument->initializeForTiledRendering(uno::Sequence<beans::PropertyValue>());
- ViewCallback aView2(SfxViewShell::Current());
+ ViewCallback aView2;
SfxLokHelper::setView(nView1);
// Insert a character the end of the document.
@@ -1399,7 +1400,7 @@ void SwTiledRenderingTest::testShapeTextUndoGroupShells()
// Load a document and create a view.
comphelper::LibreOfficeKit::setActive();
SwXTextDocument* pXTextDocument = createDoc("shape.fodt");
- ViewCallback aView1(SfxViewShell::Current());
+ ViewCallback aView1;
sal_Int32 nView1 = SfxLokHelper::getView();
// Begin text edit.
@@ -1434,7 +1435,7 @@ void SwTiledRenderingTest::testShapeTextUndoGroupShells()
// cursor position as the old one.
SfxLokHelper::createView();
pXTextDocument->initializeForTiledRendering({});
- ViewCallback aView2(SfxViewShell::Current());
+ ViewCallback aView2;
// Difference was 935 twips, the new view didn't see the editeng cursor of
// the old one. The new difference should be <1px, but here we deal with twips.
CPPUNIT_ASSERT(std::abs(aView1.m_aOwnCursor.Top() - aView2.m_aViewCursor.Top()) < 10);
@@ -1554,7 +1555,7 @@ void SwTiledRenderingTest::testSetViewGraphicSelection()
comphelper::LibreOfficeKit::setActive();
SwXTextDocument* pXTextDocument = createDoc("frame.odt");
int nView1 = SfxLokHelper::getView();
- ViewCallback aView1(SfxViewShell::Current());
+ ViewCallback aView1;
// Create a second view, and switch back to the first view.
SfxLokHelper::createView();
pXTextDocument->initializeForTiledRendering({});
@@ -1579,7 +1580,7 @@ void SwTiledRenderingTest::testCreateViewGraphicSelection()
// Load a document.
comphelper::LibreOfficeKit::setActive();
SwXTextDocument* pXTextDocument = createDoc("frame.odt");
- ViewCallback aView1(SfxViewShell::Current());
+ ViewCallback aView1;
// Mark the textframe in the first view.
SwWrtShell* pWrtShell = pXTextDocument->GetDocShell()->GetWrtShell();
@@ -1613,7 +1614,7 @@ void SwTiledRenderingTest::testCreateViewTextSelection()
// Load a document.
comphelper::LibreOfficeKit::setActive();
SwXTextDocument* pXTextDocument = createDoc("dummy.fodt");
- ViewCallback aView1(SfxViewShell::Current());
+ ViewCallback aView1;
// Create a text selection:
SwWrtShell* pWrtShell = pXTextDocument->GetDocShell()->GetWrtShell();
@@ -1629,7 +1630,7 @@ void SwTiledRenderingTest::testCreateViewTextSelection()
SfxLokHelper::createView();
// Make sure that the text selection is visible in the second view.
- ViewCallback aView2(SfxViewShell::Current());
+ ViewCallback aView2;
// This failed, the second view didn't get the text selection of the first view.
CPPUNIT_ASSERT(!aView2.m_aViewSelection.isEmpty());
}
@@ -1660,7 +1661,7 @@ void SwTiledRenderingTest::testCommentEndTextEdit()
// Create a document, type a character and remember the cursor position.
comphelper::LibreOfficeKit::setActive();
SwXTextDocument* pXTextDocument = createDoc();
- ViewCallback aView1(SfxViewShell::Current());
+ ViewCallback aView1;
pXTextDocument->postKeyEvent(LOK_KEYEVENT_KEYINPUT, 'x', 0);
pXTextDocument->postKeyEvent(LOK_KEYEVENT_KEYUP, 'x', 0);
Scheduler::ProcessEventsToIdle();
@@ -1715,7 +1716,7 @@ void SwTiledRenderingTest::testCommentInsert()
{"Text", uno::makeAny(OUString("some text"))},
{"Author", uno::makeAny(OUString("me"))},
});
- ViewCallback aView(SfxViewShell::Current());
+ ViewCallback aView;
comphelper::dispatchCommand(".uno:InsertAnnotation", xFrame, aPropertyValues);
Scheduler::ProcessEventsToIdle();
OString aAnchorPos(aView.m_aComment.get_child("anchorPos").get_value<std::string>().c_str());
@@ -1732,12 +1733,12 @@ void SwTiledRenderingTest::testCursorPosition()
// Load a document and register a callback, should get an own cursor.
comphelper::LibreOfficeKit::setActive();
SwXTextDocument* pXTextDocument = createDoc();
- ViewCallback aView1(SfxViewShell::Current());
+ ViewCallback aView1;
// Crete a second view, so the first view gets a collaborative cursor.
SfxLokHelper::createView();
pXTextDocument->initializeForTiledRendering({});
- ViewCallback aView2(SfxViewShell::Current());
+ ViewCallback aView2;
// Make sure the two are exactly the same.
// This failed, own cursor was at '1418, 1418', collaborative cursor was at
@@ -1753,7 +1754,7 @@ void SwTiledRenderingTest::testPaintCallbacks()
// Load a document and register a callback for the first view.
comphelper::LibreOfficeKit::setActive();
SwXTextDocument* pXTextDocument = createDoc();
- ViewCallback aView1(SfxViewShell::Current());
+ ViewCallback aView1;
// Create a second view and paint a tile on that second view.
SfxLokHelper::createView();
@@ -1871,12 +1872,12 @@ void SwTiledRenderingTest::testDisableUndoRepair()
// Create two views.
SwXTextDocument* pXTextDocument = createDoc("dummy.fodt");
- ViewCallback aView1(SfxViewShell::Current());
+ ViewCallback aView1;
SwView* pView1 = dynamic_cast<SwView*>(SfxViewShell::Current());
CPPUNIT_ASSERT(pView1);
int nView1 = SfxLokHelper::getView();
SfxLokHelper::createView();
- ViewCallback aView2(SfxViewShell::Current());
+ ViewCallback aView2;
SwView* pView2 = dynamic_cast<SwView*>(SfxViewShell::Current());
CPPUNIT_ASSERT(pView2);
int nView2 = SfxLokHelper::getView();
@@ -2339,12 +2340,12 @@ void SwTiledRenderingTest::testVisCursorInvalidation()
comphelper::LibreOfficeKit::setActive();
SwXTextDocument* pXTextDocument = createDoc("dummy.fodt");
- ViewCallback aView1(SfxViewShell::Current());
+ ViewCallback aView1;
int nView1 = SfxLokHelper::getView();
SfxLokHelper::createView();
int nView2 = SfxLokHelper::getView();
- ViewCallback aView2(SfxViewShell::Current());
+ ViewCallback aView2;
Scheduler::ProcessEventsToIdle();