make testCondFormatFormulaListenerXLSX reliable
Change-Id: Ibd8c9b7831af73967229c578b9dcf7217d800610 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/157686 Tested-by: Jenkins Tested-by: Caolán McNamara <caolan.mcnamara@collabora.com> Reviewed-by: Caolán McNamara <caolan.mcnamara@collabora.com>
This commit is contained in:
34
include/test/idletask.hxx
Normal file
34
include/test/idletask.hxx
Normal file
@@ -0,0 +1,34 @@
|
||||
/* -*- 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/.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <sal/config.h>
|
||||
#include <test/testdllapi.hxx>
|
||||
#include <vcl/idle.hxx>
|
||||
|
||||
//IdleTask class to add a low priority Idle task
|
||||
class OOO_DLLPUBLIC_TEST IdleTask
|
||||
{
|
||||
public:
|
||||
bool GetFlag() const;
|
||||
IdleTask();
|
||||
|
||||
// Launch an Idle at TaskPriority::LOWEST and wait until it completes. Can
|
||||
// be used to wait until pending Idles at higher TaskPriority::DEFAULT_IDLE
|
||||
// have completed.
|
||||
static void waitUntilIdleDispatched();
|
||||
|
||||
private:
|
||||
DECL_LINK(FlipFlag, Timer*, void);
|
||||
bool flag;
|
||||
Idle maIdle{ "testtool IdleTask" };
|
||||
};
|
||||
|
||||
/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */
|
@@ -50,6 +50,7 @@
|
||||
#include <unotools/syslocaleoptions.hxx>
|
||||
#include "helper/qahelper.hxx"
|
||||
#include <officecfg/Office/Common.hxx>
|
||||
#include <test/idletask.hxx>
|
||||
|
||||
using namespace ::com::sun::star;
|
||||
using namespace ::com::sun::star::uno;
|
||||
@@ -420,7 +421,7 @@ CPPUNIT_TEST_FIXTURE(ScFiltersTest3, testCondFormatFormulaListenerXLSX)
|
||||
pDoc->SetDocVisible(true);
|
||||
pDoc->SetValue(0, 0, 0, 2.0);
|
||||
|
||||
Scheduler::ProcessEventsToIdle();
|
||||
IdleTask::waitUntilIdleDispatched();
|
||||
|
||||
CPPUNIT_ASSERT(aListener.mbCalled);
|
||||
}
|
||||
@@ -442,7 +443,7 @@ CPPUNIT_TEST_FIXTURE(ScFiltersTest3, testTdf131471)
|
||||
pDoc->SetDocVisible(true);
|
||||
pDoc->SetValue(0, 0, 0, 1.0);
|
||||
|
||||
Scheduler::ProcessEventsToIdle();
|
||||
IdleTask::waitUntilIdleDispatched();
|
||||
|
||||
CPPUNIT_ASSERT(aListener.mbCalled);
|
||||
}
|
||||
|
@@ -71,6 +71,7 @@
|
||||
#include <unotxdoc.hxx>
|
||||
#include <rootfrm.hxx>
|
||||
#include <officecfg/Office/Writer.hxx>
|
||||
#include <test/idletask.hxx>
|
||||
|
||||
namespace
|
||||
{
|
||||
@@ -2271,55 +2272,11 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest7, testDde)
|
||||
#endif
|
||||
}
|
||||
|
||||
namespace
|
||||
{
|
||||
//IdleTask class to add a low priority Idle task
|
||||
class IdleTask
|
||||
{
|
||||
public:
|
||||
bool GetFlag() const;
|
||||
IdleTask();
|
||||
DECL_LINK(FlipFlag, Timer*, void);
|
||||
|
||||
private:
|
||||
bool flag;
|
||||
Idle maIdle{ "sw uiwriter IdleTask" };
|
||||
};
|
||||
}
|
||||
|
||||
//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;
|
||||
}
|
||||
|
||||
CPPUNIT_TEST_FIXTURE(SwUiWriterTest7, testDocModState)
|
||||
{
|
||||
//creating a new writer document via the XDesktop(to have more shells etc.)
|
||||
createSwDoc();
|
||||
SwDoc* pDoc = getSwDoc();
|
||||
//creating instance of IdleTask Class
|
||||
IdleTask idleTask;
|
||||
//checking the state of the document via IDocumentState
|
||||
IDocumentState& rState(pDoc->getIDocumentState());
|
||||
//the state should not be modified
|
||||
@@ -2327,12 +2284,9 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest7, testDocModState)
|
||||
//checking the state of the document via SfxObjectShell
|
||||
SwDocShell* pShell(pDoc->GetDocShell());
|
||||
CPPUNIT_ASSERT(!(pShell->IsModified()));
|
||||
//looping around yield until low priority idle task is dispatched and flag is flipped
|
||||
while (!idleTask.GetFlag())
|
||||
{
|
||||
//dispatching all the events via VCL main-loop
|
||||
Application::Yield();
|
||||
}
|
||||
|
||||
IdleTask::waitUntilIdleDispatched();
|
||||
|
||||
//again checking for the state via IDocumentState
|
||||
CPPUNIT_ASSERT(!(rState.IsModified()));
|
||||
//again checking for the state via SfxObjectShell
|
||||
|
@@ -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 \
|
||||
|
50
test/source/idletask.cxx
Normal file
50
test/source/idletask.cxx
Normal file
@@ -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 <test/idletask.hxx>
|
||||
#include <vcl/svapp.hxx>
|
||||
|
||||
//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: */
|
Reference in New Issue
Block a user