diff options
author | Pranav Kant <pranavk@collabora.co.uk> | 2017-03-16 19:33:48 +0530 |
---|---|---|
committer | Miklos Vajna <vmiklos@collabora.co.uk> | 2017-03-17 10:38:05 +0000 |
commit | 56552630fe21a143ca243807f093ebb150a2de98 (patch) | |
tree | 3aa080240bf2eeb60275473b6288b82262fb1a16 /sw/qa | |
parent | a9bbc74f1d9053cb3b950e0c14e0fae18f1b0257 (diff) |
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 <ci@libreoffice.org>
Reviewed-by: Miklos Vajna <vmiklos@collabora.co.uk>
Diffstat (limited to 'sw/qa')
-rw-r--r-- | sw/qa/extras/tiledrendering/tiledrendering.cxx | 33 | ||||
-rw-r--r-- | sw/qa/extras/uiwriter/uiwriter.cxx | 9 |
2 files changed, 37 insertions, 5 deletions
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 <cmdid.h> #include <sfx2/viewsh.hxx> #include <sfx2/lokhelper.hxx> +#include <redline.hxx> +#include <IDocumentRedlineAccess.hxx> 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<std::string>() != "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<beans::XPropertySet> 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<SwRedlineTable::size_type>(1), rTable.size()); + SwRangeRedline* pRedline = rTable[0]; + + // Reject the change by id, while the cursor does not cover the tracked change. uno::Sequence<beans::PropertyValue> aPropertyValues(comphelper::InitPropertySequence( { - {"RejectTrackedChange", uno::makeAny(static_cast<sal_uInt16>(0))} + {"RejectTrackedChange", uno::makeAny(static_cast<sal_uInt16>(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<SwRedlineTable::size_type>(2), rTable.size()); + // Select the first redline. pWrtShell->SttDoc(); uno::Sequence<beans::PropertyValue> aPropertyValues(comphelper::InitPropertySequence( { - {"NextTrackedChange", uno::makeAny(static_cast<sal_uInt16>(0))} + {"NextTrackedChange", uno::makeAny(static_cast<sal_uInt16>(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<sal_uInt16>(1))} + {"NextTrackedChange", uno::makeAny(static_cast<sal_uInt16>(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<sal_uInt16>(1))} + {"RejectTrackedChange", uno::makeAny(static_cast<sal_uInt16>(rTable[1]->GetId()))} }); lcl_dispatchCommand(mxComponent, ".uno:RejectTrackedChange", aPropertyValues); Scheduler::ProcessEventsToIdle(); |