desktop/qa/desktop_lib/test_desktop_lib.cxx | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-)
New commits: commit 548faf728cf097d93c3f6478ceea5f8747e789c6 Author: Ashod Nakashian <ashod.nakash...@collabora.co.uk> Date: Sat Apr 23 08:42:30 2016 -0400 Fixed desktop unit-tests Since desktop now queues up callback notifications and flushes them to the client on idle, the unit-tests must yield and process all tasks before they validate post-conditions. Change-Id: I78307db29a9ce647ffaed3539f953227c605968e Reviewed-on: https://gerrit.libreoffice.org/24313 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 3a0e67b..89b1ebb 100644 --- a/desktop/qa/desktop_lib/test_desktop_lib.cxx +++ b/desktop/qa/desktop_lib/test_desktop_lib.cxx @@ -71,6 +71,16 @@ public: void closeDoc(); static void callback(int nType, const char* pPayload, void* pData); void callbackImpl(int nType, const char* pPayload); + void flushTimers() + { + // Need these to make sure idle tasks are also invoked. + // Yielding once is not enough since there are higher + // priority timers that take precedence over idle. + for (auto i = 0; i < 10; ++i) + { + Application::Reschedule(true); + } + } void testGetStyles(); void testGetFonts(); @@ -315,7 +325,9 @@ void DesktopLOKTest::testSearchCalc() {"SearchItem.Backward", uno::makeAny(false)}, {"SearchItem.Command", uno::makeAny(static_cast<sal_uInt16>(SvxSearchCmd::FIND_ALL))}, })); + comphelper::dispatchCommand(".uno:ExecuteSearch", aPropertyValues); + flushTimers(); std::vector<OString> aSelections; sal_Int32 nIndex = 0; @@ -349,8 +361,7 @@ void DesktopLOKTest::testSearchAllNotificationsCalc() {"SearchItem.Command", uno::makeAny(static_cast<sal_uInt16>(SvxSearchCmd::FIND_ALL))}, })); comphelper::dispatchCommand(".uno:ExecuteSearch", aPropertyValues); - Application::Reschedule(true); - Scheduler::ProcessTaskScheduling(false); + flushTimers(); // This was 1, make sure that we get no notifications about selection changes during search. CPPUNIT_ASSERT_EQUAL(0, m_nSelectionBeforeSearchResult); @@ -569,6 +580,7 @@ void DesktopLOKTest::testCommandResult() // the condition var. m_aCommandResultCondition.reset(); pDocument->pClass->postUnoCommand(pDocument, ".uno:Bold", 0, true); + flushTimers(); m_aCommandResultCondition.wait(&aTimeValue); CPPUNIT_ASSERT(m_aCommandResult.isEmpty()); @@ -578,6 +590,7 @@ void DesktopLOKTest::testCommandResult() m_aCommandResultCondition.reset(); pDocument->pClass->postUnoCommand(pDocument, ".uno:Bold", 0, true); + flushTimers(); m_aCommandResultCondition.wait(&aTimeValue); boost::property_tree::ptree aTree; @@ -600,6 +613,8 @@ void DesktopLOKTest::testWriterComments() TimeValue aTimeValue = {2 , 0}; // 2 seconds max m_aCommandResultCondition.reset(); pDocument->pClass->postUnoCommand(pDocument, ".uno:InsertAnnotation", nullptr, true); + flushTimers(); + m_aCommandResultCondition.wait(&aTimeValue); CPPUNIT_ASSERT(!m_aCommandResult.isEmpty()); xToolkit->reschedule(); _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits