Kaydet (Commit) b6b8ef25 authored tarafından Caolán McNamara's avatar Caolán McNamara

afl-eventtesting: shutdown cleaner to allow things to deregister

Change-Id: I2dc7c90f1f5a776bb0e6772d2b381116d28dd46f
üst e9fc4129
...@@ -98,8 +98,9 @@ void Desktop::RegisterServices(Reference< XComponentContext > const & context) ...@@ -98,8 +98,9 @@ void Desktop::RegisterServices(Reference< XComponentContext > const & context)
CommandLineArgs& rCmdLine = GetCommandLineArgs(); CommandLineArgs& rCmdLine = GetCommandLineArgs();
// Headless mode for FAT Office, auto cancels any dialogs that popup // Headless mode for FAT Office, auto cancels any dialogs that popup
bool bHeadlessMode = rCmdLine.IsHeadless() && !rCmdLine.IsEventTesting(); if (rCmdLine.IsEventTesting())
if (bHeadlessMode) Application::EnableEventTestingMode();
else if (rCmdLine.IsHeadless())
Application::EnableHeadlessMode(false); Application::EnableHeadlessMode(false);
// read accept string from configuration // read accept string from configuration
......
...@@ -231,7 +231,7 @@ sal_Bool SAL_CALL Desktop::terminate() ...@@ -231,7 +231,7 @@ sal_Bool SAL_CALL Desktop::terminate()
// try to close all open frames. // try to close all open frames.
// Allow using of any UI ... because Desktop.terminate() was designed as UI functionality in the past. // Allow using of any UI ... because Desktop.terminate() was designed as UI functionality in the past.
bool bAllowUI = true; bool bAllowUI = !Application::IsEventTestingModeEnabled();
bool bFramesClosed = impl_closeFrames(bAllowUI); bool bFramesClosed = impl_closeFrames(bAllowUI);
if ( ! bFramesClosed ) if ( ! bFramesClosed )
{ {
......
...@@ -1382,6 +1382,22 @@ public: ...@@ -1382,6 +1382,22 @@ public:
///@} ///@}
/** @name Event Testing Mode
*/
/** Enables event testing mode.
*/
static void EnableEventTestingMode();
/** Determines if event testing mode is enabled
@return True if event testing mode is enabled, false if not.
*/
static bool IsEventTestingModeEnabled();
///@}
/** @name IME Status Window Control /** @name IME Status Window Control
*/ */
///@{ ///@{
......
...@@ -162,6 +162,7 @@ struct ImplSVAppData ...@@ -162,6 +162,7 @@ struct ImplSVAppData
int mnEventTestLimit; int mnEventTestLimit;
DECL_STATIC_LINK_TYPED(ImplSVAppData, ImplQuitMsg, void*, void); DECL_STATIC_LINK_TYPED(ImplSVAppData, ImplQuitMsg, void*, void);
DECL_STATIC_LINK_TYPED(ImplSVAppData, ImplPrepareExitMsg, void*, void);
DECL_STATIC_LINK_TYPED(ImplSVAppData, ImplEndAllDialogsMsg, void*, void); DECL_STATIC_LINK_TYPED(ImplSVAppData, ImplEndAllDialogsMsg, void*, void);
DECL_STATIC_LINK_TYPED(ImplSVAppData, ImplEndAllPopupsMsg, void*, void); DECL_STATIC_LINK_TYPED(ImplSVAppData, ImplEndAllPopupsMsg, void*, void);
DECL_STATIC_LINK_TYPED(ImplSVAppData, ImplVclEventTestingHdl, void*, void); DECL_STATIC_LINK_TYPED(ImplSVAppData, ImplVclEventTestingHdl, void*, void);
......
...@@ -65,7 +65,9 @@ ...@@ -65,7 +65,9 @@
#include "com/sun/star/uno/Reference.h" #include "com/sun/star/uno/Reference.h"
#include "com/sun/star/awt/XToolkit.hpp" #include "com/sun/star/awt/XToolkit.hpp"
#include <com/sun/star/frame/Desktop.hpp>
#include "com/sun/star/uno/XNamingService.hpp" #include "com/sun/star/uno/XNamingService.hpp"
#include <com/sun/star/util/XModifiable.hpp>
#include "com/sun/star/lang/XMultiServiceFactory.hpp" #include "com/sun/star/lang/XMultiServiceFactory.hpp"
#include "comphelper/solarmutex.hxx" #include "comphelper/solarmutex.hxx"
#include "osl/process.h" #include "osl/process.h"
...@@ -359,7 +361,7 @@ void Application::EndAllPopups() ...@@ -359,7 +361,7 @@ void Application::EndAllPopups()
namespace namespace
{ {
bool InjectKeyEvent(SvStream& rStream) VclPtr<vcl::Window> GetEventWindow()
{ {
VclPtr<vcl::Window> xWin(Application::GetFirstTopLevelWindow()); VclPtr<vcl::Window> xWin(Application::GetFirstTopLevelWindow());
while (xWin) while (xWin)
...@@ -368,6 +370,12 @@ namespace ...@@ -368,6 +370,12 @@ namespace
break; break;
xWin.reset(Application::GetNextTopLevelWindow(xWin)); xWin.reset(Application::GetNextTopLevelWindow(xWin));
} }
return xWin;
}
bool InjectKeyEvent(SvStream& rStream)
{
VclPtr<vcl::Window> xWin(GetEventWindow());
if (!xWin) if (!xWin)
return false; return false;
...@@ -398,6 +406,7 @@ namespace ...@@ -398,6 +406,7 @@ namespace
{ {
Application::EndAllPopups(); Application::EndAllPopups();
Application::EndAllDialogs(); Application::EndAllDialogs();
Application::PostUserEvent( LINK( NULL, ImplSVAppData, ImplPrepareExitMsg ) );
Application::Quit(); Application::Quit();
} }
} }
...@@ -437,16 +446,19 @@ IMPL_STATIC_LINK_NOARG_TYPED( ImplSVAppData, ImplVclEventTestingHdl, void*, void ...@@ -437,16 +446,19 @@ IMPL_STATIC_LINK_NOARG_TYPED( ImplSVAppData, ImplVclEventTestingHdl, void*, void
} }
} }
IMPL_STATIC_LINK_NOARG_TYPED( ImplSVAppData, ImplPrepareExitMsg, void*, void )
{
//now close top level frames
(void)GetpApp()->QueryExit();
}
void Application::Execute() void Application::Execute()
{ {
ImplSVData* pSVData = ImplGetSVData(); ImplSVData* pSVData = ImplGetSVData();
pSVData->maAppData.mbInAppExecute = true; pSVData->maAppData.mbInAppExecute = true;
pSVData->maAppData.mbAppQuit = false; pSVData->maAppData.mbAppQuit = false;
sal_uInt16 n = GetCommandLineParamCount(); if (Application::IsEventTestingModeEnabled())
for (sal_uInt16 i = 0; i != n; ++i)
{
if (GetCommandLineParam(i) == "--eventtesting")
{ {
pSVData->maAppData.mnEventTestLimit = 50; pSVData->maAppData.mnEventTestLimit = 50;
pSVData->maAppData.mpEventTestingIdle = new Idle("eventtesting"); pSVData->maAppData.mpEventTestingIdle = new Idle("eventtesting");
...@@ -454,8 +466,6 @@ void Application::Execute() ...@@ -454,8 +466,6 @@ void Application::Execute()
pSVData->maAppData.mpEventTestingIdle->SetPriority(SchedulerPriority::MEDIUM); pSVData->maAppData.mpEventTestingIdle->SetPriority(SchedulerPriority::MEDIUM);
pSVData->maAppData.mpEventTestInput = new SvFileStream("eventtesting", StreamMode::READ); pSVData->maAppData.mpEventTestInput = new SvFileStream("eventtesting", StreamMode::READ);
pSVData->maAppData.mpEventTestingIdle->Start(); pSVData->maAppData.mpEventTestingIdle->Start();
break;
}
} }
while ( !pSVData->maAppData.mbAppQuit ) while ( !pSVData->maAppData.mbAppQuit )
...@@ -1655,6 +1665,18 @@ void Application::EnableConsoleOnly() ...@@ -1655,6 +1665,18 @@ void Application::EnableConsoleOnly()
bConsoleOnly = true; bConsoleOnly = true;
} }
static bool bEventTestingMode = false;
bool Application::IsEventTestingModeEnabled()
{
return bEventTestingMode;
}
void Application::EnableEventTestingMode()
{
bEventTestingMode = true;
}
void Application::ShowNativeErrorBox(const OUString& sTitle , void Application::ShowNativeErrorBox(const OUString& sTitle ,
const OUString& sMessage) const OUString& sMessage)
{ {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment