From 9a02f4ed071f15908624fb1cafcf6dbb72b00a1b Mon Sep 17 00:00:00 2001 From: Caolán McNamara Date: Sun, 8 Oct 2023 14:33:38 +0100 Subject: make testCondFormatFormulaListenerXLSX reliable MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change-Id: Ibd8c9b7831af73967229c578b9dcf7217d800610 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/157686 Tested-by: Jenkins Tested-by: Caolán McNamara Reviewed-by: Caolán McNamara --- test/Library_test.mk | 1 + test/source/idletask.cxx | 50 ++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 51 insertions(+) create mode 100644 test/source/idletask.cxx (limited to 'test') diff --git a/test/Library_test.mk b/test/Library_test.mk index 268a68744eaf..951ddf6edab2 100644 --- a/test/Library_test.mk +++ b/test/Library_test.mk @@ -50,6 +50,7 @@ $(eval $(call gb_Library_add_exception_objects,test,\ test/source/callgrind \ test/source/xmltesttools \ test/source/htmltesttools \ + test/source/idletask \ test/source/screenshot_test \ test/source/unoapi_property_testers \ test/source/lokcallback \ diff --git a/test/source/idletask.cxx b/test/source/idletask.cxx new file mode 100644 index 000000000000..904d98eb1e24 --- /dev/null +++ b/test/source/idletask.cxx @@ -0,0 +1,50 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + */ + +#include +#include + +//constructor of IdleTask Class +IdleTask::IdleTask() + : flag(false) +{ + //setting the Priority of Idle task to LOW, LOWEST + maIdle.SetPriority(TaskPriority::LOWEST); + //set idle for callback + maIdle.SetInvokeHandler(LINK(this, IdleTask, FlipFlag)); + //starting the idle + maIdle.Start(); +} + +//GetFlag() of IdleTask Class +bool IdleTask::GetFlag() const +{ + //returning the status of current flag + return flag; +} + +//Callback function of IdleTask Class +IMPL_LINK(IdleTask, FlipFlag, Timer*, , void) +{ + //setting the flag to make sure that low priority idle task has been dispatched + flag = true; +} + +void IdleTask::waitUntilIdleDispatched() +{ + //creating instance of IdleTask Class + IdleTask idleTask; + while (!idleTask.GetFlag()) + { + //dispatching all the events via VCL main-loop + Application::Yield(); + } +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */ -- cgit