summaryrefslogtreecommitdiff
path: root/desktop
diff options
context:
space:
mode:
authorAshod Nakashian <ashod.nakashian@collabora.co.uk>2016-04-23 08:42:30 -0400
committerAshod Nakashian <ashnakash@gmail.com>2016-04-23 13:26:11 +0000
commit548faf728cf097d93c3f6478ceea5f8747e789c6 (patch)
tree43c1296e84ae67c657e787df6153a9d53db2d735 /desktop
parent6ca6f22777eb3651109cbf403577d0022a735c9b (diff)
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 <ashnakash@gmail.com> Tested-by: Ashod Nakashian <ashnakash@gmail.com>
Diffstat (limited to 'desktop')
-rw-r--r--desktop/qa/desktop_lib/test_desktop_lib.cxx19
1 files changed, 17 insertions, 2 deletions
diff --git a/desktop/qa/desktop_lib/test_desktop_lib.cxx b/desktop/qa/desktop_lib/test_desktop_lib.cxx
index 3a0e67b962e6..89b1ebbe20d7 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();