a11y tests: Don't rely on XWindow being window's XAccessible
See
commit ed03c63f00
Author: Michael Weghorn <m.weghorn@posteo.de>
Date: Thu May 22 09:45:02 2025 +0100
wina11y: Don't rely on win accessible being VCLXWindow
for more background.
Change-Id: I19a01f9715536918dd9463f18a72c22878d0cd7c
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/185836
Tested-by: Jenkins
Reviewed-by: Michael Weghorn <m.weghorn@posteo.de>
This commit is contained in:
@@ -111,8 +111,12 @@ uno::Reference<accessibility::XAccessibleContext>
|
||||
test::AccessibleTestBase::getDocumentAccessibleContext()
|
||||
{
|
||||
uno::Reference<frame::XModel> xModel(mxDocument, uno::UNO_QUERY_THROW);
|
||||
uno::Reference<accessibility::XAccessible> xAccessible(
|
||||
xModel->getCurrentController()->getFrame()->getComponentWindow(), uno::UNO_QUERY_THROW);
|
||||
uno::Reference<css::awt::XWindow> xComponentWin
|
||||
= xModel->getCurrentController()->getFrame()->getComponentWindow();
|
||||
assert(xComponentWin.is());
|
||||
uno::Reference<accessibility::XAccessible> xAccessible
|
||||
= VCLUnoHelper::GetWindow(xComponentWin)->GetAccessible();
|
||||
assert(xAccessible.is());
|
||||
|
||||
return AccessibilityTools::getAccessibleObjectForPredicate(
|
||||
xAccessible->getAccessibleContext(),
|
||||
@@ -480,7 +484,10 @@ test::AccessibleTestBase::Dialog::Dialog(const uno::Reference<awt::XDialog2>& xD
|
||||
{
|
||||
CPPUNIT_ASSERT(xDialog2.is());
|
||||
|
||||
mxAccessible.set(xDialog2, uno::UNO_QUERY);
|
||||
uno::Reference<css::awt::XWindow> xWindow(xDialog2, uno::UNO_QUERY_THROW);
|
||||
vcl::Window* pWindow = VCLUnoHelper::GetWindow(xWindow);
|
||||
assert(pWindow);
|
||||
mxAccessible = pWindow->GetAccessible();
|
||||
if (mxAccessible)
|
||||
setWindow(mxAccessible);
|
||||
else
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
|
||||
#include <sfx2/lokhelper.hxx>
|
||||
#include <test/a11y/AccessibilityTools.hxx>
|
||||
#include <toolkit/awt/vclxwindow.hxx>
|
||||
#include <vcl/accessibility/vclxaccessiblecomponent.hxx>
|
||||
|
||||
void test::EventPosterHelper::postKeyEventAsync(int nType, int nCharCode, int nKeyCode) const
|
||||
{
|
||||
@@ -32,15 +32,20 @@ void test::AccessibleEventPosterHelper::setWindow(
|
||||
{
|
||||
while (auto xParent = xAcc->getAccessibleContext()->getAccessibleParent())
|
||||
xAcc = xParent;
|
||||
auto vclXWindow = dynamic_cast<VCLXWindow*>(xAcc.get());
|
||||
if (!vclXWindow)
|
||||
assert(xAcc);
|
||||
css::uno::Reference<css::accessibility::XAccessibleContext> xAccContext
|
||||
= xAcc->getAccessibleContext();
|
||||
assert(xAccContext.is());
|
||||
rtl::Reference<VCLXAccessibleComponent> pVCLAccComponent
|
||||
= dynamic_cast<VCLXAccessibleComponent*>(xAccContext.get());
|
||||
if (!pVCLAccComponent)
|
||||
{
|
||||
std::cerr << "WARNING: AccessibleEventPosterHelper::setWindow() called on "
|
||||
"unsupported object "
|
||||
<< AccessibilityTools::debugString(xAcc) << ". Event delivery will not work."
|
||||
<< std::endl;
|
||||
}
|
||||
mxWindow = vclXWindow ? vclXWindow->GetWindow() : nullptr;
|
||||
mxWindow = pVCLAccComponent ? pVCLAccComponent->GetWindow() : nullptr;
|
||||
}
|
||||
|
||||
/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */
|
||||
|
||||
Reference in New Issue
Block a user