summaryrefslogtreecommitdiff
path: root/desktop
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@collabora.co.uk>2016-01-19 16:30:59 +0100
committerMiklos Vajna <vmiklos@collabora.co.uk>2016-01-19 16:45:53 +0100
commitcdf08b3aa74bb32ea18b583a9c0c41b91d7819ac (patch)
treec9f5f531b2eb73d283631ab399de088298f6d923 /desktop
parentabbfbb4d35d6fa9edbb8f331a9d9503183eb0356 (diff)
CppunitTest_desktop_lib: add ModifiedStatus callback testcase
Change-Id: Ieb7e808ebc7619c3a4a013cad776eeefd6163e22
Diffstat (limited to 'desktop')
-rw-r--r--desktop/qa/desktop_lib/test_desktop_lib.cxx43
1 files changed, 42 insertions, 1 deletions
diff --git a/desktop/qa/desktop_lib/test_desktop_lib.cxx b/desktop/qa/desktop_lib/test_desktop_lib.cxx
index d55ae37b6606..75b4f6469af0 100644
--- a/desktop/qa/desktop_lib/test_desktop_lib.cxx
+++ b/desktop/qa/desktop_lib/test_desktop_lib.cxx
@@ -15,6 +15,7 @@
#include <com/sun/star/awt/XReschedule.hpp>
#include <com/sun/star/awt/Toolkit.hpp>
#include <com/sun/star/drawing/XDrawPageSupplier.hpp>
+#include <com/sun/star/util/XModifiable.hpp>
#include <boost/property_tree/json_parser.hpp>
#include <comphelper/processfactory.hxx>
#include <sfx2/objsh.hxx>
@@ -39,7 +40,8 @@ class DesktopLOKTest : public UnoApiTest
public:
DesktopLOKTest() : UnoApiTest("/desktop/qa/data/"),
m_nSelectionBeforeSearchResult(0),
- m_nSelectionAfterSearchResult(0)
+ m_nSelectionAfterSearchResult(0),
+ m_bModified(false)
{
}
@@ -80,6 +82,7 @@ public:
void testCellCursor();
void testCommandResult();
void testWriterComments();
+ void testModifiedStatus();
CPPUNIT_TEST_SUITE(DesktopLOKTest);
CPPUNIT_TEST(testGetStyles);
@@ -98,6 +101,7 @@ public:
CPPUNIT_TEST(testCellCursor);
CPPUNIT_TEST(testCommandResult);
CPPUNIT_TEST(testWriterComments);
+ CPPUNIT_TEST(testModifiedStatus);
CPPUNIT_TEST_SUITE_END();
uno::Reference<lang::XComponent> mxComponent;
@@ -110,6 +114,10 @@ public:
// for testCommandResult
osl::Condition m_aCommandResultCondition;
OString m_aCommandResult;
+
+ // for testModifiedStatus
+ osl::Condition m_aStateChangedCondition;
+ bool m_bModified;
};
LibLODocument_Impl* DesktopLOKTest::loadDoc(const char* pName, LibreOfficeKitDocumentType eType)
@@ -183,6 +191,17 @@ void DesktopLOKTest::callbackImpl(int nType, const char* pPayload)
m_aCommandResultCondition.set();
}
break;
+ case LOK_CALLBACK_STATE_CHANGED:
+ {
+ OString aPayload(pPayload);
+ OString aPrefix(".uno:ModifiedStatus=");
+ if (aPayload.startsWith(aPrefix))
+ {
+ m_bModified = aPayload.copy(aPrefix.getLength()).toBoolean();
+ m_aStateChangedCondition.set();
+ }
+ }
+ break;
}
}
@@ -600,6 +619,28 @@ void DesktopLOKTest::testWriterComments()
comphelper::LibreOfficeKit::setActive(false);
}
+void DesktopLOKTest::testModifiedStatus()
+{
+ LibLibreOffice_Impl aOffice;
+ comphelper::LibreOfficeKit::setActive();
+ LibLODocument_Impl* pDocument = loadDoc("blank_text.odt");
+ pDocument->pClass->initializeForRendering(pDocument, nullptr);
+ pDocument->pClass->registerCallback(pDocument, &DesktopLOKTest::callback, this);
+
+ // Set the document as modified.
+ m_aStateChangedCondition.reset();
+ uno::Reference<util::XModifiable> xModifiable(mxComponent, uno::UNO_QUERY);
+ xModifiable->setModified(true);
+ TimeValue aTimeValue = { 2 , 0 }; // 2 seconds max
+ m_aStateChangedCondition.wait(aTimeValue);
+ Scheduler::ProcessEventsToIdle();
+
+ // This was false, there was no callback about the modified status change.
+ CPPUNIT_ASSERT(m_bModified);
+
+ comphelper::LibreOfficeKit::setActive(false);
+}
+
CPPUNIT_TEST_SUITE_REGISTRATION(DesktopLOKTest);
CPPUNIT_PLUGIN_IMPLEMENT();