From 56552630fe21a143ca243807f093ebb150a2de98 Mon Sep 17 00:00:00 2001 From: Pranav Kant Date: Thu, 16 Mar 2017 19:33:48 +0530 Subject: sw lok: Use unique redline identifier, instead of array indices Use a static integer counter as identifier to each redline Change few unit-tets that was testing redlines by using a hardcoded array index. Instead use these unique redline identifiers now. Change-Id: I63aec3fc8ab10d0dad0c936600d16e96999a2bcd Reviewed-on: https://gerrit.libreoffice.org/35276 Tested-by: Jenkins Reviewed-by: Miklos Vajna --- sw/qa/extras/tiledrendering/tiledrendering.cxx | 33 ++++++++++++++++++++++++-- sw/qa/extras/uiwriter/uiwriter.cxx | 9 ++++--- 2 files changed, 37 insertions(+), 5 deletions(-) (limited to 'sw/qa') diff --git a/sw/qa/extras/tiledrendering/tiledrendering.cxx b/sw/qa/extras/tiledrendering/tiledrendering.cxx index a4275ff25d30..c07f9fb46772 100644 --- a/sw/qa/extras/tiledrendering/tiledrendering.cxx +++ b/sw/qa/extras/tiledrendering/tiledrendering.cxx @@ -31,6 +31,8 @@ #include #include #include +#include +#include static const char* const DATA_DIRECTORY = "/sw/qa/extras/tiledrendering/data/"; @@ -651,6 +653,10 @@ public: bool m_bViewLock; /// Set if any callback was invoked. bool m_bCalled; + /// Redline table size changed payload + boost::property_tree::ptree m_aRedlineTableChanged; + /// Redline table modified payload + boost::property_tree::ptree m_aRedlineTableModified; ViewCallback() : m_bOwnCursorInvalidated(false), @@ -757,6 +763,22 @@ public: m_bViewLock = aTree.get_child("rectangle").get_value() != "EMPTY"; } break; + case LOK_CALLBACK_REDLINE_TABLE_SIZE_CHANGED: + { + m_aRedlineTableChanged.clear(); + std::stringstream aStream(pPayload); + boost::property_tree::read_json(aStream, m_aRedlineTableChanged); + m_aRedlineTableChanged = m_aRedlineTableChanged.get_child("redline"); + } + break; + case LOK_CALLBACK_REDLINE_TABLE_ENTRY_MODIFIED: + { + m_aRedlineTableModified.clear(); + std::stringstream aStream(pPayload); + boost::property_tree::read_json(aStream, m_aRedlineTableModified); + m_aRedlineTableModified = m_aRedlineTableModified.get_child("redline"); + } + break; } } }; @@ -1305,15 +1327,22 @@ void SwTiledRenderingTest::testTrackChanges() // Turn on trak changes, type "zzz" at the end, and move to the start. uno::Reference xPropertySet(mxComponent, uno::UNO_QUERY); xPropertySet->setPropertyValue("RecordChanges", uno::makeAny(true)); + ViewCallback aView; SwWrtShell* pWrtShell = pXTextDocument->GetDocShell()->GetWrtShell(); + pWrtShell->GetSfxViewShell()->registerLibreOfficeKitViewCallback(&ViewCallback::callback, &aView); pWrtShell->EndDoc(); pWrtShell->Insert("zzz"); pWrtShell->SttDoc(); - // Reject the change by index, while the cursor does not cover the tracked change. + // Get the redline just created + const SwRedlineTable& rTable = pWrtShell->GetDoc()->getIDocumentRedlineAccess().GetRedlineTable(); + CPPUNIT_ASSERT_EQUAL(static_cast(1), rTable.size()); + SwRangeRedline* pRedline = rTable[0]; + + // Reject the change by id, while the cursor does not cover the tracked change. uno::Sequence aPropertyValues(comphelper::InitPropertySequence( { - {"RejectTrackedChange", uno::makeAny(static_cast(0))} + {"RejectTrackedChange", uno::makeAny(static_cast(pRedline->GetId()))} })); comphelper::dispatchCommand(".uno:RejectTrackedChange", aPropertyValues); Scheduler::ProcessEventsToIdle(); diff --git a/sw/qa/extras/uiwriter/uiwriter.cxx b/sw/qa/extras/uiwriter/uiwriter.cxx index d906f3f56228..aec4b5e00a77 100644 --- a/sw/qa/extras/uiwriter/uiwriter.cxx +++ b/sw/qa/extras/uiwriter/uiwriter.cxx @@ -4120,11 +4120,14 @@ void SwUiWriterTest::testRedlineParam() pWrtShell->EndDoc(); pWrtShell->Insert("zzz"); + const SwRedlineTable& rTable = pDoc->getIDocumentRedlineAccess().GetRedlineTable(); + CPPUNIT_ASSERT_EQUAL(static_cast(2), rTable.size()); + // Select the first redline. pWrtShell->SttDoc(); uno::Sequence aPropertyValues(comphelper::InitPropertySequence( { - {"NextTrackedChange", uno::makeAny(static_cast(0))} + {"NextTrackedChange", uno::makeAny(static_cast(rTable[0]->GetId()))} })); lcl_dispatchCommand(mxComponent, ".uno:NextTrackedChange", aPropertyValues); Scheduler::ProcessEventsToIdle(); @@ -4137,7 +4140,7 @@ void SwUiWriterTest::testRedlineParam() pWrtShell->SttDoc(); aPropertyValues = comphelper::InitPropertySequence( { - {"NextTrackedChange", uno::makeAny(static_cast(1))} + {"NextTrackedChange", uno::makeAny(static_cast(rTable[1]->GetId()))} }); lcl_dispatchCommand(mxComponent, ".uno:NextTrackedChange", aPropertyValues); Scheduler::ProcessEventsToIdle(); @@ -4148,7 +4151,7 @@ void SwUiWriterTest::testRedlineParam() pWrtShell->SttDoc(); aPropertyValues = comphelper::InitPropertySequence( { - {"RejectTrackedChange", uno::makeAny(static_cast(1))} + {"RejectTrackedChange", uno::makeAny(static_cast(rTable[1]->GetId()))} }); lcl_dispatchCommand(mxComponent, ".uno:RejectTrackedChange", aPropertyValues); Scheduler::ProcessEventsToIdle(); -- cgit