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

afl-eventtesting: there is no focused/active window in headless mode

so close all open frames, not just the active one
and send events to the first discovered visible window and not the focus
window

Change-Id: I7339bc6743cd3106ceddea049136796121819eb3
üst b78d4c65
...@@ -1282,23 +1282,32 @@ unsigned int persist_cnt; ...@@ -1282,23 +1282,32 @@ unsigned int persist_cnt;
//the application post start-up for ui-testing //the application post start-up for ui-testing
void Desktop::CloseFrameAndReopen(Reference<XDesktop2> xDesktop) void Desktop::CloseFrameAndReopen(Reference<XDesktop2> xDesktop)
{ {
Reference<css::frame::XFrame> xFrame = xDesktop->getActiveFrame(); css::uno::Reference<css::container::XIndexAccess> xTaskContainer(
Reference<css::frame::XDispatchProvider> xProvider(xFrame, css::uno::UNO_QUERY); xDesktop->getFrames(), css::uno::UNO_QUERY_THROW);
sal_Int32 c = xTaskContainer->getCount();
for (sal_Int32 i = 0; i < c; ++i)
{
css::uno::Reference< css::frame::XFrame > xFrame;
xTaskContainer->getByIndex(i) >>= xFrame;
if (!xFrame.is())
continue;
Reference<css::frame::XDispatchProvider> xProvider(xFrame, css::uno::UNO_QUERY);
css::uno::Reference<css::frame::XController > xController = xFrame->getController(); css::uno::Reference<css::frame::XController > xController = xFrame->getController();
css::uno::Reference<css::frame::XModel> xModel = xController->getModel(); css::uno::Reference<css::frame::XModel> xModel = xController->getModel();
css::uno::Reference< css::util::XModifiable > xModifiable(xModel, css::uno::UNO_QUERY); css::uno::Reference< css::util::XModifiable > xModifiable(xModel, css::uno::UNO_QUERY);
xModifiable->setModified(false); xModifiable->setModified(false);
css::util::URL aCommand; css::util::URL aCommand;
aCommand.Complete = ".uno:CloseDoc"; aCommand.Complete = ".uno:CloseDoc";
css::uno::Reference<css::uno::XComponentContext> xContext = ::comphelper::getProcessComponentContext(); css::uno::Reference<css::uno::XComponentContext> xContext = ::comphelper::getProcessComponentContext();
Reference< css::util::XURLTransformer > xParser = css::util::URLTransformer::create(xContext); Reference< css::util::XURLTransformer > xParser = css::util::URLTransformer::create(xContext);
xParser->parseStrict(aCommand); xParser->parseStrict(aCommand);
css::uno::Reference< css::frame::XDispatch > xDispatch = xProvider->queryDispatch(aCommand, OUString(), 0); css::uno::Reference< css::frame::XDispatch > xDispatch = xProvider->queryDispatch(aCommand, OUString(), 0);
xDispatch->dispatch(aCommand, css::uno::Sequence< css::beans::PropertyValue >()); xDispatch->dispatch(aCommand, css::uno::Sequence< css::beans::PropertyValue >());
}
OpenDefault(); OpenDefault();
} }
......
...@@ -347,9 +347,16 @@ namespace ...@@ -347,9 +347,16 @@ namespace
{ {
bool InjectKeyEvent(SvStream& rStream) bool InjectKeyEvent(SvStream& rStream)
{ {
VclPtr<vcl::Window> xWin(Application::GetFocusWindow()); if (Application::AnyInput())
if (!xWin) return false;
xWin.reset(Application::GetActiveTopWindow());
VclPtr<vcl::Window> xWin(Application::GetFirstTopLevelWindow());
while (xWin)
{
if (xWin->IsVisible())
break;
xWin.reset(Application::GetNextTopLevelWindow(xWin));
}
if (!xWin) if (!xWin)
return false; return false;
......
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