Add a test for setAllowChangeComments function.
This is a follow up for: * https://gerrit.libreoffice.org/c/core/+/164570/2 Signed-off-by: Gökay Şatır <gokaysatir@gmail.com> Change-Id: If748aac779767174d14dde33efab62d980b115ff Reviewed-on: https://gerrit.libreoffice.org/c/core/+/172114 Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com> Reviewed-by: Miklos Vajna <vmiklos@collabora.com> Reviewed-on: https://gerrit.libreoffice.org/c/core/+/176287 Tested-by: Jenkins
This commit is contained in:
parent
d8e7a3b245
commit
90ab893c55
2 changed files with 69 additions and 1 deletions
|
@ -192,6 +192,7 @@ public:
|
|||
void testCommentsImpress();
|
||||
void testCommentsCallbacksWriter();
|
||||
void testCommentsAddEditDeleteDraw();
|
||||
void testCommentsInReadOnlyMode();
|
||||
void testRunMacro();
|
||||
void testExtractParameter();
|
||||
void testGetSignatureState_NonSigned();
|
||||
|
@ -262,6 +263,7 @@ public:
|
|||
CPPUNIT_TEST(testCommentsImpress);
|
||||
CPPUNIT_TEST(testCommentsCallbacksWriter);
|
||||
CPPUNIT_TEST(testCommentsAddEditDeleteDraw);
|
||||
CPPUNIT_TEST(testCommentsInReadOnlyMode);
|
||||
CPPUNIT_TEST(testRunMacro);
|
||||
CPPUNIT_TEST(testExtractParameter);
|
||||
CPPUNIT_TEST(testGetSignatureState_Signed);
|
||||
|
@ -2665,6 +2667,72 @@ void DesktopLOKTest::testCommentsAddEditDeleteDraw()
|
|||
CPPUNIT_ASSERT_EQUAL(nCommentId1, aView1.m_aCommentCallbackResult.get<int>("id"));
|
||||
}
|
||||
|
||||
void DesktopLOKTest::testCommentsInReadOnlyMode()
|
||||
{
|
||||
// Comments callback are emitted only if tiled annotations are off
|
||||
comphelper::LibreOfficeKit::setTiledAnnotations(false);
|
||||
LibLODocument_Impl* pDocument = loadDoc("blank_text.odt");
|
||||
|
||||
int viewId = pDocument->m_pDocumentClass->createView(pDocument);
|
||||
pDocument->m_pDocumentClass->setView(pDocument, viewId);
|
||||
|
||||
pDocument->m_pDocumentClass->initializeForRendering(pDocument, "{\".uno:Author\":{\"type\":\"string\",\"value\":\"LOK User1\"}}");
|
||||
|
||||
SfxLokHelper::setViewReadOnly(viewId, true);
|
||||
SfxLokHelper::setAllowChangeComments(viewId, true);
|
||||
|
||||
Scheduler::ProcessEventsToIdle();
|
||||
|
||||
ViewCallback aView(pDocument);
|
||||
|
||||
// Add a new comment
|
||||
OString aCommandArgs;
|
||||
{
|
||||
tools::JsonWriter aJson;
|
||||
addParameter(aJson, "Text", "string", "Comment");
|
||||
addParameter(aJson, "Author", "string", "LOK User1");
|
||||
aCommandArgs = aJson.finishAndGetAsOString();
|
||||
}
|
||||
|
||||
pDocument->pClass->postUnoCommand(pDocument, ".uno:InsertAnnotation", aCommandArgs.getStr(), false);
|
||||
Scheduler::ProcessEventsToIdle();
|
||||
|
||||
// We received a LOK_CALLBACK_COMMENT callback with comment 'Add' action
|
||||
CPPUNIT_ASSERT_EQUAL(std::string("Add"), aView.m_aCommentCallbackResult.get<std::string>("action"));
|
||||
int nCommentId = aView.m_aCommentCallbackResult.get<int>("id");
|
||||
|
||||
// Edit the previously added comment
|
||||
{
|
||||
tools::JsonWriter aJson;
|
||||
addParameter(aJson, "Id", "string", OString::number(nCommentId));
|
||||
addParameter(aJson, "Text", "string", "Edited comment");
|
||||
aCommandArgs = aJson.finishAndGetAsOString();
|
||||
}
|
||||
|
||||
pDocument->pClass->postUnoCommand(pDocument, ".uno:EditAnnotation", aCommandArgs.getStr(), false);
|
||||
Scheduler::ProcessEventsToIdle();
|
||||
|
||||
// We received a LOK_CALLBACK_COMMENT callback with comment 'Modify' action
|
||||
CPPUNIT_ASSERT_EQUAL(std::string("Modify"), aView.m_aCommentCallbackResult.get<std::string>("action"));
|
||||
CPPUNIT_ASSERT_EQUAL(nCommentId, aView.m_aCommentCallbackResult.get<int>("id"));
|
||||
|
||||
// Delete Comment
|
||||
{
|
||||
tools::JsonWriter aJson;
|
||||
addParameter(aJson, "Id", "string", OString::number(nCommentId));
|
||||
aCommandArgs = aJson.finishAndGetAsOString();
|
||||
}
|
||||
pDocument->pClass->postUnoCommand(pDocument, ".uno:DeleteAnnotation", aCommandArgs.getStr(), false);
|
||||
Scheduler::ProcessEventsToIdle();
|
||||
|
||||
// Result is not sent for delete operation for some reason. But it is sent when debugging with online.
|
||||
// TODO: Enable below 2 checks.
|
||||
|
||||
// We received a LOK_CALLBACK_COMMENT callback with comment 'Remove' action
|
||||
//CPPUNIT_ASSERT_EQUAL(std::string("Remove"), aView.m_aCommentCallbackResult.get<std::string>("action"));
|
||||
//CPPUNIT_ASSERT_EQUAL(nCommentId, aView.m_aCommentCallbackResult.get<int>("id"));
|
||||
}
|
||||
|
||||
void DesktopLOKTest::testRunMacro()
|
||||
{
|
||||
LibLibreOffice_Impl aOffice;
|
||||
|
|
|
@ -1635,7 +1635,7 @@ bool SfxDispatcher::FindServer_(sal_uInt16 nSlot, SfxSlotServer& rServer)
|
|||
|
||||
// This check can be true only if Lokit is active and view is readonly.
|
||||
if (pSlot && bCheckForCommentCommands)
|
||||
bReadOnly = IsCommandAllowedInLokReadOnlyViewMode(pSlot->GetCommand());
|
||||
bReadOnly = !IsCommandAllowedInLokReadOnlyViewMode(pSlot->GetCommand());
|
||||
|
||||
if ( pSlot && pSlot->nDisableFlags != SfxDisableFlags::NONE &&
|
||||
( static_cast<int>(pSlot->nDisableFlags) & static_cast<int>(pObjShell->GetDisableFlags()) ) != 0 )
|
||||
|
|
Loading…
Reference in a new issue