desktop/qa/desktop_lib/test_desktop_lib.cxx | 46 ++++++++++++++++++++++++++-- sfx2/source/control/bindings.cxx | 4 +- 2 files changed, 46 insertions(+), 4 deletions(-)
New commits: commit e32607559b48523215a8524504fc6faa893c342a Author: Miklos Vajna <vmik...@collabora.co.uk> Date: Tue Jan 19 16:30:59 2016 +0100 CppunitTest_desktop_lib: add ModifiedStatus callback testcase (cherry picked from commit cdf08b3aa74bb32ea18b583a9c0c41b91d7819ac) Change-Id: Ieb7e808ebc7619c3a4a013cad776eeefd6163e22 Reviewed-on: https://gerrit.libreoffice.org/24725 Reviewed-by: Ashod Nakashian <ashnak...@gmail.com> Tested-by: Ashod Nakashian <ashnak...@gmail.com> diff --git a/desktop/qa/desktop_lib/test_desktop_lib.cxx b/desktop/qa/desktop_lib/test_desktop_lib.cxx index 4009920..829563d 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> #ifdef WNT #include <prewin.h> @@ -47,7 +48,8 @@ class DesktopLOKTest : public UnoApiTest public: DesktopLOKTest() : UnoApiTest("/desktop/qa/data/"), m_nSelectionBeforeSearchResult(0), - m_nSelectionAfterSearchResult(0) + m_nSelectionAfterSearchResult(0), + m_bModified(false) { } @@ -99,9 +101,9 @@ public: void testHiddenRowHeaders(); void testCommandResult(); void testWriterComments(); + void testModifiedStatus(); void testSheetOperations(); void testNotificationCompression(); - CPPUNIT_TEST_SUITE(DesktopLOKTest); CPPUNIT_TEST(testGetStyles); CPPUNIT_TEST(testGetFonts); @@ -120,6 +122,7 @@ public: CPPUNIT_TEST(testHiddenRowHeaders); CPPUNIT_TEST(testCommandResult); CPPUNIT_TEST(testWriterComments); + CPPUNIT_TEST(testModifiedStatus); CPPUNIT_TEST(testSheetOperations); CPPUNIT_TEST(testNotificationCompression); CPPUNIT_TEST_SUITE_END(); @@ -134,6 +137,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) @@ -207,6 +214,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; } } @@ -365,7 +383,7 @@ void DesktopLOKTest::testSearchAllNotificationsCalc() {"SearchItem.Command", uno::makeAny(static_cast<sal_uInt16>(SvxSearchCmd::FIND_ALL))}, })); comphelper::dispatchCommand(".uno:ExecuteSearch", aPropertyValues); - flushTimers(); + Scheduler::ProcessEventsToIdle(); // This was 1, make sure that we get no notifications about selection changes during search. CPPUNIT_ASSERT_EQUAL(0, m_nSelectionBeforeSearchResult); @@ -665,6 +683,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); +} + void DesktopLOKTest::testSheetOperations() { comphelper::LibreOfficeKit::setActive(true); diff --git a/sfx2/source/control/bindings.cxx b/sfx2/source/control/bindings.cxx index cf4c8a8..45465fa 100644 --- a/sfx2/source/control/bindings.cxx +++ b/sfx2/source/control/bindings.cxx @@ -1593,7 +1593,9 @@ bool SfxBindings::NextJob_Impl(Timer * pTimer) } // if possible Update all server / happens in its own time slice - if ( pImp->bMsgDirty ) + // but process all events at once when unit testing, for reliability reasons + static bool bTest = getenv("LO_TESTNAME"); + if ( pImp->bMsgDirty && !bTest ) { UpdateSlotServer_Impl(); return false; _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits