From d5c18dc3e8bb107e8ddf960261bb9257f2e49a35 Mon Sep 17 00:00:00 2001 From: Caolán McNamara Date: Fri, 9 Oct 2015 11:06:56 +0100 Subject: afl-eventtesting: provide a way to pseudo-restart MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit i.e. to reset to the initial post-startup state performance still isn't great unfortunately, 0.7 cycles per second before this, 2.6 after this Change-Id: Ib9d83b70f0cf052af36a49ed5bacef295fe9ed11 Reviewed-on: https://gerrit.libreoffice.org/19269 Tested-by: Jenkins Reviewed-by: Caolán McNamara Tested-by: Caolán McNamara --- desktop/inc/app.hxx | 7 ++++++ desktop/source/app/app.cxx | 59 +++++++++++++++++++++++++++++++++++++++++++++- 2 files changed, 65 insertions(+), 1 deletion(-) (limited to 'desktop') diff --git a/desktop/inc/app.hxx b/desktop/inc/app.hxx index 92577f8b6a0d..cd2856689cab 100644 --- a/desktop/inc/app.hxx +++ b/desktop/inc/app.hxx @@ -27,6 +27,7 @@ #include #include #include +#include #include #include #include @@ -156,6 +157,12 @@ class Desktop : public Application */ void CheckFirstRun( ); + /** for ui-testing provide a mechanism to pseudo-restart by closing the + open frames and reopen the frame that appeared post initial startup + */ + void CloseFrameAndReopen(css::uno::Reference xDesktop); + void DoExecute(css::uno::Reference xDesktop); + /// does initializations which are necessary for the first run of the office static void DoFirstRunInitializations(); diff --git a/desktop/source/app/app.cxx b/desktop/source/app/app.cxx index 58567e99fad5..79b3c86e9f32 100644 --- a/desktop/source/app/app.cxx +++ b/desktop/source/app/app.cxx @@ -23,6 +23,9 @@ #include #include +#if defined UNX +#include +#endif #include "app.hxx" #include "desktop.hrc" @@ -47,6 +50,7 @@ #include #include #include +#include #include #include #include @@ -1270,6 +1274,59 @@ struct ExecuteGlobals static ExecuteGlobals* pExecGlobals = NULL; +#define PERSIST_MAX 100 +unsigned int persist_cnt; + +//This closes the current frame and reopens the initial frame, useful for +//pseudo-restarting, i.e. attempt to effectively reset to the initial state of +//the application post start-up for ui-testing +void Desktop::CloseFrameAndReopen(Reference xDesktop) +{ + Reference xFrame = xDesktop->getActiveFrame(); + Reference xProvider(xFrame, css::uno::UNO_QUERY); + + css::uno::Reference xController = xFrame->getController(); + css::uno::Reference xModel = xController->getModel(); + css::uno::Reference< css::util::XModifiable > xModifiable(xModel, css::uno::UNO_QUERY); + xModifiable->setModified(false); + + css::util::URL aCommand; + aCommand.Complete = ".uno:CloseDoc"; + + css::uno::Reference xContext = ::comphelper::getProcessComponentContext(); + Reference< css::util::XURLTransformer > xParser = css::util::URLTransformer::create(xContext); + xParser->parseStrict(aCommand); + + css::uno::Reference< css::frame::XDispatch > xDispatch = xProvider->queryDispatch(aCommand, OUString(), 0); + xDispatch->dispatch(aCommand, css::uno::Sequence< css::beans::PropertyValue >()); + + OpenDefault(); +} + +//This just calls Execute() for all normal uses of LibreOffice, but for +//ui-testing if AFL_PERSISTENT is set then on exit it will pseudo-restart (up +//to PERSIST_MAX times) +void Desktop::DoExecute(Reference xDesktop) +{ +try_again: + { + Execute(); + /* To signal successful completion of a run, we need to deliver + SIGSTOP to our own process, then loop to the very beginning + once we're resumed by the supervisor process. We do this only + if AFL_PERSISTENT is set to retain normal behavior when the + program is executed directly; and take note of PERSIST_MAX. */ + if (getenv("AFL_PERSISTENT") && persist_cnt++ < PERSIST_MAX) + { + CloseFrameAndReopen(xDesktop); +#if defined UNX + raise(SIGSTOP); +#endif + goto try_again; + } + } +} + int Desktop::Main() { pExecGlobals = new ExecuteGlobals(); @@ -1585,7 +1642,7 @@ int Desktop::Main() // if this run of the office is triggered by restart, some additional actions should be done DoRestartActionsIfNecessary( !rCmdLineArgs.IsInvisible() && !rCmdLineArgs.IsNoQuickstart() ); - Execute(); + DoExecute(xDesktop); } } catch(const css::document::CorruptedFilterConfigurationException& exFilterCfg) -- cgit -1-6+backports'>distro/lhm/libreoffice-4-1-6+backports LibreOffice 核心代码仓库文档基金会
summaryrefslogtreecommitdiff
AgeCommit message (Expand)Author
2019-12-10use scoped enumStephan Bergmann
2019-12-05loplugin:external (clang-cl)Stephan Bergmann
2019-10-23-Werror,-Wdeprecated-volatile (clang-cl)Stephan Bergmann
2019-10-17Remove some memset callsMike Kaganski
2019-06-03tdf#67538 XTypeDetection::queryTypeByDescriptor poor performance, part4Noel Grandin
2019-01-31loplugin:unnecessaryparen (clang-cl)Stephan Bergmann
2018-12-04tdf#34171: check foreign lockfiles to tell who has locked documentMike Kaganski
2018-11-10tdf#120703 PVS: silence a V555Mike Kaganski
2018-09-27tdf#119238: keep replaced file's identity when renaming docfileMike Kaganski
2018-09-24loplugin:external (clang-cl)Stephan Bergmann
2018-08-27directly use malloc/free in sal, instead of rtl_allocateMemory/etcNoel Grandin
2018-08-06Add missing sal/log.hxx headersGabor Kelemen
2018-08-01Replace rtl_cache_alloc/free with rtl_allocate/freeMemoryStephan Bergmann
2018-07-27Related: rhbz#1602589 add comments to coverity annotationsCaolán McNamara
2018-01-23More loplugin:cstylecast on WindowsStephan Bergmann
2017-12-15loplugin:salcall (clang-cl)Stephan Bergmann
2017-11-29loplugin:unnecessaryparen (clang-cl)Stephan Bergmann
2017-10-27-Werror,-Wtautological-constant-compare (clang-cl)Stephan Bergmann
2017-10-05Rename and move SAL_U/W to o3tl::toU/WMike Kaganski
2017-09-18Put back some #include (needed for e.g. --disable-pch)Stephan Bergmann
2017-09-15osl/w32: don't use 8-bit string functionsMike Kaganski
2017-07-18Followup to final followup 647382f52351a75 of my followupChris Sherlock
2017-07-13These arguments can apparently never be nullStephan Bergmann
2017-07-08osl: followup to 7c6ccc42 for w32/unx file.cxxChris Sherlock
2017-07-03loplugin:oncevar (clang-cl): salStephan Bergmann
2017-06-25tdf#43157 - osl: convert OSL_PRECONDs in w32 & unx file.cxxChris Sherlock
2017-06-23osl: w32/file.cxx cleanup signatures of definitionsChris Sherlock
2017-06-23osl: w32/file.cxx normalized LHS/RHS if conditionsChris Sherlock
2017-06-23osl: w32/file.cxx remove extraneous space from around bracesChris Sherlock
2017-06-23osl: w32/file.cxx update commentsChris Sherlock
2017-06-23osl: w32/file.cxx update headersChris Sherlock
2017-06-20new cannot return nullptrNoel Grandin
2017-05-18Revert "Fix typos"Stephan Bergmann
2017-05-18Fix typosAndrea Gelmini
2017-04-04Finally switch MSVC to sal_Unicode = char16_t, tooStephan Bergmann
2017-03-04Change sal/osl/w32/*.h -> *.hxxStephan Bergmann
2017-02-10Remove MinGW supportStephan Bergmann
2016-10-04clang-cl loplugin: salStephan Bergmann
2015-11-12Windows header sanitizationAshod Nakashian
2015-06-23Revert "Typo: iff->if"Julien Nabet
2015-06-23Typo: iff->ifJulien Nabet